2010-05-22 04:47:15 +00:00
|
|
|
#include "stdafx.h"
|
2015-12-06 09:59:58 +00:00
|
|
|
#include <Project64-core/AppInit.h>
|
2015-10-25 19:20:23 +00:00
|
|
|
#include "Multilanguage\LanguageSelector.h"
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-09-07 19:47:58 +00:00
|
|
|
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/)
|
2010-05-14 23:28:15 +00:00
|
|
|
{
|
2015-10-25 11:10:54 +00:00
|
|
|
try
|
|
|
|
{
|
2015-11-14 20:56:40 +00:00
|
|
|
CoInitialize(NULL);
|
2016-01-13 07:23:22 +00:00
|
|
|
AppInit(&Notify(), __argc, __argv);
|
2015-11-14 20:56:40 +00:00
|
|
|
if (!g_Lang->IsLanguageLoaded())
|
2015-11-13 21:18:36 +00:00
|
|
|
{
|
|
|
|
CLanguageSelector().Select();
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-10-25 11:10:54 +00:00
|
|
|
//Create the main window with Menu
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Create Main Window");
|
2015-11-14 20:56:40 +00:00
|
|
|
CMainGui MainWindow(true, stdstr_f("Project64 %s", VER_FILE_VERSION_STR).c_str()), HiddenWindow(false);
|
2015-10-25 11:10:54 +00:00
|
|
|
CMainMenu MainMenu(&MainWindow);
|
2015-11-13 21:18:36 +00:00
|
|
|
g_Plugins->SetRenderWindows(&MainWindow, &HiddenWindow);
|
|
|
|
Notify().SetMainWindow(&MainWindow);
|
2015-10-25 11:10:54 +00:00
|
|
|
|
2016-01-13 07:23:22 +00:00
|
|
|
if (g_Settings->LoadStringVal(Cmd_RomFile).length() > 0)
|
2015-10-25 11:10:54 +00:00
|
|
|
{
|
|
|
|
MainWindow.Show(true); //Show the main window
|
2016-01-13 07:23:22 +00:00
|
|
|
CN64System::RunFileImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str());
|
2015-10-25 11:10:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (g_Settings->LoadDword(RomBrowser_Enabled))
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Show Rom Browser");
|
2015-10-25 11:10:54 +00:00
|
|
|
//Display the rom browser
|
|
|
|
MainWindow.ShowRomList();
|
|
|
|
MainWindow.Show(true); //Show the main window
|
|
|
|
MainWindow.HighLightLastRom();
|
2015-11-13 21:18:36 +00:00
|
|
|
}
|
2015-12-14 10:51:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Show Main Window");
|
2015-10-25 11:10:54 +00:00
|
|
|
MainWindow.Show(true); //Show the main window
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Process Messages till program is closed
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Entering Message Loop");
|
2015-10-25 11:10:54 +00:00
|
|
|
MainWindow.ProcessAllMessages();
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Message Loop Finished");
|
2015-10-25 11:10:54 +00:00
|
|
|
|
|
|
|
if (g_BaseSystem)
|
|
|
|
{
|
|
|
|
g_BaseSystem->CloseCpu();
|
|
|
|
delete g_BaseSystem;
|
|
|
|
g_BaseSystem = NULL;
|
|
|
|
}
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "System Closed");
|
2015-10-25 11:10:54 +00:00
|
|
|
}
|
2015-11-13 21:18:36 +00:00
|
|
|
catch (...)
|
2015-10-25 11:10:54 +00:00
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceError, "Exception caught (File: \"%s\" Line: %d)", __FILE__, __LINE__);
|
2015-11-13 21:18:36 +00:00
|
|
|
MessageBox(NULL, stdstr_f("Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).c_str(), "Exception", MB_OK);
|
2015-10-25 11:10:54 +00:00
|
|
|
}
|
2015-11-14 20:56:40 +00:00
|
|
|
AppCleanup();
|
2015-11-13 21:18:36 +00:00
|
|
|
CoUninitialize();
|
2015-10-25 11:10:54 +00:00
|
|
|
return true;
|
2015-11-14 20:56:40 +00:00
|
|
|
}
|