Skip to content

Commit

Permalink
Recently used blueprints will respect tags
Browse files Browse the repository at this point in the history
  • Loading branch information
thommcgrath committed Dec 29, 2023
1 parent 2466c21 commit f3d9102
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
22 changes: 22 additions & 0 deletions Project/Modules/Game Support/Ark.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,28 @@ Protected Module Ark
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function MatchesTags(Extends Blueprint As Ark.Blueprint, RequiredTags() As String, ExcludedTags() As String) As Boolean
If (RequiredTags Is Nil) = False Then
For Each Tag As String In RequiredTags
If Blueprint.IsTagged(Tag) = False Then
Return False
End If
Next
End If

If (ExcludedTags Is Nil) = False Then
For Each Tag As String In ExcludedTags
If Blueprint.IsTagged(Tag) = True Then
Return False
End If
Next
End If

Return True
End Function
#tag EndMethod

#tag Method, Flags = &h1
Protected Function NormalizeBlueprintPath(Path As String, FolderName As String) As String
Path = Path.Trim
Expand Down
22 changes: 22 additions & 0 deletions Project/Modules/Game Support/ArkSA.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,28 @@ Protected Module ArkSA
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function MatchesTags(Extends Blueprint As ArkSA.Blueprint, RequiredTags() As String, ExcludedTags() As String) As Boolean
If (RequiredTags Is Nil) = False Then
For Each Tag As String In RequiredTags
If Blueprint.IsTagged(Tag) = False Then
Return False
End If
Next
End If

If (ExcludedTags Is Nil) = False Then
For Each Tag As String In ExcludedTags
If Blueprint.IsTagged(Tag) = True Then
Return False
End If
Next
End If

Return True
End Function
#tag EndMethod

#tag Method, Flags = &h1
Protected Function ModTagFromPath(Path As String) As String
If Path.BeginsWith("/Game/Mods/") Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,25 @@ End


#tag Method, Flags = &h21
Private Sub AddBlueprintsToList(Blueprints() As Ark.Blueprint, Blacklist() As String, AddToBlacklist As Boolean)
Private Sub AddBlueprintsToList(Blueprints() As Ark.Blueprint, Blacklist() As String, AddToBlacklist As Boolean, CheckTags As Boolean)
Var RequiredTags(), ExcludedTags() As String
If CheckTags Then
Try
RequiredTags = Self.Picker.RequiredTags()
ExcludedTags = Self.Picker.ExcludedTags()
Catch Err As RuntimeException
End Try
End If

For Each Blueprint As Ark.Blueprint In Blueprints
If Blacklist.IndexOf(Blueprint.BlueprintId) > -1 Then
Continue
End If

If CheckTags = True And Blueprint.MatchesTags(RequiredTags, ExcludedTags) = False Then
Continue
End If

Self.List.AddRow(Blueprint.Label, Blueprint.ContentPackName)
Self.List.RowTagAt(Self.List.LastAddedRowIndex) = Blueprint

Expand Down Expand Up @@ -725,11 +738,11 @@ End
Var RecentPaths() As String = Preferences.ArkRecentBlueprints(Self.mCategory, Self.mSubgroup)
For Each Path As String In RecentPaths
Var BlueprintsAtPath() As Ark.Blueprint = DataSource.GetBlueprintsByPath(Path, Self.mMods)
Self.AddBlueprintsToList(BlueprintsAtPath, Blacklist, True)
Self.AddBlueprintsToList(BlueprintsAtPath, Blacklist, True, True)
Next

Var Blueprints() As Ark.Blueprint = DataSource.GetBlueprints(Self.mCategory, SearchText, Self.mMods, Tags)
Self.AddBlueprintsToList(Blueprints, Blacklist, False)
Self.AddBlueprintsToList(Blueprints, Blacklist, False, True)
Self.List.ScrollPosition = ScrollPosition
End Sub
#tag EndMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,25 @@ End


#tag Method, Flags = &h21
Private Sub AddBlueprintsToList(Blueprints() As ArkSA.Blueprint, Blacklist() As String, AddToBlacklist As Boolean)
Private Sub AddBlueprintsToList(Blueprints() As ArkSA.Blueprint, Blacklist() As String, AddToBlacklist As Boolean, CheckTags As Boolean)
Var RequiredTags(), ExcludedTags() As String
If CheckTags Then
Try
RequiredTags = Self.Picker.RequiredTags()
ExcludedTags = Self.Picker.ExcludedTags()
Catch Err As RuntimeException
End Try
End If

For Each Blueprint As ArkSA.Blueprint In Blueprints
If Blacklist.IndexOf(Blueprint.BlueprintId) > -1 Then
Continue
End If

If CheckTags = True And Blueprint.MatchesTags(RequiredTags, ExcludedTags) = False Then
Continue
End If

Self.List.AddRow(Blueprint.Label, Blueprint.ContentPackName)
Self.List.RowTagAt(Self.List.LastAddedRowIndex) = Blueprint

Expand Down Expand Up @@ -725,11 +738,11 @@ End
Var RecentPaths() As String = Preferences.ArkSARecentBlueprints(Self.mCategory, Self.mSubgroup)
For Each Path As String In RecentPaths
Var BlueprintsAtPath() As ArkSA.Blueprint = DataSource.GetBlueprintsByPath(Path, Self.mMods)
Self.AddBlueprintsToList(BlueprintsAtPath, Blacklist, True)
Self.AddBlueprintsToList(BlueprintsAtPath, Blacklist, True, True)
Next

Var Blueprints() As ArkSA.Blueprint = DataSource.GetBlueprints(Self.mCategory, SearchText, Self.mMods, Tags)
Self.AddBlueprintsToList(Blueprints, Blacklist, False)
Self.AddBlueprintsToList(Blueprints, Blacklist, False, False)
Self.List.ScrollPosition = ScrollPosition
End Sub
#tag EndMethod
Expand Down

0 comments on commit f3d9102

Please sign in to comment.