Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
35a20f2
Implement custom mission support with CampaignTagSelector
SadPencil May 6, 2025
6d0945d
Merge branch 'develop' into feature-custom-mission
Starkku May 28, 2025
c5ec4fb
Disable fade between CampaignTagSelector/CampaignSelector
Starkku May 28, 2025
8959f55
Migrate CampaignSelector to INItializableWindow
Starkku May 28, 2025
2f022d7
Add return to campaign tag selector button to CampaignSelector
Starkku May 28, 2025
34701a0
Adjust the mission config section names and decouple game mission con…
Starkku May 28, 2025
f8e604c
Enforce all-caps scenario names, game makes assumptions that they are
Starkku May 28, 2025
a5ac652
Allow staying on mission selector on game launch and generalize missi…
Starkku May 28, 2025
cbc73e2
Fix some remaining issues
Starkku Jun 2, 2025
a3e5eb8
Revert "Migrate CampaignSelector to INItializableWindow"
Starkku Jun 3, 2025
a93ea06
Merge branch 'develop' into feature-custom-mission
Starkku Jul 23, 2025
82ac513
Rename lbCampaignListMissions to selectedMissions
SadPencil Aug 16, 2025
b051a1a
Create hard links for supplemental mission files
SadPencil Aug 16, 2025
34a5675
Allow customized custom mission supplemental files
SadPencil Aug 16, 2025
bc67a62
Define no supplement files by default
SadPencil Aug 16, 2025
f9d2234
Add document for custom mission configurations
SadPencil Aug 16, 2025
a20c59d
make the compiler happy
SadPencil Aug 16, 2025
73284e7
Add campaign tag selector documentation
SadPencil Aug 16, 2025
75e85fa
make the compiler happy
SadPencil Aug 16, 2025
92ea96f
Merge branch 'develop' into feature-custom-mission
Starkku Aug 18, 2025
3da03c0
Use ls/pal file names from supplementary file definitions as defaults…
Starkku Aug 18, 2025
adfa44a
Allow use of disabled, placeholder campaign tag buttons
Starkku Aug 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ClientCore/ClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ private List<TranslationGameFile> ParseTranslationGameFiles()

public int DefaultSkillLevelIndex => clientDefinitionsIni.GetIntValue(SETTINGS, "DefaultSkillLevelIndex", 0);


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

public bool ReturnToMainMenuOnMissionLaunch => clientDefinitionsIni.GetBooleanValue(SETTINGS, "ReturnToMainMenuOnMissionLaunch", true);

public string GetGameExecutableName()
{
string[] exeNames = clientDefinitionsIni.GetStringListValue(SETTINGS, "GameExecutableNames", "Game.exe");
Expand Down Expand Up @@ -502,6 +507,10 @@ public List<string> GetIRCServers()
}

public bool DiscordIntegrationGloballyDisabled => string.IsNullOrWhiteSpace(DiscordAppId) || DisableDiscordIntegration;

public string CustomMissionPath => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionPath", "Maps/CustomMissions");
public string CustomMissionSupplementDefinition // e.g., "csf|stringtable99.csf|pal|custommission.pal|shp|custommission.shp"
=> clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionSupplementDefinition", string.Empty);

