Skip to content

Commit

Permalink
Merge pull request #87 from soda3x/dev
Browse files Browse the repository at this point in the history
0.9.0.1 Hotfix
  • Loading branch information
soda3x authored Sep 7, 2024
2 parents 3e8367c + 76144d6 commit 9c7a161
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 21 deletions.
8 changes: 4 additions & 4 deletions ArmaReforgerServerTool/Forms/AddModDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ private void CancelBtnPressed(object sender, EventArgs e)
/// <param name="e"></param>
private void AddBtnPressed(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(modId.Text) && !string.IsNullOrWhiteSpace(modName.Text))
if (!string.IsNullOrWhiteSpace(modId.Text.Trim()) && !string.IsNullOrWhiteSpace(modName.Text.Trim()))
{
Mod mod;

if (!string.IsNullOrWhiteSpace(modVers.Text))
if (!string.IsNullOrWhiteSpace(modVers.Text.Trim()))
{
mod = new(modId.Text, modName.Text, modVers.Text);
mod = new(modId.Text.Trim(), modName.Text.Trim());
}
else
{
mod = new(modId.Text, modName.Text);
mod = new(modId.Text.Trim(), modName.Text.Trim());
}
if (m_isEditMode)
{
Expand Down
26 changes: 14 additions & 12 deletions ArmaReforgerServerTool/Forms/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,13 @@ private void AddModBtnPressed(object sender, EventArgs e)
/// <param name="e"></param>
private void AvailableModsSelectedIndexChanged(object sender, EventArgs e)
{
editModBtn.Enabled = availableMods.SelectedItem != null;
removeModBtn.Enabled = availableMods.SelectedItem != null;
// If the server is running, we don't want to be able to edit / remove mods
if (string.IsNullOrWhiteSpace(serverRunningLabel.Text))
{
editModBtn.Enabled = availableMods.SelectedItem != null;
removeModBtn.Enabled = availableMods.SelectedItem != null;
}

}

/// <summary>
Expand Down Expand Up @@ -206,11 +211,9 @@ private void AddToEnabledModsBtnPressed(object sender, EventArgs e)
{
Mod m = (Mod)GetAvailableModsList().SelectedItem;

if (!ConfigurationManager.GetInstance().GetEnabledMods().Contains(m))
{
ConfigurationManager.GetInstance().GetEnabledMods().Add(new(m));
}
ConfigurationManager.GetInstance().GetAvailableMods().Remove(m);
// Move mod from Available Mods -> Enabled Mods
ConfigurationManager.MoveMod(m, ConfigurationManager.GetInstance().GetAvailableMods(),
ConfigurationManager.GetInstance().GetEnabledMods());
}
ConfigurationManager.GetInstance().AlphabetiseModLists();
ResetModFilters();
Expand All @@ -230,11 +233,9 @@ private void RemovedFromEnabledModsBtnPressed(object sender, EventArgs e)
{
Mod m = (Mod)GetEnabledModsList().SelectedItem;

if (!ConfigurationManager.GetInstance().GetAvailableMods().Contains(m))
{
ConfigurationManager.GetInstance().GetAvailableMods().Add(new(m));
}
ConfigurationManager.GetInstance().GetEnabledMods().Remove(m);
// Move mod from Enabled Mods -> Available Mods
ConfigurationManager.MoveMod(m, ConfigurationManager.GetInstance().GetEnabledMods(),
ConfigurationManager.GetInstance().GetAvailableMods());
}
ConfigurationManager.GetInstance().AlphabetiseModLists();
ResetModFilters();
Expand All @@ -257,6 +258,7 @@ private void SaveSettingsToFileBtnPressed(object sender, EventArgs e)
/// <param name="e"></param>
private void LoadSettingsFromFileBtnPressed(object sender, EventArgs e)
{
ResetModFilters();
FileIOManager.LoadConfigurationFromFile();
}

Expand Down
26 changes: 24 additions & 2 deletions ArmaReforgerServerTool/Managers/ConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public Dictionary<string, ServerParameter> GetServerParametersDictionary()
/// <param name="input"></param>
public void PopulateServerConfiguration(string input)
{
// First move mods back to available mods so we don't lose them
for (int i = 0; i < m_enabledMods.Count; i++)
{
MoveMod(m_enabledMods[i], m_enabledMods, m_availableMods);
}

try
{
Log.Debug("ConfigurationManager - Populating Server Configuration from {input}", input);
Expand Down Expand Up @@ -150,8 +156,6 @@ public void PopulateServerConfiguration(string input)
m_serverParamsDictionary["slotReservationTimeout"].ParameterValue = m_serverConfig.root.operating.slotReservationTimeout;
m_serverParamsDictionary["disableAI"].ParameterValue = m_serverConfig.root.operating.disableAI;

m_enabledMods.Clear();

foreach (Mod m in m_serverConfig.root.game.mods)
{
m_enabledMods.Add(m);
Expand Down Expand Up @@ -266,6 +270,24 @@ public void AlphabetiseModLists()
}
}

/// <summary>
/// Utility method for moving a mod from one list to another
/// </summary>
/// <param name="m">Mod to move</param>
/// <param name="from">List to move mod from</param>
/// <param name="to">List to move mod to</param>
public static void MoveMod(Mod m, BindingList<Mod> from, BindingList<Mod> to)
{
if (to.Contains(m))
{
from.Remove(m);
} else
{
to.Add(m);
from.Remove(m);
}
}

/// <summary>
/// Sender for the 'UpdateScenarioIdFromLoadedConfig' Event
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions ArmaReforgerServerTool/ReforgerServerApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ImplicitUsings>enable</ImplicitUsings>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<Company>soda3x</Company>
<AssemblyVersion>0.9.0</AssemblyVersion>
<FileVersion>0.9.0</FileVersion>
<AssemblyVersion>0.9.0.1</AssemblyVersion>
<FileVersion>0.9.0.1</FileVersion>
<ApplicationIcon>Resources\arma_icon_white.ico</ApplicationIcon>
<PublishSingleFile>true</PublishSingleFile>
<OutputType>winexe</OutputType>
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.9.0.1

0 comments on commit 9c7a161

Please sign in to comment.