Skip to content

Commit ba2aa28

Browse files
committed
Fix missing custom mission codes during last migration
1 parent 1485f2a commit ba2aa28

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

DXMainClient/DXGUI/Generic/CampaignSelector.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,15 @@ private void LoadCustomMissions()
417417
return;
418418

419419
string[] mapFiles = Directory.GetFiles(customMissionsDirectory, "*.map");
420+
if (mapFiles.Length == 0)
421+
return;
422+
423+
// Add a dummy mission to separate custom missions from official missions
424+
IniSection customMissionSeparatorSection = new();
425+
customMissionSeparatorSection.AddKey("Description", "-------- Custom Scenarios --------".L10N("Client:Main:CustomMissionSeparator"));
426+
Mission separator = Mission.NewCustomMission(customMissionSeparatorSection, "__XCUSTOM", string.Empty, null);
427+
AddMission(separator);
428+
420429
foreach (string mapFilePath in mapFiles)
421430
{
422431
var mapFile = new IniFile(mapFilePath);
@@ -482,7 +491,8 @@ private bool ParseBattleIni(string path)
482491
/// Load or re-load missons with selected tags.
483492
/// </summary>
484493
/// <param name="selectedTags">Missions with at lease one of which tags to be shown. As an exception, null means show all missions.</param>
485-
public void LoadMissionsWithFilter(ISet<string> selectedTags = null)
494+
/// <param name="loadCustomMissions">True means show official missions. False means show custom missions.</param>
495+
public void LoadMissionsWithFilter(ISet<string> selectedTags, bool loadCustomMissions = false)
486496
{
487497
lbCampaignListMissions.Clear();
488498

@@ -497,6 +507,7 @@ public void LoadMissionsWithFilter(ISet<string> selectedTags = null)
497507

498508
// Select missions with the filter
499509
IEnumerable<Mission> missions = AllMissions;
510+
missions = missions.Where(mission => mission.IsCustomMission == loadCustomMissions);
500511
if (selectedTags != null)
501512
missions = missions.Where(mission => mission.Tags.Intersect(selectedTags).Any()).ToList();
502513
lbCampaignListMissions = missions.ToList();

DXMainClient/DXGUI/Generic/CampaignTagSelector.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ public override void Initialize()
5656
Disable();
5757
};
5858

59+
btnShowCustomMission = FindChild<XNAClientButton>(nameof(btnShowCustomMission));
60+
btnShowCustomMission.LeftClick += (sender, e) =>
61+
{
62+
CampaignSelector.LoadMissionsWithFilter(null, true);
63+
CampaignSelector.Enable();
64+
Disable();
65+
};
66+
5967
const string TagButtonsPrefix = "ButtonTag_";
6068
var tagButtons = FindChildrenStartWith<XNAClientButton>(TagButtonsPrefix);
6169
foreach (var tagButton in tagButtons)

0 commit comments

Comments
 (0)