[Freeciv-Dev] (PR#14243) [PATCH] Scenario descriptions
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#14243) [PATCH] Scenario descriptions |
From: |
"Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx> |
Date: |
Sun, 9 Oct 2005 14:50:30 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14243 >
> [jdorje - Sun Oct 09 21:45:31 2005]:
>
> Vasco Alexandre da Silva Costa wrote:
> > <URL: http://bugs.freeciv.org/Ticket/Display.html?id=14243 >
> >
> > As requested by Hogne here:
> > http://www.freeciv.org/index.php/User:Freim
> >
> > To commit ASAP.
>
> Huh?
Sorry, here is the patch. :O)
Index: client/gui-gtk-2.0/pages.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/pages.c,v
retrieving revision 1.44
diff -u -r1.44 pages.c
--- client/gui-gtk-2.0/pages.c 9 Oct 2005 17:02:01 -0000 1.44
+++ client/gui-gtk-2.0/pages.c 9 Oct 2005 21:21:52 -0000
@@ -56,6 +56,8 @@
static GtkWidget *start_options_table;
GtkWidget *ready_button;
+static GtkWidget *scenario_description;
+
static GtkListStore *load_store, *scenario_store,
*nation_store, *meta_store, *lan_store;
@@ -1486,6 +1488,26 @@
/**************************************************************************
+ Updates the info for the currently selected scenario.
+**************************************************************************/
+static void scenario_list_callback(void)
+{
+ GtkTreeIter it;
+ GtkTextBuffer *buffer;
+ char *description;
+
+ if (gtk_tree_selection_get_selected(scenario_selection, NULL, &it)) {
+ gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
+ 2, &description, -1);
+ } else {
+ description = "";
+ }
+
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(scenario_description));
+ gtk_text_buffer_set_text(buffer, description, -1);
+}
+
+/**************************************************************************
loads the currently selected scenario.
**************************************************************************/
static void scenario_callback(void)
@@ -1528,10 +1550,19 @@
files = datafilelist_infix("scenario", ".sav", TRUE);
datafile_list_iterate(files, pfile) {
GtkTreeIter it;
+ struct section_file sf;
+ char *description;
+
+ if (section_file_load(&sf, pfile->fullname)) {
+ description = secfile_lookup_str_default(&sf, "", "game.description");
+ } else {
+ description = "";
+ }
+ section_file_free(&sf);
gtk_list_store_append(scenario_store, &it);
gtk_list_store_set(scenario_store, &it,
- 0, pfile->name, 1, pfile->fullname, -1);
+ 0, pfile->name, 1, pfile->fullname, 2, description, -1);
free(pfile->name);
free(pfile->fullname);
@@ -1547,18 +1578,17 @@
**************************************************************************/
GtkWidget *create_scenario_page(void)
{
- GtkWidget *align, *box, *sbox, *bbox;
+ GtkWidget *vbox, *hbox, *sbox, *bbox;
- GtkWidget *button, *label, *view, *sw;
+ GtkWidget *align, *button, *label, *view, *sw, *text;
GtkCellRenderer *rend;
- box = gtk_vbox_new(FALSE, 18);
- gtk_container_set_border_width(GTK_CONTAINER(box), 4);
+ vbox = gtk_vbox_new(FALSE, 18);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
- align = gtk_alignment_new(0.5, 0.5, 0.0, 1.0);
- gtk_box_pack_start(GTK_BOX(box), align, TRUE, TRUE, 0);
-
- scenario_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+ scenario_store = gtk_list_store_new(3, G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(scenario_store));
g_object_unref(scenario_store);
@@ -1567,6 +1597,8 @@
-1, NULL, rend, "text", 0, NULL);
scenario_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+ g_signal_connect(scenario_selection, "changed",
+ G_CALLBACK(scenario_list_callback), NULL);
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
gtk_tree_selection_set_mode(scenario_selection, GTK_SELECTION_SINGLE);
@@ -1575,7 +1607,7 @@
G_CALLBACK(scenario_callback), NULL);
sbox = gtk_vbox_new(FALSE, 2);
- gtk_container_add(GTK_CONTAINER(align), sbox);
+ gtk_box_pack_start(GTK_BOX(vbox), sbox, TRUE, TRUE, 0);
label = g_object_new(GTK_TYPE_LABEL,
"use-underline", TRUE,
@@ -1586,19 +1618,38 @@
NULL);
gtk_box_pack_start(GTK_BOX(sbox), label, FALSE, FALSE, 0);
+ hbox = gtk_hbox_new(TRUE, 12);
+ gtk_box_pack_start(GTK_BOX(sbox), hbox, TRUE, TRUE, 0);
+
sw = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
- gtk_widget_set_size_request(sw, 300, -1);
gtk_container_add(GTK_CONTAINER(sw), view);
- gtk_box_pack_start(GTK_BOX(sbox), sw, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), sw, TRUE, TRUE, 0);
+
+ align = gtk_alignment_new(0.5, 0.0, 1.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(hbox), align, TRUE, TRUE, 0);
+
+ text = gtk_text_view_new();
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
+ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 2);
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
+ scenario_description = text;
+
+ sw = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
+ GTK_SHADOW_ETCHED_IN);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(sw), text);
+ gtk_container_add(GTK_CONTAINER(align), sw);
bbox = gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
gtk_box_set_spacing(GTK_BOX(bbox), 12);
- gtk_box_pack_start(GTK_BOX(box), bbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
button = gtk_button_new_with_mnemonic(_("_Browse..."));
gtk_container_add(GTK_CONTAINER(bbox), button);
@@ -1616,7 +1667,7 @@
g_signal_connect(button, "clicked",
G_CALLBACK(scenario_callback), NULL);
- return box;
+ return vbox;
}
Index: data/scenario/tutorial.sav
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/scenario/tutorial.sav,v
retrieving revision 1.4
diff -u -r1.4 tutorial.sav
--- data/scenario/tutorial.sav 7 Oct 2005 23:02:11 -0000 1.4
+++ data/scenario/tutorial.sav 9 Oct 2005 21:21:53 -0000
@@ -450,6 +450,7 @@
randseed=0
save_random=0
rulesetdir="default"
+description="Tutorial Scenario."
[savefile]
options="startoptions spacerace2 rulesets diplchance_percent worklists2
map_editor known32fix turn attributes watchtower rulesetdir client_worklists
orders startunits turn_last_built improvement_order technology_order embassies"
|
|