2014-04-03 04:08:06 +02:00
|
|
|
/*****************************************************************************
|
2022-10-01 09:42:14 +02:00
|
|
|
* Copyright (c) 2014-2022 OpenRCT2 developers
|
2014-04-03 04:08:06 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2014-04-03 04:08:06 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2014-04-03 04:08:06 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
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>
|
2014-04-03 04:08:06 +02:00
|
|
|
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format off
|
2022-06-07 13:06:57 +02:00
|
|
|
static rct_widget _mainWidgets[] = {
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget({0, 0}, {0, 0}, WindowWidgetType::Viewport, WindowColour::Primary, STR_VIEWPORT),
|
2021-09-26 11:11:42 +02:00
|
|
|
WIDGETS_END,
|
2014-04-03 04:08:06 +02:00
|
|
|
};
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format on
|
2014-07-15 15:59:43 +02:00
|
|
|
|
2022-06-07 13:06:57 +02:00
|
|
|
class MainWindow final : public Window
|
2014-04-03 04:08:06 +02:00
|
|
|
{
|
2022-06-07 13:06:57 +02:00
|
|
|
public:
|
|
|
|
void OnOpen() override
|
2022-03-06 18:33:02 +01:00
|
|
|
{
|
2022-06-07 13:06:57 +02:00
|
|
|
_mainWidgets[0].right = width;
|
|
|
|
_mainWidgets[0].bottom = height;
|
|
|
|
widgets = _mainWidgets;
|
|
|
|
|
|
|
|
viewport_create(this, windowPos, width, height, Focus(CoordsXYZ(0x0FFF, 0x0FFF, 0)));
|
|
|
|
if (viewport != nullptr)
|
|
|
|
{
|
|
|
|
SetViewportFlags();
|
|
|
|
}
|
|
|
|
gCurrentRotation = 0;
|
|
|
|
gShowGridLinesRefCount = 0;
|
|
|
|
gShowLandRightsRefCount = 0;
|
2022-12-10 22:35:59 +01:00
|
|
|
gShowConstructionRightsRefCount = 0;
|
2022-06-07 13:06:57 +02:00
|
|
|
WindowFootpathResetSelectedPath();
|
2022-03-06 18:33:02 +01:00
|
|
|
}
|
2017-08-12 23:06:12 +02:00
|
|
|
|
2022-06-07 13:06:57 +02:00
|
|
|
void OnDraw(rct_drawpixelinfo& dpi) override
|
|
|
|
{
|
|
|
|
viewport_render(&dpi, viewport, { { dpi.x, dpi.y }, { dpi.x + dpi.width, dpi.y + dpi.height } });
|
|
|
|
}
|
2014-07-15 15:59:43 +02:00
|
|
|
|
2022-06-07 13:06:57 +02:00
|
|
|
private:
|
|
|
|
void SetViewportFlags()
|
|
|
|
{
|
|
|
|
viewport->flags |= VIEWPORT_FLAG_SOUND_ON;
|
2022-10-16 17:27:01 +02:00
|
|
|
if (gConfigGeneral.InvisibleRides)
|
2022-06-07 13:06:57 +02:00
|
|
|
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_RIDES;
|
2022-10-16 17:27:01 +02:00
|
|
|
if (gConfigGeneral.InvisibleVehicles)
|
2022-06-07 13:06:57 +02:00
|
|
|
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_VEHICLES;
|
2022-10-16 17:27:01 +02:00
|
|
|
if (gConfigGeneral.InvisibleTrees)
|
2022-06-07 13:06:57 +02:00
|
|
|
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_VEGETATION;
|
2022-10-16 17:27:01 +02:00
|
|
|
if (gConfigGeneral.InvisibleScenery)
|
2022-06-07 13:06:57 +02:00
|
|
|
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_SCENERY;
|
2022-10-16 17:27:01 +02:00
|
|
|
if (gConfigGeneral.InvisiblePaths)
|
2022-06-07 13:06:57 +02:00
|
|
|
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_PATHS;
|
2022-10-16 17:27:01 +02:00
|
|
|
if (gConfigGeneral.InvisibleSupports)
|
2022-06-07 13:06:57 +02:00
|
|
|
viewport->flags |= VIEWPORT_FLAG_INVISIBLE_SUPPORTS;
|
|
|
|
}
|
|
|
|
};
|
2022-03-06 18:33:02 +01:00
|
|
|
|
2014-07-15 15:59:43 +02:00
|
|
|
/**
|
2022-06-07 13:06:57 +02:00
|
|
|
* Creates the main window that holds the main viewport.
|
|
|
|
* rct2: 0x0066B3E8
|
2014-07-15 15:59:43 +02:00
|
|
|
*/
|
2022-06-07 13:06:57 +02:00
|
|
|
rct_window* 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
|
|
|
}
|