From d0867673cf541f4de5d03944f72f9b55083694c9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 29 Oct 2022 00:26:33 +0300 Subject: [PATCH 33/33] gtk3.22: Implement Battle Groups menu To make functionality more discoverable. See osdn #45924 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.22/gui_main.c | 48 ----------- client/gui-gtk-3.22/menu.c | 150 +++++++++++++++++++++++++++++++++ data/gtk3.22_menus.xml | 44 ++++++++++ 3 files changed, 194 insertions(+), 48 deletions(-) diff --git a/client/gui-gtk-3.22/gui_main.c b/client/gui-gtk-3.22/gui_main.c index 0e671bac2b..74c87330e6 100644 --- a/client/gui-gtk-3.22/gui_main.c +++ b/client/gui-gtk-3.22/gui_main.c @@ -483,54 +483,6 @@ static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, return FALSE; } - fc_assert(MAX_NUM_BATTLEGROUPS == 4); - - if ((ev->state & GDK_CONTROL_MASK)) { - switch (ev->keyval) { - - case GDK_KEY_F1: - key_unit_assign_battlegroup(0, (ev->state & GDK_SHIFT_MASK)); - return TRUE; - - case GDK_KEY_F2: - key_unit_assign_battlegroup(1, (ev->state & GDK_SHIFT_MASK)); - return TRUE; - - case GDK_KEY_F3: - key_unit_assign_battlegroup(2, (ev->state & GDK_SHIFT_MASK)); - return TRUE; - - case GDK_KEY_F4: - key_unit_assign_battlegroup(3, (ev->state & GDK_SHIFT_MASK)); - return TRUE; - - default: - break; - }; - } else if ((ev->state & GDK_SHIFT_MASK)) { - switch (ev->keyval) { - - case GDK_KEY_F1: - key_unit_select_battlegroup(0, FALSE); - return TRUE; - - case GDK_KEY_F2: - key_unit_select_battlegroup(1, FALSE); - return TRUE; - - case GDK_KEY_F3: - key_unit_select_battlegroup(2, FALSE); - return TRUE; - - case GDK_KEY_F4: - key_unit_select_battlegroup(3, FALSE); - return TRUE; - - default: - break; - }; - } - switch (ev->keyval) { case GDK_KEY_KP_Up: diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c index d958fb99eb..0e6cf6924f 100644 --- a/client/gui-gtk-3.22/menu.c +++ b/client/gui-gtk-3.22/menu.c @@ -127,6 +127,18 @@ static void report_wow_callback(GtkMenuItem *item, gpointer data); static void report_top_cities_callback(GtkMenuItem *item, gpointer data); static void report_messages_callback(GtkMenuItem *item, gpointer data); static void report_demographic_callback(GtkMenuItem *item, gpointer data); +static void bg_select0_callback(GtkMenuItem *item, gpointer data); +static void bg_assign0_callback(GtkMenuItem *item, gpointer data); +static void bg_append0_callback(GtkMenuItem *item, gpointer data); +static void bg_select1_callback(GtkMenuItem *item, gpointer data); +static void bg_assign1_callback(GtkMenuItem *item, gpointer data); +static void bg_append1_callback(GtkMenuItem *item, gpointer data); +static void bg_select2_callback(GtkMenuItem *item, gpointer data); +static void bg_assign2_callback(GtkMenuItem *item, gpointer data); +static void bg_append2_callback(GtkMenuItem *item, gpointer data); +static void bg_select3_callback(GtkMenuItem *item, gpointer data); +static void bg_assign3_callback(GtkMenuItem *item, gpointer data); +static void bg_append3_callback(GtkMenuItem *item, gpointer data); static void help_overview_callback(GtkMenuItem *item, gpointer data); static void help_playing_callback(GtkMenuItem *item, gpointer data); static void help_policies_callback(GtkMenuItem *item, gpointer data); @@ -259,6 +271,8 @@ static struct menu_entry_info menu_entries[] = NULL, MGROUP_SAFE }, { "MENU_CIVILIZATION", N_("C_ivilization"), 0, 0, NULL, MGROUP_SAFE }, + { "MENU_BATTLE_GROUPS", N_("_Battle Groups"), 0, 0, + NULL, MGROUP_SAFE }, { "MENU_HELP", N_("_Help"), 0, 0, NULL, MGROUP_SAFE }, { "CLEAR_CHAT_LOGS", N_("_Clear Chat Log"), 0, 0, G_CALLBACK(clear_chat_logs_callback), MGROUP_SAFE }, @@ -312,6 +326,46 @@ static struct menu_entry_info menu_entries[] = G_CALLBACK(report_messages_callback), MGROUP_SAFE }, { "REPORT_DEMOGRAPHIC", N_("_Demographics"), GDK_KEY_F11, 0, G_CALLBACK(report_demographic_callback), MGROUP_SAFE }, + + /* Battle Groups menu */ + /* Note that user view: 1 - 4, internal: 0 - 3 */ + { "BATTLE_GROUP_SELECT_0", N_("Select Battle Group 1"), + GDK_KEY_F1, GDK_SHIFT_MASK, + G_CALLBACK(bg_select0_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_ASSIGN_0", N_("Assign Battle Group 1"), + GDK_KEY_F1, GDK_CONTROL_MASK, + G_CALLBACK(bg_assign0_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_APPEND_0", N_("Append to Battle Group 1"), + GDK_KEY_F1, GDK_SHIFT_MASK | GDK_CONTROL_MASK, + G_CALLBACK(bg_append0_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_SELECT_1", N_("Select Battle Group 2"), + GDK_KEY_F1, GDK_SHIFT_MASK, + G_CALLBACK(bg_select1_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_ASSIGN_1", N_("Assign Battle Group 2"), + GDK_KEY_F1, GDK_CONTROL_MASK, + G_CALLBACK(bg_assign1_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_APPEND_1", N_("Append to Battle Group 2"), + GDK_KEY_F1, GDK_SHIFT_MASK | GDK_CONTROL_MASK, + G_CALLBACK(bg_append1_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_SELECT_2", N_("Select Battle Group 3"), + GDK_KEY_F1, GDK_SHIFT_MASK, + G_CALLBACK(bg_select2_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_ASSIGN_2", N_("Assign Battle Group 3"), + GDK_KEY_F1, GDK_CONTROL_MASK, + G_CALLBACK(bg_assign2_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_APPEND_2", N_("Append to Battle Group 3"), + GDK_KEY_F1, GDK_SHIFT_MASK | GDK_CONTROL_MASK, + G_CALLBACK(bg_append2_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_SELECT_3", N_("Select Battle Group 4"), + GDK_KEY_F1, GDK_SHIFT_MASK, + G_CALLBACK(bg_select3_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_ASSIGN_3", N_("Assign Battle Group 4"), + GDK_KEY_F1, GDK_CONTROL_MASK, + G_CALLBACK(bg_assign3_callback), MGROUP_SAFE }, + { "BATTLE_GROUP_APPEND_3", N_("Append to Battle Group 4"), + GDK_KEY_F1, GDK_SHIFT_MASK | GDK_CONTROL_MASK, + G_CALLBACK(bg_append3_callback), MGROUP_SAFE }, + { "HELP_OVERVIEW", N_("?help:Overview"), 0, 0, G_CALLBACK(help_overview_callback), MGROUP_SAFE }, { "HELP_PLAYING", N_("Strategy and Tactics"), 0, 0, @@ -821,6 +875,102 @@ static void help_cma_callback(GtkMenuItem *item, gpointer data) popup_help_dialog_string(HELP_CMA_ITEM); } +/************************************************************************//** + Item "BATTLE_GROUP_SELECT_0" callback. +****************************************************************************/ +static void bg_select0_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_select_battlegroup(0, FALSE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_ASSIGN_0" callback. +****************************************************************************/ +static void bg_assign0_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_assign_battlegroup(0, FALSE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_APPEND_0" callback. +****************************************************************************/ +static void bg_append0_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_assign_battlegroup(0, TRUE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_SELECT_1" callback. +****************************************************************************/ +static void bg_select1_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_select_battlegroup(1, FALSE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_ASSIGN_1" callback. +****************************************************************************/ +static void bg_assign1_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_assign_battlegroup(1, FALSE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_APPEND_1" callback. +****************************************************************************/ +static void bg_append1_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_assign_battlegroup(1, TRUE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_SELECT_2" callback. +****************************************************************************/ +static void bg_select2_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_select_battlegroup(2, FALSE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_ASSIGN_2" callback. +****************************************************************************/ +static void bg_assign2_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_assign_battlegroup(2, FALSE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_APPEND_2" callback. +****************************************************************************/ +static void bg_append2_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_assign_battlegroup(2, TRUE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_SELECT_3" callback. +****************************************************************************/ +static void bg_select3_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_select_battlegroup(3, FALSE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_ASSIGN_3" callback. +****************************************************************************/ +static void bg_assign3_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_assign_battlegroup(3, FALSE); +} + +/************************************************************************//** + Item "BATTLE_GROUP_APPEND_3" callback. +****************************************************************************/ +static void bg_append3_callback(GtkMenuItem *item, gpointer data) +{ + key_unit_assign_battlegroup(3, TRUE); +} + /************************************************************************//** Item "HELP_OVERVIEW" callback. ****************************************************************************/ diff --git a/data/gtk3.22_menus.xml b/data/gtk3.22_menus.xml index b62c87f7e8..47b8d5e966 100644 --- a/data/gtk3.22_menus.xml +++ b/data/gtk3.22_menus.xml @@ -490,6 +490,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.35.1