project64/Source/Project64/main.cpp

66 lines
2.4 KiB
C++

#include "stdafx.h"
#include <Project64-core/AppInit.h>
#include "Multilanguage\LanguageSelector.h"
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/)
{
try
{
CoInitialize(NULL);
AppInit(&Notify(), CPath(CPath::MODULE_DIRECTORY), __argc, __argv);
if (!g_Lang->IsLanguageLoaded())
{
CLanguageSelector().Select();
}
//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);
CMainMenu MainMenu(&MainWindow);
g_Plugins->SetRenderWindows(&MainWindow, &HiddenWindow);
Notify().SetMainWindow(&MainWindow);
if (g_Settings->LoadStringVal(Cmd_RomFile).length() > 0)
{
MainWindow.Show(true); //Show the main window
CN64System::RunFileImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str());
}
else
{
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
WriteTrace(TraceUserInterface, TraceDebug, "Show Rom Browser");
//Display the rom browser
MainWindow.ShowRomList();
MainWindow.Show(true); //Show the main window
MainWindow.HighLightLastRom();
}
else
{
WriteTrace(TraceUserInterface, TraceDebug, "Show Main Window");
MainWindow.Show(true); //Show the main window
}
}
//Process Messages till program is closed
WriteTrace(TraceUserInterface, TraceDebug, "Entering Message Loop");
MainWindow.ProcessAllMessages();
WriteTrace(TraceUserInterface, TraceDebug, "Message Loop Finished");
if (g_BaseSystem)
{
g_BaseSystem->CloseCpu();
delete g_BaseSystem;
g_BaseSystem = NULL;
}
WriteTrace(TraceUserInterface, TraceDebug, "System Closed");
}
catch (...)
{
WriteTrace(TraceUserInterface, TraceError, "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);
}
AppCleanup();
CoUninitialize();
return true;
}