Hotkey selected state cleanup. Sync gui menu selected state when state changes occur via hotkeys. Removed deprecated gtk widgets from sdl/input.cpp.
This commit is contained in:
parent
3573a596e9
commit
c3e4db0faa
|
@ -59,15 +59,15 @@ GtkWidget *evbox = NULL;
|
|||
GtkWidget *padNoCombo = NULL;
|
||||
GtkWidget *configNoCombo = NULL;
|
||||
GtkWidget *buttonMappings[10];
|
||||
GtkWidget *Menubar;
|
||||
GtkRadioAction *stateSlot = NULL;
|
||||
static GtkWidget *Menubar = NULL;
|
||||
static GtkRadioMenuItem *stateSlot[10] = { NULL };
|
||||
bool gtkIsStarted = false;
|
||||
bool menuTogglingEnabled = false;
|
||||
|
||||
unsigned int gtk_draw_area_width = NES_WIDTH;
|
||||
unsigned int gtk_draw_area_height = NES_HEIGHT;
|
||||
static unsigned int gtk_win_width = NES_WIDTH;
|
||||
static unsigned int gtk_win_height = NES_HEIGHT;
|
||||
static unsigned int gtk_win_width = 0;
|
||||
static unsigned int gtk_win_height = 0;
|
||||
static GtkTreeStore *hotkey_store = NULL;
|
||||
|
||||
// check to see if a particular GTK version is available
|
||||
|
@ -2168,11 +2168,18 @@ void quickSave (void)
|
|||
FCEUI_SaveState (NULL);
|
||||
}
|
||||
|
||||
//void changeState(GtkAction *action, GtkRadioAction *current, gpointer data)
|
||||
void changeState (GtkRadioMenuItem * radiomenuitem, gpointer user_data)
|
||||
void setStateMenuItem( int i )
|
||||
{
|
||||
//printf("Changing State: %li\n", (long)user_data);
|
||||
FCEUI_SelectState ((long) user_data, 0);
|
||||
if ( (i >= 0) && (i < 10) )
|
||||
{
|
||||
gtk_menu_item_activate( GTK_MENU_ITEM(stateSlot[i]) );
|
||||
}
|
||||
}
|
||||
|
||||
static void changeState (GtkRadioMenuItem * radiomenuitem, gpointer user_data)
|
||||
{
|
||||
printf("GTK Changing State: %li\n", (long)user_data);
|
||||
FCEUI_SelectState ((long) user_data, 1);
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
|
@ -2526,6 +2533,8 @@ static GtkWidget *CreateMenubar (GtkWidget * window)
|
|||
|
||||
item = gtk_radio_menu_item_new_with_label (radioGroup, stmp);
|
||||
|
||||
stateSlot[i] = GTK_RADIO_MENU_ITEM(item);
|
||||
|
||||
radioGroup =
|
||||
gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM
|
||||
(item));
|
||||
|
@ -3015,7 +3024,7 @@ gboolean handle_resize (GtkWindow * win, GdkEvent * event, gpointer data)
|
|||
// of the GTK window as possible
|
||||
|
||||
// get new window width/height
|
||||
int width, height, winsize_changed;
|
||||
int width, height, draw_width, draw_height, winsize_changed = 0;
|
||||
width = event->configure.width;
|
||||
height = event->configure.height;
|
||||
//printf ("DEBUG: Configure new window size: %dx%d\n", width, height);
|
||||
|
@ -3029,8 +3038,15 @@ gboolean handle_resize (GtkWindow * win, GdkEvent * event, gpointer data)
|
|||
double xscale = width / (double) NES_WIDTH;
|
||||
double yscale = height / (double) NES_HEIGHT;
|
||||
|
||||
gtk_draw_area_width = gtk_widget_get_allocated_width (evbox);
|
||||
gtk_draw_area_height = gtk_widget_get_allocated_height (evbox);
|
||||
draw_width = gtk_widget_get_allocated_width (evbox);
|
||||
draw_height = gtk_widget_get_allocated_height (evbox);
|
||||
|
||||
if ( (draw_width != gtk_draw_area_width) || (draw_height != gtk_draw_area_height) )
|
||||
{
|
||||
winsize_changed = 1;
|
||||
}
|
||||
gtk_draw_area_width = draw_width;
|
||||
gtk_draw_area_height = draw_height;
|
||||
|
||||
if ( gtk_draw_area_width < NES_WIDTH ) gtk_draw_area_width = NES_WIDTH;
|
||||
if ( gtk_draw_area_height < NES_HEIGHT ) gtk_draw_area_height = NES_HEIGHT;
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#endif
|
||||
extern GtkWidget* MainWindow;
|
||||
extern GtkWidget* evbox;
|
||||
extern GtkRadioAction* stateSlot;
|
||||
extern int GtkMouseData[3];
|
||||
extern bool gtkIsStarted;
|
||||
|
||||
|
@ -55,6 +54,8 @@ void setGl(GtkWidget* w, gpointer p);
|
|||
void setDoubleBuffering(GtkWidget* w, gpointer p);
|
||||
#endif
|
||||
|
||||
void setStateMenuItem( int i );
|
||||
|
||||
void openVideoConfig();
|
||||
void openSoundConfig();
|
||||
void quit ();
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "../../movie.h"
|
||||
#include "../../fceu.h"
|
||||
#include "../../driver.h"
|
||||
#include "../../state.h"
|
||||
#include "../../utils/xstring.h"
|
||||
#ifdef _S9XLUA_H
|
||||
#include "../../fceulua.h"
|
||||
|
@ -281,16 +282,16 @@ std::string GetFilename (const char *title, bool save, const char *filter)
|
|||
if (save)
|
||||
fileChooser = gtk_file_chooser_dialog_new ("Save as", NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
GTK_STOCK_CANCEL,
|
||||
"_Cancel",
|
||||
GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_SAVE_AS,
|
||||
"_Save",
|
||||
GTK_RESPONSE_ACCEPT, NULL);
|
||||
else
|
||||
fileChooser = gtk_file_chooser_dialog_new ("Open", NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
GTK_STOCK_CANCEL,
|
||||
"_Cancel",
|
||||
GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OPEN,
|
||||
"_Open",
|
||||
GTK_RESPONSE_ACCEPT, NULL);
|
||||
|
||||
// TODO: make file filters case insensitive
|
||||
|
@ -739,22 +740,30 @@ static void KeyboardCommands ()
|
|||
#endif
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
if (_keyonly (Hotkeys[HK_SELECT_STATE_0 + i]))
|
||||
{
|
||||
#ifdef _GTK
|
||||
gtk_radio_action_set_current_value (stateSlot, i);
|
||||
setStateMenuItem(i);
|
||||
#endif
|
||||
FCEUI_SelectState (i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (_keyonly (Hotkeys[HK_SELECT_STATE_NEXT]))
|
||||
{
|
||||
FCEUI_SelectStateNext (1);
|
||||
#ifdef _GTK
|
||||
setStateMenuItem( CurrentState );
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_keyonly (Hotkeys[HK_SELECT_STATE_PREV]))
|
||||
{
|
||||
FCEUI_SelectStateNext (-1);
|
||||
#ifdef _GTK
|
||||
setStateMenuItem( CurrentState );
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_keyonly (Hotkeys[HK_BIND_STATE]))
|
||||
|
@ -1685,13 +1694,13 @@ const char * ButtonName (const ButtConfig * bc, int which)
|
|||
inputValue = bc->ButtonNum[which] & 0xF;
|
||||
|
||||
if (inputValue & SDL_HAT_UP)
|
||||
strncat (direction, "Up ", sizeof (direction));
|
||||
strncat (direction, "Up ", sizeof (direction)-1);
|
||||
if (inputValue & SDL_HAT_DOWN)
|
||||
strncat (direction, "Down ", sizeof (direction));
|
||||
strncat (direction, "Down ", sizeof (direction)-1);
|
||||
if (inputValue & SDL_HAT_LEFT)
|
||||
strncat (direction, "Left ", sizeof (direction));
|
||||
strncat (direction, "Left ", sizeof (direction)-1);
|
||||
if (inputValue & SDL_HAT_RIGHT)
|
||||
strncat (direction, "Right ", sizeof (direction));
|
||||
strncat (direction, "Right ", sizeof (direction)-1);
|
||||
|
||||
if (direction[0])
|
||||
inputDirection = direction;
|
||||
|
@ -2127,7 +2136,7 @@ UpdateInput (Config * config)
|
|||
for (unsigned int i = 0; i < GAMEPAD_NUM_DEVICES; i++)
|
||||
{
|
||||
char buf[64];
|
||||
snprintf (buf, 20, "SDL.Input.GamePad.%d.", i);
|
||||
snprintf (buf, 32, "SDL.Input.GamePad.%d.", i);
|
||||
prefix = buf;
|
||||
|
||||
config->getOption (prefix + "DeviceType", &device);
|
||||
|
@ -2160,7 +2169,7 @@ UpdateInput (Config * config)
|
|||
for (unsigned int i = 0; i < POWERPAD_NUM_DEVICES; i++)
|
||||
{
|
||||
char buf[64];
|
||||
snprintf (buf, 20, "SDL.Input.PowerPad.%d.", i);
|
||||
snprintf (buf, 32, "SDL.Input.PowerPad.%d.", i);
|
||||
prefix = buf;
|
||||
|
||||
config->getOption (prefix + "DeviceType", &device);
|
||||
|
|
Loading…
Reference in New Issue