project64/Source/Project64/main.cpp

66 lines
2.3 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);
AppInit(&Notify());
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
2015-11-13 21:18:36 +00:00
WriteTrace(TraceDebug, __FUNCTION__ ": 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
if (__argc > 1)
{
2015-11-13 21:18:36 +00:00
WriteTraceF(TraceDebug, __FUNCTION__ ": Cmd line found \"%s\"", __argv[1]);
2015-10-25 11:10:54 +00:00
MainWindow.Show(true); //Show the main window
CN64System::RunFileImage(__argv[1]);
}
else
{
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
2015-11-13 21:18:36 +00:00
WriteTrace(TraceDebug, __FUNCTION__ ": 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(TraceDebug, __FUNCTION__ ": 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-11-13 21:18:36 +00:00
WriteTrace(TraceDebug, __FUNCTION__ ": Entering Message Loop");
2015-10-25 11:10:54 +00:00
MainWindow.ProcessAllMessages();
2015-11-13 21:18:36 +00:00
WriteTrace(TraceDebug, __FUNCTION__ ": Message Loop Finished");
2015-10-25 11:10:54 +00:00
if (g_BaseSystem)
{
g_BaseSystem->CloseCpu();
delete g_BaseSystem;
g_BaseSystem = NULL;
}
2015-11-13 21:18:36 +00:00
WriteTrace(TraceDebug, __FUNCTION__ ": 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-11-13 21:18:36 +00:00
WriteTraceF(TraceError, __FUNCTION__ ": Exception caught (File: \"%s\" Line: %d)", __FILE__, __LINE__);
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;
}