Search
lxdream.org :: lxdream :: r1040:9e3e41eab2db
lxdream 0.9.1
released Jun 29
Download Now
changeset1040:9e3e41eab2db
parent1039:98b9f0791bff
child1041:5fcc39857c5c
authornkeynes
dateThu Jun 25 21:21:18 2009 +0000 (10 years ago)
Add quick state bits to the menus
src/cocoaui/cocoa_gd.m
src/cocoaui/cocoaui.m
src/dreamcast.h
src/gtkui/gtkcb.c
src/gtkui/gtkui.c
src/gtkui/gtkui.h
1.1 --- a/src/cocoaui/cocoa_gd.m Thu Jun 25 09:06:44 2009 +0000
1.2 +++ b/src/cocoaui/cocoa_gd.m Thu Jun 25 21:21:18 2009 +0000
1.3 @@ -36,8 +36,12 @@
1.4 if( entry[0] == '\0' ) {
1.5 [menu addItem: [NSMenuItem separatorItem]];
1.6 } else {
1.7 + NSString *keyEquiv = @"";
1.8 + if( i == 0 ) {
1.9 + keyEquiv = @"e";
1.10 + }
1.11 [[menu addItemWithTitle: [NSString stringWithCString: entry]
1.12 - action: @selector(gdrom_list_action:) keyEquivalent: @""]
1.13 + action: @selector(gdrom_list_action:) keyEquivalent: keyEquiv]
1.14 setTag: i];
1.15 }
1.16 }
2.1 --- a/src/cocoaui/cocoaui.m Thu Jun 25 09:06:44 2009 +0000
2.2 +++ b/src/cocoaui/cocoaui.m Thu Jun 25 21:21:18 2009 +0000
2.3 @@ -90,6 +90,7 @@
2.4
2.5 static void cocoa_gui_create_menu(void)
2.6 {
2.7 + int i;
2.8 NSMenu *appleMenu, *services;
2.9 NSMenuItem *menuItem;
2.10 NSString *title;
2.11 @@ -137,6 +138,19 @@
2.12
2.13 NSMenu *gdromMenu = cocoa_gdrom_menu_new();
2.14
2.15 + NSMenu *quickStateMenu = [[NSMenu alloc] initWithTitle:NSMENU_("_Quick State")];
2.16 + int quickState = dreamcast_get_quick_state();
2.17 + for( i=0; i<=MAX_QUICK_STATE; i++ ) {
2.18 + NSString *label = [NSString stringWithFormat: NSMENU_("State _%d"), i];
2.19 + NSString *keyEquiv = [NSString stringWithFormat: @"%d", i];
2.20 + menuItem = [[NSMenuItem alloc] initWithTitle: label action: @selector(quick_state_action:) keyEquivalent: keyEquiv];
2.21 + [menuItem setTag: i];
2.22 + if( i == quickState ) {
2.23 + [menuItem setState:NSOnState];
2.24 + }
2.25 + [quickStateMenu addItem: menuItem];
2.26 + }
2.27 +
2.28 NSMenu *fileMenu = [[NSMenu alloc] initWithTitle: NSMENU_("_File")];
2.29 [fileMenu addItemWithTitle: NSMENU_("Load _Binary...") action: @selector(load_binary_action:) keyEquivalent: @"b"];
2.30 [[fileMenu addItemWithTitle: NSMENU_("_GD-Rom") action: nil keyEquivalent: @""]
2.31 @@ -147,8 +161,14 @@
2.32 [fileMenu addItemWithTitle: NSMENU_("_Pause") action: @selector(pause_action:) keyEquivalent: @"p"];
2.33 [fileMenu addItemWithTitle: NS_("Resume") action: @selector(run_action:) keyEquivalent: @"r"];
2.34 [fileMenu addItem: [NSMenuItem separatorItem]];
2.35 - [fileMenu addItemWithTitle: NSMENU_("_Load State...") action: @selector(load_action:) keyEquivalent: @"o"];
2.36 - [fileMenu addItemWithTitle: NSMENU_("_Save State...") action: @selector(save_action:) keyEquivalent: @"s"];
2.37 + [fileMenu addItemWithTitle: NSMENU_("L_oad State...") action: @selector(load_action:) keyEquivalent: @"o"];
2.38 + [fileMenu addItemWithTitle: NSMENU_("S_ave State...") action: @selector(save_action:) keyEquivalent: @"a"];
2.39 + menuItem = [[NSMenuItem alloc] initWithTitle:NSMENU_("Select _Quick State") action: nil keyEquivalent: @""];
2.40 + [fileMenu addItem: [NSMenuItem separatorItem]];
2.41 + [fileMenu addItemWithTitle: NSMENU_("_Load Quick State") action: @selector(quick_load_action:) keyEquivalent: @"l"];
2.42 + [fileMenu addItemWithTitle: NSMENU_("_Save Quick State") action: @selector(quick_save_action:) keyEquivalent: @"s"];
2.43 + [menuItem setSubmenu: quickStateMenu];
2.44 + [fileMenu addItem: menuItem];
2.45 [fileMenu addItem: [NSMenuItem separatorItem]];
2.46 [fileMenu addItemWithTitle: NSMENU_("_Full Screen...") action: @selector(fullscreen_action:) keyEquivalent: @"\r"];
2.47
2.48 @@ -286,6 +306,20 @@
2.49 {
2.50 [mainWindow setFullscreen: ![mainWindow isFullscreen]];
2.51 }
2.52 +- (void) quick_state_action: (id)sender
2.53 +{
2.54 + [[[sender menu] itemWithTag: dreamcast_get_quick_state()] setState: NSOffState ];
2.55 + [sender setState: NSOnState ];
2.56 + dreamcast_set_quick_state( [sender tag] );
2.57 +}
2.58 +- (void) quick_save_action: (id)sender
2.59 +{
2.60 + dreamcast_quick_save();
2.61 +}
2.62 +- (void) quick_load_action: (id)sender
2.63 +{
2.64 + dreamcast_quick_load();
2.65 +}
2.66 @end
2.67
2.68
3.1 --- a/src/dreamcast.h Thu Jun 25 09:06:44 2009 +0000
3.2 +++ b/src/dreamcast.h Thu Jun 25 21:21:18 2009 +0000
3.3 @@ -68,7 +68,7 @@
3.4
3.5 /* Quick saves */
3.6 #define MAX_QUICK_STATE 9
3.7 -#define QUICK_STATE_FILENAME "quicksave%d.dst"
3.8 +#define QUICK_STATE_FILENAME "%s/quicksave%d.dst"
3.9
3.10 void dreamcast_quick_save();
3.11 void dreamcast_quick_load();
4.1 --- a/src/gtkui/gtkcb.c Thu Jun 25 09:06:44 2009 +0000
4.2 +++ b/src/gtkui/gtkcb.c Thu Jun 25 21:21:18 2009 +0000
4.3 @@ -213,6 +213,24 @@
4.4 {
4.5 save_file_dialog_cb( "Save state...", dreamcast_save_state, "*.dst", _("lxDream Save State (*.dst)"), CONFIG_SAVE_PATH );
4.6 }
4.7 +
4.8 +void quick_state_action_callback( GtkRadioAction *action, GtkRadioAction *current, gpointer user_data)
4.9 +{
4.10 + gint val = gtk_radio_action_get_current_value(action);
4.11 + dreamcast_set_quick_state(val);
4.12 +}
4.13 +
4.14 +void quick_load_action_callback( GtkAction *action, gpointer user_data)
4.15 +{
4.16 + dreamcast_quick_load();
4.17 +}
4.18 +
4.19 +void quick_save_action_callback( GtkAction *action, gpointer user_data)
4.20 +{
4.21 + dreamcast_quick_save();
4.22 +}
4.23 +
4.24 +
4.25 void about_action_callback( GtkAction *action, gpointer user_data)
4.26 {
4.27
5.1 --- a/src/gtkui/gtkui.c Thu Jun 25 09:06:44 2009 +0000
5.2 +++ b/src/gtkui/gtkui.c Thu Jun 25 21:21:18 2009 +0000
5.3 @@ -74,8 +74,11 @@
5.4 { "Reset", GTK_STOCK_REFRESH, N_("_Reset"), "<control>R", N_("Reset dreamcast"), G_CALLBACK(reset_action_callback) },
5.5 { "Pause", GTK_STOCK_MEDIA_PAUSE, N_("_Pause"), NULL, N_("Pause dreamcast"), G_CALLBACK(pause_action_callback) },
5.6 { "Run", GTK_STOCK_MEDIA_PLAY, N_("Resume"), NULL, N_("Resume"), G_CALLBACK(resume_action_callback) },
5.7 - { "LoadState", GTK_STOCK_REVERT_TO_SAVED, N_("_Load State..."), "F4", N_("Load an lxdream save state"), G_CALLBACK(load_state_action_callback) },
5.8 - { "SaveState", GTK_STOCK_SAVE_AS, N_("_Save State..."), "F3", N_("Create an lxdream save state"), G_CALLBACK(save_state_action_callback) },
5.9 + { "LoadState", GTK_STOCK_REVERT_TO_SAVED, N_("L_oad State..."), "F4", N_("Load an lxdream save state"), G_CALLBACK(load_state_action_callback) },
5.10 + { "SaveState", GTK_STOCK_SAVE_AS, N_("S_ave State..."), "F3", N_("Create an lxdream save state"), G_CALLBACK(save_state_action_callback) },
5.11 + { "QuickLoad", NULL, N_("_Load Quick State"), "F6", N_("Load the current quick save state"), G_CALLBACK(quick_load_action_callback) },
5.12 + { "QuickSave", NULL, N_("_Save Quick State..."), "F5", N_("Save to the current quick save state"), G_CALLBACK(quick_save_action_callback) },
5.13 + { "QuickStateMenu", NULL, N_("Select _Quick State"), NULL, N_("Set quick save state") },
5.14 { "Exit", GTK_STOCK_QUIT, N_("E_xit"), NULL, N_("Exit lxdream"), G_CALLBACK(exit_action_callback) },
5.15 { "GdromSettings", NULL, N_("_GD-Rom") },
5.16 { "GdromUnmount", NULL, N_("_Empty") },
5.17 @@ -99,6 +102,7 @@
5.18 static const GtkToggleActionEntry ui_toggle_actions[] = {
5.19 { "FullScreen", NULL, "_Full Screen", "<alt>Return", "Toggle full screen video", G_CALLBACK(fullscreen_toggle_callback), 0 },
5.20 };
5.21 +static GtkRadioActionEntry ui_radio_actions[MAX_QUICK_STATE+1];
5.22
5.23 // Menus and toolbars
5.24 static const char *ui_description =
5.25 @@ -116,6 +120,21 @@
5.26 " <menuitem action='LoadState'/>"
5.27 " <menuitem action='SaveState'/>"
5.28 " <separator/>"
5.29 + " <menuitem action='QuickLoad'/>"
5.30 + " <menuitem action='QuickSave'/>"
5.31 + " <menu action='QuickStateMenu'>"
5.32 + " <menuitem action='QuickState0'/>"
5.33 + " <menuitem action='QuickState1'/>"
5.34 + " <menuitem action='QuickState2'/>"
5.35 + " <menuitem action='QuickState3'/>"
5.36 + " <menuitem action='QuickState4'/>"
5.37 + " <menuitem action='QuickState5'/>"
5.38 + " <menuitem action='QuickState6'/>"
5.39 + " <menuitem action='QuickState7'/>"
5.40 + " <menuitem action='QuickState8'/>"
5.41 + " <menuitem action='QuickState9'/>"
5.42 + " </menu>"
5.43 + " <separator/>"
5.44 " <menuitem action='Exit'/>"
5.45 " </menu>"
5.46 " <menu action='SettingsMenu'>"
5.47 @@ -150,6 +169,21 @@
5.48 " <menuitem action='LoadState'/>"
5.49 " <menuitem action='SaveState'/>"
5.50 " <separator/>"
5.51 + " <menuitem action='QuickLoad'/>"
5.52 + " <menuitem action='QuickSave'/>"
5.53 + " <menu action='QuickStateMenu'>"
5.54 + " <menuitem action='QuickState0'/>"
5.55 + " <menuitem action='QuickState1'/>"
5.56 + " <menuitem action='QuickState2'/>"
5.57 + " <menuitem action='QuickState3'/>"
5.58 + " <menuitem action='QuickState4'/>"
5.59 + " <menuitem action='QuickState5'/>"
5.60 + " <menuitem action='QuickState6'/>"
5.61 + " <menuitem action='QuickState7'/>"
5.62 + " <menuitem action='QuickState8'/>"
5.63 + " <menuitem action='QuickState9'/>"
5.64 + " </menu>"
5.65 + " <separator/>"
5.66 " <menuitem action='Exit'/>"
5.67 " </menu>"
5.68 " <menu action='DebugMenu'>"
5.69 @@ -207,6 +241,7 @@
5.70 gboolean gui_init( gboolean withDebug, gboolean withFullscreen )
5.71 {
5.72 if( gtk_gui_init_ok ) {
5.73 + int i;
5.74 GError *error = NULL;
5.75 dreamcast_register_module( &gtk_gui_module );
5.76 gtk_gui_alloc_resources();
5.77 @@ -215,6 +250,17 @@
5.78 gtk_action_group_set_translation_domain( global_action_group, NULL );
5.79 gtk_action_group_add_actions( global_action_group, ui_actions, G_N_ELEMENTS(ui_actions), NULL );
5.80 gtk_action_group_add_toggle_actions( global_action_group, ui_toggle_actions, G_N_ELEMENTS(ui_toggle_actions), NULL );
5.81 +
5.82 + for( i=0; i<=MAX_QUICK_STATE; i++ ) {
5.83 + ui_radio_actions[i].name = g_strdup_printf("QuickState%d", i);
5.84 + ui_radio_actions[i].stock_id = NULL;
5.85 + ui_radio_actions[i].label = g_strdup_printf(_("State _%d"), i );
5.86 + ui_radio_actions[i].accelerator = NULL;
5.87 + ui_radio_actions[i].tooltip = g_strdup_printf(_("Use quick save state %d"),i);
5.88 + ui_radio_actions[i].value = i;
5.89 + }
5.90 + gtk_action_group_add_radio_actions( global_action_group, ui_radio_actions, G_N_ELEMENTS(ui_radio_actions),
5.91 + dreamcast_get_quick_state(), G_CALLBACK(quick_state_action_callback), NULL );
5.92 gtk_gui_enable_action("AudioSettings", FALSE);
5.93 gtk_gui_enable_action("NetworkSettings", FALSE);
5.94 gtk_gui_enable_action("VideoSettings", FALSE);
6.1 --- a/src/gtkui/gtkui.h Thu Jun 25 09:06:44 2009 +0000
6.2 +++ b/src/gtkui/gtkui.h Thu Jun 25 21:21:18 2009 +0000
6.3 @@ -134,6 +134,9 @@
6.4 void resume_action_callback( GtkAction *action, gpointer user_data);
6.5 void load_state_action_callback( GtkAction *action, gpointer user_data);
6.6 void save_state_action_callback( GtkAction *action, gpointer user_data);
6.7 +void quick_load_action_callback( GtkAction *action, gpointer user_data);
6.8 +void quick_save_action_callback( GtkAction *action, gpointer user_data);
6.9 +void quick_state_action_callback( GtkRadioAction *action, GtkRadioAction *current, gpointer user_data);
6.10 void about_action_callback( GtkAction *action, gpointer user_data);
6.11 void exit_action_callback( GtkAction *action, gpointer user_data);
6.12
.