Live game development.

This commit is contained in:
gyboth 2005-03-08 08:25:46 +00:00
parent e5d846bac9
commit d345416177
36 changed files with 1098 additions and 1144 deletions

View File

@ -86,7 +86,7 @@
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.05</property>
<property name="xalign">0.0500000007451</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">5</property>
@ -122,7 +122,7 @@
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
<signal name="changed" handler="on_combo_country_entry_changed" last_modification_time="Thu, 09 Dec 2004 12:48:36 GMT"/>
</widget>
@ -267,7 +267,7 @@
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.05</property>
<property name="xalign">0.0500000007451</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@ -412,7 +412,7 @@
<property name="max_length">12</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
<property name="width_chars">12</property>
<signal name="activate" handler="on_entry_player_name_activate" last_modification_time="Sat, 26 Feb 2005 10:40:03 GMT"/>
@ -770,545 +770,6 @@
</child>
</widget>
<widget class="GtkWindow" id="popup_window">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Bygfoot</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</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>
<signal name="delete_event" handler="on_popup_window_delete_event" last_modification_time="Fri, 06 Feb 2004 17:57:53 GMT"/>
<child>
<widget class="GtkVBox" id="vbox12">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHBox" id="hbox16">
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label_popup_status">
<property name="visible">True</property>
<property name="label" translatable="yes">-1</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">29</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="GtkVSeparator" id="vseparator12">
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_popup_status2">
<property name="visible">True</property>
<property name="label" translatable="yes">-1</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">22</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="GtkVSeparator" id="vseparator13">
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_popup_status3">
<property name="visible">True</property>
<property name="label" translatable="yes">-1</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">23</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>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox20">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="image_popup_warning">
<property name="stock">gtk-dialog-warning</property>
<property name="icon_size">6</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">5</property>
<property name="ypad">5</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="image_popup_question">
<property name="stock">gtk-dialog-question</property>
<property name="icon_size">6</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">5</property>
<property name="ypad">5</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_popup_text">
<property name="visible">True</property>
<property name="label" translatable="yes">label23</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</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">6</property>
</widget>
<packing>
<property name="padding">10</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radiobutton0">
<property name="can_focus">True</property>
<property name="label" translatable="yes">radiobutton0</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radiobutton1">
<property name="can_focus">True</property>
<property name="label" translatable="yes">radiobutton1</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">radiobutton0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_popup">
<property name="border_width">3</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Don't bother me with this next time</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_popup_check_toggled" last_modification_time="Thu, 05 Feb 2004 18:38:54 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox17">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkButton" id="button_popup_ok">
<property name="border_width">2</property>
<property name="tooltip" translatable="yes">Return</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_popup_ok_clicked" last_modification_time="Sun, 01 Feb 2004 16:27:19 GMT"/>
<accelerator key="Return" modifiers="0" signal="clicked"/>
<child>
<widget class="GtkAlignment" id="alignment6">
<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="hbox30">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image27">
<property name="visible">True</property>
<property name="stock">gtk-apply</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="label50">
<property name="visible">True</property>
<property name="label" translatable="yes">OK</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>
</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">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_popup_cancel">
<property name="border_width">2</property>
<property name="tooltip" translatable="yes">Esc</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_popup_cancel_clicked" last_modification_time="Sun, 01 Feb 2004 16:27:28 GMT"/>
<accelerator key="Escape" modifiers="0" signal="clicked"/>
<child>
<widget class="GtkAlignment" id="alignment7">
<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="hbox31">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image28">
<property name="visible">True</property>
<property name="stock">gtk-cancel</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="label51">
<property name="visible">True</property>
<property name="label" translatable="yes">Cancel</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>
</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">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_popup_close">
<property name="border_width">2</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_popup_close_clicked" last_modification_time="Thu, 05 Feb 2004 10:18:34 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment8">
<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="hbox32">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image29">
<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="label52">
<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>
</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">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button8">
<property name="border_width">2</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">button8</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button9">
<property name="border_width">2</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">button9</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button10">
<property name="border_width">2</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">button10</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkFileSelection" id="fsel_window">
<property name="border_width">10</property>
<property name="visible">True</property>
@ -1445,7 +906,7 @@
<property name="visible">True</property>
<property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
<property name="fraction">0</property>
<property name="pulse_step">0.1</property>
<property name="pulse_step">0.10000000149</property>
</widget>
<packing>
<property name="padding">0</property>
@ -1565,7 +1026,7 @@
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_pause_clicked" last_modification_time="Fri, 07 Jan 2005 13:35:11 GMT"/>
<accelerator key="space" modifiers="0" signal="clicked"/>
<accelerator key="Escape" modifiers="0" signal="clicked"/>
<child>
<widget class="GtkAlignment" id="alignment16">
@ -1605,7 +1066,7 @@
<child>
<widget class="GtkLabel" id="label72">
<property name="visible">True</property>
<property name="label" translatable="yes">Pause</property>
<property name="label" translatable="yes">_Pause</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@ -1640,6 +1101,7 @@
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_resume_clicked" last_modification_time="Sat, 08 Jan 2005 11:22:05 GMT"/>
<accelerator key="Return" modifiers="0" signal="clicked"/>
<child>
<widget class="GtkAlignment" id="alignment17">
@ -1679,7 +1141,7 @@
<child>
<widget class="GtkLabel" id="label73">
<property name="visible">True</property>
<property name="label" translatable="yes">Resume</property>
<property name="label" translatable="yes">_Resume</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>

View File

@ -12,6 +12,11 @@
<property name="modal">False</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>
<signal name="delete_event" handler="on_button_cancel_clicked" last_modification_time="Sat, 17 Jul 2004 19:20:32 GMT"/>
<child>
@ -73,6 +78,7 @@
<property name="label" translatable="yes">500</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -91,6 +97,7 @@
<property name="label" translatable="yes">1000</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -110,6 +117,7 @@
<property name="label" translatable="yes">1500</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -129,6 +137,7 @@
<property name="label" translatable="yes">2000</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -469,6 +478,7 @@
<property name="tooltip" translatable="yes">Return</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_ok_clicked" last_modification_time="Sat, 17 Jul 2004 19:19:57 GMT"/>
<accelerator key="Return" modifiers="0" signal="clicked"/>
@ -479,6 +489,10 @@
<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="hbox3">
@ -542,6 +556,7 @@
<property name="tooltip" translatable="yes">Esc</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_cancel_clicked" last_modification_time="Sat, 17 Jul 2004 19:20:04 GMT"/>
<accelerator key="Escape" modifiers="0" signal="clicked"/>
@ -552,6 +567,10 @@
<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="hbox4">
@ -628,6 +647,11 @@
<property name="default_height">600</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>
<child>
<widget class="GtkVBox" id="vbox5">
@ -690,7 +714,7 @@
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">2.23517e-10</property>
<property name="xalign">2.23516996578e-10</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@ -711,7 +735,7 @@
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">2.23517e-10</property>
<property name="xalign">2.23516996578e-10</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@ -732,7 +756,7 @@
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">2.23517e-10</property>
<property name="xalign">2.23516996578e-10</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@ -753,7 +777,7 @@
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">2.23517e-10</property>
<property name="xalign">2.23516996578e-10</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@ -774,7 +798,7 @@
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">2.23517e-10</property>
<property name="xalign">2.23516996578e-10</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@ -1081,6 +1105,7 @@
<property name="visible">True</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_offer_ok_clicked" last_modification_time="Wed, 18 Aug 2004 13:33:07 GMT"/>
<child>
@ -1090,6 +1115,10 @@
<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="hbox9">
@ -1152,6 +1181,7 @@
<property name="visible">True</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_offer_cancel_clicked" last_modification_time="Wed, 18 Aug 2004 13:33:15 GMT"/>
<child>
@ -1161,6 +1191,10 @@
<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="hbox8">
@ -1238,6 +1272,11 @@
<property name="default_height">400</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>
<signal name="delete_event" handler="on_graph_window_delete_event" last_modification_time="Sat, 09 Oct 2004 13:04:29 GMT"/>
<child>
@ -1458,7 +1497,7 @@
<property name="metric">GTK_PIXELS</property>
<property name="lower">0</property>
<property name="upper">10</property>
<property name="position">4.75504</property>
<property name="position">4.75504016876</property>
<property name="max_size">10</property>
</widget>
<packing>
@ -1474,7 +1513,7 @@
<property name="metric">GTK_PIXELS</property>
<property name="lower">0</property>
<property name="upper">10</property>
<property name="position">3.83285</property>
<property name="position">3.8328499794</property>
<property name="max_size">10</property>
</widget>
<packing>
@ -1701,6 +1740,7 @@
<property name="tooltip" translatable="yes">Space / Esc</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_close_clicked" last_modification_time="Sat, 09 Oct 2004 13:04:13 GMT"/>
<accelerator key="Escape" modifiers="0" signal="clicked"/>
<accelerator key="space" modifiers="0" signal="clicked"/>
@ -1709,9 +1749,13 @@
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.51</property>
<property name="yalign">0.509999990463</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="hbox14">
@ -1779,13 +1823,99 @@
<property name="modal">False</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>
<child>
<widget class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
<property name="fraction">0</property>
<property name="pulse_step">0.1</property>
<property name="pulse_step">0.10000000149</property>
</widget>
</child>
</widget>
<widget class="GtkWindow" id="window_warning">
<property name="border_width">10</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">True</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>
<signal name="delete_event" handler="on_button_warning_clicked" last_modification_time="Sat, 05 Mar 2005 19:16:17 GMT"/>
<signal name="destroy_event" handler="on_button_warning_clicked" last_modification_time="Sat, 05 Mar 2005 19:16:28 GMT"/>
<child>
<widget class="GtkVBox" id="vbox13">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">10</property>
<child>
<widget class="GtkImage" id="image7">
<property name="visible">True</property>
<property name="stock">gtk-dialog-warning</property>
<property name="icon_size">6</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">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_warning">
<property name="visible">True</property>
<property name="label" translatable="yes">label42</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>
</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_warning">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_warning_clicked" last_modification_time="Sat, 05 Mar 2005 19:12:51 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>

View File

@ -86,7 +86,8 @@ typedef struct
GtkWidget *main,
*startup,
*startup_users,
*live;
*live,
*warning;
} Windows;
/** A struct representing an option or a constant. */

View File

@ -19,6 +19,8 @@ callback_show_next_live_game(void)
{
gint i, j;
stat0 = STATUS_SHOW_LIVE_GAME;
if(week_round == 1)
{
for(i=0;i<ligs->len;i++)
@ -38,7 +40,7 @@ callback_show_next_live_game(void)
for(j=0;j<cp(i).fixtures->len;j++)
if(g_array_index(cp(i).fixtures, Fixture, j).week_number == week &&
g_array_index(cp(i).fixtures, Fixture, j).week_round_number == week_round &&
fixture_user_team_involved(&g_array_index(cp(i).fixtures, Fixture, j)) &&
fixture_user_team_involved(&g_array_index(cp(i).fixtures, Fixture, j)) != -1 &&
g_array_index(cp(i).fixtures, Fixture, j).attendance == -1)
{
live_game_calculate_fixture(&g_array_index(cp(i).fixtures, Fixture, j));
@ -46,7 +48,7 @@ callback_show_next_live_game(void)
}
}
window_destroy(&window.live);
window_destroy(&window.live, TRUE);
/* no more user games to show: end round. */
end_week_round();

View File

@ -141,7 +141,6 @@ void
on_button_new_week_clicked (GtkButton *button,
gpointer user_data)
{
stat0 = STATUS_SHOW_LIVE_GAME;
callback_show_next_live_game();
}
@ -565,7 +564,6 @@ on_menu_next_user_activate (GtkMenuItem *menuitem,
{
current_user = (current_user + 1) % users->len;
stat0 = STATUS_MAIN;
game_gui_show_main();
}
@ -576,7 +574,6 @@ on_menu_previous_user_activate (GtkMenuItem *menuitem,
{
current_user = (current_user == 0) ? users->len - 1 : current_user - 1;
stat0 = STATUS_MAIN;
game_gui_show_main();
}

View File

@ -1,20 +1,15 @@
#include "fixture.h"
#include "game.h"
#include "game_gui.h"
#include "maths.h"
#include "misc.h"
#include "option.h"
#include "player.h"
#include "team.h"
#include "treeview.h"
#include "user.h"
#include "variables.h"
/** How the cskill of field players get weighted for the team values in
a match. Rows are player position, columns value type.
@see game_get_player_contribution() */
gfloat player_weights[3][3] =
{{1, 0.4, 0.25},
{0.625, 1, 0.625},
{0.2, 0.6, 1.3}};
/** Calculate attacking, defending and goalie values for the two teams
of a fixture.
@param fix The fixture we calculate.
@ -42,9 +37,7 @@ game_get_values(const Fixture *fix, gfloat team_values[][GAME_TEAM_VALUE_END],
team_values[i][GAME_TEAM_VALUE_GOALIE] =
game_get_player_contribution(player_of(tm[i], 0), FALSE) *
(1 + home_advantage * (i == 0)) *
(1 + const_float("float_player_boost_skill_effect") *
(team_is_user(tm[i]) != -1 &&
option_int("int_opt_user_boost", usr(team_is_user(tm[i])).options) == 1));
(1 + const_float("float_player_boost_skill_effect") * tm[i]->boost);
for(j=1;j<11;j++)
{
@ -56,17 +49,18 @@ game_get_values(const Fixture *fix, gfloat team_values[][GAME_TEAM_VALUE_END],
game_get_player_contribution(player_of(tm[i], j), GAME_TEAM_VALUE_DEFEND);
}
team_values[i][GAME_TEAM_VALUE_ATTACK] *=
((1 + style_factor) * (1 + home_advantage * (i == 0)) *
(1 + const_float("float_player_boost_skill_effect") *
(team_is_user(tm[i]) != -1 &&
option_int("int_opt_user_boost", usr(team_is_user(tm[i])).options) == 1)));
team_values[i][GAME_TEAM_VALUE_DEFEND] *=
((1 - style_factor) * (1 + home_advantage * (i == 0)) *
(1 + const_float("float_player_boost_skill_effect") *
(team_is_user(tm[i]) != -1 &&
option_int("int_opt_user_boost", usr(team_is_user(tm[i])).options) == 1)));
}
for(j=GAME_TEAM_VALUE_DEFEND;j<GAME_TEAM_VALUE_DEFEND + 3;j++)
team_values[i][j] *=
((1 + style_factor) * (1 + home_advantage * (i == 0)) *
(1 + const_float("float_player_boost_skill_effect") * tm[i]->boost));
printf("%s attack %.1f midf %.1f defend %.1f style %d struct %d\n",
tm[i]->name->str,
team_values[i][GAME_TEAM_VALUE_ATTACK],
team_values[i][GAME_TEAM_VALUE_MIDFIELD],
team_values[i][GAME_TEAM_VALUE_DEFEND],
tm[i]->style, tm[i]->structure);
}
}
/** Return the contribution of a player to the attack, midfield or defend.
@ -77,7 +71,21 @@ game_get_values(const Fixture *fix, gfloat team_values[][GAME_TEAM_VALUE_END],
gfloat
game_get_player_contribution(const Player *pl, gint type)
{
return (gfloat)(pl->cskill * powf((gfloat)pl->fitness / 100,
/** How the cskill of field players get weighted for the team values in
a match. Rows are player position, columns value type.
@see game_get_player_contribution() */
gfloat player_weights[3][3] =
{{const_float("float_player_team_weight_defender_defense"),
const_float("float_player_team_weight_defender_midfield"),
const_float("float_player_team_weight_defender_attack")},
{const_float("float_player_team_weight_midfielder_defense"),
const_float("float_player_team_weight_midfielder_midfield"),
const_float("float_player_team_weight_midfielder_attack")},
{const_float("float_player_team_weight_forward_defense"),
const_float("float_player_team_weight_forward_midfield"),
const_float("float_player_team_weight_forward_attack")}};
return (gfloat)(pl->cskill * powf((gfloat)pl->fitness / 10000,
const_float("float_player_fitness_exponent")) *
player_weights[pl->cpos - 1][type - GAME_TEAM_VALUE_DEFEND]);
}
@ -181,7 +189,7 @@ game_get_player_probs(GArray *players, gfloat *probs, gfloat *weights, gboolean
gint
game_get_penalty_taker(const Team *tm, gint last_penalty)
{
gint i;
gint i, return_value = -1;
GPtrArray *players = g_ptr_array_new();
for(i=0;i<11;i++)
@ -193,20 +201,197 @@ game_get_penalty_taker(const Team *tm, gint last_penalty)
if(last_penalty == -1 ||
last_penalty == ((Player*)g_ptr_array_index(players, players->len - 1))->id)
return ((Player*)g_ptr_array_index(players, 0))->id;
return_value = ((Player*)g_ptr_array_index(players, 0))->id;
for(i=0;i<players->len - 1;i++)
if(last_penalty == ((Player*)g_ptr_array_index(players, i))->id)
return ((Player*)g_ptr_array_index(players, i + 1))->id;
{
return_value = ((Player*)g_ptr_array_index(players, i + 1))->id;
break;
}
return -1;
g_ptr_array_free(players, TRUE);
return return_value;
}
/** Calculate the number of spectators.
/** Do some things that have to be done at the beginning of a
game, e.g. calculate attendance etc.
@param fix The fixture we examine. */
void
game_calculate_attendance(Fixture *fix)
game_initialize(Fixture *fix)
{
gint i, j;
/*d*/
fix->attendance = 1000;
for(i=0;i<2;i++)
for(j=0;j<11;j++)
if(player_of(fix->teams[i], j)->cskill > 0)
game_player_increase(fix, player_of(fix->teams[i], j),
GAME_PLAYER_INCREASE_GAMES);
}
/** Save the team states in the current live game
when a pause occurs. */
void
game_save_team_states(void)
{
gint i, j;
const Team *teams[2] = {usr(stat2).live_game.fix->teams[0],
usr(stat2).live_game.fix->teams[1]};
for(i=0;i<2;i++)
{
usr(stat2).live_game.team_state[i].structure =
teams[i]->structure;
usr(stat2).live_game.team_state[i].style =
teams[i]->style;
usr(stat2).live_game.team_state[i].boost =
teams[i]->boost;
for(j=0;j<11;j++)
usr(stat2).live_game.team_state[i].player_ids[j] =
player_of(teams[i], j)->id;
}
}
/** Check whether the number of substitutions
during a live game pause isn't too high.
@return TRUE if the subs were ok, FALSE else. */
gboolean
game_check_live_game_resume_state(void)
{
gint i, j;
gint subs[2] = {0, 0};
const Team *teams[2] = {usr(stat2).live_game.fix->teams[0],
usr(stat2).live_game.fix->teams[1]};
gboolean return_value = TRUE;
for(i=0;i<2;i++)
{
for(j=0;j<11;j++)
if(!query_integer_is_in_array(player_of(teams[i], j)->id,
usr(stat2).live_game.team_state[i].player_ids,
0, 11))
subs[i]++;
if(subs[i] > usr(stat2).live_game.subs_left[i])
return_value = FALSE;
}
return return_value;
}
/** Find pairs of substituted players after a live game pause. */
void
game_get_subs(gint team_number, gint *subs_in, gint *subs_out)
{
gint i, cnt = 0;
const Team *tm = usr(stat2).live_game.fix->teams[team_number];
gint current_players[11];
for(i=0;i<3;i++)
subs_in[i] = subs_out[i] = -1;
for(i=0;i<11;i++)
{
current_players[i] = player_of(tm, i)->id;
if(!query_integer_is_in_array(player_of(tm, i)->id,
usr(stat2).live_game.team_state[team_number].player_ids,
0, 11))
{
subs_in[cnt] = player_of(tm, i)->id;
cnt++;
}
}
cnt = 0;
for(i=0;i<11;i++)
if(!query_integer_is_in_array(usr(stat2).live_game.team_state[team_number].player_ids[i],
current_players, 0, 11))
{
subs_out[cnt] = usr(stat2).live_game.team_state[team_number].player_ids[i];
cnt++;
}
}
/** Substitute a player during a match.
@param tm The team we work on.
@param player_number The index of the player. */
gint
game_substitute_player(Team *tm, gint player_number)
{
gint i;
GPtrArray *substitutes = g_ptr_array_new();
gboolean adapt_structure;
gint substitute = -1;
for(i=11;i<tm->players->len;i++)
g_ptr_array_add(substitutes, player_of(tm, i));
/* printf("################## %d\n", player_of(tm, player_number)->cpos); */
g_ptr_array_sort_with_data(substitutes, (GCompareDataFunc)player_compare_substitute_func,
GINT_TO_POINTER(player_of(tm, player_number)->cpos));
adapt_structure =
player_substitution_good_structure(tm->structure,
player_of(tm, player_number)->cpos,
((Player*)g_ptr_array_index(substitutes, 0))->pos);
substitute = ((Player*)g_ptr_array_index(substitutes, 0))->id;
player_swap(tm, player_number,
tm, player_id_index(tm, ((Player*)g_ptr_array_index(substitutes, 0))->id));
g_ptr_array_free(substitutes, TRUE);
if(adapt_structure)
{
team_change_structure(tm, team_find_appropriate_structure(tm));
team_rearrange(tm);
}
if(team_is_user(tm) == current_user)
{
game_gui_write_av_skills();
selected_row[0] = -1;
treeview_show_user_player_list(&usr(current_user), 1);
}
return substitute;
}
/** Increase the number of shots in the player struct.
@param fix The game being played.
@param team The team index.
@param player_id The player id. */
void
game_player_increase(const Fixture *fix, Player *pl, gint type)
{
gint i;
PlayerGamesGoals new;
for(i=0;i<pl->games_goals->len;i++)
if(g_array_index(pl->games_goals, PlayerGamesGoals, i).clid == fix->clid)
{
if(type == GAME_PLAYER_INCREASE_SHOTS)
g_array_index(pl->games_goals, PlayerGamesGoals, i).shots++;
else if(type == GAME_PLAYER_INCREASE_GOALS)
g_array_index(pl->games_goals, PlayerGamesGoals, i).goals++;
else if(type == GAME_PLAYER_INCREASE_GAMES)
g_array_index(pl->games_goals, PlayerGamesGoals, i).games++;
return;
}
/* Entry not found, we create a new one. */
new.clid = fix->clid;
new.shots = new.goals = new.games = 0;
g_array_append_val(pl->games_goals, new);
game_player_increase(fix, pl, type);
}

View File

@ -27,6 +27,15 @@ enum GamePlayerType
GAME_PLAYER_TYPE_END
};
/** @see game_player_increase() */
enum GamePlayerIncreaseType
{
GAME_PLAYER_INCREASE_SHOTS = 0,
GAME_PLAYER_INCREASE_GOALS,
GAME_PLAYER_INCREASE_GAMES,
GAME_PLAYER_INCREASE_END
};
void
game_get_values(const Fixture *fix, gfloat team_values[][GAME_TEAM_VALUE_END],
gfloat home_advantage);
@ -46,6 +55,21 @@ gint
game_get_penalty_taker(const Team *tm, gint last_penalty);
void
game_calculate_attendance(Fixture *fix);
game_initialize(Fixture *fix);
void
game_save_team_states(void);
gboolean
game_check_live_game_resume_state(void);
void
game_get_subs(gint team_number, gint *subs_in, gint *subs_out);
gint
game_substitute_player(Team *tm, gint player_number);
void
game_player_increase(const Fixture *fix, Player *pl, gint type);
#endif

View File

@ -11,6 +11,7 @@
#include "team.h"
#include "user.h"
#include "variables.h"
#include "window.h"
/** Show the live game in the live game window.
@param unit The current unit we show.
@ -46,6 +47,8 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit)
gtk_widget_set_sensitive(lookup_widget(window.live, "button_live_close"), TRUE);
gtk_widget_hide(lookup_widget(window.live, "button_pause"));
}
else if(unit->event.type == LIVE_GAME_EVENT_PENALTIES)
gtk_widget_hide(lookup_widget(window.live, "button_pause"));
}
/** Set the area scale position and color in the live game window.
@ -192,7 +195,7 @@ game_gui_write_radio_items(void)
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(style[usr(current_user).tm->style + 2]), TRUE);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(scout[usr(current_user).scout]), TRUE);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(physio[usr(current_user).physio]), TRUE);
gtk_check_menu_item_set_active(boost, opt_user_int("int_opt_user_boost"));
gtk_check_menu_item_set_active(boost, usr(current_user).tm->boost);
}
/** Set playing style etc. variables according to
@ -210,8 +213,7 @@ game_gui_read_radio_items(GtkWidget *widget)
game_gui_get_radio_items(style, scout, physio);
if(widget == boost)
opt_user_set_int("int_opt_user_boost",
!opt_user_int("int_opt_user_boost"));
usr(current_user).tm->boost = !usr(current_user).tm->boost;
for(i=0;i<5;i++)
if(widget == style[i])
@ -328,3 +330,13 @@ game_gui_set_main_window_sensitivity(gboolean value)
gtk_widget_set_sensitive(window.main, value);
}
/** Show a window with a warning.
@param text The text to show in the window. */
void
game_gui_show_warning(gchar *text)
{
window_create(WINDOW_WARNING);
gtk_label_set_text(GTK_LABEL(lookup_widget(window.warning, "label_warning")), text);
}

View File

@ -38,4 +38,7 @@ game_gui_set_main_window_sensitivity(gboolean value);
void
game_gui_write_av_skills(void);
void
game_gui_show_warning(gchar *text);
#endif

View File

@ -35,28 +35,21 @@ gboolean show;
void
live_game_calculate_fixture(Fixture *fix)
{
Fixture *local_fix = NULL;
if(stat0 != STATUS_LIVE_GAME_PAUSE)
if(stat0 != STATUS_LIVE_GAME_PAUSE)
{
local_fix = fix;
live_game_reset(local_fix);
game_calculate_attendance(local_fix);
live_game_reset(fix);
game_initialize(fix);
}
else
{
stat0 = STATUS_SHOW_LIVE_GAME;
local_fix = usr(stat2).live_game.fix;
match = &usr(stat2).live_game;
}
game_get_values(match->fix, match->team_values,
match->home_advantage);
do
{
live_game_create_unit();
live_game_evaluate_unit(&last_unit);
if(show)
game_gui_live_game_show_unit(&last_unit);
}
while(last_unit.event.type != LIVE_GAME_EVENT_END_MATCH &&
stat0 != STATUS_LIVE_GAME_PAUSE);
@ -65,8 +58,8 @@ live_game_calculate_fixture(Fixture *fix)
{
live_game_create_stats();
if(query_fixture_has_tables(local_fix))
table_update(local_fix);
if(query_fixture_has_tables(fix))
table_update(fix);
}
}
@ -77,7 +70,7 @@ live_game_create_unit(void)
{
LiveGameUnit new;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_create_unit\n");
if(unis->len == 0)
{
@ -104,7 +97,6 @@ live_game_create_unit(void)
{
new.event.type = live_game_get_break();
new.possession = last_unit.possession;
live_game_generate_commentary(&new, FALSE);
g_array_append_val(unis, new);
return;
}
@ -128,7 +120,7 @@ live_game_fill_new_unit(LiveGameUnit *new)
const_float("float_live_game_stadium_event_exponent"));
gfloat possession_change, scoring_chance = 0;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_fill_new_unit\n");
possession_change = const_float("float_live_game_event_general") *
const_float("float_live_game_possession_changes") /
@ -178,7 +170,7 @@ live_game_create_start_unit(void)
{
LiveGameUnit new;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_create_start_unit\n");
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1;
@ -208,10 +200,10 @@ live_game_evaluate_unit(LiveGameUnit *unit)
{
gint type = unit->event.type;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_evaluate_unit type %d\n", type);
if(type == LIVE_GAME_EVENT_FOUL)
live_game_event_foul(TRUE);
live_game_event_foul();
else if(type == LIVE_GAME_EVENT_LOST_POSSESSION)
live_game_event_lost_possession();
else if(type == LIVE_GAME_EVENT_INJURY)
@ -225,13 +217,15 @@ live_game_evaluate_unit(LiveGameUnit *unit)
else if(type == LIVE_GAME_EVENT_GENERAL)
live_game_event_general(FALSE);
else if(type == LIVE_GAME_EVENT_START_MATCH)
live_game_generate_commentary(&last_unit, TRUE);
live_game_generate_commentary(&last_unit);
else if(type == LIVE_GAME_EVENT_HALF_TIME ||
type == LIVE_GAME_EVENT_EXTRA_TIME ||
type == LIVE_GAME_EVENT_PENALTIES)
type == LIVE_GAME_EVENT_PENALTIES ||
type == LIVE_GAME_EVENT_END_MATCH)
{
live_game_generate_commentary(&last_unit, FALSE);
if(show)
live_game_generate_commentary(&last_unit);
if(type != LIVE_GAME_EVENT_END_MATCH && show &&
option_int("int_opt_user_pause_break", usr(fixture_user_team_involved(match->fix)).options))
misc_callback_pause_live_game();
}
else if(type != LIVE_GAME_EVENT_END_MATCH)
@ -243,22 +237,22 @@ live_game_evaluate_unit(LiveGameUnit *unit)
@param general Whether to create a general event after
showing this one. @see live_game_event_general() */
void
live_game_event_foul(gboolean general)
live_game_event_foul(void)
{
gfloat rndom = math_rnd(0, 1);
gint type;
gint type, fouled_player, foul_player;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_foul\n");
if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_GENERAL)
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
fouled_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER];
else
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
fouled_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
game_get_player(tm[last_unit.possession],
last_unit.area, 0, -1, FALSE);
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] =
foul_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] =
game_get_player(tm[!last_unit.possession],
last_unit.area, 0, -1, FALSE);
@ -273,7 +267,7 @@ live_game_event_foul(gboolean general)
last_unit.event.type = type;
live_game_generate_commentary(&last_unit, TRUE);
live_game_generate_commentary(&last_unit);
if(type == LIVE_GAME_EVENT_FOUL_RED ||
type == LIVE_GAME_EVENT_FOUL_RED_INJURY ||
@ -281,11 +275,9 @@ live_game_event_foul(gboolean general)
query_live_game_second_yellow(!last_unit.possession,
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2])))
{
live_game_event_send_off(!last_unit.possession,
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]);
live_game_event_send_off(!last_unit.possession, foul_player);
if(type == LIVE_GAME_EVENT_FOUL_RED_INJURY)
live_game_event_injury(last_unit.possession,
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER], TRUE);
live_game_event_injury(last_unit.possession, fouled_player, TRUE);
}
if(last_unit.area == LIVE_GAME_UNIT_AREA_ATTACK)
@ -295,18 +287,14 @@ live_game_event_foul(gboolean general)
live_game_event_penalty();
else if(rndom < const_float("float_live_game_free_kick_prob"))
live_game_event_free_kick();
else
live_game_event_general(TRUE);
}
else
live_game_event_general(TRUE);
}
/** Calculate a lost possession event. */
void
live_game_event_lost_possession(void)
{
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_lost_possession\n");
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
game_get_player(tm[last_unit.possession],
@ -320,12 +308,12 @@ live_game_event_lost_possession(void)
game_get_player(tm[!last_unit.possession],
uni(unis->len - 2).area, 0, -1, FALSE);
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("## pls %d %d\n",
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER],
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]);
live_game_generate_commentary(&last_unit, TRUE);
live_game_generate_commentary(&last_unit);
live_game_event_general(TRUE);
}
@ -340,8 +328,9 @@ void
live_game_event_injury(gint team, gint player, gboolean create_new)
{
LiveGameUnit new;
gint old_structure = -1;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_injury\n");
if(create_new)
{
@ -354,7 +343,7 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
team;
}
else
live_game_event_injury_get_player();
live_game_injury_get_player();
last_unit.minute = -1;
last_unit.event.type = LIVE_GAME_EVENT_INJURY;
@ -362,10 +351,33 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
if(math_rnd(0, 1) < const_float("float_live_game_injury_is_temp"))
last_unit.event.type = LIVE_GAME_EVENT_TEMP_INJURY;
live_game_generate_commentary(&last_unit, TRUE);
live_game_generate_commentary(&last_unit);
/*d*/
live_game_event_general(TRUE);
if(last_unit.event.type == LIVE_GAME_EVENT_INJURY)
{
if(show &&
team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]) != -1 &&
option_int("int_opt_user_pause_injury",
usr(team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]])).options) &&
!option_int("int_opt_user_auto_sub",
usr(team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]])).options))
misc_callback_pause_live_game();
else if(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->players->len > 11)
{
old_structure = tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure;
live_game_event_substitution(
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM],
game_substitute_player(
tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
player_id_index(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER])),
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]);
if(old_structure != tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure)
live_game_event_team_change(last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM],
LIVE_GAME_EVENT_STRUCTURE_CHANGE);
}
}
}
/** Calculate a stadium event. */
@ -374,7 +386,7 @@ live_game_event_stadium(void)
{
gfloat rndom = math_rnd(0, 1);
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_stadium\n");
if(rndom < const_float("float_live_game_stadium_event_fire"))
last_unit.event.type = LIVE_GAME_EVENT_STADIUM_FIRE;
@ -383,7 +395,7 @@ live_game_event_stadium(void)
else if(rndom < const_float("float_live_game_stadium_event_breakdown"))
last_unit.event.type = LIVE_GAME_EVENT_STADIUM_BREAKDOWN;
live_game_generate_commentary(&last_unit, TRUE);
live_game_generate_commentary(&last_unit);
live_game_event_general(TRUE);
}
@ -392,7 +404,7 @@ live_game_event_stadium(void)
void
live_game_event_scoring_chance(void)
{
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_scoring_chance\n");
if(math_rnd(0, 1) < const_float("float_live_game_scoring_chance_is_own_goal"))
{
@ -430,7 +442,7 @@ live_game_event_scoring_chance(void)
}
}
live_game_generate_commentary(&last_unit, TRUE);
live_game_generate_commentary(&last_unit);
live_game_event_duel();
}
@ -441,7 +453,7 @@ live_game_event_penalty(void)
{
LiveGameUnit new;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_penalty\n");
if(last_unit.time != LIVE_GAME_UNIT_TIME_PENALTIES)
@ -495,7 +507,7 @@ live_game_event_penalty(void)
game_get_player(tm[last_unit.possession], GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE);
}
live_game_generate_commentary(&last_unit, TRUE);
live_game_generate_commentary(&last_unit);
live_game_event_duel();
}
@ -507,7 +519,7 @@ live_game_event_general(gboolean create_new)
{
LiveGameUnit new;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_general\n");
if(create_new)
{
@ -534,7 +546,7 @@ live_game_event_general(gboolean create_new)
last_unit.event.type == LIVE_GAME_EVENT_CROSS_BAR) &&
math_rnd(0, 1) < const_float("float_live_game_possession_after_post")))
{
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("##### last type: %d\n", last_unit.event.type);
new.possession = last_unit.possession;
new.area = (last_unit.event.type == LIVE_GAME_EVENT_GENERAL) ?
@ -575,12 +587,12 @@ live_game_event_general(gboolean create_new)
live_game_event_general_get_players();
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("+++ general %d %d\n",
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER],
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]);
live_game_generate_commentary(&last_unit, FALSE);
live_game_generate_commentary(&last_unit);
}
/** Fill in the players values in a general unit. */
@ -590,21 +602,19 @@ live_game_event_general_get_players(void)
gint *pl1 = &last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER];
gint *pl2 = &last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2];
gint old_pl1 =
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER],
old_pl2 =
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER2];
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER];
gint type = uni(unis->len - 2).event.type;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_general_get_players\n");
*pl1 = *pl2 = -1;
if(type == LIVE_GAME_EVENT_LOST_POSSESSION)
{
*pl1 = old_pl2;
*pl2 = game_get_player(tm[last_unit.possession],
*pl1 = game_get_player(tm[last_unit.possession],
last_unit.area, 0, *pl1,
TRUE);
*pl2 = old_pl1;
}
else if(type != LIVE_GAME_EVENT_GENERAL)
{
@ -628,7 +638,7 @@ live_game_event_free_kick(void)
{
LiveGameUnit new = last_unit;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_free_kick\n");
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1;
@ -651,7 +661,7 @@ live_game_event_free_kick(void)
g_array_append_val(unis, new);
live_game_generate_commentary(&last_unit, TRUE);
live_game_generate_commentary(&last_unit);
live_game_event_duel();
}
@ -660,9 +670,10 @@ live_game_event_free_kick(void)
void
live_game_event_send_off(gint team, gint player)
{
gint old_structure = tm[team]->structure;
LiveGameUnit new = last_unit;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_send_off\n");
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1;
@ -676,7 +687,69 @@ live_game_event_send_off(gint team, gint player)
g_array_append_val(unis, new);
live_game_generate_commentary(&last_unit, TRUE);
live_game_generate_commentary(&last_unit);
if(show && team_is_user(tm[team]) != -1 &&
option_int("int_opt_user_pause_red",
usr(team_is_user(tm[team])).options) &&
!option_int("int_opt_user_auto_sub",
usr(team_is_user(tm[team])).options))
misc_callback_pause_live_game();
else if(tm[team]->players->len > 11)
{
old_structure = tm[team]->structure;
live_game_event_substitution(team,
game_substitute_player(tm[team],
player_id_index(tm[team], player)), player);
if(old_structure != tm[team]->structure)
live_game_event_team_change(team, LIVE_GAME_EVENT_STRUCTURE_CHANGE);
}
}
/** Show a substitution event.
@param team_number The team that substitutes.
@param sub_in The id of the player who moves into the team.
@param sub_out The id of the player who gets replaced. */
void
live_game_event_substitution(gint team_number, gint sub_in, gint sub_out)
{
LiveGameUnit new = last_unit;
new.minute = -1;
new.time = live_game_get_time(&last_unit);
new.event.commentary = g_string_new("dummy commentary");
new.event.type = LIVE_GAME_EVENT_SUBSTITUTION;
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = team_number;
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = sub_in;
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = sub_out;
g_array_append_val(unis, new);
live_game_generate_commentary(&last_unit);
}
/** Show a team change event, e.g. structure change.
@param team_number The index of the team.
@param event_type The event type. */
void
live_game_event_team_change(gint team_number, gint event_type)
{
LiveGameUnit new = last_unit;
new.minute = -1;
new.time = live_game_get_time(&last_unit);
new.event.commentary = g_string_new("dummy commentary");
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = team_number;
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1;
new.event.type = event_type;
g_array_append_val(unis, new);
live_game_generate_commentary(&last_unit);
}
/** Calculate whether a player who tries to score succeeds. */
@ -690,7 +763,7 @@ live_game_event_duel(void)
Player *attacker, *goalie;
gint res_idx1, res_idx2;
if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1)
if(opt_int("int_opt_debug"))
printf("live_game_event_duel\n");
new.minute = -1;
@ -698,12 +771,12 @@ live_game_event_duel(void)
new.event.commentary = g_string_new("duel");
attacker = player_of(tm[new.possession],
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]);
attacker = player_of_id(tm[new.possession],
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]);
goalie = player_of(tm[!new.possession], 0);
duel_factor = (((gfloat)attacker->cskill * powf((gfloat)attacker->fitness / 100,
duel_factor = (((gfloat)attacker->cskill * powf((gfloat)attacker->fitness / 10000,
const_float("float_player_fitness_exponent"))) /
((gfloat)goalie->cskill * powf((gfloat)goalie->fitness / 100,
((gfloat)goalie->cskill * powf((gfloat)goalie->fitness / 10000,
const_float("float_player_fitness_exponent"))));
res_idx1 = new.possession;
if(new.time == LIVE_GAME_UNIT_TIME_PENALTIES)
@ -724,18 +797,30 @@ live_game_event_duel(void)
match->team_values[!new.possession][GAME_TEAM_VALUE_DEFEND],
const_float("float_live_game_score_team_exponent"));
if(new.time != LIVE_GAME_UNIT_TIME_PENALTIES)
{
game_player_increase(match->fix, attacker, GAME_PLAYER_INCREASE_SHOTS);
game_player_increase(match->fix, goalie, GAME_PLAYER_INCREASE_SHOTS);
}
if(rndom < scoring_prob)
{
new.event.type = LIVE_GAME_EVENT_GOAL;
match->fix->result[res_idx1][res_idx2]++;
new.result[res_idx1]++;
if(new.time != LIVE_GAME_UNIT_TIME_PENALTIES)
{
game_player_increase(match->fix, attacker, GAME_PLAYER_INCREASE_GOALS);
game_player_increase(match->fix, goalie, GAME_PLAYER_INCREASE_GOALS);
}
}
else
new.event.type = math_gauss_disti(LIVE_GAME_EVENT_POST, LIVE_GAME_EVENT_CROSS_BAR);
g_array_append_val(unis, new);
live_game_generate_commentary(&last_unit, TRUE);
live_game_generate_commentary(&last_unit);
if(last_unit.time != LIVE_GAME_UNIT_TIME_PENALTIES)
live_game_event_general(TRUE);
@ -945,21 +1030,22 @@ live_game_reset(Fixture *fix)
match->home_advantage =
math_rnd(const_float("float_game_home_advantage_lower"),
const_float("float_game_home_advantage_upper"));
game_get_values(match->fix, match->team_values,
match->home_advantage);
}
/** Generate commentary for the live game event in the unit
and show the unit in the live game window.
@param unit The unit we comment. */
void
live_game_generate_commentary(LiveGameUnit *unit, gboolean show_unit)
live_game_generate_commentary(LiveGameUnit *unit)
{
GString *commentary = unit->event.commentary;
switch(unit->event.type)
{
default:
g_warning("live_game_generate_commentary: unknown event type %d\n",
unit->event.type);
break;
case LIVE_GAME_EVENT_GENERAL:
if(unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER] != -1 &&
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] != -1)
@ -1066,12 +1152,12 @@ live_game_generate_commentary(LiveGameUnit *unit, gboolean show_unit)
break;
case LIVE_GAME_EVENT_INJURY:
g_string_printf(commentary, "%s is injured.",
player_of_id(tm[unit->possession],
player_of_id(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->name->str);
break;
case LIVE_GAME_EVENT_TEMP_INJURY:
g_string_printf(commentary, "%s is injured but he can continue to play.",
player_of_id(tm[unit->possession],
player_of_id(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->name->str);
break;
case LIVE_GAME_EVENT_PENALTIES:
@ -1086,9 +1172,34 @@ live_game_generate_commentary(LiveGameUnit *unit, gboolean show_unit)
case LIVE_GAME_EVENT_STADIUM_RIOTS:
g_string_printf(commentary, "There are riots in the stadium.");
break;
case LIVE_GAME_EVENT_SUBSTITUTION:
g_string_printf(commentary, "%s substitutes %s for %s.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str,
player_of_id(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->name->str,
player_of_id(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2])->name->str);
break;
case LIVE_GAME_EVENT_STRUCTURE_CHANGE:
g_string_printf(commentary, "%s changes structure to %d.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str,
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure);
break;
case LIVE_GAME_EVENT_STYLE_CHANGE:
g_string_printf(commentary, "%s changes style to %s.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str,
team_style_to_char(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->style));
break;
case LIVE_GAME_EVENT_BOOST_CHANGE:
if(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->boost)
g_string_printf(commentary, "%s changes boost to ON.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
else
g_string_printf(commentary, "%s changes boost to OFF.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
}
if(show && show_unit)
if(show)
game_gui_live_game_show_unit(unit);
}
@ -1219,7 +1330,7 @@ live_game_pit_teams(const LiveGameUnit *unit, gfloat exponent)
/** Find a random player (influenced by fitness) who gets
injured. */
void
live_game_event_injury_get_player(void)
live_game_injury_get_player(void)
{
gint i, j;
gfloat probs[22];
@ -1228,14 +1339,17 @@ live_game_event_injury_get_player(void)
for(j=0;j<2;j++)
{
probs[j * 11] = const_float("float_live_game_injury_goalie_factor") *
(gfloat)(100 - player_of(tm[j], 0)->fitness) *
((gfloat)(10000 - player_of(tm[j], 0)->fitness) / 100) *
(player_of(tm[j], 0)->cskill != 0);
if(j == 1)
probs[11] += probs[10];
for(i=1;i<11;i++)
probs[i + j * 11] = probs[i + j * 11 - 1] +
(gfloat)(100 - player_of(tm[j], i)->fitness) *
((gfloat)(10000 - player_of(tm[j], i)->fitness) / 100) *
(player_of(tm[j], i)->cskill != 0);
}
rndom = math_rnd(0, probs[21]);
if(rndom < probs[0])
@ -1253,3 +1367,39 @@ live_game_event_injury_get_player(void)
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = (i > 10);
}
}
/** Resume a live game. Show team changes. */
void
live_game_resume(void)
{
gint i, j;
gint subs_in[3],
subs_out[3];
match = &usr(stat2).live_game;
for(i=0;i<2;i++)
{
game_get_subs(i, subs_in, subs_out);
for(j=0;j<3;j++)
{
if(subs_in[j] != -1)
{
usr(stat2).live_game.subs_left[i]--;
live_game_event_substitution(i, subs_in[j], subs_out[j]);
}
}
if(tm[i]->structure != usr(stat2).live_game.team_state[i].structure)
live_game_event_team_change(i, LIVE_GAME_EVENT_STRUCTURE_CHANGE);
if(tm[i]->style != usr(stat2).live_game.team_state[i].style)
live_game_event_team_change(i, LIVE_GAME_EVENT_STYLE_CHANGE);
if(tm[i]->boost != usr(stat2).live_game.team_state[i].boost)
live_game_event_team_change(i, LIVE_GAME_EVENT_BOOST_CHANGE);
}
live_game_calculate_fixture(usr(stat2).live_game.fix);
}

View File

@ -35,7 +35,7 @@ void
live_game_evaluate_unit(LiveGameUnit *unit);
void
live_game_event_foul(gboolean general);
live_game_event_foul(void);
void
live_game_event_lost_possession(void);
@ -65,7 +65,7 @@ void
live_game_event_send_off(gint team, gint player);
void
live_game_generate_commentary(LiveGameUnit *unit, gboolean show_unit);
live_game_generate_commentary(LiveGameUnit *unit);
void
live_game_event_duel(void);
@ -89,6 +89,15 @@ gfloat
live_game_pit_teams(const LiveGameUnit *unit, gfloat exponent);
void
live_game_event_injury_get_player(void);
live_game_injury_get_player(void);
void
live_game_resume(void);
void
live_game_event_substitution(gint team_number, gint sub_in, gint sub_out);
void
live_game_event_team_change(gint team_number, gint event_type);
#endif

View File

@ -45,8 +45,7 @@ enum LiveGameEventType
LIVE_GAME_EVENT_SUBSTITUTION,
LIVE_GAME_EVENT_STRUCTURE_CHANGE,
LIVE_GAME_EVENT_STYLE_CHANGE,
/* LIVE_GAME_EVENT_, */
/* LIVE_GAME_EVENT_, */
LIVE_GAME_EVENT_BOOST_CHANGE,
LIVE_GAME_EVENT_END
};
@ -150,6 +149,16 @@ typedef struct
} LiveGameUnit;
/** A structure storing team settings during a live game
pause (so that we know what users have changed in pauses. */
typedef struct
{
gint structure, style;
gboolean boost;
gint player_ids[11];
} LiveGameTeamState;
typedef struct
{
/** The fixture that belongs to the game. */
@ -170,6 +179,7 @@ typedef struct
GArray *units;
/** Match statistics. @see #LiveGameStats */
LiveGameStats stats;
LiveGameTeamState team_state[2];
} LiveGame;
#endif

View File

@ -25,7 +25,7 @@ main_init_variables(void)
player_names = NULL;
window.main = window.startup = window.startup_users =
window.live = NULL;
window.live = window.warning = NULL;
live_game_temp.units = NULL;
@ -92,7 +92,10 @@ main (gint argc, gchar *argv[])
window_show_startup();
gtk_window_get_position(GTK_WINDOW(window.startup), &x_pos, &y_pos);
gtk_window_move(GTK_WINDOW(window.startup_users), x_pos, y_pos);
stat0 = STATUS_TEAM_SELECTION;
stat0 = STATUS_TEAM_SELECTION;
/*d*/
on_button_add_player_clicked(NULL, NULL);
gtk_main ();

View File

@ -166,3 +166,33 @@ misc_print_grouped_int(gint number, gchar *buf, gboolean append)
else if(number == 0)
strcat(buf, "0");
}
/** Check whether 'item' is in array 'array' between
'min' and 'max'.
@param array The integer list.
@param min The lower delimitor (inclusive).
@param max The upper delimitor (exclusive).
@param item The item we look for. */
gboolean
query_integer_is_in_array(gint item, gint *array, gint min, gint max)
{
gint i;
for(i=min;i<max;i++)
if(item == array[i])
return TRUE;
return FALSE;
}
/** Compare two integers. */
gint
misc_int_compare(gint first, gint second)
{
if(first > second)
return -1;
else if(first < second)
return 1;
return 0;
}

View File

@ -21,4 +21,10 @@ misc_randomise_g_pointer_array(GPtrArray *array);
void
misc_print_grouped_int(gint number, gchar *buf, gboolean append);
gboolean
query_integer_is_in_array(gint item, gint *array, gint min, gint max);
gint
misc_int_compare(gint first, gint second);
#endif

View File

@ -4,9 +4,12 @@
#include <gtk/gtk.h>
#include "bygfoot.h"
#include "misc2_callbacks.h"
#include "misc2_interface.h"
#include "support.h"
#include "variables.h"
#include "window.h"
gboolean
@ -76,3 +79,14 @@ on_button_close_clicked (GtkButton *button,
}
gboolean
on_button_warning_clicked (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
window_destroy(&window.warning, FALSE);
return FALSE;
}

View File

@ -34,3 +34,8 @@ on_optionmenu_team_changed (GtkOptionMenu *optionmenu,
void
on_button_close_clicked (GtkButton *button,
gpointer user_data);
gboolean
on_button_warning_clicked (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);

View File

@ -889,3 +889,54 @@ create_progressbar_window (void)
return progressbar_window;
}
GtkWidget*
create_window_warning (void)
{
GtkWidget *window_warning;
GtkWidget *vbox13;
GtkWidget *image7;
GtkWidget *label_warning;
GtkWidget *button_warning;
window_warning = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window_warning), 10);
gtk_window_set_title (GTK_WINDOW (window_warning), _("window1"));
gtk_window_set_position (GTK_WINDOW (window_warning), GTK_WIN_POS_CENTER);
gtk_window_set_modal (GTK_WINDOW (window_warning), TRUE);
vbox13 = gtk_vbox_new (FALSE, 10);
gtk_widget_show (vbox13);
gtk_container_add (GTK_CONTAINER (window_warning), vbox13);
image7 = gtk_image_new_from_stock ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG);
gtk_widget_show (image7);
gtk_box_pack_start (GTK_BOX (vbox13), image7, FALSE, TRUE, 0);
label_warning = gtk_label_new (_("label42"));
gtk_widget_show (label_warning);
gtk_box_pack_start (GTK_BOX (vbox13), label_warning, FALSE, FALSE, 0);
button_warning = gtk_button_new_from_stock ("gtk-close");
gtk_widget_show (button_warning);
gtk_box_pack_start (GTK_BOX (vbox13), button_warning, FALSE, FALSE, 0);
g_signal_connect ((gpointer) window_warning, "delete_event",
G_CALLBACK (on_button_warning_clicked),
NULL);
g_signal_connect ((gpointer) window_warning, "destroy_event",
G_CALLBACK (on_button_warning_clicked),
NULL);
g_signal_connect ((gpointer) button_warning, "clicked",
G_CALLBACK (on_button_warning_clicked),
NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (window_warning, window_warning, "window_warning");
GLADE_HOOKUP_OBJECT (window_warning, vbox13, "vbox13");
GLADE_HOOKUP_OBJECT (window_warning, image7, "image7");
GLADE_HOOKUP_OBJECT (window_warning, label_warning, "label_warning");
GLADE_HOOKUP_OBJECT (window_warning, button_warning, "button_warning");
return window_warning;
}

View File

@ -6,3 +6,4 @@ GtkWidget* create_stadium_window (void);
GtkWidget* create_job_offer_window (void);
GtkWidget* create_graph_window (void);
GtkWidget* create_progressbar_window (void);
GtkWidget* create_window_warning (void);

View File

@ -1,3 +1,4 @@
#include "game.h"
#include "game_gui.h"
#include "misc_callback_func.h"
#include "start_end.h"
@ -64,8 +65,8 @@ misc_callback_start_game(void)
for(i=0;i<users->len;i++)
user_set_up_team_new_game(&usr(i));
window_destroy(&window.startup);
window_destroy(&window.startup_users);
window_destroy(&window.startup, TRUE);
window_destroy(&window.startup_users, TRUE);
window_create(WINDOW_MAIN);
@ -144,6 +145,7 @@ misc_callback_pause_live_game(void)
gtk_widget_show(lookup_widget(window.live, "button_resume"));
game_gui_set_main_window_sensitivity(TRUE);
game_save_team_states();
stat0 = STATUS_LIVE_GAME_PAUSE;
}

View File

@ -102,48 +102,6 @@ on_team_selection_load_clicked (GtkButton *button,
}
gboolean
on_popup_window_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
return FALSE;
}
void
on_popup_check_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
}
void
on_button_popup_ok_clicked (GtkButton *button,
gpointer user_data)
{
}
void
on_button_popup_cancel_clicked (GtkButton *button,
gpointer user_data)
{
}
void
on_button_popup_close_clicked (GtkButton *button,
gpointer user_data)
{
}
gboolean
on_fsel_window_delete_event (GtkWidget *widget,
GdkEvent *event,
@ -210,6 +168,7 @@ void
on_button_live_close_clicked (GtkButton *button,
gpointer user_data)
{
stat2 = -1;
callback_show_next_live_game();
}
@ -248,10 +207,18 @@ void
on_button_resume_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(GTK_WIDGET(button));
gtk_widget_show(lookup_widget(window.live, "button_pause"));
game_gui_set_main_window_sensitivity(FALSE);
live_game_calculate_fixture(NULL);
if(game_check_live_game_resume_state())
{
gtk_widget_hide(GTK_WIDGET(button));
if(g_array_index(usr(stat2).live_game.units, LiveGameUnit,
usr(stat2).live_game.units->len - 1).event.type !=
LIVE_GAME_EVENT_PENALTIES)
gtk_widget_show(lookup_widget(window.live, "button_pause"));
game_gui_set_main_window_sensitivity(FALSE);
live_game_resume();
}
else
game_gui_show_warning("There were too many substitutions. Only 3 per game are allowed.");
}
void

View File

@ -43,27 +43,6 @@ void
on_team_selection_load_clicked (GtkButton *button,
gpointer user_data);
gboolean
on_popup_window_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
void
on_popup_check_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
void
on_button_popup_ok_clicked (GtkButton *button,
gpointer user_data);
void
on_button_popup_cancel_clicked (GtkButton *button,
gpointer user_data);
void
on_button_popup_close_clicked (GtkButton *button,
gpointer user_data);
gboolean
on_fsel_window_delete_event (GtkWidget *widget,
GdkEvent *event,

View File

@ -414,261 +414,6 @@ create_window_startup (void)
return window_startup;
}
GtkWidget*
create_popup_window (void)
{
GtkWidget *popup_window;
GtkWidget *vbox12;
GtkWidget *hbox16;
GtkWidget *label_popup_status;
GtkWidget *vseparator12;
GtkWidget *label_popup_status2;
GtkWidget *vseparator13;
GtkWidget *label_popup_status3;
GtkWidget *hbox20;
GtkWidget *image_popup_warning;
GtkWidget *image_popup_question;
GtkWidget *label_popup_text;
GtkWidget *radiobutton0;
GSList *radiobutton0_group = NULL;
GtkWidget *radiobutton1;
GtkWidget *check_popup;
GtkWidget *hbox17;
GtkWidget *button_popup_ok;
GtkWidget *alignment6;
GtkWidget *hbox30;
GtkWidget *image27;
GtkWidget *label50;
GtkWidget *button_popup_cancel;
GtkWidget *alignment7;
GtkWidget *hbox31;
GtkWidget *image28;
GtkWidget *label51;
GtkWidget *button_popup_close;
GtkWidget *alignment8;
GtkWidget *hbox32;
GtkWidget *image29;
GtkWidget *label52;
GtkWidget *button8;
GtkWidget *button9;
GtkWidget *button10;
GtkAccelGroup *accel_group;
GtkTooltips *tooltips;
tooltips = gtk_tooltips_new ();
accel_group = gtk_accel_group_new ();
popup_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (popup_window), 6);
gtk_window_set_title (GTK_WINDOW (popup_window), _("Bygfoot"));
gtk_window_set_position (GTK_WINDOW (popup_window), GTK_WIN_POS_CENTER);
vbox12 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox12);
gtk_container_add (GTK_CONTAINER (popup_window), vbox12);
hbox16 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox12), hbox16, TRUE, TRUE, 0);
label_popup_status = gtk_label_new (_("-1"));
gtk_widget_show (label_popup_status);
gtk_box_pack_start (GTK_BOX (hbox16), label_popup_status, FALSE, FALSE, 0);
gtk_misc_set_padding (GTK_MISC (label_popup_status), 29, 0);
vseparator12 = gtk_vseparator_new ();
gtk_widget_show (vseparator12);
gtk_box_pack_start (GTK_BOX (hbox16), vseparator12, TRUE, TRUE, 0);
label_popup_status2 = gtk_label_new (_("-1"));
gtk_widget_show (label_popup_status2);
gtk_box_pack_start (GTK_BOX (hbox16), label_popup_status2, FALSE, FALSE, 0);
gtk_misc_set_padding (GTK_MISC (label_popup_status2), 22, 0);
vseparator13 = gtk_vseparator_new ();
gtk_widget_show (vseparator13);
gtk_box_pack_start (GTK_BOX (hbox16), vseparator13, TRUE, TRUE, 0);
label_popup_status3 = gtk_label_new (_("-1"));
gtk_widget_show (label_popup_status3);
gtk_box_pack_start (GTK_BOX (hbox16), label_popup_status3, FALSE, FALSE, 0);
gtk_misc_set_padding (GTK_MISC (label_popup_status3), 23, 0);
hbox20 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox20);
gtk_box_pack_start (GTK_BOX (vbox12), hbox20, TRUE, TRUE, 0);
image_popup_warning = gtk_image_new_from_stock ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox20), image_popup_warning, TRUE, TRUE, 0);
gtk_misc_set_padding (GTK_MISC (image_popup_warning), 5, 5);
image_popup_question = gtk_image_new_from_stock ("gtk-dialog-question", GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox20), image_popup_question, TRUE, TRUE, 0);
gtk_misc_set_padding (GTK_MISC (image_popup_question), 5, 5);
label_popup_text = gtk_label_new (_("label23"));
gtk_widget_show (label_popup_text);
gtk_box_pack_start (GTK_BOX (vbox12), label_popup_text, FALSE, FALSE, 10);
gtk_label_set_line_wrap (GTK_LABEL (label_popup_text), TRUE);
gtk_misc_set_padding (GTK_MISC (label_popup_text), 0, 6);
radiobutton0 = gtk_radio_button_new_with_mnemonic (NULL, _("radiobutton0"));
gtk_box_pack_start (GTK_BOX (vbox12), radiobutton0, FALSE, FALSE, 0);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton0), radiobutton0_group);
radiobutton0_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton0));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton0), TRUE);
radiobutton1 = gtk_radio_button_new_with_mnemonic (NULL, _("radiobutton1"));
gtk_box_pack_start (GTK_BOX (vbox12), radiobutton1, FALSE, FALSE, 0);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton1), radiobutton0_group);
radiobutton0_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton1));
check_popup = gtk_check_button_new_with_mnemonic (_("Don't bother me with this next time"));
gtk_box_pack_start (GTK_BOX (vbox12), check_popup, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (check_popup), 3);
hbox17 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox17);
gtk_box_pack_start (GTK_BOX (vbox12), hbox17, TRUE, TRUE, 0);
button_popup_ok = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (hbox17), button_popup_ok, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (button_popup_ok), 2);
gtk_tooltips_set_tip (tooltips, button_popup_ok, _("Return"), NULL);
gtk_widget_add_accelerator (button_popup_ok, "clicked", accel_group,
GDK_Return, 0,
GTK_ACCEL_VISIBLE);
alignment6 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment6);
gtk_container_add (GTK_CONTAINER (button_popup_ok), alignment6);
hbox30 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox30);
gtk_container_add (GTK_CONTAINER (alignment6), hbox30);
image27 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image27);
gtk_box_pack_start (GTK_BOX (hbox30), image27, FALSE, FALSE, 0);
label50 = gtk_label_new_with_mnemonic (_("OK"));
gtk_widget_show (label50);
gtk_box_pack_start (GTK_BOX (hbox30), label50, FALSE, FALSE, 0);
button_popup_cancel = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (hbox17), button_popup_cancel, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (button_popup_cancel), 2);
gtk_tooltips_set_tip (tooltips, button_popup_cancel, _("Esc"), NULL);
gtk_widget_add_accelerator (button_popup_cancel, "clicked", accel_group,
GDK_Escape, 0,
GTK_ACCEL_VISIBLE);
alignment7 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment7);
gtk_container_add (GTK_CONTAINER (button_popup_cancel), alignment7);
hbox31 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox31);
gtk_container_add (GTK_CONTAINER (alignment7), hbox31);
image28 = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image28);
gtk_box_pack_start (GTK_BOX (hbox31), image28, FALSE, FALSE, 0);
label51 = gtk_label_new_with_mnemonic (_("Cancel"));
gtk_widget_show (label51);
gtk_box_pack_start (GTK_BOX (hbox31), label51, FALSE, FALSE, 0);
button_popup_close = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (hbox17), button_popup_close, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (button_popup_close), 2);
alignment8 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment8);
gtk_container_add (GTK_CONTAINER (button_popup_close), alignment8);
hbox32 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox32);
gtk_container_add (GTK_CONTAINER (alignment8), hbox32);
image29 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image29);
gtk_box_pack_start (GTK_BOX (hbox32), image29, FALSE, FALSE, 0);
label52 = gtk_label_new_with_mnemonic (_("Close"));
gtk_widget_show (label52);
gtk_box_pack_start (GTK_BOX (hbox32), label52, FALSE, FALSE, 0);
button8 = gtk_button_new_with_mnemonic (_("button8"));
gtk_box_pack_start (GTK_BOX (hbox17), button8, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (button8), 2);
button9 = gtk_button_new_with_mnemonic (_("button9"));
gtk_box_pack_start (GTK_BOX (hbox17), button9, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (button9), 2);
button10 = gtk_button_new_with_mnemonic (_("button10"));
gtk_box_pack_start (GTK_BOX (hbox17), button10, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (button10), 2);
g_signal_connect ((gpointer) popup_window, "delete_event",
G_CALLBACK (on_popup_window_delete_event),
NULL);
g_signal_connect ((gpointer) check_popup, "toggled",
G_CALLBACK (on_popup_check_toggled),
NULL);
g_signal_connect ((gpointer) button_popup_ok, "clicked",
G_CALLBACK (on_button_popup_ok_clicked),
NULL);
g_signal_connect ((gpointer) button_popup_cancel, "clicked",
G_CALLBACK (on_button_popup_cancel_clicked),
NULL);
g_signal_connect ((gpointer) button_popup_close, "clicked",
G_CALLBACK (on_button_popup_close_clicked),
NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (popup_window, popup_window, "popup_window");
GLADE_HOOKUP_OBJECT (popup_window, vbox12, "vbox12");
GLADE_HOOKUP_OBJECT (popup_window, hbox16, "hbox16");
GLADE_HOOKUP_OBJECT (popup_window, label_popup_status, "label_popup_status");
GLADE_HOOKUP_OBJECT (popup_window, vseparator12, "vseparator12");
GLADE_HOOKUP_OBJECT (popup_window, label_popup_status2, "label_popup_status2");
GLADE_HOOKUP_OBJECT (popup_window, vseparator13, "vseparator13");
GLADE_HOOKUP_OBJECT (popup_window, label_popup_status3, "label_popup_status3");
GLADE_HOOKUP_OBJECT (popup_window, hbox20, "hbox20");
GLADE_HOOKUP_OBJECT (popup_window, image_popup_warning, "image_popup_warning");
GLADE_HOOKUP_OBJECT (popup_window, image_popup_question, "image_popup_question");
GLADE_HOOKUP_OBJECT (popup_window, label_popup_text, "label_popup_text");
GLADE_HOOKUP_OBJECT (popup_window, radiobutton0, "radiobutton0");
GLADE_HOOKUP_OBJECT (popup_window, radiobutton1, "radiobutton1");
GLADE_HOOKUP_OBJECT (popup_window, check_popup, "check_popup");
GLADE_HOOKUP_OBJECT (popup_window, hbox17, "hbox17");
GLADE_HOOKUP_OBJECT (popup_window, button_popup_ok, "button_popup_ok");
GLADE_HOOKUP_OBJECT (popup_window, alignment6, "alignment6");
GLADE_HOOKUP_OBJECT (popup_window, hbox30, "hbox30");
GLADE_HOOKUP_OBJECT (popup_window, image27, "image27");
GLADE_HOOKUP_OBJECT (popup_window, label50, "label50");
GLADE_HOOKUP_OBJECT (popup_window, button_popup_cancel, "button_popup_cancel");
GLADE_HOOKUP_OBJECT (popup_window, alignment7, "alignment7");
GLADE_HOOKUP_OBJECT (popup_window, hbox31, "hbox31");
GLADE_HOOKUP_OBJECT (popup_window, image28, "image28");
GLADE_HOOKUP_OBJECT (popup_window, label51, "label51");
GLADE_HOOKUP_OBJECT (popup_window, button_popup_close, "button_popup_close");
GLADE_HOOKUP_OBJECT (popup_window, alignment8, "alignment8");
GLADE_HOOKUP_OBJECT (popup_window, hbox32, "hbox32");
GLADE_HOOKUP_OBJECT (popup_window, image29, "image29");
GLADE_HOOKUP_OBJECT (popup_window, label52, "label52");
GLADE_HOOKUP_OBJECT (popup_window, button8, "button8");
GLADE_HOOKUP_OBJECT (popup_window, button9, "button9");
GLADE_HOOKUP_OBJECT (popup_window, button10, "button10");
GLADE_HOOKUP_OBJECT_NO_REF (popup_window, tooltips, "tooltips");
gtk_window_add_accel_group (GTK_WINDOW (popup_window), accel_group);
return popup_window;
}
GtkWidget*
create_fsel_window (void)
{
@ -864,7 +609,7 @@ create_window_live (void)
gtk_widget_show (button_pause);
gtk_box_pack_start (GTK_BOX (hbox48), button_pause, FALSE, FALSE, 0);
gtk_widget_add_accelerator (button_pause, "clicked", accel_group,
GDK_space, 0,
GDK_Escape, 0,
GTK_ACCEL_VISIBLE);
alignment16 = gtk_alignment_new (0.5, 0.5, 0, 0);
@ -879,12 +624,15 @@ create_window_live (void)
gtk_widget_show (image56);
gtk_box_pack_start (GTK_BOX (hbox51), image56, FALSE, FALSE, 0);
label72 = gtk_label_new_with_mnemonic (_("Pause"));
label72 = gtk_label_new_with_mnemonic (_("_Pause"));
gtk_widget_show (label72);
gtk_box_pack_start (GTK_BOX (hbox51), label72, FALSE, FALSE, 0);
button_resume = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (hbox48), button_resume, FALSE, FALSE, 0);
gtk_widget_add_accelerator (button_resume, "clicked", accel_group,
GDK_Return, 0,
GTK_ACCEL_VISIBLE);
alignment17 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment17);
@ -898,7 +646,7 @@ create_window_live (void)
gtk_widget_show (image57);
gtk_box_pack_start (GTK_BOX (hbox52), image57, FALSE, FALSE, 0);
label73 = gtk_label_new_with_mnemonic (_("Resume"));
label73 = gtk_label_new_with_mnemonic (_("_Resume"));
gtk_widget_show (label73);
gtk_box_pack_start (GTK_BOX (hbox52), label73, FALSE, FALSE, 0);

View File

@ -3,7 +3,6 @@
*/
GtkWidget* create_window_startup (void);
GtkWidget* create_popup_window (void);
GtkWidget* create_fsel_window (void);
GtkWidget* create_font_sel_window (void);
GtkWidget* create_window_live (void);

View File

@ -2,6 +2,7 @@
#include "free.h"
#include "league.h"
#include "maths.h"
#include "misc.h"
#include "option.h"
#include "player.h"
#include "team.h"
@ -271,38 +272,23 @@ player_of_ids(gint clid, gint team_id, gint id)
return pl;
}
/** Return the number of all games or goals the player's
participated in / scored in all cups and leagues.
@param pl The player we examine.
@param goals Whether we sum up the goals.
@return The number of goals. */
/** Get a player's index in the players array from
his id.
@param tm The team.
@param player_id The player's id.
@return The array index or -1. */
gint
player_all_games_goals(const Player *pl, gboolean goals)
player_id_index(const Team *tm, gint player_id)
{
gint i, sum = 0;
gint i;
for(i=0;i<pl->games_goals->len;i++)
if(goals)
sum += g_array_index(pl->games_goals, PlayerGamesGoals, i).goals;
else
sum += g_array_index(pl->games_goals, PlayerGamesGoals, i).games;
return sum;
}
/** Return the sum of all the yellow cards in all
leagues and cups for the player.
@param pl The player we examine.
@return The number of all cards.*/
gint
player_all_cards(const Player *pl)
{
gint i, sum = 0;
for(i=0;i<pl->cards->len;i++)
sum += g_array_index(pl->cards, PlayerCard, i).yellow;
return sum;
for(i=0;i<tm->players->len;i++)
if(g_array_index(tm->players, Player, i).id == player_id)
return i;
g_warning("player_id_index: didn't find player with id %d of team %s\n", player_id, tm->name->str);
return -1;
}
/** Return a pointer to the number'th player of the team.
@ -341,10 +327,47 @@ player_of_id(const Team *tm, gint id)
return NULL;
}
/** Return the number of all games or goals the player's
participated in / scored in all cups and leagues.
@param pl The player we examine.
@param goals Whether we sum up the goals.
@return The number of goals. */
gint
player_all_games_goals(const Player *pl, gint type)
{
gint i, sum = 0;
for(i=0;i<pl->games_goals->len;i++)
if(type == PLAYER_LIST_ATTRIBUTE_GOALS)
sum += g_array_index(pl->games_goals, PlayerGamesGoals, i).goals;
else if(type == PLAYER_LIST_ATTRIBUTE_GAMES)
sum += g_array_index(pl->games_goals, PlayerGamesGoals, i).games;
else if(type == PLAYER_LIST_ATTRIBUTE_SHOTS)
sum += g_array_index(pl->games_goals, PlayerGamesGoals, i).shots;
return sum;
}
/** Return the sum of all the yellow cards in all
leagues and cups for the player.
@param pl The player we examine.
@return The number of all cards.*/
gint
player_all_cards(const Player *pl)
{
gint i, sum = 0;
for(i=0;i<pl->cards->len;i++)
sum += g_array_index(pl->cards, PlayerCard, i).yellow;
return sum;
}
/** Compare two players in a pointer array.
@param pl1 Pointer to the pointer to the first player.
@param pl2 Pointer to the pointer to the second player.
@param data Coded integer that tells us which attribute to compare. */
@param data Coded integer that tells us which attribute to compare.
@return 1, 0 or -1 (see the C qsort() function). */
gint
player_compare_func(gconstpointer a, gconstpointer b, gpointer data)
{
@ -354,23 +377,91 @@ player_compare_func(gconstpointer a, gconstpointer b, gpointer data)
gint return_value = 0;
if(type == PLAYER_COMPARE_ATTRIBUTE_GAME_SKILL)
{
if(pl1->cskill == pl2->cskill && pl1->fitness == pl2->fitness)
return_value = 0;
else if((gfloat)pl1->cskill *
powf((gfloat)pl1->fitness / 100,
const_float("float_player_fitness_exponent")) >
(gfloat)pl2->cskill *
powf((gfloat)pl2->fitness / 100,
const_float("float_player_fitness_exponent")))
return_value = -1;
else
return_value = 1;
}
return_value =
misc_int_compare(pl1->cskill * pl1->fitness, pl2->cskill * pl2->fitness);
return return_value;
}
/** Compare two players in a pointer array.
@param pl1 Pointer to the pointer to the first player.
@param pl2 Pointer to the pointer to the second player.
@param data Coded integer that tells us which position we
would like to substitute.
@return 1, 0 or -1 (see the C qsort() function). */
gint
player_compare_substitute_func(gconstpointer a, gconstpointer b, gpointer data)
{
const Player *pl1 = *(const Player**)a;
const Player *pl2 = *(const Player**)b;
gint position = GPOINTER_TO_INT(data);
gint skill_for_pos1 = player_get_cskill(pl1, position) * pl1->fitness,
skill_for_pos2 = player_get_cskill(pl2, position) * pl2->fitness;
gint game_skill1 = pl1->cskill * pl1->fitness,
game_skill2 = pl2->cskill * pl2->fitness;
gboolean good_structure1 =
player_substitution_good_structure(pl1->team->structure, position, pl1->pos),
good_structure2 =
player_substitution_good_structure(pl2->team->structure, position, pl2->pos);
gint return_value = 0;
if(pl1->pos == position && pl2->pos == position)
return_value =
misc_int_compare(game_skill1, game_skill2);
else if(pl1->pos == position)
return_value = -1;
//misc_int_compare(game_skill1, skill_for_pos2);
else if(pl2->pos == position)
return_value = 1;
//misc_int_compare(skill_for_pos1, game_skill2);
else if(position != PLAYER_POS_GOALIE)
{
if(good_structure1 && good_structure2)
return_value =
misc_int_compare(game_skill1, game_skill2);
else if(good_structure1)
return_value =
misc_int_compare(game_skill1, skill_for_pos2);
else if(good_structure2)
return_value =
misc_int_compare(skill_for_pos1, game_skill2);
else
return_value =
misc_int_compare(skill_for_pos1, skill_for_pos2);
}
else
return_value =
misc_int_compare(skill_for_pos1, skill_for_pos2);
/* printf("%s %d %s %d %d\n", pl1->name->str, pl1->pos, pl2->name->str, */
/* pl2->pos, return_value); */
/* printf("\t gaski %.1f %.1f skipos %.1f %.1f struc %d %d\n", */
/* (gfloat)game_skill1 / 10000, (gfloat)game_skill2 / 10000, */
/* (gfloat)skill_for_pos1 / 10000, (gfloat)skill_for_pos2 / 10000, */
/* good_structure1, good_structure2); */
return return_value;
}
/** Find out whether substituting a player into a team
and adapting the team structure results in a normal
structure.
@param old_structure The team's structure before substituting.
@param old_pos The position of the player that gets replaced.
@param player_pos The position of the player that comes into the game.
@return TRUE or FALSE. */
gboolean
player_substitution_good_structure(gint old_structure, gint old_pos, gint player_pos)
{
gint accepted_structures[5] = {532, 442, 352, 433, 343};
gint new_structure =
old_structure - (gint)rint(powf(10, PLAYER_POS_FORWARD - old_pos)) +
(gint)rint(powf(10, PLAYER_POS_FORWARD - player_pos));
return query_integer_is_in_array(new_structure, accepted_structures, 0, 5);
}
/** Move a player from one player array to another one.
@param tm1 The source team.
@param player_number The index of the player in the players array.
@ -401,8 +492,9 @@ player_swap(Team *tm1, gint player_number1, Team *tm2, gint player_number2)
player_get_position_from_structure(tm2->structure, player_number2);
else
player_of(tm2, player_number2)->cpos = player_of(tm2, player_number2)->pos;
player_of(tm2, player_number2)->cskill =
player_get_cskill(player_of(tm2, player_number2));
player_get_cskill(player_of(tm2, player_number2), player_of(tm2, player_number2)->cpos);
player_move(tm2, player_number2 + move,
tm1, player_number1);
@ -411,36 +503,39 @@ player_swap(Team *tm1, gint player_number1, Team *tm2, gint player_number2)
player_get_position_from_structure(tm1->structure, player_number1);
else
player_of(tm1, player_number1)->cpos = player_of(tm1, player_number1)->pos;
player_of(tm1, player_number1)->cskill =
player_get_cskill(player_of(tm1, player_number1));
player_get_cskill(player_of(tm1, player_number1), player_of(tm1, player_number1)->cpos);
}
/** Return the player's cskill depending on
whether he's on his normal position or not.
@param pl The player we examine.
@param position The position we's like to put the player.
@return A new cskill. */
gint
player_get_cskill(const Player *pl)
player_get_cskill(const Player *pl, gint position)
{
gfloat cskill_factor;
if(pl->health != PLAYER_INJURY_NONE ||
player_is_banned(pl) > 0)
cskill_factor = 0.0;
else if(pl->pos == pl->cpos)
cskill_factor = 1.0;
else if(pl->cpos == PLAYER_POS_GOALIE ||
pl->pos == PLAYER_POS_GOALIE)
cskill_factor = 0.5;
else if(abs(pl->cpos - pl->pos) == 2)
cskill_factor = 0.65;
else
cskill_factor = 0.75;
return 0;
if(pl->cpos != pl->pos)
return MIN(pl->talent * cskill_factor, pl->skill);
if(pl->pos != position)
{
if(position == PLAYER_POS_GOALIE ||
pl->pos == PLAYER_POS_GOALIE)
cskill_factor = 0.5;
else if(abs(position - pl->pos) == 2)
cskill_factor = 0.65;
else
cskill_factor = 0.75;
return MIN((gint)rint((gfloat)pl->talent * cskill_factor), pl->skill);
}
else
return pl->skill * (cskill_factor != 0);
return pl->skill;
}
/** Find out whether the player is banned in

View File

@ -42,7 +42,7 @@ void
player_remove_from_team(Team *tm, gint player_number);
gint
player_all_games_goals(const Player *pl, gboolean goals);
player_all_games_goals(const Player *pl, gint type);
gint
player_all_cards(const Player *pl);
@ -59,6 +59,9 @@ player_of_id(const Team *tm, gint id);
gint
player_compare_func(gconstpointer a, gconstpointer b, gpointer data);
gint
player_compare_substitute_func(gconstpointer a, gconstpointer b, gpointer data);
void
player_move(Team *tm1, gint player_number, Team *tm2, gint insert_at);
@ -66,9 +69,15 @@ void
player_swap(Team *tm1, gint player_number1, Team *tm2, gint player_number2);
gint
player_get_cskill(const Player *pl);
player_get_cskill(const Player *pl, gint position);
gint
player_is_banned(const Player *pl);
gboolean
player_substitution_good_structure(gint old_structure, gint old_pos, gint player_pos);
gint
player_id_index(const Team *tm, gint player_id);
#endif

View File

@ -42,6 +42,8 @@ typedef struct
gint games;
/** Number of goals (scored for field players or conceded for goalies). */
gint goals;
/** Number of shots (taken or faced). */
gint shots;
} PlayerGamesGoals;
enum PlayerInjury
@ -67,7 +69,7 @@ typedef struct
talent, /**< Talent. The peak ability (which isn't always reached). */
etal[QUALITY_END], /**< Estimated talent (the user never sees the actual talent).
Depends on scout quality. */
fitness, /**< Fitness. Between 0 and 99. */
fitness, /**< Fitness. Between 0 and 9900. */
health, /**< Health. An integer signifying an injury or good health. @see #PlayerInjury */
recovery, /**< Weeks until the player gets healthy. */
id, /**< Id of the player within the team. */
@ -99,6 +101,7 @@ enum PlayerListAttributeValue
PLAYER_LIST_ATTRIBUTE_FITNESS,
PLAYER_LIST_ATTRIBUTE_GAMES,
PLAYER_LIST_ATTRIBUTE_GOALS,
PLAYER_LIST_ATTRIBUTE_SHOTS,
PLAYER_LIST_ATTRIBUTE_STATUS,
PLAYER_LIST_ATTRIBUTE_CARDS,
PLAYER_LIST_ATTRIBUTE_AGE,

View File

@ -57,7 +57,14 @@ start_new_season(void)
fixture_write_league_fixtures(&lig(i));
for(i=0;i<cps->len;i++)
{
fixture_write_cup_fixtures(&cp(i));
/*d*/
/* printf("%s %d %d %d\n", */
/* cp(i).name->str, cp(i).id, */
/* g_array_index(cp(i).fixtures, Fixture, 0).week_number, */
/* g_array_index(cp(i).fixtures, Fixture, 0).week_round_number); */
}
}
/** Fill some global variables with default values at the
@ -69,7 +76,7 @@ start_write_variables(void)
season = week = week_round = 1;
current_user = 0;
//week=23; week_round = 2;
/* week=24; week_round = 2; */
transfer_list = g_array_new(FALSE, FALSE, sizeof(TransferPlayer));
for(i=0;i<users->len;i++)
@ -187,7 +194,7 @@ end_week_round_results(void)
for(j=0;j<cp(i).fixtures->len;j++)
if(g_array_index(cp(i).fixtures, Fixture, j).week_number == week &&
g_array_index(cp(i).fixtures, Fixture, j).week_round_number == week_round &&
g_array_index(lig(i).fixtures, Fixture, j).attendance == -1)
g_array_index(cp(i).fixtures, Fixture, j).attendance == -1)
{
live_game_calculate_fixture(&g_array_index(cp(i).fixtures, Fixture, j));
/*d*/

View File

@ -26,6 +26,7 @@ team_new(void)
new.clid = new.id = -1;
new.structure = team_assign_playing_structure();
new.style = team_assign_playing_style();
new.boost = FALSE;
new.stadium = team_stadium_new();
@ -110,13 +111,15 @@ team_generate_players(Team *tm)
if(tm->clid < ID_CUP_START)
average_skill =
(gint)rint((gfloat)team_return_league_cup_value_int(tm, LEAGUE_CUP_VALUE_AVERAGE_SKILL) *
(gint)rint((gfloat)const_int("int_player_max_skill") *
((gfloat)team_return_league_cup_value_int(tm, LEAGUE_CUP_VALUE_AVERAGE_SKILL) / 100) *
skill_factor);
else
average_skill =
(gint)rint((gfloat)lig(0).average_skill +
(gfloat)team_return_league_cup_value_int(tm, LEAGUE_CUP_VALUE_SKILL_DIFF)) *
skill_factor;
(gint)rint((gfloat)const_int("int_player_max_skill") *
(((gfloat)lig(0).average_skill +
(gfloat)team_return_league_cup_value_int(tm, LEAGUE_CUP_VALUE_SKILL_DIFF)) / 100) *
skill_factor);
average_skill = CLAMP(average_skill, 0, const_int("int_player_max_skill"));
@ -500,7 +503,7 @@ team_get_average_skill(const Team *tm, gboolean cskill)
for(i=0;i<11;i++)
{
sum += player_of(tm, i)->cskill *
powf((gfloat)player_of(tm, i)->fitness / 100,
powf((gfloat)player_of(tm, i)->fitness / 10000,
const_float("float_player_fitness_exponent"));
counter++;
}
@ -577,7 +580,7 @@ team_change_structure(Team *tm, gint new_structure)
player_get_position_from_structure(new_structure, i);
player_of(tm, i)->cskill =
player_get_cskill(player_of(tm, i));
player_get_cskill(player_of(tm, i), player_of(tm, i)->cpos);
}
}
@ -621,3 +624,29 @@ team_rearrange(Team *tm)
i++;
}
}
/** Describe the playing style in words.
@param style The team style.
@return The name of the style. */
gchar*
team_style_to_char(gint style)
{
switch(style)
{
default:
g_warning("team_style_to_char: unknown style %d\n", style);
return NULL;
case PLAYING_STYLE_ALL_OUT_DEFEND:
return _("All Out Defend");
case PLAYING_STYLE_DEFEND:
return _("Defend");
case PLAYING_STYLE_BALANCED:
return _("Balanced");
case PLAYING_STYLE_ATTACK:
return _("Attack");
case PLAYING_STYLE_ALL_OUT_ATTACK:
return _("All Out Attack");
}
return NULL;
}

View File

@ -78,4 +78,7 @@ team_find_appropriate_structure(const Team *tm);
void
team_rearrange(Team *tm);
gchar*
team_style_to_char(gint style);
#endif

View File

@ -59,7 +59,8 @@ typedef struct
id, /**< Id of the team. */
structure, /**< Playing structure. @see team_assign_playing_structure() */
style; /**< Playing style. @see team_assign_playing_style() */
gboolean boost; /**< Whether player boost is switched on. */
Stadium stadium;
/**
Array of players.

View File

@ -143,9 +143,6 @@ treeview_live_game_icon(gint event_type)
case LIVE_GAME_EVENT_FOUL_YELLOW:
return "yellow.png";
break;
case LIVE_GAME_EVENT_FOUL_RED:
return "red.png";
break;
case LIVE_GAME_EVENT_SEND_OFF:
return "red.png";
break;
@ -393,6 +390,7 @@ treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max)
_("Fit"),
_("Ga"),
_("Go"),
_("Sh"),
_("Status"),
_("YC"),
_("Age"),
@ -465,6 +463,8 @@ treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListA
gtk_tree_view_set_model(treeview, model);
g_object_unref(model);
g_ptr_array_free(players, TRUE);
}
/** Show the list of the user's players in the left view.
@ -501,7 +501,7 @@ treeview_live_game_show_commentary(const LiveGameUnit *unit)
symbol =
treeview_pixbuf_from_filename(treeview_live_game_icon(unit->event.type));
sprintf(buf, "%d.", live_game_unit_get_minute(unit));
sprintf(buf, "%3d.", live_game_unit_get_minute(unit));
gtk_list_store_prepend(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, buf, 1, symbol,
2, unit->event.commentary->str, -1);
@ -530,7 +530,7 @@ treeview_live_game_create_init_commentary(const LiveGameUnit *unit)
GDK_TYPE_PIXBUF,
G_TYPE_STRING);
sprintf(buf, "%d.", unit->minute);
sprintf(buf, "%3d.", unit->minute);
symbol =
treeview_pixbuf_from_filename(treeview_live_game_icon(unit->event.type));
@ -750,7 +750,7 @@ treeview_set_up_users_startup(GtkTreeView *treeview)
GtkTreeViewColumn *col;
GtkCellRenderer *renderer;
gchar *titles[4] =
{_(""),
{"",
_("Name"),
_("Team"),
_("Start in")};

View File

@ -64,24 +64,21 @@ treeview_cell_player_to_cell(GtkTreeViewColumn *col,
gint column = treeview_get_col_number_column(col);
gint attribute = GPOINTER_TO_INT(user_data);
gchar buf[SMALL];
gchar fg_color[SMALL],
bg_color[SMALL];
Player *pl;
if(strcmp(usr(current_user).font_name->str, "0") != 0)
g_object_set(renderer, "font", usr(current_user).font_name->str, NULL);
strcpy(fg_color, const_str("string_treeview_cell_color_default_foreground"));
strcpy(bg_color, const_str("string_treeview_cell_color_default_background"));
g_object_set(renderer, "text", "", "foreground",
const_str("string_treeview_cell_color_default_foreground"),
"background",
const_str("string_treeview_cell_color_default_background"), NULL);
strcpy(buf, "");
gtk_tree_model_get(model, iter, column, &pl, -1);
if(pl == NULL)
{
g_object_set(renderer, "text", "", "foreground", fg_color, "background", bg_color, NULL);
return;
}
switch(attribute)
{
@ -105,10 +102,13 @@ treeview_cell_player_to_cell(GtkTreeViewColumn *col,
break;
case PLAYER_LIST_ATTRIBUTE_GAMES:
/*todo*/
treeview_cell_player_games_goals_to_cell(buf, pl, FALSE);
treeview_cell_player_games_goals_to_cell(buf, pl, PLAYER_LIST_ATTRIBUTE_GAMES);
break;
case PLAYER_LIST_ATTRIBUTE_GOALS:
treeview_cell_player_games_goals_to_cell(buf, pl, TRUE);
treeview_cell_player_games_goals_to_cell(buf, pl, PLAYER_LIST_ATTRIBUTE_GOALS);
break;
case PLAYER_LIST_ATTRIBUTE_SHOTS:
treeview_cell_player_games_goals_to_cell(buf, pl, PLAYER_LIST_ATTRIBUTE_SHOTS);
break;
case PLAYER_LIST_ATTRIBUTE_STATUS:
treeview_cell_player_status_to_cell(renderer, buf, pl);
@ -234,44 +234,38 @@ treeview_cell_player_status_to_cell(GtkCellRenderer *renderer, gchar *buf, const
@param pl The pointer to the player.
@param goals Whether we render games or goals. */
void
treeview_cell_player_games_goals_to_cell(gchar *buf, const Player *pl, gboolean goals)
treeview_cell_player_games_goals_to_cell(gchar *buf, const Player *pl, gint type)
{
gint i;
gint i, idx = -1;
Fixture *fix = team_get_next_fixture(pl->team);
if(fix == NULL)
if(pl->games_goals->len == 0)
{
if(pl->games_goals->len == 0)
strcpy(buf, "0");
else
{
if(goals)
sprintf(buf, "%d(%d)",
g_array_index(pl->games_goals, PlayerGamesGoals, 0).goals,
player_all_games_goals(pl, goals));
else
sprintf(buf, "%d(%d)",
g_array_index(pl->games_goals, PlayerGamesGoals, 0).games,
player_all_games_goals(pl, goals));
}
strcpy(buf, "0");
return;
}
for(i=0;i<pl->games_goals->len;i++)
if(g_array_index(pl->games_goals, PlayerGamesGoals, 0).clid == fix->clid)
{
if(goals)
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, 0).goals,
player_all_games_goals(pl, goals));
else
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, 0).games,
player_all_games_goals(pl, goals));
return;
}
if(fix == NULL)
idx = 0;
else
{
for(i=0;i<pl->games_goals->len;i++)
if(g_array_index(pl->games_goals, PlayerGamesGoals, i).clid == fix->clid)
{
idx = i;
break;
}
}
sprintf(buf, "0");
if(type == PLAYER_LIST_ATTRIBUTE_GOALS)
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, idx).goals,
player_all_games_goals(pl, PLAYER_LIST_ATTRIBUTE_GOALS));
else if(type == PLAYER_LIST_ATTRIBUTE_GAMES)
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, idx).games,
player_all_games_goals(pl, PLAYER_LIST_ATTRIBUTE_GAMES));
else if(type == PLAYER_LIST_ATTRIBUTE_SHOTS)
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, idx).shots,
player_all_games_goals(pl, PLAYER_LIST_ATTRIBUTE_SHOTS));
}
/** Render a cell of player fitness.
@ -281,7 +275,7 @@ treeview_cell_player_games_goals_to_cell(gchar *buf, const Player *pl, gboolean
void
treeview_cell_player_fitness_to_cell(GtkCellRenderer *renderer, gchar *buf, gint fitness)
{
sprintf(buf, "%d%%", fitness);
sprintf(buf, "%d%%", (gint)rint((gfloat)fitness / 100));
if(fitness < const_int("int_treeview_cell_limit_player_fitness_below3"))
g_object_set(renderer, "foreground",
@ -345,14 +339,14 @@ void
treeview_cell_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl)
{
sprintf(buf, "%d", (gint)rint((gfloat)pl->cskill *
powf((gfloat)pl->fitness / 100,
powf((gfloat)pl->fitness / 10000,
const_float("float_player_fitness_impact_on_skill"))));
if(pl->cskill < pl->skill)
g_object_set(renderer, "background",
const_str("string_treeview_cell_color_player_bad_cskill_bg"),
"foreground",
const_str("string_treeview_cell_color_player_bad_cskill_bg"), NULL);
const_str("string_treeview_cell_color_player_bad_cskill_fg"), NULL);
else
g_object_set(renderer, "background",
const_str("string_treeview_cell_color_default_background"),

View File

@ -35,7 +35,7 @@ void
treeview_cell_player_status_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl);
void
treeview_cell_player_games_goals_to_cell(gchar *buf, const Player *pl, gboolean goals);
treeview_cell_player_games_goals_to_cell(gchar *buf, const Player *pl, gint type);
void
treeview_cell_player_fitness_to_cell(GtkCellRenderer *renderer, gchar *buf, gint fitness);

View File

@ -4,6 +4,7 @@
#include "interface.h"
#include "main.h"
#include "misc_interface.h"
#include "misc2_interface.h"
#include "option.h"
#include "support.h"
#include "user.h"
@ -56,22 +57,25 @@ window_set_version(GtkWidget *wind)
/** Create and show a window. Which one depends on the argument.
@param window_type An integer telling us which window to
create.
@param count_popups Whether this window adds to the popup
counter that determines when the main window gets (in)sensitive.
@return The pointer to the new window.
@see #Windows */
GtkWidget*
window_create(gint window_type)
{
gint old_popups_active = popups_active;
GtkWidget *wind = NULL;
popups_active++;
switch(window_type)
{
default:
g_warning("window_create: unknown window type %d\n", window_type);
break;
case WINDOW_MAIN:
if(window.main == NULL)
{
window.main = create_main_window();
popups_active--;
wind = window.main;
game_gui_print_message("Welcome to Bygfoot "VERS);
}
@ -82,14 +86,20 @@ window_create(gint window_type)
if(window.startup != NULL)
g_warning("window_create: called on already existing window\n");
else
{
popups_active++;
window.startup = create_window_startup();
}
wind = window.startup;
break;
case WINDOW_LIVE:
if(window.live != NULL)
g_warning("window_create: called on already existing window\n");
else
{
popups_active++;
window.live = create_window_live();
}
wind = window.live;
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(lookup_widget(wind, "spinbutton_speed")),
@ -99,15 +109,25 @@ window_create(gint window_type)
if(window.startup_users != NULL)
g_warning("window_create: called on already existing window\n");
else
{
popups_active++;
window.startup_users = create_window_startup_users();
}
wind = window.startup_users;
break;
case WINDOW_WARNING:
if(window.warning != NULL)
g_warning("window_create: called on already existing window\n");
else
window.warning = create_window_warning();
wind = window.warning;
break;
}
window_set_version(wind);
gtk_widget_show(wind);
if(popups_active != 0 && window.main != NULL)
if(popups_active < old_popups_active && window.main != NULL)
gtk_widget_set_sensitive(window.main, FALSE);
return wind;
@ -115,14 +135,16 @@ window_create(gint window_type)
/** Destroy a window widget and set the popups and
main window sensitivity correctly.
@param window The window we destroy. */
@param window The window we destroy.
@param count_popups Whether this window adds to the popup
counter that determines when the main window gets (in)sensitive. */
void
window_destroy(GtkWidget **wind)
window_destroy(GtkWidget **wind, gboolean count_popups)
{
if(*wind == NULL)
return;
if(*wind != window.main)
if(*wind != window.main && count_popups)
{
popups_active--;

View File

@ -11,6 +11,7 @@ enum Windows
WINDOW_STARTUP,
WINDOW_LIVE,
WINDOW_STARTUP_USERS,
WINDOW_WARNING,
WINDOW_END
};
@ -24,6 +25,6 @@ GtkWidget*
window_create(gint window_type);
void
window_destroy(GtkWidget **window);
window_destroy(GtkWidget **wind, gboolean count_popups);
#endif