From 99d044ef0e7ea0887470a7aa0667f026eb727d18 Mon Sep 17 00:00:00 2001
From: Simon Judd <sirjuddington@gmail.com>
Date: Sat, 2 Dec 2023 14:56:28 +1030
Subject: [PATCH] Really fix clang compilation issue

Not sure why it couldn't disambiguate the functions since wxArrayString can't be constructed using an initializer list, either way I just removed it in favour of vector<wxString>
---
 .../UI/EntryPanel/DataEntryPanel.cpp          |  8 ++-----
 .../UI/EntryPanel/PaletteEntryPanel.cpp       | 13 ++++++-----
 .../UI/EntryPanel/TextEntryPanel.cpp          |  2 +-
 src/MapEditor/MapEditContext.cpp              | 17 +++++---------
 src/MapEditor/UI/ScriptEditorPanel.cpp        |  9 ++------
 src/UI/SToolBar/SToolBar.cpp                  | 22 +------------------
 src/UI/SToolBar/SToolBar.h                    |  3 +--
 src/UI/STopWindow.cpp                         |  2 +-
 src/UI/STopWindow.h                           |  2 +-
 9 files changed, 22 insertions(+), 56 deletions(-)

diff --git a/src/MainEditor/UI/EntryPanel/DataEntryPanel.cpp b/src/MainEditor/UI/EntryPanel/DataEntryPanel.cpp
index d15349ce2..95a03181c 100644
--- a/src/MainEditor/UI/EntryPanel/DataEntryPanel.cpp
+++ b/src/MainEditor/UI/EntryPanel/DataEntryPanel.cpp
@@ -922,12 +922,8 @@ DataEntryPanel::DataEntryPanel(wxWindow* parent) : EntryPanel(parent, "data"), t
 
 	// Add actions to toolbar
 	wxArrayString actions;
-	actions.Add("data_add_row");
-	actions.Add("data_delete_row");
-	actions.Add("data_cut_row");
-	actions.Add("data_copy_row");
-	actions.Add("data_paste_row");
-	toolbar_->addActionGroup("Data", actions);
+	toolbar_->addActionGroup(
+		"Data", { "data_add_row", "data_delete_row", "data_cut_row", "data_copy_row", "data_paste_row" });
 
 	// Bind events
 	Bind(wxEVT_KEY_DOWN, &DataEntryPanel::onKeyDown, this);
