Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2006:
[Freeciv-Dev] (PR#14763) Design of advanced governments code (GUI)
Home

[Freeciv-Dev] (PR#14763) Design of advanced governments code (GUI)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#14763) Design of advanced governments code (GUI)
From: "Vasco Alexandre da Silva Costa" <vasco.costa@xxxxxxxxx>
Date: Sat, 11 Feb 2006 17:22:12 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14763 >

Here is a patch with a prototype for a GUI to be used in government
selection.

-- 
Vasco Alexandre da Silva Costa
Index: client/gui-gtk-2.0/repodlgs.c
===================================================================
--- client/gui-gtk-2.0/repodlgs.c       (revision 11575)
+++ client/gui-gtk-2.0/repodlgs.c       (working copy)
@@ -70,6 +70,16 @@
 
 /******************************************************************/
 enum {
+  GOVERNMENT_CHANGE = 1
+};
+
+static void create_government_report_dialog(void);
+
+static struct gui_dialog *government_dialog_shell = NULL;
+static GtkWidget *government_change_button;
+
+/******************************************************************/
+enum {
   ECONOMY_SELL_OBSOLETE = 1, ECONOMY_SELL_ALL
 };
 
@@ -132,6 +142,7 @@
   economy_report_dialog_update();
   city_report_dialog_update(); 
   science_dialog_update();
+  government_report_dialog_update();
 }
 
 
@@ -592,6 +603,173 @@
 
 /****************************************************************
 
+                   GOVERNMENT REPORT DIALOG
+ 
+****************************************************************/
+
+/****************************************************************
+...
+****************************************************************/
+void popup_government_report_dialog(bool raise)
+{
+  if (!government_dialog_shell) {
+    create_government_report_dialog();
+  }
+
+  gui_dialog_present(government_dialog_shell);
+  if (raise) {
+    gui_dialog_raise(government_dialog_shell);
+  }
+}
+
+/****************************************************************
+ Close the government report dialog.
+****************************************************************/
+void popdown_government_report_dialog(void)
+{
+  if (government_dialog_shell) {
+    gui_dialog_destroy(government_dialog_shell);
+  }
+}
+ 
+/****************************************************************
+...
+*****************************************************************/
+void create_government_report_dialog(void)
+{
+  GtkWidget *label, *hbox;
+  int i;
+  
+  gui_dialog_new(&government_dialog_shell, GTK_NOTEBOOK(top_notebook), NULL);
+  gui_dialog_set_title(government_dialog_shell, _("Government"));
+
+  hbox = gtk_hbox_new(TRUE, 6);
+  gtk_box_pack_start(GTK_BOX(government_dialog_shell->vbox),
+      hbox, TRUE, TRUE, 0);
+
+  for (i = 0; i < 3; i++) {
+    GtkWidget *vbox, *vbox2, *vbox3;
+    GtkWidget *progress, *align, *label, *image;
+    struct government *pgov;
+    struct sprite *gsprite;
+    GSList *bgroup = NULL;
+    char desc[512];
+
+    vbox = gtk_vbox_new(FALSE, 1);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    label = gtk_label_new(_("Politics"));
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+
+
+    vbox2 = gtk_vbox_new(FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0);
+
+    pgov = get_government(0);
+
+    align = gtk_alignment_new(0.5, 0.5, 1.0, 1.0);
+    gtk_box_pack_start(GTK_BOX(vbox2), align, FALSE, FALSE, 0);
+
+    if ((gsprite = get_government_sprite(tileset, pgov))) {
+      image = gtk_image_new_from_pixbuf(sprite_get_pixbuf(gsprite));
+      gtk_container_add(GTK_CONTAINER(align), image);
+    }
+
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    gtk_widget_set_name(label, "small font");
+    gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 2);
+
+    my_snprintf(desc, sizeof(desc), _("%s Level %d"),
+       pgov->name, 0);
+    gtk_label_set_text(GTK_LABEL(label), desc);
+
+    vbox3 = gtk_vbox_new(FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), vbox3, FALSE, FALSE, 0);
+
+    label = gtk_label_new(_("Improves in:"));
+    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
+    gtk_box_pack_start(GTK_BOX(vbox3), label, FALSE, FALSE, 0);
+
+    progress = gtk_progress_bar_new();
+    gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress),
+       _("6 turns"));
+    gtk_box_pack_start(GTK_BOX(vbox3), progress, FALSE, FALSE, 0);
+
+    label = gtk_label_new(NULL);
+    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
+    gtk_box_pack_start(GTK_BOX(vbox2), label, TRUE, TRUE, 0);
+
+    gtk_label_set_text(GTK_LABEL(label),
+       "Your government for 1 turn.\n"
+       "Cannot change for 3 turns.");
+
+
+    align = gtk_alignment_new(0.5, 0.5, 1.0, 1.0);
+    gtk_box_pack_start(GTK_BOX(vbox), align, FALSE, FALSE, 0);
+
+    vbox2 = gtk_vbox_new(TRUE, 0);
+    gtk_container_add(GTK_CONTAINER(align), vbox2);
+
+    government_iterate(g) {
+      GtkWidget *button, *hbox, *align, *label, *image;
+      struct sprite *gsprite;
+
+      button = gtk_radio_button_new(bgroup);
+      bgroup = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
+      gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, FALSE, 0);
+
+      align = gtk_alignment_new(0.5, 0.5, 1.0, 0.0);
+      gtk_container_add(GTK_CONTAINER(button), align);
+
+      hbox = gtk_hbox_new(FALSE, 2);
+      gtk_container_add(GTK_CONTAINER(align), hbox);
+
+      if ((gsprite = get_government_sprite(tileset, g))) {
+       image = gtk_image_new_from_pixbuf(sprite_get_pixbuf(gsprite));
+       gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
+      }
+
+      label = gtk_label_new(g->name);
+      gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+      gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    } government_iterate_end;
+  }
+  
+  label = gtk_label_new(NULL);
+  gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
+  gtk_box_pack_end(GTK_BOX(government_dialog_shell->vbox),
+      label, FALSE, FALSE, 8);
+
+  gtk_label_set_text(GTK_LABEL(label),
+      "You must press \"Change\" to effect the changes.");
+
+  government_change_button =
+    gui_dialog_add_button(government_dialog_shell, _("Change!"),
+       GOVERNMENT_CHANGE);
+
+  government_report_dialog_update();
+  gui_dialog_set_default_size(government_dialog_shell, -1, 350);
+
+  gui_dialog_set_default_response(government_dialog_shell,
+      GOVERNMENT_CHANGE);
+
+  gui_dialog_show_all(government_dialog_shell);
+}
+
+
+/****************************************************************
+...
+*****************************************************************/
+void government_report_dialog_update(void)
+{
+  if (!is_report_dialogs_frozen() && government_dialog_shell) {
+  }
+}
+
+/****************************************************************
+
                       ECONOMY REPORT DIALOG
  
 ****************************************************************/
Index: client/gui-gtk-2.0/menu.c
===================================================================
--- client/gui-gtk-2.0/menu.c   (revision 11575)
+++ client/gui-gtk-2.0/menu.c   (working copy)
@@ -151,6 +151,7 @@
   MENU_REPORT_CITIES,
   MENU_REPORT_UNITS,
   MENU_REPORT_PLAYERS,
+  MENU_REPORT_GOVERNMENT,
   MENU_REPORT_ECONOMY,
   MENU_REPORT_SCIENCE,
   MENU_REPORT_WOW,
@@ -554,6 +555,9 @@
   case MENU_REPORT_PLAYERS:
     popup_players_dialog(TRUE);
     break;
+   case MENU_REPORT_GOVERNMENT:
+    popup_government_report_dialog(TRUE);
+    break;
    case MENU_REPORT_ECONOMY:
     popup_economy_report_dialog(TRUE);
     break;
@@ -889,6 +893,8 @@
        reports_menu_callback,  MENU_REPORT_UNITS                               
        },
   { "/" N_("Reports") "/" N_("_Players"),              "F3",
        reports_menu_callback,  MENU_REPORT_PLAYERS                             
        },
+  { "/" N_("Reports") "/" N_("_Government"),           NULL,
+       reports_menu_callback,  MENU_REPORT_GOVERNMENT                          
        },
   { "/" N_("Reports") "/" N_("_Economy"),              "F5",
        reports_menu_callback,  MENU_REPORT_ECONOMY                             
        },
   { "/" N_("Reports") "/" N_("_Science"),              "F6",
Index: client/include/repodlgs_g.h
===================================================================
--- client/include/repodlgs_g.h (revision 11575)
+++ client/include/repodlgs_g.h (working copy)
@@ -22,6 +22,8 @@
 
 void science_dialog_update(void);
 void popup_science_dialog(bool raise);
+void government_report_dialog_update(void);
+void popup_government_report_dialog(bool raise);
 void economy_report_dialog_update(void);
 void popup_economy_report_dialog(bool raise);
 void activeunits_report_dialog_update(void);

[Prev in Thread] Current Thread [Next in Thread]