From 6ebc8a24bfab6e4ec41e347b2ca88485405aa649 Mon Sep 17 00:00:00 2001 From: Philiquaz Date: Mon, 4 Dec 2023 21:45:18 +0000 Subject: [PATCH] Uniqueness search and updates to merge scripts --- .../Common/{SlowMerge.txt => FieldMerge.txt} | 4 ++-- .../Assets/MassEditScripts/Common/QuickMerge.txt | 2 +- src/StudioCore/ParamEditor/SearchEngine.cs | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) rename src/StudioCore/Assets/MassEditScripts/Common/{SlowMerge.txt => FieldMerge.txt} (52%) diff --git a/src/StudioCore/Assets/MassEditScripts/Common/SlowMerge.txt b/src/StudioCore/Assets/MassEditScripts/Common/FieldMerge.txt similarity index 52% rename from src/StudioCore/Assets/MassEditScripts/Common/SlowMerge.txt rename to src/StudioCore/Assets/MassEditScripts/Common/FieldMerge.txt index 588fc13b9..063ed283c 100644 --- a/src/StudioCore/Assets/MassEditScripts/Common/SlowMerge.txt +++ b/src/StudioCore/Assets/MassEditScripts/Common/FieldMerge.txt @@ -1,5 +1,5 @@ ##Make sure to use the compare menu first. ##Once the additional regulation is loaded, its name should appear in both the menu and at the top of the field list. newvar regulationFolderName:mod; -auxparam $regulationFolderName .*: !conflicts: paste; -param .*: conflicts: !modified && auxmodified $regulationFolderName: = aux $regulationFolderName; \ No newline at end of file +auxparam $regulationFolderName .*: !conflicts && unique ID: paste; +param .*: conflicts && unique ID: !modified && auxmodified $regulationFolderName: = aux $regulationFolderName; diff --git a/src/StudioCore/Assets/MassEditScripts/Common/QuickMerge.txt b/src/StudioCore/Assets/MassEditScripts/Common/QuickMerge.txt index c49f8e456..2268a7500 100644 --- a/src/StudioCore/Assets/MassEditScripts/Common/QuickMerge.txt +++ b/src/StudioCore/Assets/MassEditScripts/Common/QuickMerge.txt @@ -1,4 +1,4 @@ ##Make sure to use the compare menu first. ##Once the additional regulation is loaded, its name should appear in both the menu and at the top of the field list. newvar regulationFolderName:mod; -auxparam $regulationFolderName .*: modified: paste; \ No newline at end of file +auxparam $regulationFolderName .*: modified && unique ID: paste; diff --git a/src/StudioCore/ParamEditor/SearchEngine.cs b/src/StudioCore/ParamEditor/SearchEngine.cs index 7feb3c400..594d5844e 100644 --- a/src/StudioCore/ParamEditor/SearchEngine.cs +++ b/src/StudioCore/ParamEditor/SearchEngine.cs @@ -726,6 +726,22 @@ internal override void Setup() }; }; }, () => CFG.Current.Param_AdvancedMassedit)); + filterList.Add("unique", newCmd(new string[] { "field" }, "Selects all rows where the value in the given field is unique", (args, lenient) => + { + string field = args[0].Replace(@"\s", " "); + return (param) => + { + var col = param.Item2.GetCol(field); + if (!col.IsColumnValid()) + throw new Exception("Could not find field " + field); + var distribution = ParamUtils.GetParamValueDistribution(param.Item2.Rows, col); + var setOfDuped = distribution.Where((entry, linqi) => entry.Item2 > 1).Select((entry, linqi) => entry.Item1).ToHashSet(); + return (row) => + { + return !setOfDuped.Contains(row.Get(col)); + }; + }; + }, () => CFG.Current.Param_AdvancedMassedit)); defaultFilter = newCmd(new[] { "row ID or Name (regex)" }, "Selects rows where either the ID or Name matches the given regex, except in strict/massedit mode", (args, lenient) =>