Skip to content

Commit

Permalink
Browse for server exe file instead of folder
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdaGaming committed Jul 23, 2021
1 parent 904282a commit cf53214
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 21 deletions.
5 changes: 4 additions & 1 deletion App.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<setting name="Gamemode" serializeAs="String">
<value />
</setting>
<setting name="FilePath" serializeAs="String">
<setting name="FileName" serializeAs="String">
<value />
</setting>
<setting name="Password" serializeAs="String">
Expand All @@ -41,6 +41,9 @@
<setting name="CollectionID" serializeAs="String">
<value />
</setting>
<setting name="FilePath" serializeAs="String">
<value />
</setting>
</GMod_Server_Launcher_Console.Properties.Settings>
</userSettings>
</configuration>
14 changes: 8 additions & 6 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public MainForm()
CollectionIDBox.Enabled = consolecheck.Checked;

StringBuilder path = new StringBuilder( label4.Text );
path.Append( Properties.Settings.Default.FilePath );
path.Append( Properties.Settings.Default.FileName );
label4.Text = path.ToString();

string[] listgamemodes = Directory.GetDirectories( Settings.FilePath + @"\garrysmod\gamemodes" );
Expand Down Expand Up @@ -115,12 +115,14 @@ private void GamemodeChanged( object sender, EventArgs e )

private void ChangePathClick( object sender, EventArgs e )
{
FolderBrowserDialog browse = new FolderBrowserDialog();
browse.Description = "Select server file path. (The folder containing the srcds.exe file.)";
OpenFileDialog browse = new OpenFileDialog();
browse.Filter = "Server Executable (*.exe)|*.exe";
browse.RestoreDirectory = true;
if ( browse.ShowDialog() == DialogResult.OK )
{
Properties.Settings.Default.FilePath = browse.SelectedPath;
label4.Text = "Current server file path: " + Properties.Settings.Default.FilePath;
Properties.Settings.Default.FileName = browse.FileName;
Properties.Settings.Default.FilePath = Path.GetDirectoryName( browse.FileName );
label4.Text = "Current server file path: " + Properties.Settings.Default.FileName;
}
}

Expand Down Expand Up @@ -178,7 +180,7 @@ private void StartButtonClick( object sender, EventArgs e )
{
UseShellExecute = true,
WorkingDirectory = Properties.Settings.Default.FilePath,
FileName = Properties.Settings.Default.FilePath + @"\srcds.exe",
FileName = Properties.Settings.Default.FileName,
Arguments = "+gamemode " + gameselect.Text.ToString() + ConsoleEnabled + LANEnabled + "+map " + mapselect.Text.ToString() + " +maxplayers " + maxplayers.Value + " +r_hunkalloclightmaps 0" + Password + SteamToken + CollectionID,
};

Expand Down
14 changes: 7 additions & 7 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if ( string.IsNullOrWhiteSpace( Properties.Settings.Default.FilePath ) || !Directory.Exists( Properties.Settings.Default.FilePath ) )
if ( string.IsNullOrWhiteSpace( Properties.Settings.Default.FileName ) || !Directory.Exists( Properties.Settings.Default.FileName ) )
{
DialogResult BrowseCheck = MessageBox.Show( "Please select the server directory.", "Server file path not found.", MessageBoxButtons.OK, MessageBoxIcon.Warning );
DialogResult BrowseCheck = MessageBox.Show( "Please select the server file.", "Server file path not found.", MessageBoxButtons.OK, MessageBoxIcon.Warning );
if ( BrowseCheck == DialogResult.OK )
{
FolderBrowserDialog browse = new FolderBrowserDialog
{
Description = "Select server file path. (The folder containing the srcds.exe file.)"
};
OpenFileDialog browse = new OpenFileDialog();
browse.Filter = "Server Executable (*.exe)|*.exe";
browse.RestoreDirectory = true;
if ( browse.ShowDialog() == DialogResult.OK )
{
Properties.Settings.Default.FilePath = browse.SelectedPath;
Properties.Settings.Default.FileName = browse.FileName;
Properties.Settings.Default.FilePath = Path.GetDirectoryName( browse.FileName );
}
}
else return;
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion( "1.3.1" )]
[assembly: AssemblyFileVersion( "1.3.1" )]
[assembly: AssemblyVersion( "1.3.2" )]
[assembly: AssemblyFileVersion( "1.3.2" )]
20 changes: 16 additions & 4 deletions Properties/Settings.Designer.cs

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

5 changes: 4 additions & 1 deletion Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Setting Name="Gamemode" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="FilePath" Type="System.String" Scope="User">
<Setting Name="FileName" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="Password" Type="System.String" Scope="User">
Expand All @@ -32,5 +32,8 @@
<Setting Name="CollectionID" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="FilePath" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

0 comments on commit cf53214

Please sign in to comment.