mirror of https://github.com/OpenRCT2/OpenRCT2.git
improve command line version information and add headless check
This commit is contained in:
parent
7d51eb55e1
commit
e1b67eeda0
|
@ -53,6 +53,7 @@ int gNetworkStartPort = NETWORK_DEFAULT_PORT;
|
||||||
#endif // DISABLE_NETWORK
|
#endif // DISABLE_NETWORK
|
||||||
|
|
||||||
static void print_launch_information();
|
static void print_launch_information();
|
||||||
|
static void print_version();
|
||||||
static int cmdline_call_action(const char **argv, int argc);
|
static int cmdline_call_action(const char **argv, int argc);
|
||||||
|
|
||||||
static const char *const usage[] = {
|
static const char *const usage[] = {
|
||||||
|
@ -92,7 +93,7 @@ int cmdline_run(const char **argv, int argc)
|
||||||
argc = argparse_parse(&argparse, argc, argv);
|
argc = argparse_parse(&argparse, argc, argv);
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
print_launch_information();
|
print_version();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,34 +121,55 @@ int cmdline_run(const char **argv, int argc)
|
||||||
|
|
||||||
if (argc != 0) {
|
if (argc != 0) {
|
||||||
gExitCode = cmdline_call_action(argv, argc);
|
gExitCode = cmdline_call_action(argv, argc);
|
||||||
if (gExitCode != 0)
|
if (gExitCode != 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print_launch_information();
|
// Headless mode requires a park to open
|
||||||
|
if (gOpenRCT2Headless) {
|
||||||
|
if (str_is_null_or_empty(gOpenRCT2StartupActionPath)) {
|
||||||
|
printf("You must specify a park to open in headless mode.\n");
|
||||||
|
gExitCode = -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
print_launch_information();
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_launch_information()
|
static void print_launch_information()
|
||||||
{
|
{
|
||||||
char buffer[32];
|
char buffer[256];
|
||||||
time_t timer;
|
time_t timer;
|
||||||
tm_t* tmInfo;
|
tm_t* tmInfo;
|
||||||
|
|
||||||
// Print version information
|
// Print name and version information
|
||||||
printf("Starting %s v%s\n", OPENRCT2_NAME, OPENRCT2_VERSION);
|
openrct2_write_full_version_info(buffer, sizeof(buffer));
|
||||||
printf(" %s (%s)\n", OPENRCT2_PLATFORM, OPENRCT2_ARCHITECTURE);
|
printf("%s\n", buffer);
|
||||||
printf(" %s\n\n", OPENRCT2_TIMESTAMP);
|
printf("%s (%s)\n", OPENRCT2_PLATFORM, OPENRCT2_ARCHITECTURE);
|
||||||
|
printf("@ %s\n\n", OPENRCT2_TIMESTAMP);
|
||||||
|
|
||||||
// Print current time
|
// Print current time
|
||||||
time(&timer);
|
time(&timer);
|
||||||
tmInfo = localtime(&timer);
|
tmInfo = localtime(&timer);
|
||||||
strftime(buffer, sizeof(buffer), "%Y/%m/%d %H:%M:%S", tmInfo);
|
strftime(buffer, sizeof(buffer), "%Y/%m/%d %H:%M:%S", tmInfo);
|
||||||
printf("Time: %s\n", buffer);
|
printf("VERBOSE: time is %s\n", buffer);
|
||||||
|
|
||||||
// TODO Print other potential information (e.g. user, hardware)
|
// TODO Print other potential information (e.g. user, hardware)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_version()
|
||||||
|
{
|
||||||
|
char buffer[256];
|
||||||
|
openrct2_write_full_version_info(buffer, sizeof(buffer));
|
||||||
|
printf("%s\n", buffer);
|
||||||
|
printf("%s (%s)\n", OPENRCT2_PLATFORM, OPENRCT2_ARCHITECTURE);
|
||||||
|
}
|
||||||
|
|
||||||
static int cmdline_for_intro(const char **argv, int argc)
|
static int cmdline_for_intro(const char **argv, int argc)
|
||||||
{
|
{
|
||||||
gOpenRCT2StartupAction = STARTUP_ACTION_INTRO;
|
gOpenRCT2StartupAction = STARTUP_ACTION_INTRO;
|
||||||
|
|
|
@ -1292,6 +1292,10 @@ void title_handle_keyboard_input()
|
||||||
rct_window *w;
|
rct_window *w;
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
|
if (gOpenRCT2Headless) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!gConsoleOpen) {
|
if (!gConsoleOpen) {
|
||||||
// Handle modifier keys and key scrolling
|
// Handle modifier keys and key scrolling
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0;
|
RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0;
|
||||||
|
|
|
@ -76,6 +76,30 @@ static bool openrct2_setup_rct2_segment();
|
||||||
static bool openrct2_release_rct2_segment();
|
static bool openrct2_release_rct2_segment();
|
||||||
static void openrct2_setup_rct2_hooks();
|
static void openrct2_setup_rct2_hooks();
|
||||||
|
|
||||||
|
void openrct2_write_full_version_info(utf8 *buffer, size_t bufferSize)
|
||||||
|
{
|
||||||
|
utf8 *ch = buffer;
|
||||||
|
|
||||||
|
// Name and version
|
||||||
|
strcpy(ch, OPENRCT2_NAME);
|
||||||
|
strcat(buffer, ", v");
|
||||||
|
strcat(buffer, OPENRCT2_VERSION);
|
||||||
|
|
||||||
|
// Build information
|
||||||
|
if (!str_is_null_or_empty(OPENRCT2_BRANCH)) {
|
||||||
|
sprintf(strchr(buffer, 0), "-%s", OPENRCT2_BRANCH);
|
||||||
|
}
|
||||||
|
if (!str_is_null_or_empty(OPENRCT2_BUILD_NUMBER)) {
|
||||||
|
sprintf(strchr(buffer, 0), " build %s", OPENRCT2_BUILD_NUMBER);
|
||||||
|
}
|
||||||
|
if (!str_is_null_or_empty(OPENRCT2_COMMIT_SHA1_SHORT)) {
|
||||||
|
sprintf(strchr(buffer, 0), " (%s)", OPENRCT2_COMMIT_SHA1_SHORT);
|
||||||
|
}
|
||||||
|
if (!str_is_null_or_empty(OPENRCT2_BUILD_SERVER)) {
|
||||||
|
sprintf(strchr(buffer, 0), " provided by %s", OPENRCT2_BUILD_SERVER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void openrct2_copy_files_over(const utf8 *originalDirectory, const utf8 *newDirectory, const utf8 *extension)
|
static void openrct2_copy_files_over(const utf8 *originalDirectory, const utf8 *newDirectory, const utf8 *extension)
|
||||||
{
|
{
|
||||||
utf8 *ch, filter[MAX_PATH], oldPath[MAX_PATH], newPath[MAX_PATH];
|
utf8 *ch, filter[MAX_PATH], oldPath[MAX_PATH], newPath[MAX_PATH];
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern utf8 gCustomUserDataPath[MAX_PATH];
|
||||||
extern bool gOpenRCT2Headless;
|
extern bool gOpenRCT2Headless;
|
||||||
extern bool gOpenRCT2ShowChangelog;
|
extern bool gOpenRCT2ShowChangelog;
|
||||||
|
|
||||||
|
void openrct2_write_full_version_info(utf8 *buffer, size_t bufferSize);
|
||||||
bool openrct2_initialise();
|
bool openrct2_initialise();
|
||||||
void openrct2_launch();
|
void openrct2_launch();
|
||||||
void openrct2_dispose();
|
void openrct2_dispose();
|
||||||
|
|
20
src/title.c
20
src/title.c
|
@ -460,30 +460,20 @@ static void title_update_showcase()
|
||||||
|
|
||||||
void DrawOpenRCT2(int x, int y)
|
void DrawOpenRCT2(int x, int y)
|
||||||
{
|
{
|
||||||
char buffer[256];
|
utf8 buffer[256];
|
||||||
rct_drawpixelinfo *dpi = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo);
|
rct_drawpixelinfo *dpi = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo);
|
||||||
|
|
||||||
// Draw background
|
// Draw background
|
||||||
gfx_fill_rect_inset(dpi, x, y, x + 128, y + 20, 0x80 | 12, 0x8);
|
gfx_fill_rect_inset(dpi, x, y, x + 128, y + 20, 0x80 | 12, 0x8);
|
||||||
|
|
||||||
// Format text (name and version)
|
// Write format codes
|
||||||
char *ch = buffer;;
|
utf8 *ch = buffer;
|
||||||
ch = utf8_write_codepoint(ch, FORMAT_MEDIUMFONT);
|
ch = utf8_write_codepoint(ch, FORMAT_MEDIUMFONT);
|
||||||
ch = utf8_write_codepoint(ch, FORMAT_OUTLINE);
|
ch = utf8_write_codepoint(ch, FORMAT_OUTLINE);
|
||||||
ch = utf8_write_codepoint(ch, FORMAT_WHITE);
|
ch = utf8_write_codepoint(ch, FORMAT_WHITE);
|
||||||
strcpy(ch, OPENRCT2_NAME);
|
|
||||||
strcat(buffer, ", v");
|
|
||||||
strcat(buffer, OPENRCT2_VERSION);
|
|
||||||
|
|
||||||
// sprintf(buffer, "%c%c%c%s, v%s", FORMAT_MEDIUMFONT, FORMAT_OUTLINE, FORMAT_WHITE, OPENRCT2_NAME, OPENRCT2_VERSION);
|
// Write name and version information
|
||||||
if (!str_is_null_or_empty(OPENRCT2_BRANCH))
|
openrct2_write_full_version_info(ch, sizeof(buffer) - (ch - buffer));
|
||||||
sprintf(strchr(buffer, 0), "-%s", OPENRCT2_BRANCH);
|
|
||||||
if (!str_is_null_or_empty(OPENRCT2_BUILD_NUMBER))
|
|
||||||
sprintf(strchr(buffer, 0), " build %s", OPENRCT2_BUILD_NUMBER);
|
|
||||||
if (!str_is_null_or_empty(OPENRCT2_COMMIT_SHA1_SHORT))
|
|
||||||
sprintf(strchr(buffer, 0), " (%s)", OPENRCT2_COMMIT_SHA1_SHORT);
|
|
||||||
if (!str_is_null_or_empty(OPENRCT2_BUILD_SERVER))
|
|
||||||
sprintf(strchr(buffer, 0), " provided by %s", OPENRCT2_BUILD_SERVER);
|
|
||||||
|
|
||||||
// Draw Text
|
// Draw Text
|
||||||
gfx_draw_string(dpi, buffer, 0, x + 5, y + 5);
|
gfx_draw_string(dpi, buffer, 0, x + 5, y + 5);
|
||||||
|
|
Loading…
Reference in New Issue