From 0ed491cdb3a65615e2be5a8c04e4cdcd040715d6 Mon Sep 17 00:00:00 2001 From: Thom McGrath Date: Thu, 24 Oct 2024 13:38:19 -0400 Subject: [PATCH] Projects can force-enable mods --- .../ModSelectionGrid.xojo_window | 33 ++++++++++++------- Project/Modules/Beacon/Project.xojo_code | 6 ++++ Project/Modules/Beacon/StringList.xojo_code | 17 ++++++++++ .../Game Support/ArkSA/Project.xojo_code | 16 +++++++++ .../Loot Drops/ArkLootEntryEditor.xojo_window | 2 +- .../ArkSALootEntryEditor.xojo_window | 2 +- 6 files changed, 62 insertions(+), 14 deletions(-) diff --git a/Project/Custom Controls/ModSelectionGrid.xojo_window b/Project/Custom Controls/ModSelectionGrid.xojo_window index 08bae7186..e85a1e2d0 100644 --- a/Project/Custom Controls/ModSelectionGrid.xojo_window +++ b/Project/Custom Controls/ModSelectionGrid.xojo_window @@ -303,8 +303,8 @@ End Check.Width = CheckboxWidth Check.Left = NextLeft Check.Top = NextTop - Check.Value = Packs(Idx).Required Or Self.ModEnabled(Packs(Idx).ContentPackId) - Check.Enabled = (Packs(Idx).Required = False) + Check.Value = Packs(Idx).Required Or Self.ModEnabled(Packs(Idx).ContentPackId) Or Self.mForcedMods.Contains(Packs(Idx).ContentPackId) + Check.Enabled = (Packs(Idx).Required Or Self.mForcedMods.Contains(Packs(Idx).ContentPackId)) = False Self.mMap(Idx - StartIndex) = Packs(Idx).ContentPackId If (Idx + 1) Mod ColumnCount = 0 Then @@ -360,14 +360,11 @@ End #tag EndMethod #tag Method, Flags = &h0 - Sub Constructor(DataSource As Beacon.DataSource, EnabledMods As Beacon.StringList) - Var EmbeddedContentPacks() As Beacon.ContentPack - Self.Constructor(DataSource, EnabledMods, EmbeddedContentPacks) - End Sub - #tag EndMethod - - #tag Method, Flags = &h0 - Sub Constructor(DataSource As Beacon.DataSource, EnabledMods As Beacon.StringList, EmbeddedContentPacks() As Beacon.ContentPack) + Sub Constructor(DataSource As Beacon.DataSource, EnabledMods As Beacon.StringList, EmbeddedContentPacks() As Beacon.ContentPack, ForcedMods As Beacon.StringList) + If ForcedMods Is Nil Then + ForcedMods = New Beacon.StringList + End If + Self.mOfficialPacks = DataSource.GetContentPacks(Beacon.ContentPack.TypeOfficial) Self.mThirdPartyPacks = DataSource.GetContentPacks(Beacon.ContentPack.TypeThirdParty) @@ -390,13 +387,21 @@ End Self.mGameId = DataSource.Identifier Self.Constructor() - Self.EnabledMods = EnabledMods + Self.mForcedMods = ForcedMods + Self.EnabledMods = EnabledMods + ForcedMods + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor(DataSource As Beacon.DataSource, EnabledMods As Beacon.StringList, ForcedMods As Beacon.StringList) + Var EmbeddedContentPacks() As Beacon.ContentPack + Self.Constructor(DataSource, EnabledMods, EmbeddedContentPacks, ForcedMods) End Sub #tag EndMethod #tag Method, Flags = &h0 Sub Constructor(Project As Beacon.Project) - Self.Constructor(Project.DataSource(False), Project.ContentPacks, Project.EmbeddedContentPacks) + Self.Constructor(Project.DataSource(False), Project.ContentPacks, Project.EmbeddedContentPacks, Project.ForcedContentPacks) End Sub #tag EndMethod @@ -474,6 +479,10 @@ End Private mCustomPacks() As Beacon.ContentPack #tag EndProperty + #tag Property, Flags = &h21 + Private mForcedMods As Beacon.StringList + #tag EndProperty + #tag Property, Flags = &h21 Private mGameId As String #tag EndProperty diff --git a/Project/Modules/Beacon/Project.xojo_code b/Project/Modules/Beacon/Project.xojo_code index 5c1b816ff..696bd0f0c 100644 --- a/Project/Modules/Beacon/Project.xojo_code +++ b/Project/Modules/Beacon/Project.xojo_code @@ -506,6 +506,12 @@ Implements ObservationKit.Observable End Function #tag EndMethod + #tag Method, Flags = &h0 + Function ForcedContentPacks() As Beacon.StringList + Return Nil + End Function + #tag EndMethod + #tag Method, Flags = &h0 Shared Function FromSaveData(SaveData As Dictionary, Identity As Beacon.Identity) As Beacon.Project Var AdditionalProperties As New Dictionary diff --git a/Project/Modules/Beacon/StringList.xojo_code b/Project/Modules/Beacon/StringList.xojo_code index d71016267..00f06f22b 100644 --- a/Project/Modules/Beacon/StringList.xojo_code +++ b/Project/Modules/Beacon/StringList.xojo_code @@ -124,6 +124,23 @@ Implements Iterable End Function #tag EndMethod + #tag Method, Flags = &h0 + Function Operator_Add(Other As Beacon.StringList) As Beacon.StringList + Var NewList As New Beacon.StringList + For Each Member As String In Self.mItems + NewList.mItems.Add(Member) + Next + If (Other Is Nil) = False Then + For Each Member As String In Other.mItems + If NewList.mItems.IndexOf(Member) = -1 Then + NewList.mItems.Add(Member) + End If + Next + End If + Return NewList + End Function + #tag EndMethod + #tag Method, Flags = &h0 Function Operator_Compare(Other As Beacon.StringList) As Integer If Other = Nil Then diff --git a/Project/Modules/Game Support/ArkSA/Project.xojo_code b/Project/Modules/Game Support/ArkSA/Project.xojo_code index 057c4fb91..60422e86c 100644 --- a/Project/Modules/Game Support/ArkSA/Project.xojo_code +++ b/Project/Modules/Game Support/ArkSA/Project.xojo_code @@ -800,6 +800,22 @@ Inherits Beacon.Project End Function #tag EndMethod + #tag Method, Flags = &h0 + Function ForcedContentPacks() As Beacon.StringList + Var Mods As Beacon.StringList = Super.ForcedContentPacks() + If Mods Is Nil Then + Mods = New Beacon.StringList + End If + + Var Maps() As Beacon.Map = ArkSA.Maps.ForMask(Self.mMapMask) + For Each Map As Beacon.Map In Maps + Mods.Append(Map.ContentPackId) + Next + + Return Mods + End Function + #tag EndMethod + #tag Method, Flags = &h0 Function GameId() As String Return ArkSA.Identifier diff --git a/Project/Views/Ark/Config Editors/Loot Drops/ArkLootEntryEditor.xojo_window b/Project/Views/Ark/Config Editors/Loot Drops/ArkLootEntryEditor.xojo_window index 77e2232d5..21a96946f 100644 --- a/Project/Views/Ark/Config Editors/Loot Drops/ArkLootEntryEditor.xojo_window +++ b/Project/Views/Ark/Config Editors/Loot Drops/ArkLootEntryEditor.xojo_window @@ -1005,7 +1005,7 @@ End Return End If - Var ModPicker As New ModSelectionGrid(Ark.DataSource.Pool.Get(False), Self.mMods) + Var ModPicker As New ModSelectionGrid(Ark.DataSource.Pool.Get(False), Self.mMods, Nil) Var Controller As New PopoverController("Select Mods", ModPicker) Controller.Show(Me) diff --git a/Project/Views/ArkSA/Config Editors/Loot Drops/ArkSALootEntryEditor.xojo_window b/Project/Views/ArkSA/Config Editors/Loot Drops/ArkSALootEntryEditor.xojo_window index ddafc7a87..edc55cd95 100644 --- a/Project/Views/ArkSA/Config Editors/Loot Drops/ArkSALootEntryEditor.xojo_window +++ b/Project/Views/ArkSA/Config Editors/Loot Drops/ArkSALootEntryEditor.xojo_window @@ -1005,7 +1005,7 @@ End Return End If - Var ModPicker As New ModSelectionGrid(ArkSA.DataSource.Pool.Get(False), Self.mMods) + Var ModPicker As New ModSelectionGrid(ArkSA.DataSource.Pool.Get(False), Self.mMods, Nil) Var Controller As New PopoverController("Select Mods", ModPicker) Controller.Show(Me)