-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix AC6 param offsets and improve error detection (#820)
* Fix AC6 param offsets and improve error detection * Add unique row testing code
- Loading branch information
1 parent
08cb90a
commit cd102a6
Showing
4 changed files
with
151 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using ImGuiNET; | ||
using SoulsFormats; | ||
using StudioCore.ParamEditor; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace StudioCore.Tests; | ||
|
||
public static class ParamUniqueRowFinder | ||
{ | ||
private static int _searchID = 0; | ||
private static int _searchIndex = -1; | ||
|
||
public static void Display() | ||
{ | ||
ImGui.InputInt("id", ref _searchID); | ||
ImGui.InputInt("index", ref _searchIndex); | ||
if (ImGui.Button("Search##ParamUniqueInserter")) | ||
{ | ||
Find(_searchID, _searchIndex); | ||
} | ||
if (ImGui.Button("Insert unique row ID into every param")) | ||
{ | ||
var baseID = ParamBank.PrimaryBank.Params.Values.Max(p => p.Rows.Max(r => r.ID)) + 1; | ||
var i = baseID; | ||
foreach (var p in ParamBank.PrimaryBank.Params.Values) | ||
{ | ||
Andre.Formats.Param.Row row = new(p.Rows.First()); | ||
row.ID = i; | ||
i++; | ||
p.AddRow(row); | ||
} | ||
TaskLogs.AddLog($"Added rows to all params with IDs {baseID}-{i-1} ", | ||
Microsoft.Extensions.Logging.LogLevel.Debug, TaskLogs.LogPriority.High); | ||
} | ||
} | ||
|
||
|
||
public static bool Find(int id, int index) | ||
{ | ||
List<string> output = new(); | ||
foreach (var p in ParamBank.PrimaryBank.Params) | ||
{ | ||
for (var i = 0; i < p.Value.Rows.Count; i++) | ||
{ | ||
var r = p.Value.Rows[i]; | ||
if (r.ID == id | ||
&& (index == -1 || index == i)) | ||
{ | ||
output.Add(p.Key); | ||
} | ||
} | ||
} | ||
if (output.Count > 0) | ||
{ | ||
string message = ""; | ||
foreach (var line in output) | ||
{ | ||
message += $"{line}\n"; | ||
} | ||
TaskLogs.AddLog(message, | ||
Microsoft.Extensions.Logging.LogLevel.Debug, TaskLogs.LogPriority.High); | ||
} | ||
else | ||
{ | ||
TaskLogs.AddLog("No row IDs found", | ||
Microsoft.Extensions.Logging.LogLevel.Debug, TaskLogs.LogPriority.High); | ||
} | ||
|
||
|
||
return true; | ||
} | ||
} |