[Freeciv-Dev] (PR#9841) remove government dialog
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9841 >
> [jdorje - Fri Aug 27 22:00:29 2004]:
>
> This patch removes the government dialog.
>
> Reasons:
>
> - Popups are bad.
>
> - It is no longer needed (government menu can be used instead).
>
> gui-gtk, gui-gtk-2.0, gui-xaw, and gui-stub are updated.
Here is an updated version of the patch. There should now be no
problems with it since this dialog isn't used anyway anymore. Though
that's not to say there aren't any bugs from the patch that removed its
usage.
jason
Index: client/gui-ftwl/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-ftwl/dialogs.c,v
retrieving revision 1.3
diff -u -r1.3 dialogs.c
--- client/gui-ftwl/dialogs.c 16 Sep 2004 08:53:08 -0000 1.3
+++ client/gui-ftwl/dialogs.c 21 Sep 2004 05:13:27 -0000
@@ -277,31 +277,6 @@
}
/**************************************************************************
- Popup a dialog asking the player what government to switch to (this
- happens after a revolution completes).
-**************************************************************************/
-void popup_government_dialog(int governments,
- struct government **government)
-{
- /* PORTME */
- int i;
-
- for (i = 0; i < game.government_count; i++) {
- if (i == game.government_when_anarchy) {
- continue;
- }
-
- if (can_change_to_government(game.player_ptr, i)) {
- /* ... */
- } else {
- /* ... */
- }
- }
-
- /* ... */
-}
-
-/**************************************************************************
Popup a dialog giving a player choices when their caravan arrives at
a city (other than its home city). Example:
- Establish traderoute.
Index: client/gui-gtk/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/dialogs.c,v
retrieving revision 1.146
diff -u -r1.146 dialogs.c
--- client/gui-gtk/dialogs.c 21 Sep 2004 05:00:50 -0000 1.146
+++ client/gui-gtk/dialogs.c 21 Sep 2004 05:13:28 -0000
@@ -157,8 +157,6 @@
static GtkWidget *caravan_dialog;
-static bool government_dialog_is_open = FALSE;
-
struct pillage_data {
int unit_id;
enum tile_special_type what;
@@ -1177,46 +1175,6 @@
/****************************************************************
...
*****************************************************************/
-static void government_callback(gpointer data)
-{
- set_government_choice(GPOINTER_TO_INT(data));
-
- assert(government_dialog_is_open);
- government_dialog_is_open = FALSE;
-}
-
-/****************************************************************
-...
-*****************************************************************/
-void popup_government_dialog(int governments,
- struct government **government)
-{
- int i;
- struct button_descr *buttons;
-
- if (government_dialog_is_open) {
- return;
- }
-
- buttons = fc_malloc(sizeof(struct button_descr) * governments);
-
- for (i = 0; i < governments; i++) {
- buttons[i].text = government[i]->name;
- buttons[i].callback = government_callback;
- buttons[i].data = GINT_TO_POINTER(government[i]->index);
- buttons[i].sensitive =
- can_change_to_government(game.player_ptr, government[i]->index);
- }
-
- government_dialog_is_open = TRUE;
- base_popup_message_dialog(top_vbox, _("Choose Your New Government"),
- _("Select government type:"), NULL, NULL,
- governments, buttons);
-}
-
-/****************************************************************
-...
-*****************************************************************/
static void revolution_callback_yes(gpointer data)
{
start_revolution();
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.73
diff -u -r1.73 dialogs.c
--- client/gui-gtk-2.0/dialogs.c 21 Sep 2004 05:00:50 -0000 1.73
+++ client/gui-gtk-2.0/dialogs.c 21 Sep 2004 05:13:28 -0000
@@ -106,8 +106,6 @@
static int selected_sex;
static int selected_city_style;
-static bool is_showing_government_dialog;
-
static int is_showing_pillage_dialog = FALSE;
static int unit_to_use_to_pillage;
@@ -1011,91 +1009,6 @@
return caravan_dialog != NULL;
}
-
-/****************************************************************
-...
-*****************************************************************/
-static void government_callback(GtkWidget *w, gpointer data)
-{
- set_government_choice(GPOINTER_TO_INT(data));
- is_showing_government_dialog = FALSE;
-}
-
-
-/****************************************************************
-...
-*****************************************************************/
-void popup_government_dialog(int governments,
- struct government **government)
-{
- int i;
- GtkWidget *dshell, *dlabel, *vbox;
-
- if(!is_showing_government_dialog) {
- is_showing_government_dialog = TRUE;
-
- dshell=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- setup_dialog(dshell, toplevel);
- g_object_set(GTK_WINDOW(dshell),
- "title", _("Choose Your New Government"),
- "window-position", GTK_WIN_POS_CENTER_ON_PARENT,
- NULL);
-
- g_signal_connect(
- dshell,
- "delete_event",
- G_CALLBACK(gtk_true),
- GINT_TO_POINTER(toplevel)
- );
-
- dlabel = gtk_frame_new(_("Select government type:"));
- gtk_container_add(GTK_CONTAINER(dshell), dlabel);
-
- vbox = gtk_vbutton_box_new();
- gtk_container_add(GTK_CONTAINER(dlabel), vbox);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
-
- for (i = 0; i < governments; i++) {
- GtkWidget *label, *image, *hbox, *align, *button;
- struct Sprite *gsprite = government[i]->sprite;
-
- /* create button. */
- button = gtk_button_new();
-
- label = gtk_label_new_with_mnemonic(government[i]->name);
- gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
-
- image = gtk_image_new_from_pixmap(gsprite->pixmap, gsprite->mask);
- hbox = gtk_hbox_new(FALSE, 2);
-
- align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
-
- gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), align, TRUE, FALSE, 5);
-
- gtk_container_add(GTK_CONTAINER(align), label);
- gtk_container_add(GTK_CONTAINER(button), hbox);
-
- /* tidy up. */
- gtk_container_add(GTK_CONTAINER(vbox), button);
- g_signal_connect(button, "clicked", G_CALLBACK(government_callback),
- GINT_TO_POINTER(government[i]->index));
- g_signal_connect_swapped(button, "clicked",
- G_CALLBACK(gtk_widget_destroy), dshell);
-
- gtk_widget_set_sensitive(button,
- can_change_to_government(game.player_ptr,
- government[i]->
- index));
- }
-
- gtk_widget_show_all(dlabel);
- gtk_widget_show(dshell);
- }
-}
-
-
-
/****************************************************************
...
*****************************************************************/
Index: client/gui-mui/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/dialogs.c,v
retrieving revision 1.57
diff -u -r1.57 dialogs.c
--- client/gui-mui/dialogs.c 10 Sep 2004 21:20:52 -0000 1.57
+++ client/gui-mui/dialogs.c 21 Sep 2004 05:13:28 -0000
@@ -1025,65 +1025,6 @@
return caravan_dialog;
}
-
-/****************************************************************
- Callback for a government button
-*****************************************************************/
-static void government_button(struct popup_message_data *msg)
-{
- is_showing_government_dialog = 0;
- request_player_government((int)msg->data);
- message_close(msg);
-}
-
-
-/****************************************************************
- Fills the New_Msg_Dlg for the requested government
- TRUE, if player can choose the governemt, otherwise FALSE
-*****************************************************************/
-int fill_government_dialog(struct New_Msg_Dlg *dlg, int government)
-{
- struct government *g = &governments[government];
-
- if(can_change_to_government(game.player_ptr, government))
- {
- dlg->label = g->name;
- dlg->function = (APTR)government_button;
- dlg->data = (APTR)g->index;
- return TRUE;
- }
- return FALSE;
-}
-
-/****************************************************************
-...
-*****************************************************************/
-void popup_government_dialog(void)
-{
- struct New_Msg_Dlg *msg_dlg = (struct New_Msg_Dlg*)malloc(sizeof(struct
New_Msg_Dlg)*(game.government_count+1));
- if(msg_dlg)
- {
- if(!is_showing_government_dialog)
- {
- int i,j;
- is_showing_government_dialog=1;
- j=0;
-
- for(i=0;i<game.government_count;i++)
- {
- if(i == game.government_when_anarchy) continue;
- if(fill_government_dialog(&msg_dlg[j],i)) j++;
- }
-
- msg_dlg[j].label = NULL;
-
- popup_message_dialog_args(main_wnd, _("Choose Your New Government"),
- _("Select government type:"),msg_dlg);
- }
- free(msg_dlg);
- }
-}
-
/****************************************************************
Callback for the Yes button in the revolution confirmation
window
Index: client/gui-sdl/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/dialogs.c,v
retrieving revision 1.49
diff -u -r1.49 dialogs.c
--- client/gui-sdl/dialogs.c 21 Sep 2004 05:00:51 -0000 1.49
+++ client/gui-sdl/dialogs.c 21 Sep 2004 05:13:29 -0000
@@ -3638,121 +3638,6 @@
}
/**************************************************************************
- Sellect Goverment Type
-**************************************************************************/
-static struct SMALL_DLG *pGov_Dlg = NULL;
-
-/**************************************************************************
- ...
-**************************************************************************/
-static int government_dlg_callback(struct GUI *pGov_Button)
-{
- set_government_choice(MAX_ID - pGov_Button->ID);
- popdown_window_group_dialog(pGov_Dlg->pBeginWidgetList,
- pGov_Dlg->pEndWidgetList);
- FREE(pGov_Dlg);
- SDL_Client_Flags |= CF_REVOLUTION;
- flush_dirty();
- return (-1);
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-static int move_government_dlg_callback(struct GUI *pWindow)
-{
- return std_move_window_group_callback(pGov_Dlg->pBeginWidgetList, pWindow);
-}
-
-/**************************************************************************
- Public -
-
- Popup a dialog asking the player what government to switch to (this
- happens after a revolution completes).
-**************************************************************************/
-void popup_government_dialog(int governments,
- struct government **government)
-{
- SDL_Surface *pLogo = NULL;
- struct SDL_String16 *pStr = NULL;
- struct GUI *pGov_Button = NULL;
- struct GUI *pWindow = NULL;
- struct government *pGov = NULL;
- int i;
- Uint16 max_w, max_h = 0;
-
- if (pGov_Dlg) {
- return;
- }
-
- pGov_Dlg = MALLOC(sizeof(struct SMALL_DLG));
-
- /* create window */
- pStr = create_str16_from_char(_("Choose Your New Government"), 12);
- pStr->style |= TTF_STYLE_BOLD;
- /* this win. size is temp. */
- pWindow = create_window(NULL, pStr, 10, 30, 0);
- pWindow->action = move_government_dlg_callback;
- pGov_Dlg->pEndWidgetList = pWindow;
- max_w = pWindow->size.w;
- add_to_gui_list(ID_GOVERNMENT_DLG_WINDOW, pWindow);
-
- /* create gov. buttons */
- for (i = 0; i < governments; i++) {
- pGov = government[i];
- pStr = create_str16_from_char(pGov->name, 12);
- pGov_Button =
- create_icon_button(GET_SURF(pGov->sprite), pWindow->dst, pStr, 0);
- pGov_Button->action = government_dlg_callback;
-
- max_w = MAX(max_w, pGov_Button->size.w);
- max_h = MAX(max_h, pGov_Button->size.h);
-
- /* ugly hack */
- add_to_gui_list((MAX_ID - pGov->index), pGov_Button);
- }
-
- pGov_Dlg->pBeginWidgetList = pGov_Button;
-
- max_w += 10;
- max_h += 4;
-
- /* set window start positions */
- pWindow->size.x = (Main.screen->w - pWindow->size.w) / 2;
- pWindow->size.y = (Main.screen->h - pWindow->size.h) / 2;
-
- /* create window background */
- pLogo = get_logo_gfx();
- if (resize_window(pWindow, pLogo, NULL, max_w + 20,
- governments * (max_h + 10) + WINDOW_TILE_HIGH + 6)) {
- FREESURFACE(pLogo);
- }
-
- pWindow->size.w = max_w + 20;
- pWindow->size.h = governments * (max_h + 10) + WINDOW_TILE_HIGH + 6;
-
- /* set buttons start positions and size */
- i = 1;
- while (pGov_Button != pGov_Dlg->pEndWidgetList) {
- pGov_Button->size.w = max_w;
- pGov_Button->size.h = max_h;
- pGov_Button->size.x = pWindow->size.x + 10;
- pGov_Button->size.y = pWindow->size.y + pWindow->size.h -
- (i++) * (max_h + 10);
- set_wstate(pGov_Button, FC_WS_NORMAL);
-
- pGov_Button = pGov_Button->next;
- }
-
- set_wstate(pWindow, FC_WS_NORMAL);
-
- /* redraw */
- redraw_group(pGov_Dlg->pBeginWidgetList, pWindow, 0);
-
- flush_rect(pWindow->size);
-}
-
-/**************************************************************************
Nation Wizard
**************************************************************************/
static struct ADVANCED_DLG *pNationDlg = NULL;
Index: client/gui-stub/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/dialogs.c,v
retrieving revision 1.14
diff -u -r1.14 dialogs.c
--- client/gui-stub/dialogs.c 16 Jun 2004 02:50:27 -0000 1.14
+++ client/gui-stub/dialogs.c 21 Sep 2004 05:13:29 -0000
@@ -86,23 +86,6 @@
}
/**************************************************************************
- Popup a dialog asking the player what government to switch to (this
- happens after a revolution completes).
-**************************************************************************/
-void popup_government_dialog(int governments,
- struct government **government)
-{
- /* PORTME */
- int i;
-
- for (i = 0; i < governments; i++) {
- /* PORTME: add option for converting to government[i]. */
- }
-
- /* ... */
-}
-
-/**************************************************************************
Popup a dialog giving a player choices when their caravan arrives at
a city (other than its home city). Example:
- Establish traderoute.
Index: client/gui-win32/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/dialogs.c,v
retrieving revision 1.54
diff -u -r1.54 dialogs.c
--- client/gui-win32/dialogs.c 21 Sep 2004 05:00:51 -0000 1.54
+++ client/gui-win32/dialogs.c 21 Sep 2004 05:13:30 -0000
@@ -80,9 +80,6 @@
static HWND spy_sabotage_dialog;
static int improvement_type[B_LAST+1];
-static bool is_showing_government_dialog;
-
-
struct message_dialog_button
{
@@ -911,60 +908,6 @@
0);
}
-/**************************************************************************
-
-**************************************************************************/
-static void government_callback(HWND w, void *data)
-{
- set_government_choice((size_t)data);
-
- destroy_message_dialog(w);
- is_showing_government_dialog=0;
-}
-
-/****************************************************************
-...
-*****************************************************************/
-void popup_government_dialog(int governments, struct government **government)
-{
- HWND hWnd;
- int i, id[MAX_NUM_GOVERNMENTS];
- char *names[MAX_NUM_GOVERNMENTS];
-
- if (is_showing_government_dialog) return;
- is_showing_government_dialog = 1;
-
- for (i = 0; i < governments; i++) {
- names[i] = government[i]->name;
- id[i] = government[i]->index;
- }
-
- for (; i < MAX_NUM_GOVERNMENTS; i++) {
- names[i] = NULL;
- }
-
- /* just a quick hack */
- hWnd = popup_message_dialog(NULL, _("Choose Your New Government"),
- _("Select government type:"),
- names[0], government_callback, id[0],
- names[1], government_callback, id[1],
- names[2], government_callback, id[2],
- names[3], government_callback, id[3],
- names[4], government_callback, id[4],
- names[5], government_callback, id[5],
- names[6], government_callback, id[6],
- names[7], government_callback, id[7],
- names[8], government_callback, id[8],
- names[9], government_callback, id[9],
- 0);
- for (i = 0; i < governments; i++) {
- bool can_change =
- can_change_to_government(game.player_ptr, government[i]->index);
-
- message_dialog_button_set_sensitive(hWnd, i, can_change);
- }
-}
-
/****************************************************************
...
*****************************************************************/
Index: client/gui-xaw/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/dialogs.c,v
retrieving revision 1.102
diff -u -r1.102 dialogs.c
--- client/gui-xaw/dialogs.c 21 Sep 2004 05:00:51 -0000 1.102
+++ client/gui-xaw/dialogs.c 21 Sep 2004 05:13:30 -0000
@@ -158,8 +158,6 @@
/******************************************************************/
-int is_showing_government_dialog;
-
int is_showing_pillage_dialog = FALSE;
int unit_to_use_to_pillage;
@@ -1216,58 +1214,6 @@
return BOOL_VAL(caravan_dialog);
}
-
-/****************************************************************
-...
-*****************************************************************/
-static void government_callback(Widget w, XtPointer client_data,
- XtPointer call_data)
-{
- set_government_choice((size_t) client_data);
- destroy_message_dialog(w);
- is_showing_government_dialog = 0;
-}
-
-/****************************************************************
-...
-*****************************************************************/
-void popup_government_dialog(int governments,
- struct government **government)
-{
- Widget shell, form, dlabel, prev;
- int i;
-
- if(is_showing_government_dialog) {
- return;
- }
- is_showing_government_dialog=1;
-
- XtSetSensitive(toplevel, FALSE);
-
- shell = I_T(XtCreatePopupShell("governmentdialog", transientShellWidgetClass,
- toplevel, NULL, 0));
- form = XtVaCreateManagedWidget("form", formWidgetClass, shell, NULL);
- dlabel = I_L(XtVaCreateManagedWidget("dlabel", labelWidgetClass, form,
NULL));
-
- prev = dlabel;
- for (i = 0; i < governments; i++) {
- Widget button =
- XtVaCreateManagedWidget("button", commandWidgetClass, form,
- XtNfromVert, prev,
- XtNlabel, (XtArgVal) government[i]->name,
- NULL);
- XtAddCallback(button, XtNcallback, government_callback,
- INT_TO_XTPOINTER(government[i]->index));
- XtSetSensitive(button,
- can_change_to_government(game.player_ptr,
- government[i]->index));
- prev = button;
- }
-
- xaw_set_relative_position(toplevel, shell, 10, 0);
- XtPopup(shell, XtGrabNone);
-}
-
/****************************************************************
...
*****************************************************************/
Index: client/include/dialogs_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/dialogs_g.h,v
retrieving revision 1.19
diff -u -r1.19 dialogs_g.h
--- client/include/dialogs_g.h 3 Sep 2004 04:22:36 -0000 1.19
+++ client/include/dialogs_g.h 21 Sep 2004 05:13:30 -0000
@@ -34,8 +34,6 @@
void races_toggles_set_sensitive(bool *nations_used);
void popup_revolution_dialog(void);
-void popup_government_dialog(int governments,
- struct government **government);
void popup_caravan_dialog(struct unit *punit,
struct city *phomecity, struct city *pdestcity);
bool caravan_dialog_is_open(void);
|
|