1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 21:43:06 +01:00

Editor Bottom Toolbar Window class (#17358)

* Move EditorBottomToolbar to window class

* Minor refactoring

* Further refactoring

* keep compilers happy
This commit is contained in:
Duncan
2022-06-08 20:54:03 +01:00
committed by GitHub
parent a0f5493575
commit f0949284c4

View File

@@ -35,429 +35,362 @@ enum {
WIDX_NEXT_STEP_BUTTON, // 8
};
static rct_widget window_editor_bottom_toolbar_widgets[] = {
static rct_widget _editorBottomToolbarWidgets[] = {
MakeWidget({ 0, 0}, {200, 34}, WindowWidgetType::ImgBtn, WindowColour::Primary),
MakeWidget({ 2, 2}, {196, 30}, WindowWidgetType::FlatBtn, WindowColour::Primary),
MakeWidget({440, 0}, {200, 34}, WindowWidgetType::ImgBtn, WindowColour::Primary),
MakeWidget({442, 2}, {196, 30}, WindowWidgetType::FlatBtn, WindowColour::Primary),
WIDGETS_END,
};
static void WindowEditorBottomToolbarMouseup(rct_window *w, rct_widgetindex widgetIndex);
static void WindowEditorBottomToolbarInvalidate(rct_window *w);
static void WindowEditorBottomToolbarPaint(rct_window *w, rct_drawpixelinfo *dpi);
static void WindowEditorBottomToolbarJumpBackToObjectSelection();
static void WindowEditorBottomToolbarJumpBackToLandscapeEditor();
static void WindowEditorBottomToolbarJumpBackToInventionListSetUp();
static void WindowEditorBottomToolbarJumpBackToOptionsSelection();
static void WindowEditorBottomToolbarJumpForwardFromObjectSelection();
static void WindowEditorBottomToolbarJumpForwardToInventionListSetUp();
static void WindowEditorBottomToolbarJumpForwardToOptionsSelection();
static void WindowEditorBottomToolbarJumpForwardToObjectiveSelection();
static void WindowEditorBottomToolbarJumpForwardToSaveScenario();
static rct_window_event_list window_editor_bottom_toolbar_events([](auto& events)
{
events.mouse_up = &WindowEditorBottomToolbarMouseup;
events.invalidate = &WindowEditorBottomToolbarInvalidate;
events.paint = &WindowEditorBottomToolbarPaint;
});
static EMPTY_ARGS_VOID_POINTER *previous_button_mouseup_events[] = {
nullptr,
WindowEditorBottomToolbarJumpBackToObjectSelection,
WindowEditorBottomToolbarJumpBackToLandscapeEditor,
WindowEditorBottomToolbarJumpBackToInventionListSetUp,
WindowEditorBottomToolbarJumpBackToOptionsSelection,
nullptr,
WindowEditorBottomToolbarJumpBackToObjectSelection,
nullptr,
};
static EMPTY_ARGS_VOID_POINTER *next_button_mouseup_events[] = {
WindowEditorBottomToolbarJumpForwardFromObjectSelection,
WindowEditorBottomToolbarJumpForwardToInventionListSetUp,
WindowEditorBottomToolbarJumpForwardToOptionsSelection,
WindowEditorBottomToolbarJumpForwardToObjectiveSelection,
WindowEditorBottomToolbarJumpForwardToSaveScenario,
nullptr,
nullptr,
nullptr,
};
static constexpr const rct_string_id EditorStepNames[] = {
STR_EDITOR_STEP_OBJECT_SELECTION,
STR_EDITOR_STEP_LANDSCAPE_EDITOR,
STR_EDITOR_STEP_INVENTIONS_LIST_SET_UP,
STR_EDITOR_STEP_OPTIONS_SELECTION,
STR_EDITOR_STEP_OBJECTIVE_SELECTION,
STR_EDITOR_STEP_SAVE_SCENARIO,
STR_EDITOR_STEP_ROLLERCOASTER_DESIGNER,
STR_EDITOR_STEP_TRACK_DESIGNS_MANAGER,
};
// clang-format on
class EditorBottomToolbarWindow final : public Window
{
private:
using FuncPtr = void (EditorBottomToolbarWindow::*)() const;
static constexpr const rct_string_id _editorStepNames[] = {
STR_EDITOR_STEP_OBJECT_SELECTION, STR_EDITOR_STEP_LANDSCAPE_EDITOR, STR_EDITOR_STEP_INVENTIONS_LIST_SET_UP,
STR_EDITOR_STEP_OPTIONS_SELECTION, STR_EDITOR_STEP_OBJECTIVE_SELECTION, STR_EDITOR_STEP_SAVE_SCENARIO,
STR_EDITOR_STEP_ROLLERCOASTER_DESIGNER, STR_EDITOR_STEP_TRACK_DESIGNS_MANAGER,
};
public:
void OnOpen() override
{
widgets = _editorBottomToolbarWidgets;
InitScrollWidgets();
set_all_scenery_items_invented();
}
void OnPrepareDraw() override
{
ColourSchemeUpdateByClass(
this,
(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) ? WC_EDITOR_SCENARIO_BOTTOM_TOOLBAR : WC_EDITOR_TRACK_BOTTOM_TOOLBAR);
uint16_t screenWidth = context_get_width();
widgets[WIDX_NEXT_IMAGE].left = screenWidth - 200;
widgets[WIDX_NEXT_IMAGE].right = screenWidth - 1;
widgets[WIDX_NEXT_STEP_BUTTON].left = screenWidth - 198;
widgets[WIDX_NEXT_STEP_BUTTON].right = screenWidth - 3;
widgets[WIDX_PREVIOUS_STEP_BUTTON].type = WindowWidgetType::FlatBtn;
widgets[WIDX_NEXT_STEP_BUTTON].type = WindowWidgetType::FlatBtn;
widgets[WIDX_PREVIOUS_IMAGE].type = WindowWidgetType::ImgBtn;
widgets[WIDX_NEXT_IMAGE].type = WindowWidgetType::ImgBtn;
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
{
HidePreviousStepButton();
HideNextStepButton();
}
else
{
if (gEditorStep == EditorStep::ObjectSelection)
{
HidePreviousStepButton();
}
else if (gEditorStep == EditorStep::RollercoasterDesigner)
{
HideNextStepButton();
}
else if (!(gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER))
{
if (GetNumFreeEntities() != MAX_ENTITIES || gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)
{
HidePreviousStepButton();
}
}
}
}
void OnDraw(rct_drawpixelinfo& dpi) override
{
auto drawPreviousButton = widgets[WIDX_PREVIOUS_STEP_BUTTON].type != WindowWidgetType::Empty;
auto drawNextButton = widgets[WIDX_NEXT_STEP_BUTTON].type != WindowWidgetType::Empty;
if (drawPreviousButton)
DrawLeftButtonBack(dpi);
if (drawNextButton)
DrawRightButtonBack(dpi);
DrawWidgets(dpi);
if (drawPreviousButton)
DrawLeftButton(dpi);
if (drawNextButton)
DrawRightButton(dpi);
DrawStepText(dpi);
}
void OnMouseUp(rct_widgetindex widgetIndex) override
{
if (widgetIndex == WIDX_PREVIOUS_STEP_BUTTON)
{
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|| (GetNumFreeEntities() == MAX_ENTITIES && !(gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)))
{
((this)->*(_previousButtonMouseUp[EnumValue(gEditorStep)]))();
}
}
else if (widgetIndex == WIDX_NEXT_STEP_BUTTON)
{
((this)->*(_nextButtonMouseUp[EnumValue(gEditorStep)]))();
}
}
private:
void JumpBackToObjectSelection() const
{
window_close_all();
gEditorStep = EditorStep::ObjectSelection;
gfx_invalidate_screen();
}
void JumpBackToLandscapeEditor() const
{
window_close_all();
set_all_scenery_items_invented();
scenery_set_default_placement_configuration();
gEditorStep = EditorStep::LandscapeEditor;
context_open_window(WC_MAP);
gfx_invalidate_screen();
}
void JumpBackToInventionListSetUp() const
{
window_close_all();
context_open_window(WC_EDITOR_INVENTION_LIST);
gEditorStep = EditorStep::InventionsListSetUp;
gfx_invalidate_screen();
}
void JumpBackToOptionsSelection() const
{
window_close_all();
context_open_window(WC_EDITOR_SCENARIO_OPTIONS);
gEditorStep = EditorStep::OptionsSelection;
gfx_invalidate_screen();
}
bool CheckObjectSelection() const
{
rct_window* w;
auto [missingObjectType, errorString] = Editor::CheckObjectSelection();
if (missingObjectType == ObjectType::None)
{
window_close_by_class(WC_EDITOR_OBJECT_SELECTION);
return true;
}
context_show_error(STR_INVALID_SELECTION_OF_OBJECTS, errorString, {});
w = window_find_by_class(WC_EDITOR_OBJECT_SELECTION);
if (w != nullptr)
{
// Click tab with missing object
window_event_mouse_up_call(w, WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 + EnumValue(missingObjectType));
}
return false;
}
void JumpForwardFromObjectSelection() const
{
if (!CheckObjectSelection())
return;
finish_object_selection();
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
{
context_open_window(WC_CONSTRUCT_RIDE);
}
else
{
context_open_window(WC_MAP);
}
}
void JumpForwardToInventionListSetUp() const
{
auto [checksPassed, errorString] = Editor::CheckPark();
if (checksPassed)
{
window_close_all();
context_open_window(WC_EDITOR_INVENTION_LIST);
gEditorStep = EditorStep::InventionsListSetUp;
}
else
{
context_show_error(STR_CANT_ADVANCE_TO_NEXT_EDITOR_STAGE, errorString, {});
}
gfx_invalidate_screen();
}
void JumpForwardToOptionsSelection() const
{
window_close_all();
context_open_window(WC_EDITOR_SCENARIO_OPTIONS);
gEditorStep = EditorStep::OptionsSelection;
gfx_invalidate_screen();
}
void JumpForwardToObjectiveSelection() const
{
window_close_all();
context_open_window(WC_EDITOR_OBJECTIVE_OPTIONS);
gEditorStep = EditorStep::ObjectiveSelection;
gfx_invalidate_screen();
}
void JumpForwardToSaveScenario() const
{
if (!scenario_prepare_for_save())
{
context_show_error(STR_UNABLE_TO_SAVE_SCENARIO_FILE, gGameCommandErrorText, {});
gfx_invalidate_screen();
return;
}
window_close_all();
auto intent = Intent(WC_LOADSAVE);
intent.putExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO);
intent.putExtra(INTENT_EXTRA_PATH, gScenarioName);
context_open_intent(&intent);
}
void HidePreviousStepButton()
{
widgets[WIDX_PREVIOUS_STEP_BUTTON].type = WindowWidgetType::Empty;
widgets[WIDX_PREVIOUS_IMAGE].type = WindowWidgetType::Empty;
}
void HideNextStepButton()
{
widgets[WIDX_NEXT_STEP_BUTTON].type = WindowWidgetType::Empty;
widgets[WIDX_NEXT_IMAGE].type = WindowWidgetType::Empty;
}
void DrawLeftButtonBack(rct_drawpixelinfo& dpi)
{
auto previousWidget = widgets[WIDX_PREVIOUS_IMAGE];
auto leftTop = windowPos + ScreenCoordsXY{ previousWidget.left, previousWidget.top };
auto rightBottom = windowPos + ScreenCoordsXY{ previousWidget.right, previousWidget.bottom };
gfx_filter_rect(&dpi, { leftTop, rightBottom }, FilterPaletteID::Palette51);
}
void DrawLeftButton(rct_drawpixelinfo& dpi)
{
const auto topLeft = windowPos
+ ScreenCoordsXY{ widgets[WIDX_PREVIOUS_IMAGE].left + 1, widgets[WIDX_PREVIOUS_IMAGE].top + 1 };
const auto bottomRight = windowPos
+ ScreenCoordsXY{ widgets[WIDX_PREVIOUS_IMAGE].right - 1, widgets[WIDX_PREVIOUS_IMAGE].bottom - 1 };
gfx_fill_rect_inset(&dpi, { topLeft, bottomRight }, colours[1], INSET_RECT_F_30);
gfx_draw_sprite(
&dpi, ImageId(SPR_PREVIOUS),
windowPos + ScreenCoordsXY{ widgets[WIDX_PREVIOUS_IMAGE].left + 6, widgets[WIDX_PREVIOUS_IMAGE].top + 6 });
colour_t textColour = NOT_TRANSLUCENT(colours[1]);
if (gHoverWidget.window_classification == WC_BOTTOM_TOOLBAR && gHoverWidget.widget_index == WIDX_PREVIOUS_STEP_BUTTON)
{
textColour = COLOUR_WHITE;
}
int16_t textX = (widgets[WIDX_PREVIOUS_IMAGE].left + 30 + widgets[WIDX_PREVIOUS_IMAGE].right) / 2 + windowPos.x;
int16_t textY = widgets[WIDX_PREVIOUS_IMAGE].top + 6 + windowPos.y;
rct_string_id stringId = _editorStepNames[EnumValue(gEditorStep) - 1];
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
stringId = STR_EDITOR_STEP_OBJECT_SELECTION;
DrawTextBasic(&dpi, { textX, textY }, STR_BACK_TO_PREVIOUS_STEP, {}, { textColour, TextAlignment::CENTRE });
DrawTextBasic(&dpi, { textX, textY + 10 }, stringId, {}, { textColour, TextAlignment::CENTRE });
}
void DrawRightButtonBack(rct_drawpixelinfo& dpi)
{
auto nextWidget = widgets[WIDX_NEXT_IMAGE];
auto leftTop = windowPos + ScreenCoordsXY{ nextWidget.left, nextWidget.top };
auto rightBottom = windowPos + ScreenCoordsXY{ nextWidget.right, nextWidget.bottom };
gfx_filter_rect(&dpi, { leftTop, rightBottom }, FilterPaletteID::Palette51);
}
void DrawRightButton(rct_drawpixelinfo& dpi)
{
const auto topLeft = windowPos + ScreenCoordsXY{ widgets[WIDX_NEXT_IMAGE].left + 1, widgets[WIDX_NEXT_IMAGE].top + 1 };
const auto bottomRight = windowPos
+ ScreenCoordsXY{ widgets[WIDX_NEXT_IMAGE].right - 1, widgets[WIDX_NEXT_IMAGE].bottom - 1 };
gfx_fill_rect_inset(&dpi, { topLeft, bottomRight }, colours[1], INSET_RECT_F_30);
gfx_draw_sprite(
&dpi, ImageId(SPR_NEXT),
windowPos + ScreenCoordsXY{ widgets[WIDX_NEXT_IMAGE].right - 29, widgets[WIDX_NEXT_IMAGE].top + 6 });
colour_t textColour = NOT_TRANSLUCENT(colours[1]);
if (gHoverWidget.window_classification == WC_BOTTOM_TOOLBAR && gHoverWidget.widget_index == WIDX_NEXT_STEP_BUTTON)
{
textColour = COLOUR_WHITE;
}
int16_t textX = (widgets[WIDX_NEXT_IMAGE].left + widgets[WIDX_NEXT_IMAGE].right - 30) / 2 + windowPos.x;
int16_t textY = widgets[WIDX_NEXT_IMAGE].top + 6 + windowPos.y;
rct_string_id stringId = _editorStepNames[EnumValue(gEditorStep) + 1];
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
stringId = STR_EDITOR_STEP_ROLLERCOASTER_DESIGNER;
DrawTextBasic(&dpi, { textX, textY }, STR_FORWARD_TO_NEXT_STEP, {}, { textColour, TextAlignment::CENTRE });
DrawTextBasic(&dpi, { textX, textY + 10 }, stringId, {}, { textColour, TextAlignment::CENTRE });
}
void DrawStepText(rct_drawpixelinfo& dpi)
{
int16_t stateX = (widgets[WIDX_PREVIOUS_IMAGE].right + widgets[WIDX_NEXT_IMAGE].left) / 2 + windowPos.x;
int16_t stateY = height - 0x0C + windowPos.y;
DrawTextBasic(
&dpi, { stateX, stateY }, _editorStepNames[EnumValue(gEditorStep)], {},
{ static_cast<colour_t>(NOT_TRANSLUCENT(colours[2]) | COLOUR_FLAG_OUTLINE), TextAlignment::CENTRE });
}
static constexpr FuncPtr _previousButtonMouseUp[] = {
nullptr,
&EditorBottomToolbarWindow::JumpBackToObjectSelection,
&EditorBottomToolbarWindow::JumpBackToLandscapeEditor,
&EditorBottomToolbarWindow::JumpBackToInventionListSetUp,
&EditorBottomToolbarWindow::JumpBackToOptionsSelection,
nullptr,
&EditorBottomToolbarWindow::JumpBackToObjectSelection,
nullptr,
};
static constexpr const FuncPtr _nextButtonMouseUp[] = {
&EditorBottomToolbarWindow::JumpForwardFromObjectSelection,
&EditorBottomToolbarWindow::JumpForwardToInventionListSetUp,
&EditorBottomToolbarWindow::JumpForwardToOptionsSelection,
&EditorBottomToolbarWindow::JumpForwardToObjectiveSelection,
&EditorBottomToolbarWindow::JumpForwardToSaveScenario,
nullptr,
nullptr,
nullptr,
};
};
/**
* Creates the main editor top toolbar window.
* rct2: 0x0066F052 (part of 0x0066EF38)
*/
rct_window* WindowEditorBottomToolbarOpen()
{
rct_window* window = WindowCreate(
ScreenCoordsXY(0, context_get_height() - 32), context_get_width(), 32, &window_editor_bottom_toolbar_events,
WC_BOTTOM_TOOLBAR, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_BACKGROUND);
window->widgets = window_editor_bottom_toolbar_widgets;
WindowInitScrollWidgets(window);
set_all_scenery_items_invented();
auto* window = WindowCreate<EditorBottomToolbarWindow>(
WC_BOTTOM_TOOLBAR, ScreenCoordsXY(0, context_get_height() - 32), context_get_width(), 32,
WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_BACKGROUND);
return window;
}
/**
*
* rct2: 0x0066F619
*/
void WindowEditorBottomToolbarJumpBackToObjectSelection()
{
window_close_all();
gEditorStep = EditorStep::ObjectSelection;
gfx_invalidate_screen();
}
/**
*
* rct2: 0x0066F62C
*/
void WindowEditorBottomToolbarJumpBackToLandscapeEditor()
{
window_close_all();
set_all_scenery_items_invented();
scenery_set_default_placement_configuration();
gEditorStep = EditorStep::LandscapeEditor;
context_open_window(WC_MAP);
gfx_invalidate_screen();
}
/**
*
* rct2: 0x0066F64E
*/
static void WindowEditorBottomToolbarJumpBackToInventionListSetUp()
{
window_close_all();
context_open_window(WC_EDITOR_INVENTION_LIST);
gEditorStep = EditorStep::InventionsListSetUp;
gfx_invalidate_screen();
}
/**
*
* rct2: 0x0066F666
*/
void WindowEditorBottomToolbarJumpBackToOptionsSelection()
{
window_close_all();
context_open_window(WC_EDITOR_SCENARIO_OPTIONS);
gEditorStep = EditorStep::OptionsSelection;
gfx_invalidate_screen();
}
/**
*
* rct2: 0x006AB1CE
*/
static bool WindowEditorBottomToolbarCheckObjectSelection()
{
rct_window* w;
auto [missingObjectType, errorString] = Editor::CheckObjectSelection();
if (missingObjectType == ObjectType::None)
{
window_close_by_class(WC_EDITOR_OBJECT_SELECTION);
return true;
}
context_show_error(STR_INVALID_SELECTION_OF_OBJECTS, errorString, {});
w = window_find_by_class(WC_EDITOR_OBJECT_SELECTION);
if (w != nullptr)
{
// Click tab with missing object
window_event_mouse_up_call(w, WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 + EnumValue(missingObjectType));
}
return false;
}
/**
*
* rct2: 0x0066F6B0
*/
void WindowEditorBottomToolbarJumpForwardFromObjectSelection()
{
if (!WindowEditorBottomToolbarCheckObjectSelection())
return;
finish_object_selection();
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
{
context_open_window(WC_CONSTRUCT_RIDE);
}
else
{
context_open_window(WC_MAP);
}
}
/**
*
* rct2: 0x0066F758
*/
void WindowEditorBottomToolbarJumpForwardToInventionListSetUp()
{
auto [checksPassed, errorString] = Editor::CheckPark();
if (checksPassed)
{
window_close_all();
context_open_window(WC_EDITOR_INVENTION_LIST);
gEditorStep = EditorStep::InventionsListSetUp;
}
else
{
context_show_error(STR_CANT_ADVANCE_TO_NEXT_EDITOR_STAGE, errorString, {});
}
gfx_invalidate_screen();
}
/**
*
* rct2: 0x0066f790
*/
void WindowEditorBottomToolbarJumpForwardToOptionsSelection()
{
window_close_all();
context_open_window(WC_EDITOR_SCENARIO_OPTIONS);
gEditorStep = EditorStep::OptionsSelection;
gfx_invalidate_screen();
}
/**
*
* rct2: 0x0066f7a8
*/
void WindowEditorBottomToolbarJumpForwardToObjectiveSelection()
{
window_close_all();
context_open_window(WC_EDITOR_OBJECTIVE_OPTIONS);
gEditorStep = EditorStep::ObjectiveSelection;
gfx_invalidate_screen();
}
/**
*
* rct2: 0x0066F7C0
*/
void WindowEditorBottomToolbarJumpForwardToSaveScenario()
{
if (!scenario_prepare_for_save())
{
context_show_error(STR_UNABLE_TO_SAVE_SCENARIO_FILE, gGameCommandErrorText, {});
gfx_invalidate_screen();
return;
}
window_close_all();
auto intent = Intent(WC_LOADSAVE);
intent.putExtra(INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO);
intent.putExtra(INTENT_EXTRA_PATH, gScenarioName);
context_open_intent(&intent);
}
/**
*
* rct2: 0x0066F5AE
*/
static void WindowEditorBottomToolbarMouseup([[maybe_unused]] rct_window* w, rct_widgetindex widgetIndex)
{
if (widgetIndex == WIDX_PREVIOUS_STEP_BUTTON)
{
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|| (GetNumFreeEntities() == MAX_ENTITIES && !(gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)))
{
previous_button_mouseup_events[EnumValue(gEditorStep)]();
}
}
else if (widgetIndex == WIDX_NEXT_STEP_BUTTON)
{
next_button_mouseup_events[EnumValue(gEditorStep)]();
}
}
static void HidePreviousStepButton()
{
window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_STEP_BUTTON].type = WindowWidgetType::Empty;
window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].type = WindowWidgetType::Empty;
}
static void HideNextStepButton()
{
window_editor_bottom_toolbar_widgets[WIDX_NEXT_STEP_BUTTON].type = WindowWidgetType::Empty;
window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].type = WindowWidgetType::Empty;
}
/**
*
* rct2: 0x0066F1C9
*/
void WindowEditorBottomToolbarInvalidate(rct_window* w)
{
ColourSchemeUpdateByClass(
w, (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) ? WC_EDITOR_SCENARIO_BOTTOM_TOOLBAR : WC_EDITOR_TRACK_BOTTOM_TOOLBAR);
uint16_t screenWidth = context_get_width();
window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].left = screenWidth - 200;
window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].right = screenWidth - 1;
window_editor_bottom_toolbar_widgets[WIDX_NEXT_STEP_BUTTON].left = screenWidth - 198;
window_editor_bottom_toolbar_widgets[WIDX_NEXT_STEP_BUTTON].right = screenWidth - 3;
window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_STEP_BUTTON].type = WindowWidgetType::FlatBtn;
window_editor_bottom_toolbar_widgets[WIDX_NEXT_STEP_BUTTON].type = WindowWidgetType::FlatBtn;
window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].type = WindowWidgetType::ImgBtn;
window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].type = WindowWidgetType::ImgBtn;
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
{
HidePreviousStepButton();
HideNextStepButton();
}
else
{
if (gEditorStep == EditorStep::ObjectSelection)
{
HidePreviousStepButton();
}
else if (gEditorStep == EditorStep::RollercoasterDesigner)
{
HideNextStepButton();
}
else if (!(gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER))
{
if (GetNumFreeEntities() != MAX_ENTITIES || gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)
{
HidePreviousStepButton();
}
}
}
}
static void WindowEditorBottomToolbarDrawLeftButtonBack(rct_window* w, rct_drawpixelinfo* dpi)
{
auto previousWidget = w->widgets[WIDX_PREVIOUS_IMAGE];
auto leftTop = w->windowPos + ScreenCoordsXY{ previousWidget.left, previousWidget.top };
auto rightBottom = w->windowPos + ScreenCoordsXY{ previousWidget.right, previousWidget.bottom };
gfx_filter_rect(dpi, { leftTop, rightBottom }, FilterPaletteID::Palette51);
}
static void WindowEditorBottomToolbarDrawLeftButton(rct_window* w, rct_drawpixelinfo* dpi)
{
const auto topLeft = w->windowPos
+ ScreenCoordsXY{ w->widgets[WIDX_PREVIOUS_IMAGE].left + 1, w->widgets[WIDX_PREVIOUS_IMAGE].top + 1 };
const auto bottomRight = w->windowPos
+ ScreenCoordsXY{ w->widgets[WIDX_PREVIOUS_IMAGE].right - 1, w->widgets[WIDX_PREVIOUS_IMAGE].bottom - 1 };
gfx_fill_rect_inset(dpi, { topLeft, bottomRight }, w->colours[1], INSET_RECT_F_30);
gfx_draw_sprite(
dpi, ImageId(SPR_PREVIOUS),
w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_PREVIOUS_IMAGE].left + 6, w->widgets[WIDX_PREVIOUS_IMAGE].top + 6 });
colour_t textColour = NOT_TRANSLUCENT(w->colours[1]);
if (gHoverWidget.window_classification == WC_BOTTOM_TOOLBAR && gHoverWidget.widget_index == WIDX_PREVIOUS_STEP_BUTTON)
{
textColour = COLOUR_WHITE;
}
int16_t textX = (w->widgets[WIDX_PREVIOUS_IMAGE].left + 30 + w->widgets[WIDX_PREVIOUS_IMAGE].right) / 2 + w->windowPos.x;
int16_t textY = w->widgets[WIDX_PREVIOUS_IMAGE].top + 6 + w->windowPos.y;
rct_string_id stringId = EditorStepNames[EnumValue(gEditorStep) - 1];
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
stringId = STR_EDITOR_STEP_OBJECT_SELECTION;
DrawTextBasic(dpi, { textX, textY }, STR_BACK_TO_PREVIOUS_STEP, {}, { textColour, TextAlignment::CENTRE });
DrawTextBasic(dpi, { textX, textY + 10 }, stringId, {}, { textColour, TextAlignment::CENTRE });
}
static void WindowEditorBottomToolbarDrawRightButtonBack(rct_window* w, rct_drawpixelinfo* dpi)
{
auto nextWidget = w->widgets[WIDX_NEXT_IMAGE];
auto leftTop = w->windowPos + ScreenCoordsXY{ nextWidget.left, nextWidget.top };
auto rightBottom = w->windowPos + ScreenCoordsXY{ nextWidget.right, nextWidget.bottom };
gfx_filter_rect(dpi, { leftTop, rightBottom }, FilterPaletteID::Palette51);
}
static void WindowEditorBottomToolbarDrawRightButton(rct_window* w, rct_drawpixelinfo* dpi)
{
const auto topLeft = w->windowPos
+ ScreenCoordsXY{ w->widgets[WIDX_NEXT_IMAGE].left + 1, w->widgets[WIDX_NEXT_IMAGE].top + 1 };
const auto bottomRight = w->windowPos
+ ScreenCoordsXY{ w->widgets[WIDX_NEXT_IMAGE].right - 1, w->widgets[WIDX_NEXT_IMAGE].bottom - 1 };
gfx_fill_rect_inset(dpi, { topLeft, bottomRight }, w->colours[1], INSET_RECT_F_30);
gfx_draw_sprite(
dpi, ImageId(SPR_NEXT),
w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_NEXT_IMAGE].right - 29, w->widgets[WIDX_NEXT_IMAGE].top + 6 });
colour_t textColour = NOT_TRANSLUCENT(w->colours[1]);
if (gHoverWidget.window_classification == WC_BOTTOM_TOOLBAR && gHoverWidget.widget_index == WIDX_NEXT_STEP_BUTTON)
{
textColour = COLOUR_WHITE;
}
int16_t textX = (w->widgets[WIDX_NEXT_IMAGE].left + w->widgets[WIDX_NEXT_IMAGE].right - 30) / 2 + w->windowPos.x;
int16_t textY = w->widgets[WIDX_NEXT_IMAGE].top + 6 + w->windowPos.y;
rct_string_id stringId = EditorStepNames[EnumValue(gEditorStep) + 1];
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
stringId = STR_EDITOR_STEP_ROLLERCOASTER_DESIGNER;
DrawTextBasic(dpi, { textX, textY }, STR_FORWARD_TO_NEXT_STEP, {}, { textColour, TextAlignment::CENTRE });
DrawTextBasic(dpi, { textX, textY + 10 }, stringId, {}, { textColour, TextAlignment::CENTRE });
}
static void WindowEditorBottomToolbarDrawStepText(rct_window* w, rct_drawpixelinfo* dpi)
{
int16_t stateX = (w->widgets[WIDX_PREVIOUS_IMAGE].right + w->widgets[WIDX_NEXT_IMAGE].left) / 2 + w->windowPos.x;
int16_t stateY = w->height - 0x0C + w->windowPos.y;
DrawTextBasic(
dpi, { stateX, stateY }, EditorStepNames[EnumValue(gEditorStep)], {},
{ static_cast<colour_t>(NOT_TRANSLUCENT(w->colours[2]) | COLOUR_FLAG_OUTLINE), TextAlignment::CENTRE });
}
/**
*
* rct2: 0x0066F25C
*/
void WindowEditorBottomToolbarPaint(rct_window* w, rct_drawpixelinfo* dpi)
{
auto drawPreviousButton = w->widgets[WIDX_PREVIOUS_STEP_BUTTON].type != WindowWidgetType::Empty;
auto drawNextButton = w->widgets[WIDX_NEXT_STEP_BUTTON].type != WindowWidgetType::Empty;
if (drawPreviousButton)
WindowEditorBottomToolbarDrawLeftButtonBack(w, dpi);
if (drawNextButton)
WindowEditorBottomToolbarDrawRightButtonBack(w, dpi);
WindowDrawWidgets(w, dpi);
if (drawPreviousButton)
WindowEditorBottomToolbarDrawLeftButton(w, dpi);
if (drawNextButton)
WindowEditorBottomToolbarDrawRightButton(w, dpi);
WindowEditorBottomToolbarDrawStepText(w, dpi);
}