Skip to content

Commit

Permalink
Projects can force-enable mods
Browse files Browse the repository at this point in the history
  • Loading branch information
thommcgrath committed Oct 24, 2024
1 parent 0c94541 commit 0ed491c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 14 deletions.
33 changes: 21 additions & 12 deletions Project/Custom Controls/ModSelectionGrid.xojo_window
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Project/Modules/Beacon/Project.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions Project/Modules/Beacon/StringList.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions Project/Modules/Game Support/ArkSA/Project.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 0ed491c

Please sign in to comment.