Remove all references to title editor

The title editor is now a plugin and these codepaths could only be reached during bugs :)
This commit is contained in:
duncanspumpkin 2023-06-29 08:14:29 +01:00
parent aa93b8d041
commit a68865d016
6 changed files with 21 additions and 44 deletions

View File

@ -285,7 +285,7 @@ public:
} }
case WindowClass::ScenarioSelect: case WindowClass::ScenarioSelect:
return WindowScenarioselectOpen( return WindowScenarioselectOpen(
reinterpret_cast<scenarioselect_callback>(intent->GetPointerExtra(INTENT_EXTRA_CALLBACK)), false); reinterpret_cast<scenarioselect_callback>(intent->GetPointerExtra(INTENT_EXTRA_CALLBACK)));
case WindowClass::Null: case WindowClass::Null:
// Intent does not hold a window class // Intent does not hold a window class

View File

@ -304,12 +304,10 @@ namespace OpenRCT2::Scripting
auto plugin = _scriptEngine.GetExecInfo().GetCurrentPlugin(); auto plugin = _scriptEngine.GetExecInfo().GetCurrentPlugin();
auto callback = desc["callback"]; auto callback = desc["callback"];
WindowScenarioselectOpen( WindowScenarioselectOpen([this, plugin, callback](std::string_view path) {
[this, plugin, callback](std::string_view path) { auto dukValue = GetScenarioFile(path);
auto dukValue = GetScenarioFile(path); _scriptEngine.ExecutePluginCall(plugin, callback, { dukValue }, false);
_scriptEngine.ExecutePluginCall(plugin, callback, { dukValue }, false); });
},
false);
} }
void activateTool(const DukValue& desc) void activateTool(const DukValue& desc)

View File

