[Project64] Split cheat class between UI and code

This commit is contained in:
zilmar 2015-11-07 14:32:23 +11:00
parent 45a8598290
commit 9f87dbf30d
16 changed files with 2776 additions and 2667 deletions

File diff suppressed because it is too large Load Diff

View File

@ -13,79 +13,36 @@
class CCheats
{
public:
CCheats ( const CN64Rom * Rom = NULL );
CCheats();
~CCheats(void);
bool IsCheatMessage ( MSG * msg );
enum
{
MaxCheats = 50000,
MaxGSEntries = 100,
};
void ApplyCheats(CMipsMemory * MMU);
void ApplyGSButton(CMipsMemory * MMU);
void LoadCheats(bool DisableSelected, CPlugins * Plugins);
void SelectCheats ( HWND hParent, bool BlockExecution );
inline bool CheatsSlectionChanged ( void ) const { return m_CheatSelectionChanged; }
static bool IsValid16BitCode(const char * CheatString);
private:
struct GAMESHARK_CODE {
DWORD Command;
WORD Value;
struct GAMESHARK_CODE
{
uint32_t Command;
uint16_t Value;
};
typedef std::vector<GAMESHARK_CODE> CODES;
typedef std::vector<CODES> CODES_ARRAY;
enum { MaxCheats = 50000 };
void LoadPermCheats(CPlugins * Plugins);
static int CALLBACK CheatAddProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
static int CALLBACK CheatListProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
static int CALLBACK ManageCheatsProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
static int CALLBACK CheatsCodeExProc ( HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam);
static int CALLBACK CheatsCodeQuantProc ( HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam);
//information about the gui for selecting cheats
HWND m_Window, m_hSelectCheat, m_AddCheat, m_hCheatTree, m_hSelectedItem;
const CN64Rom * m_Rom;
void * const m_rcList, * const m_rcAdd;
int m_MinSizeDlg, m_MaxSizeDlg;
int m_EditCheat;
bool m_DeleteingEntries;
CODES_ARRAY m_Codes;
bool m_CheatSelectionChanged;
//Information about the current cheat we are editing
stdstr m_EditName;
stdstr m_EditCode;
stdstr m_EditOptions;
stdstr m_EditNotes;
enum Dialog_State { CONTRACTED, EXPANDED } m_DialogState;
enum TV_CHECK_STATE { TV_STATE_UNKNOWN, TV_STATE_CLEAR, TV_STATE_CHECKED, TV_STATE_INDETERMINATE };
enum { MaxGSEntries = 100, IDC_MYTREE = 0x500 };
bool LoadCode ( int CheatNo, LPCSTR CheatString );
void AddCodeLayers ( int CheatNumber, const stdstr &CheatName, HWND hParent, bool CheatActive );
//Reload the cheats from the ini file to the select gui
void RefreshCheatManager ();
void ChangeChildrenStatus ( HWND hParent, bool Checked );
void CheckParentStatus ( HWND hParent );
static stdstr ReadCodeString ( HWND hDlg, bool &validcodes, bool &validoption, bool &nooptions, int &codeformat );
static stdstr ReadOptionsString( HWND hDlg, bool &validcodes, bool &validoptions, bool &nooptions, int &codeformat );
int ApplyCheatEntry (CMipsMemory * MMU,const CODES & CodeEntry, int CurrentEntry, bool Execute );
void RecordCheatValues ( HWND hDlg );
bool CheatChanged ( HWND hDlg );
bool IsValid16BitCode ( LPCSTR CheatString ) const;
void DeleteCheat(int Index);
//Get Information about the Cheat
stdstr GetCheatName ( int CheatNo, bool AddExtension ) const;
static bool CheatUsesCodeExtensions ( const stdstr &LineEntry );
//Working with treeview
static bool TV_SetCheckState(HWND hwndTreeView, HWND hItem, TV_CHECK_STATE state);
static int TV_GetCheckState(HWND hwndTreeView, HWND hItem);
static DWORD AsciiToHex ( const char * HexValue );
static void MenuSetText ( HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut );
//UI Functions
static stdstr GetDlgItemStr (HWND hDlg, int nIDDlgItem);
bool LoadCode(int32_t CheatNo, const char * CheatString);
int32_t ApplyCheatEntry(CMipsMemory * MMU, const CODES & CodeEntry, int32_t CurrentEntry, bool Execute);
};

View File

@ -125,8 +125,9 @@ void CSystemEvents::ExecuteEvents()
Notify().ChangeFullScreen();
break;
case SysEvent_GSButtonPressed:
if (m_System->m_Cheats.CheatsSlectionChanged())
if (m_System->HasCheatsSlectionChanged())
{
m_System->SetCheatsSlectionChanged(false);
m_System->m_Cheats.LoadCheats(false, m_Plugins);
}
m_System->m_Cheats.ApplyGSButton(g_MMU);
@ -195,6 +196,14 @@ void CSystemEvents::ExecuteEvents()
bPause = true;
}
break;
case SysEvent_PauseCPU_Cheats:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{
g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_Cheats);
bPause = true;
}
break;
default:
g_Notify->BreakPoint(__FILEW__, __LINE__);
break;

