Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement custom mission support with CampaignTagSelector #518

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions ClientCore/ClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ private List<TranslationGameFile> ParseTranslationGameFiles()

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

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

public string GetGameExecutableName()
{
string[] exeNames = clientDefinitionsIni.GetStringValue(SETTINGS, "GameExecutableNames", "Game.exe").Split(',');
Expand Down Expand Up @@ -420,6 +422,11 @@ public List<string> GetIRCServers()

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

public string CustomMissionPath => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionPath", "Maps/CustomMissions");
public string CustomMissionCsfName => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionCsfName", "stringtable99.csf");
public string CustomMissionPalName => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionPalName", "custommission.pal");
public string CustomMissionShpName => clientDefinitionsIni.GetStringValue(SETTINGS, "CustomMissionShpName", "custommission.shp");

public OSVersion GetOperatingSystemVersion()
{
#if NETFRAMEWORK
Expand Down
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
2 changes: 2 additions & 0 deletions DXMainClient/DXGUI/GameClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Rampastring.Tools;
using Rampastring.XNAUI;
using System;
using ClientGUI;

Check warning on line 13 in DXMainClient/DXGUI/GameClass.cs

View workflow job for this annotation

GitHub Actions / build-clients (Ares)

The using directive for 'ClientGUI' appeared previously in this namespace

Check warning on line 13 in DXMainClient/DXGUI/GameClass.cs

View workflow job for this annotation

GitHub Actions / build-clients (TS)

The using directive for 'ClientGUI' appeared previously in this namespace

Check warning on line 13 in DXMainClient/DXGUI/GameClass.cs

View workflow job for this annotation

GitHub Actions / build-clients (YR)

The using directive for 'ClientGUI' appeared previously in this namespace
using DTAClient.Domain.Multiplayer;
using DTAClient.Domain.Multiplayer.CnCNet;
using DTAClient.DXGUI.Multiplayer;
Expand Down Expand Up @@ -235,6 +235,8 @@
.AddSingletonXnaControl<CnCNetGameLoadingLobby>()
.AddSingletonXnaControl<CnCNetLobby>()
.AddSingletonXnaControl<GameInProgressWindow>()
.AddSingletonXnaControl<CampaignTagSelector>()
.AddSingletonXnaControl<GameLoadingWindow>()
.AddSingletonXnaControl<SkirmishLobby>()
.AddSingletonXnaControl<MainMenu>()
.AddSingletonXnaControl<MapPreviewBox>()
Expand Down
Loading
Loading