project64/Source/Project64/main.cpp

66 lines
2.4 KiB
C++
Raw Normal View History

#include "stdafx.h"
2015-12-06 09:59:58 +00:00
#include <Project64-core/AppInit.h>
#include "Multilanguage\LanguageSelector.h"
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/)
{
2015-10-25 11:10:54 +00:00
try
{
CoInitialize(NULL);
2016-01-13 07:23:22 +00:00
AppInit(&Notify(), __argc, __argv);
if (!g_Lang->IsLanguageLoaded())
2015-11-13 21:18:36 +00:00
{
CLanguageSelector().Select();
}
2015-10-25 11:10:54 +00:00
//Create the main window with Menu
WriteTrace(TraceUserInterface, TraceDebug, "Create Main Window");
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))
{
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
}
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
WriteTrace(TraceUserInterface, TraceDebug, "Entering Message Loop");
2015-10-25 11:10:54 +00:00
MainWindow.ProcessAllMessages();
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;
}
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
{
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
}
AppCleanup();
2015-11-13 21:18:36 +00:00
CoUninitialize();
2015-10-25 11:10:54 +00:00
return true;
}