Skip to content

Commit

Permalink
Console released
Browse files Browse the repository at this point in the history
SteamCMD uses the new console
  • Loading branch information
AndrSator committed Aug 10, 2014
1 parent eae6464 commit 1f947d9
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 77 deletions.
7 changes: 5 additions & 2 deletions Documentation/Changelog.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -69,4 +72,4 @@
- Added an input to choose the path where is located the file steamcmd.exe

Version 1
- Release
- Release
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
============
Expand Down
1 change: 1 addition & 0 deletions Source Code/SteamCMD GUI/ApplicationEvents.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 3 additions & 1 deletion Source Code/SteamCMD GUI/MainMenu.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

159 changes: 90 additions & 69 deletions Source Code/SteamCMD GUI/MainMenu.vb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Source Code/SteamCMD GUI/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Imports System.Runtime.InteropServices
' mediante el asterisco ('*'), como se muestra a continuación:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("3.0.0.0")>
<Assembly: AssemblyFileVersion("3.0.0.0")>
<Assembly: AssemblyVersion("3.0.0.2")>
<Assembly: AssemblyFileVersion("3.0.0.2")>

<Assembly: NeutralResourcesLanguageAttribute("en")>

0 comments on commit 1f947d9

Please sign in to comment.