Skip to content

Commit 8b509cc

Browse files
ejaquayejaquay
authored andcommitted
F10 brings up a fullscreen cartridge menu
Centered fd502, harddisk, mpi, and sdc config menus on screen so they don't end up in far top left corner when activated.
1 parent 47758f8 commit 8b509cc

File tree

8 files changed

+61
-5
lines changed

8 files changed

+61
-5
lines changed

FD502/fd502.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void LoadConfig(void);
6767
void SaveConfig(void);
6868
long CreateDiskHeader(char *,unsigned char,unsigned char,unsigned char);
6969
void Load_Disk(unsigned char);
70+
void CenterDialog(HWND hDlg);
7071

7172
static HWND g_hConfDlg;
7273
static HINSTANCE g_hinstDLL;
@@ -249,6 +250,15 @@ void CPUAssertInterupt(unsigned char Interupt,unsigned char Latencey)
249250
return;
250251
}
251252

253+
void CenterDialog(HWND hDlg)
254+
{
255+
RECT rPar, rDlg;
256+
GetWindowRect(GetParent(hDlg), &rPar);
257+
GetWindowRect(hDlg, &rDlg);
258+
int x = rPar.left + (rPar.right - rPar.left - (rDlg.right - rDlg.left)) / 2;
259+
int y = rPar.top + (rPar.bottom - rPar.top - (rDlg.bottom - rDlg.top)) / 2;
260+
SetWindowPos(hDlg, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
261+
}
252262

253263
LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
254264
{
@@ -262,6 +272,7 @@ LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
262272
switch (message)
263273
{
264274
case WM_INITDIALOG:
275+
CenterDialog(hDlg);
265276
TempSelectRom=SelectRom;
266277
if (!RealDisks)
267278
{

HardDisk/harddisk.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void LoadConfig(void);
5555
void SaveConfig(void);
5656
void BuildDynaMenu(void);
5757
int CreateDisk(HWND,int);
58+
void CenterDialog(HWND hDlg);
5859

5960
static HINSTANCE g_hinstDLL;
6061
static HWND hConfDlg = NULL;
@@ -142,12 +143,23 @@ extern "C"
142143
}
143144
}
144145

146+
void CenterDialog(HWND hDlg)
147+
{
148+
RECT rPar, rDlg;
149+
GetWindowRect(GetParent(hDlg), &rPar);
150+
GetWindowRect(hDlg, &rDlg);
151+
int x = rPar.left + (rPar.right - rPar.left - (rDlg.right - rDlg.left)) / 2;
152+
int y = rPar.top + (rPar.bottom - rPar.top - (rDlg.bottom - rDlg.top)) / 2;
153+
SetWindowPos(hDlg, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
154+
}
155+
145156
LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
146157
{
147158
switch (message)
148159
{
149160
case WM_INITDIALOG:
150161
hConfDlg=hDlg;
162+
CenterDialog(hDlg);
151163
SendDlgItemMessage(hDlg,IDC_CLOCK,BM_SETCHECK,ClockEnabled,0);
152164
SendDlgItemMessage(hDlg,IDC_READONLY,BM_SETCHECK,ClockReadOnly,0);
153165
EnableWindow(GetDlgItem(hDlg, IDC_CLOCK), TRUE);

Vcc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
528528
break;
529529

530530
case DIK_F10:
531+
if (!IsShiftKeyDown() && EmuState.FullScreen) {
532+
RECT r;
533+
HMENU hMenu=RefreshDynamicMenu();
534+
GetClientRect(hWnd,&r);
535+
TrackPopupMenu(hMenu, TPM_CENTERALIGN|TPM_VCENTERALIGN,
536+
r.right/2, r.bottom/2, 0, hWnd, NULL);
537+
}
531538
break;
532539

533540
case DIK_F11:

Vcc.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ BEGIN
172172
LTEXT " F7 Pause Toggle" IDC_STATIC,5,60,85,10
173173
LTEXT " F8 Toggle Throttle", IDC_STATIC,5,70,85,10
174174
LTEXT " F9 Stop/Start reset", IDC_STATIC,5,80,85,10
175-
LTEXT "F10 \t---", IDC_STATIC,5,90,85,10
175+
LTEXT "F10 Cartridge Menu", IDC_STATIC,5,90,85,10
176176
LTEXT "F11 Toggle Fullscreen", IDC_STATIC,5,100,85,10
177177
LTEXT "F12 Function Keys", IDC_STATIC,5,110,85,10
178178
LTEXT "Shifted", IDC_STATIC,110,8,50,10

mpi/mpi.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static unsigned int BankedCartOffset[MAXPAX]={0,0,0,0};
4444
static unsigned char Temp,Temp2;
4545
static char IniFile[MAX_PATH]="";
4646
static char MPIPath[MAX_PATH];
47+
void CenterDialog(HWND);
4748

4849
using namespace std;
4950

@@ -419,6 +420,16 @@ extern "C"
419420
}
420421
}
421422

423+
void CenterDialog(HWND hDlg)
424+
{
425+
RECT rPar, rDlg;
426+
GetWindowRect(GetParent(hDlg), &rPar);
427+
GetWindowRect(hDlg, &rDlg);
428+
int x = rPar.left + (rPar.right - rPar.left - (rDlg.right - rDlg.left)) / 2;
429+
int y = rPar.top + (rPar.bottom - rPar.top - (rDlg.bottom - rDlg.top)) / 2;
430+
SetWindowPos(hDlg, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
431+
}
432+
422433
LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
423434
{
424435
unsigned short EDITBOXS[4]={IDC_EDIT1,IDC_EDIT2,IDC_EDIT3,IDC_EDIT4};
@@ -434,7 +445,7 @@ LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
434445
EndDialog(hDlg, LOWORD(wParam));
435446

436447
case WM_INITDIALOG:
437-
448+
CenterDialog(hDlg);
438449
hConfDlg=hDlg;
439450
for (Temp=0;Temp<4;Temp++)
440451
SendDlgItemMessage(hDlg,EDITBOXS[Temp],WM_SETTEXT,0,(LPARAM)(LPCSTR) SlotLabel[Temp] );

pakinterface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ void DynamicMenuCallback(const char *MenuName,int MenuId, int Type)
521521
return;
522522
}
523523

524-
void RefreshDynamicMenu(void)
524+
HMENU RefreshDynamicMenu(void)
525525
{
526526
MENUITEMINFO Mii;
527527
char MenuTitle[32]="Cartridge";
@@ -613,6 +613,6 @@ void RefreshDynamicMenu(void)
613613
}
614614
}
615615
DrawMenuBar(EmuState.WindowHandle);
616-
return;
616+
return hSubMenu[0];
617617
}
618618

pakinterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void UpdateBusPointer(void);
3535
void UnloadDll(void);
3636
void UnloadPack(void);
3737
void DynamicMenuActivated(unsigned char );
38-
void RefreshDynamicMenu(void);
38+
HMENU RefreshDynamicMenu(void);
3939
#define ID_SDYNAMENU 5000 //Defines the start and end IDs for the dynamic menus
4040
#define ID_EDYNAMENU 5100
4141
#define NOMODULE 1

sdc/sdc.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ void LoadConfig(void);
140140
void SaveConfig(void);
141141
void BuildDynaMenu(void);
142142
void UpdateListBox(HWND);
143+
void CenterDialog(HWND);
143144
void UpdateCardBox(void);
144145
void UpdateFlashItem(void);
145146
void InitCardBox(void);
@@ -380,6 +381,19 @@ void BuildDynaMenu(void)
380381
DynamicMenuCallback("",1,0);
381382
}
382383

384+
//------------------------------------------------------------
385+
// Center a dialog box in parent window
386+
//------------------------------------------------------------
387+
void CenterDialog(HWND hDlg)
388+
{
389+
RECT rPar, rDlg;
390+
GetWindowRect(GetParent(hDlg), &rPar);
391+
GetWindowRect(hDlg, &rDlg);
392+
int x = rPar.left + (rPar.right - rPar.left - (rDlg.right - rDlg.left)) / 2;
393+
int y = rPar.top + (rPar.bottom - rPar.top - (rDlg.bottom - rDlg.top)) / 2;
394+
SetWindowPos(hDlg, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
395+
}
396+
383397
//------------------------------------------------------------
384398
// Configure the SDC
385399
//------------------------------------------------------------
@@ -391,6 +405,7 @@ SDC_Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
391405
EndDialog(hDlg,LOWORD(wParam));
392406
break;
393407
case WM_INITDIALOG:
408+
CenterDialog(hDlg);
394409
hConfDlg=hDlg;
395410
InitFlashBox();
396411
InitCardBox();

0 commit comments

Comments
 (0)