From 31f1b62a4c181aef43c89003874e16e7d14d521c Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 13 Jul 2021 22:09:49 -0400 Subject: [PATCH] Disallow CGOL with duplicate rulestrings or names > 7 chars --- src/gui/game/GOLTool.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gui/game/GOLTool.cpp b/src/gui/game/GOLTool.cpp index 6f613a4d6..0bb27389f 100644 --- a/src/gui/game/GOLTool.cpp +++ b/src/gui/game/GOLTool.cpp @@ -1,18 +1,18 @@ #include "Tool.h" -#include "simulation/GOLString.h" - #include "client/Client.h" #include "common/tpt-rand.h" +#include "simulation/GOLString.h" +#include "simulation/Simulation.h" #include "gui/Style.h" -#include "gui/game/GameModel.h" -#include "gui/interface/Window.h" #include "gui/interface/Button.h" #include "gui/interface/Label.h" #include "gui/interface/Textbox.h" -#include "gui/dialogues/ErrorMessage.h" +#include "gui/interface/Window.h" #include "gui/colourpicker/ColourPickerActivity.h" +#include "gui/dialogues/ErrorMessage.h" +#include "gui/game/GameModel.h" #include "graphics/Graphics.h" @@ -64,6 +64,7 @@ toolSelection(toolSelection) nameField = new ui::Textbox(ui::Point(8, 25), ui::Point(Size.X-16, 16), "", "[name]"); nameField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; nameField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; + nameField->SetLimit(7); AddComponent(nameField); FocusComponent(nameField); @@ -145,6 +146,11 @@ void GOLWindow::Validate() new ErrorMessage("Could not add GOL type", "Invalid rule provided"); return; } + if (sim->GetCustomGOLByRule(rule)) + { + new ErrorMessage("Could not add GOL type", "This Custom GoL rule already exists"); + return; + } ruleString = SerialiseGOLRule(rule); // * Make it canonical. Client::Ref().SetPrefUnicode("CustomGOL.Name", nameString);