mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #6715 from Broxzier/screenshot_climate
Add optional screenshot argument to set weather
This commit is contained in:
commit
84305af7ab
|
@ -17,18 +17,33 @@
|
||||||
#include "../interface/Screenshot.h"
|
#include "../interface/Screenshot.h"
|
||||||
#include "CommandLine.hpp"
|
#include "CommandLine.hpp"
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
sint32 gScreenshotWeather = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32 _weather = 0;
|
||||||
|
|
||||||
|
static const CommandLineOptionDefinition ScreenshotOptions[]
|
||||||
|
{
|
||||||
|
{ CMDLINE_TYPE_INTEGER, &_weather, NAC, "weather", "weather to be used (0 = default, 1 = sunny, ..., 6 = thunder)." },
|
||||||
|
OptionTableEnd
|
||||||
|
};
|
||||||
|
|
||||||
static exitcode_t HandleScreenshot(CommandLineArgEnumerator *argEnumerator);
|
static exitcode_t HandleScreenshot(CommandLineArgEnumerator *argEnumerator);
|
||||||
|
|
||||||
const CommandLineCommand CommandLine::ScreenshotCommands[]
|
const CommandLineCommand CommandLine::ScreenshotCommands[]
|
||||||
{
|
{
|
||||||
// Main commands
|
// Main commands
|
||||||
DefineCommand("", "<file> <output_image> <width> <height> [<x> <y> <zoom> <rotation>]", nullptr, HandleScreenshot),
|
DefineCommand("", "<file> <output_image> <width> <height> [<x> <y> <zoom> <rotation>]", ScreenshotOptions, HandleScreenshot),
|
||||||
DefineCommand("", "<file> <output_image> giant <zoom> <rotation>", nullptr, HandleScreenshot),
|
DefineCommand("", "<file> <output_image> giant <zoom> <rotation>", ScreenshotOptions, HandleScreenshot),
|
||||||
CommandTableEnd
|
CommandTableEnd
|
||||||
};
|
};
|
||||||
|
|
||||||
static exitcode_t HandleScreenshot(CommandLineArgEnumerator *argEnumerator)
|
static exitcode_t HandleScreenshot(CommandLineArgEnumerator *argEnumerator)
|
||||||
{
|
{
|
||||||
|
gScreenshotWeather = _weather;
|
||||||
|
|
||||||
const char * * argv = (const char * *)argEnumerator->GetArguments() + argEnumerator->GetIndex();
|
const char * * argv = (const char * *)argEnumerator->GetArguments() + argEnumerator->GetIndex();
|
||||||
sint32 argc = argEnumerator->GetCount() - argEnumerator->GetIndex();
|
sint32 argc = argEnumerator->GetCount() - argEnumerator->GetIndex();
|
||||||
sint32 result = cmdline_for_screenshot(argv, argc);
|
sint32 result = cmdline_for_screenshot(argv, argc);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cstdlib>
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../Context.h"
|
#include "../Context.h"
|
||||||
#include "../core/Console.hpp"
|
#include "../core/Console.hpp"
|
||||||
|
@ -28,6 +29,7 @@
|
||||||
#include "../localisation/localisation.h"
|
#include "../localisation/localisation.h"
|
||||||
#include "../platform/platform.h"
|
#include "../platform/platform.h"
|
||||||
#include "../util/util.h"
|
#include "../util/util.h"
|
||||||
|
#include "../world/Climate.h"
|
||||||
#include "viewport.h"
|
#include "viewport.h"
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
|
@ -347,10 +349,21 @@ sint32 cmdline_for_gfxbench(const char **argv, sint32 argc)
|
||||||
|
|
||||||
sint32 cmdline_for_screenshot(const char **argv, sint32 argc)
|
sint32 cmdline_for_screenshot(const char **argv, sint32 argc)
|
||||||
{
|
{
|
||||||
bool giantScreenshot = argc == 5 && _stricmp(argv[2], "giant") == 0;
|
// Don't include options in the count (they have been handled by CommandLine::ParseOptions already)
|
||||||
|
for (sint32 i = 0; i < argc; i++)
|
||||||
|
{
|
||||||
|
if (argv[i][0] == '-')
|
||||||
|
{
|
||||||
|
// Setting argc to i works, because options can only be at the end of the command
|
||||||
|
argc = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool giantScreenshot = (argc == 5) && _stricmp(argv[2], "giant") == 0;
|
||||||
if (argc != 4 && argc != 8 && !giantScreenshot) {
|
if (argc != 4 && argc != 8 && !giantScreenshot) {
|
||||||
printf("Usage: openrct2 screenshot <file> <ouput_image> <width> <height> [<x> <y> <zoom> <rotation>]\n");
|
std::printf("Usage: openrct2 screenshot <file> <ouput_image> <width> <height> [<x> <y> <zoom> <rotation>]\n");
|
||||||
printf("Usage: openrct2 screenshot <file> <ouput_image> giant <zoom> <rotation>\n");
|
std::printf("Usage: openrct2 screenshot <file> <ouput_image> giant <zoom> <rotation>\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,31 +374,38 @@ sint32 cmdline_for_screenshot(const char **argv, sint32 argc)
|
||||||
|
|
||||||
const char *inputPath = argv[0];
|
const char *inputPath = argv[0];
|
||||||
const char *outputPath = argv[1];
|
const char *outputPath = argv[1];
|
||||||
if (giantScreenshot) {
|
if (giantScreenshot)
|
||||||
|
{
|
||||||
resolutionWidth = 0;
|
resolutionWidth = 0;
|
||||||
resolutionHeight = 0;
|
resolutionHeight = 0;
|
||||||
customLocation = true;
|
customLocation = true;
|
||||||
centreMapX = true;
|
centreMapX = true;
|
||||||
centreMapY = true;
|
centreMapY = true;
|
||||||
customZoom = atoi(argv[3]);
|
customZoom = std::atoi(argv[3]);
|
||||||
customRotation = atoi(argv[4]) & 3;
|
customRotation = std::atoi(argv[4]) & 3;
|
||||||
} else {
|
}
|
||||||
resolutionWidth = atoi(argv[2]);
|
else
|
||||||
resolutionHeight = atoi(argv[3]);
|
{
|
||||||
if (argc == 8) {
|
resolutionWidth = std::atoi(argv[2]);
|
||||||
|
resolutionHeight = std::atoi(argv[3]);
|
||||||
|
if (argc == 8)
|
||||||
|
{
|
||||||
customLocation = true;
|
customLocation = true;
|
||||||
if (argv[4][0] == 'c')
|
if (argv[4][0] == 'c')
|
||||||
centreMapX = true;
|
centreMapX = true;
|
||||||
else
|
else
|
||||||
customX = atoi(argv[4]);
|
customX = std::atoi(argv[4]);
|
||||||
|
|
||||||
if (argv[5][0] == 'c')
|
if (argv[5][0] == 'c')
|
||||||
centreMapY = true;
|
centreMapY = true;
|
||||||
else
|
else
|
||||||
customY = atoi(argv[5]);
|
customY = std::atoi(argv[5]);
|
||||||
|
|
||||||
customZoom = atoi(argv[6]);
|
customZoom = std::atoi(argv[6]);
|
||||||
customRotation = atoi(argv[7]) & 3;
|
customRotation = std::atoi(argv[7]) & 3;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
customZoom = 0;
|
customZoom = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -395,7 +415,18 @@ sint32 cmdline_for_screenshot(const char **argv, sint32 argc)
|
||||||
if (context->Initialise())
|
if (context->Initialise())
|
||||||
{
|
{
|
||||||
drawing_engine_init();
|
drawing_engine_init();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
context->LoadParkFromFile(inputPath);
|
context->LoadParkFromFile(inputPath);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
std::printf("%s\n", e.what());
|
||||||
|
drawing_engine_dispose();
|
||||||
|
delete context;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
gIntroState = INTRO_STATE_NONE;
|
gIntroState = INTRO_STATE_NONE;
|
||||||
gScreenFlags = SCREEN_FLAGS_PLAYING;
|
gScreenFlags = SCREEN_FLAGS_PLAYING;
|
||||||
|
@ -457,6 +488,20 @@ sint32 cmdline_for_screenshot(const char **argv, sint32 argc)
|
||||||
gCurrentRotation = gSavedViewRotation;
|
gCurrentRotation = gSavedViewRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gScreenshotWeather != 0)
|
||||||
|
{
|
||||||
|
if (gScreenshotWeather < 1 || gScreenshotWeather > 6)
|
||||||
|
{
|
||||||
|
std::printf("Weather can only be set to an integer value from 1 till 6.");
|
||||||
|
drawing_engine_dispose();
|
||||||
|
delete context;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 customWeather = gScreenshotWeather - 1;
|
||||||
|
climate_force_weather(customWeather);
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure sprites appear regardless of rotation
|
// Ensure sprites appear regardless of rotation
|
||||||
reset_all_sprite_quadrant_placements();
|
reset_all_sprite_quadrant_placements();
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
extern uint8 gScreenshotCountdown;
|
extern uint8 gScreenshotCountdown;
|
||||||
|
extern sint32 gScreenshotWeather;
|
||||||
|
|
||||||
void screenshot_check();
|
void screenshot_check();
|
||||||
sint32 screenshot_dump();
|
sint32 screenshot_dump();
|
||||||
|
|
Loading…
Reference in New Issue