-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented window title version number and instance+session persistent directory memory #89
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,4 +334,7 @@ ASALocalRun/ | |
.localhistory/ | ||
|
||
# Executables | ||
*.exe | ||
*.exe | ||
|
||
# Scripts | ||
*.ps1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
using ReforgerServerApp.Models; | ||
using System.ComponentModel; | ||
using Serilog; | ||
using System.Reflection; | ||
|
||
namespace ReforgerServerApp | ||
{ | ||
|
@@ -21,6 +22,9 @@ public Main() | |
{ | ||
InitializeComponent(); | ||
|
||
// Set the window title with the version number | ||
this.Text = $"ReforgerServerApp - {GetAppVersion()}"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be "Arma Reforger Dedicated Server Tool", There are some messagebox constants in
we could have |
||
|
||
CreateServerParameterControls(); | ||
|
||
serverRunningLabel.Text = string.Empty; | ||
|
@@ -75,6 +79,20 @@ public Main() | |
Mod.GetScenariosForMod("591AF5BDA9F7CE8B"); | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves the application's version number. | ||
/// </summary> | ||
/// <returns>Formatted version string.</returns> | ||
private string GetAppVersion() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably shouldn't be in Main, maybe this can live in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could also be used to populate the About Box if put in the |
||
{ | ||
// Retrieve the version from the assembly metadata using pattern matching | ||
return Assembly.GetExecutingAssembly().GetName().Version switch | ||
{ | ||
{ } version => $"v{version.Major}.{version.Minor}.{version.Build}.{version.Revision}", | ||
_ => "v0.0.0.0" // Fallback version if Version is null | ||
}; | ||
Comment on lines
+88
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer throwing on null version. It's the kind of thing that is either set or not, and it's vital for it to be set when released. |
||
} | ||
|
||
/// <summary> | ||
/// Initialise tool tips for certain UI elements. | ||
/// </summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ internal class FileIOManager | |
private readonly string m_legacyModDatabaseFile = "./mod_database.txt"; | ||
private string m_steamCmdFile; | ||
private string m_installDir; | ||
private string lastUsedDirectory; | ||
private FileIOManager() | ||
{ | ||
bool modDatabaseExists = File.Exists(ToolPropertiesManager.GetInstance().GetToolProperties().modDatabaseFile); | ||
|
@@ -52,6 +53,7 @@ private FileIOManager() | |
m_installDir = string.Empty; | ||
m_steamCmdFile = string.Empty; | ||
} | ||
lastUsedDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
} | ||
|
||
public static FileIOManager GetInstance() | ||
|
@@ -113,13 +115,29 @@ public void ReadModsDatabase() | |
/// </summary> | ||
public static void SaveConfigurationToFile() | ||
{ | ||
FileIOManager instance = GetInstance(); | ||
using SaveFileDialog sfd = new(); | ||
sfd.InitialDirectory = Environment.SpecialFolder.UserProfile.ToString(); | ||
|
||
// Use lastUsedDirectory if available | ||
if (!string.IsNullOrEmpty(instance.lastUsedDirectory)) | ||
{ | ||
sfd.InitialDirectory = instance.lastUsedDirectory; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of calling this instance in here which I think might be a bit weird, have a getter which means we can, for static methods go |
||
} | ||
else | ||
{ | ||
sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
} | ||
|
||
sfd.Filter = "JSON (*.json)|*.json"; | ||
if (sfd.ShowDialog() == DialogResult.OK) | ||
{ | ||
ConfigurationManager.GetInstance().CreateConfiguration(); | ||
SaveConfigurationToFile(sfd.FileName); | ||
bool success = SaveConfigurationToFile(sfd.FileName); | ||
if (success) | ||
{ | ||
// Update lastUsedDirectory | ||
instance.lastUsedDirectory = Path.GetDirectoryName(sfd.FileName) ?? instance.lastUsedDirectory; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. once updated, use getter here |
||
} | ||
} | ||
} | ||
|
||
|
@@ -150,14 +168,28 @@ public static bool SaveConfigurationToFile(string path) | |
/// </summary> | ||
public static void LoadConfigurationFromFile() | ||
{ | ||
FileIOManager instance = GetInstance(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wont need with the getter |
||
using OpenFileDialog ofd = new(); | ||
ofd.InitialDirectory = Environment.SpecialFolder.UserProfile.ToString(); | ||
|
||
// Use lastUsedDirectory if available | ||
if (!string.IsNullOrEmpty(instance.lastUsedDirectory)) | ||
{ | ||
ofd.InitialDirectory = instance.lastUsedDirectory; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getter |
||
} | ||
else | ||
{ | ||
ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
} | ||
|
||
ofd.Filter = "JSON (*.json)|*.json"; | ||
if (ofd.ShowDialog() == DialogResult.OK) | ||
{ | ||
string filePath = ofd.FileName; | ||
using StreamReader sr = File.OpenText(filePath); | ||
ConfigurationManager.GetInstance().PopulateServerConfiguration(sr.ReadToEnd()); | ||
|
||
// Update lastUsedDirectory | ||
instance.lastUsedDirectory = Path.GetDirectoryName(filePath) ?? instance.lastUsedDirectory; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getter |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.exe should already be in the gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see it explicitly but the builds would be ignored here.
ArmaReforgerServerTool/.gitignore
Lines 16 to 26 in 472ea23