1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 11:33:03 +01:00

Merge pull request #16864 from IntelOrca/remove-title-editor

Remove built-in title editor
This commit is contained in:
Michael Steenbeek
2022-04-26 22:39:23 +02:00
committed by GitHub
13 changed files with 73 additions and 2247 deletions

View File

@@ -2553,8 +2553,6 @@ STR_5250 :Title Exit Button
STR_5251 :Title Options Button
STR_5252 :Title Scenario Selection
STR_5253 :Park Information
STR_5254 :Create
STR_5255 :Create a new title sequence from scratch
STR_5256 :Create a new theme to make changes to
STR_5257 :Create a new theme based on the current one
STR_5258 :Delete the current theme
@@ -2649,75 +2647,10 @@ STR_5373 :Name {STRINGID}
STR_5374 :Date {STRINGID}
STR_5375 :▲
STR_5376 :▼
STR_5377 :Saves
STR_5378 :Script
STR_5379 :Skip to next wait command
STR_5380 :Start playing title sequence
STR_5381 :Stop playing title sequence
STR_5382 :Restart title sequence
STR_5383 :Create a new title sequence based on the current one
STR_5384 :Delete the current title sequence
STR_5385 :Rename the current title sequence
STR_5386 :Insert a new command
STR_5387 :Edit the selected command
STR_5388 :Delete the selected command
STR_5389 :Skip to the selected command in the title sequence
STR_5390 :Move the selected command down
STR_5391 :Move the selected command up
STR_5392 :Add a save to the title sequence
STR_5393 :Remove the selected save from the title sequence
STR_5394 :Rename the selected save
STR_5395 :Load the selected save in game
STR_5396 :Reload the title sequence if changes have been made to it outside of the game
STR_5397 :Can only be used on the title screen
STR_5398 :Cannot edit title sequence while its playing
STR_5399 :Press the stop button to continue editing
STR_5400 :Cant change this title sequence
STR_5401 :Create a new title sequence to make changes to
STR_5402 :Failed to load title sequence
STR_5403 :There may be no Load or Wait command or a save may be invalid
STR_5404 :Name already exists
STR_5405 :Enter a name for the save
STR_5406 :Enter a name for the title sequence
STR_5407 :Add
STR_5408 :Remove
STR_5409 :Insert
STR_5410 :Edit
STR_5411 :Reload
STR_5412 :Skip to
STR_5413 :Load
STR_5415 :Load{MOVE_X}{87}{STRING}
STR_5416 :Load{MOVE_X}{87}No save selected
STR_5417 :Location
STR_5418 :Location{MOVE_X}{87}{COMMA16} {COMMA16}
STR_5419 :Rotate
STR_5420 :Rotate{MOVE_X}{87}{COMMA16}
STR_5421 :Zoom
STR_5422 :Zoom{MOVE_X}{87}{COMMA16}
STR_5423 :Wait
STR_5424 :Wait{MOVE_X}{87}{UINT16}
STR_5425 :Restart
STR_5426 :End
STR_5427 :Coordinates:
STR_5428 :Anticlockwise rotations:
STR_5429 :Zoom level:
STR_5430 :Milliseconds to wait:
STR_5431 :Save to load:
STR_5432 :Command:
STR_5433 :Title Sequences
STR_5434 :Command Editor
STR_5435 :Rename save
STR_5436 :Edit Title Sequences…
STR_5437 :No save selected
STR_5438 :Cant make changes while command editor is open
STR_5439 :A wait command with at least 4 seconds is required with a restart command
STR_5440 :Minimise fullscreen on focus loss
STR_5441 :Identifies rides by track type{NEWLINE}so vehicles can be changed{NEWLINE}afterwards (RCT1 behaviour)
STR_5442 :Force park rating:
STR_5443 :Speed{MOVE_X}{87}{STRINGID}
STR_5444 :Speed:
STR_5445 :Speed
STR_5446 :Get
STR_5447 :Type {STRINGID}
STR_5448 :Ride / Vehicle {STRINGID}
STR_5449 :Reduce game speed
@@ -3073,7 +3006,6 @@ STR_5844 :Stay connected to a multiplayer server{NEWLINE}even if a desync or
STR_5845 :Adds a button for{NEWLINE}debugging tools to the toolbar.{NEWLINE}Enables keyboard shortcut for developer console
STR_5846 :Set how often OpenRCT2 automatically saves
STR_5847 :Select park sequence used on the title screen.{NEWLINE}Title sequences from RCT1/2 require imported scenarios to function
STR_5848 :Create and manage custom title sequences
STR_5849 :Automatically place{NEWLINE}newly hired staff members
STR_5851 :Sets the default inspection interval{NEWLINE}on newly built rides
STR_5853 :Toggle sound effects on/off
@@ -3387,23 +3319,8 @@ STR_6170 :Interface Tweaks
STR_6171 :Search
STR_6172 :Search
STR_6173 :Please provide the name to search:
STR_6174 :Load Save
STR_6175 :Load Scenario
STR_6176 :Scenario to load:
STR_6177 :Load{MOVE_X}{87}No scenario selected
STR_6178 :Load{MOVE_X}{87}{RED}Missing scenario
STR_6179 :Select
STR_6180 :No scenario selected
STR_6181 :{RED}Missing scenario
STR_6182 :Follow{MOVE_X}{87}{STRING}
STR_6183 :Follow{MOVE_X}{87}No sprite selected
STR_6184 :Follow Sprite
STR_6185 :Select Sprite
STR_6186 :No sprite selected
STR_6187 :{OUTLINE}{WINDOW_COLOUR_2}{STRING}
STR_6188 :Vomit
STR_6189 :Duck
STR_6190 :You cannot select a sprite while the main title screen is active.
STR_6191 :Surface
STR_6192 :Wall
STR_6193 :{COMMA16} guest

View File

