Handle args on Windows in NativeInit() too.

Now it's like everyone else, plus it works again.  Bonus.

Fixes #1134.
This commit is contained in:
Unknown W. Brackets 2013-03-31 18:22:27 -07:00
parent 8cecdbe1dc
commit d8cb2cdffb
3 changed files with 4 additions and 49 deletions

View File

@ -201,6 +201,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co
config_filename = user_data_path + "/ppsspp.ini";
g_Config.Load(config_filename.c_str());
#endif
const char *fileToLog = 0;
const char *stateToLoad = 0;
@ -252,6 +253,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co
if (fileToLog != NULL)
LogManager::GetInstance()->ChangeFileLog(fileToLog);
#ifndef _WIN32
if (g_Config.currentDirectory == "") {
#if defined(ANDROID)
g_Config.currentDirectory = external_directory;
@ -261,7 +263,6 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co
g_Config.currentDirectory = getenv("HOME");
#endif
}
#endif
#if defined(ANDROID)
// Maybe there should be an option to use internal memory instead, but I think
@ -283,7 +284,6 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co
g_Config.flashDirectory = g_Config.memCardDirectory+"/flash/";
#endif
#ifndef _WIN32
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i;

View File

@ -55,7 +55,7 @@ DWORD TheThread(LPVOID x) {
Host *oldHost = host;
UpdateScreenScale();
NativeInit(0, 0, memstick.c_str(), memstick.c_str(), "1234");
NativeInit(__argc, (const char **)__argv, memstick.c_str(), memstick.c_str(), "1234");
Host *nativeHost = host;
host = oldHost;

View File

@ -58,9 +58,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
{
Common::EnableCrashingOnCrashes();
const char *fileToStart = NULL;
const char *fileToLog = NULL;
const char *stateToLoad = NULL;
bool hideLog = true;
#ifdef _DEBUG
@ -71,6 +68,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
VFSRegister("", new DirectoryAssetReader("assets/"));
VFSRegister("", new DirectoryAssetReader(""));
// The rest is handled in NativeInit().
for (int i = 1; i < __argc; ++i)
{
if (__argv[i][0] == '\0')
@ -80,14 +78,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
{
switch (__argv[i][1])
{
case 'j':
g_Config.bJit = true;
g_Config.bSaveSettings = false;
break;
case 'i':
g_Config.bJit = false;
g_Config.bSaveSettings = false;
break;
case 'l':
hideLog = false;
break;
@ -95,32 +85,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
g_Config.bAutoRun = false;
g_Config.bSaveSettings = false;
break;
case '-':
if (!strcmp(__argv[i], "--log") && i < __argc - 1)
fileToLog = __argv[++i];
if (!strncmp(__argv[i], "--log=", strlen("--log=")) && strlen(__argv[i]) > strlen("--log="))
fileToLog = __argv[i] + strlen("--log=");
if (!strcmp(__argv[i], "--state") && i < __argc - 1)
stateToLoad = __argv[++i];
if (!strncmp(__argv[i], "--state=", strlen("--state=")) && strlen(__argv[i]) > strlen("--state="))
stateToLoad = __argv[i] + strlen("--state=");
break;
}
}
else if (fileToStart == NULL)
{
fileToStart = __argv[i];
if (!File::Exists(fileToStart))
{
fprintf(stderr, "File not found: %s\n", fileToStart);
exit(1);
}
}
else
{
fprintf(stderr, "Can only boot one file");
exit(1);
}
}
//Windows, API init stuff
@ -152,16 +118,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
MainWindow::UpdateMenus();
LogManager::Init();
if (fileToLog != NULL)
LogManager::GetInstance()->ChangeFileLog(fileToLog);
LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console");
LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR);
if (fileToStart != NULL)
{
MainWindow::SetPlaying(fileToStart);
MainWindow::Update();
MainWindow::UpdateMenus();
}
// Emu thread is always running!
EmuThread_Start();
@ -172,9 +130,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
if (!hideLog)
SetForegroundWindow(hwndMain);
if (fileToStart != NULL && stateToLoad != NULL)
SaveState::Load(stateToLoad);
//so.. we're at the message pump of the GUI thread
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) //while no quit