/** SelectFilter.Script.txt a MapEditorPlugin for tm2020
*
* update 2022-05-22: make search ignore letter case and ignore ground for "grass".
* update 2022-12-27: fix manialink z-index
*
* usage: Enable plugin and press Ctrl-F to filter out blocks on map.
*
*/
#RequireContext CMapEditorPlugin
#Include "TextLib" as TL
#Const Version "1.0.1"
main() {
LayersDefaultManialinkVersion = 3;
ManialinkText = """
""";
while (True) {
yield;
foreach (Event in PendingEvents) {
switch (Event.Type) {
case CMapEditorPluginEvent::Type::LayerCustomEvent: {
if(Event.CustomEventType == "changeMode") {
PlaceMode = CMapEditorPlugin::PlaceMode::CopyPaste;
}
if(Event.CustomEventType == "gogo") {
declare Text value = (ManialinkPage.MainFrame.GetFirstChild("filter") as CMlEntry).Value;
declare CMlFrame waitDialog = (ManialinkPage.MainFrame.GetFirstChild("waitDialog") as CMlFrame);
if (value == "") continue;
CopyPaste_ResetSelection();
declare Integer counter = 0;
waitDialog.Show();
foreach (block in Blocks) {
if (block.BlockModel.Name == "Grass") continue;
declare Text[] match = TL::RegexMatch(TL::ToLowerCase(value), TL::ToLowerCase(block.BlockModel.Name), "");
if (match[0] == TL::ToLowerCase(value)) {
if (counter >= 200) {
counter = 0;
yield;
}
CopyPaste_AddOrSubSelection(block.Coord, block.Coord);
counter +=1;
}
}
waitDialog.Hide();
}
}
}
}
}
}