View File

@ -27,6 +27,7 @@ enum SystemEvent
SysEvent_PauseCPU_DumpMemory,
SysEvent_PauseCPU_SearchMemory,
SysEvent_PauseCPU_Settings,
SysEvent_PauseCPU_Cheats,
SysEvent_ResumeCPU_FromMenu,
SysEvent_ResumeCPU_AppGainedActive,
SysEvent_ResumeCPU_AppGainedFocus,
@ -35,6 +36,7 @@ enum SystemEvent
SysEvent_ResumeCPU_DumpMemory,
SysEvent_ResumeCPU_SearchMemory,
SysEvent_ResumeCPU_Settings,
SysEvent_ResumeCPU_Cheats,
SysEvent_ChangingFullScreen,
SysEvent_ChangePlugins,
SysEvent_SaveMachineState,

View File

@ -17,7 +17,6 @@
CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly) :
CSystemEvents(this, Plugins),
m_Cheats(NULL),
m_EndEmulation(false),
m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)),
m_Plugins(Plugins),
@ -42,7 +41,8 @@ CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) :
m_TLBStoreAddress(0),
m_SyncCount(0),
m_CPU_Handle(NULL),
m_CPU_ThreadID(0)
m_CPU_ThreadID(0),
m_CheatsSlectionChanged(false)
{
DWORD gameHertz = g_Settings->LoadDword(Game_ScreenHertz);
if (gameHertz == 0)
@ -115,6 +115,7 @@ void CN64System::ExternalEvent ( SystemEvent action )
case SysEvent_PauseCPU_DumpMemory:
case SysEvent_PauseCPU_SearchMemory:
case SysEvent_PauseCPU_Settings:
case SysEvent_PauseCPU_Cheats:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{
QueueEvent(action);
@ -166,6 +167,12 @@ void CN64System::ExternalEvent ( SystemEvent action )
SetEvent(m_hPauseEvent);
}
break;
case SysEvent_ResumeCPU_Cheats:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Cheats)
{
SetEvent(m_hPauseEvent);
}
break;
default:
WriteTraceF(TraceError, __FUNCTION__ ": Unknown event %d", action);
g_Notify->BreakPoint(__FILEW__, __LINE__);
@ -453,11 +460,6 @@ void CN64System::CloseCpu()
CpuStopped();
}
void CN64System::SelectCheats ( HWND hParent )
{
m_Cheats.SelectCheats(hParent,false);
}
void CN64System::DisplayRomInfo ( HWND hParent )
{
if (!g_Rom) { return; }
@ -508,15 +510,6 @@ stdstr CN64System::ChooseFileToOpen ( HWND hParent )
return stdstr("");
}
bool CN64System::IsDialogMsg( MSG * msg )
{
if (m_Cheats.IsCheatMessage(msg))
{
return true;
}
return false;
}
void CN64System::GameReset()
{
m_SystemTimer.SetTimer(CSystemTimer::SoftResetTimer,0x3000000,false);
@ -2053,15 +2046,16 @@ void CN64System::RefreshScreen()
}
if ((m_Reg.STATUS_REGISTER & STATUS_IE) != 0)
{
if (g_BaseSystem == NULL)
if (HasCheatsSlectionChanged())
{
return;
}
if (g_BaseSystem->m_Cheats.CheatsSlectionChanged())
if (this == g_BaseSystem && g_SyncSystem != NULL)
{
g_BaseSystem->m_Cheats.LoadCheats(false, g_BaseSystem->m_Plugins);
g_SyncSystem->SetCheatsSlectionChanged(true);
}
g_BaseSystem->m_Cheats.ApplyCheats(g_MMU);
SetCheatsSlectionChanged(false);
m_Cheats.LoadCheats(false, g_BaseSystem->m_Plugins);
}
m_Cheats.ApplyCheats(g_MMU);
}
// if (bProfiling) { m_Profile.StartTimer(ProfilingAddr != Timer_None ? ProfilingAddr : Timer_R4300); }
}

