2016-01-27 09:11:59 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include <Project64-core/AppInit.h>
|
|
|
|
#include "Multilanguage\LanguageSelector.h"
|
2016-04-13 07:34:19 +00:00
|
|
|
#include "Settings/UISettings.h"
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
2016-01-28 09:37:44 +00:00
|
|
|
AppInit(&Notify(), CPath(CPath::MODULE_DIRECTORY), __argc, __argv);
|
2016-01-27 09:11:59 +00:00
|
|
|
if (!g_Lang->IsLanguageLoaded())
|
|
|
|
{
|
|
|
|
CLanguageSelector().Select();
|
|
|
|
}
|
|
|
|
|
|
|
|
//Create the main window with Menu
|
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Create Main Window");
|
2017-06-18 23:08:35 +00:00
|
|
|
CMainGui MainWindow(true, stdstr_f("Project64 %s", VER_FILE_VERSION_STR).c_str()), HiddenWindow(false);
|
2016-01-27 09:11:59 +00:00
|
|
|
CMainMenu MainMenu(&MainWindow);
|
2018-01-10 07:05:57 +00:00
|
|
|
CDebuggerUI Debugger;
|
|
|
|
g_Debugger = &Debugger;
|
2016-01-27 09:11:59 +00:00
|
|
|
g_Plugins->SetRenderWindows(&MainWindow, &HiddenWindow);
|
|
|
|
Notify().SetMainWindow(&MainWindow);
|
2016-08-11 10:38:45 +00:00
|
|
|
CSupportWindow SupportWindow;
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
if (g_Settings->LoadStringVal(Cmd_RomFile).length() > 0)
|
|
|
|
{
|
|
|
|
MainWindow.Show(true); //Show the main window
|
2016-05-22 12:55:23 +00:00
|
|
|
//N64 ROM or 64DD Disk
|
|
|
|
stdstr ext = CPath(g_Settings->LoadStringVal(Cmd_RomFile)).GetExtension();
|
|
|
|
if (!(_stricmp(ext.c_str(), "ndd") == 0))
|
|
|
|
{
|
|
|
|
//File Extension is not *.ndd so it should be a N64 ROM
|
|
|
|
CN64System::RunFileImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Ext is *.ndd, so it should be a disk file.
|
2019-01-25 20:32:26 +00:00
|
|
|
if (!CPath(g_Settings->LoadStringVal(File_DiskIPLPath)).Exists() || !g_BaseSystem->RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str()))
|
|
|
|
{
|
2019-01-27 12:17:31 +00:00
|
|
|
if (!CPath(g_Settings->LoadStringVal(File_DiskIPLPath)).Exists()) { g_Notify->DisplayError(MSG_IPL_REQUIRED); }
|
2019-01-25 20:32:26 +00:00
|
|
|
CPath FileNameIPL;
|
|
|
|
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
|
|
|
|
if (FileNameIPL.SelectFile(NULL, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
|
|
|
{
|
|
|
|
g_Settings->SaveString(File_DiskIPLPath, (const char *)FileNameIPL);
|
|
|
|
g_BaseSystem->RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str());
|
|
|
|
}
|
|
|
|
}
|
2016-05-22 12:55:23 +00:00
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-11 10:38:45 +00:00
|
|
|
SupportWindow.Show(reinterpret_cast<HWND>(MainWindow.GetWindowHandle()));
|
2016-04-13 07:34:19 +00:00
|
|
|
if (UISettingsLoadBool(RomBrowser_Enabled))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
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;
|
2015-11-14 20:56:40 +00:00
|
|
|
}
|