Commit 9a7ca63f authored by bbbradsmith's avatar bbbradsmith
Browse files

start to exit GUI, ability to savestate into and out of GUI

parent d79d4a6e
......@@ -62,7 +62,7 @@ A Auto-Fire / Right mouse button
Y Toggle virtual keyboard Shift
X Show/hide virtual keyboard
SEL Toggle Joystick / Mouse mode
STR Hatari GUI
STR Enter/Exit Hatari GUI
L Show/Hide status
R Select virtual keyboard page
L2 Lower Mouse Speed (1-6) for gui and emu
......
......@@ -54,13 +54,12 @@ void Dialog_AboutDlg(void)
aboutdlg[1].x = (aboutdlg[0].w - strlen(PROG_NAME)) / 2;
SDLGui_CenterDlg(aboutdlg);
do
do
{
but=SDLGui_DoDialog(aboutdlg, NULL);
gui_poll_events();
}
while (but != DLGABOUT_EXIT && but != SDLGUI_QUIT
but=SDLGui_DoDialog(aboutdlg, NULL);
if (gui_poll_events()) break;
}
while (but != DLGABOUT_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
}
......@@ -171,11 +171,10 @@ static int DlgAlert_ShowDlg(const char *text)
bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY);
SDL_ShowCursor(SDL_ENABLE);
do
{
i = SDLGui_DoDialog(alertdlg, NULL);
gui_poll_events();
do
{
i = SDLGui_DoDialog(alertdlg, NULL);
if (gui_poll_events()) break;
}
while (i != DLGALERT_OK && i != DLGALERT_CANCEL && i != SDLGUI_QUIT
&& i != SDLGUI_ERROR && !bQuitProgram);
......
......@@ -145,7 +145,7 @@ void Dialog_DeviceDlg(void)
true);
break;
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DEVDLG_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
......
......@@ -833,7 +833,7 @@ char* SDLGui_FileSelect(const char *title,const char *path_and_name, char **zip_
scrollbar_Ypos = 0.0;
}
} /* other button code */
gui_poll_events();
if (gui_poll_events()) retbut=SGFSDLG_CANCEL;
} /* do */
while (retbut!=SGFSDLG_OKAY && retbut!=SGFSDLG_CANCEL
......
......@@ -289,7 +289,7 @@ void DlgFloppy_Main(void)
}
break;
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != FLOPPYDLG_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
......
......@@ -211,7 +211,7 @@ printf("skip: %d\n", ConfigureParams.HardDisk.nHardDiskDrive);
ConfigureParams.HardDisk.bUseHardDiskDirectories = true;
break;
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DISKDLG_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
......
......@@ -260,7 +260,7 @@ void Dialog_JoyDlg(void)
}
break;
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DLGJOY_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
......
......@@ -82,7 +82,7 @@ void Dialog_KeyboardDlg(void)
ConfigureParams.Keyboard.szMappingFileName,
keyboarddlg[DLGKEY_MAPNAME].w, false);
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DLGKEY_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
......
......@@ -160,8 +160,7 @@ int Dialog_MainDlg(bool *bReset, bool *bLoadedSnapshot)
bQuitProgram = true;
break;
}
gui_poll_events();
if (gui_poll_events()) retbut = MAINDLG_CANCEL;
}
while (retbut != MAINDLG_OK && retbut != MAINDLG_CANCEL && retbut != SDLGUI_QUIT
&& retbut != SDLGUI_ERROR && !bQuitProgram);
......
......@@ -130,7 +130,7 @@ bool Dialog_MemDlg(void)
}
break;
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DLGMEM_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram );
......
......@@ -146,7 +146,7 @@ char *DlgNewDisk_Main(void)
}
break;
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DLGNEWDISK_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
......
......@@ -87,7 +87,7 @@ void DlgRom_Main(void)
false);
break;
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DLGROM_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
......
......@@ -265,7 +265,7 @@ void Dialog_MonitorDlg(void)
sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
break;
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DLGSCRN_EXIT_MONITOR && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
......@@ -411,7 +411,7 @@ void Dialog_WindowDlg(void)
}
break;
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DLGSCRN_EXIT_WINDOW && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
......
......@@ -171,7 +171,7 @@ void Dialog_SoundDlg(void)
}
break;
}
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DLGSOUND_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram );
......
......@@ -257,13 +257,12 @@ void Dialog_SystemDlg(void)
int but;
do
{
/* Show the dialog: */
but=SDLGui_DoDialog(systemdlg, NULL);
gui_poll_events();
if (gui_poll_events()) break;
}
while (but != DLGSYS_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram);
&& but != SDLGUI_ERROR && !bQuitProgram);
/* Read values from dialog: */
......
......@@ -51,9 +51,9 @@ char RPATH[512];
int NPAGE=-1, KCOL=1, BKGCOLOR=0, MAXPAS=6;
int SHIFTON=-1,MOUSEMODE=-1,SHOWKEY=-1,PAS=4,STATUTON=-1;
int SND=1; //SOUND ON/OFF
int firstps=0;
int pauseg=0; //enter_gui
int slowdown=0;
int exitgui=0; // exit gui (not serialized)
//JOY
int al[2];//left analog1
......@@ -124,7 +124,7 @@ static bool hatari_mapper_serialize_bidi(char* data, char version)
serialize_int(&gmx);
serialize_int(&gmy);
int NUMjoy=0; serialize_int(&NUMjoy); // this variable was removed
serialize_int(&firstps);
int firstps=0; serialize_int(&firstps); // this variable was removed
serialize_int(&mbL);
serialize_int(&mbR);
serialize_int(&mmbL);
......@@ -154,7 +154,12 @@ bool hatari_mapper_unserialize(const char* data, char version)
serialize_forward = false;
int pauseg_old = pauseg;
bool result = hatari_mapper_serialize_bidi((char*)data, version);
if (pauseg_old) pauseg = pauseg_old; // because of the co-thread implementation there's really no way to save-state out of the GUI, so: stay paused
exitgui = 0;
if (pauseg_old && !pauseg) // want to exit GUI, turn pauseg back on and tell it to exit on its own
{
pauseg = pauseg_old;
exitgui = 1;
}
return result;
}
......@@ -205,10 +210,11 @@ long GetTicks(void)
}
//NO SURE FIND BETTER WAY TO COME BACK IN MAIN THREAD IN HATARI GUI
void gui_poll_events(void)
bool gui_poll_events(void)
{
slowdown=0;
co_switch(mainThread);
return (exitgui != 0);
}
//save bkg for screenshot
......@@ -318,21 +324,12 @@ void texture_init(void)
void enter_gui(void)
{
save_bkg();
exitgui=0;
pauseg=1; // should already be set
Dialog_DoProperty();
pauseg=0;
}
void pause_select(void)
{
if(pauseg==1 && firstps==0)
{
firstps=1;
enter_gui();
firstps=0;
}
}
void Print_Statut(void)
{
STAT_BASEY=CROP_HEIGHT+24;
......@@ -435,7 +432,7 @@ void Deadzone(int* a)
L2 MOUSE SPEED DOWN (gui/emu)
R2 MOUSE SPEED UP(gui/emu)
SEL toggle mouse/joy mode
STR Hatari Gui
STR Hatari Gui / Exit Gui
B fire/mouse-left/valid key in vkbd
A mouse-right
Y switch Shift ON/OFF
......@@ -466,8 +463,11 @@ void update_input(void)
Process_key();
i=RETRO_DEVICE_ID_JOYPAD_START;// Hatari GUI
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 )
mbt[i]=1;
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
{
mbt[i]=0;
pauseg=1;
}
......@@ -820,6 +820,17 @@ void input_gui(void)
PAS++;if(PAS>MAXPAS)PAS=1;
}
// START to exit GUI
i=RETRO_DEVICE_ID_JOYPAD_START;
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 )
mbt[i]=1;
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
{
mbt[i]=0;
exitgui=1;
}
//emulate mouse with joy analog left
al[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X));
al[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y));
......@@ -885,6 +896,4 @@ void input_gui(void)
gmy=0;
if (gmy>retroh-1)
gmy=retroh-1;
// TODO could pressing START act like "escape" for the purpose of quitting the GUI back to game?
}
......@@ -18,7 +18,7 @@
#include "graph.h"
extern void gui_poll_events();
extern bool gui_poll_events();
extern int GuiGetMouseState( int * x,int * y);
extern int pauseg;
......@@ -19,7 +19,7 @@ extern char RETRO_DIR[512];
extern char RETRO_TOS[512];
extern char RPATH[512];
extern long GetTicks(void);
extern void pause_select();
extern void enter_gui();
extern int LoadTosFromRetroSystemDir();
extern void retro_shutdown_hatari(void);
......
......@@ -312,7 +312,7 @@ void Main_WaitOnVbl(void)
Sint64 nDelay;
#ifdef __LIBRETRO__
if(pauseg==1)pause_select();
if(pauseg==1)enter_gui();
co_switch(mainThread);
#if defined(WIIU) || defined(VITA)
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment