Skip to content

Commit

Permalink
Make CampaignTagSelector optional
Browse files Browse the repository at this point in the history
  • Loading branch information
SadPencil committed Sep 14, 2022
1 parent fa46e49 commit f356b26
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
2 changes: 2 additions & 0 deletions ClientCore/ClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ public string GetThemePath(string themeName)

public string AllowedCustomGameModes => clientDefinitionsIni.GetStringValue(SETTINGS, "AllowedCustomGameModes", "Standard,Custom Map");

public bool CampaignGroupSelectorEnabled => clientDefinitionsIni.GetBooleanValue(SETTINGS, "CampaignGroupSelectorEnabled", false);

public string GetGameExecutableName()
{
string[] exeNames = clientDefinitionsIni.GetStringValue(SETTINGS, "GameExecutableNames", "Game.exe").Split(',');
Expand Down
9 changes: 6 additions & 3 deletions DXMainClient/DXGUI/Generic/CampaignSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public CampaignSelector(WindowManager windowManager, DiscordHandler discordHandl
/// <param name="selectedTags">Missions with at lease one of which tags to be shown. As an exception, null means show all missions.</param>
public void ParseMissionWithFillter(ISet<string> selectedTags = null)
{
Missions.Clear();
lbCampaignList.Items.Clear();
ParseBattleIni("INI/Battle.ini", selectedTags);
ParseBattleIni("INI/" + ClientConfiguration.Instance.BattleFSFileName, selectedTags);
Expand Down Expand Up @@ -326,7 +327,8 @@ private void LaunchMission(Mission mission)
UserINISettings.Instance.Difficulty.Value = trbDifficultySelector.Value;
UserINISettings.Instance.SaveSettings();

((MainMenuDarkeningPanel)Parent).Hide();
//((DarkeningPanel)Parent).Hide();
Disable();

discordHandler?.UpdatePresence(mission.GUIName, difficultyName, mission.IconPath, true);
GameProcessLogic.GameProcessExited += GameProcessExited_Callback;
Expand Down Expand Up @@ -382,8 +384,6 @@ private bool ParseBattleIni(string path, ISet<string> selectedTags = null)

var mission = new Mission(battleIni, battleSection);

Missions.Add(mission);

XNAListBoxItem item = new XNAListBoxItem();
item.Text = mission.GUIName;
if (!mission.Enabled)
Expand All @@ -406,7 +406,10 @@ private bool ParseBattleIni(string path, ISet<string> selectedTags = null)
item.Texture = AssetLoader.LoadTexture(mission.IconPath + "icon.png");

if (selectedTags == null || mission.Tags.Intersect(selectedTags).Count() >= 1)
{
Missions.Add(mission);
lbCampaignList.AddItem(item);
}
}

Logger.Log("Finished parsing " + path + ".");
Expand Down
23 changes: 16 additions & 7 deletions DXMainClient/DXGUI/Generic/CampaignTagSelector.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ClientGUI;
using ClientCore;
using ClientGUI;
using DTAClient.Domain;
using Microsoft.Xna.Framework;
using Rampastring.Tools;
Expand Down Expand Up @@ -27,19 +28,21 @@ public CampaignTagSelector(WindowManager windowManager, string iniName, DiscordH
protected XNAClientButton btnShowAllMission;
public override void Initialize()
{
CampaignSelector = new CampaignSelector(WindowManager, discordHandler);
DarkeningPanel.AddAndInitializeWithControl(WindowManager, CampaignSelector);
CampaignSelector.Disable();

Name = _iniSectionName;

if (!ClientConfiguration.Instance.CampaignGroupSelectorEnabled) return;

ClientRectangle = new Rectangle(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
WindowManager.CenterControlOnScreen(this);

BorderColor = UISettings.ActiveSettings.PanelBorderColor;

base.Initialize();

CampaignSelector = new CampaignSelector(WindowManager, discordHandler);
DarkeningPanel.AddAndInitializeWithControl(WindowManager, CampaignSelector);
CampaignSelector.Disable();

btnCancel = FindChild<XNAClientButton>(nameof(btnCancel));
btnCancel.LeftClick += BtnCancel_LeftClick;
btnShowAllMission = FindChild<XNAClientButton>(nameof(btnShowAllMission));
Expand Down Expand Up @@ -69,12 +72,18 @@ private void BtnCancel_LeftClick(object sender, EventArgs e)

private void Hide()
{
Disable();
if (ClientConfiguration.Instance.CampaignGroupSelectorEnabled)
Disable();
else
CampaignSelector.Disable();
}

public void Show()
{
Enable();
if (ClientConfiguration.Instance.CampaignGroupSelectorEnabled)
Enable();
else
CampaignSelector.Enable();
}

CampaignSelector CampaignSelector;
Expand Down

0 comments on commit f356b26

Please sign in to comment.