2016-01-27 09:11:59 +00:00
|
|
|
#include "stdafx.h"
|
2022-09-21 05:16:07 +00:00
|
|
|
|
|
|
|
#include "DiscordRPC.h"
|
2021-04-14 05:34:15 +00:00
|
|
|
#include "RomInformation.h"
|
2021-02-16 23:54:17 +00:00
|
|
|
#include <Project64-core/N64System/Enhancement/Enhancements.h>
|
2021-04-14 05:34:15 +00:00
|
|
|
#include <Project64-core/N64System/N64Disk.h>
|
2022-09-21 05:16:07 +00:00
|
|
|
#include <Project64-core/Settings/SettingType/SettingsType-Application.h>
|
2021-09-03 05:11:04 +00:00
|
|
|
#include <Project64/UserInterface/Debugger/DebuggerUI.h>
|
2022-09-21 05:16:07 +00:00
|
|
|
#include <Project64\UserInterface\About.h>
|
|
|
|
#include <commctrl.h>
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
void EnterLogOptions(HWND hwndOwner);
|
|
|
|
|
|
|
|
#pragma comment(lib, "Comctl32.lib")
|
|
|
|
|
|
|
|
LRESULT CALLBACK MainGui_Proc(HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lParam);
|
|
|
|
|
|
|
|
CMainGui::CMainGui(bool bMainWindow, const char * WindowTitle) :
|
|
|
|
CRomBrowser(m_hMainWindow, m_hStatusWnd),
|
|
|
|
m_ThreadId(GetCurrentThreadId()),
|
|
|
|
m_bMainWindow(bMainWindow),
|
|
|
|
m_Created(false),
|
|
|
|
m_AttachingMenu(false),
|
|
|
|
m_MakingVisible(false),
|
|
|
|
m_ResetPlugins(false),
|
2021-04-12 11:35:39 +00:00
|
|
|
m_ResetInfo(nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
m_Menu = nullptr;
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
m_hMainWindow = 0;
|
|
|
|
m_hStatusWnd = 0;
|
|
|
|
m_SaveMainWindowPos = false;
|
|
|
|
m_SaveMainWindowTop = 0;
|
|
|
|
m_SaveMainWindowLeft = 0;
|
|
|
|
|
|
|
|
m_SaveRomBrowserPos = false;
|
|
|
|
m_SaveRomBrowserTop = 0;
|
|
|
|
m_SaveRomBrowserLeft = 0;
|
|
|
|
|
|
|
|
if (m_bMainWindow)
|
|
|
|
{
|
2021-03-18 00:32:37 +00:00
|
|
|
g_Settings->RegisterChangeCB((SettingID)RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged);
|
|
|
|
g_Settings->RegisterChangeCB((SettingID)RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
|
2022-09-21 05:16:07 +00:00
|
|
|
g_Settings->RegisterChangeCB((SettingID)Setting_EnableDiscordRPC, this, (CSettings::SettingChangedFunc)DiscordRPCChanged);
|
2018-12-28 11:47:09 +00:00
|
|
|
g_Settings->RegisterChangeCB(RomList_GameDirRecursive, this, (CSettings::SettingChangedFunc)RomBrowserListChanged);
|
|
|
|
g_Settings->RegisterChangeCB(RomList_ShowFileExtensions, this, (CSettings::SettingChangedFunc)RomBrowserListChanged);
|
2016-01-27 09:11:59 +00:00
|
|
|
g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged);
|
|
|
|
g_Settings->RegisterChangeCB(GameRunning_CPU_Running, this, (CSettings::SettingChangedFunc)GameCpuRunning);
|
|
|
|
g_Settings->RegisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused);
|
|
|
|
g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
|
2021-03-18 00:32:37 +00:00
|
|
|
g_Settings->RegisterChangeCB((SettingID)UserInterface_ShowStatusBar, this, (CSettings::SettingChangedFunc)ShowStatusBarChanged);
|
2019-10-23 21:12:12 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (UISettingsLoadBool(Setting_EnableDiscordRPC))
|
|
|
|
{
|
|
|
|
CDiscord::Init();
|
|
|
|
CDiscord::Update(false);
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2021-03-17 08:36:30 +00:00
|
|
|
// If this fails then it has already been created
|
2016-01-27 09:11:59 +00:00
|
|
|
RegisterWinClass();
|
|
|
|
Create(WindowTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
CMainGui::~CMainGui(void)
|
|
|
|
{
|
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Start");
|
|
|
|
if (m_bMainWindow)
|
|
|
|
{
|
2021-03-18 00:32:37 +00:00
|
|
|
g_Settings->UnregisterChangeCB((SettingID)RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged);
|
|
|
|
g_Settings->UnregisterChangeCB((SettingID)RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
|
2022-09-21 05:16:07 +00:00
|
|
|
g_Settings->UnregisterChangeCB((SettingID)Setting_EnableDiscordRPC, this, (CSettings::SettingChangedFunc)DiscordRPCChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(RomList_GameDirRecursive, this, (CSettings::SettingChangedFunc)RomBrowserListChanged);
|
2018-12-28 11:47:09 +00:00
|
|
|
g_Settings->UnregisterChangeCB(RomList_ShowFileExtensions, this, (CSettings::SettingChangedFunc)RomBrowserListChanged);
|
2016-01-27 09:11:59 +00:00
|
|
|
g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(GameRunning_CPU_Running, this, (CSettings::SettingChangedFunc)GameCpuRunning);
|
|
|
|
g_Settings->UnregisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused);
|
|
|
|
g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
|
2021-03-18 00:32:37 +00:00
|
|
|
g_Settings->UnregisterChangeCB((SettingID)UserInterface_ShowStatusBar, this, (CSettings::SettingChangedFunc)ShowStatusBarChanged);
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (UISettingsLoadBool(Setting_EnableDiscordRPC))
|
|
|
|
{
|
|
|
|
CDiscord::Shutdown();
|
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
if (m_hMainWindow)
|
|
|
|
{
|
|
|
|
DestroyWindow(m_hMainWindow);
|
|
|
|
}
|
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Done");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CMainGui::RegisterWinClass(void)
|
|
|
|
{
|
2020-05-12 12:19:05 +00:00
|
|
|
std::wstring VersionDisplay = stdstr_f("Project64 %s", VER_FILE_VERSION_STR).ToUTF16();
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
WNDCLASS wcl;
|
|
|
|
|
|
|
|
wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wcl.cbClsExtra = 0;
|
|
|
|
wcl.cbWndExtra = 0;
|
2021-04-12 11:35:39 +00:00
|
|
|
wcl.hIcon = LoadIcon(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDI_PJ64_Icon));
|
|
|
|
wcl.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
|
|
|
wcl.hInstance = GetModuleHandle(nullptr);
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
wcl.lpfnWndProc = (WNDPROC)MainGui_Proc;
|
|
|
|
wcl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
2021-04-12 11:35:39 +00:00
|
|
|
wcl.lpszMenuName = nullptr;
|
2016-01-27 09:11:59 +00:00
|
|
|
wcl.lpszClassName = VersionDisplay.c_str();
|
|
|
|
if (RegisterClass(&wcl) == 0) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::AddRecentRom(const char * ImagePath)
|
|
|
|
{
|
2022-09-26 02:31:54 +00:00
|
|
|
if (HIWORD(ImagePath) == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2021-03-17 08:36:30 +00:00
|
|
|
// Get information about the stored ROM list
|
2016-04-13 07:34:19 +00:00
|
|
|
size_t MaxRememberedFiles = UISettingsLoadDword(File_RecentGameFileCount);
|
2016-01-27 09:11:59 +00:00
|
|
|
strlist RecentGames;
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < MaxRememberedFiles; i++)
|
|
|
|
{
|
2016-04-13 07:34:19 +00:00
|
|
|
stdstr RecentGame = UISettingsLoadStringIndex(File_RecentGameFileIndex, i);
|
2016-01-27 09:11:59 +00:00
|
|
|
if (RecentGame.empty())
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RecentGames.push_back(RecentGame);
|
|
|
|
}
|
|
|
|
|
2021-03-17 08:36:30 +00:00
|
|
|
// See if the directory is already in the list, if so then move it to the top of the list
|
2016-01-27 09:11:59 +00:00
|
|
|
strlist::iterator iter;
|
|
|
|
for (iter = RecentGames.begin(); iter != RecentGames.end(); iter++)
|
|
|
|
{
|
|
|
|
if (_stricmp(ImagePath, iter->c_str()) != 0)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
RecentGames.erase(iter);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RecentGames.push_front(ImagePath);
|
|
|
|
if (RecentGames.size() > MaxRememberedFiles)
|
|
|
|
{
|
|
|
|
RecentGames.pop_back();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0, iter = RecentGames.begin(); iter != RecentGames.end(); iter++, i++)
|
|
|
|
{
|
2016-04-13 07:34:19 +00:00
|
|
|
UISettingsSaveStringIndex(File_RecentGameFileIndex, i, *iter);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::SetWindowCaption(const wchar_t * title)
|
|
|
|
{
|
|
|
|
static const size_t TITLE_SIZE = 256;
|
|
|
|
wchar_t WinTitle[TITLE_SIZE];
|
|
|
|
|
2016-04-13 07:34:19 +00:00
|
|
|
_snwprintf(WinTitle, TITLE_SIZE, L"%s - %s", title, stdstr(g_Settings->LoadStringVal(Setting_ApplicationName)).ToUTF16().c_str());
|
2016-01-27 09:11:59 +00:00
|
|
|
WinTitle[TITLE_SIZE - 1] = 0;
|
|
|
|
Caption(WinTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::ShowRomBrowser(void)
|
|
|
|
{
|
2016-04-13 07:34:19 +00:00
|
|
|
if (UISettingsLoadBool(RomBrowser_Enabled))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
ShowRomList();
|
|
|
|
HighLightLastRom();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RomBowserEnabledChanged(CMainGui * Gui)
|
|
|
|
{
|
2016-04-13 07:34:19 +00:00
|
|
|
if (Gui && UISettingsLoadBool(RomBrowser_Enabled))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
if (!Gui->RomBrowserVisible())
|
|
|
|
{
|
|
|
|
Gui->ShowRomList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Gui->RomBrowserVisible())
|
|
|
|
{
|
|
|
|
Gui->HideRomList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::LoadingInProgressChanged(CMainGui * Gui)
|
|
|
|
{
|
|
|
|
Gui->RefreshMenu();
|
|
|
|
if (!g_Settings->LoadBool(GameRunning_LoadingInProgress) && g_Settings->LoadStringVal(Game_File).length() == 0)
|
|
|
|
{
|
|
|
|
Notify().WindowMode();
|
2016-04-13 07:34:19 +00:00
|
|
|
if (UISettingsLoadBool(RomBrowser_Enabled))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
Gui->ShowRomBrowser();
|
|
|
|
}
|
|
|
|
Gui->MakeWindowOnTop(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::GameLoaded(CMainGui * Gui)
|
|
|
|
{
|
|
|
|
stdstr FileLoc = g_Settings->LoadStringVal(Game_File);
|
|
|
|
if (FileLoc.length() > 0)
|
|
|
|
{
|
2021-05-18 11:51:36 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Add recent ROM");
|
2016-01-27 09:11:59 +00:00
|
|
|
Gui->AddRecentRom(FileLoc.c_str());
|
2017-01-31 15:31:56 +00:00
|
|
|
Gui->SetWindowCaption(stdstr(g_Settings->LoadStringVal(Rdb_GoodName)).ToUTF16().c_str());
|
2022-09-21 05:16:07 +00:00
|
|
|
|
|
|
|
if (UISettingsLoadBool(Setting_EnableDiscordRPC))
|
|
|
|
{
|
|
|
|
CDiscord::Update();
|
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::GamePaused(CMainGui * Gui)
|
|
|
|
{
|
|
|
|
Gui->RefreshMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::GameCpuRunning(CMainGui * Gui)
|
|
|
|
{
|
|
|
|
if (g_Settings->LoadBool(GameRunning_CPU_Running))
|
|
|
|
{
|
2016-04-13 07:34:19 +00:00
|
|
|
Gui->MakeWindowOnTop(UISettingsLoadBool(UserInterface_AlwaysOnTop));
|
2016-07-02 13:35:11 +00:00
|
|
|
Gui->HideRomList();
|
2016-04-13 07:34:19 +00:00
|
|
|
if (UISettingsLoadBool(Setting_AutoFullscreen))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "15");
|
|
|
|
CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
|
2016-04-13 07:34:19 +00:00
|
|
|
std::string Status = UISettingsLoadStringVal(Rdb_Status);
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
char String[100];
|
2021-03-17 08:36:30 +00:00
|
|
|
RomIniFile.GetString("ROM Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String));
|
2016-01-27 09:11:59 +00:00
|
|
|
if (_stricmp(String, "true") == 0)
|
|
|
|
{
|
|
|
|
g_Notify->ChangeFullScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Gui->RefreshMenu();
|
|
|
|
Gui->BringToTop();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
if (Gui->m_CheatsUI.m_hWnd != nullptr)
|
2020-05-25 10:38:31 +00:00
|
|
|
{
|
|
|
|
Gui->m_CheatsUI.SendMessage(WM_COMMAND, MAKELONG(IDCANCEL, 0));
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
PostMessage(Gui->m_hMainWindow, WM_GAME_CLOSED, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-18 00:32:37 +00:00
|
|
|
void CMainGui::ShowStatusBarChanged(CMainGui * Gui)
|
|
|
|
{
|
|
|
|
if (!Gui->bCPURunning())
|
|
|
|
{
|
|
|
|
ShowWindow(Gui->m_hStatusWnd, g_Settings->LoadBool((SettingID)UserInterface_ShowStatusBar) ? SW_SHOW : SW_HIDE);
|
2022-09-21 05:16:07 +00:00
|
|
|
|
2021-03-18 00:32:37 +00:00
|
|
|
RECT rc;
|
|
|
|
GetClientRect(Gui->m_hMainWindow, &rc);
|
|
|
|
Gui->ResizeRomList((WORD)(rc.right - rc.left), (WORD)(rc.bottom - rc.top));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
void RomBowserColoumnsChanged(CMainGui * Gui)
|
|
|
|
{
|
|
|
|
Gui->ResetRomBrowserColomuns();
|
|
|
|
}
|
|
|
|
|
2018-12-28 11:47:09 +00:00
|
|
|
void RomBrowserListChanged(CMainGui * Gui)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2016-04-14 22:07:34 +00:00
|
|
|
Gui->RefreshRomList();
|
2016-01-27 09:11:59 +00:00
|
|
|
Gui->HighLightLastRom();
|
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
void DiscordRPCChanged(CMainGui *)
|
2019-10-23 21:12:12 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
if (UISettingsLoadBool(Setting_EnableDiscordRPC))
|
|
|
|
{
|
|
|
|
CDiscord::Init();
|
|
|
|
CDiscord::Update();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CDiscord::Shutdown();
|
|
|
|
}
|
2019-10-23 21:12:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
void CMainGui::ChangeWinSize(long width, long height)
|
|
|
|
{
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
WINDOWPLACEMENT wndpl;
|
|
|
|
RECT rc1, swrect;
|
|
|
|
|
|
|
|
wndpl.length = sizeof(wndpl);
|
|
|
|
GetWindowPlacement(m_hMainWindow, &wndpl);
|
|
|
|
|
2021-03-18 00:32:37 +00:00
|
|
|
if (m_hStatusWnd != nullptr && IsWindowVisible(m_hStatusWnd))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2021-03-18 00:32:37 +00:00
|
|
|
GetClientRect(m_hStatusWnd, &swrect);
|
2016-01-27 09:11:59 +00:00
|
|
|
SetRect(&rc1, 0, 0, width, height + swrect.bottom);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetRect(&rc1, 0, 0, width, height);
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
AdjustWindowRectEx(&rc1, GetWindowLong(m_hMainWindow, GWL_STYLE), GetMenu(m_hMainWindow) != nullptr, GetWindowLong(m_hMainWindow, GWL_EXSTYLE));
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
MoveWindow(m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE);
|
|
|
|
}
|
|
|
|
|
2021-03-18 00:32:37 +00:00
|
|
|
void * CMainGui::GetStatusBar(void) const
|
|
|
|
{
|
|
|
|
return g_Settings->LoadBool((SettingID)UserInterface_ShowStatusBar) ? m_hStatusWnd : nullptr;
|
|
|
|
}
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
void * CMainGui::GetModuleInstance(void) const
|
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
return GetModuleHandle(nullptr);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CMainGui::ResetPluginsInUiThread(CPlugins * plugins, CN64System * System)
|
|
|
|
{
|
|
|
|
RESET_PLUGIN info;
|
|
|
|
info.system = System;
|
|
|
|
info.plugins = plugins;
|
2021-04-12 11:35:39 +00:00
|
|
|
info.hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
|
2016-01-27 09:11:59 +00:00
|
|
|
bool bRes = true;
|
|
|
|
if (info.hEvent)
|
|
|
|
{
|
|
|
|
PostMessage(m_hMainWindow, WM_RESET_PLUGIN, (WPARAM)&bRes, (LPARAM)&info);
|
|
|
|
#ifdef _DEBUG
|
|
|
|
DWORD dwRes = WaitForSingleObject(info.hEvent, INFINITE);
|
|
|
|
#else
|
|
|
|
DWORD dwRes = WaitForSingleObject(info.hEvent, 5000);
|
|
|
|
#endif
|
|
|
|
dwRes = dwRes;
|
|
|
|
CloseHandle(info.hEvent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteTrace(TraceUserInterface, TraceError, "Failed to create event");
|
|
|
|
bRes = false;
|
|
|
|
}
|
|
|
|
Notify().RefreshMenu();
|
|
|
|
return bRes;
|
|
|
|
}
|
|
|
|
|
2020-05-25 10:38:31 +00:00
|
|
|
void CMainGui::DisplayCheatsUI(bool BlockExecution)
|
|
|
|
{
|
|
|
|
m_CheatsUI.Display(m_hMainWindow, BlockExecution);
|
|
|
|
}
|
|
|
|
|
2021-02-02 02:52:47 +00:00
|
|
|
void CMainGui::DisplayEnhancements(bool BlockExecution)
|
|
|
|
{
|
|
|
|
m_EnhancementUI.Display(m_hMainWindow, BlockExecution);
|
|
|
|
}
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
void CMainGui::BringToTop(void)
|
|
|
|
{
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
SetForegroundWindow(m_hMainWindow);
|
|
|
|
SetFocus(GetDesktopWindow());
|
|
|
|
Sleep(100);
|
|
|
|
SetFocus(m_hMainWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::MakeWindowOnTop(bool OnTop)
|
|
|
|
{
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
SetWindowPos(m_hMainWindow, OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0,
|
2022-09-21 05:16:07 +00:00
|
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::Caption(LPCWSTR Caption)
|
|
|
|
{
|
|
|
|
CGuard Guard(m_CS);
|
2021-01-02 03:37:00 +00:00
|
|
|
SetWindowText(m_hMainWindow, Caption);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::Create(const char * WindowTitle)
|
|
|
|
{
|
|
|
|
stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR);
|
2022-09-21 05:16:07 +00:00
|
|
|
m_hMainWindow = CreateWindowEx(WS_EX_ACCEPTFILES, VersionDisplay.ToUTF16().c_str(), stdstr(WindowTitle).ToUTF16().c_str(), WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX, 5, 5, 640, 480,
|
|
|
|
nullptr, nullptr, GetModuleHandle(nullptr), this);
|
2021-04-12 11:35:39 +00:00
|
|
|
m_Created = m_hMainWindow != nullptr;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::CreateStatusBar(void)
|
|
|
|
{
|
2020-05-12 12:19:05 +00:00
|
|
|
m_hStatusWnd = (HWND)CreateStatusWindow(WS_CHILD | WS_VISIBLE, L"", m_hMainWindow, StatusBarID);
|
2022-09-21 05:16:07 +00:00
|
|
|
SendMessage((HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM) "");
|
2021-03-18 00:32:37 +00:00
|
|
|
ShowWindow(m_hStatusWnd, g_Settings->LoadBool((SettingID)UserInterface_ShowStatusBar) ? SW_SHOW : SW_HIDE);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WPARAM CMainGui::ProcessAllMessages(void)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
while (GetMessage(&msg, nullptr, 0, 0))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
if (m_ResetPlugins)
|
|
|
|
{
|
|
|
|
m_ResetPlugins = false;
|
|
|
|
m_ResetInfo->res = m_ResetInfo->plugins->Reset(m_ResetInfo->system);
|
|
|
|
SetEvent(m_ResetInfo->hEvent);
|
2021-04-12 11:35:39 +00:00
|
|
|
m_ResetInfo = nullptr;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2022-09-26 02:31:54 +00:00
|
|
|
if ((m_CheatsUI.m_hWnd != nullptr && IsDialogMessage(m_CheatsUI.m_hWnd, &msg)) || (m_EnhancementUI.m_hWnd != nullptr && IsDialogMessage(m_EnhancementUI.m_hWnd, &msg)))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg))
|
2020-05-25 10:38:31 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
return msg.wParam;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CMainGui::ProcessGuiMessages(void)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
while (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
if (m_ResetPlugins)
|
|
|
|
{
|
|
|
|
m_ResetPlugins = false;
|
|
|
|
}
|
|
|
|
if (msg.message == WM_QUIT)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2021-04-12 11:35:39 +00:00
|
|
|
PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE);
|
2022-09-26 02:31:54 +00:00
|
|
|
if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::Resize(DWORD /*fwSizeType*/, WORD nWidth, WORD nHeight)
|
|
|
|
{
|
|
|
|
RECT clrect, swrect;
|
|
|
|
GetClientRect(m_hMainWindow, &clrect);
|
2021-03-18 00:32:37 +00:00
|
|
|
GetClientRect(m_hStatusWnd, &swrect);
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
int Parts[2];
|
2022-09-21 05:16:07 +00:00
|
|
|
Parts[0] = (int)(nWidth - 135 * DPIScale(m_hStatusWnd));
|
2016-01-27 09:11:59 +00:00
|
|
|
Parts[1] = nWidth;
|
|
|
|
|
2021-03-18 00:32:37 +00:00
|
|
|
SendMessage(m_hStatusWnd, SB_SETPARTS, 2, (LPARAM)&Parts[0]);
|
|
|
|
MoveWindow(m_hStatusWnd, 0, clrect.bottom - swrect.bottom, nWidth, nHeight, TRUE);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::Show(bool Visible)
|
|
|
|
{
|
|
|
|
m_MakingVisible = true;
|
|
|
|
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
if (m_hMainWindow)
|
|
|
|
{
|
|
|
|
ShowWindow(m_hMainWindow, Visible ? SW_SHOW : SW_HIDE);
|
|
|
|
if (Visible && RomBrowserVisible())
|
|
|
|
{
|
|
|
|
RomBrowserToTop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_MakingVisible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::EnterLogOptions(void)
|
|
|
|
{
|
|
|
|
::EnterLogOptions(m_hMainWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMainGui::Height(void)
|
|
|
|
{
|
2022-09-26 02:31:54 +00:00
|
|
|
if (!m_hMainWindow)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
RECT rect;
|
|
|
|
GetWindowRect(m_hMainWindow, &rect);
|
|
|
|
return rect.bottom - rect.top;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMainGui::Width(void)
|
|
|
|
{
|
2022-09-26 02:31:54 +00:00
|
|
|
if (!m_hMainWindow)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
RECT rect;
|
|
|
|
GetWindowRect(m_hMainWindow, &rect);
|
|
|
|
return rect.right - rect.left;
|
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
float CMainGui::DPIScale(HWND hWnd)
|
2021-03-18 00:32:37 +00:00
|
|
|
{
|
2019-04-19 19:13:37 +00:00
|
|
|
return CClientDC(hWnd).GetDeviceCaps(LOGPIXELSX) / 96.0f;
|
|
|
|
}
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
void CMainGui::SetPos(int X, int Y)
|
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
SetWindowPos(m_hMainWindow, nullptr, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::SetWindowMenu(CBaseMenu * Menu)
|
|
|
|
{
|
|
|
|
m_AttachingMenu = true;
|
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
HMENU hMenu = nullptr;
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
m_Menu = Menu;
|
|
|
|
hMenu = (HMENU)Menu->GetHandle();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hMenu)
|
|
|
|
{
|
|
|
|
SetMenu(m_hMainWindow, hMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_AttachingMenu = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::RefreshMenu(void)
|
|
|
|
{
|
2022-09-26 02:31:54 +00:00
|
|
|
if (!m_Menu)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
m_Menu->ResetMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::SetStatusText(int Panel, const wchar_t * Text)
|
|
|
|
{
|
|
|
|
static wchar_t Message[2][500];
|
|
|
|
if (Panel >= 2)
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
wchar_t * Msg = Message[Panel];
|
|
|
|
|
|
|
|
memset(Msg, 0, sizeof(Message[0]));
|
|
|
|
_snwprintf(Msg, sizeof(Message[0]) / sizeof(Message[0][0]), L"%s", Text);
|
|
|
|
Msg[(sizeof(Message[0]) / sizeof(Message[0][0])) - 1] = 0;
|
|
|
|
if (GetCurrentThreadId() == m_ThreadId)
|
|
|
|
{
|
2021-03-18 00:32:37 +00:00
|
|
|
SendMessage(m_hStatusWnd, SB_SETTEXT, Panel, (LPARAM)Msg);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
else
|
2021-03-18 00:32:37 +00:00
|
|
|
{
|
|
|
|
PostMessage(m_hStatusWnd, SB_SETTEXT, Panel, (LPARAM)Msg);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::ShowStatusBar(bool ShowBar)
|
|
|
|
{
|
2021-03-18 00:32:37 +00:00
|
|
|
ShowWindow(m_hStatusWnd, ShowBar ? SW_SHOW : SW_HIDE);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::SaveWindowLoc(void)
|
|
|
|
{
|
|
|
|
bool flush = false;
|
|
|
|
if (m_SaveMainWindowPos)
|
|
|
|
{
|
|
|
|
m_SaveMainWindowPos = false;
|
2016-04-13 07:34:19 +00:00
|
|
|
UISettingsSaveDword(UserInterface_MainWindowTop, m_SaveMainWindowTop);
|
|
|
|
UISettingsSaveDword(UserInterface_MainWindowLeft, m_SaveMainWindowLeft);
|
2016-01-27 09:11:59 +00:00
|
|
|
flush = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_SaveRomBrowserPos)
|
|
|
|
{
|
|
|
|
m_SaveRomBrowserPos = false;
|
2016-04-13 07:34:19 +00:00
|
|
|
UISettingsSaveDword(RomBrowser_Top, m_SaveRomBrowserTop);
|
|
|
|
UISettingsSaveDword(RomBrowser_Left, m_SaveRomBrowserLeft);
|
2016-01-27 09:11:59 +00:00
|
|
|
flush = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flush)
|
|
|
|
{
|
|
|
|
CSettingTypeApplication::Flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
|
|
|
|
{
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
// Record class for future usage
|
|
|
|
LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
|
|
|
|
CMainGui * _this = (CMainGui *)lpcs->lpCreateParams;
|
|
|
|
SetProp(hWnd, L"Class", _this);
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
_this->m_hMainWindow = hWnd;
|
|
|
|
_this->CreateStatusBar();
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
// Move the main window to the location last executed from or center the window
|
|
|
|
int X = (GetSystemMetrics(SM_CXSCREEN) - _this->Width()) / 2;
|
|
|
|
int Y = (GetSystemMetrics(SM_CYSCREEN) - _this->Height()) / 2;
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
UISettingsLoadDword(UserInterface_MainWindowTop, (uint32_t &)Y);
|
|
|
|
UISettingsLoadDword(UserInterface_MainWindowLeft, (uint32_t &)X);
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
_this->SetPos(X, Y);
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
_this->ChangeWinSize(int(640 * _this->DPIScale(hWnd)), int(480 * _this->DPIScale(hWnd)));
|
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_SYSCOMMAND:
|
2022-09-21 05:16:07 +00:00
|
|
|
switch (wParam)
|
|
|
|
{
|
2016-01-27 09:11:59 +00:00
|
|
|
case SC_SCREENSAVE:
|
|
|
|
case SC_MONITORPOWER:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
2022-09-26 02:31:54 +00:00
|
|
|
if (_this && _this->bCPURunning() && !g_Settings->LoadBool(GameRunning_CPU_Paused) && UISettingsLoadBool(Setting_DisableScrSaver))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
return 0;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case SC_MAXIMIZE:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
if (_this)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
if (_this->RomBrowserVisible())
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
_this->RomBrowserMaximize(true);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
|
|
break;
|
|
|
|
case WM_MOVE:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
|
2022-09-26 02:31:54 +00:00
|
|
|
if (!_this->m_bMainWindow || !_this->m_Created || _this->m_AttachingMenu || _this->m_MakingVisible || IsIconic(hWnd) || _this->ShowingRomBrowser())
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (IsZoomed(hWnd))
|
|
|
|
{
|
|
|
|
if (_this->RomBrowserVisible())
|
2016-04-12 08:07:01 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
// Save that browser is maximized
|
2016-04-12 08:07:01 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
// Get the current position of the window
|
|
|
|
RECT WinRect;
|
|
|
|
GetWindowRect(hWnd, &WinRect);
|
2016-04-12 08:07:01 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
// Save the location of the window
|
|
|
|
if (_this->RomBrowserVisible())
|
|
|
|
{
|
|
|
|
_this->m_SaveRomBrowserPos = true;
|
|
|
|
_this->m_SaveRomBrowserTop = WinRect.top;
|
|
|
|
_this->m_SaveRomBrowserLeft = WinRect.left;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
_this->m_SaveMainWindowPos = true;
|
|
|
|
_this->m_SaveMainWindowTop = WinRect.top;
|
|
|
|
_this->m_SaveMainWindowLeft = WinRect.left;
|
|
|
|
}
|
|
|
|
KillTimer(hWnd, Timer_SetWindowPos);
|
|
|
|
SetTimer(hWnd, Timer_SetWindowPos, 1000, nullptr);
|
|
|
|
}
|
2016-04-12 08:07:01 +00:00
|
|
|
if (CGuiSettings::bCPURunning() && g_BaseSystem)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2016-04-12 08:07:01 +00:00
|
|
|
if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen)
|
|
|
|
{
|
2022-06-27 10:02:38 +00:00
|
|
|
WriteTrace(TraceVideoPlugin, TraceDebug, "Starting");
|
2016-04-12 08:07:01 +00:00
|
|
|
g_Plugins->Gfx()->MoveScreen((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam));
|
2022-06-27 10:02:38 +00:00
|
|
|
WriteTrace(TraceVideoPlugin, TraceDebug, "Done");
|
2016-04-12 08:07:01 +00:00
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2016-04-12 08:07:01 +00:00
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_TIMER:
|
|
|
|
if (wParam == Timer_SetWindowPos)
|
|
|
|
{
|
|
|
|
KillTimer(hWnd, Timer_SetWindowPos);
|
2020-05-12 12:19:05 +00:00
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
2016-01-27 09:11:59 +00:00
|
|
|
_this->SaveWindowLoc();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_SIZE:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
2022-09-26 02:31:54 +00:00
|
|
|
if (_this)
|
|
|
|
{
|
|
|
|
_this->Resize(wParam, LOWORD(lParam), HIWORD(lParam));
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
if (_this)
|
|
|
|
{
|
|
|
|
if (wParam == SIZE_MAXIMIZED)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
if (_this->RomBrowserVisible())
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
_this->RomBrowserMaximize(true);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
_this->ResizeRomList(LOWORD(lParam), HIWORD(lParam));
|
|
|
|
}
|
|
|
|
if (_this)
|
|
|
|
{
|
|
|
|
if (wParam == SIZE_RESTORED && _this->RomBrowserVisible())
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
_this->RomBrowserMaximize(false);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_NOTIFY:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
if (_this == nullptr || !_this->RomBrowserVisible() || !_this->RomListNotify(wParam, lParam))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_DRAWITEM:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
if (_this)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
if (!_this->RomListDrawItem(wParam, lParam))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_PAINT:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
// CMainGui * _this = (CMainGui *)GetProp(hWnd,"Class");
|
|
|
|
// CN64System * System = _this->m_System;
|
|
|
|
|
|
|
|
// if (bCPURunning() && Settings->Load(CPU_Paused)) {
|
|
|
|
// CPlugins * Plugins = System->Plugins();
|
|
|
|
// if (Plugins->Gfx()->DrawScreen) {
|
|
|
|
// Plugins->Gfx()->DrawScreen();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
ValidateRect(hWnd, nullptr);
|
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_KEYUP:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
2016-04-12 08:07:01 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (_this->m_bMainWindow && bCPURunning())
|
|
|
|
{
|
|
|
|
if (g_BaseSystem)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
if (g_Plugins && g_Plugins->Control()->WM_KeyUp)
|
2016-04-12 08:07:01 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_Plugins->Control()->WM_KeyUp(wParam, lParam);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_KEYDOWN:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
2016-04-12 08:07:01 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (_this->m_bMainWindow && bCPURunning())
|
|
|
|
{
|
|
|
|
if (g_BaseSystem)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
if (g_Plugins && g_Plugins->Control()->WM_KeyDown)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_Plugins->Control()->WM_KeyDown(wParam, lParam);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_SETFOCUS:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
if (_this->RomBrowserVisible())
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
PostMessage(hWnd, WM_BROWSER_TOP, 0, 0);
|
|
|
|
break;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
|
|
|
|
{
|
|
|
|
if (g_BaseSystem)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_KILLFOCUS:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
if (_this->RomBrowserVisible())
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (_this->m_bMainWindow && bCPURunning())
|
|
|
|
{
|
|
|
|
if (g_BaseSystem)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
if (bAutoSleep())
|
2016-04-12 08:07:01 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus);
|
|
|
|
}
|
2022-01-09 11:13:12 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (g_Plugins && g_Plugins->Control()->WM_KillFocus)
|
|
|
|
{
|
|
|
|
g_Plugins->Control()->WM_KillFocus(wParam, lParam);
|
2016-04-12 08:07:01 +00:00
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_ACTIVATEAPP:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
DWORD fActive = (BOOL)wParam;
|
2016-04-12 08:07:01 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (fActive && _this->RomBrowserVisible())
|
|
|
|
{
|
|
|
|
PostMessage(hWnd, WM_BROWSER_TOP, 0, 0);
|
|
|
|
}
|
|
|
|
if (_this->m_bMainWindow && bCPURunning())
|
|
|
|
{
|
|
|
|
if (!fActive && UISettingsLoadBool(UserInterface_InFullScreen) && UISettingsLoadBool(UserInterface_ExitFullscreenOnLoseFocus))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
Notify().WindowMode();
|
|
|
|
if (bAutoSleep() && g_BaseSystem)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
//System->ExternalEvent(PauseCPU_AppLostActiveDelayed );
|
2016-04-12 08:07:01 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (bAutoSleep() || fActive)
|
|
|
|
{
|
|
|
|
if (g_BaseSystem)
|
2016-04-12 08:07:01 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_HIDE_CUROSR:
|
|
|
|
if (!wParam)
|
|
|
|
{
|
2022-09-26 02:31:54 +00:00
|
|
|
while (ShowCursor(FALSE) >= 0)
|
|
|
|
{
|
|
|
|
Sleep(0);
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-26 02:31:54 +00:00
|
|
|
while (ShowCursor(TRUE) < 0)
|
|
|
|
{
|
|
|
|
Sleep(0);
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_MAKE_FOCUS:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
_this->BringToTop();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_BROWSER_TOP:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
_this->RomBrowserToTop();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_RESET_PLUGIN:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
if (_this->m_ResetInfo != nullptr)
|
2016-04-12 08:07:01 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
2016-04-12 08:07:01 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
_this->m_ResetInfo = (RESET_PLUGIN *)lParam;
|
|
|
|
_this->m_ResetPlugins = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_GAME_CLOSED:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
|
|
|
Notify().WindowMode();
|
|
|
|
if (UISettingsLoadBool(RomBrowser_Enabled))
|
2016-04-12 08:07:01 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
_this->ShowRomBrowser();
|
2016-04-12 08:07:01 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
_this->RefreshMenu();
|
|
|
|
_this->MakeWindowOnTop(false);
|
|
|
|
_this->SetStatusText(0, L"");
|
|
|
|
_this->SetStatusText(1, L"");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_JSAPI_ACTION:
|
|
|
|
{
|
|
|
|
switch (wParam)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
case JSAPI_ACT_OPEN_ROM:
|
|
|
|
{
|
|
|
|
char * romPath = (char *)lParam;
|
|
|
|
stdstr ext = CPath(romPath).GetExtension();
|
2022-09-26 02:31:54 +00:00
|
|
|
if ((_stricmp(ext.c_str(), "ndd") != 0) && (_stricmp(ext.c_str(), "d64") != 0))
|
2016-04-12 08:07:01 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_BaseSystem->RunFileImage(romPath);
|
2016-04-12 08:07:01 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
else
|
2016-04-12 08:07:01 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_BaseSystem->RunDiskImage(romPath);
|
2016-04-12 08:07:01 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
delete[] romPath;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2016-04-12 08:07:01 +00:00
|
|
|
break;
|
2022-09-21 05:16:07 +00:00
|
|
|
case JSAPI_ACT_CLOSE_ROM:
|
|
|
|
if (g_BaseSystem)
|
2021-09-03 05:11:04 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_BaseSystem->ExternalEvent(SysEvent_CloseCPU);
|
|
|
|
}
|
2021-09-03 05:11:04 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (UISettingsLoadBool(Setting_EnableDiscordRPC))
|
|
|
|
{
|
|
|
|
CDiscord::Update(false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case JSAPI_ACT_RESET:
|
|
|
|
if (g_BaseSystem)
|
|
|
|
{
|
|
|
|
g_BaseSystem->ExternalEvent((bool)lParam ? SysEvent_ResetCPU_Soft : SysEvent_ResetCPU_Hard);
|
2021-09-03 05:11:04 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
break;
|
|
|
|
case JSAPI_ACT_PAUSE:
|
|
|
|
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_FromMenu);
|
|
|
|
break;
|
|
|
|
case JSAPI_ACT_RESUME:
|
|
|
|
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_FromMenu);
|
|
|
|
break;
|
2021-09-03 05:11:04 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2021-09-03 05:11:04 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_RBUTTONDOWN:
|
2022-09-21 05:16:07 +00:00
|
|
|
if (g_Settings->LoadBool(Debugger_Enabled))
|
|
|
|
{
|
2021-09-03 05:11:04 +00:00
|
|
|
SetCapture(hWnd);
|
2022-09-21 05:16:07 +00:00
|
|
|
CDebuggerUI * debugger = (CDebuggerUI *)g_Debugger;
|
2021-09-03 05:11:04 +00:00
|
|
|
debugger->ScriptSystem()->DoMouseEvent(JS_HOOK_MOUSEDOWN,
|
2022-09-21 05:16:07 +00:00
|
|
|
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), uMsg);
|
2021-09-03 05:11:04 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
case WM_RBUTTONUP:
|
2022-09-21 05:16:07 +00:00
|
|
|
if (g_Settings->LoadBool(Debugger_Enabled))
|
|
|
|
{
|
2021-09-03 05:11:04 +00:00
|
|
|
ReleaseCapture();
|
2022-09-21 05:16:07 +00:00
|
|
|
CDebuggerUI * debugger = (CDebuggerUI *)g_Debugger;
|
2021-09-03 05:11:04 +00:00
|
|
|
debugger->ScriptSystem()->DoMouseEvent(JS_HOOK_MOUSEUP,
|
2022-09-21 05:16:07 +00:00
|
|
|
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), uMsg);
|
2021-09-03 05:11:04 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_MOUSEMOVE:
|
2022-09-21 05:16:07 +00:00
|
|
|
if (g_Settings->LoadBool(Debugger_Enabled))
|
|
|
|
{
|
2021-09-03 05:11:04 +00:00
|
|
|
static int lastX = 0;
|
|
|
|
static int lastY = 0;
|
|
|
|
int x = GET_X_LPARAM(lParam);
|
|
|
|
int y = GET_Y_LPARAM(lParam);
|
|
|
|
if (lastX != x || lastY != y)
|
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
CDebuggerUI * debugger = (CDebuggerUI *)g_Debugger;
|
2021-09-03 05:11:04 +00:00
|
|
|
debugger->ScriptSystem()->DoMouseEvent(JS_HOOK_MOUSEMOVE, x, y, (DWORD)-1);
|
|
|
|
lastX = x;
|
|
|
|
lastY = y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_COMMAND:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
2022-09-26 02:31:54 +00:00
|
|
|
if (_this == nullptr)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case ID_POPUPMENU_PLAYGAME:
|
|
|
|
{
|
|
|
|
if ((CPath(_this->CurrentedSelectedRom()).GetExtension() != "ndd") && (CPath(_this->CurrentedSelectedRom()).GetExtension() != "d64"))
|
|
|
|
{
|
|
|
|
g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_BaseSystem->RunDiskImage(_this->CurrentedSelectedRom());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_POPUPMENU_PLAYGAMEWITHDISK:
|
|
|
|
{
|
|
|
|
CPath FileName;
|
|
|
|
const char * Filter = "N64DD Disk Image (*.ndd, *.d64)\0*.ndd;*.d64\0All files (*.*)\0*.*\0";
|
|
|
|
if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
|
|
|
{
|
|
|
|
g_BaseSystem->RunDiskComboImage(_this->CurrentedSelectedRom(), FileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break;
|
|
|
|
case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomList(); break;
|
|
|
|
case ID_POPUPMENU_ROMINFORMATION:
|
|
|
|
{
|
|
|
|
RomInformation Info(_this->CurrentedSelectedRom());
|
|
|
|
Info.DisplayInformation(hWnd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_EDITSETTINGS:
|
|
|
|
case ID_POPUPMENU_EDITCHEATS:
|
|
|
|
case ID_POPUPMENU_CHOOSEENHANCEMENT:
|
|
|
|
{
|
|
|
|
if ((CPath(_this->CurrentedSelectedRom()).GetExtension() != "ndd") && (CPath(_this->CurrentedSelectedRom()).GetExtension() != "d64"))
|
|
|
|
{
|
|
|
|
CN64Rom Rom;
|
|
|
|
Rom.LoadN64Image(_this->CurrentedSelectedRom(), true);
|
|
|
|
Rom.SaveRomSettingID(true);
|
|
|
|
|
|
|
|
if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS)
|
2019-01-25 20:32:26 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
CSettingConfig SettingConfig(true);
|
|
|
|
SettingConfig.Display(hWnd);
|
|
|
|
}
|
|
|
|
else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
|
|
|
|
{
|
|
|
|
g_Enhancements->ResetActive(nullptr);
|
|
|
|
g_Enhancements->LoadActive(nullptr, nullptr);
|
|
|
|
_this->m_CheatsUI.Display(hWnd, true);
|
|
|
|
}
|
|
|
|
else if (LOWORD(wParam) == ID_POPUPMENU_CHOOSEENHANCEMENT)
|
|
|
|
{
|
|
|
|
g_Enhancements->LoadActive(nullptr, nullptr);
|
|
|
|
_this->m_EnhancementUI.Display(hWnd, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_Rom)
|
|
|
|
{
|
|
|
|
g_Rom->SaveRomSettingID(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Rom.ClearRomSettingID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CN64Disk Disk;
|
|
|
|
Disk.LoadDiskImage(_this->CurrentedSelectedRom());
|
|
|
|
Disk.SaveDiskSettingID(true);
|
|
|
|
|
|
|
|
if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS)
|
|
|
|
{
|
|
|
|
CSettingConfig SettingConfig(true);
|
|
|
|
SettingConfig.Display(hWnd);
|
|
|
|
}
|
|
|
|
else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
|
|
|
|
{
|
|
|
|
CCheatsUI().Display(hWnd, true);
|
2019-01-25 20:32:26 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
|
|
|
|
if (g_Disk)
|
|
|
|
{
|
|
|
|
g_Disk->SaveDiskSettingID(false);
|
|
|
|
}
|
|
|
|
else
|
2016-04-12 08:07:01 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
Disk.ClearDiskSettingID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (_this->m_Menu)
|
|
|
|
{
|
|
|
|
if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100)
|
|
|
|
{
|
|
|
|
if (g_Plugins->RSP())
|
2019-01-25 20:32:26 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam));
|
2019-01-25 20:32:26 +00:00
|
|
|
}
|
2016-04-12 08:07:01 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
if (g_Plugins->Gfx())
|
|
|
|
{
|
|
|
|
WriteTrace(TraceVideoPlugin, TraceDebug, "Starting");
|
|
|
|
g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam));
|
|
|
|
WriteTrace(TraceVideoPlugin, TraceDebug, "Done");
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300)
|
2016-04-12 08:07:01 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != nullptr)
|
2019-01-25 20:32:26 +00:00
|
|
|
{
|
|
|
|
CN64Rom Rom;
|
2022-09-21 05:16:07 +00:00
|
|
|
if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(), true))
|
2019-01-25 20:32:26 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
break;
|
2019-01-25 20:32:26 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
Rom.SaveRomSettingID(true);
|
|
|
|
g_Notify->DisplayMessage(0, EMPTY_STRING);
|
|
|
|
BYTE * RomHeader = Rom.GetRomAddress();
|
|
|
|
WriteTrace(TraceVideoPlugin, TraceDebug, "OnRomBrowserMenuItem - Starting");
|
|
|
|
g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader);
|
|
|
|
WriteTrace(TraceVideoPlugin, TraceDebug, "OnRomBrowserMenuItem - Done");
|
2019-01-25 20:32:26 +00:00
|
|
|
if (g_Rom)
|
|
|
|
{
|
|
|
|
g_Rom->SaveRomSettingID(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
g_Settings->SaveString(Game_IniKey, "");
|
2019-01-25 20:32:26 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam)))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
return true;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_DROPFILES:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
char filename[MAX_PATH];
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
HDROP hDrop = (HDROP)wParam;
|
|
|
|
DragQueryFileA(hDrop, 0, filename, sizeof(filename));
|
|
|
|
DragFinish(hDrop);
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
stdstr ext = CPath(filename).GetExtension();
|
|
|
|
if ((!(_stricmp(ext.c_str(), "ndd") == 0)) && (!(_stricmp(ext.c_str(), "d64") == 0)))
|
|
|
|
{
|
|
|
|
CN64System::RunFileImage(filename);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
CN64System::RunDiskImage(filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case WM_DESTROY:
|
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - start");
|
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
|
2016-01-27 09:11:59 +00:00
|
|
|
if (_this->m_bMainWindow)
|
|
|
|
{
|
|
|
|
Notify().WindowMode();
|
|
|
|
}
|
2021-04-12 11:35:39 +00:00
|
|
|
_this->m_hMainWindow = nullptr;
|
2016-01-27 09:11:59 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - 1");
|
|
|
|
if (_this->m_bMainWindow)
|
|
|
|
{
|
|
|
|
_this->SaveRomListColoumnInfo();
|
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - 2");
|
|
|
|
_this->SaveWindowLoc();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - 3");
|
2020-05-12 12:19:05 +00:00
|
|
|
RemoveProp(hWnd, L"Class");
|
2016-01-27 09:11:59 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - 4");
|
|
|
|
PostQuitMessage(0);
|
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - Done");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2021-03-17 08:36:30 +00:00
|
|
|
}
|