mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-02 12:01:15 +00:00
Add CLI --help argument
This commit is contained in:
parent
deca5e5a2e
commit
60e6a55b61
@ -315,7 +315,8 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
|
|||||||
// Create global app instance
|
// Create global app instance
|
||||||
g_isle = new IsleApp();
|
g_isle = new IsleApp();
|
||||||
|
|
||||||
if (g_isle->ParseArguments(argc, argv) != SUCCESS) {
|
SDL_AppResult argParseSuccess = g_isle->ParseArguments(argc, argv);
|
||||||
|
if (argParseSuccess == SDL_APP_FAILURE) {
|
||||||
Any_ShowSimpleMessageBox(
|
Any_ShowSimpleMessageBox(
|
||||||
SDL_MESSAGEBOX_ERROR,
|
SDL_MESSAGEBOX_ERROR,
|
||||||
"LEGO® Island Error",
|
"LEGO® Island Error",
|
||||||
@ -324,6 +325,9 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
|
|||||||
);
|
);
|
||||||
return SDL_APP_FAILURE;
|
return SDL_APP_FAILURE;
|
||||||
}
|
}
|
||||||
|
else if (argParseSuccess == SDL_APP_SUCCESS) {
|
||||||
|
return SDL_APP_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
// Create window
|
// Create window
|
||||||
if (g_isle->SetupWindow() != SUCCESS) {
|
if (g_isle->SetupWindow() != SUCCESS) {
|
||||||
@ -1301,7 +1305,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) {
|
for (int i = 1, consumed; i < argc; i += consumed) {
|
||||||
consumed = -1;
|
consumed = -1;
|
||||||
@ -1318,13 +1322,28 @@ MxResult IsleApp::ParseArguments(int argc, char** argv)
|
|||||||
#endif
|
#endif
|
||||||
consumed = 1;
|
consumed = 1;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(argv[i], "--help") == 0) {
|
||||||
|
DisplayArgumentHelp();
|
||||||
|
return SDL_APP_SUCCESS;
|
||||||
|
}
|
||||||
if (consumed <= 0) {
|
if (consumed <= 0) {
|
||||||
SDL_Log("Invalid argument(s): %s", argv[i]);
|
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()
|
MxResult IsleApp::VerifyFilesystem()
|
||||||
|
|||||||
@ -61,7 +61,7 @@ class IsleApp {
|
|||||||
void SetGameStarted(MxS32 p_gameStarted) { m_gameStarted = p_gameStarted; }
|
void SetGameStarted(MxS32 p_gameStarted) { m_gameStarted = p_gameStarted; }
|
||||||
void SetDrawCursor(MxS32 p_drawCursor) { m_drawCursor = p_drawCursor; }
|
void SetDrawCursor(MxS32 p_drawCursor) { m_drawCursor = p_drawCursor; }
|
||||||
|
|
||||||
MxResult ParseArguments(int argc, char** argv);
|
SDL_AppResult ParseArguments(int argc, char** argv);
|
||||||
MxResult VerifyFilesystem();
|
MxResult VerifyFilesystem();
|
||||||
void DetectGameVersion();
|
void DetectGameVersion();
|
||||||
void MoveVirtualMouseViaJoystick();
|
void MoveVirtualMouseViaJoystick();
|
||||||
@ -99,6 +99,7 @@ class IsleApp {
|
|||||||
const CursorBitmap* m_cursorCurrentBitmap;
|
const CursorBitmap* m_cursorCurrentBitmap;
|
||||||
char* m_mediaPath;
|
char* m_mediaPath;
|
||||||
MxFloat m_cursorSensitivity;
|
MxFloat m_cursorSensitivity;
|
||||||
|
void DisplayArgumentHelp();
|
||||||
|
|
||||||
char* m_iniPath;
|
char* m_iniPath;
|
||||||
MxFloat m_maxLod;
|
MxFloat m_maxLod;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user