diff --git a/bygfoot_options.glade b/bygfoot_options.glade
index 7072bdfc..72e2315f 100644
--- a/bygfoot_options.glade
+++ b/bygfoot_options.glade
@@ -9,7 +9,7 @@
GTK_WINDOW_TOPLEVEL
GTK_WIN_POS_CENTER
- True
+ False
True
False
True
@@ -519,7 +519,7 @@
True
False
- 0
+ 2
@@ -620,6 +620,86 @@
False
+
+
+
+ True
+ Edit the constants used in the game (this won't change the file, however)
+ True
+ GTK_RELIEF_NORMAL
+ True
+
+
+
+
+ True
+ 0.5
+ 0.5
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+ True
+ False
+ 2
+
+
+
+ True
+ gtk-edit
+ 4
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ Edit
+ True
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+
+
+
+ 0
+ False
+ False
+
+
1
@@ -3595,4 +3675,431 @@
+
+ 5
+ True
+ window1
+ GTK_WINDOW_TOPLEVEL
+ GTK_WIN_POS_CENTER
+ False
+ 550
+ 700
+ True
+ False
+ True
+ False
+ False
+ GDK_WINDOW_TYPE_HINT_NORMAL
+ GDK_GRAVITY_NORTH_WEST
+ True
+
+
+
+
+
+ True
+ False
+ 5
+
+
+
+ True
+ True
+ True
+ True
+ GTK_POS_TOP
+ False
+ False
+
+
+
+ True
+ True
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+ GTK_SHADOW_IN
+ GTK_CORNER_TOP_LEFT
+
+
+
+ True
+ True
+ True
+ False
+ False
+ True
+ False
+ False
+ False
+
+
+
+
+ False
+ True
+
+
+
+
+
+ True
+ Integer
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ tab
+
+
+
+
+
+ True
+ True
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+ GTK_SHADOW_IN
+ GTK_CORNER_TOP_LEFT
+
+
+
+ True
+ True
+ True
+ False
+ False
+ True
+ False
+ False
+ False
+
+
+
+
+ False
+ True
+
+
+
+
+
+ True
+ Float
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ tab
+
+
+
+
+
+ True
+ True
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+ GTK_SHADOW_IN
+ GTK_CORNER_TOP_LEFT
+
+
+
+ True
+ True
+ True
+ False
+ False
+ True
+ False
+ False
+ False
+
+
+
+
+ False
+ True
+
+
+
+
+
+ True
+ String
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ tab
+
+
+
+
+
+ True
+ True
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+ GTK_SHADOW_IN
+ GTK_CORNER_TOP_LEFT
+
+
+
+ True
+ True
+ True
+ False
+ False
+ True
+ False
+ False
+ False
+
+
+
+
+ False
+ True
+
+
+
+
+
+ True
+ Appearance
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ tab
+
+
+
+
+ 0
+ True
+ True
+
+
+
+
+
+ 10
+ True
+
+
+ 0
+ False
+ True
+
+
+
+
+
+ True
+ Reload constants files. This will overwrite any changes you made in the current game session.
+ True
+ GTK_RELIEF_NORMAL
+ True
+
+
+
+
+ True
+ 0.5
+ 0.5
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+ True
+ False
+ 2
+
+
+
+ True
+ gtk-refresh
+ 4
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ Reload from file
+ True
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ Close window. Changes will be saved for the current session. To make permanent changes, edit constants files directly.
+ True
+ GTK_RELIEF_NORMAL
+ True
+
+
+
+
+
+ True
+ 0.5
+ 0.5
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+ True
+ False
+ 2
+
+
+
+ True
+ gtk-close
+ 4
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ Close
+ True
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+
diff --git a/src/bygfoot.h b/src/bygfoot.h
index 5f31a0ff..34502fc3 100644
--- a/src/bygfoot.h
+++ b/src/bygfoot.h
@@ -160,6 +160,7 @@ typedef struct
*job_offer,
*yesno,
*options,
+ *constants,
*font_sel,
*file_chooser,
*contract,
diff --git a/src/option.c b/src/option.c
index ce440c1b..b55dd939 100644
--- a/src/option.c
+++ b/src/option.c
@@ -123,7 +123,7 @@ option_float(const gchar *name, OptionList *optionlist)
gpointer element = g_datalist_get_data(&optionlist->datalist, name);
if(element != NULL)
- return (gfloat)((Option*)element)->value / 100000;
+ return (gfloat)((Option*)element)->value / OPTION_FLOAT_DIVISOR;
main_exit_program(EXIT_OPTION_NOT_FOUND,
"option_float: option named %s not found\nMaybe you should delete the .bygfoot directory from your home dir", name);
diff --git a/src/option.h b/src/option.h
index cf3f8f39..82edf23b 100644
--- a/src/option.h
+++ b/src/option.h
@@ -30,6 +30,11 @@
#include "bygfoot.h"
#include "option_struct.h"
+/** We store float constants as integer to avoid
+ localisation problems, and this is the value
+ the integers get divided by when we load them. */
+#define OPTION_FLOAT_DIVISOR 100000
+
/** Convenience abbrevs. */
#define option_set_float(name, option_array, value) option_set_int(name, option_array, (gint)rint(value * 1000))
diff --git a/src/options_callbacks.c b/src/options_callbacks.c
index db04cd01..5a63cac6 100644
--- a/src/options_callbacks.c
+++ b/src/options_callbacks.c
@@ -24,6 +24,7 @@
*/
#include "file.h"
+#include "option.h"
#include "options_callbacks.h"
#include "options_interface.h"
#include "option_gui.h"
@@ -187,3 +188,55 @@ on_spinbutton_recreation_value_changed (GtkSpinButton *spinbutton,
gtk_label_set_text(GTK_LABEL(lookup_widget(window.options, "label_training")), buf);
}
+
+void
+on_button_edit_constants_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ window_show_constants();
+}
+
+
+gboolean
+on_window_constants_destroy_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ on_button_constants_close_clicked(NULL, NULL);
+ return FALSE;
+}
+
+
+gboolean
+on_window_constants_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ on_button_constants_close_clicked(NULL, NULL);
+ return FALSE;
+}
+
+
+void
+on_button_constants_reload_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ if(window.options != NULL)
+ {
+ printf("hu\n");
+ file_load_opt_file(gtk_entry_get_text(GTK_ENTRY(lookup_widget(window.options, "entry_constants_file"))),
+ &constants);
+ }
+ else
+ file_load_opt_file(opt_str("string_opt_constants_file"),
+ &constants);
+}
+
+
+void
+on_button_constants_close_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ window_destroy(&window.constants);
+}
+
diff --git a/src/options_callbacks.h b/src/options_callbacks.h
index 6a3807a4..ac5a02d0 100644
--- a/src/options_callbacks.h
+++ b/src/options_callbacks.h
@@ -60,8 +60,30 @@ gboolean
on_window_options_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
-#endif
-
void
on_spinbutton_recreation_value_changed (GtkSpinButton *spinbutton,
gpointer user_data);
+
+void
+on_button_edit_constants_clicked (GtkButton *button,
+ gpointer user_data);
+
+gboolean
+on_window_constants_destroy_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+gboolean
+on_window_constants_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+void
+on_button_constants_reload_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_button_constants_close_clicked (GtkButton *button,
+ gpointer user_data);
+#endif
+
diff --git a/src/options_interface.c b/src/options_interface.c
index 8f43d15a..b15efbad 100644
--- a/src/options_interface.c
+++ b/src/options_interface.c
@@ -67,6 +67,11 @@ create_window_options (void)
GtkWidget *hbox9;
GtkWidget *image2;
GtkWidget *label35;
+ GtkWidget *button_edit_constants;
+ GtkWidget *alignment3;
+ GtkWidget *hbox19;
+ GtkWidget *image3;
+ GtkWidget *label49;
GtkWidget *label40;
GtkWidget *checkbutton_autosave;
GtkObject *spinbutton_precision_adj;
@@ -227,7 +232,6 @@ create_window_options (void)
window_options = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window_options), 5);
gtk_window_set_position (GTK_WINDOW (window_options), GTK_WIN_POS_CENTER);
- gtk_window_set_modal (GTK_WINDOW (window_options), TRUE);
vbox1 = gtk_vbox_new (FALSE, 2);
gtk_widget_show (vbox1);
@@ -374,7 +378,7 @@ create_window_options (void)
gtk_widget_show (label34);
gtk_box_pack_start (GTK_BOX (hbox7), label34, FALSE, FALSE, 0);
- hbox8 = gtk_hbox_new (FALSE, 0);
+ hbox8 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox8);
gtk_table_attach (GTK_TABLE (table1), hbox8, 1, 2, 3, 4,
(GtkAttachOptions) (GTK_FILL),
@@ -406,6 +410,27 @@ create_window_options (void)
gtk_widget_show (label35);
gtk_box_pack_start (GTK_BOX (hbox9), label35, FALSE, FALSE, 0);
+ button_edit_constants = gtk_button_new ();
+ gtk_widget_show (button_edit_constants);
+ gtk_box_pack_start (GTK_BOX (hbox8), button_edit_constants, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip (tooltips, button_edit_constants, _("Edit the constants used in the game (this won't change the file, however)"), NULL);
+
+ alignment3 = gtk_alignment_new (0.5, 0.5, 0, 0);
+ gtk_widget_show (alignment3);
+ gtk_container_add (GTK_CONTAINER (button_edit_constants), alignment3);
+
+ hbox19 = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox19);
+ gtk_container_add (GTK_CONTAINER (alignment3), hbox19);
+
+ image3 = gtk_image_new_from_stock ("gtk-edit", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (image3);
+ gtk_box_pack_start (GTK_BOX (hbox19), image3, FALSE, FALSE, 0);
+
+ label49 = gtk_label_new_with_mnemonic (_("Edit"));
+ gtk_widget_show (label49);
+ gtk_box_pack_start (GTK_BOX (hbox19), label49, FALSE, FALSE, 0);
+
label40 = gtk_label_new (_("Language"));
gtk_widget_show (label40);
gtk_table_attach (GTK_TABLE (table1), label40, 0, 1, 5, 6,
@@ -1212,6 +1237,9 @@ create_window_options (void)
g_signal_connect ((gpointer) button_reload_constants, "clicked",
G_CALLBACK (on_button_reload_constants_clicked),
NULL);
+ g_signal_connect ((gpointer) button_edit_constants, "clicked",
+ G_CALLBACK (on_button_edit_constants_clicked),
+ NULL);
g_signal_connect ((gpointer) spinbutton_recreation, "value_changed",
G_CALLBACK (on_spinbutton_recreation_value_changed),
NULL);
@@ -1265,6 +1293,11 @@ create_window_options (void)
GLADE_HOOKUP_OBJECT (window_options, hbox9, "hbox9");
GLADE_HOOKUP_OBJECT (window_options, image2, "image2");
GLADE_HOOKUP_OBJECT (window_options, label35, "label35");
+ GLADE_HOOKUP_OBJECT (window_options, button_edit_constants, "button_edit_constants");
+ GLADE_HOOKUP_OBJECT (window_options, alignment3, "alignment3");
+ GLADE_HOOKUP_OBJECT (window_options, hbox19, "hbox19");
+ GLADE_HOOKUP_OBJECT (window_options, image3, "image3");
+ GLADE_HOOKUP_OBJECT (window_options, label49, "label49");
GLADE_HOOKUP_OBJECT (window_options, label40, "label40");
GLADE_HOOKUP_OBJECT (window_options, checkbutton_autosave, "checkbutton_autosave");
GLADE_HOOKUP_OBJECT (window_options, spinbutton_precision, "spinbutton_precision");
@@ -1414,3 +1447,206 @@ create_window_options (void)
return window_options;
}
+GtkWidget*
+create_window_constants (void)
+{
+ GtkWidget *window_constants;
+ GtkWidget *vbox12;
+ GtkWidget *notebook2;
+ GtkWidget *scrolledwindow1;
+ GtkWidget *treeview_constants_integer;
+ GtkWidget *label50;
+ GtkWidget *scrolledwindow2;
+ GtkWidget *treeview_constants_float;
+ GtkWidget *label51;
+ GtkWidget *scrolledwindow3;
+ GtkWidget *treeview_constants_string;
+ GtkWidget *label52;
+ GtkWidget *scrolledwindow4;
+ GtkWidget *treeview_constants_app;
+ GtkWidget *label53;
+ GtkWidget *hseparator9;
+ GtkWidget *button_constants_reload;
+ GtkWidget *alignment4;
+ GtkWidget *hbox20;
+ GtkWidget *image4;
+ GtkWidget *label54;
+ GtkWidget *button_constants_close;
+ GtkWidget *alignment5;
+ GtkWidget *hbox21;
+ GtkWidget *image5;
+ GtkWidget *label55;
+ GtkAccelGroup *accel_group;
+ GtkTooltips *tooltips;
+
+ tooltips = gtk_tooltips_new ();
+
+ accel_group = gtk_accel_group_new ();
+
+ window_constants = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_container_set_border_width (GTK_CONTAINER (window_constants), 5);
+ gtk_window_set_title (GTK_WINDOW (window_constants), _("window1"));
+ gtk_window_set_position (GTK_WINDOW (window_constants), GTK_WIN_POS_CENTER);
+ gtk_window_set_default_size (GTK_WINDOW (window_constants), 550, 700);
+
+ vbox12 = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox12);
+ gtk_container_add (GTK_CONTAINER (window_constants), vbox12);
+
+ notebook2 = gtk_notebook_new ();
+ gtk_widget_show (notebook2);
+ gtk_box_pack_start (GTK_BOX (vbox12), notebook2, TRUE, TRUE, 0);
+
+ scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolledwindow1);
+ gtk_container_add (GTK_CONTAINER (notebook2), scrolledwindow1);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN);
+
+ treeview_constants_integer = gtk_tree_view_new ();
+ gtk_widget_show (treeview_constants_integer);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow1), treeview_constants_integer);
+
+ label50 = gtk_label_new (_("Integer"));
+ gtk_widget_show (label50);
+ gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 0), label50);
+
+ scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolledwindow2);
+ gtk_container_add (GTK_CONTAINER (notebook2), scrolledwindow2);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_SHADOW_IN);
+
+ treeview_constants_float = gtk_tree_view_new ();
+ gtk_widget_show (treeview_constants_float);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow2), treeview_constants_float);
+
+ label51 = gtk_label_new (_("Float"));
+ gtk_widget_show (label51);
+ gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 1), label51);
+
+ scrolledwindow3 = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolledwindow3);
+ gtk_container_add (GTK_CONTAINER (notebook2), scrolledwindow3);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow3), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow3), GTK_SHADOW_IN);
+
+ treeview_constants_string = gtk_tree_view_new ();
+ gtk_widget_show (treeview_constants_string);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow3), treeview_constants_string);
+
+ label52 = gtk_label_new (_("String"));
+ gtk_widget_show (label52);
+ gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 2), label52);
+
+ scrolledwindow4 = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolledwindow4);
+ gtk_container_add (GTK_CONTAINER (notebook2), scrolledwindow4);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow4), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow4), GTK_SHADOW_IN);
+
+ treeview_constants_app = gtk_tree_view_new ();
+ gtk_widget_show (treeview_constants_app);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow4), treeview_constants_app);
+
+ label53 = gtk_label_new (_("Appearance"));
+ gtk_widget_show (label53);
+ gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 3), label53);
+
+ hseparator9 = gtk_hseparator_new ();
+ gtk_widget_show (hseparator9);
+ gtk_box_pack_start (GTK_BOX (vbox12), hseparator9, FALSE, TRUE, 0);
+ gtk_widget_set_size_request (hseparator9, -1, 10);
+
+ button_constants_reload = gtk_button_new ();
+ gtk_widget_show (button_constants_reload);
+ gtk_box_pack_start (GTK_BOX (vbox12), button_constants_reload, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip (tooltips, button_constants_reload, _("Reload constants files. This will overwrite any changes you made in the current game session."), NULL);
+
+ alignment4 = gtk_alignment_new (0.5, 0.5, 0, 0);
+ gtk_widget_show (alignment4);
+ gtk_container_add (GTK_CONTAINER (button_constants_reload), alignment4);
+
+ hbox20 = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox20);
+ gtk_container_add (GTK_CONTAINER (alignment4), hbox20);
+
+ image4 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (image4);
+ gtk_box_pack_start (GTK_BOX (hbox20), image4, FALSE, FALSE, 0);
+
+ label54 = gtk_label_new_with_mnemonic (_("Reload from file"));
+ gtk_widget_show (label54);
+ gtk_box_pack_start (GTK_BOX (hbox20), label54, FALSE, FALSE, 0);
+
+ button_constants_close = gtk_button_new ();
+ gtk_widget_show (button_constants_close);
+ gtk_box_pack_start (GTK_BOX (vbox12), button_constants_close, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip (tooltips, button_constants_close, _("Close window. Changes will be saved for the current session. To make permanent changes, edit constants files directly."), NULL);
+ gtk_widget_add_accelerator (button_constants_close, "clicked", accel_group,
+ GDK_Escape, (GdkModifierType) 0,
+ GTK_ACCEL_VISIBLE);
+
+ alignment5 = gtk_alignment_new (0.5, 0.5, 0, 0);
+ gtk_widget_show (alignment5);
+ gtk_container_add (GTK_CONTAINER (button_constants_close), alignment5);
+
+ hbox21 = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox21);
+ gtk_container_add (GTK_CONTAINER (alignment5), hbox21);
+
+ image5 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (image5);
+ gtk_box_pack_start (GTK_BOX (hbox21), image5, FALSE, FALSE, 0);
+
+ label55 = gtk_label_new_with_mnemonic (_("Close"));
+ gtk_widget_show (label55);
+ gtk_box_pack_start (GTK_BOX (hbox21), label55, FALSE, FALSE, 0);
+
+ g_signal_connect ((gpointer) window_constants, "destroy_event",
+ G_CALLBACK (on_window_constants_destroy_event),
+ NULL);
+ g_signal_connect ((gpointer) window_constants, "delete_event",
+ G_CALLBACK (on_window_constants_delete_event),
+ NULL);
+ g_signal_connect ((gpointer) button_constants_reload, "clicked",
+ G_CALLBACK (on_button_constants_reload_clicked),
+ NULL);
+ g_signal_connect ((gpointer) button_constants_close, "clicked",
+ G_CALLBACK (on_button_constants_close_clicked),
+ NULL);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (window_constants, window_constants, "window_constants");
+ GLADE_HOOKUP_OBJECT (window_constants, vbox12, "vbox12");
+ GLADE_HOOKUP_OBJECT (window_constants, notebook2, "notebook2");
+ GLADE_HOOKUP_OBJECT (window_constants, scrolledwindow1, "scrolledwindow1");
+ GLADE_HOOKUP_OBJECT (window_constants, treeview_constants_integer, "treeview_constants_integer");
+ GLADE_HOOKUP_OBJECT (window_constants, label50, "label50");
+ GLADE_HOOKUP_OBJECT (window_constants, scrolledwindow2, "scrolledwindow2");
+ GLADE_HOOKUP_OBJECT (window_constants, treeview_constants_float, "treeview_constants_float");
+ GLADE_HOOKUP_OBJECT (window_constants, label51, "label51");
+ GLADE_HOOKUP_OBJECT (window_constants, scrolledwindow3, "scrolledwindow3");
+ GLADE_HOOKUP_OBJECT (window_constants, treeview_constants_string, "treeview_constants_string");
+ GLADE_HOOKUP_OBJECT (window_constants, label52, "label52");
+ GLADE_HOOKUP_OBJECT (window_constants, scrolledwindow4, "scrolledwindow4");
+ GLADE_HOOKUP_OBJECT (window_constants, treeview_constants_app, "treeview_constants_app");
+ GLADE_HOOKUP_OBJECT (window_constants, label53, "label53");
+ GLADE_HOOKUP_OBJECT (window_constants, hseparator9, "hseparator9");
+ GLADE_HOOKUP_OBJECT (window_constants, button_constants_reload, "button_constants_reload");
+ GLADE_HOOKUP_OBJECT (window_constants, alignment4, "alignment4");
+ GLADE_HOOKUP_OBJECT (window_constants, hbox20, "hbox20");
+ GLADE_HOOKUP_OBJECT (window_constants, image4, "image4");
+ GLADE_HOOKUP_OBJECT (window_constants, label54, "label54");
+ GLADE_HOOKUP_OBJECT (window_constants, button_constants_close, "button_constants_close");
+ GLADE_HOOKUP_OBJECT (window_constants, alignment5, "alignment5");
+ GLADE_HOOKUP_OBJECT (window_constants, hbox21, "hbox21");
+ GLADE_HOOKUP_OBJECT (window_constants, image5, "image5");
+ GLADE_HOOKUP_OBJECT (window_constants, label55, "label55");
+ GLADE_HOOKUP_OBJECT_NO_REF (window_constants, tooltips, "tooltips");
+
+ gtk_window_add_accel_group (GTK_WINDOW (window_constants), accel_group);
+
+ return window_constants;
+}
+
diff --git a/src/options_interface.h b/src/options_interface.h
index 4506878d..5388d11b 100644
--- a/src/options_interface.h
+++ b/src/options_interface.h
@@ -3,3 +3,4 @@
*/
GtkWidget* create_window_options (void);
+GtkWidget* create_window_constants (void);
diff --git a/src/treeview2.c b/src/treeview2.c
index 7e6577d3..35df3823 100644
--- a/src/treeview2.c
+++ b/src/treeview2.c
@@ -698,7 +698,7 @@ void
treeview2_show_news(void)
{
#ifdef DEBUG
- printf("treeview2_show_job_exchange\n");
+ printf("treeview2_show_news\n");
#endif
GtkTreeView *treeview =
@@ -714,3 +714,151 @@ treeview2_show_news(void)
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(model));
g_object_unref(model);
}
+
+/** Types of constants we use in the game,
+ enum needed for displaying purposes. */
+enum
+{
+ CONSTANTS_TYPE_INT = 0,
+ CONSTANTS_TYPE_FLOAT,
+ CONSTANTS_TYPE_STRING,
+ CONSTANTS_TYPE_APP,
+ CONSTANTS_TYPE_END
+};
+
+GtkTreeModel*
+treeview2_create_constants(const GArray *list, gint type)
+{
+#ifdef DEBUG
+ printf("treeview2_create_constants\n");
+#endif
+
+ gint i;
+ GtkTreeIter iter;
+ GtkListStore *ls;
+
+ switch(type)
+ {
+ default:
+ g_warning("treeview2_create_constants: unknown constants type\n");
+ return NULL;
+ case CONSTANTS_TYPE_INT:
+ ls = gtk_list_store_new(3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT);
+ break;
+ case CONSTANTS_TYPE_FLOAT:
+ ls = gtk_list_store_new(3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_FLOAT);
+ break;
+ case CONSTANTS_TYPE_STRING:
+ case CONSTANTS_TYPE_APP:
+ ls = gtk_list_store_new(3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING);
+ break;
+ }
+
+ for(i = 0; i < list->len; i++)
+ {
+ gtk_list_store_append(ls, &iter);
+
+ if(type == CONSTANTS_TYPE_INT)
+ gtk_list_store_set(ls, &iter,
+ 0, i,
+ 1, g_array_index(list, Option, i).name,
+ 2, g_array_index(list, Option, i).value,
+ -1);
+ else if(type == CONSTANTS_TYPE_FLOAT)
+ gtk_list_store_set(ls, &iter,
+ 0, i,
+ 1, g_array_index(list, Option, i).name,
+ 2, (gfloat)g_array_index(list, Option, i).value / OPTION_FLOAT_DIVISOR,
+ -1);
+ else
+ gtk_list_store_set(ls, &iter,
+ 0, i,
+ 1, g_array_index(list, Option, i).name,
+ 2, g_array_index(list, Option, i).string_value,
+ -1);
+ }
+
+ return GTK_TREE_MODEL(ls);
+}
+
+void
+treeview2_set_up_constants(GtkTreeView *treeview)
+{
+#ifdef DEBUG
+ printf("treeview2_set_up_constants\n");
+#endif
+
+ GtkTreeViewColumn *col;
+ GtkCellRenderer *renderer;
+ gchar *titles[3] =
+ {"",
+ _("Name"),
+ _("Value")};
+ gint i;
+
+ gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
+ GTK_SELECTION_SINGLE);
+ gtk_tree_view_set_headers_visible(treeview, TRUE);
+ gtk_tree_view_set_rules_hint(treeview, TRUE);
+
+ for(i = 0; i < 3; i++)
+ {
+ col = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_title(col, titles[i]);
+ gtk_tree_view_append_column(treeview, col);
+ renderer = treeview_helper_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(col, renderer, TRUE);
+ gtk_tree_view_column_add_attribute(col, renderer,
+ "text", i);
+ }
+}
+
+/** Show the news in the news treeview. */
+void
+treeview2_show_constants(void)
+{
+#ifdef DEBUG
+ printf("treeview2_show_constants\n");
+#endif
+
+ gint i, j;
+ GtkTreeView *treeview[4] =
+ {GTK_TREE_VIEW(lookup_widget(window.constants, "treeview_constants_integer")),
+ GTK_TREE_VIEW(lookup_widget(window.constants, "treeview_constants_float")),
+ GTK_TREE_VIEW(lookup_widget(window.constants, "treeview_constants_string")),
+ GTK_TREE_VIEW(lookup_widget(window.constants, "treeview_constants_app"))};
+ GtkTreeModel *model;
+ GArray *list[4] =
+ {g_array_new(FALSE, FALSE, sizeof(Option)),
+ g_array_new(FALSE, FALSE, sizeof(Option)),
+ g_array_new(FALSE, FALSE, sizeof(Option)),
+ constants_app.list};
+
+ for(i = 0; i < constants.list->len; i++)
+ if(g_str_has_prefix(g_array_index(constants.list, Option, i).name, "int_"))
+ g_array_append_val(list[CONSTANTS_TYPE_INT], g_array_index(constants.list, Option, i));
+ else if(g_str_has_prefix(g_array_index(constants.list, Option, i).name, "float_"))
+ g_array_append_val(list[CONSTANTS_TYPE_FLOAT], g_array_index(constants.list, Option, i));
+ else
+ g_array_append_val(list[CONSTANTS_TYPE_STRING], g_array_index(constants.list, Option, i));
+
+ for(i = 0; i < 4; i++)
+ {
+ treeview_helper_clear(treeview[i]);
+ treeview2_set_up_constants(treeview[i]);
+ model = treeview2_create_constants(list[i], i);
+ gtk_tree_view_set_model(treeview[i], model);
+ g_object_unref(model);
+
+/* if(i < 4) */
+/* { */
+/* for(j = 0; j < list[i]->len; j++) */
+/* { */
+/* g_free(g_array_index(list[i], Option, j).name); */
+/* g_free(g_array_index(list[i], Option, j).string_value); */
+/* } */
+
+/* g_array_free(list[i], TRUE); */
+/* } */
+ }
+}
diff --git a/src/treeview2.h b/src/treeview2.h
index 2c30817d..e6087871 100644
--- a/src/treeview2.h
+++ b/src/treeview2.h
@@ -82,4 +82,13 @@ treeview2_set_up_news(GtkTreeView *treeview);
void
treeview2_show_news(void);
+GtkTreeModel*
+treeview2_create_constants(const GArray *list, gint type);
+
+void
+treeview2_set_up_constants(GtkTreeView *treeview);
+
+void
+treeview2_show_constants(void);
+
#endif
diff --git a/src/window.c b/src/window.c
index 5023ee3e..0c459fb1 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1022,6 +1022,14 @@ window_create(gint window_type)
wind = window.news;
strcpy(buf, _("Bygfoot News"));
break;
+ case WINDOW_CONSTANTS:
+ if(window.constants != NULL)
+ g_warning("window_create: called on already existing window\n");
+ else
+ window.constants = create_window_constants();
+ wind = window.constants;
+ strcpy(buf, _("Bygfoot constants"));
+ break;
}
if(window_type != WINDOW_FILE_CHOOSER)
@@ -1174,3 +1182,11 @@ window_show_alr(void)
0, -current_user.debt * powf(1 + current_user.debt_interest, const_int("int_finance_payback_weeks")) + 1);
}
+/** Show the window where the user can edit constants determining
+ gameplay behaviour. */
+void
+window_show_constants(void)
+{
+ window_create(WINDOW_CONSTANTS);
+ treeview2_show_constants();
+}
diff --git a/src/window.h b/src/window.h
index 95714839..f5d2c7d5 100644
--- a/src/window.h
+++ b/src/window.h
@@ -42,6 +42,7 @@ enum Windows
WINDOW_JOB_OFFER,
WINDOW_YESNO,
WINDOW_OPTIONS,
+ WINDOW_CONSTANTS,
WINDOW_FONT_SEL,
WINDOW_FILE_CHOOSER,
WINDOW_CONTRACT,
@@ -132,4 +133,7 @@ window_show_training_camp(void);
void
window_show_alr(void);
+void
+window_show_constants(void);
+
#endif
diff --git a/support_files/bygfoot_constants b/support_files/bygfoot_constants
index e6dd4596..6759cc97 100644
--- a/support_files/bygfoot_constants
+++ b/support_files/bygfoot_constants
@@ -520,6 +520,9 @@ float_live_game_stadium_event_fire 10000
float_live_game_foul_base 7000
float_live_game_foul_max_inc 8000
+# influence of boost on foul probability
+float_team_boost_foul_factor 40000
+
# if a team already got booked it fouls less often
float_live_game_foul_prob_reduction_yellow 10000
float_live_game_foul_prob_reduction_red 20000
@@ -632,9 +635,6 @@ float_player_boost_card_effect 80000
float_team_boost_foul_by_possession_factor1 50000
float_team_boost_foul_by_possession_factor2 90000
-# influence of boost on foul probability
-float_team_boost_foul_factor 40000
-
# costs factor of boost per minute
float_boost_cost_factor 2000