From 1f947d9e64427b81fffea6a329421d91c2993b8e Mon Sep 17 00:00:00 2001 From: Dio Joestar Date: Sun, 10 Aug 2014 21:06:50 +0200 Subject: [PATCH] Console released SteamCMD uses the new console --- Documentation/Changelog.txt | 7 +- README.md | 5 +- Source Code/SteamCMD GUI/ApplicationEvents.vb | 1 + Source Code/SteamCMD GUI/MainMenu.Designer.vb | 4 +- Source Code/SteamCMD GUI/MainMenu.vb | 159 ++++++++++-------- .../SteamCMD GUI/My Project/AssemblyInfo.vb | 4 +- 6 files changed, 103 insertions(+), 77 deletions(-) create mode 100644 Source Code/SteamCMD GUI/ApplicationEvents.vb diff --git a/Documentation/Changelog.txt b/Documentation/Changelog.txt index 3e40f22..18ac512 100644 --- a/Documentation/Changelog.txt +++ b/Documentation/Changelog.txt @@ -1,4 +1,7 @@ - Version 3.0.0.1 (Not Released/Unstable) + Version 3.0.0.2 +- SteamCMD uses the new console + + Version 3.0.0.1 (Not Released/Unstable) - Improved Codestyle / Code formatting ~ By Giswald @ GitHub  Version 3.0.0.0 (Not Released/Unstable) @@ -69,4 +72,4 @@ - Added an input to choose the path where is located the file steamcmd.exe Version 1 -- Release +- Release \ No newline at end of file diff --git a/README.md b/README.md index 55f0ec6..91d92d8 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,8 @@ SteamCMD GUI by Dio Joestar is licensed under a [Creative Commons Attribution-No Last Changes ============ -######Version 2.1.1.2 -* Added Alien Swarm, Dota 2, and Left 4 Dead to the game list - * (The Dota 2 servers needs additional files for work properly.) +######Version 3.0.0.2 +* SteamCMD uses the new console Download ============ diff --git a/Source Code/SteamCMD GUI/ApplicationEvents.vb b/Source Code/SteamCMD GUI/ApplicationEvents.vb new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Source Code/SteamCMD GUI/ApplicationEvents.vb @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Source Code/SteamCMD GUI/MainMenu.Designer.vb b/Source Code/SteamCMD GUI/MainMenu.Designer.vb index 320f2d0..400255f 100644 --- a/Source Code/SteamCMD GUI/MainMenu.Designer.vb +++ b/Source Code/SteamCMD GUI/MainMenu.Designer.vb @@ -937,7 +937,7 @@ Partial Class MainMenu ' Me.ConsoleCommandList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.ConsoleCommandList.FormattingEnabled = True - Me.ConsoleCommandList.Items.AddRange(New Object() {"Empty", "say", "rcon", "echo"}) + Me.ConsoleCommandList.Items.AddRange(New Object() {"None", "say", "rcon", "echo"}) Me.ConsoleCommandList.Location = New System.Drawing.Point(6, 250) Me.ConsoleCommandList.Name = "ConsoleCommandList" Me.ConsoleCommandList.Size = New System.Drawing.Size(88, 21) @@ -945,6 +945,7 @@ Partial Class MainMenu ' 'ConsoleButton ' + Me.ConsoleButton.Enabled = False Me.ConsoleButton.Location = New System.Drawing.Point(519, 248) Me.ConsoleButton.Name = "ConsoleButton" Me.ConsoleButton.Size = New System.Drawing.Size(55, 23) @@ -954,6 +955,7 @@ Partial Class MainMenu ' 'ConsoleInput ' + Me.ConsoleInput.Enabled = False Me.ConsoleInput.Location = New System.Drawing.Point(100, 250) Me.ConsoleInput.Name = "ConsoleInput" Me.ConsoleInput.Size = New System.Drawing.Size(413, 20) diff --git a/Source Code/SteamCMD GUI/MainMenu.vb b/Source Code/SteamCMD GUI/MainMenu.vb index 534aac3..e1bcffa 100644 --- a/Source Code/SteamCMD GUI/MainMenu.vb +++ b/Source Code/SteamCMD GUI/MainMenu.vb @@ -1,20 +1,26 @@ Imports System.IO Imports System.Net Imports System.Xml +Imports System.Threading +Imports System.Text Module Module1 Public SteamCMDExePath, SteamAppID, Login, ServerPathInstallation, ValidateApp, GoldSrcMod, Program, Game, PathForLog As String ' Run Server Public SrcdsExePath, GameMod, ServerName, ServerMap, NetworkType, MaxPlayers, RCON, UDPPort, DebugMode, SourceTV, ConsoleMode, InsecureMode, NoBots, DevMode, AdditionalCommands, Parameters As String + 'Public p As New Process End Module Public Class MainMenu Dim WithEvents WC As New WebClient + Private Declare Function GetInputState Lib "user32" () As Int32 + Private Sub Form1_Load() Handles MyBase.Load Icon = My.Resources.SteamCMDGUI_Icon TabMenu.Size = New Size(417, 303) + ThrSteamCMD = New Thread(AddressOf ThreadTaskSteamCMD) GamesList.SelectedIndex = 1 ModList.SelectedIndex = 1 NetworkComboBox.SelectedIndex = 0 @@ -60,7 +66,6 @@ Public Class MainMenu Dim LogFileName As String = Program & " Log-" & DateTime.Now.ToString("dd.MM.yyyy") & " @ " & DateTime.Now.ToString("HH;mm") File.WriteAllText("Logs\" & LogFileName & ".txt", ConsoleContent) - Status.Text = "File " & LogFileName & " has been saved in Logs folder." End Sub ' Resize tabs @@ -106,7 +111,7 @@ Public Class MainMenu Process.Start("explorer.exe", ".") End Sub - Private Sub WC_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged + Private Sub WC_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged DonwloadBar.Value = e.ProgressPercentage If DonwloadBar.Value = 100 Then Status.Text = "The file 'steamcmd.zip' has been downloaded. Please, unzip it." @@ -169,7 +174,7 @@ Public Class MainMenu End If End Sub - Private Sub CustomIDTextBox_KeyPress(sender As Object, e As Windows.Forms.KeyPressEventArgs) Handles CustomIDTextBox.KeyPress + Private Sub CustomIDTextBox_KeyPress(ByVal sender As Object, ByVal e As Windows.Forms.KeyPressEventArgs) Handles CustomIDTextBox.KeyPress If InStr(1, "0123456789" & Chr(8), e.KeyChar) = 0 Then e.KeyChar = "" End If @@ -313,44 +318,12 @@ Public Class MainMenu Status.Text = "Installing/Updating..." Status.BackColor = Color.FromArgb(240, 240, 240) - Dim p As New Process - - With (p.StartInfo) - .FileName = SteamCMDExePath & "\steamcmd.exe" - .UseShellExecute = False - .CreateNoWindow = False - .RedirectStandardOutput = True - .Arguments = "SteamCmd +login " & Login & " +force_install_dir " & ServerPathInstallation & GoldSrcMod & " +app_update " & SteamAppID & ValidateApp - End With - ConsoleTab_Click() TabMenu.SelectedTab = ConsoleTab - ' Clear console, Run process and stream + ' Clear console, Run subprocess and stream ConsoleOutput.Clear() - p.Start() - Dim sr As StreamReader = p.StandardOutput - Dim line As String - Do - line = sr.ReadLine() - If Not (line Is Nothing) Then - ConsoleOutput.SelectionStart = ConsoleOutput.TextLength - ConsoleOutput.ScrollToCaret() - ConsoleOutput.Text = ConsoleOutput.Text + line + Environment.NewLine - End If - Loop Until p.HasExited - - If p.HasExited = True Then - ' Autosave log - If CustomIDCheckbox.Checked Then - Game = "Steam App ID: " & SteamAppID - Else - Game = "Game: " & GamesList.Text - End If - Program = "SteamCmd.exe" - PathForLog = "Server path: " & ServerPathInstallation - SaveLog() - End If + ThrSteamCMD.Start() End If End If End If @@ -363,6 +336,52 @@ Public Class MainMenu End If End Sub + Private ThrSteamCMD As Thread + Private WithEvents p As Process + + Private Sub ThreadTaskSteamCMD() + Control.CheckForIllegalCrossThreadCalls = False + p = New Process + With (p.StartInfo) + .FileName = SteamCMDExePath & "\steamcmd.exe" + .UseShellExecute = False + .CreateNoWindow = True + .RedirectStandardOutput = True + .RedirectStandardInput = True + .RedirectStandardError = True + .Arguments = "SteamCmd +login " & Login & " +force_install_dir " & ServerPathInstallation & GoldSrcMod & " +app_update " & SteamAppID & ValidateApp + End With + + p.Start() + + Dim pStreamWriter As StreamWriter = p.StandardInput + p.BeginOutputReadLine() + p.BeginErrorReadLine() + ConsoleInput.Enabled = True + ConsoleButton.Enabled = True + p.WaitForExit() + End Sub + + Private Sub p_OutputDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles p.OutputDataReceived + AppendOutputText(vbCrLf & e.Data) + End Sub + + Private Sub ExecuteButton_Click() Handles ConsoleButton.Click + p.StandardInput.WriteLine(ConsoleInput.Text) + p.StandardInput.Flush() + ConsoleInput.Text = "" + End Sub + + Private Delegate Sub AppendOutputTextDelegate(ByVal text As String) + Private Sub AppendOutputText(ByVal text As String) + If ConsoleOutput.InvokeRequired Then + Dim myDelegate As New AppendOutputTextDelegate(AddressOf AppendOutputText) + Me.Invoke(myDelegate, text) + Else + ConsoleOutput.AppendText(text) + End If + End Sub + 'Run server inputs Private Sub SrcdsExePath_Browser() Handles SrcdsExePathTextBox.Click, SrcdsExeBrowserButton.Click If FolderBrowserDialog3.ShowDialog() = DialogResult.OK Then @@ -594,43 +613,16 @@ Public Class MainMenu Parameters = DebugMode & SourceTV & ConsoleMode & InsecureMode & NoBots & DevMode Status.Text = "Running server..." Status.BackColor = Color.FromArgb(240, 240, 240) - Dim p As New Process + Dim p As New Process With (p.StartInfo) .FileName = SrcdsExePath & "\srcds.exe" .UseShellExecute = False .CreateNoWindow = False - .RedirectStandardOutput = True .Arguments = Parameters & "-game " & GameMod & " -port " & UDPPort & " +hostname " & Chr(34) & ServerName & Chr(34) & " +map " & ServerMap & " +maxplayers " & MaxPlayers & " +sv_lan " & NetworkComboBox.SelectedIndex & " " & AdditionalCommands End With - ConsoleTab_Click() - TabMenu.SelectedTab = ConsoleTab - - ' Clear console, Run process and stream - ConsoleOutput.Clear() p.Start() - Dim sr As StreamReader = p.StandardOutput - Dim line As String - Do - line = sr.ReadLine() - If Not (line Is Nothing) Then - ConsoleOutput.SelectionStart = ConsoleOutput.TextLength - ConsoleOutput.ScrollToCaret() - ConsoleOutput.Text = ConsoleOutput.Text + line + Environment.NewLine - End If - Loop Until line Is Nothing - If p.HasExited = True Then - ' Autosave log - If CustomModCheckBox.Checked = True Then - Game = "Server from mod: " & GameMod - Else - Game = "Server from: " & ModList.Text - End If - Program = "Srcds.exe" - PathForLog = "Server path: " & SrcdsExePath - SaveLog() - End If End If End If End If @@ -845,7 +837,7 @@ Public Class MainMenu End If End Sub - Private Sub CfgMenuItems_Click(sender As Object, e As EventArgs) + Private Sub CfgMenuItems_Click(ByVal sender As Object, ByVal e As EventArgs) Dim item = CType(sender, ToolStripItem) Dim path = CStr(item.Tag) Process.Start(path) @@ -862,7 +854,7 @@ Public Class MainMenu End If End Sub - Private Sub MenuTxt_Click(sender As System.Object, e As EventArgs) Handles MotdTxtButton.Click, MapcycleTxtButton.Click, MaplistTxtButton.Click + Private Sub MenuTxt_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles MotdTxtButton.Click, MapcycleTxtButton.Click, MaplistTxtButton.Click Dim TxtFile As ToolStripMenuItem = CType(sender, ToolStripMenuItem) Dim MotdPath As String = SrcdsExePath & "\" & GameMod & "\" & TxtFile.Text & ".txt" If File.Exists(MotdPath) Then @@ -890,11 +882,14 @@ Public Class MainMenu Next Else Status.Text = "Seems that SourceMod isn't installed." + Status.BackColor = Color.FromArgb(240, 200, 200) + My.Computer.Audio.PlaySystemSound( _ + Media.SystemSounds.Hand) End If End If End Sub - Private Sub SMFileMenuItems_Click(sender As Object, e As EventArgs) + Private Sub SMFileMenuItems_Click(ByVal sender As Object, ByVal e As EventArgs) Dim item = CType(sender, ToolStripItem) Dim path = CStr(item.Tag) Process.Start(path) @@ -918,13 +913,39 @@ Public Class MainMenu End If End Sub - Private Sub LogFileMenuItems_Click(sender As Object, e As EventArgs) + Private Sub LogFileMenuItems_Click(ByVal sender As Object, ByVal e As EventArgs) Dim item = CType(sender, ToolStripItem) Dim path = CStr(item.Tag) Process.Start(path) End Sub ' Console Tab + Private Sub ConsoleConnect_Click() Handles ConsoleConnect.Click + 'Stop steamcmd.exe + For Each proc As Process In Process.GetProcessesByName("steamcmd") + Dim result As Integer = MessageBox.Show("Really want to stop and close SteamCMD?", "Stop SteamCMD", MessageBoxButtons.YesNo) + If result = DialogResult.Yes Then + If Not proc.HasExited Then + If CustomIDCheckbox.Checked Then + Game = "Steam App ID: " & SteamAppID + Else + Game = "Game: " & GamesList.Text + End If + Program = "SteamCmd.exe" + PathForLog = "Server path: " & ServerPathInstallation + SaveLog() + proc.Kill() + ConsoleInput.Enabled = False + ConsoleButton.Enabled = False + End If + Status.Text = "SteamCMD closed." + Status.BackColor = Color.FromArgb(240, 200, 200) + My.Computer.Audio.PlaySystemSound( _ + Media.SystemSounds.Hand) + End If + Next proc + End Sub + Private Sub ConsoleOpenLog_Click() Handles ConsoleOpenLog.Click Process.Start("explorer.exe", ".\Logs") End Sub diff --git a/Source Code/SteamCMD GUI/My Project/AssemblyInfo.vb b/Source Code/SteamCMD GUI/My Project/AssemblyInfo.vb index 84a2559..049bae3 100644 --- a/Source Code/SteamCMD GUI/My Project/AssemblyInfo.vb +++ b/Source Code/SteamCMD GUI/My Project/AssemblyInfo.vb @@ -31,7 +31,7 @@ Imports System.Runtime.InteropServices ' mediante el asterisco ('*'), como se muestra a continuación: ' - - + + \ No newline at end of file