1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 19:13:07 +01:00

Refactor screenshot options

This commit is contained in:
Hielke Morsink
2017-12-06 15:45:24 +01:00
committed by Richard Jenkins
parent 68fac3b30a
commit 9b874f8abe
3 changed files with 16 additions and 19 deletions

View File

@@ -17,16 +17,11 @@
#include "../interface/Screenshot.h"
#include "CommandLine.hpp"
extern "C"
{
sint32 gScreenshotWeather = 0;
}
static ScreenshotOptions options;
static uint32 _weather = 0;
static const CommandLineOptionDefinition ScreenshotOptions[]
static const CommandLineOptionDefinition ScreenshotOptionsDef[]
{
{ CMDLINE_TYPE_INTEGER, &_weather, NAC, "weather", "weather to be used (0 = default, 1 = sunny, ..., 6 = thunder)." },
{ CMDLINE_TYPE_INTEGER, &options.weather, NAC, "weather", "weather to be used (0 = default, 1 = sunny, ..., 6 = thunder)." },
OptionTableEnd
};
@@ -35,18 +30,16 @@ static exitcode_t HandleScreenshot(CommandLineArgEnumerator *argEnumerator);
const CommandLineCommand CommandLine::ScreenshotCommands[]
{
// Main commands
DefineCommand("", "<file> <output_image> <width> <height> [<x> <y> <zoom> <rotation>]", ScreenshotOptions, HandleScreenshot),
DefineCommand("", "<file> <output_image> giant <zoom> <rotation>", ScreenshotOptions, HandleScreenshot),
DefineCommand("", "<file> <output_image> <width> <height> [<x> <y> <zoom> <rotation>]", ScreenshotOptionsDef, HandleScreenshot),
DefineCommand("", "<file> <output_image> giant <zoom> <rotation>", ScreenshotOptionsDef, HandleScreenshot),
CommandTableEnd
};
static exitcode_t HandleScreenshot(CommandLineArgEnumerator *argEnumerator)
{
gScreenshotWeather = _weather;
const char * * argv = (const char * *)argEnumerator->GetArguments() + argEnumerator->GetIndex();
sint32 argc = argEnumerator->GetCount() - argEnumerator->GetIndex();
sint32 result = cmdline_for_screenshot(argv, argc);
sint32 result = cmdline_for_screenshot(argv, argc, &options);
if (result < 0) {
return EXITCODE_FAIL;
}

View File

@@ -355,7 +355,7 @@ sint32 cmdline_for_gfxbench(const char **argv, sint32 argc)
return 1;
}
sint32 cmdline_for_screenshot(const char **argv, sint32 argc)
sint32 cmdline_for_screenshot(const char * * argv, sint32 argc, ScreenshotOptions * options)
{
// Don't include options in the count (they have been handled by CommandLine::ParseOptions already)
for (sint32 i = 0; i < argc; i++)
@@ -496,9 +496,9 @@ sint32 cmdline_for_screenshot(const char **argv, sint32 argc)
gCurrentRotation = gSavedViewRotation;
}
if (gScreenshotWeather != 0)
if (options->weather != 0)
{
if (gScreenshotWeather < 1 || gScreenshotWeather > 6)
if (options->weather < 1 || options->weather > 6)
{
std::printf("Weather can only be set to an integer value from 1 till 6.");
drawing_engine_dispose();
@@ -506,7 +506,7 @@ sint32 cmdline_for_screenshot(const char **argv, sint32 argc)
return -1;
}
uint8 customWeather = gScreenshotWeather - 1;
uint8 customWeather = options->weather - 1;
climate_force_weather(customWeather);
}

View File

@@ -25,7 +25,11 @@ extern "C"
{
#endif
extern uint8 gScreenshotCountdown;
extern sint32 gScreenshotWeather;
struct ScreenshotOptions
{
sint32 weather = 0;
};
void screenshot_check();
sint32 screenshot_dump();
@@ -33,7 +37,7 @@ extern "C"
sint32 screenshot_dump_png_32bpp(sint32 width, sint32 height, const void *pixels);
void screenshot_giant();
sint32 cmdline_for_screenshot(const char **argv, sint32 argc);
sint32 cmdline_for_screenshot(const char * * argv, sint32 argc, ScreenshotOptions * options);
sint32 cmdline_for_gfxbench(const char **argv, sint32 argc);
#ifdef __cplusplus
}