View File

@ -50,10 +50,8 @@ public:
void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc..
stdstr ChooseFileToOpen ( HWND hParent );
void DisplayRomInfo ( HWND hParent );
void SelectCheats ( HWND hParent );
void StartEmulation ( bool NewThread );
void SyncToAudio ();
bool IsDialogMsg ( MSG * msg );
void IncreaseSpeed () { m_Limitor.IncreaseSpeed(); }
void DecreaseSpeed () { m_Limitor.DecreaseSpeed(); }
void Reset ( bool bInitReg, bool ClearMenory );
@ -68,6 +66,8 @@ public:
bool DmaUsed() const { return m_DMAUsed; }
void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; }
void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; }
bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; }
DWORD GetButtons(int Control) const { return m_Buttons[Control]; }
//Variable used to track that the SP is being handled and stays the same as the real SP in sync core
@ -144,6 +144,7 @@ private:
DWORD m_TLBLoadAddress;
DWORD m_TLBStoreAddress;
DWORD m_SyncCount;
bool m_CheatsSlectionChanged;
//When Syncing cores this is the PC where it last Sync'ed correctly
DWORD m_LastSuccessSyncPC[10];

View File

@ -26,17 +26,21 @@ enum PauseType
PauseType_DumpMemory,
PauseType_SearchMemory,
PauseType_Settings,
PauseType_Cheats,
};
enum CPU_TYPE {
enum CPU_TYPE
{
CPU_Default = -1, CPU_Interpreter = 1, CPU_Recompiler = 2, CPU_SyncCores = 3
};
enum FRAMERATE_TYPE {
enum FRAMERATE_TYPE
{
FR_VIs = 0, FR_DLs = 1, FR_PERCENT = 2,
};
enum SAVE_CHIP_TYPE {
enum SAVE_CHIP_TYPE
{
SaveChip_Auto = -1, SaveChip_Eeprom_4K, SaveChip_Eeprom_16K, SaveChip_Sram, SaveChip_FlashRam
};
@ -45,23 +49,27 @@ enum FUNC_LOOKUP_METHOD
FuncFind_Default = -1, FuncFind_PhysicalLookup = 1, FuncFind_VirtualLookup = 2, FuncFind_ChangeMemory = 3,
};
enum SYSTEM_TYPE {
enum SYSTEM_TYPE
{
SYSTEM_NTSC = 0, SYSTEM_PAL = 1, SYSTEM_MPAL = 2
};
enum CICChip {
enum CICChip
{
CIC_UNKNOWN = -1, CIC_NUS_6101 = 1, CIC_NUS_6102 = 2, CIC_NUS_6103 = 3,
CIC_NUS_6104 = 4, CIC_NUS_6105 = 5, CIC_NUS_6106 = 6, CIC_NUS_5167 = 7,
CIC_NUS_8303 = 8
};
enum Country {
enum Country
{
NTSC_BETA = 0x37, X_NTSC = 0x41, Germany = 0x44, USA = 0x45, french = 0x46, Italian = 0x49,
Japan = 0x4A, Europe = 0x50, Spanish = 0x53, Australia = 0x55, X_PAL = 0x58, Y_PAL = 0x59,
UnknownCountry = 0
};
enum SPECIAL_TIMERS {
enum SPECIAL_TIMERS
{
Timer_None = 0, Timer_R4300 = -1, Timer_RSP_Dlist = -2,
Timer_RSP_Alist = -3, Timer_RSP_Unknown = -5, Timer_RefreshScreen = -6,
Timer_UpdateScreen = -7, Timer_UpdateFPS = -9, Timer_Idel = -10,
@ -70,7 +78,8 @@ enum SPECIAL_TIMERS {
Timer_InheritParentInfo = -19, Timer_AddX86Code = -20,
};
enum STEP_TYPE {
enum STEP_TYPE
{
NORMAL = 0,
DO_DELAY_SLOT = 1,
DO_END_DELAY_SLOT = 2,
@ -84,3 +93,4 @@ enum STEP_TYPE {
PERMLOOP_DO_DELAY = 10,
PERMLOOP_DELAY_DONE = 11,
};

View File

@ -284,6 +284,10 @@
<Filter
Name="User Interface Source"
>
<File
RelativePath=".\User Interface\Cheat Class UI.cpp"
>
</File>
<File
RelativePath="User Interface\Frame Per Second Class.cpp"
>
@ -936,6 +940,10 @@
<Filter
Name="User Interface Headers"
>
<File
RelativePath=".\User Interface\Cheat Class UI.h"
>
</File>
<File
RelativePath="User Interface\Frame Per Second Class.h"
>

View File

@ -74,6 +74,7 @@
<ClCompile Include="Settings\SettingType\SettingsType-TempBool.cpp" />
<ClCompile Include="Settings\SettingType\SettingsType-TempNumber.cpp" />
<ClCompile Include="Settings\SettingType\SettingsType-TempString.cpp" />
<ClCompile Include="User Interface\Cheat Class UI.cpp" />
<ClCompile Include="User Interface\Frame Per Second Class.cpp" />
<ClCompile Include="User Interface\Gui Class.cpp" />
<ClCompile Include="User Interface\Main Menu Class.cpp" />
@ -186,6 +187,7 @@
<ClInclude Include="Settings.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="User Interface.h" />
<ClInclude Include="User Interface\Cheat Class UI.h" />
<ClInclude Include="Version.h" />
<ClInclude Include="WTL App.h" />
<ClInclude Include="Settings\Debug Settings.h" />

View File

@ -417,6 +417,9 @@
<ClCompile Include="Multilanguage\LanguageSelector.cpp">
<Filter>Source Files\Multilanguage Source</Filter>
</ClCompile>
<ClCompile Include="User Interface\Cheat Class UI.cpp">
<Filter>Source Files\User Interface Source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="User Interface\Bitmaps\AboutScreenBottom.bmp">
@ -842,5 +845,8 @@
<ClInclude Include="Multilanguage\LanguageSelector.h">
<Filter>Header Files\Multilanguage Headers</Filter>
</ClInclude>
<ClInclude Include="User Interface\Cheat Class UI.h">
<Filter>Header Files\User Interface Headers</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -61,3 +61,4 @@ class CN64System;
#include ".\\User Interface\\Frame Per Second Class.h"
#include ".\\User Interface\\resource.h"
#include ".\\User Interface\\Settings Config.h"
#include ".\\User Interface\\Cheat Class UI.h"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
class CCheatsUI
{
public:
CCheatsUI(void);
~CCheatsUI(void);
bool IsCheatMessage(MSG * msg);
void SelectCheats(HWND hParent, bool BlockExecution);
private:
static int CALLBACK CheatAddProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam);
static int CALLBACK CheatListProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam);
static int CALLBACK ManageCheatsProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam);
static int CALLBACK CheatsCodeExProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam);
static int CALLBACK CheatsCodeQuantProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam);
//information about the gui for selecting cheats
HWND m_Window, m_hSelectCheat, m_AddCheat, m_hCheatTree, m_hSelectedItem;
void * const m_rcList, *const m_rcAdd;
int m_MinSizeDlg, m_MaxSizeDlg;
int m_EditCheat;
bool m_DeleteingEntries;
//Information about the current cheat we are editing
stdstr m_EditName;
stdstr m_EditCode;
stdstr m_EditOptions;
stdstr m_EditNotes;
enum Dialog_State { CONTRACTED, EXPANDED } m_DialogState;
enum TV_CHECK_STATE { TV_STATE_UNKNOWN, TV_STATE_CLEAR, TV_STATE_CHECKED, TV_STATE_INDETERMINATE };
enum { IDC_MYTREE = 0x500 };
void AddCodeLayers(int CheatNumber, const stdstr &CheatName, HWND hParent, bool CheatActive);
//Reload the cheats from the ini file to the select gui
void RefreshCheatManager();
void ChangeChildrenStatus(HWND hParent, bool Checked);
void CheckParentStatus(HWND hParent);
static stdstr ReadCodeString(HWND hDlg, bool &validcodes, bool &validoption, bool &nooptions, int &codeformat);
static stdstr ReadOptionsString(HWND hDlg, bool &validcodes, bool &validoptions, bool &nooptions, int &codeformat);
void RecordCheatValues(HWND hDlg);
bool CheatChanged(HWND hDlg);
void DeleteCheat(int Index);
//Get Information about the Cheat
stdstr GetCheatName(int CheatNo, bool AddExtension) const;
static bool CheatUsesCodeExtensions(const stdstr &LineEntry);
//Working with treeview
static bool TV_SetCheckState(HWND hwndTreeView, HWND hItem, TV_CHECK_STATE state);
static int TV_GetCheckState(HWND hwndTreeView, HWND hItem);
static void MenuSetText(HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut);
//UI Functions
static stdstr GetDlgItemStr(HWND hDlg, int nIDDlgItem);
};
extern CCheatsUI * g_cheatUI;

View File

@ -10,7 +10,6 @@
****************************************************************************/
#include "stdafx.h"
#ifdef WINDOWS_UI
#include <commctrl.h>
#include "Settings/SettingType/SettingsType-Application.h"
@ -24,12 +23,7 @@ void EnterLogOptions(HWND hwndOwner);
DWORD CALLBACK AboutBoxProc(HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lParam);
LRESULT CALLBACK MainGui_Proc(HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lParam);
extern BOOL set_about_field(
HWND hDlg,
int nIDDlgItem,
const wchar_t * config_string,
const wchar_t * language_string
);
extern BOOL set_about_field(HWND hDlg, int nIDDlgItem, const wchar_t * config_string, const wchar_t * language_string);
CMainGui::CMainGui(bool bMainWindow, const char * WindowTitle) :
CRomBrowser(m_hMainWindow, m_hStatusWnd),
@ -63,7 +57,6 @@ CMainGui::CMainGui (bool bMainWindow, const char * WindowTitle ) :
//if this fails then it has already been created
RegisterWinClass();
Create(WindowTitle);
}
CMainGui::~CMainGui(void)
@ -112,7 +105,9 @@ void RomBowserEnabledChanged (CMainGui * Gui)
{
Gui->ShowRomList();
}
} else {
}
else
{
if (Gui->RomBrowserVisible())
{
Gui->HideRomList();
@ -150,12 +145,9 @@ void CMainGui::ChangeWinSize (long width, long height)
SetRect(&rc1, 0, 0, width, height);
}
AdjustWindowRectEx(&rc1, GetWindowLong(m_hMainWindow, GWL_STYLE), GetMenu(m_hMainWindow) != NULL, GetWindowLong(m_hMainWindow, GWL_EXSTYLE));
AdjustWindowRectEx( &rc1,GetWindowLong( m_hMainWindow, GWL_STYLE ),
GetMenu( m_hMainWindow ) != NULL, GetWindowLong( m_hMainWindow, GWL_EXSTYLE ) );
MoveWindow( m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top,
rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE );
MoveWindow(m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE);
}
void CMainGui::AboutBox(void)
@ -195,7 +187,6 @@ DWORD CALLBACK AboutIniBoxProc (HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lPa
EnableWindow(GetDlgItem(hDlg, IDC_LAN_VERSION), FALSE);
EnableWindow(GetDlgItem(hDlg, IDC_LAN_DATE), FALSE);
}
//RDB
CIniFile RdbIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
wcsncpy(String, RdbIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
@ -357,10 +348,11 @@ WPARAM CMainGui::ProcessAllMessages (void)
while (GetMessage(&msg, NULL, 0, 0))
{
if (g_BaseSystem && g_BaseSystem->IsDialogMsg(&msg))
if (g_cheatUI != NULL && g_cheatUI->IsCheatMessage(&msg))
{
continue;
}
if (m_ResetPlugins)
{
m_ResetPlugins = false;
@ -368,7 +360,7 @@ WPARAM CMainGui::ProcessAllMessages (void)
SetEvent(m_ResetInfo->hEvent);
m_ResetInfo = NULL;
}
//if (IsDialogMessage( hManageWindow,&msg)) { continue; }
if (g_cheatUI && g_cheatUI->IsCheatMessage(&msg)) { continue; }
if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; }
TranslateMessage(&msg);
DispatchMessage(&msg);
@ -376,7 +368,8 @@ WPARAM CMainGui::ProcessAllMessages (void)
return msg.wParam;
}
bool CMainGui::ProcessGuiMessages (void) {
bool CMainGui::ProcessGuiMessages(void)
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
@ -385,7 +378,8 @@ bool CMainGui::ProcessGuiMessages (void) {
{
m_ResetPlugins = false;
}
if (msg.message == WM_QUIT) {
if (msg.message == WM_QUIT)
{
return true;
}
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
@ -396,7 +390,8 @@ bool CMainGui::ProcessGuiMessages (void) {
return false;
}
void CMainGui::Resize (DWORD /*fwSizeType*/, WORD nWidth, WORD nHeight) {
void CMainGui::Resize(DWORD /*fwSizeType*/, WORD nWidth, WORD nHeight)
{
RECT clrect, swrect;
GetClientRect(m_hMainWindow, &clrect);
GetClientRect((HWND)m_hStatusWnd, &swrect);
@ -431,7 +426,8 @@ void CMainGui::EnterLogOptions (void)
::EnterLogOptions(m_hMainWindow);
}
int CMainGui::Height (void) {
int CMainGui::Height(void)
{
if (!m_hMainWindow) { return 0; }
RECT rect;
@ -483,7 +479,7 @@ void CMainGui::SetStatusText (int Panel,const wchar_t * Text)
static wchar_t Message[2][500];
if (Panel >= 2)
{
Notify().BreakPoint(__FILEW__,__LINE__);
g_Notify->BreakPoint(__FILEW__, __LINE__);
return;
}
wchar_t * Msg = Message[Panel];
@ -494,7 +490,8 @@ void CMainGui::SetStatusText (int Panel,const wchar_t * Text)
if (GetCurrentThreadId() == m_ThreadId)
{
SendMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg);
} else {
}
else {
PostMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg);
}
}
@ -553,7 +550,6 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
_this->SetPos(X, Y);
_this->ChangeWinSize(640, 480);
}
break;
case WM_SYSCOMMAND:
@ -574,8 +570,10 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
case SC_MAXIMIZE:
{
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
if (_this) {
if (_this->RomBrowserVisible()) {
if (_this)
{
if (_this->RomBrowserVisible())
{
_this->RomBrowserMaximize(true);
}
}
@ -617,7 +615,9 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
_this->m_SaveRomBrowserPos = true;
_this->m_SaveRomBrowserTop = WinRect.top;
_this->m_SaveRomBrowserLeft = WinRect.left;
} else {
}
else
{
_this->m_SaveMainWindowPos = true;
_this->m_SaveMainWindowTop = WinRect.top;
_this->m_SaveMainWindowLeft = WinRect.left;
@ -652,14 +652,17 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
{
if (wParam == SIZE_MAXIMIZED)
{
if (_this->RomBrowserVisible()) {
if (_this->RomBrowserVisible())
{
_this->RomBrowserMaximize(true);
}
}
_this->ResizeRomList(LOWORD(lParam), HIWORD(lParam));
}
if (_this) {
if (wParam == SIZE_RESTORED && _this->RomBrowserVisible()) {
if (_this)
{
if (wParam == SIZE_RESTORED && _this->RomBrowserVisible())
{
_this->RomBrowserMaximize(false);
}
}
@ -668,8 +671,10 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
case WM_NOTIFY:
{
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
if (_this) {
if (_this->RomBrowserVisible() && !_this->RomListNotify(wParam,lParam)) {
if (_this)
{
if (_this->RomBrowserVisible() && !_this->RomListNotify(wParam, lParam))
{
return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam);
}
}
@ -678,8 +683,10 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
case WM_DRAWITEM:
{
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
if (_this) {
if (!_this->RomListDrawItem(wParam,lParam)) {
if (_this)
{
if (!_this->RomListDrawItem(wParam, lParam))
{
return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam);
}
}
@ -770,7 +777,8 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
DWORD fActive = (BOOL)wParam;
if (fActive && _this->RomBrowserVisible()) {
if (fActive && _this->RomBrowserVisible())
{
PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0);
}
if (_this->m_bMainWindow && bCPURunning())
@ -792,13 +800,15 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
}
}
}
}
break;
case WM_HIDE_CUROSR:
if (!wParam) {
if (!wParam)
{
while (ShowCursor(FALSE) >= 0) { Sleep(0); }
} else {
}
else
{
while (ShowCursor(TRUE) < 0) { Sleep(0); }
}
break;
@ -819,7 +829,7 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
if (_this->m_ResetInfo != NULL)
{
Notify().BreakPoint(__FILEW__, __LINE__);
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
_this->m_ResetInfo = (RESET_PLUGIN *)lParam;
_this->m_ResetPlugins = true;
@ -846,11 +856,6 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
CN64Rom Rom;
Rom.LoadN64Image(_this->CurrentedSelectedRom(), true);
Rom.SaveRomSettingID(true);
/*if (g_Settings->LoadStringVal(ROM_MD5).length() == 0) {
Rom.LoadN64Image(_this->CurrentedSelectedRom(),false);
g_Settings->SaveString(ROM_MD5,Rom.GetRomMD5().c_str());
g_Settings->SaveString(ROM_InternalName,Rom.GetRomName().c_str());
}*/
if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS)
{
@ -858,33 +863,48 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
SettingConfig.Display(hWnd);
}
if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) {
CCheats RomCheats(&Rom);
RomCheats.SelectCheats(hWnd,true);
if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
{
CCheatsUI * cheatUI = new CCheatsUI;
g_cheatUI = cheatUI;
cheatUI->SelectCheats(hWnd, true);
if (g_cheatUI == cheatUI)
{
g_cheatUI = NULL;
}
}
if (g_Rom) {
if (g_Rom)
{
g_Rom->SaveRomSettingID(false);
} else {
}
else
{
Rom.ClearRomSettingID();
}
}
break;
default:
if (_this->m_Menu) {
if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100 ) {
if (_this->m_Menu)
{
if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100)
{
if (g_Plugins->RSP())
{
g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam));
}
} else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200 ) {
}
else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200)
{
if (g_Plugins->Gfx())
{
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting");
g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam));
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done");
}
} else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300 ) {
}
else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300)
{
if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != NULL)
{
CN64Rom Rom;
@ -898,13 +918,18 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Starting");
g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader);
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Done");
if (g_Rom) {
if (g_Rom)
{
g_Rom->SaveRomSettingID(false);
} else {
}
else
{
g_Settings->SaveString(Game_IniKey, "");
}
}
} else if (_this->m_Menu->ProcessMessage(hWnd,HIWORD(wParam), LOWORD(wParam))) {
}
else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam)))
{
return true;
}
}
@ -1015,7 +1040,6 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
pfnWndAboutBoxCancelProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hWnd, IDCANCEL), GWLP_WNDPROC);
::SetWindowLongPtr(GetDlgItem(hWnd, IDCANCEL), GWLP_WNDPROC, (LONG_PTR)AboutBoxCancelProc);
if (hbmpBackgroundTop)
{
// int iHeight = bmTL.bmHeight;
@ -1027,17 +1051,7 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
rect.bottom -= rect.top;
rect.top -= rect.top;
// Tweaked
HRGN hWindowRegion= CreateRoundRectRgn
(
rect.left,
rect.top,
rect.left+iWidth+GetSystemMetrics(SM_CXEDGE)-1,
rect.bottom+GetSystemMetrics(SM_CYEDGE)-1,
ROUND_EDGE,
ROUND_EDGE
);
HRGN hWindowRegion = CreateRoundRectRgn(rect.left, rect.top, rect.left + iWidth + GetSystemMetrics(SM_CXEDGE) - 1, rect.bottom + GetSystemMetrics(SM_CYEDGE) - 1, ROUND_EDGE, ROUND_EDGE);
if (hWindowRegion)
{
SetWindowRgn(hWnd, hWindowRegion, TRUE);
@ -1045,59 +1059,10 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
}
}
hTextFont = ::CreateFont
(
18,
0,
0,
0,
FW_NORMAL,
0,
0,
0,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
DEFAULT_PITCH|FF_DONTCARE,
"Arial"
);
hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
hAuthorFont = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
hAuthorFont = ::CreateFont
(
18,
0,
0,
0,
FW_BOLD,
0,
0,
0,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
DEFAULT_PITCH|FF_DONTCARE,
"Arial"
);
hPageHeadingFont = ::CreateFont
(
24,
0,
0,
0,
FW_BOLD,
0,
FALSE, //Show underlined?
0,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
DEFAULT_PITCH|FF_DONTCARE,
"Arial Bold"
);
hPageHeadingFont = ::CreateFont(24, 0, 0, 0, FW_BOLD, 0, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Bold");
SendDlgItemMessage(hWnd, IDC_VERSION, WM_SETFONT, (WPARAM)hTextFont, TRUE);
SendDlgItemMessage(hWnd, IDC_TEAM, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE);
@ -1115,7 +1080,6 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
SendDlgItemMessage(hWnd, IDC_THANK_LIST, WM_SETFONT, (WPARAM)hTextFont, TRUE);
//SetCapture(hWnd);
stdstr_f VersionDisplay("Version: %s", VER_FILE_VERSION_STR);
SetWindowText(GetDlgItem(hWnd, IDC_VERSION), VersionDisplay.c_str());
}
@ -1131,7 +1095,6 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
client.right += client.left;
client.bottom += client.top;
int nCaption = GetSystemMetrics(SM_CYCAPTION) * 4;
LRESULT lResult = HTCLIENT;
@ -1174,12 +1137,10 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
SelectObject(memdc, save);
DeleteDC(memdc);
memdc = CreateCompatibleDC(ps.hdc);
save = SelectObject(memdc, hbmpBackgroundMiddle);
for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight)
{
//BitBlt(ps.hdc, 0, bmTL_top.bmHeight, bmTL_Middle.bmWidth, rcClient.bottom - (bmTL_bottom.bmHeight + bmTL_top.bmHeight), memdc, 0, 0, SRCCOPY);
BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY);
}
SelectObject(memdc, save);
@ -1199,7 +1160,8 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
}
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
if (hbmpBackgroundTop)
@ -1215,13 +1177,17 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
DeleteObject(hbmpBackgroundMiddle);
}
if (hTextFont)
{
::DeleteObject(hTextFont);
}
if (hPageHeadingFont)
{
::DeleteObject(hPageHeadingFont);
}
if (hAuthorFont)
{
::DeleteObject(hAuthorFont);
}
//ReleaseCapture();
EndDialog(hWnd, 0);
break;
@ -1232,26 +1198,10 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
return TRUE;
}
BOOL set_about_field(
HWND hDlg,
int nIDDlgItem,
const wchar_t * config_string,
const wchar_t * language_string
)
BOOL set_about_field(HWND hDlg, int nIDDlgItem, const wchar_t * config_string, const wchar_t * language_string)
{
wchar_t temp_string[200];
swprintf(
temp_string,
sizeof(temp_string) / sizeof(temp_string[0]),
L"%s: %s",
config_string,
language_string
);
return SetDlgItemTextW(
hDlg,
nIDDlgItem,
temp_string
);
swprintf(temp_string, sizeof(temp_string) / sizeof(temp_string[0]), L"%s: %s", config_string, language_string);
return SetDlgItemTextW(hDlg, nIDDlgItem, temp_string);
}
#endif

View File

@ -129,5 +129,4 @@ private:
bool m_SaveRomBrowserPos;
LONG m_SaveRomBrowserTop;
LONG m_SaveRomBrowserLeft;
};

View File

@ -215,7 +215,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
break;
case ID_SYSTEM_CHEAT:
{
g_BaseSystem->SelectCheats(hWnd);
CCheatsUI * cheatUI = new CCheatsUI;
g_cheatUI = cheatUI;
cheatUI->SelectCheats(hWnd, false);
}
break;
case ID_SYSTEM_GSBUTTON: