Constants editing.

This commit is contained in:
gyboth 2009-03-09 20:20:26 +00:00
parent 78fc4a8af7
commit 70d42221ca
13 changed files with 1013 additions and 11 deletions

View File

@ -9,7 +9,7 @@
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">True</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
@ -519,7 +519,7 @@
<widget class="GtkHBox" id="hbox8">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<property name="spacing">2</property>
<child>
<widget class="GtkEntry" id="entry_constants_file">
@ -620,6 +620,86 @@
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_edit_constants">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Edit the constants used in the game (this won't change the file, however)</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_edit_constants_clicked" last_modification_time="Mon, 09 Mar 2009 18:34:57 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox19">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="stock">gtk-edit</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label49">
<property name="visible">True</property>
<property name="label" translatable="yes">Edit</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
@ -3595,4 +3675,431 @@
</child>
</widget>
<widget class="GtkWindow" id="window_constants">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="title" translatable="yes">window1</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="default_width">550</property>
<property name="default_height">700</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<signal name="destroy_event" handler="on_window_constants_destroy_event" last_modification_time="Mon, 09 Mar 2009 18:40:09 GMT"/>
<signal name="delete_event" handler="on_window_constants_delete_event" last_modification_time="Mon, 09 Mar 2009 18:40:18 GMT"/>
<child>
<widget class="GtkVBox" id="vbox12">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkNotebook" id="notebook2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">True</property>
<property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview_constants_integer">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label50">
<property name="visible">True</property>
<property name="label" translatable="yes">Integer</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview_constants_float">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label51">
<property name="visible">True</property>
<property name="label" translatable="yes">Float</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview_constants_string">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label52">
<property name="visible">True</property>
<property name="label" translatable="yes">String</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview_constants_app">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label53">
<property name="visible">True</property>
<property name="label" translatable="yes">Appearance</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator9">
<property name="height_request">10</property>
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_constants_reload">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Reload constants files. This will overwrite any changes you made in the current game session.</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_constants_reload_clicked" last_modification_time="Mon, 09 Mar 2009 18:48:14 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox20">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label54">
<property name="visible">True</property>
<property name="label" translatable="yes">Reload from file</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_constants_close">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Close window. Changes will be saved for the current session. To make permanent changes, edit constants files directly.</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_constants_close_clicked" last_modification_time="Mon, 09 Mar 2009 18:48:37 GMT"/>
<accelerator key="Escape" modifiers="0" signal="clicked"/>
<child>
<widget class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox21">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="stock">gtk-close</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label55">
<property name="visible">True</property>
<property name="label" translatable="yes">Close</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -160,6 +160,7 @@ typedef struct
*job_offer,
*yesno,
*options,
*constants,
*font_sel,
*file_chooser,
*contract,

View File

@ -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);

View File

@ -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))

View File

@ -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);
}

View File

@ -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

View File

@ -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;
}

View File

@ -3,3 +3,4 @@
*/
GtkWidget* create_window_options (void);
GtkWidget* create_window_constants (void);

View File

@ -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); */
/* } */
}
}

View File

@ -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

View File

@ -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();
}

View File

@ -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

View File

@ -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