improve command line version information and add headless check

This commit is contained in:
IntelOrca 2015-11-08 12:49:19 +00:00
parent 7d51eb55e1
commit e1b67eeda0
5 changed files with 65 additions and 24 deletions

View File

@ -53,6 +53,7 @@ int gNetworkStartPort = NETWORK_DEFAULT_PORT;
#endif // DISABLE_NETWORK
static void print_launch_information();
static void print_version();
static int cmdline_call_action(const char **argv, int argc);
static const char *const usage[] = {
@ -92,7 +93,7 @@ int cmdline_run(const char **argv, int argc)
argc = argparse_parse(&argparse, argc, argv);
if (version) {
print_launch_information();
print_version();
return 0;
}
@ -120,34 +121,55 @@ int cmdline_run(const char **argv, int argc)
if (argc != 0) {
gExitCode = cmdline_call_action(argv, argc);
if (gExitCode != 0)
if (gExitCode != 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;
}
static void print_launch_information()
{
char buffer[32];
char buffer[256];
time_t timer;
tm_t* tmInfo;
// Print version information
printf("Starting %s v%s\n", OPENRCT2_NAME, OPENRCT2_VERSION);
printf(" %s (%s)\n", OPENRCT2_PLATFORM, OPENRCT2_ARCHITECTURE);
printf(" %s\n\n", OPENRCT2_TIMESTAMP);
// Print name and version information
openrct2_write_full_version_info(buffer, sizeof(buffer));
printf("%s\n", buffer);
printf("%s (%s)\n", OPENRCT2_PLATFORM, OPENRCT2_ARCHITECTURE);
printf("@ %s\n\n", OPENRCT2_TIMESTAMP);
// Print current time
time(&timer);
tmInfo = localtime(&timer);
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)
}
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)
{
gOpenRCT2StartupAction = STARTUP_ACTION_INTRO;

View File

@ -1292,6 +1292,10 @@ void title_handle_keyboard_input()
rct_window *w;
int key;
if (gOpenRCT2Headless) {
return;
}
if (!gConsoleOpen) {
// Handle modifier keys and key scrolling
RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0;

View File

@ -76,6 +76,30 @@ static bool openrct2_setup_rct2_segment();
static bool openrct2_release_rct2_segment();
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)
{
utf8 *ch, filter[MAX_PATH], oldPath[MAX_PATH], newPath[MAX_PATH];

View File

@ -37,6 +37,7 @@ extern utf8 gCustomUserDataPath[MAX_PATH];
extern bool gOpenRCT2Headless;
extern bool gOpenRCT2ShowChangelog;
void openrct2_write_full_version_info(utf8 *buffer, size_t bufferSize);
bool openrct2_initialise();
void openrct2_launch();
void openrct2_dispose();

View File

@ -460,30 +460,20 @@ static void title_update_showcase()
void DrawOpenRCT2(int x, int y)
{
char buffer[256];
utf8 buffer[256];
rct_drawpixelinfo *dpi = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo);
// Draw background
gfx_fill_rect_inset(dpi, x, y, x + 128, y + 20, 0x80 | 12, 0x8);
// Format text (name and version)
char *ch = buffer;;
// Write format codes
utf8 *ch = buffer;
ch = utf8_write_codepoint(ch, FORMAT_MEDIUMFONT);
ch = utf8_write_codepoint(ch, FORMAT_OUTLINE);
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);
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);
// Write name and version information
openrct2_write_full_version_info(ch, sizeof(buffer) - (ch - buffer));
// Draw Text
gfx_draw_string(dpi, buffer, 0, x + 5, y + 5);