mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 10:31:16 +00:00
Add CLI help message, accessible with --help (#614)
* Add CLI --help argument * Make clang-format happy * Move to switch instead of creating temp var * Remove unnecesary break Co-authored-by: Christian Semmler <mail@csemmler.com> * Remove unnecesary break 2 Co-authored-by: Christian Semmler <mail@csemmler.com> * Make clang-format happy again --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
parent
ad2832b096
commit
b6a4f65db4
@ -315,7 +315,8 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
|
||||
// Create global app instance
|
||||
g_isle = new IsleApp();
|
||||
|
||||
if (g_isle->ParseArguments(argc, argv) != SUCCESS) {
|
||||
switch (g_isle->ParseArguments(argc, argv)) {
|
||||
case SDL_APP_FAILURE:
|
||||
Any_ShowSimpleMessageBox(
|
||||
SDL_MESSAGEBOX_ERROR,
|
||||
"LEGO® Island Error",
|
||||
@ -323,6 +324,10 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
|
||||
window
|
||||
);
|
||||
return SDL_APP_FAILURE;
|
||||
case SDL_APP_SUCCESS:
|
||||
return SDL_APP_SUCCESS;
|
||||
case SDL_APP_CONTINUE:
|
||||
break;
|
||||
}
|
||||
|
||||
// Create window
|
||||
@ -1301,7 +1306,7 @@ void IsleApp::SetupCursor(Cursor p_cursor)
|
||||
}
|
||||
}
|
||||
|
||||
MxResult IsleApp::ParseArguments(int argc, char** argv)
|
||||
SDL_AppResult IsleApp::ParseArguments(int argc, char** argv)
|
||||
{
|
||||
for (int i = 1, consumed; i < argc; i += consumed) {
|
||||
consumed = -1;
|
||||
@ -1318,13 +1323,29 @@ MxResult IsleApp::ParseArguments(int argc, char** argv)
|
||||
#endif
|
||||
consumed = 1;
|
||||
}
|
||||
else if (strcmp(argv[i], "--help") == 0) {
|
||||
DisplayArgumentHelp();
|
||||
return SDL_APP_SUCCESS;
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
SDL_Log("Invalid argument(s): %s", argv[i]);
|
||||
return FAILURE;
|
||||
DisplayArgumentHelp();
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
void IsleApp::DisplayArgumentHelp()
|
||||
{
|
||||
SDL_Log("Usage: isle [options]");
|
||||
SDL_Log("Options:");
|
||||
SDL_Log(" --ini <path> Set custom path to .ini config");
|
||||
#ifdef ISLE_DEBUG
|
||||
SDL_Log(" --debug Launch in debug mode");
|
||||
#endif
|
||||
SDL_Log(" --help Show this help message");
|
||||
}
|
||||
|
||||
MxResult IsleApp::VerifyFilesystem()
|
||||
|
||||
@ -61,7 +61,7 @@ class IsleApp {
|
||||
void SetGameStarted(MxS32 p_gameStarted) { m_gameStarted = p_gameStarted; }
|
||||
void SetDrawCursor(MxS32 p_drawCursor) { m_drawCursor = p_drawCursor; }
|
||||
|
||||
MxResult ParseArguments(int argc, char** argv);
|
||||
SDL_AppResult ParseArguments(int argc, char** argv);
|
||||
MxResult VerifyFilesystem();
|
||||
void DetectGameVersion();
|
||||
void MoveVirtualMouseViaJoystick();
|
||||
@ -99,6 +99,7 @@ class IsleApp {
|
||||
const CursorBitmap* m_cursorCurrentBitmap;
|
||||
char* m_mediaPath;
|
||||
MxFloat m_cursorSensitivity;
|
||||
void DisplayArgumentHelp();
|
||||
|
||||
char* m_iniPath;
|
||||
MxFloat m_maxLod;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user