@@ -1,6 +1,7 @@
0.4.1 (in development)
------------------------------------------------------------------------
- Fix: [#16974] Small scenery ghosts can be deleted.
- Removed: [#16864] Title sequence editor (replaced by plug-in).
0.4.0 (2022-04-25)
------------------------------------------------------------------------

View File

@@ -171,7 +171,6 @@ static constexpr const WindowThemeDesc WindowThemeDescriptors[] =
{ THEME_WC(WC_STAFF), STR_THEMES_WINDOW_STAFF, COLOURS_3(COLOUR_GREY, COLOUR_LIGHT_PURPLE, COLOUR_LIGHT_PURPLE ) },
{ THEME_WC(WC_EDITOR_TRACK_BOTTOM_TOOLBAR), STR_THEMES_WINDOW_BOTTOM_TOOLBAR_TRACK_EDITOR, COLOURS_3(TRANSLUCENT(COLOUR_LIGHT_BLUE), TRANSLUCENT(COLOUR_LIGHT_BLUE), TRANSLUCENT(COLOUR_LIGHT_BLUE) ) },
{ THEME_WC(WC_EDITOR_SCENARIO_BOTTOM_TOOLBAR), STR_THEMES_WINDOW_BOTTOM_TOOLBAR_SCENARIO_EDITOR, COLOURS_3(TRANSLUCENT(COLOUR_LIGHT_BROWN), TRANSLUCENT(COLOUR_LIGHT_BROWN), TRANSLUCENT(COLOUR_MOSS_GREEN) ) },
{ THEME_WC(WC_TITLE_EDITOR), STR_TITLE_EDITOR_TITLE, COLOURS_3(COLOUR_GREY, COLOUR_OLIVE_GREEN, COLOUR_OLIVE_GREEN ) },
{ THEME_WC(WC_TILE_INSPECTOR), STR_TILE_INSPECTOR_TITLE, COLOURS_2(COLOUR_LIGHT_BLUE, COLOUR_LIGHT_BLUE ) },
{ THEME_WC(WC_VIEW_CLIPPING), STR_VIEW_CLIPPING_TITLE, COLOURS_1(COLOUR_DARK_GREEN ) },
{ THEME_WC(WC_PATROL_AREA), STR_SET_PATROL_AREA, COLOURS_3(COLOUR_LIGHT_PURPLE, COLOUR_LIGHT_PURPLE, COLOUR_LIGHT_PURPLE ) },

View File

@@ -180,8 +180,6 @@
<ClCompile Include="windows\TextInput.cpp" />
<ClCompile Include="windows\Themes.cpp" />
<ClCompile Include="windows\TileInspector.cpp" />
<ClCompile Include="windows\TitleCommandEditor.cpp" />
<ClCompile Include="windows\TitleEditor.cpp" />
<ClCompile Include="windows\TitleExit.cpp" />
<ClCompile Include="windows\TitleLogo.cpp" />
<ClCompile Include="windows\TitleMenu.cpp" />

View File

@@ -172,11 +172,8 @@ enum WindowOptionsWidgetIdx {
// Misc
WIDX_TITLE_SEQUENCE_GROUP = WIDX_PAGE_START,
WIDX_TITLE_SEQUENCE_RANDOM,
WIDX_TITLE_SEQUENCE_LABEL,
WIDX_TITLE_SEQUENCE,
WIDX_TITLE_SEQUENCE_DROPDOWN,
WIDX_TITLE_SEQUENCE_BUTTON,
WIDX_SCENARIO_GROUP,
WIDX_SCENARIO_GROUPING_LABEL,
WIDX_SCENARIO_GROUPING,
@@ -344,28 +341,25 @@ static rct_widget window_options_controls_and_interface_widgets[] = {
#undef TOOLBAR_GROUP_START
};
#define TITLE_SEQUENCE_START 53
#define SCENARIO_START (TITLE_SEQUENCE_START + 35)
#define SCENARIO_OPTIONS_START (SCENARIO_START + 55)
#define TWEAKS_START (SCENARIO_OPTIONS_START + 39)
static rct_widget window_options_misc_widgets[] = {
MAIN_OPTIONS_WIDGETS,
#define TITLE_SEQUENCE_START 53
MakeWidget({ 5, TITLE_SEQUENCE_START + 0}, {300, 65}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_OPTIONS_TITLE_SEQUENCE ),
MakeWidget({ 10, TITLE_SEQUENCE_START + 15}, {290, 16}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_OPTIONS_RANDOM_TITLE_SEQUENCE ), // Random Title Sequence
MakeWidget({ 10, TITLE_SEQUENCE_START + 33}, {125, 12}, WindowWidgetType::Label, WindowColour::Secondary, STR_TITLE_SEQUENCE, STR_TITLE_SEQUENCE_TIP ),
MakeWidget({135, TITLE_SEQUENCE_START + 32}, {165, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary, STR_STRING ), // Title sequence dropdown
MakeWidget({288, TITLE_SEQUENCE_START + 33}, { 11, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH, STR_TITLE_SEQUENCE_TIP ), // Title sequence dropdown button
MakeWidget({135, TITLE_SEQUENCE_START + 48}, {165, 13}, WindowWidgetType::Button, WindowColour::Secondary, STR_EDIT_TITLE_SEQUENCES_BUTTON, STR_EDIT_TITLE_SEQUENCES_BUTTON_TIP), // Edit title sequences button
#undef TITLE_SEQUENCE_START
#define SCENARIO_START 122
MakeWidget( { 5, TITLE_SEQUENCE_START + 0}, {300, 31}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_OPTIONS_TITLE_SEQUENCE ),
MakeDropdownWidgets({ 10, TITLE_SEQUENCE_START + 15}, {290, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary, STR_STRINGID, STR_TITLE_SEQUENCE_TIP), // Title sequence dropdown
MakeWidget({ 5, SCENARIO_START + 0}, {300, 51}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_OPTIONS_SCENARIO_SELECTION ),
MakeWidget({ 10, SCENARIO_START + 16}, {165, 12}, WindowWidgetType::Label, WindowColour::Secondary, STR_OPTIONS_SCENARIO_GROUPING, STR_SCENARIO_GROUPING_TIP ),
MakeWidget({175, SCENARIO_START + 15}, {125, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // Scenario select mode
MakeWidget({288, SCENARIO_START + 16}, { 11, 10}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH, STR_SCENARIO_GROUPING_TIP ),
MakeWidget({ 25, SCENARIO_START + 30}, {275, 16}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_OPTIONS_SCENARIO_UNLOCKING, STR_SCENARIO_UNLOCKING_TIP), // Unlocking of scenarios
#undef SCENARIO_START
#define SCENARIO_OPTIONS_START 177
MakeWidget({ 5, SCENARIO_OPTIONS_START + 0}, {300, 35}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_SCENARIO_OPTIONS ),
MakeWidget({10, SCENARIO_OPTIONS_START + 15}, {290, 15}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_ALLOW_EARLY_COMPLETION, STR_EARLY_COMPLETION_TIP), // Allow early scenario completion
#undef SCENARIO_OPTIONS_START
#define TWEAKS_START 216
MakeWidget({ 5, TWEAKS_START + 0}, {300, 81}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_OPTIONS_TWEAKS ),
MakeWidget({ 10, TWEAKS_START + 15}, {290, 15}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_REAL_NAME, STR_REAL_NAME_TIP ), // Show 'real' names of guests
MakeWidget({ 10, TWEAKS_START + 30}, {290, 15}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_AUTO_STAFF_PLACEMENT, STR_AUTO_STAFF_PLACEMENT_TIP ), // Auto staff placement
@@ -373,10 +367,14 @@ static rct_widget window_options_misc_widgets[] = {
MakeWidget({ 10, TWEAKS_START + 62}, {165, 12}, WindowWidgetType::Label, WindowColour::Secondary, STR_DEFAULT_INSPECTION_INTERVAL, STR_DEFAULT_INSPECTION_INTERVAL_TIP),
MakeWidget({175, TWEAKS_START + 61}, {125, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // Default inspection time dropdown
MakeWidget({288, TWEAKS_START + 62}, { 11, 10}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH, STR_DEFAULT_INSPECTION_INTERVAL_TIP ), // Default inspection time dropdown button
#undef TWEAKS_START
WIDGETS_END,
};
#undef TWEAKS_START
#undef SCENARIO_OPTIONS_START
#undef SCENARIO_START
#undef TITLE_SEQUENCE_START
static rct_widget window_options_advanced_widgets[] = {
MAIN_OPTIONS_WIDGETS,
MakeWidget ({ 10, 54}, {290, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_ENABLE_DEBUGGING_TOOLS, STR_ENABLE_DEBUGGING_TOOLS_TIP ), // Enable debugging tools
@@ -406,6 +404,7 @@ static rct_widget *window_options_page_widgets[] = {
};
#pragma endregion
// clang-format on
class OptionsWindow final : public Window
{
@@ -1645,19 +1644,11 @@ private:
config_save_default();
Invalidate();
break;
case WIDX_TITLE_SEQUENCE_BUTTON:
WindowTitleEditorOpen(0);
break;
case WIDX_SCENARIO_UNLOCKING:
gConfigGeneral.scenario_unlocking_enabled ^= 1;
config_save_default();
window_close_by_class(WC_SCENARIO_SELECT);
break;
case WIDX_TITLE_SEQUENCE_RANDOM:
gConfigInterface.random_title_sequence ^= 1;
config_save_default();
Invalidate();
break;
case WIDX_AUTO_OPEN_SHOPS:
gConfigGeneral.auto_open_shops = !gConfigGeneral.auto_open_shops;
config_save_default();
@@ -1694,11 +1685,20 @@ private:
gDropdownItems[i].Args = reinterpret_cast<uintptr_t>(title_sequence_manager_get_name(i));
}
gDropdownItems[numItems].Format = 0;
numItems++;
gDropdownItems[numItems].Format = STR_DROPDOWN_MENU_LABEL;
gDropdownItems[numItems].Args = STR_TITLE_SEQUENCE_RANDOM;
numItems++;
WindowDropdownShowText(
{ windowPos.x + widget->left, windowPos.y + widget->top }, widget->height() + 1, colours[1],
Dropdown::Flag::StayOpen, numItems);
Dropdown::SetChecked(static_cast<int32_t>(title_get_current_sequence()), true);
auto selectedIndex = gConfigInterface.random_title_sequence
? numItems - 1
: static_cast<int32_t>(title_get_current_sequence());
Dropdown::SetChecked(selectedIndex, true);
break;
}
case WIDX_SCENARIO_GROUPING_DROPDOWN:
@@ -1735,13 +1735,23 @@ private:
switch (widgetIndex)
{
case WIDX_TITLE_SEQUENCE_DROPDOWN:
if (dropdownIndex != static_cast<int32_t>(title_get_current_sequence()))
{
auto numItems = static_cast<int32_t>(title_sequence_manager_get_count());
if (dropdownIndex < numItems && dropdownIndex != static_cast<int32_t>(title_get_current_sequence()))
{
gConfigInterface.random_title_sequence = false;
title_sequence_change_preset(static_cast<size_t>(dropdownIndex));
config_save_default();
Invalidate();
}
else if (dropdownIndex == numItems + 1)
{
gConfigInterface.random_title_sequence = true;
config_save_default();
Invalidate();
}
break;
}
case WIDX_DEFAULT_INSPECTION_INTERVAL_DROPDOWN:
if (dropdownIndex != gConfigGeneral.default_inspection_interval)
{
@@ -1765,9 +1775,17 @@ private:
void MiscPrepareDraw()
{
const utf8* name = title_sequence_manager_get_name(title_get_config_sequence());
auto ft = Formatter::Common();
ft.Add<utf8*>(name);
if (gConfigInterface.random_title_sequence)
{
ft.Add<rct_string_id>(STR_TITLE_SEQUENCE_RANDOM);
}
else
{
auto name = title_sequence_manager_get_name(title_get_config_sequence());
ft.Add<rct_string_id>(STR_STRING);
ft.Add<utf8*>(name);
}
// The real name setting of clients is fixed to that of the server
// and the server cannot change the setting during gameplay to prevent desyncs
@@ -1788,21 +1806,8 @@ private:
SetCheckboxValue(WIDX_REAL_NAME_CHECKBOX, gConfigGeneral.show_real_names_of_guests);
SetCheckboxValue(WIDX_AUTO_STAFF_PLACEMENT, gConfigGeneral.auto_staff_placement);
SetCheckboxValue(WIDX_AUTO_OPEN_SHOPS, gConfigGeneral.auto_open_shops);
SetCheckboxValue(WIDX_TITLE_SEQUENCE_RANDOM, gConfigInterface.random_title_sequence);
SetCheckboxValue(WIDX_ALLOW_EARLY_COMPLETION, gConfigGeneral.allow_early_completion);
// Disable title sequence dropdown if set to random
if (gConfigInterface.random_title_sequence)
{
disabled_widgets |= (1ULL << WIDX_TITLE_SEQUENCE_DROPDOWN);
disabled_widgets |= (1ULL << WIDX_TITLE_SEQUENCE);
}
else
{
disabled_widgets &= ~(1ULL << WIDX_TITLE_SEQUENCE_DROPDOWN);
disabled_widgets &= ~(1ULL << WIDX_TITLE_SEQUENCE);
}
if (gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_DIFFICULTY)
widgets[WIDX_SCENARIO_GROUPING].text = STR_OPTIONS_SCENARIO_DIFFICULTY;
else

View File

@@ -116,7 +116,7 @@ static rct_widget window_themes_widgets[] = {
MakeWidget({219, 46}, { 97, 15}, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_THEMES_HEADER_PALETTE ), // Palette header
MakeWidget({125, 60}, {175, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // Preset colour schemes
MakeWidget({288, 61}, { 11, 10}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH ),
MakeWidget({ 10, 82}, { 91, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_TITLE_EDITOR_ACTION_DUPLICATE, STR_THEMES_ACTION_DUPLICATE_TIP ), // Duplicate button
MakeWidget({ 10, 82}, { 91, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_THEMES_ACTION_DUPLICATE, STR_THEMES_ACTION_DUPLICATE_TIP ), // Duplicate button
MakeWidget({110, 82}, { 91, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_TRACK_MANAGE_DELETE, STR_THEMES_ACTION_DELETE_TIP ), // Delete button
MakeWidget({210, 82}, { 91, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_TRACK_MANAGE_RENAME, STR_THEMES_ACTION_RENAME_TIP ), // Rename button
MakeWidget({ 0, 0}, { 1, 1}, WindowWidgetType::ColourBtn, WindowColour::Secondary ), // colour button mask
@@ -224,7 +224,6 @@ static rct_windowclass window_themes_tab_6_classes[] = {
WC_VIEW_CLIPPING,
WC_TRANSPARENCY,
WC_THEMES,
WC_TITLE_EDITOR,
WC_OPTIONS,
WC_KEYBOARD_SHORTCUT_LIST,
WC_CHANGE_KEYBOARD_SHORTCUT,
@@ -355,7 +354,7 @@ static void WindowThemesMouseup(rct_window* w, rct_widgetindex widgetIndex)
activeAvailableThemeIndex = ThemeManagerGetAvailableThemeIndex();
activeThemeName = ThemeManagerGetAvailableThemeName(activeAvailableThemeIndex);
WindowTextInputOpen(
w, widgetIndex, STR_TITLE_EDITOR_ACTION_DUPLICATE, STR_THEMES_PROMPT_ENTER_THEME_NAME, {}, STR_STRING,
w, widgetIndex, STR_THEMES_ACTION_DUPLICATE, STR_THEMES_PROMPT_ENTER_THEME_NAME, {}, STR_STRING,
reinterpret_cast<uintptr_t>(activeThemeName), 64);
break;
case WIDX_THEMES_DELETE_BUTTON:

View File

@@ -1,859 +0,0 @@
/*****************************************************************************
* Copyright (c) 2014-2020 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "../interface/Theme.h"
#include <iterator>
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/Viewport.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Game.h>
#include <openrct2/Input.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/core/Memory.hpp>
#include <openrct2/core/Path.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/entity/Balloon.h>
#include <openrct2/entity/Duck.h>
#include <openrct2/entity/Peep.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/ride/Vehicle.h>
#include <openrct2/scenario/ScenarioRepository.h>
#include <openrct2/scenario/ScenarioSources.h>
#include <openrct2/sprites.h>
#include <openrct2/title/TitleSequence.h>
#include <openrct2/util/Util.h>
// clang-format off
struct TitleCommandOrder {
TitleScript command;
rct_string_id nameStringId;
rct_string_id descStringId;
};
static TitleCommandOrder _window_title_command_editor_orders[] = {
{ TitleScript::Load, STR_TITLE_EDITOR_ACTION_LOAD_SAVE, STR_TITLE_EDITOR_ARGUMENT_SAVEFILE },
{ TitleScript::LoadSc, STR_TITLE_EDITOR_ACTION_LOAD_SCENARIO, STR_TITLE_EDITOR_ARGUMENT_SCENARIO },
{ TitleScript::Location, STR_TITLE_EDITOR_COMMAND_TYPE_LOCATION, STR_TITLE_EDITOR_ARGUMENT_COORDINATES },
{ TitleScript::Rotate, STR_TITLE_EDITOR_COMMAND_TYPE_ROTATE, STR_TITLE_EDITOR_ARGUMENT_ROTATIONS },
{ TitleScript::Zoom, STR_TITLE_EDITOR_COMMAND_TYPE_ZOOM, STR_TITLE_EDITOR_ARGUMENT_ZOOM_LEVEL },
{ TitleScript::Speed, STR_TITLE_EDITOR_COMMAND_TYPE_SPEED, STR_TITLE_EDITOR_ARGUMENT_SPEED },
{ TitleScript::Follow, STR_TITLE_EDITOR_COMMAND_TYPE_FOLLOW, STR_NONE },
{ TitleScript::Wait, STR_TITLE_EDITOR_COMMAND_TYPE_WAIT, STR_TITLE_EDITOR_ARGUMENT_WAIT_SECONDS },
{ TitleScript::Restart, STR_TITLE_EDITOR_RESTART, STR_NONE },
{ TitleScript::End, STR_TITLE_EDITOR_END, STR_NONE },
};
#define NUM_COMMANDS std::size(_window_title_command_editor_orders)
enum WindowTitleCommandEditorWidgetIdx {
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_COMMAND,
WIDX_COMMAND_DROPDOWN,
WIDX_TEXTBOX_FULL,
WIDX_TEXTBOX_X,
WIDX_TEXTBOX_Y,
WIDX_INPUT,
WIDX_INPUT_DROPDOWN,
WIDX_GET,
WIDX_SELECT_SCENARIO,
WIDX_SELECT_SPRITE,
WIDX_VIEWPORT,
WIDX_OKAY,
WIDX_CANCEL
};
static constexpr rct_string_id WINDOW_TITLE = STR_TITLE_COMMAND_EDITOR_TITLE;
static constexpr const int32_t WW = 200;
static constexpr const int32_t WH = 120;
static constexpr int32_t BY = 32;
static constexpr int32_t BY2 = 70;
static constexpr int32_t WS = 16;
static bool _window_title_command_editor_insert;
static int32_t _window_title_command_editor_index;
constexpr size_t BUF_SIZE = 50;
static char textbox1Buffer[BUF_SIZE];
static char textbox2Buffer[BUF_SIZE];
static TitleCommand _command = { TitleScript::Load, { 0 } };
static TitleSequence * _sequence = nullptr;
static rct_widget window_title_command_editor_widgets[] = {
WINDOW_SHIM(WINDOW_TITLE, WW, WH),
MakeWidget({ 16, 32}, { 168, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // Command dropdown
MakeWidget({172, 33}, { 11, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH ),
MakeWidget({ 16, 70}, { 168, 12}, WindowWidgetType::TextBox, WindowColour::Secondary ), // full textbox
MakeWidget({ 16, 70}, { 81, 12}, WindowWidgetType::TextBox, WindowColour::Secondary ), // x textbox
MakeWidget({103, 70}, { 81, 12}, WindowWidgetType::TextBox, WindowColour::Secondary ), // y textbox
MakeWidget({ 16, 70}, { 168, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // Save dropdown
MakeWidget({172, 71}, { 11, 10}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH ),
MakeWidget({103, 56}, { 81, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_TITLE_COMMAND_EDITOR_ACTION_GET_LOCATION ), // Get location/zoom/etc
MakeWidget({112, 56}, { 72, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_TITLE_COMMAND_EDITOR_ACTION_SELECT_SCENARIO), // Select scenario
MakeWidget({ 16, 56}, { 168, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_TITLE_COMMAND_EDITOR_SELECT_SPRITE ), // Select sprite
MakeWidget({ 16, 70}, { 168, 24}, WindowWidgetType::Viewport, WindowColour::Secondary ), // Viewport
MakeWidget({ 10, 99}, { 71, 14}, WindowWidgetType::Button, WindowColour::Secondary, STR_OK ), // OKAY
MakeWidget({120, 99}, { 71, 14}, WindowWidgetType::Button, WindowColour::Secondary, STR_CANCEL ), // Cancel
WIDGETS_END,
};
static void WindowTitleCommandEditorClose(rct_window * w);
static void WindowTitleCommandEditorMouseup(rct_window * w, rct_widgetindex widgetIndex);
static void WindowTitleCommandEditorMousedown(rct_window * w, rct_widgetindex widgetIndex, rct_widget * widget);
static void WindowTitleCommandEditorDropdown(rct_window * w, rct_widgetindex widgetIndex, int32_t dropdownIndex);
static void WindowTitleCommandEditorUpdate(rct_window * w);
static void WindowTitleCommandEditorToolDown(rct_window * w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
static void WindowTitleCommandEditorInvalidate(rct_window * w);
static void WindowTitleCommandEditorPaint(rct_window * w, rct_drawpixelinfo * dpi);
static void WindowTitleCommandEditorTextinput(rct_window * w, rct_widgetindex widgetIndex, char * text);
static void ScenarioSelectCallback(const utf8 * path);
static int32_t GetCommandInfoIndex(TitleScript commandType);
static TitleCommandOrder GetCommandInfo(TitleScript commandType);
static TileCoordsXY GetLocation();
static uint8_t GetZoom();
static rct_window_event_list window_title_command_editor_events([](auto& events)
{
events.close = &WindowTitleCommandEditorClose;
events.mouse_up = &WindowTitleCommandEditorMouseup;
events.mouse_down = &WindowTitleCommandEditorMousedown;
events.dropdown = &WindowTitleCommandEditorDropdown;
events.update = &WindowTitleCommandEditorUpdate;
events.tool_down = &WindowTitleCommandEditorToolDown;
events.text_input = &WindowTitleCommandEditorTextinput;
events.invalidate = &WindowTitleCommandEditorInvalidate;
events.paint = &WindowTitleCommandEditorPaint;
});
// clang-format on
static void ScenarioSelectCallback(const utf8* path)
{
if (_command.Type == TitleScript::LoadSc)
{
const auto fileName = Path::GetFileName(path);
auto scenario = GetScenarioRepository()->GetByFilename(fileName);
safe_strcpy(_command.Scenario, scenario->internal_name, sizeof(_command.Scenario));
}
}
static int32_t GetCommandInfoIndex(TitleScript commandType)
{
for (int32_t i = 0; i < static_cast<int32_t>(NUM_COMMANDS); i++)
{
if (_window_title_command_editor_orders[i].command == commandType)
return i;
}
return 0;
}
static TitleCommandOrder GetCommandInfo(TitleScript commandType)
{
for (int32_t i = 0; i < static_cast<int32_t>(NUM_COMMANDS); i++)
{
if (_window_title_command_editor_orders[i].command == commandType)
return _window_title_command_editor_orders[i];
}
return _window_title_command_editor_orders[0];
}
static TileCoordsXY GetLocation()
{
TileCoordsXY tileCoord = {};
rct_window* w = window_get_main();
if (w != nullptr)
{
auto info = get_map_coordinates_from_pos_window(
w, { w->viewport->view_width / 2, w->viewport->view_height / 2 }, EnumsToFlags(ViewportInteractionItem::Terrain));
auto mapCoord = info.Loc;
mapCoord.x -= 16;
mapCoord.y -= 16;
tileCoord = TileCoordsXY{ mapCoord };
tileCoord.x++;
tileCoord.y++;
}
return tileCoord;
}
static uint8_t GetZoom()
{
uint8_t zoom = 0;
rct_window* w = window_get_main();
if (w != nullptr)
{
zoom = static_cast<int8_t>(w->viewport->zoom);
}
return zoom;
}
static bool SpriteSelectorToolIsActive()
{
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
return false;
if (gCurrentToolWidget.window_classification != WC_TITLE_COMMAND_EDITOR)
return false;
return true;
}
void WindowTitleCommandEditorOpen(TitleSequence* sequence, int32_t index, bool insert)
{
_sequence = sequence;
// Check if window is already open
if (window_find_by_class(WC_TITLE_COMMAND_EDITOR) != nullptr)
return;
rct_window* window = WindowCreateCentred(
WW, WH, &window_title_command_editor_events, WC_TITLE_COMMAND_EDITOR, WF_STICK_TO_FRONT);
window_title_command_editor_widgets[WIDX_TEXTBOX_FULL].string = textbox1Buffer;
window_title_command_editor_widgets[WIDX_TEXTBOX_X].string = textbox1Buffer;
window_title_command_editor_widgets[WIDX_TEXTBOX_Y].string = textbox2Buffer;
window->widgets = window_title_command_editor_widgets;
WindowInitScrollWidgets(window);
rct_widget* const viewportWidget = &window_title_command_editor_widgets[WIDX_VIEWPORT];
const auto focus = Focus(CoordsXYZ{ 0, 0, 0 });
viewport_create(
window, window->windowPos + ScreenCoordsXY{ viewportWidget->left + 1, viewportWidget->top + 1 },
viewportWidget->width() - 1, viewportWidget->height() - 1, focus);
_window_title_command_editor_index = index;
_window_title_command_editor_insert = insert;
if (!insert)
{
_command = _sequence->Commands[index];
}
switch (_command.Type)
{
case TitleScript::Load:
if (_command.SaveIndex >= _sequence->Saves.size())
_command.SaveIndex = SAVE_INDEX_INVALID;
break;
case TitleScript::Location:
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Location.X);
snprintf(textbox2Buffer, BUF_SIZE, "%d", _command.Location.Y);
break;
case TitleScript::Rotate:
case TitleScript::Zoom:
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Rotations);
break;
case TitleScript::Wait:
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Milliseconds);
break;
case TitleScript::Follow:
if (!_command.Follow.SpriteIndex.IsNull())
{
window_follow_sprite(window, _command.Follow.SpriteIndex);
}
break;
case TitleScript::Undefined:
break;
case TitleScript::Restart:
break;
case TitleScript::End:
break;
case TitleScript::Speed:
break;
case TitleScript::Loop:
break;
case TitleScript::EndLoop:
break;
case TitleScript::LoadSc:
break;
}
}
static void WindowTitleCommandEditorClose(rct_window* w)
{
if (SpriteSelectorToolIsActive())
{
tool_cancel();
}
}
static void WindowTitleCommandEditorMouseup(rct_window* w, rct_widgetindex widgetIndex)
{
switch (widgetIndex)
{
case WIDX_CLOSE:
case WIDX_CANCEL:
window_close(w);
break;
case WIDX_TEXTBOX_FULL:
// The only commands that use TEXTBOX_FULL currently are Wait, Rotate, and Zoom. Rotate and Zoom have single-digit
// maximum values, while Wait has 5-digit maximum values.
if (_command.Type == TitleScript::Wait)
{
window_start_textbox(w, widgetIndex, STR_STRING, textbox1Buffer, 6);
}
else
{
window_start_textbox(w, widgetIndex, STR_STRING, textbox1Buffer, 2);
}
break;
case WIDX_TEXTBOX_X:
window_start_textbox(w, widgetIndex, STR_STRING, textbox1Buffer, 4);
break;
case WIDX_TEXTBOX_Y:
window_start_textbox(w, widgetIndex, STR_STRING, textbox2Buffer, 4);
break;
case WIDX_GET:
if (_command.Type == TitleScript::Location)
{
auto tileCoord = GetLocation();
_command.Location.X = static_cast<uint8_t>(tileCoord.x);
_command.Location.Y = static_cast<uint8_t>(tileCoord.y);
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Location.X);
snprintf(textbox2Buffer, BUF_SIZE, "%d", _command.Location.Y);
}
else if (_command.Type == TitleScript::Zoom)
{
uint8_t zoom = GetZoom();
_command.Zoom = zoom;
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Zoom);
}
w->Invalidate();
break;
case WIDX_SELECT_SCENARIO:
WindowScenarioselectOpen(ScenarioSelectCallback, true);
break;
case WIDX_SELECT_SPRITE:
if (!SpriteSelectorToolIsActive())
{
tool_set(w, WIDX_BACKGROUND, Tool::Crosshair);
}
else
{
tool_cancel();
}
break;
case WIDX_OKAY:
if (_window_title_command_editor_insert)
{
size_t insertIndex = _window_title_command_editor_index;
_sequence->Commands.insert(_sequence->Commands.begin() + insertIndex, _command);
}
else
{
_sequence->Commands[_window_title_command_editor_index] = _command;
}
TitleSequenceSave(*_sequence);
rct_window* title_editor_w = window_find_by_class(WC_TITLE_EDITOR);
if (title_editor_w != nullptr)
{
title_editor_w->selected_list_item = _window_title_command_editor_index;
}
window_close(w);
break;
}
}
static void WindowTitleCommandEditorMousedown(rct_window* w, rct_widgetindex widgetIndex, rct_widget* widget)
{
widget--;
switch (widgetIndex)
{
case WIDX_COMMAND_DROPDOWN:
{
size_t numItems = NUM_COMMANDS;
for (size_t i = 0; i < numItems; i++)
{
gDropdownItems[i].Format = STR_DROPDOWN_MENU_LABEL;
gDropdownItems[i].Args = _window_title_command_editor_orders[i].nameStringId;
}
WindowDropdownShowTextCustomWidth(
{ w->windowPos.x + widget->left, w->windowPos.y + widget->top }, widget->height() + 1, w->colours[1], 0,
Dropdown::Flag::StayOpen, numItems, widget->width() - 3);
Dropdown::SetChecked(GetCommandInfoIndex(_command.Type), true);
break;
}
case WIDX_INPUT_DROPDOWN:
if (_command.Type == TitleScript::Speed)
{
int32_t numItems = 4;
for (int32_t i = 0; i < numItems; i++)
{
gDropdownItems[i].Format = STR_DROPDOWN_MENU_LABEL;
gDropdownItems[i].Args = SpeedNames[i];
}
WindowDropdownShowTextCustomWidth(
{ w->windowPos.x + widget->left, w->windowPos.y + widget->top }, widget->height() + 1, w->colours[1], 0,
Dropdown::Flag::StayOpen, numItems, widget->width() - 3);
Dropdown::SetChecked(_command.Speed - 1, true);
}
else if (_command.Type == TitleScript::Load)
{
int32_t numItems = static_cast<int32_t>(_sequence->Saves.size());
for (int32_t i = 0; i < numItems; i++)
{
gDropdownItems[i].Format = STR_OPTIONS_DROPDOWN_ITEM;
gDropdownItems[i].Args = reinterpret_cast<uintptr_t>(_sequence->Saves[i].c_str());
}
WindowDropdownShowTextCustomWidth(
{ w->windowPos.x + widget->left, w->windowPos.y + widget->top }, widget->height() + 1, w->colours[1], 0,
Dropdown::Flag::StayOpen, numItems, widget->width() - 3);
Dropdown::SetChecked(_command.SaveIndex, true);
}
break;
}
}
static void WindowTitleCommandEditorDropdown(rct_window* w, rct_widgetindex widgetIndex, int32_t dropdownIndex)
{
if (dropdownIndex == -1)
return;
// Cancel sprite selector tool if it's active
if (SpriteSelectorToolIsActive())
{
tool_cancel();
}
switch (widgetIndex)
{
case WIDX_COMMAND_DROPDOWN:
if (!_command.Follow.SpriteIndex.IsNull())
{
window_unfollow_sprite(w);
}
if (dropdownIndex == GetCommandInfoIndex(_command.Type))
{
break;
}
_command.Type = _window_title_command_editor_orders[dropdownIndex].command;
switch (_command.Type)
{
case TitleScript::Location:
{
auto tileCoord = GetLocation();
_command.Location.X = static_cast<uint8_t>(tileCoord.x);
_command.Location.Y = static_cast<uint8_t>(tileCoord.y);
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Location.X);
snprintf(textbox2Buffer, BUF_SIZE, "%d", _command.Location.Y);
break;
}
case TitleScript::Rotate:
_command.Rotations = 1;
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Rotations);
break;
case TitleScript::Undefined:
break;
case TitleScript::Restart:
break;
case TitleScript::End:
break;
case TitleScript::Loop:
break;
case TitleScript::EndLoop:
break;
case TitleScript::Zoom:
_command.Zoom = 0;
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Zoom);
break;
case TitleScript::Follow:
_command.Follow.SpriteIndex = EntityId::GetNull();
_command.Follow.SpriteName[0] = '\0';
window_unfollow_sprite(w);
// This is incorrect
w->viewport->flags &= ~VIEWPORT_FLAG_GRIDLINES;
break;
case TitleScript::Speed:
_command.Speed = 1;
break;
case TitleScript::Wait:
_command.Milliseconds = 10000;
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Milliseconds);
break;
case TitleScript::Load:
_command.SaveIndex = 0;
if (_command.SaveIndex >= _sequence->Saves.size())
{
_command.SaveIndex = 0xFF;
}
break;
case TitleScript::LoadSc:
_command.Scenario[0] = '\0';
}
w->Invalidate();
break;
case WIDX_INPUT_DROPDOWN:
switch (_command.Type)
{
case TitleScript::Speed:
if (dropdownIndex != _command.Speed - 1)
{
_command.Speed = static_cast<uint8_t>(dropdownIndex + 1);
w->Invalidate();
}
break;
case TitleScript::Load:
if (dropdownIndex != _command.SaveIndex)
{
_command.SaveIndex = static_cast<uint8_t>(dropdownIndex);
w->Invalidate();
}
break;
case TitleScript::Restart:
break;
case TitleScript::End:
break;
case TitleScript::Loop:
break;
case TitleScript::EndLoop:
break;
case TitleScript::Undefined:
break;
case TitleScript::Location:
break;
case TitleScript::Wait:
break;
case TitleScript::Rotate:
break;
case TitleScript::Zoom:
break;
case TitleScript::Follow:
break;
case TitleScript::LoadSc:
break;
}
break;
}
}
static void WindowTitleCommandEditorTextinput(rct_window* w, rct_widgetindex widgetIndex, char* text)
{
char* end;
int32_t value = strtol(widgetIndex != WIDX_TEXTBOX_Y ? textbox1Buffer : textbox2Buffer, &end, 10);
if (value < 0)
value = 0;
// The Wait command is the only one with acceptable values greater than 255.
if (value > 255 && _command.Type != TitleScript::Wait)
value = 255;
switch (widgetIndex)
{
case WIDX_TEXTBOX_FULL:
if (text == nullptr)
{
if (*end == '\0')
{
if (_command.Type == TitleScript::Wait)
{
if (value < 100)
value = 100;
if (value > 65000)
value = 65000;
_command.Milliseconds = static_cast<uint16_t>(value);
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Milliseconds);
}
else
{
// Both Rotate and Zoom have a maximum value of 3, but Rotate has a min value of 1 not 0.
if (value > 3)
value = 3;
if (value < 1 && _command.Type == TitleScript::Rotate)
value = 1;
_command.Rotations = static_cast<uint8_t>(value);
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Rotations);
}
}
w->Invalidate();
}
else
{
safe_strcpy(textbox1Buffer, text, sizeof(textbox1Buffer));
}
break;
case WIDX_TEXTBOX_X:
if (text == nullptr)
{
if (*end == '\0')
{
_command.Location.X = static_cast<uint8_t>(value);
}
snprintf(textbox1Buffer, BUF_SIZE, "%d", _command.Location.X);
w->Invalidate();
}
else
{
safe_strcpy(textbox1Buffer, text, sizeof(textbox1Buffer));
}
break;
case WIDX_TEXTBOX_Y:
if (text == nullptr)
{
if (*end == '\0')
{
_command.Location.Y = static_cast<uint8_t>(value);
}
snprintf(textbox2Buffer, BUF_SIZE, "%d", _command.Location.Y);
w->Invalidate();
}
else
{
safe_strcpy(textbox2Buffer, text, sizeof(textbox2Buffer));
}
break;
}
}
static void WindowTitleCommandEditorUpdate(rct_window* w)
{
if (gCurrentTextBox.window.classification == w->classification && gCurrentTextBox.window.number == w->number)
{
window_update_textbox_caret();
widget_invalidate(w, gCurrentTextBox.widget_index);
}
}
static void WindowTitleCommandEditorToolDown(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
{
auto info = ViewportInteractionGetItemLeft(screenCoords);
if (info.SpriteType == ViewportInteractionItem::Entity)
{
auto entity = info.Entity;
bool validSprite = false;
auto peep = entity->As<Peep>();
auto vehicle = entity->As<Vehicle>();
auto litter = entity->As<Litter>();
auto duck = entity->As<Duck>();
auto balloon = entity->As<Balloon>();
if (peep != nullptr)
{
validSprite = true;
Formatter ft;
peep->FormatNameTo(ft);
format_string(_command.Follow.SpriteName, USER_STRING_MAX_LENGTH, STR_STRINGID, &peep->Id);
}
else if (vehicle != nullptr)
{
validSprite = true;
auto ride = vehicle->GetRide();
if (ride != nullptr)
{
Formatter ft;
ride->FormatNameTo(ft);
format_string(_command.Follow.SpriteName, USER_STRING_MAX_LENGTH, STR_STRINGID, ft.Data());
}
}
else if (litter != nullptr)
{
auto name = litter->GetName();
if (name != STR_NONE)
{
validSprite = true;
format_string(_command.Follow.SpriteName, USER_STRING_MAX_LENGTH, name, nullptr);
}
}
else if (balloon != nullptr)
{
validSprite = true;
format_string(_command.Follow.SpriteName, USER_STRING_MAX_LENGTH, STR_SHOP_ITEM_SINGULAR_BALLOON, nullptr);
}
else if (duck != nullptr)
{
validSprite = true;
format_string(_command.Follow.SpriteName, USER_STRING_MAX_LENGTH, STR_DUCK, nullptr);
}
if (validSprite)
{
_command.Follow.SpriteIndex = entity->sprite_index;
window_follow_sprite(w, _command.Follow.SpriteIndex);
tool_cancel();
w->Invalidate();
}
}
}
static void WindowTitleCommandEditorInvalidate(rct_window* w)
{
ColourSchemeUpdateByClass(w, WC_TITLE_EDITOR);
window_title_command_editor_widgets[WIDX_TEXTBOX_FULL].type = WindowWidgetType::Empty;
window_title_command_editor_widgets[WIDX_TEXTBOX_X].type = WindowWidgetType::Empty;
window_title_command_editor_widgets[WIDX_TEXTBOX_Y].type = WindowWidgetType::Empty;
window_title_command_editor_widgets[WIDX_INPUT].type = WindowWidgetType::Empty;
window_title_command_editor_widgets[WIDX_INPUT_DROPDOWN].type = WindowWidgetType::Empty;
window_title_command_editor_widgets[WIDX_GET].type = WindowWidgetType::Empty;
window_title_command_editor_widgets[WIDX_SELECT_SCENARIO].type = WindowWidgetType::Empty;
window_title_command_editor_widgets[WIDX_SELECT_SPRITE].type = WindowWidgetType::Empty;
window_title_command_editor_widgets[WIDX_VIEWPORT].type = WindowWidgetType::Empty;
switch (_command.Type)
{
case TitleScript::Load:
case TitleScript::Speed:
window_title_command_editor_widgets[WIDX_INPUT].type = WindowWidgetType::DropdownMenu;
window_title_command_editor_widgets[WIDX_INPUT_DROPDOWN].type = WindowWidgetType::Button;
break;
case TitleScript::LoadSc:
window_title_command_editor_widgets[WIDX_INPUT].type = WindowWidgetType::DropdownMenu;
window_title_command_editor_widgets[WIDX_SELECT_SCENARIO].type = WindowWidgetType::Button;
break;
case TitleScript::Location:
window_title_command_editor_widgets[WIDX_TEXTBOX_X].type = WindowWidgetType::TextBox;
window_title_command_editor_widgets[WIDX_TEXTBOX_Y].type = WindowWidgetType::TextBox;
window_title_command_editor_widgets[WIDX_GET].type = WindowWidgetType::Button;
break;
case TitleScript::Rotate:
case TitleScript::Wait:
window_title_command_editor_widgets[WIDX_TEXTBOX_FULL].type = WindowWidgetType::TextBox;
break;
case TitleScript::Zoom:
window_title_command_editor_widgets[WIDX_GET].type = WindowWidgetType::Button;
window_title_command_editor_widgets[WIDX_TEXTBOX_FULL].type = WindowWidgetType::TextBox;
break;
case TitleScript::Undefined:
break;
case TitleScript::Restart:
break;
case TitleScript::End:
break;
case TitleScript::Loop:
break;
case TitleScript::EndLoop:
break;
case TitleScript::Follow:
window_title_command_editor_widgets[WIDX_SELECT_SPRITE].type = WindowWidgetType::Button;
window_title_command_editor_widgets[WIDX_VIEWPORT].type = WindowWidgetType::Viewport;
// Draw button pressed while the tool is active
if (SpriteSelectorToolIsActive())
w->pressed_widgets |= (1ULL << WIDX_SELECT_SPRITE);
else
w->pressed_widgets &= ~(1ULL << WIDX_SELECT_SPRITE);
break;
}
if ((gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) == SCREEN_FLAGS_TITLE_DEMO)
{
w->disabled_widgets |= (1ULL << WIDX_GET) | (1ULL << WIDX_SELECT_SPRITE);
window_title_command_editor_widgets[WIDX_SELECT_SPRITE].tooltip = STR_TITLE_COMMAND_EDITOR_SELECT_SPRITE_TOOLTIP;
}
else
{
w->disabled_widgets &= ~((1ULL << WIDX_GET) | (1ULL << WIDX_SELECT_SPRITE));
window_title_command_editor_widgets[WIDX_SELECT_SPRITE].tooltip = STR_NONE;
}
}
static void WindowTitleCommandEditorPaint(rct_window* w, rct_drawpixelinfo* dpi)
{
WindowDrawWidgets(w, dpi);
TitleCommandOrder command_info = GetCommandInfo(_command.Type);
// "Command:" label
DrawTextBasic(
dpi, w->windowPos + ScreenCoordsXY{ WS, BY - 14 }, STR_TITLE_COMMAND_EDITOR_COMMAND_LABEL, {}, { w->colours[1] });
// Command dropdown name
DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_COMMAND].left + 1, w->windowPos.y + w->widgets[WIDX_COMMAND].top },
w->widgets[WIDX_COMMAND_DROPDOWN].left - w->widgets[WIDX_COMMAND].left - 4, command_info.nameStringId, {},
{ w->colours[1] });
// Label (e.g. "Location:")
DrawTextBasic(dpi, w->windowPos + ScreenCoordsXY{ WS, BY2 - 14 }, command_info.descStringId, {}, { w->colours[1] });
if (_command.Type == TitleScript::Speed)
{
DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top },
w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, SpeedNames[_command.Speed - 1], {},
{ w->colours[1] });
}
if (_command.Type == TitleScript::Follow)
{
uint8_t colour = COLOUR_BLACK;
rct_string_id spriteString = STR_TITLE_COMMAND_EDITOR_FORMAT_SPRITE_NAME;
auto ft = Formatter();
if (!_command.Follow.SpriteIndex.IsNull())
{
window_draw_viewport(dpi, w);
ft.Add<utf8*>(_command.Follow.SpriteName);
}
else
{
colour = w->colours[1];
spriteString = STR_TITLE_COMMAND_EDITOR_FOLLOW_NO_SPRITE;
}
gfx_set_dirty_blocks(
{ { w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_VIEWPORT].left, w->widgets[WIDX_VIEWPORT].top } },
{ w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_VIEWPORT].right, w->widgets[WIDX_VIEWPORT].bottom } } });
DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_VIEWPORT].left + 2, w->windowPos.y + w->widgets[WIDX_VIEWPORT].top + 1 },
w->widgets[WIDX_VIEWPORT].width() - 2, spriteString, ft, { colour });
}
else if (_command.Type == TitleScript::Load)
{
if (_command.SaveIndex == SAVE_INDEX_INVALID)
{
DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top },
w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4,
STR_TITLE_COMMAND_EDITOR_NO_SAVE_SELECTED, {}, { w->colours[1] });
}
else
{
auto ft = Formatter();
ft.Add<utf8*>(_sequence->Saves[_command.SaveIndex].c_str());
DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top },
w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, STR_STRING, ft, { w->colours[1] });
}
}
else if (_command.Type == TitleScript::LoadSc)
{
if (_command.Scenario[0] == '\0')
{
DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top },
w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4,
STR_TITLE_COMMAND_EDITOR_NO_SCENARIO_SELECTED, {}, { w->colours[1] });
}
else
{
const char* name = "";
rct_string_id nameString = STR_STRING;
auto scenario = GetScenarioRepository()->GetByInternalName(_command.Scenario);
if (scenario != nullptr)
{
name = scenario->name;
}
else
{
nameString = STR_TITLE_COMMAND_EDITOR_MISSING_SCENARIO;
}
auto ft = Formatter();
ft.Add<const char*>(name);
DrawTextEllipsised(
dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top },
w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, nameString, ft, { w->colours[1] });
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -99,8 +99,6 @@ void WindowGuestListRefreshList();
rct_window* WindowGuestListOpen();
rct_window* WindowGuestListOpenWithFilter(GuestListFilterType type, int32_t index);
rct_window* WindowStaffFirePromptOpen(Peep* peep);
void WindowTitleEditorOpen(int32_t tab);
void WindowTitleCommandEditorOpen(struct TitleSequence* sequence, int32_t command, bool insert);
rct_window* WindowScenarioselectOpen(scenarioselect_callback callback, bool titleEditor);
rct_window* WindowScenarioselectOpen(std::function<void(std::string_view)> callback, bool titleEditor, bool disableLocking);

View File

@@ -1343,10 +1343,6 @@ static int32_t cc_open(InteractiveConsole& console, const arguments_t& argv)
{
context_open_window(WC_THEMES);
}
else if (argv[0] == "title_sequences")
{
context_open_window(WC_TITLE_EDITOR);
}
else if (invalidTitle)
{
console.WriteLineError("Cannot open this window in the title screen.");

View File

@@ -123,6 +123,27 @@ constexpr rct_widget MakeSpinnerIncreaseWidget(
return MakeWidget({ xPos, yPos }, { width, height }, WindowWidgetType::Button, colour, STR_NUMERIC_UP, tooltip);
}
#define MakeDropdownWidgets(...) MakeDropdownBoxWidget(__VA_ARGS__), MakeDropdownButtonWidget(__VA_ARGS__)
constexpr rct_widget MakeDropdownBoxWidget(
const ScreenCoordsXY& origin, const ScreenSize& size, [[maybe_unused]] WindowWidgetType type, WindowColour colour,
[[maybe_unused]] uint32_t content = 0xFFFFFFFF, rct_string_id tooltip = STR_NONE)
{
return MakeWidget(origin, size, type, colour, content);
}
constexpr rct_widget MakeDropdownButtonWidget(
const ScreenCoordsXY& origin, const ScreenSize& size, [[maybe_unused]] WindowWidgetType type, WindowColour colour,
[[maybe_unused]] uint32_t content = 0xFFFFFFFF, rct_string_id tooltip = STR_NONE)
{
const int16_t xPos = origin.x + size.width - 11;
const int16_t yPos = origin.y + 1;
const uint16_t width = 11;
const uint16_t height = 10;
return MakeWidget({ xPos, yPos }, { width, height }, WindowWidgetType::Button, colour, STR_DROPDOWN_GLYPH, tooltip);
}
void WidgetScrollUpdateThumbs(rct_window* w, rct_widgetindex widget_index);
void WidgetDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex widgetIndex);

View File

@@ -451,8 +451,6 @@ enum
WC_THEMES = 119,
WC_TILE_INSPECTOR = 120,
WC_CHANGELOG = 121,
WC_TITLE_EDITOR = 122,
WC_TITLE_COMMAND_EDITOR = 123,
WC_MULTIPLAYER = 124,
WC_PLAYER = 125,
WC_NETWORK_STATUS = 126,

View File

@@ -2667,7 +2667,7 @@ enum : uint16_t
STR_THEMES_HEADER_WINDOW = 5236,
STR_THEMES_HEADER_PALETTE = 5237,
STR_THEMES_LABEL_CURRENT_THEME = 5238,
STR_TITLE_EDITOR_ACTION_DUPLICATE = 5239,
STR_THEMES_ACTION_DUPLICATE = 5239,
STR_THEMES_PROMPT_ENTER_THEME_NAME = 5240,
STR_THEMES_ERR_CANT_CHANGE_THIS_THEME = 5241,
STR_THEMES_ERR_NAME_ALREADY_EXISTS = 5242,
@@ -2682,8 +2682,6 @@ enum : uint16_t
STR_THEMES_WINDOW_TITLE_MENU_OPTIONS = 5251,
STR_THEMES_WINDOW_TITLE_MENU_SCENARIO_SELECTION = 5252,
STR_THEMES_WINDOW_PARK_INFORMATION = 5253,
STR_TITLE_EDITOR_ACTION_CREATE = 5254,
STR_TITLE_EDITOR_ACTION_CREATE_SEQUENCE_TIP = 5255,
STR_THEMES_DESC_CANT_CHANGE_THIS_THEME = 5256,
STR_THEMES_ACTION_DUPLICATE_TIP = 5257,
STR_THEMES_ACTION_DELETE_TIP = 5258,
@@ -2736,7 +2734,7 @@ enum : uint16_t
STR_TITLE_SEQUENCE_RCT1_AA_LL = 5307,
STR_TITLE_SEQUENCE_RCT2 = 5308,
STR_TITLE_SEQUENCE_OPENRCT2 = 5309,
STR_TITLE_SEQUENCE_RANDOM = 5310, // Unused
STR_TITLE_SEQUENCE_RANDOM = 5310,
STR_DEBUG_TIP = 5311,
STR_DEBUG_DROPDOWN_CONSOLE = 5312,
STR_DEBUG_DROPDOWN_TILE_INSPECTOR = 5313,
@@ -2779,75 +2777,10 @@ enum : uint16_t
STR_DATE = 5374,
STR_UP = 5375,
STR_DOWN = 5376,
STR_TITLE_EDITOR_SAVES_TAB_TIP = 5377,
STR_TITLE_EDITOR_SCRIPT_TAB_TIP = 5378,
STR_TITLE_EDITOR_ACTION_SKIP_TIP = 5379,
STR_TITLE_EDITOR_ACTION_PLAY_TIP = 5380,
STR_TITLE_EDITOR_ACTION_STOP_TIP = 5381,
STR_TITLE_EDITOR_ACTION_REPLAY_TIP = 5382,
STR_TITLE_EDITOR_ACTION_DUPLICATE_SEQUENCE_TIP = 5383,
STR_TITLE_EDITOR_ACTION_DELETE_SEQUENCE_TIP = 5384,
STR_TITLE_EDITOR_ACTION_RENAME_SEQUENCE_TIP = 5385,
STR_TITLE_EDITOR_ACTION_INSERT_TIP = 5386,
STR_TITLE_EDITOR_ACTION_EDIT_TIP = 5387,
STR_TITLE_EDITOR_ACTION_DELETE_TIP = 5388,
STR_TITLE_EDITOR_ACTION_SKIP_TO_TIP = 5389,
STR_TITLE_EDITOR_ACTION_MOVE_DOWN_TIP = 5390,
STR_TITLE_EDITOR_ACTION_MOVE_UP_TIP = 5391,
STR_TITLE_EDITOR_ACTION_ADD_TIP = 5392,
STR_TITLE_EDITOR_ACTION_REMOVE_TIP = 5393,
STR_TITLE_EDITOR_ACTION_RENAME_TIP = 5394,
STR_TITLE_EDITOR_ACTION_LOAD_TIP = 5395,
STR_TITLE_EDITOR_ACTION_RELOAD_TIP = 5396,
STR_TITLE_EDITOR_ERR_CANT_EDIT_WHILE_PLAYING = 5398,
STR_TITLE_EDITOR_PRESS_STOP_TO_CONTINUE_EDITING = 5399,
STR_ERROR_CANT_CHANGE_TITLE_SEQUENCE = 5400,
// STR_5401 :Create a new title sequence to make changes to
STR_ERR_FAILED_TO_LOAD_TITLE_SEQUENCE = 5402,
// STR_5403 :There may be no Load or Wait command or a save may be invalid
STR_ERROR_EXISTING_NAME = 5404,
STR_TITLE_EDITOR_ENTER_NAME_FOR_SAVE = 5405,
STR_TITLE_EDITOR_ENTER_NAME_FOR_SEQUENCE = 5406,
STR_TITLE_EDITOR_ACTION_ADD = 5407,
STR_TITLE_EDITOR_ACTION_REMOVE = 5408,
STR_TITLE_EDITOR_ACTION_INSERT = 5409,
STR_TITLE_EDITOR_ACTION_EDIT = 5410,
STR_TITLE_EDITOR_ACTION_RELOAD = 5411, // unused (commented out)
STR_TITLE_EDITOR_ACTION_SKIP_TO = 5412,
STR_TITLE_EDITOR_ACTION_LOAD = 5413,
STR_TITLE_EDITOR_COMMAND_LOAD_FILE = 5415,
STR_TITLE_EDITOR_COMMAND_LOAD_NO_SAVE = 5416,
STR_TITLE_EDITOR_COMMAND_TYPE_LOCATION = 5417,
STR_TITLE_EDITOR_COMMAND_LOCATION = 5418,
STR_TITLE_EDITOR_COMMAND_TYPE_ROTATE = 5419,
STR_TITLE_EDITOR_COMMAND_ROTATE = 5420,
STR_TITLE_EDITOR_COMMAND_TYPE_ZOOM = 5421,
STR_TITLE_EDITOR_COMMAND_ZOOM = 5422,
STR_TITLE_EDITOR_COMMAND_TYPE_WAIT = 5423,
STR_TITLE_EDITOR_COMMAND_WAIT = 5424,
STR_TITLE_EDITOR_RESTART = 5425,
STR_TITLE_EDITOR_END = 5426,
STR_TITLE_EDITOR_ARGUMENT_COORDINATES = 5427,
STR_TITLE_EDITOR_ARGUMENT_ROTATIONS = 5428,
STR_TITLE_EDITOR_ARGUMENT_ZOOM_LEVEL = 5429,
STR_TITLE_EDITOR_ARGUMENT_WAIT_SECONDS = 5430,
STR_TITLE_EDITOR_ARGUMENT_SAVEFILE = 5431,
STR_TITLE_COMMAND_EDITOR_COMMAND_LABEL = 5432,
STR_TITLE_EDITOR_TITLE = 5433,
STR_TITLE_COMMAND_EDITOR_TITLE = 5434,
STR_FILEBROWSER_RENAME_SAVE_TITLE = 5435,
STR_EDIT_TITLE_SEQUENCES_BUTTON = 5436,
STR_TITLE_COMMAND_EDITOR_NO_SAVE_SELECTED = 5437,
STR_TITLE_EDITOR_ERR_CANT_CHANGE_WHILE_EDITOR_IS_OPEN = 5438,
STR_TITLE_EDITOR_ERR_RESTART_REQUIRES_WAIT = 5439,
STR_MINIMISE_FULLSCREEN_ON_FOCUS_LOSS = 5440,
STR_FORCE_PARK_RATING = 5442,
STR_TITLE_EDITOR_COMMAND_SPEED = 5443,
STR_TITLE_EDITOR_ARGUMENT_SPEED = 5444,
STR_TITLE_EDITOR_COMMAND_TYPE_SPEED = 5445,
STR_TITLE_COMMAND_EDITOR_ACTION_GET_LOCATION = 5446,
STR_OBJECTS_SORT_TYPE = 5447,
STR_OBJECTS_SORT_RIDE = 5448,
STR_SHORTCUT_REDUCE_GAME_SPEED = 5449,
@@ -3201,7 +3134,6 @@ enum : uint16_t
STR_ENABLE_DEBUGGING_TOOLS_TIP = 5845,
STR_AUTOSAVE_FREQUENCY_TIP = 5846,
STR_TITLE_SEQUENCE_TIP = 5847,
STR_EDIT_TITLE_SEQUENCES_BUTTON_TIP = 5848,
STR_AUTO_STAFF_PLACEMENT_TIP = 5849,
STR_HANDYMEN_MOW_BY_DEFAULT_TIP = 5850,
STR_DEFAULT_INSPECTION_INTERVAL_TIP = 5851,
@@ -3559,24 +3491,8 @@ enum : uint16_t
STR_GUESTS_FILTER_BY_NAME_TIP = 6172,
STR_GUESTS_ENTER_NAME_TO_SEARCH = 6173,
STR_TITLE_EDITOR_ACTION_LOAD_SAVE = 6174,
STR_TITLE_EDITOR_ACTION_LOAD_SCENARIO = 6175,
STR_TITLE_EDITOR_ARGUMENT_SCENARIO = 6176,
STR_TITLE_EDITOR_COMMAND_LOAD_NO_SCENARIO = 6177,
STR_TITLE_EDITOR_COMMAND_LOAD_MISSING_SCENARIO = 6178,
STR_TITLE_COMMAND_EDITOR_ACTION_SELECT_SCENARIO = 6179,
STR_TITLE_COMMAND_EDITOR_NO_SCENARIO_SELECTED = 6180,
STR_TITLE_COMMAND_EDITOR_MISSING_SCENARIO = 6181,
STR_TITLE_EDITOR_COMMAND_FOLLOW = 6182,
STR_TITLE_EDITOR_COMMAND_FOLLOW_NO_SPRITE = 6183,
STR_TITLE_EDITOR_COMMAND_TYPE_FOLLOW = 6184,
STR_TITLE_COMMAND_EDITOR_SELECT_SPRITE = 6185,
STR_TITLE_COMMAND_EDITOR_FOLLOW_NO_SPRITE = 6186,
STR_TITLE_COMMAND_EDITOR_FORMAT_SPRITE_NAME = 6187,
STR_LITTER_VOMIT = 6188,
STR_DUCK = 6189,
STR_TITLE_COMMAND_EDITOR_SELECT_SPRITE_TOOLTIP = 6190,
STR_TILE_INSPECTOR_SURFACE = 6191,
STR_TILE_INSPECTOR_WALL = 6192,