@ -112,15 +112,13 @@ class ScenarioSelectWindow final : public Window
{ {
private: private:
bool _showLockedInformation = false; bool _showLockedInformation = false;
bool _titleEditor = false;
std::function<void(std::string_view)> _callback; std::function<void(std::string_view)> _callback;
std::vector<ScenarioListItem> _listItems; std::vector<ScenarioListItem> _listItems;
const ScenarioIndexEntry* _highlightedScenario = nullptr; const ScenarioIndexEntry* _highlightedScenario = nullptr;
public: public:
ScenarioSelectWindow(std::function<void(std::string_view)> callback, bool isTitleEditor) ScenarioSelectWindow(std::function<void(std::string_view)> callback)
: _titleEditor(isTitleEditor) : _callback(callback)
, _callback(callback)
{ {
} }
@ -136,11 +134,6 @@ public:
InitScrollWidgets(); InitScrollWidgets();
} }
bool IsTitleEditor() const
{
return _titleEditor;
}
void OnMouseUp(WidgetIndex widgetIndex) override void OnMouseUp(WidgetIndex widgetIndex) override
{ {
if (widgetIndex == WIDX_CLOSE) if (widgetIndex == WIDX_CLOSE)
@ -184,7 +177,7 @@ public:
continue; continue;
auto ft = Formatter(); auto ft = Formatter();
if (gConfigGeneral.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN || IsTitleEditor()) if (gConfigGeneral.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN)
{ {
ft.Add<StringId>(kScenarioOriginStringIds[i]); ft.Add<StringId>(kScenarioOriginStringIds[i]);
} }
@ -392,7 +385,7 @@ public:
{ {
OpenRCT2::Audio::Play(OpenRCT2::Audio::SoundId::Click1, 0, windowPos.x + (width / 2)); OpenRCT2::Audio::Play(OpenRCT2::Audio::SoundId::Click1, 0, windowPos.x + (width / 2));
gFirstTimeSaving = true; gFirstTimeSaving = true;
Close(); // The callback will likely close this window so this is perhaps overkill // Callback will likely close this window! So should always return after it.
_callback(listItem.scenario.scenario->Path); _callback(listItem.scenario.scenario->Path);
return; return;
} }
@ -554,12 +547,10 @@ private:
if (!IsScenarioVisible(*scenario)) if (!IsScenarioVisible(*scenario))
continue; continue;
if (IsTitleEditor() && scenario->SourceGame == ScenarioSource::Other)
continue;
// Category heading // Category heading
StringId headingStringId = STR_NONE; StringId headingStringId = STR_NONE;
if (gConfigGeneral.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN || IsTitleEditor()) if (gConfigGeneral.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN)
{ {
if (selected_tab != static_cast<uint8_t>(ScenarioSource::Real) && currentHeading != scenario->Category) if (selected_tab != static_cast<uint8_t>(ScenarioSource::Real) && currentHeading != scenario->Category)
{ {
@ -664,7 +655,7 @@ private:
bool IsScenarioVisible(const ScenarioIndexEntry& scenario) const bool IsScenarioVisible(const ScenarioIndexEntry& scenario) const
{ {
if (gConfigGeneral.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN || IsTitleEditor()) if (gConfigGeneral.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN)
{ {
if (static_cast<uint8_t>(scenario.SourceGame) != selected_tab) if (static_cast<uint8_t>(scenario.SourceGame) != selected_tab)
{ {
@ -694,8 +685,6 @@ private:
return false; return false;
if (selected_tab >= 6) if (selected_tab >= 6)
return false; return false;
if (IsTitleEditor())
return false;
return true; return true;
} }
@ -707,10 +696,8 @@ private:
for (size_t i = 0; i < numScenarios; i++) for (size_t i = 0; i < numScenarios; i++)
{ {
const ScenarioIndexEntry* scenario = ScenarioRepositoryGetByIndex(i); const ScenarioIndexEntry* scenario = ScenarioRepositoryGetByIndex(i);
if (gConfigGeneral.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN || IsTitleEditor()) if (gConfigGeneral.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN)
{ {
if (IsTitleEditor() && scenario->SourceGame == ScenarioSource::Other)
continue;
showPages |= 1 << static_cast<uint8_t>(scenario->SourceGame); showPages |= 1 << static_cast<uint8_t>(scenario->SourceGame);
} }
else else
@ -774,30 +761,22 @@ private:
} }
}; };
WindowBase* WindowScenarioselectOpen(scenarioselect_callback callback, bool titleEditor) WindowBase* WindowScenarioselectOpen(scenarioselect_callback callback)
{ {
return WindowScenarioselectOpen( return WindowScenarioselectOpen([callback](std::string_view scenario) { callback(std::string(scenario).c_str()); });
[callback](std::string_view scenario) { callback(std::string(scenario).c_str()); }, titleEditor);
} }
WindowBase* WindowScenarioselectOpen(std::function<void(std::string_view)> callback, bool titleEditor) WindowBase* WindowScenarioselectOpen(std::function<void(std::string_view)> callback)
{ {
auto* window = static_cast<ScenarioSelectWindow*>(WindowBringToFrontByClass(WindowClass::ScenarioSelect)); auto* window = static_cast<ScenarioSelectWindow*>(WindowBringToFrontByClass(WindowClass::ScenarioSelect));
if (window != nullptr) if (window != nullptr)
{ {
if (window->IsTitleEditor() != titleEditor) return window;
{
WindowCloseByClass(WindowClass::ScenarioSelect);
}
else
{
return window;
}
} }
int32_t screenWidth = ContextGetWidth(); int32_t screenWidth = ContextGetWidth();
int32_t screenHeight = ContextGetHeight(); int32_t screenHeight = ContextGetHeight();
ScreenCoordsXY screenPos = { (screenWidth - WW) / 2, std::max(TOP_TOOLBAR_HEIGHT + 1, (screenHeight - WH) / 2) }; ScreenCoordsXY screenPos = { (screenWidth - WW) / 2, std::max(TOP_TOOLBAR_HEIGHT + 1, (screenHeight - WH) / 2) };
window = WindowCreate<ScenarioSelectWindow>(WindowClass::ScenarioSelect, screenPos, WW, WH, 0, callback, titleEditor); window = WindowCreate<ScenarioSelectWindow>(WindowClass::ScenarioSelect, screenPos, WW, WH, 0, callback);
return window; return window;
} }

View File

@ -134,7 +134,7 @@ public:
break; break;
case WIDX_START_SERVER: case WIDX_START_SERVER:
NetworkSetPassword(_password); NetworkSetPassword(_password);
WindowScenarioselectOpen(ScenarioSelectCallback, false); WindowScenarioselectOpen(ScenarioSelectCallback);
break; break;
case WIDX_LOAD_SERVER: case WIDX_LOAD_SERVER:
NetworkSetPassword(_password); NetworkSetPassword(_password);

View File

@ -132,7 +132,7 @@ public:
{ {
WindowCloseByClass(WindowClass::Loadsave); WindowCloseByClass(WindowClass::Loadsave);
WindowCloseByClass(WindowClass::ServerList); WindowCloseByClass(WindowClass::ServerList);
WindowScenarioselectOpen(WindowTitleMenuScenarioselectCallback, false); WindowScenarioselectOpen(WindowTitleMenuScenarioselectCallback);
} }
break; break;
case WIDX_CONTINUE_SAVED_GAME: case WIDX_CONTINUE_SAVED_GAME:

View File

@ -101,8 +101,8 @@ void WindowGuestListRefreshList();
WindowBase* WindowGuestListOpen(); WindowBase* WindowGuestListOpen();
WindowBase* WindowGuestListOpenWithFilter(GuestListFilterType type, int32_t index); WindowBase* WindowGuestListOpenWithFilter(GuestListFilterType type, int32_t index);
WindowBase* WindowStaffFirePromptOpen(Peep* peep); WindowBase* WindowStaffFirePromptOpen(Peep* peep);
WindowBase* WindowScenarioselectOpen(scenarioselect_callback callback, bool titleEditor); WindowBase* WindowScenarioselectOpen(scenarioselect_callback callback);
WindowBase* WindowScenarioselectOpen(std::function<void(std::string_view)> callback, bool titleEditor); WindowBase* WindowScenarioselectOpen(std::function<void(std::string_view)> callback);
WindowBase* WindowErrorOpen(StringId title, StringId message, const class Formatter& formatter); WindowBase* WindowErrorOpen(StringId title, StringId message, const class Formatter& formatter);
WindowBase* WindowErrorOpen(std::string_view title, std::string_view message); WindowBase* WindowErrorOpen(std::string_view title, std::string_view message);