diff --git a/src/MainEditor/UI/EntryPanel/PaletteEntryPanel.cpp b/src/MainEditor/UI/EntryPanel/PaletteEntryPanel.cpp
index 76d3d734f..6143878f1 100644
--- a/src/MainEditor/UI/EntryPanel/PaletteEntryPanel.cpp
+++ b/src/MainEditor/UI/EntryPanel/PaletteEntryPanel.cpp
@@ -621,18 +621,19 @@ PaletteEntryPanel::PaletteEntryPanel(wxWindow* parent) : EntryPanel(parent, "pal
 	toolbar_->addGroup(group_palette);
 
 	// Current Palette
-	wxString actions = "ppal_moveup;ppal_movedown;ppal_duplicate;ppal_remove;ppal_removeothers";
-	toolbar_->addActionGroup("Palette Organisation", wxSplit(actions, ';'));
+	toolbar_->addActionGroup(
+		"Palette Organisation",
+		{ "ppal_moveup", "ppal_movedown", "ppal_duplicate", "ppal_remove", "ppal_removeothers" });
 
 	// Palette Entry Operations
-	actions = "ppal_addcustom;ppal_exportas;ppal_importfrom;ppal_test;ppal_generate";
-	toolbar_->addActionGroup("Palette Operations", wxSplit(actions, ';'));
+	toolbar_->addActionGroup(
+		"Palette Operations", { "ppal_addcustom", "ppal_exportas", "ppal_importfrom", "ppal_test", "ppal_generate" });
 
 	// --- Left toolbar ---
 
 	// Colour Operations
-	actions = "ppal_colourise;ppal_tint;ppal_invert;ppal_tweak;ppal_gradient";
-	toolbar_left_->addActionGroup("Colours", wxSplit(actions, ';'));
+	toolbar_left_->addActionGroup(
+		"Colours", { "ppal_colourise", "ppal_tint", "ppal_invert", "ppal_tweak", "ppal_gradient" });
 
 	// --- Palette canvas ---
 	pal_canvas_ = new PaletteCanvas(this, -1);
diff --git a/src/MapEditor/MapEditContext.cpp b/src/MapEditor/MapEditContext.cpp
index 73c64eabd..5327b8478 100644
--- a/src/MapEditor/MapEditContext.cpp
+++ b/src/MapEditor/MapEditContext.cpp
@@ -212,11 +212,8 @@ void MapEditContext::setEditMode(Mode mode)
 		// Sector mode toolbar
 		if (edit_mode_prev_ != Mode::Sectors)
 		{
-			wxArrayString actions;
-			actions.Add("mapw_sectormode_normal");
-			actions.Add("mapw_sectormode_floor");
-			actions.Add("mapw_sectormode_ceiling");
-			mapeditor::window()->addCustomToolBar("Sector Mode", actions);
+			mapeditor::window()->addCustomToolBar(
+				"Sector Mode", { "mapw_sectormode_normal", "mapw_sectormode_floor", "mapw_sectormode_ceiling" });
 		}
 
 		// Toggle current sector mode
@@ -231,9 +228,7 @@ void MapEditContext::setEditMode(Mode mode)
 	{
 		SAction::fromId("mapw_mode_things")->setChecked();
 
-		wxArrayString actions;
-		actions.Add("mapw_thing_light_previews");
-		mapeditor::window()->addCustomToolBar("Things Mode", actions);
+		mapeditor::window()->addCustomToolBar("Things Mode", { "mapw_thing_light_previews" });
 
 		SAction::fromId("mapw_thing_light_previews")->setChecked(thing_preview_lights);
 	}
@@ -670,9 +665,9 @@ void MapEditContext::updateTagged()
 				case TagType::Sector1Thing2:
 				{
 					int thingtag = (needs_tag == TagType::Sector1Thing2) ? arg2 : tag;
-					int sectag   = (needs_tag == TagType::Sector1Thing2) ?
-									 tag :
-									 (needs_tag == TagType::Thing1Sector2) ? arg2 : arg3;
+					int sectag   = (needs_tag == TagType::Sector1Thing2) ? tag :
+								   (needs_tag == TagType::Thing1Sector2) ? arg2 :
+																		   arg3;
 					if ((thingtag | sectag) == 0)
 						break;
 					else if (thingtag == 0)
diff --git a/src/MapEditor/UI/ScriptEditorPanel.cpp b/src/MapEditor/UI/ScriptEditorPanel.cpp
index e24440545..3fc42dbbb 100644
--- a/src/MapEditor/UI/ScriptEditorPanel.cpp
+++ b/src/MapEditor/UI/ScriptEditorPanel.cpp
@@ -72,9 +72,7 @@ EXTERN_CVAR(Bool, txed_trim_whitespace)
 // ScriptEditorPanel class constructor
 // -----------------------------------------------------------------------------
 ScriptEditorPanel::ScriptEditorPanel(wxWindow* parent) :
-	wxPanel(parent, -1),
-	entry_script_{ new ArchiveEntry() },
-	entry_compiled_{ new ArchiveEntry() }
+	wxPanel(parent, -1), entry_script_{ new ArchiveEntry() }, entry_compiled_{ new ArchiveEntry() }
 {
 	// Setup sizer
 	auto sizer = new wxBoxSizer(wxVERTICAL);
@@ -85,10 +83,7 @@ ScriptEditorPanel::ScriptEditorPanel(wxWindow* parent) :
 	sizer->Add(toolbar, 0, wxEXPAND);
 
 	wxArrayString actions;
-	actions.Add("mapw_script_save");
-	actions.Add("mapw_script_compile");
-	actions.Add("mapw_script_togglelanguage");
-	toolbar->addActionGroup("Scripts", actions);
+	toolbar->addActionGroup("Scripts", { "mapw_script_save", "mapw_script_compile", "mapw_script_togglelanguage" });
 
 	// Jump To toolbar group
 	auto group_jump_to = new SToolBarGroup(toolbar, "Jump To", true);
diff --git a/src/UI/SToolBar/SToolBar.cpp b/src/UI/SToolBar/SToolBar.cpp
index 051167e79..1b074543f 100644
--- a/src/UI/SToolBar/SToolBar.cpp
+++ b/src/UI/SToolBar/SToolBar.cpp
@@ -536,27 +536,7 @@ void SToolBar::deleteCustomGroups()
 // Adds a new group [name] to the toolbar, containing toolbar buttons for each
 // action in [actions]
 // -----------------------------------------------------------------------------
-void SToolBar::addActionGroup(const wxString& name, const wxArrayString& actions, bool at_end)
-{
-	// Do nothing if no actions were given
-	if (actions.empty())
-		return;
-
-	// Create new toolbar group
-	auto* group = new SToolBarGroup(this, name);
-	if (at_end)
-		groups_end_.push_back(group);
-	else
-		groups_.push_back(group);
-
-	// Add actions to the group
-	for (const auto& action : actions)
-		group->addActionButton(action);
-
-	// Update layout
-	updateLayout(true);
-}
-void SToolBar::addActionGroup(const wxString& name, const vector<string>& actions, bool at_end)
+void SToolBar::addActionGroup(const wxString& name, const vector<wxString>& actions, bool at_end)
 {
 	// Do nothing if no actions were given
 	if (actions.empty())
diff --git a/src/UI/SToolBar/SToolBar.h b/src/UI/SToolBar/SToolBar.h
index 82155843a..54243defc 100644
--- a/src/UI/SToolBar/SToolBar.h
+++ b/src/UI/SToolBar/SToolBar.h
@@ -73,8 +73,7 @@ class SToolBar : public wxPanel
 	void            addGroup(SToolBarGroup* group, bool at_end = false);
 	void            deleteGroup(const wxString& name);
 	void            deleteCustomGroups();
-	void            addActionGroup(const wxString& name, const wxArrayString& actions, bool at_end = false);
-	void            addActionGroup(const wxString& name, const vector<string>& actions, bool at_end = false);
+	void            addActionGroup(const wxString& name, const vector<wxString>& actions, bool at_end = false);
 	void            enableGroup(const wxString& name, bool enable = true);
 	void            populateGroupsMenu(wxMenu* menu, int start_id = 0) const;
 	void            enableContextMenu(bool enable = true) { enable_context_menu_ = enable; }
diff --git a/src/UI/STopWindow.cpp b/src/UI/STopWindow.cpp
index c8f97d63f..e7bb28510 100644
--- a/src/UI/STopWindow.cpp
+++ b/src/UI/STopWindow.cpp
@@ -152,7 +152,7 @@ void STopWindow::enableToolBar(const wxString& name, bool enable) const
 // Adds a custom toolbar group to the toolbar, with buttons for each action in
 // [actions]
 // -----------------------------------------------------------------------------
-void STopWindow::addCustomToolBar(const wxString& name, const wxArrayString& actions) const
+void STopWindow::addCustomToolBar(const wxString& name, const vector<wxString>& actions) const
 {
 	toolbar_->addActionGroup(name, actions);
 	populateToolbarsMenu();
diff --git a/src/UI/STopWindow.h b/src/UI/STopWindow.h
index 51e2400dc..7133f4680 100644
--- a/src/UI/STopWindow.h
+++ b/src/UI/STopWindow.h
@@ -24,7 +24,7 @@ class STopWindow : public wxFrame
 
 	// Toolbars
 	void enableToolBar(const wxString& name, bool enable = true) const;
-	void addCustomToolBar(const wxString& name, const wxArrayString& actions) const;
+	void addCustomToolBar(const wxString& name, const vector<wxString>& actions) const;
 	void removeCustomToolBar(const wxString& name) const;
 	void removeAllCustomToolBars() const;
 	void populateToolbarsMenu() const;