public OSVersion GetOperatingSystemVersion()
{
Expand Down
32 changes: 28 additions & 4 deletions ClientGUI/DarkeningPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace ClientGUI
public class DarkeningPanel : XNAPanel
{
public const float ALPHA_RATE = 0.6f;
private bool _fadeEnabled = true;

public DarkeningPanel(WindowManager windowManager) : base(windowManager)
{
Expand All @@ -24,7 +25,7 @@ public override void Initialize()
Name = "DarkeningPanel";

SetPositionAndSize();

PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
DrawBorders = false;
Expand Down Expand Up @@ -67,8 +68,17 @@ public void Show()
{
Enabled = true;
Visible = true;
AlphaRate = ALPHA_RATE;
Alpha = 0.01f;

if (_fadeEnabled)
{
AlphaRate = ALPHA_RATE;
Alpha = 0.01f;
}
else
{
AlphaRate = 1.0f;
Alpha = 1.0f;
}

foreach (XNAControl child in Children)
{
Expand All @@ -79,7 +89,16 @@ public void Show()

public void Hide()
{
AlphaRate = -ALPHA_RATE;
if (_fadeEnabled)
{
AlphaRate = -ALPHA_RATE;
}
else
{
Enabled = false;
Visible = false;
Hidden?.Invoke(this, EventArgs.Empty);
}

foreach (XNAControl child in Children)
{
Expand All @@ -106,5 +125,10 @@ public static void AddAndInitializeWithControl(WindowManager wm, XNAControl cont
wm.AddAndInitializeControl(dp);
dp.AddChild(control);
}

public void ToggleFade(bool enabled)
{
_fadeEnabled = enabled;
}
}
}
44 changes: 29 additions & 15 deletions ClientGUI/INItializableWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,43 @@ public INItializableWindow(WindowManager windowManager) : base(windowManager)
/// instead of the window's name.
/// </summary>
protected string IniNameOverride { get; set; }
private bool VisitChild(IEnumerable<XNAControl> list, Func<XNAControl, bool> judge)
{
foreach (XNAControl child in list)
{
bool stop = judge(child);
if (stop) return true;
stop = VisitChild(child.Children, judge);
if (stop) return true;
}
return false;
}

public T FindChild<T>(string childName, bool optional = false) where T : XNAControl
{
T child = FindChild<T>(Children, childName);
if (child == null && !optional)
XNAControl result = null;
VisitChild(new List<XNAControl>() { this }, control =>
{
if (control.Name != childName) return false;
result = control;
return true;
});
if (result == null && !optional)
throw new KeyNotFoundException("Could not find required child control: " + childName);

return child;
return (T)result;
}

private T FindChild<T>(IEnumerable<XNAControl> list, string controlName) where T : XNAControl
public List<T> FindChildrenStartWith<T>(string prefix) where T : XNAControl
{
foreach (XNAControl child in list)
List<T> result = new List<T>();
VisitChild(new List<XNAControl>() { this }, (control) =>
{
if (child.Name == controlName)
return (T)child;

T childOfChild = FindChild<T>(child.Children, controlName);
if (childOfChild != null)
return childOfChild;
}

return null;
if (string.IsNullOrEmpty(prefix) ||
!string.IsNullOrEmpty(control.Name) && control.Name.StartsWith(prefix))
result.Add((T)control);
return false;
});
return result;
}

/// <summary>
Expand Down
20 changes: 20 additions & 0 deletions DTAConfig/OptionPanels/XNAOptionsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using Rampastring.Tools;
using Rampastring.XNAUI;
using Rampastring.XNAUI.XNAControls;

using System;
using System.Collections.Generic;

namespace DTAConfig.OptionPanels
Expand Down Expand Up @@ -33,6 +35,24 @@ public override void Initialize()
PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;

base.Initialize();

GameProcessLogic.GameProcessExited += GameProcessExited_Callback;
}

private void GameProcessExited_Callback()
{
foreach (IUserSetting setting in userSettings)
{
if (!setting.ResetToDefaultOnGameExit)
continue;

if (setting is SettingCheckBoxBase cb)
cb.Checked = cb.DefaultValue;
else if (setting is SettingDropDownBase dd)
dd.SelectedIndex = dd.DefaultValue;

setting.Save();
}
}

/// <summary>
Expand Down
7 changes: 6 additions & 1 deletion DTAConfig/Settings/IUserSetting.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace DTAConfig.Settings
{
interface IUserSetting
public interface IUserSetting
{

/// <summary>
Expand All @@ -19,6 +19,11 @@ interface IUserSetting
/// </summary>
bool RestartRequired { get; }

/// <summary>
/// Determines if the setting should reset to its default value where applicable once game process exits.
/// </summary>
public bool ResetToDefaultOnGameExit { get; }

/// <summary>
/// Loads the current value for the user setting.
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion DTAConfig/Settings/SettingCheckBoxBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ public abstract class SettingCheckBoxBase : XNAClientCheckBox, IUserSetting
{
public SettingCheckBoxBase(WindowManager windowManager) : base(windowManager) { }

public SettingCheckBoxBase(WindowManager windowManager, bool defaultValue, string settingSection, string settingKey, bool restartRequired = false) : base(windowManager)
public SettingCheckBoxBase(WindowManager windowManager, bool defaultValue, string settingSection, string settingKey, bool restartRequired = false, bool resetPerGameSession = false) : base(windowManager)
{
DefaultValue = defaultValue;
SettingSection = settingSection;
SettingKey = settingKey;
RestartRequired = restartRequired;
ResetToDefaultOnGameExit = resetPerGameSession;
}

public bool DefaultValue { get; set; }
Expand All @@ -34,6 +35,7 @@ public string SettingKey
}

public bool RestartRequired { get; set; }
public bool ResetToDefaultOnGameExit { get; set; }

private string _parentCheckBoxName;
/// <summary>
Expand Down Expand Up @@ -95,6 +97,9 @@ protected override void ParseControlINIAttribute(IniFile iniFile, string key, st
case "ParentCheckBoxRequiredValue":
ParentCheckBoxRequiredValue = Conversions.BooleanFromString(value, true);
return;
case "ResetToDefaultOnGameExit":
ResetToDefaultOnGameExit = Conversions.BooleanFromString(value, false);
return;
}

base.ParseControlINIAttribute(iniFile, key, value);
Expand Down
1 change: 1 addition & 0 deletions DTAConfig/Settings/SettingDropDownBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public string SettingKey
}

public bool RestartRequired { get; set; }
public bool ResetToDefaultOnGameExit { get; set; }

protected string defaultSection = "CustomSettings";
protected string defaultKeySuffix = "_SelectedIndex";
Expand Down
2 changes: 1 addition & 1 deletion DXMainClient/DXGUI/GameClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private IServiceProvider BuildServiceProvider(WindowManager windowManager)
.AddSingletonXnaControl<MapPreviewBox>()
.AddSingletonXnaControl<GameLaunchButton>()
.AddSingletonXnaControl<PlayerExtraOptionsPanel>()
.AddSingletonXnaControl<CampaignSelector>()
.AddSingletonXnaControl<CampaignTagSelector>()
.AddSingletonXnaControl<GameLoadingWindow>()
.AddSingletonXnaControl<StatisticsWindow>()
.AddSingletonXnaControl<UpdateQueryWindow>()
Expand Down
Loading
Loading