1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-26 08:14:38 +01:00
Files
OpenRCT2/src/openrct2-ui/windows/Main.cpp
Duncan fa57b6aea0 Remove focus union and replace with typed focus (#15426)
* Remove focus union and replace with typed focus

This if for the NSF to allow for CoordsXYZ

* Remove legacy structures

* Rework viewport_create to deduplicate logic

* Simplify yet further

* Apply review comments

* Remove intermediate
2021-09-18 20:34:38 +01:00

66 lines
2.1 KiB
C++

/*****************************************************************************
* 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 <openrct2-ui/interface/Viewport.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/localisation/StringIds.h>
#include <openrct2/world/Footpath.h>
// clang-format off
static rct_widget window_main_widgets[] = {
MakeWidget({0, 0}, {0, 0}, WindowWidgetType::Viewport, WindowColour::Primary, STR_VIEWPORT),
{ WIDGETS_END },
};
void window_main_paint(rct_window *w, rct_drawpixelinfo *dpi);
static rct_window_event_list window_main_events([](auto& events)
{
events.paint = &window_main_paint;
});
// clang-format on
/**
* Creates the main window that holds the main viewport.
* rct2: 0x0066B3E8
*/
rct_window* window_main_open()
{
window_main_widgets[0].right = context_get_width();
window_main_widgets[0].bottom = context_get_height();
rct_window* window = WindowCreate(
ScreenCoordsXY(0, 0), window_main_widgets[0].right, window_main_widgets[0].bottom, &window_main_events, WC_MAIN_WINDOW,
WF_STICK_TO_BACK);
window->widgets = window_main_widgets;
const auto focus = Focus2(CoordsXYZ(0x0FFF, 0x0FFF, 0));
viewport_create(window, window->windowPos, window->width, window->height, focus);
window->viewport->flags |= VIEWPORT_FLAG_SOUND_ON;
gCurrentRotation = 0;
gShowGridLinesRefCount = 0;
gShowLandRightsRefCount = 0;
gShowConstuctionRightsRefCount = 0;
WindowFootpathResetSelectedPath();
return window;
}
/**
*
* rct2: 0x66CCAE
* This function immediately jumps to 0x00685BE1 this is the second function
* decompiled.
*/
void window_main_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
viewport_render(dpi, w->viewport, dpi->x, dpi->y, dpi->x + dpi->width, dpi->y + dpi->height);
}