Skip to content

Commit 35a20f2

Browse files
committed
Implement custom mission support with CampaignTagSelector
1 parent 18a3f11 commit 35a20f2

File tree

11 files changed

+523
-117
lines changed

11 files changed

+523
-117
lines changed

ClientCore/ClientConfiguration.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ private List<TranslationGameFile> ParseTranslationGameFiles()
360360

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

363+
364+
public bool CampaignTagSelectorEnabled => clientDefinitionsIni.GetBooleanValue(SETTINGS, "CampaignTagSelectorEnabled", false);
365+
363366
public string GetGameExecutableName()
364367
{
365368
string[] exeNames = clientDefinitionsIni.GetStringValue(SETTINGS, "GameExecutableNames", "Game.exe").Split(',');
@@ -490,6 +493,11 @@ public List<string> GetIRCServers()
490493
}
491494

492495
public bool DiscordIntegrationGloballyDisabled => string.IsNullOrWhiteSpace(DiscordAppId) || DisableDiscordIntegration;
496+
497+
public string CustomMissionPath => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionPath", "Maps/CustomMissions");
498+
public string CustomMissionCsfName => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionCsfName", "stringtable99.csf");
499+
public string CustomMissionPalName => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionPalName", "custommission.pal");
500+
public string CustomMissionShpName => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionShpName", "custommission.shp");
493501

494502
public OSVersion GetOperatingSystemVersion()
495503
{

ClientGUI/INItializableWindow.cs

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,43 @@ public INItializableWindow(WindowManager windowManager) : base(windowManager)
2929
/// instead of the window's name.
3030
/// </summary>
3131
protected string IniNameOverride { get; set; }
32+
private bool VisitChild(IEnumerable<XNAControl> list, Func<XNAControl, bool> judge)
33+
{
34+
foreach (XNAControl child in list)
35+
{
36+
bool stop = judge(child);
37+
if (stop) return true;
38+
stop = VisitChild(child.Children, judge);
39+
if (stop) return true;
40+
}
41+
return false;
42+
}
3243

3344
public T FindChild<T>(string childName, bool optional = false) where T : XNAControl
3445
{
35-
T child = FindChild<T>(Children, childName);
36-
if (child == null && !optional)
46+
XNAControl result = null;
47+
VisitChild(new List<XNAControl>() { this }, control =>
48+
{
49+
if (control.Name != childName) return false;
50+
result = control;
51+
return true;
52+
});
53+
if (result == null && !optional)
3754
throw new KeyNotFoundException("Could not find required child control: " + childName);
38-
39-
return child;
55+
return (T)result;
4056
}
4157

42-
private T FindChild<T>(IEnumerable<XNAControl> list, string controlName) where T : XNAControl
58+
public List<T> FindChildrenStartWith<T>(string prefix) where T : XNAControl
4359
{
44-
foreach (XNAControl child in list)
60+
List<T> result = new List<T>();
61+
VisitChild(new List<XNAControl>() { this }, (control) =>
4562
{
46-
if (child.Name == controlName)
47-
return (T)child;
48-
49-
T childOfChild = FindChild<T>(child.Children, controlName);
50-
if (childOfChild != null)
51-
return childOfChild;
52-
}
53-
54-
return null;
63+
if (string.IsNullOrEmpty(prefix) ||
64+
!string.IsNullOrEmpty(control.Name) && control.Name.StartsWith(prefix))
65+
result.Add((T)control);
66+
return false;
67+
});
68+
return result;
5569
}
5670

5771
/// <summary>

DXMainClient/DXGUI/GameClass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ private IServiceProvider BuildServiceProvider(WindowManager windowManager)
280280
.AddSingletonXnaControl<MapPreviewBox>()
281281
.AddSingletonXnaControl<GameLaunchButton>()
282282
.AddSingletonXnaControl<PlayerExtraOptionsPanel>()
283-
.AddSingletonXnaControl<CampaignSelector>()
283+
.AddSingletonXnaControl<CampaignTagSelector>()
284284
.AddSingletonXnaControl<GameLoadingWindow>()
285285
.AddSingletonXnaControl<StatisticsWindow>()
286286
.AddSingletonXnaControl<UpdateQueryWindow>()

0 commit comments

Comments
 (0)