OpenRCT2/src/openrct2-ui/windows/Main.cpp

78 lines
2.6 KiB
C++
Raw Normal View History

/*****************************************************************************
* Copyright (c) 2014-2023 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.
*****************************************************************************/
2018-01-03 00:13:37 +01:00
#include <openrct2-ui/interface/Viewport.h>
#include <openrct2-ui/interface/Widget.h>
2018-06-22 23:21:44 +02:00
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
2022-03-06 18:33:02 +01:00
#include <openrct2/config/Config.h>
2018-01-06 18:32:25 +01:00
#include <openrct2/localisation/StringIds.h>
2018-01-11 10:59:26 +01:00
#include <openrct2/world/Footpath.h>
// clang-format off
2022-12-24 16:50:29 +01:00
static Widget _mainWidgets[] = {
MakeWidget({0, 0}, {0, 0}, WindowWidgetType::Viewport, WindowColour::Primary, STR_VIEWPORT),
2021-09-26 11:11:42 +02:00
WIDGETS_END,
};
// clang-format on
2014-07-15 15:59:43 +02:00
class MainWindow final : public Window
{
public:
void OnOpen() override
2022-03-06 18:33:02 +01:00
{
_mainWidgets[0].right = width;
_mainWidgets[0].bottom = height;
widgets = _mainWidgets;
2023-01-16 21:14:50 +01:00
ViewportCreate(this, windowPos, width, height, Focus(CoordsXYZ(0x0FFF, 0x0FFF, 0)));
if (viewport != nullptr)
{
SetViewportFlags();
}
gCurrentRotation = 0;
gShowGridLinesRefCount = 0;
gShowLandRightsRefCount = 0;
gShowConstructionRightsRefCount = 0;
WindowFootpathResetSelectedPath();
2022-03-06 18:33:02 +01:00
}
2017-08-12 23:06:12 +02:00
void OnDraw(DrawPixelInfo& dpi) override
{
2023-01-16 21:14:50 +01:00
ViewportRender(&dpi, viewport, { { dpi.x, dpi.y }, { dpi.x + dpi.width, dpi.y + dpi.height } });
}
2014-07-15 15:59:43 +02:00
private:
void SetViewportFlags()
{
viewport->flags |= VIEWPORT_FLAG_SOUND_ON;
if (gConfigGeneral.InvisibleRides)
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_RIDES;
if (gConfigGeneral.InvisibleVehicles)
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_VEHICLES;
if (gConfigGeneral.InvisibleTrees)
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_VEGETATION;
if (gConfigGeneral.InvisibleScenery)
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_SCENERY;
if (gConfigGeneral.InvisiblePaths)
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_PATHS;
if (gConfigGeneral.InvisibleSupports)
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_SUPPORTS;
}
};
2022-03-06 18:33:02 +01:00
2014-07-15 15:59:43 +02:00
/**
* Creates the main window that holds the main viewport.
* rct2: 0x0066B3E8
2014-07-15 15:59:43 +02:00
*/
WindowBase* WindowMainOpen()
2014-10-09 16:55:47 +02:00
{
2022-11-06 21:49:07 +01:00
return WindowCreate<MainWindow>(WindowClass::MainWindow, { 0, 0 }, ContextGetWidth(), ContextGetHeight(), WF_STICK_TO_BACK);
2014-07-15 15:59:43 +02:00
}