2016-09-06 21:58:58 +02:00
|
|
|
/*****************************************************************************
|
2018-06-15 14:07:34 +02:00
|
|
|
* Copyright (c) 2014-2018 OpenRCT2 developers
|
2016-09-06 21:58:58 +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
|
2016-09-06 21:58:58 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2016-09-06 21:58:58 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-06-22 22:29:03 +02:00
|
|
|
#include "TestPaint.hpp"
|
2016-09-06 21:58:58 +02:00
|
|
|
|
2016-10-17 00:13:46 +02:00
|
|
|
#include "GeneralSupportHeightCall.hpp"
|
2018-06-22 22:29:03 +02:00
|
|
|
#include "Hook.h"
|
2016-10-17 00:13:46 +02:00
|
|
|
#include "Printer.hpp"
|
|
|
|
#include "SegmentSupportHeightCall.hpp"
|
2016-10-16 21:41:20 +02:00
|
|
|
#include "Utils.hpp"
|
2016-10-08 00:52:01 +02:00
|
|
|
|
2018-06-22 22:29:03 +02:00
|
|
|
#include <algorithm>
|
|
|
|
#include <openrct2/interface/Viewport.h>
|
2017-12-14 10:34:12 +01:00
|
|
|
#include <openrct2/paint/Paint.h>
|
|
|
|
#include <openrct2/paint/Supports.h>
|
2017-10-16 12:02:23 +02:00
|
|
|
#include <openrct2/ride/TrackData.h>
|
2018-03-19 23:34:37 +01:00
|
|
|
#include <openrct2/scenario/Scenario.h>
|
2018-06-22 22:29:03 +02:00
|
|
|
#include <vector>
|
2016-09-06 21:58:58 +02:00
|
|
|
|
2016-10-17 16:06:05 +02:00
|
|
|
namespace TestPaint
|
2016-09-06 21:58:58 +02:00
|
|
|
{
|
2018-06-22 22:29:03 +02:00
|
|
|
void ResetEnvironment()
|
|
|
|
{
|
2016-10-16 15:49:04 +02:00
|
|
|
gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
|
2017-09-02 18:33:12 +02:00
|
|
|
gPaintSession.InteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
|
|
|
|
|
2016-10-16 15:49:04 +02:00
|
|
|
gTrackColours[SCHEME_TRACK] = DEFAULT_SCHEME_TRACK;
|
|
|
|
gTrackColours[SCHEME_SUPPORTS] = DEFAULT_SCHEME_SUPPORTS;
|
|
|
|
gTrackColours[SCHEME_MISC] = DEFAULT_SCHEME_MISC;
|
|
|
|
gTrackColours[SCHEME_3] = DEFAULT_SCHEME_3;
|
|
|
|
|
2017-09-12 20:48:18 +02:00
|
|
|
gPaintSession.TrackColours[SCHEME_TRACK] = DEFAULT_SCHEME_TRACK;
|
|
|
|
gPaintSession.TrackColours[SCHEME_SUPPORTS] = DEFAULT_SCHEME_SUPPORTS;
|
|
|
|
gPaintSession.TrackColours[SCHEME_MISC] = DEFAULT_SCHEME_MISC;
|
|
|
|
gPaintSession.TrackColours[SCHEME_3] = DEFAULT_SCHEME_3;
|
|
|
|
|
2018-06-05 15:28:19 +02:00
|
|
|
rct_drawpixelinfo dpi = {};
|
2016-10-16 15:49:04 +02:00
|
|
|
dpi.zoom_level = 1;
|
2017-12-04 19:57:41 +01:00
|
|
|
RCT2_Unk140E9A8 = &dpi;
|
2018-05-18 22:50:57 +02:00
|
|
|
gPaintSession.DPI = &dpi;
|
2016-10-16 15:49:04 +02:00
|
|
|
|
2017-12-04 20:01:16 +01:00
|
|
|
{
|
2018-06-05 15:28:19 +02:00
|
|
|
Ride ride = {};
|
2017-12-04 20:01:16 +01:00
|
|
|
ride.entrance_style = RIDE_ENTRANCE_STYLE_PLAIN;
|
2018-06-05 15:28:19 +02:00
|
|
|
static rct_ride_entry rideEntry = {};
|
2018-06-22 22:29:03 +02:00
|
|
|
rct_ride_entry_vehicle vehicleEntry{};
|
2017-12-04 20:01:16 +01:00
|
|
|
vehicleEntry.base_image_id = 0x70000;
|
|
|
|
rideEntry.vehicles[0] = vehicleEntry;
|
|
|
|
gRideList[0] = ride;
|
|
|
|
gRideEntries[0] = &rideEntry;
|
|
|
|
}
|
|
|
|
{
|
2018-06-05 15:28:19 +02:00
|
|
|
rct2_ride ride = {};
|
2017-12-04 20:01:16 +01:00
|
|
|
ride.entrance_style = RIDE_ENTRANCE_STYLE_PLAIN;
|
|
|
|
RCT2_Rides[0] = ride;
|
|
|
|
}
|
2016-10-16 15:49:04 +02:00
|
|
|
|
2016-10-16 16:06:18 +02:00
|
|
|
g141E9DB = G141E9DB_FLAG_1 | G141E9DB_FLAG_2;
|
2017-09-02 18:33:12 +02:00
|
|
|
gPaintSession.Unk141E9DB = G141E9DB_FLAG_1 | G141E9DB_FLAG_2;
|
2017-12-03 23:07:24 +01:00
|
|
|
|
|
|
|
gCurrentViewportFlags = 0;
|
2017-12-04 19:57:41 +01:00
|
|
|
RCT2_CurrentViewportFlags = 0;
|
2017-12-03 23:07:24 +01:00
|
|
|
|
|
|
|
gScenarioTicks = 0;
|
2017-12-04 19:57:41 +01:00
|
|
|
RCT2_ScenarioTicks = 0;
|
2016-10-16 16:06:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 22:29:03 +02:00
|
|
|
void ResetTunnels()
|
|
|
|
{
|
2016-10-16 16:06:18 +02:00
|
|
|
gLeftTunnelCount = 0;
|
|
|
|
gRightTunnelCount = 0;
|
2017-09-02 18:33:12 +02:00
|
|
|
gPaintSession.LeftTunnelCount = 0;
|
|
|
|
gPaintSession.RightTunnelCount = 0;
|
2016-10-16 16:06:18 +02:00
|
|
|
|
2018-06-22 22:29:03 +02:00
|
|
|
for (int i = 0; i < TUNNEL_MAX_COUNT; i++)
|
|
|
|
{
|
2016-10-16 19:10:55 +02:00
|
|
|
gLeftTunnels[i].height = 0;
|
|
|
|
gLeftTunnels[i].type = 0;
|
|
|
|
gRightTunnels[i].height = 0;
|
|
|
|
gRightTunnels[i].type = 0;
|
2017-09-02 18:33:12 +02:00
|
|
|
gPaintSession.LeftTunnels[i].height = 0;
|
|
|
|
gPaintSession.LeftTunnels[i].type = 0;
|
|
|
|
gPaintSession.RightTunnels[i].height = 0;
|
|
|
|
gPaintSession.RightTunnels[i].type = 0;
|
2016-10-16 16:06:18 +02:00
|
|
|
}
|
|
|
|
|
2016-10-16 19:10:55 +02:00
|
|
|
gLeftTunnels[0].height = 0xFF;
|
|
|
|
gLeftTunnels[0].type = 0xFF;
|
|
|
|
gRightTunnels[0].height = 0xFF;
|
|
|
|
gRightTunnels[0].type = 0xFF;
|
2017-09-02 18:33:12 +02:00
|
|
|
gPaintSession.LeftTunnels[0].height = 0xFF;
|
|
|
|
gPaintSession.LeftTunnels[0].type = 0xFF;
|
|
|
|
gPaintSession.RightTunnels[0].height = 0xFF;
|
|
|
|
gPaintSession.RightTunnels[0].type = 0xFF;
|
2016-10-16 16:06:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 22:29:03 +02:00
|
|
|
void ResetSupportHeights()
|
|
|
|
{
|
2016-10-16 15:49:04 +02:00
|
|
|
for (int s = 0; s < 9; ++s)
|
|
|
|
{
|
|
|
|
gSupportSegments[s].height = 0;
|
|
|
|
gSupportSegments[s].slope = 0xFF;
|
2017-09-02 18:33:12 +02:00
|
|
|
gPaintSession.SupportSegments[s].height = 0;
|
|
|
|
gPaintSession.SupportSegments[s].slope = 0xFF;
|
2016-10-16 15:49:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gSupport.height = 0;
|
|
|
|
gSupport.slope = 0xFF;
|
2017-09-02 18:33:12 +02:00
|
|
|
gPaintSession.Support.height = 0;
|
|
|
|
gPaintSession.Support.slope = 0xFF;
|
2016-10-16 15:49:04 +02:00
|
|
|
}
|
|
|
|
|
2016-09-18 17:46:26 +02:00
|
|
|
struct IgnoredEntry
|
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t Direction;
|
|
|
|
uint8_t TrackSequence;
|
2016-09-18 17:46:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static bool _ignoredAll;
|
|
|
|
static std::vector<IgnoredEntry> _ignoredEntries;
|
|
|
|
|
2018-02-01 12:28:50 +01:00
|
|
|
void testClearIgnore()
|
2016-09-18 17:46:26 +02:00
|
|
|
{
|
|
|
|
_ignoredAll = false;
|
|
|
|
_ignoredEntries.clear();
|
|
|
|
}
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
void testIgnore(uint8_t direction, uint8_t trackSequence)
|
2016-09-18 17:46:26 +02:00
|
|
|
{
|
|
|
|
_ignoredEntries.push_back({ direction, trackSequence });
|
|
|
|
}
|
|
|
|
|
2018-02-01 12:28:50 +01:00
|
|
|
void testIgnoreAll()
|
2016-09-18 17:46:26 +02:00
|
|
|
{
|
|
|
|
_ignoredAll = true;
|
|
|
|
}
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
bool testIsIgnored(uint8_t direction, uint8_t trackSequence)
|
2016-09-18 17:46:26 +02:00
|
|
|
{
|
2018-06-22 22:29:03 +02:00
|
|
|
if (_ignoredAll)
|
|
|
|
return true;
|
|
|
|
for (const IgnoredEntry& entry : _ignoredEntries)
|
2016-09-18 17:46:26 +02:00
|
|
|
{
|
2018-06-22 22:29:03 +02:00
|
|
|
if (entry.Direction == direction && entry.TrackSequence == trackSequence)
|
2016-09-18 17:46:26 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2018-06-22 22:29:03 +02:00
|
|
|
} // namespace TestPaint
|
2016-09-06 21:58:58 +02:00
|
|
|
|
2018-02-01 12:28:50 +01:00
|
|
|
void testpaint_clear_ignore()
|
2016-09-06 21:58:58 +02:00
|
|
|
{
|
2018-02-01 12:28:50 +01:00
|
|
|
TestPaint::testClearIgnore();
|
|
|
|
}
|
2016-09-18 17:46:26 +02:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
void testpaint_ignore(uint8_t direction, uint8_t trackSequence)
|
2018-02-01 12:28:50 +01:00
|
|
|
{
|
|
|
|
TestPaint::testIgnore(direction, trackSequence);
|
|
|
|
}
|
2016-09-18 17:46:26 +02:00
|
|
|
|
2018-02-01 12:28:50 +01:00
|
|
|
void testpaint_ignore_all()
|
|
|
|
{
|
|
|
|
TestPaint::testIgnoreAll();
|
|
|
|
}
|
2016-09-18 17:46:26 +02:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
bool testpaint_is_ignored(uint8_t direction, uint8_t trackSequence)
|
2018-02-01 12:28:50 +01:00
|
|
|
{
|
|
|
|
return TestPaint::testIsIgnored(direction, trackSequence);
|
2016-09-06 21:58:58 +02:00
|
|
|
}
|