Skip to content

Commit 1485f2a

Browse files
committed
Implement custom mission support with CampaignTagSelector
1 parent ac044f7 commit 1485f2a

12 files changed

+471
-118
lines changed

ClientCore/ClientConfiguration.cs

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

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

331+
public bool CampaignTagSelectorEnabled => clientDefinitionsIni.GetBooleanValue(SETTINGS, "CampaignTagSelectorEnabled", false);
332+
331333
public string GetGameExecutableName()
332334
{
333335
string[] exeNames = clientDefinitionsIni.GetStringValue(SETTINGS, "GameExecutableNames", "Game.exe").Split(',');
@@ -420,6 +422,11 @@ public List<string> GetIRCServers()
420422

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

425+
public string CustomMissionPath => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionPath", "Maps/CustomMissions");
426+
public string CustomMissionCsfName => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionCsfName", "stringtable99.csf");
427+
public string CustomMissionPalName => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionPalName", "custommission.pal");
428+
public string CustomMissionShpName => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionShpName", "custommission.shp");
429+
423430
public OSVersion GetOperatingSystemVersion()
424431
{
425432
#if NETFRAMEWORK

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ private IServiceProvider BuildServiceProvider(WindowManager windowManager)
235235
.AddSingletonXnaControl<CnCNetGameLoadingLobby>()
236236
.AddSingletonXnaControl<CnCNetLobby>()
237237
.AddSingletonXnaControl<GameInProgressWindow>()
238+
.AddSingletonXnaControl<CampaignTagSelector>()
239+
.AddSingletonXnaControl<GameLoadingWindow>()
238240
.AddSingletonXnaControl<SkirmishLobby>()
239241
.AddSingletonXnaControl<MainMenu>()
240242
.AddSingletonXnaControl<MapPreviewBox>()

0 commit comments

Comments
 (0)