mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-06-05 21:49:20 +02:00
Live game can be tested a bit now.
This commit is contained in:
2
Doxyfile
2
Doxyfile
@@ -417,7 +417,7 @@ WARN_LOGFILE =
|
|||||||
# directories like "/usr/src/myproject". Separate the files or directories
|
# directories like "/usr/src/myproject". Separate the files or directories
|
||||||
# with spaces.
|
# with spaces.
|
||||||
|
|
||||||
INPUT = ./src/
|
INPUT = /home/gy/progs/bygfoot/1.9/src/
|
||||||
|
|
||||||
# If the value of the INPUT tag contains directories, you can use the
|
# If the value of the INPUT tag contains directories, you can use the
|
||||||
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||||
|
2036
bygfoot.glade
2036
bygfoot.glade
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,7 @@
|
|||||||
<property name="border_width">2</property>
|
<property name="border_width">2</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="has_focus">True</property>
|
||||||
<property name="headers_visible">True</property>
|
<property name="headers_visible">True</property>
|
||||||
<property name="rules_hint">True</property>
|
<property name="rules_hint">True</property>
|
||||||
<property name="reorderable">True</property>
|
<property name="reorderable">True</property>
|
||||||
@@ -165,88 +166,6 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkEventBox" id="eventbox2">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkHBox" id="hbox50">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">0</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkRadioButton" id="radiobutton_cl">
|
|
||||||
<property name="border_width">3</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="tooltip" translatable="yes">Play only in Champions' League / Copa Libertadores</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label" translatable="yes">CL</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="active">False</property>
|
|
||||||
<property name="inconsistent">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<property name="group">team_selection_radio1</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="radiobutton_cwc">
|
|
||||||
<property name="border_width">3</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="tooltip" translatable="yes">Play only in Cup Winners' Cup / Copa Conmebol</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label" translatable="yes">CWC / Conm.</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="active">False</property>
|
|
||||||
<property name="inconsistent">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<property name="group">team_selection_radio1</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="radiobutton_uefa">
|
|
||||||
<property name="border_width">3</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="tooltip" translatable="yes">Play only in UEFA Cup / Copa Sul-Americana</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label" translatable="yes">UEFA / Sul-Americana</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="active">False</property>
|
|
||||||
<property name="inconsistent">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<property name="group">team_selection_radio1</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkHSeparator" id="hseparator11">
|
<widget class="GtkHSeparator" id="hseparator11">
|
||||||
<property name="width_request">1</property>
|
<property name="width_request">1</property>
|
||||||
@@ -1455,7 +1374,7 @@
|
|||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkWindow" id="live_window">
|
<widget class="GtkWindow" id="window_live">
|
||||||
<property name="border_width">6</property>
|
<property name="border_width">6</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="title" translatable="yes">Live game</property>
|
<property name="title" translatable="yes">Live game</property>
|
||||||
@@ -1469,57 +1388,11 @@
|
|||||||
<signal name="delete_event" handler="on_live_window_delete_event" last_modification_time="Fri, 18 Jun 2004 16:46:46 GMT"/>
|
<signal name="delete_event" handler="on_live_window_delete_event" last_modification_time="Fri, 18 Jun 2004 16:46:46 GMT"/>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkVBox" id="vbox23">
|
<widget class="GtkVBox" id="vbox36">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="spacing">0</property>
|
<property name="spacing">0</property>
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkHScale" id="hscale_tendency">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="draw_value">False</property>
|
|
||||||
<property name="value_pos">GTK_POS_TOP</property>
|
|
||||||
<property name="digits">1</property>
|
|
||||||
<property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
|
|
||||||
<property name="inverted">False</property>
|
|
||||||
<property name="adjustment">0.5 0 1 0 0 0</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkScrolledWindow" id="scrolledwindow_live">
|
|
||||||
<property name="border_width">2</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
|
||||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
|
||||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
|
||||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkTreeView" id="treeview_live">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="headers_visible">True</property>
|
|
||||||
<property name="rules_hint">False</property>
|
|
||||||
<property name="reorderable">False</property>
|
|
||||||
<property name="enable_search">True</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkProgressBar" id="progressbar_live">
|
<widget class="GtkProgressBar" id="progressbar_live">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@@ -1541,32 +1414,133 @@
|
|||||||
<property name="metric">GTK_PIXELS</property>
|
<property name="metric">GTK_PIXELS</property>
|
||||||
<property name="lower">0</property>
|
<property name="lower">0</property>
|
||||||
<property name="upper">120</property>
|
<property name="upper">120</property>
|
||||||
<property name="position">55.0685</property>
|
<property name="position">77.2603</property>
|
||||||
<property name="max_size">0</property>
|
<property name="max_size">120</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">0</property>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">True</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkVBox" id="vbox26">
|
<widget class="GtkHBox" id="hbox50">
|
||||||
<property name="border_width">4</property>
|
<property name="visible">True</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="spacing">0</property>
|
<property name="spacing">3</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkCheckButton" id="check_live_window_show_live">
|
<widget class="GtkVBox" id="vbox38">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="spacing">3</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkScrolledWindow" id="scrolledwindow8">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
|
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
|
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
|
||||||
|
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkTreeView" id="treeview_result">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="headers_visible">False</property>
|
||||||
|
<property name="rules_hint">False</property>
|
||||||
|
<property name="reorderable">False</property>
|
||||||
|
<property name="enable_search">True</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkScrolledWindow" id="scrolledwindow9">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
|
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
|
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
|
||||||
|
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkTreeView" id="treeview_commentary">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="headers_visible">True</property>
|
||||||
|
<property name="rules_hint">False</property>
|
||||||
|
<property name="reorderable">False</property>
|
||||||
|
<property name="enable_search">True</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</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>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkHBox" id="hbox48">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="spacing">4</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkButton" id="button_pause">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">Show live games</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
<property name="active">True</property>
|
<signal name="clicked" handler="on_button_pause_clicked" last_modification_time="Fri, 07 Jan 2005 13:35:11 GMT"/>
|
||||||
<property name="inconsistent">False</property>
|
<accelerator key="space" modifiers="0" signal="clicked"/>
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkAlignment" id="alignment16">
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkHBox" id="hbox51">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="spacing">2</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImage" id="image56">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="stock">gtk-no</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>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">0</property>
|
||||||
@@ -1576,15 +1550,98 @@
|
|||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkCheckButton" id="check_live_window_tendency">
|
<widget class="GtkLabel" id="label72">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="label" translatable="yes">Pause</property>
|
||||||
<property name="label" translatable="yes">Show tendency bar</property>
|
|
||||||
<property name="use_underline">True</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">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkButton" id="button_resume">
|
||||||
|
<property name="can_focus">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
<property name="active">False</property>
|
<signal name="clicked" handler="on_button_resume_clicked" last_modification_time="Sat, 08 Jan 2005 11:22:05 GMT"/>
|
||||||
<property name="inconsistent">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
<child>
|
||||||
|
<widget class="GtkAlignment" id="alignment17">
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkHBox" id="hbox52">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="spacing">2</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImage" id="image57">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="stock">gtk-yes</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="label73">
|
||||||
|
<property name="visible">True</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>
|
||||||
|
<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>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">0</property>
|
||||||
@@ -1595,17 +1652,13 @@
|
|||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkButton" id="button_live_close">
|
<widget class="GtkButton" id="button_live_close">
|
||||||
<property name="border_width">2</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="tooltip" translatable="yes">Esc</property>
|
<property name="sensitive">False</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label">gtk-close</property>
|
<property name="label">gtk-close</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
<signal name="clicked" handler="on_button_live_close_clicked" last_modification_time="Mon, 09 Feb 2004 14:22:48 GMT"/>
|
<signal name="clicked" handler="on_button_live_close_clicked" last_modification_time="Sat, 08 Jan 2005 11:24:05 GMT"/>
|
||||||
<accelerator key="Escape" modifiers="0" signal="clicked"/>
|
|
||||||
<accelerator key="Return" modifiers="0" signal="clicked"/>
|
|
||||||
<accelerator key="space" modifiers="0" signal="clicked"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">0</property>
|
||||||
@@ -1615,9 +1668,9 @@
|
|||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">5</property>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">True</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
@@ -17,7 +17,7 @@ bygfoot_SOURCES = \
|
|||||||
editor_interface.c editor_interface.h \
|
editor_interface.c editor_interface.h \
|
||||||
file.c file.h free.h misc.h support.h \
|
file.c file.h free.h misc.h support.h \
|
||||||
finance.c finance.h \
|
finance.c finance.h \
|
||||||
fixture.c fixture.h \
|
fixture.c cup.h fixture.h league_struct.h main.h maths.h misc.h team.h variables.h \
|
||||||
free.c cup.h fixture.h free.h league.h player.h variables.h \
|
free.c cup.h fixture.h free.h league.h player.h variables.h \
|
||||||
game.c game.h \
|
game.c game.h \
|
||||||
game_gui.c game_gui.h \
|
game_gui.c game_gui.h \
|
||||||
@@ -27,12 +27,13 @@ bygfoot_SOURCES = \
|
|||||||
history.c history.h \
|
history.c history.h \
|
||||||
interface.c callbacks.h interface.h support.h \
|
interface.c callbacks.h interface.h support.h \
|
||||||
league.c league.h team.h variables.h \
|
league.c league.h team.h variables.h \
|
||||||
|
live_game.c game.h live_game.h variables.h \
|
||||||
load_save.c load_save.h \
|
load_save.c load_save.h \
|
||||||
main.c file.h free.h main.h variables.h window.h \
|
main.c file.h free.h main.h variables.h window.h \
|
||||||
maths.c maths.h misc.h variables.h \
|
maths.c maths.h misc.h variables.h \
|
||||||
misc.c free.h misc.h \
|
misc.c free.h misc.h \
|
||||||
misc_callbacks.c free.h misc_callback_func.h misc_callbacks.h \
|
misc_callbacks.c free.h misc_callback_func.h misc_callbacks.h \
|
||||||
misc_callback_func.c misc_callback_func.h start_end.h support.h treeview.h variables.h xml_country.h \
|
misc_callback_func.c misc_callback_func.h start_end.h support.h team.h treeview.h user.h variables.h xml_country.h \
|
||||||
misc_interface.c misc_interface.h misc_callbacks.h support.h \
|
misc_interface.c misc_interface.h misc_callbacks.h support.h \
|
||||||
misc2_callbacks.c misc2_callbacks.h \
|
misc2_callbacks.c misc2_callbacks.h \
|
||||||
misc2_interface.c misc2_interface.h misc2_callbacks.h support.h \
|
misc2_interface.c misc2_interface.h misc2_callbacks.h support.h \
|
||||||
@@ -46,6 +47,7 @@ bygfoot_SOURCES = \
|
|||||||
transfer.c transfer.h \
|
transfer.c transfer.h \
|
||||||
treeview.c gui.h league.h support.h team.h treeview.h variables.h \
|
treeview.c gui.h league.h support.h team.h treeview.h variables.h \
|
||||||
treeview_cell.c treeview_cell.h \
|
treeview_cell.c treeview_cell.h \
|
||||||
|
user.c team.h user.h \
|
||||||
window.c misc_interface.h file.h free.h support.h window.h \
|
window.c misc_interface.h file.h free.h support.h window.h \
|
||||||
xml_cup.c cup.h file.h misc.h variables.h xml_cup.h \
|
xml_cup.c cup.h file.h misc.h variables.h xml_cup.h \
|
||||||
xml_country.c file.h free.h league.h misc.h variables.h xml_cup.h xml_country.h xml_league.h \
|
xml_country.c file.h free.h league.h misc.h variables.h xml_cup.h xml_country.h xml_league.h \
|
||||||
|
@@ -31,10 +31,11 @@ enum ExitCodes
|
|||||||
{
|
{
|
||||||
EXIT_OK = 0, /**< Normal exit. */
|
EXIT_OK = 0, /**< Normal exit. */
|
||||||
EXIT_DIR_OPEN_FAILED, /**< Exit when the $HOME/.bygfoot/definitions directory can't be opened. */
|
EXIT_DIR_OPEN_FAILED, /**< Exit when the $HOME/.bygfoot/definitions directory can't be opened. */
|
||||||
EXIT_FILE_OPEN_FAILED,
|
EXIT_FILE_OPEN_FAILED, /** A file could not be opened. */
|
||||||
EXIT_PRINT_ERROR, /**< Exit when the print_error function is called on a set error.*/
|
EXIT_PRINT_ERROR, /**< Exit when the print_error function is called on a set error.*/
|
||||||
EXIT_NO_LEAGUES,
|
EXIT_NO_LEAGUES, /**< The game must contain at least one league. */
|
||||||
EXIT_CHOOSE_TEAM_ERROR,
|
EXIT_CHOOSE_TEAM_ERROR, /**< There was a problem loading the choose_teams. @see cup_load_choose_teams() */
|
||||||
|
EXIT_FIXTURE_WRITE_ERROR, /** There was an error writing the fixtures. */
|
||||||
EXIT_END
|
EXIT_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
591
src/callbacks.c
591
src/callbacks.c
@@ -1,10 +1,22 @@
|
|||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
|
/*d*/
|
||||||
|
#include "game.h"
|
||||||
|
#include "live_game.h"
|
||||||
|
#include "maths.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include "team.h"
|
||||||
|
|
||||||
|
#include "gui.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "treeview.h"
|
||||||
|
#include "variables.h"
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
on_button_quit_clicked (GtkWidget *widget,
|
on_button_quit_clicked (GtkWidget *widget,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
main_exit_program(EXIT_OK, NULL);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -42,14 +54,6 @@ on_menu_save_as_activate (GtkMenuItem *menuitem,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_menu_options_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_start_editor_activate (GtkMenuItem *menuitem,
|
on_start_editor_activate (GtkMenuItem *menuitem,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -106,22 +110,6 @@ on_button_save_clicked (GtkButton *button,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_button_options_clicked (GtkButton *button,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_optionmenu_quick_opt_changed (GtkOptionMenu *optionmenu,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_button_back_to_main_clicked (GtkButton *button,
|
on_button_back_to_main_clicked (GtkButton *button,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -154,14 +142,6 @@ on_button_preview_clicked (GtkButton *button,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_optionmenu_figures_changed (GtkOptionMenu *optionmenu,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_button_new_week_clicked (GtkButton *button,
|
on_button_new_week_clicked (GtkButton *button,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -177,55 +157,6 @@ on_button_help_clicked (GtkButton *button,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_show_info_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_show_statistics_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_put_on_transfer_list_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_remove_from_transfer_list_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_fire_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_shoots_penalties_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
on_player_list_button_press_event (GtkWidget *widget,
|
on_player_list_button_press_event (GtkWidget *widget,
|
||||||
GdkEventButton *event,
|
GdkEventButton *event,
|
||||||
@@ -246,22 +177,6 @@ on_player_list2_button_press_event (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_style_optionmenu_changed (GtkOptionMenu *optionmenu,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_checkbutton_boost_toggled (GtkToggleButton *togglebutton,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_structure_entry_activate (GtkEntry *entry,
|
on_structure_entry_activate (GtkEntry *entry,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -294,31 +209,6 @@ on_button_undo_clicked (GtkButton *button,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_scout_optionmenu_changed (GtkOptionMenu *optionmenu,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_optionmenu_physio_changed (GtkOptionMenu *optionmenu,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
on_player_info_button_press_event (GtkWidget *widget,
|
|
||||||
GdkEventButton *event,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_button_browse_clicked (GtkButton *button,
|
on_button_browse_clicked (GtkButton *button,
|
||||||
@@ -343,15 +233,6 @@ on_button_browse_back_clicked (GtkButton *button,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_button_league_results_clicked (GtkButton *button,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_optionmenu_finstad_changed (GtkOptionMenu *optionmenu,
|
on_optionmenu_finstad_changed (GtkOptionMenu *optionmenu,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -360,22 +241,6 @@ on_optionmenu_finstad_changed (GtkOptionMenu *optionmenu,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_spin_fee_activate (GtkEntry *entry,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_button_transfer_ok_clicked (GtkButton *button,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_button_fixtures_clicked (GtkButton *button,
|
on_button_fixtures_clicked (GtkButton *button,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -391,9 +256,437 @@ on_button_tables_clicked (GtkButton *button,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_optionmenu_fixtures_changed (GtkOptionMenu *optionmenu,
|
on_menu_preferences_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_notify_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_job_offers_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_live_game_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_overwrite_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_fixtures_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league1_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league2_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league3_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league4_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league5_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league6_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup_1_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup2_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup3_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup4_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup5_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup6_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_tables_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_players1_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_season_history_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_team_history_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_player_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_show_info_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_show_history_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_remove_from_transfer_list_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_fire_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_shoots_penalties_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_all_out_defend_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_defend_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_balanced_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_attack_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_all_out_attack_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_scout_best_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_scout_good_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_scout_average_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_scout_bad_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_physio_best_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_physio_good_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_physio_average_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_physio_bad_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_boost_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_my_league_results_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_browse_teams_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkWidget *treeview_right =
|
||||||
|
lookup_widget(main_window, "treeview_right");
|
||||||
|
|
||||||
|
treeview_show_team_list(GTK_TREE_VIEW(treeview_right), TRUE);
|
||||||
|
|
||||||
|
status = STATUS_BROWSE_TEAMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
on_treeview_right_button_press_event (GtkWidget *widget,
|
||||||
|
GdkEventButton *event,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
/*d*/
|
||||||
|
gint i, j, k;
|
||||||
|
Fixture *fix;/* = &g_array_index(lig(0).fixtures, Fixture, */
|
||||||
|
/* math_rndi(0, lig(0).fixtures->len - 1)); */
|
||||||
|
|
||||||
|
for(k=0;k<lig(0).fixtures->len;k++)
|
||||||
|
if(g_array_index(lig(0).fixtures, Fixture, k).week_number == 1 &&
|
||||||
|
g_array_index(lig(0).fixtures, Fixture, k).week_round_number == 1)
|
||||||
|
{
|
||||||
|
fix = &g_array_index(lig(0).fixtures, Fixture, k);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
for(j=0;j<2;j++)
|
||||||
|
{
|
||||||
|
printf("%s %d %d %.1f\n", fix->teams[j]->name->str, fix->teams[j]->structure,
|
||||||
|
fix->teams[j]->style, team_average_cskill(fix->teams[j]));
|
||||||
|
}
|
||||||
|
|
||||||
|
live_game_calculate_fixture(fix);
|
||||||
|
printf("%d : %d\n", math_sum_int_array(fix->result[0], 3),
|
||||||
|
math_sum_int_array(fix->result[1], 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_finances_stadium_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_increase_capacity_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_increase_safety_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_get_loan_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_pay_loan_activate (GtkMenuItem *menuitem,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
286
src/callbacks.h
286
src/callbacks.h
@@ -1,9 +1,11 @@
|
|||||||
|
#ifndef CALLBACKS_H
|
||||||
|
#define CALLBACKS_H
|
||||||
|
|
||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
|
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
on_button_quit_clicked (GtkWidget *widget,
|
on_button_quit_clicked (GtkWidget *widget,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
@@ -25,10 +27,6 @@ void
|
|||||||
on_menu_save_as_activate (GtkMenuItem *menuitem,
|
on_menu_save_as_activate (GtkMenuItem *menuitem,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void
|
|
||||||
on_menu_options_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_start_editor_activate (GtkMenuItem *menuitem,
|
on_start_editor_activate (GtkMenuItem *menuitem,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -57,14 +55,6 @@ void
|
|||||||
on_button_save_clicked (GtkButton *button,
|
on_button_save_clicked (GtkButton *button,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void
|
|
||||||
on_button_options_clicked (GtkButton *button,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
|
||||||
on_optionmenu_quick_opt_changed (GtkOptionMenu *optionmenu,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_button_back_to_main_clicked (GtkButton *button,
|
on_button_back_to_main_clicked (GtkButton *button,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -81,10 +71,6 @@ void
|
|||||||
on_button_preview_clicked (GtkButton *button,
|
on_button_preview_clicked (GtkButton *button,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void
|
|
||||||
on_optionmenu_figures_changed (GtkOptionMenu *optionmenu,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_button_new_week_clicked (GtkButton *button,
|
on_button_new_week_clicked (GtkButton *button,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -93,48 +79,11 @@ void
|
|||||||
on_button_help_clicked (GtkButton *button,
|
on_button_help_clicked (GtkButton *button,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void
|
|
||||||
on_show_info_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
|
||||||
on_show_statistics_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
|
||||||
on_put_on_transfer_list_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
|
||||||
on_remove_from_transfer_list_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
|
||||||
on_fire_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
|
||||||
on_shoots_penalties_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
on_player_list_button_press_event (GtkWidget *widget,
|
on_player_list_button_press_event (GtkWidget *widget,
|
||||||
GdkEventButton *event,
|
GdkEventButton *event,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
gboolean
|
|
||||||
on_player_list2_button_press_event (GtkWidget *widget,
|
|
||||||
GdkEventButton *event,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
|
||||||
on_style_optionmenu_changed (GtkOptionMenu *optionmenu,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
|
||||||
on_checkbutton_boost_toggled (GtkToggleButton *togglebutton,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_structure_entry_activate (GtkEntry *entry,
|
on_structure_entry_activate (GtkEntry *entry,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -151,16 +100,8 @@ void
|
|||||||
on_button_undo_clicked (GtkButton *button,
|
on_button_undo_clicked (GtkButton *button,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void
|
|
||||||
on_scout_optionmenu_changed (GtkOptionMenu *optionmenu,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
|
||||||
on_optionmenu_physio_changed (GtkOptionMenu *optionmenu,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
on_player_info_button_press_event (GtkWidget *widget,
|
on_player_list2_button_press_event (GtkWidget *widget,
|
||||||
GdkEventButton *event,
|
GdkEventButton *event,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
@@ -176,22 +117,9 @@ void
|
|||||||
on_button_browse_back_clicked (GtkButton *button,
|
on_button_browse_back_clicked (GtkButton *button,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void
|
|
||||||
on_button_league_results_clicked (GtkButton *button,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_optionmenu_finstad_changed (GtkOptionMenu *optionmenu,
|
on_optionmenu_finstad_changed (GtkOptionMenu *optionmenu,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void
|
|
||||||
on_spin_fee_activate (GtkEntry *entry,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
|
||||||
on_button_transfer_ok_clicked (GtkButton *button,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
on_button_fixtures_clicked (GtkButton *button,
|
on_button_fixtures_clicked (GtkButton *button,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -201,5 +129,209 @@ on_button_tables_clicked (GtkButton *button,
|
|||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void
|
void
|
||||||
on_optionmenu_fixtures_changed (GtkOptionMenu *optionmenu,
|
on_menu_preferences_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_notify_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_job_offers_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_live_game_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_overwrite_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_fixtures_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league1_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league2_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league3_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league4_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league5_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_league6_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup_1_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup2_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup3_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup4_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup5_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_cup6_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_tables_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_players1_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_season_history_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_team_history_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_player_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_show_info_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_show_history_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_remove_from_transfer_list_activate
|
||||||
|
(GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_fire_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_shoots_penalties_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_all_out_defend_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_defend_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_balanced_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_attack_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_all_out_attack_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_scout_best_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_scout_good_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_scout_average_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_scout_bad_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_physio_best_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_physio_good_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_physio_average_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_physio_bad_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_boost_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_my_league_results_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_browse_teams_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
on_treeview_right_button_press_event (GtkWidget *widget,
|
||||||
|
GdkEventButton *event,
|
||||||
|
gpointer user_data);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_finances_stadium_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_increase_capacity_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_increase_safety_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_get_loan_activate (GtkMenuItem *menuitem,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_menu_pay_loan_activate (GtkMenuItem *menuitem,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
113
src/cup.c
113
src/cup.c
@@ -1,4 +1,5 @@
|
|||||||
#include "cup.h"
|
#include "cup.h"
|
||||||
|
#include "fixture_struct.h"
|
||||||
#include "free.h"
|
#include "free.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
@@ -33,6 +34,13 @@ cup_new(void)
|
|||||||
new.choose_team_user = cup_choose_team_new();
|
new.choose_team_user = cup_choose_team_new();
|
||||||
new.rounds = g_array_new(FALSE, FALSE, sizeof(CupRound));
|
new.rounds = g_array_new(FALSE, FALSE, sizeof(CupRound));
|
||||||
new.teams = g_array_new(FALSE, FALSE, sizeof(Team));
|
new.teams = g_array_new(FALSE, FALSE, sizeof(Team));
|
||||||
|
new.user_teams = g_ptr_array_new();
|
||||||
|
new.tables = g_array_new(FALSE, FALSE, sizeof(Table));
|
||||||
|
new.fixtures = g_array_new(FALSE, FALSE, sizeof(Fixture));
|
||||||
|
new.bye = g_ptr_array_new();
|
||||||
|
|
||||||
|
new.next_fixture_update_week = -1;
|
||||||
|
new.next_fixture_update_week_round = -1;
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
@@ -147,7 +155,7 @@ cup_load_choose_teams(Cup *cup)
|
|||||||
|
|
||||||
for(j = 0; j < end_idx; j++)
|
for(j = 0; j < end_idx; j++)
|
||||||
{
|
{
|
||||||
if(!is_in_international_cups(&g_array_index(teams, Team, permutation[j])))
|
if(!query_is_in_international_cups(&g_array_index(teams, Team, permutation[j])))
|
||||||
{
|
{
|
||||||
team_append_to_array_with_ids(&g_array_index(teams, Team, permutation[j]), cup->teams,
|
team_append_to_array_with_ids(&g_array_index(teams, Team, permutation[j]), cup->teams,
|
||||||
cup->id, cup->teams->len);
|
cup->id, cup->teams->len);
|
||||||
@@ -186,7 +194,6 @@ cup_load_choose_team_user(Cup *cup)
|
|||||||
|
|
||||||
sscanf(choose_team->sid->str, "%[^0-9]%d", type, &number);
|
sscanf(choose_team->sid->str, "%[^0-9]%d", type, &number);
|
||||||
|
|
||||||
|
|
||||||
if(strcmp(type, "league") == 0)
|
if(strcmp(type, "league") == 0)
|
||||||
{
|
{
|
||||||
if(ligs->len < number ||
|
if(ligs->len < number ||
|
||||||
@@ -195,10 +202,9 @@ cup_load_choose_team_user(Cup *cup)
|
|||||||
|
|
||||||
for(i = choose_team->start_idx - 1; i <= choose_team->end_idx - 1; i++)
|
for(i = choose_team->start_idx - 1; i <= choose_team->end_idx - 1; i++)
|
||||||
{
|
{
|
||||||
if(!is_in_international_cups(&g_array_index(lig(number - 1).teams, Team, i)))
|
if(!query_is_in_international_cups(&g_array_index(lig(number - 1).teams, Team, i)))
|
||||||
{
|
{
|
||||||
team_append_to_array(&g_array_index(lig(number - 1).teams, Team, i),
|
g_ptr_array_add(cup->user_teams, (gpointer)&g_array_index(lig(number - 1).teams, Team, i));
|
||||||
cup->teams);
|
|
||||||
number_of_teams++;
|
number_of_teams++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,13 +228,14 @@ cup_load_choose_team_user(Cup *cup)
|
|||||||
gint permutation[lig(0).teams->len];
|
gint permutation[lig(0).teams->len];
|
||||||
math_generate_permutation(permutation, 0, lig(0).teams->len - 1);
|
math_generate_permutation(permutation, 0, lig(0).teams->len - 1);
|
||||||
|
|
||||||
for(i = choose_team->start_idx - 1; i < choose_team->end_idx - 1; i++)
|
for(i = choose_team->start_idx - 1; i <= choose_team->end_idx - 1; i++)
|
||||||
{
|
{
|
||||||
if(!is_in_international_cups(&g_array_index(lig(number - 1).teams, Team, permutation[i])))
|
if(!query_is_in_international_cups(&g_array_index(lig(number - 1).teams,
|
||||||
|
Team, permutation[i - choose_team->start_idx + 1])))
|
||||||
{
|
{
|
||||||
team_append_to_array(&g_array_index(lig(number - 1).teams,
|
g_ptr_array_add(cup->user_teams,
|
||||||
Team, permutation[i - choose_team->start_idx + 1]),
|
(gpointer)&g_array_index(lig(number - 1).teams,
|
||||||
cup->teams);
|
Team, permutation[i - choose_team->start_idx + 1]));
|
||||||
number_of_teams++;
|
number_of_teams++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,5 +267,89 @@ cup_choose_team_abort(const Cup *cup, const CupChooseTeam *choose_team, gboolean
|
|||||||
else
|
else
|
||||||
g_warning("cup_load_choose_teams: there was an error loading choose_team %s from cup %s. maybe there aren't enough teams in the specified league or cup.\n", choose_team->sid->str, cup->sid->str);
|
g_warning("cup_load_choose_teams: there was an error loading choose_team %s from cup %s. maybe there aren't enough teams in the specified league or cup.\n", choose_team->sid->str, cup->sid->str);
|
||||||
|
|
||||||
main_exit_program(EXIT_CHOOSE_TEAM_ERROR);
|
main_exit_program(EXIT_CHOOSE_TEAM_ERROR, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Calculate the week number the first matchday of the given
|
||||||
|
cup round takes place.
|
||||||
|
@param cup The cup we examine.
|
||||||
|
@param cup_round The index of the cup round in the cup.rounds array.
|
||||||
|
@return A week number. */
|
||||||
|
gint
|
||||||
|
cup_get_first_week_of_cup_round(const Cup *cup, gint cup_round)
|
||||||
|
{
|
||||||
|
gint week_number;
|
||||||
|
|
||||||
|
if(cup_round == cup->rounds->len - 1)
|
||||||
|
week_number = cup->last_week -
|
||||||
|
(cup_get_matchdays_in_cup_round(cup, cup_round) - 1) * cup->week_gap;
|
||||||
|
else
|
||||||
|
week_number = cup_get_first_week_of_cup_round(cup, cup_round + 1) -
|
||||||
|
cup_get_matchdays_in_cup_round(cup, cup_round) * cup->week_gap;
|
||||||
|
|
||||||
|
return week_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the number of matchdays for a given cup round.
|
||||||
|
@param cup The cup we examine.
|
||||||
|
@param cup_round The index of the cup round.
|
||||||
|
@return The number of matchdays, mostly 1 or 2. */
|
||||||
|
gint
|
||||||
|
cup_get_matchdays_in_cup_round(const Cup *cup, gint cup_round)
|
||||||
|
{
|
||||||
|
gint number_of_teams = -1;
|
||||||
|
gint number_of_matchdays = -1;
|
||||||
|
|
||||||
|
if(g_array_index(cup->rounds, CupRound, cup_round).
|
||||||
|
round_robin_number_of_groups > 0)
|
||||||
|
{
|
||||||
|
number_of_teams = cup_round_get_number_of_teams(cup, cup_round);
|
||||||
|
number_of_matchdays =
|
||||||
|
2 * (number_of_teams / g_array_index(cup->rounds, CupRound, cup_round).round_robin_number_of_groups - 1);
|
||||||
|
}
|
||||||
|
else if(g_array_index(cup->rounds, CupRound, cup_round).home_away)
|
||||||
|
number_of_matchdays = 2;
|
||||||
|
else
|
||||||
|
number_of_matchdays = 1;
|
||||||
|
|
||||||
|
return number_of_matchdays;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the number of teams playing in the given cup round.
|
||||||
|
@param cup The cup we examine.
|
||||||
|
@param cup_round The index of the cup round.
|
||||||
|
@return The number teams. */
|
||||||
|
gint
|
||||||
|
cup_round_get_number_of_teams(const Cup *cup, gint cup_round)
|
||||||
|
{
|
||||||
|
gint number_of_teams = -1;
|
||||||
|
|
||||||
|
if(cup_round == 0)
|
||||||
|
number_of_teams = cup->teams->len;
|
||||||
|
else if(g_array_index(cup->rounds, CupRound, cup_round - 1).round_robin_number_of_groups > 0)
|
||||||
|
{
|
||||||
|
number_of_teams =
|
||||||
|
g_array_index(cup->rounds, CupRound, cup_round - 1).round_robin_number_of_groups *
|
||||||
|
g_array_index(cup->rounds, CupRound, cup_round - 1).round_robin_number_of_advance +
|
||||||
|
g_array_index(cup->rounds, CupRound, cup_round - 1).round_robin_number_of_best_advance;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
number_of_teams = cup_round_get_number_of_teams(cup, cup_round - 1) / 2;
|
||||||
|
|
||||||
|
return number_of_teams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the teams participating in the cup as a pointer array.
|
||||||
|
@param cup The cup pointer.
|
||||||
|
@return An array of team pointers. */
|
||||||
|
GPtrArray*
|
||||||
|
cup_get_team_pointers(const Cup *cup)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
GPtrArray *teams = team_get_pointers_from_array(cup->teams);
|
||||||
|
|
||||||
|
for(i=0;i<cup->user_teams->len;i++)
|
||||||
|
g_ptr_array_add(teams, g_ptr_array_index(cup->user_teams, i));
|
||||||
|
|
||||||
|
return teams;
|
||||||
}
|
}
|
||||||
|
12
src/cup.h
12
src/cup.h
@@ -25,4 +25,16 @@ cup_load_choose_team_user(Cup *cup);
|
|||||||
void
|
void
|
||||||
cup_choose_team_abort(const Cup *cup, const CupChooseTeam *choose_team, gboolean user);
|
cup_choose_team_abort(const Cup *cup, const CupChooseTeam *choose_team, gboolean user);
|
||||||
|
|
||||||
|
GPtrArray*
|
||||||
|
cup_get_team_pointers(const Cup *cup);
|
||||||
|
|
||||||
|
gint
|
||||||
|
cup_get_first_week_of_cup_round(const Cup *cup, gint cup_round);
|
||||||
|
|
||||||
|
gint
|
||||||
|
cup_get_matchdays_in_cup_round(const Cup *cup, gint cup_round);
|
||||||
|
|
||||||
|
gint
|
||||||
|
cup_round_get_number_of_teams(const Cup *cup, gint cup_round);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#ifndef CUP_STRUCT_H
|
#ifndef CUP_STRUCT_H
|
||||||
#define CUP_STRUCT_H
|
#define CUP_STRUCT_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
#include "table_struct.h"
|
#include "table_struct.h"
|
||||||
|
|
||||||
/** Types for cups. */
|
/** Types for cups. */
|
||||||
@@ -101,9 +102,21 @@ typedef struct
|
|||||||
/** The rounds of the cup.
|
/** The rounds of the cup.
|
||||||
@see #CupRound*/
|
@see #CupRound*/
|
||||||
GArray *rounds;
|
GArray *rounds;
|
||||||
|
/** Pointer array containing teams that got a bye for a round of the cup. */
|
||||||
|
GPtrArray *bye;
|
||||||
/** The teams belonging to the cup.
|
/** The teams belonging to the cup.
|
||||||
Relevant only if it's an international one. */
|
Relevant only if it's an international one. */
|
||||||
GArray *teams;
|
GArray *teams;
|
||||||
|
/** Pointers to the teams from the leagues that participate. */
|
||||||
|
GPtrArray *user_teams;
|
||||||
|
/** An array of tables for round robin groups. */
|
||||||
|
GArray *tables;
|
||||||
|
/** The fixtures of a season for the cup. */
|
||||||
|
GArray *fixtures;
|
||||||
|
/** The week and week_round at the beginning of which the fixtures
|
||||||
|
have to be updated. */
|
||||||
|
gint next_fixture_update_week;
|
||||||
|
gint next_fixture_update_week_round;
|
||||||
} Cup;
|
} Cup;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
88
src/enums.h
88
src/enums.h
@@ -0,0 +1,88 @@
|
|||||||
|
#ifndef ENUMS_H
|
||||||
|
#define ENUMS_H
|
||||||
|
|
||||||
|
/** Indices for the #finances variable. */
|
||||||
|
enum FinanceValue
|
||||||
|
{
|
||||||
|
FIN_PRIZE = 0, /**< Prize money at the end of the season. */
|
||||||
|
FIN_DEBTS, /**< User's debts. */
|
||||||
|
FIN_MONEY, /**< User's money. */
|
||||||
|
FIN_TICKETS, /**< Ticket income (weekly). */
|
||||||
|
FIN_JOURNEY, /**< Journey costs (weekly). */
|
||||||
|
FIN_WAGES, /**< Wages (weekly). */
|
||||||
|
FIN_SCOUT, /**< Scout wage (weekly). */
|
||||||
|
FIN_PHYSIO, /**< Physio wage (weekly). */
|
||||||
|
FIN_TRANSFERS_IN, /**< Transfer fees income (weekly). */
|
||||||
|
FIN_TRANSFERS_OUT, /**< Transfer fees spent (weekly). */
|
||||||
|
FIN_STADIUM, /**< Stadium improvement (weekly). */
|
||||||
|
FIN_STAD_BILLS, /**< Bills for riots or fire or so (weekly). */
|
||||||
|
FIN_END
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Indices for the #counters variable. */
|
||||||
|
enum CounterValue
|
||||||
|
{
|
||||||
|
COUNT_LOAN = 0, /** How many weeks until user has to pay back his loan. */
|
||||||
|
COUNT_OVERDRAWN, /**< How often the user overdrew his bank account. */
|
||||||
|
COUNT_POSITIVE, /**< How many weeks until the bank account has to be positive
|
||||||
|
or at least not overdrawn). */
|
||||||
|
COUNT_SUCCESS, /**< How successful the user is. */
|
||||||
|
COUNT_WARNING, /**< Whether there was already a warning about rumours (new coach). */
|
||||||
|
COUNT_INC_CAP, /**< How many weeks until the stadium capacity is increased. */
|
||||||
|
COUNT_INC_SAF, /**< How often the stadium safety was increased (in a week). */
|
||||||
|
COUNT_AUTOSAVE, /**< How often the game is autosaved. */
|
||||||
|
COUNT_OLD_WAGE1,
|
||||||
|
COUNT_OLD_WAGE2,
|
||||||
|
COUNT_OLD_WAGE3,
|
||||||
|
COUNT_OLD_WAGE4,
|
||||||
|
COUNT_OLD_WAGE5,
|
||||||
|
COUNT_END
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Indices for the #options variable. */
|
||||||
|
enum OptionValue
|
||||||
|
{
|
||||||
|
OPT_BOOL_CONF_NEW_ROUND = 0, /**< Whether beginning of a new week round has to be confirmed. */
|
||||||
|
OPT_BOOL_CONF_UNFIT, /**< Unfit player confirmation. */
|
||||||
|
OPT_BOOL_CONF_QUIT, /**< Quit confirmation. */
|
||||||
|
OPT_BOOL_OVERWRITE, /**< Clicking on save overwrites current save game. */
|
||||||
|
OPT_BOOL_SHOW_LIVE, /**< Whether live game is shown. */
|
||||||
|
OPT_LIVE_DURATION, /**< Live game speed. */
|
||||||
|
OPT_BOOL_LIVE_TENDENCY, /**< Tendency bar. */
|
||||||
|
OPT_BOOL_MAXIMIZE, /**< Whether to start maximized. */
|
||||||
|
OPT_BOOL_NOTIFY, /**< Whether transfer list notification is on. */
|
||||||
|
OPT_NOTIFY_POS, /**< Whether we look for a certain position. */
|
||||||
|
OPT_NOTIFY_LEAGUE_UPPER, /**< League with lowest index for notification. */
|
||||||
|
OPT_NOTIFY_LEAGUE_LOWER, /**< League with highest index for notification. */
|
||||||
|
OPT_BOOL_NOTIFY_CUPS, /**< Notify when player from international cups. */
|
||||||
|
OPT_NOTIFY_AGE_UPPER, /**< Upper age bound. */
|
||||||
|
OPT_NOTIFY_AGE_LOWER, /**< Lower age bound. */
|
||||||
|
OPT_NOTIFY_SKILL_UPPER, /**< Skill bound. */
|
||||||
|
OPT_NOTIFY_SKILL_LOWER, /**< Skill bound. */
|
||||||
|
OPT_NOTIFY_ETAL_UPPER, /**< Etal bound. */
|
||||||
|
OPT_NOTIFY_ETAL_LOWER, /**< Etal bound. */
|
||||||
|
OPT_NOTIFY_VALUE, /**< Upper value bound. */
|
||||||
|
OPT_BOOL_JOBS, /**< Whether job offers are shown. */
|
||||||
|
OPT_MESS, /**< Message style. */
|
||||||
|
OPT_BOOL_PREFER_MESS, /**< Messages instead of popups when possible. */
|
||||||
|
OPT_BOOL_AUTOSAVE, /**< Whether autosave is on. */
|
||||||
|
OPT_AUTOSAVE_INTERVAL, /**< How often to autosave. */
|
||||||
|
OPT_BOOL_SORT_TRANSFERS, /**< Whether to sort transfers. */
|
||||||
|
OPT_SORT_TRANSFERS_ATTRIBUTE, /**< Which attribute to sort. */
|
||||||
|
OPT_BOOL_SORT_TRANSFERS_DESCENDING, /**< Whether we sort descending. */
|
||||||
|
OPT_BOOL_REARRANGE, /**< Whether the players get sorted when a new structure is given. */
|
||||||
|
OPT_BOOL_SWAP, /**< Whether the players get sorted when two players are swapped. */
|
||||||
|
OPT_HISTORY_TEAM_INTERVAL, /**< Interval of team history update. */
|
||||||
|
OPT_HISTORY_PLAYER_INTERVAL, /**< Interval of player history update. */
|
||||||
|
OPT_HISTORY_TEAM_MAX, /**< Maximum length of team history. */
|
||||||
|
OPT_HISTORY_PLAYER_MAX, /**< Maximum length of player history. */
|
||||||
|
OPT_BOOL_HISTORY_TEAM_DELETE, /**< Whether team histories get deleted each new season. */
|
||||||
|
OPT_BOOL_HISTORY_PLAYER_DELETE, /**< Whether player histories get deleted each new season. */
|
||||||
|
OPT_BOOL_BOOST, /**< Whether player boost is on. */
|
||||||
|
OPT_BOOL_COMPRESS, /**< Whether to zip-compress savegames. */
|
||||||
|
OPT_BOOL_OBJECTIVE, /**< Whether season objective is on. */
|
||||||
|
OPT_PENALTY_SHOOTER, /**< The id of the penalty shooter. */
|
||||||
|
OPT_END
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
227
src/file.c
227
src/file.c
@@ -3,6 +3,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
#include "variables.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The list of directories the file_find_support_file() function
|
The list of directories the file_find_support_file() function
|
||||||
@@ -34,7 +35,6 @@ file_add_support_directory_recursive (const gchar *directo
|
|||||||
add_pixmap_directory(directory);
|
add_pixmap_directory(directory);
|
||||||
support_directories = g_list_prepend (support_directories,
|
support_directories = g_list_prepend (support_directories,
|
||||||
g_strdup (directory));
|
g_strdup (directory));
|
||||||
|
|
||||||
while(TRUE)
|
while(TRUE)
|
||||||
{
|
{
|
||||||
file = g_dir_read_name(newdir);
|
file = g_dir_read_name(newdir);
|
||||||
@@ -91,7 +91,7 @@ file_find_support_file (const gchar *filename)
|
|||||||
@param abort_program Whether to abort the program if we encounter an error.
|
@param abort_program Whether to abort the program if we encounter an error.
|
||||||
@return TRUE on success, FALSE otherwise. */
|
@return TRUE on success, FALSE otherwise. */
|
||||||
gboolean
|
gboolean
|
||||||
my_fopen(const gchar *filename, gchar *bits, FILE **fil, gboolean abort_program)
|
file_my_fopen(const gchar *filename, gchar *bits, FILE **fil, gboolean abort_program)
|
||||||
{
|
{
|
||||||
gchar buf[SMALL];
|
gchar buf[SMALL];
|
||||||
gchar *support_file = file_find_support_file(filename);
|
gchar *support_file = file_find_support_file(filename);
|
||||||
@@ -117,7 +117,7 @@ my_fopen(const gchar *filename, gchar *bits, FILE **fil, gboolean abort_program)
|
|||||||
/* show_popup_window(buf, NULL); */
|
/* show_popup_window(buf, NULL); */
|
||||||
|
|
||||||
if(abort_program)
|
if(abort_program)
|
||||||
main_exit_program(EXIT_FILE_OPEN_FAILED);
|
main_exit_program(EXIT_FILE_OPEN_FAILED, NULL);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ file_dir_get_contents(const gchar *dir_name, const gchar *prefix)
|
|||||||
GString *new = NULL;
|
GString *new = NULL;
|
||||||
const gchar *file = NULL;
|
const gchar *file = NULL;
|
||||||
|
|
||||||
misc_print_error(error, FALSE);
|
misc_print_error(&error, FALSE);
|
||||||
|
|
||||||
if(dir == NULL)
|
if(dir == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -165,3 +165,222 @@ file_dir_get_contents(const gchar *dir_name, const gchar *prefix)
|
|||||||
|
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Write the first directory called 'definitions' from the support
|
||||||
|
directories array into the buffer.
|
||||||
|
@param dir The string buffer we write the directory path into. */
|
||||||
|
void
|
||||||
|
file_get_definitions_dir(gchar *dir)
|
||||||
|
{
|
||||||
|
GList *elem;
|
||||||
|
|
||||||
|
strcpy(dir, "");
|
||||||
|
|
||||||
|
elem = support_directories;
|
||||||
|
|
||||||
|
while(elem != NULL)
|
||||||
|
{
|
||||||
|
if(g_str_has_suffix((gchar*)elem->data, "definitions") ||
|
||||||
|
g_str_has_suffix((gchar*)elem->data, "definitions/"))
|
||||||
|
{
|
||||||
|
strcpy(dir, (gchar*)elem->data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
elem = elem->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strlen(dir) == 0)
|
||||||
|
main_exit_program(EXIT_DIR_OPEN_FAILED,
|
||||||
|
"Didn't find definitions directory.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Read the file until the next line that's not a comment or
|
||||||
|
a blank line and copy the line into buf.
|
||||||
|
@param fil The file stream.
|
||||||
|
@param buf The buffer we fill.
|
||||||
|
@return TRUE if the file still contains lines to read, FALSE otherwise. */
|
||||||
|
gboolean
|
||||||
|
file_get_next_line(FILE *fil, gchar *buf)
|
||||||
|
{
|
||||||
|
gchar local_buf[BIG];
|
||||||
|
|
||||||
|
strcpy(local_buf, "");
|
||||||
|
|
||||||
|
while( (local_buf[0] == '#' || strlen(local_buf) == 0) &&
|
||||||
|
feof(fil) == 0)
|
||||||
|
{
|
||||||
|
fscanf(fil, "%[\n \t]*", local_buf);
|
||||||
|
fscanf(fil, "%[^\n]", local_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(local_buf[0] != '#' && strlen(local_buf) != 0)
|
||||||
|
{
|
||||||
|
if(strlen(local_buf) > 100)
|
||||||
|
g_warning("\n the text file I'm reading contains a line longer than 100 chars.\n\n");
|
||||||
|
|
||||||
|
if(buf != NULL)
|
||||||
|
strcpy(buf, local_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (feof(fil) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Supply the strings in the config file that belong to the options.
|
||||||
|
@param opt_names The array we write the optionstrings into.
|
||||||
|
@param player_list_att_names The array we write the player list attribute strings into. */
|
||||||
|
void
|
||||||
|
file_write_opt_names(gchar opt_names[][50], gchar player_list_att_names[][PLAYER_LIST_ATTRIBUTE_END][50])
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
|
||||||
|
strcpy(opt_names[OPT_BOOL_CONF_NEW_ROUND], "confirm_new_week_round");
|
||||||
|
strcpy(opt_names[OPT_BOOL_CONF_UNFIT], "confirm_unfit");
|
||||||
|
strcpy(opt_names[OPT_BOOL_CONF_QUIT], "confirm_quit");
|
||||||
|
strcpy(opt_names[OPT_BOOL_OVERWRITE], "save_will_ovewrite");
|
||||||
|
strcpy(opt_names[OPT_BOOL_SHOW_LIVE], "show_live_game");
|
||||||
|
strcpy(opt_names[OPT_LIVE_DURATION], "live_game_duration");
|
||||||
|
strcpy(opt_names[OPT_BOOL_LIVE_TENDENCY], "show_tendency_bar");
|
||||||
|
strcpy(opt_names[OPT_BOOL_MAXIMIZE], "maximize_main_window");
|
||||||
|
|
||||||
|
strcpy(opt_names[OPT_BOOL_NOTIFY], "notify_transfer");
|
||||||
|
strcpy(opt_names[OPT_NOTIFY_POS], "notify_pos");
|
||||||
|
strcpy(opt_names[OPT_NOTIFY_LEAGUE_UPPER], "notify_league_upper");
|
||||||
|
strcpy(opt_names[OPT_NOTIFY_LEAGUE_LOWER], "notify_league_lower");
|
||||||
|
strcpy(opt_names[OPT_BOOL_NOTIFY_CUPS], "notify_cups");
|
||||||
|
strcpy(opt_names[OPT_NOTIFY_AGE_UPPER], "notify_age_upper");
|
||||||
|
strcpy(opt_names[OPT_NOTIFY_AGE_LOWER], "notify_age_lower");
|
||||||
|
strcpy(opt_names[OPT_NOTIFY_SKILL_UPPER], "notify_skill_upper");
|
||||||
|
strcpy(opt_names[OPT_NOTIFY_SKILL_LOWER], "notify_skill_lower");
|
||||||
|
strcpy(opt_names[OPT_NOTIFY_ETAL_UPPER], "notify_etal_upper");
|
||||||
|
strcpy(opt_names[OPT_NOTIFY_ETAL_LOWER], "notify_etal_lower");
|
||||||
|
strcpy(opt_names[OPT_NOTIFY_VALUE], "notify_value");
|
||||||
|
|
||||||
|
strcpy(opt_names[OPT_BOOL_JOBS], "show_job_offers");
|
||||||
|
strcpy(opt_names[OPT_MESS], "message_style");
|
||||||
|
strcpy(opt_names[OPT_BOOL_PREFER_MESS], "prefer_messages");
|
||||||
|
|
||||||
|
strcpy(opt_names[OPT_BOOL_AUTOSAVE], "autosave");
|
||||||
|
strcpy(opt_names[OPT_AUTOSAVE_INTERVAL], "autosave_interval");
|
||||||
|
|
||||||
|
strcpy(opt_names[OPT_BOOL_SORT_TRANSFERS], "sort_transfer_list");
|
||||||
|
strcpy(opt_names[OPT_SORT_TRANSFERS_ATTRIBUTE], "sort_transfer_attribute");
|
||||||
|
strcpy(opt_names[OPT_BOOL_REARRANGE], "reaarrange_adapts");
|
||||||
|
strcpy(opt_names[OPT_BOOL_SWAP], "swap_adapts");
|
||||||
|
|
||||||
|
strcpy(opt_names[OPT_HISTORY_TEAM_INTERVAL], "history_team_interval");
|
||||||
|
strcpy(opt_names[OPT_HISTORY_PLAYER_INTERVAL], "history_player_interval");
|
||||||
|
strcpy(opt_names[OPT_HISTORY_TEAM_MAX], "history_team_max");
|
||||||
|
strcpy(opt_names[OPT_HISTORY_PLAYER_MAX], "history_player_max");
|
||||||
|
strcpy(opt_names[OPT_BOOL_HISTORY_TEAM_DELETE], "history_team_delete");
|
||||||
|
strcpy(opt_names[OPT_BOOL_HISTORY_PLAYER_DELETE], "history_player_delete");
|
||||||
|
|
||||||
|
strcpy(opt_names[OPT_BOOL_BOOST], "boost");
|
||||||
|
strcpy(opt_names[OPT_BOOL_COMPRESS], "compress");
|
||||||
|
strcpy(opt_names[OPT_BOOL_OBJECTIVE], "objective");
|
||||||
|
strcpy(opt_names[OPT_PENALTY_SHOOTER], "penalty_shooter");
|
||||||
|
|
||||||
|
for(i=0;i<2;i++)
|
||||||
|
{
|
||||||
|
for(j=0;j<PLAYER_LIST_ATTRIBUTE_END;j++)
|
||||||
|
sprintf(player_list_att_names[i][j], "pl%d_att_", i + 1);
|
||||||
|
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_NAME], "name");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_CPOS], "cpos");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_POS], "pos");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_CSKILL], "cskill");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_SKILL], "skill");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_FITNESS], "fitness");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_GAMES], "games");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_GOALS], "goals");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_STATUS], "status");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_CARDS], "cards");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_AGE], "age");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_ETAL], "etal");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_VALUE], "value");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_WAGE], "wage");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_CONTRACT], "contract");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_TEAM], "team");
|
||||||
|
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_LEAGUE_CUP], "league_cup");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load the options at the beginning of a new game from
|
||||||
|
the configuration file. */
|
||||||
|
void
|
||||||
|
file_load_conf_file(void)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
gchar opt_names[OPT_END][50];
|
||||||
|
gchar player_list_attribute_names[2][PLAYER_LIST_ATTRIBUTE_END][50];
|
||||||
|
FILE *fil;
|
||||||
|
gchar *conf_file = file_find_support_file("bygfoot.conf");
|
||||||
|
gchar buf[SMALL];
|
||||||
|
gchar buf2[SMALL];
|
||||||
|
gchar trash[SMALL];
|
||||||
|
|
||||||
|
file_my_fopen(conf_file, "r", &fil, TRUE);
|
||||||
|
|
||||||
|
g_free(conf_file);
|
||||||
|
|
||||||
|
file_write_opt_names(opt_names, player_list_attribute_names);
|
||||||
|
|
||||||
|
while(file_get_next_line(fil, buf))
|
||||||
|
{
|
||||||
|
for(i=0;i<OPT_END;i++)
|
||||||
|
if(strncmp(opt_names[i], buf, strlen(opt_names[i])) == 0)
|
||||||
|
sscanf(buf, "%[^-0-9 ]%d", trash, &options[i]);
|
||||||
|
|
||||||
|
for(j=0;j<2;j++)
|
||||||
|
for(i=0;i<PLAYER_LIST_ATTRIBUTE_END;i++)
|
||||||
|
if(strncmp(player_list_attribute_names[j][i], buf, strlen(player_list_attribute_names[j][i])) == 0)
|
||||||
|
sscanf(buf, "%[^ ]%[ ]%d", trash, buf2,
|
||||||
|
&player_list_attributes[j].on_off[i]);
|
||||||
|
|
||||||
|
if(strncmp(buf, "font_name", strlen("font_name")) == 0)
|
||||||
|
{
|
||||||
|
sscanf(buf, "%[font_name ]%[^\n]", trash, buf2);
|
||||||
|
g_string_printf(font_name, "%s", buf2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strncmp(buf, "debug", strlen("debug")) == 0)
|
||||||
|
sscanf(buf, "%[debug ]%d", trash, &debug);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Save the current options to the configuration file. */
|
||||||
|
void
|
||||||
|
file_save_conf(void)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
gchar opt_names[OPT_END][50];
|
||||||
|
gchar player_list_att_names[2][PLAYER_LIST_ATTRIBUTE_END][50];
|
||||||
|
FILE *fil = NULL;
|
||||||
|
gchar *conf_file = file_find_support_file("bygfoot.conf");
|
||||||
|
|
||||||
|
if(!file_my_fopen(conf_file, "w", &fil, FALSE))
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_free(conf_file);
|
||||||
|
|
||||||
|
file_write_opt_names(opt_names, player_list_att_names);
|
||||||
|
|
||||||
|
for(i=0;i<OPT_PENALTY_SHOOTER;i++)
|
||||||
|
fprintf(fil, "%s %d\n", opt_names[i], options[i]);
|
||||||
|
|
||||||
|
fprintf(fil, "%s -1\n", opt_names[OPT_PENALTY_SHOOTER]);
|
||||||
|
|
||||||
|
for(j=0;j<2;j++)
|
||||||
|
{
|
||||||
|
fprintf(fil, "\n");
|
||||||
|
for(i=0;i<PLAYER_LIST_ATTRIBUTE_END;i++)
|
||||||
|
fprintf(fil, "%s %d\n", player_list_att_names[j][i],
|
||||||
|
player_list_attributes[j].on_off[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fil, "\n");
|
||||||
|
fprintf(fil, "font_name %s\n", font_name->str);
|
||||||
|
fprintf(fil, "debug %d\n", debug);
|
||||||
|
|
||||||
|
fclose(fil);
|
||||||
|
}
|
||||||
|
15
src/file.h
15
src/file.h
@@ -2,6 +2,7 @@
|
|||||||
#define FILE_H
|
#define FILE_H
|
||||||
|
|
||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
|
#include "player_struct.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
file_add_support_directory_recursive (const gchar *directory);
|
file_add_support_directory_recursive (const gchar *directory);
|
||||||
@@ -19,6 +20,18 @@ void
|
|||||||
file_get_player_names(gint number_of_names);
|
file_get_player_names(gint number_of_names);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
my_fopen(const gchar *filename, gchar *bits, FILE **fil, gboolean abort_program);
|
file_my_fopen(const gchar *filename, gchar *bits, FILE **fil, gboolean abort_program);
|
||||||
|
|
||||||
|
void
|
||||||
|
file_get_definitions_dir(gchar *dir);
|
||||||
|
|
||||||
|
void
|
||||||
|
file_write_opt_names(gchar opt_names[][50], gchar player_list_att_names[][PLAYER_LIST_ATTRIBUTE_END][50]);
|
||||||
|
|
||||||
|
void
|
||||||
|
file_load_conf_file(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
file_save_conf(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
402
src/fixture.c
402
src/fixture.c
@@ -1 +1,403 @@
|
|||||||
|
#include "cup.h"
|
||||||
#include "fixture.h"
|
#include "fixture.h"
|
||||||
|
#include "free.h"
|
||||||
|
#include "league.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "maths.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "team.h"
|
||||||
|
#include "variables.h"
|
||||||
|
|
||||||
|
/** Write the fixtures for the given league
|
||||||
|
at the beginning of a new season.
|
||||||
|
@param league The league we write the fixtures for. */
|
||||||
|
void
|
||||||
|
fixture_write_league_fixtures(League *league)
|
||||||
|
{
|
||||||
|
/*d*/
|
||||||
|
gint i;
|
||||||
|
Fixture *fix = NULL;
|
||||||
|
GPtrArray *teams = NULL;
|
||||||
|
|
||||||
|
teams = team_get_pointers_from_array(league->teams);
|
||||||
|
|
||||||
|
fixture_write_round_robin((gpointer)league, -1, teams);
|
||||||
|
|
||||||
|
/*d*/
|
||||||
|
/* printf("\n%s\n", league->name->str); */
|
||||||
|
/* for(i=0;i<league->fixtures->len;i++) */
|
||||||
|
/* { */
|
||||||
|
/* fix = &g_array_index(league->fixtures, Fixture, i); */
|
||||||
|
/* if(i > 0 && */
|
||||||
|
/* g_array_index(league->fixtures, Fixture, i).week_number != */
|
||||||
|
/* g_array_index(league->fixtures, Fixture, i - 1).week_number) */
|
||||||
|
/* printf("\nweek %d\n", g_array_index(league->fixtures, Fixture, i).week_number); */
|
||||||
|
|
||||||
|
/* printf("%s -- %s round %d week %d wr %d res %d %d home %d sec %d dec %d\n", */
|
||||||
|
/* fix->teams[0]->name->str, fix->teams[1]->name->str, */
|
||||||
|
/* fix->round, */
|
||||||
|
/* fix->week_number, fix->week_round_number, */
|
||||||
|
/* fix->result[0][0], fix->result[1][0], */
|
||||||
|
/* fix->home_advantage, fix->second_leg, */
|
||||||
|
/* fix->decisive); */
|
||||||
|
|
||||||
|
/* } */
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Write the fixtures for the given cup
|
||||||
|
at the beginning of a new season.
|
||||||
|
@param cup The cup we write the fixtures for. */
|
||||||
|
void
|
||||||
|
fixture_write_cup_fixtures(Cup *cup)
|
||||||
|
{
|
||||||
|
/*d*/
|
||||||
|
gint i;
|
||||||
|
Fixture *fix = NULL;
|
||||||
|
GPtrArray *teams = NULL;
|
||||||
|
|
||||||
|
if(g_array_index(cup->rounds, CupRound, 0).
|
||||||
|
round_robin_number_of_groups > 0)
|
||||||
|
fixture_write_cup_round_robin(cup, 0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(cup->type == CUP_TYPE_INTERNATIONAL)
|
||||||
|
teams = cup_get_team_pointers(cup);
|
||||||
|
else
|
||||||
|
teams = team_get_pointers_from_choose_teams(cup->choose_teams);
|
||||||
|
|
||||||
|
fixture_write_knockout_round(teams, cup, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*d*/
|
||||||
|
/* printf("\n%s\n", cup->name->str); */
|
||||||
|
/* for(i=0;i<cup->fixtures->len;i++) */
|
||||||
|
/* { */
|
||||||
|
/* fix = &g_array_index(cup->fixtures, Fixture, i); */
|
||||||
|
/* if(i > 0 && */
|
||||||
|
/* g_array_index(cup->fixtures, Fixture, i).week_number != */
|
||||||
|
/* g_array_index(cup->fixtures, Fixture, i - 1).week_number) */
|
||||||
|
/* printf("\nweek %d\n", g_array_index(cup->fixtures, Fixture, i).week_number); */
|
||||||
|
|
||||||
|
/* printf("%2d %s -- %s round %d week %d wr %d res %d %d home %d sec %d dec %d\n", i, */
|
||||||
|
/* fix->teams[0]->name->str, */
|
||||||
|
/* fix->teams[1]->name->str, */
|
||||||
|
/* fix->round, */
|
||||||
|
/* fix->week_number, fix->week_round_number, */
|
||||||
|
/* fix->result[0][0], fix->result[1][0], */
|
||||||
|
/* fix->home_advantage, fix->second_leg, */
|
||||||
|
/* fix->decisive); */
|
||||||
|
|
||||||
|
/* } */
|
||||||
|
}
|
||||||
|
/** Write round robins for the given cup and cup round.
|
||||||
|
@param cup The cup the fixtures are for.
|
||||||
|
@param cup_round The cup round. */
|
||||||
|
void
|
||||||
|
fixture_write_cup_round_robin(Cup *cup, gint cup_round)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
gint number_of_groups =
|
||||||
|
g_array_index(cup->rounds, CupRound, cup_round).round_robin_number_of_groups;
|
||||||
|
GPtrArray *teams = NULL;
|
||||||
|
GPtrArray *teams_group[number_of_groups];
|
||||||
|
Table new_table;
|
||||||
|
TableElement new_table_element;
|
||||||
|
|
||||||
|
if(cup_round == 0)
|
||||||
|
teams = misc_randomise_g_pointer_array(cup_get_team_pointers(cup));
|
||||||
|
/*todo*/
|
||||||
|
/* else */
|
||||||
|
/* teams = cup_get_winners_of_round(cup, cup_round - 1); */
|
||||||
|
|
||||||
|
if(teams->len % number_of_groups != 0)
|
||||||
|
{
|
||||||
|
g_warning("fixture_write_cup_round_robin: number of teams not divisable by number of groups\ncup %s cup_round %d\n",
|
||||||
|
cup->name->str, cup_round);
|
||||||
|
main_exit_program(EXIT_FIXTURE_WRITE_ERROR, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
free_cup_tables(cup->tables);
|
||||||
|
cup->tables = g_array_new(FALSE, FALSE, sizeof(Table));
|
||||||
|
|
||||||
|
for(i=0;i<number_of_groups;i++)
|
||||||
|
{
|
||||||
|
new_table.name = g_string_new(cup->name->str);
|
||||||
|
new_table.clid = cup->id;
|
||||||
|
new_table.elements = g_array_new(FALSE, FALSE, sizeof(TableElement));
|
||||||
|
|
||||||
|
teams_group[i] = g_ptr_array_new();
|
||||||
|
|
||||||
|
for(j=0;j<teams->len / number_of_groups;j++)
|
||||||
|
{
|
||||||
|
g_ptr_array_add(teams_group[i], g_ptr_array_index(teams, j + i * number_of_groups));
|
||||||
|
new_table_element =
|
||||||
|
league_table_element_new((Team*)g_ptr_array_index(teams, j + i * number_of_groups));
|
||||||
|
g_array_append_val(new_table.elements, new_table_element);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_array_append_val(cup->tables, new_table);
|
||||||
|
|
||||||
|
fixture_write_round_robin((gpointer)cup, cup_round, teams_group[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
cup->next_fixture_update_week =
|
||||||
|
g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_number;
|
||||||
|
cup->next_fixture_update_week_round =
|
||||||
|
g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_round_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Write round robin fixtures for the teams in the array.
|
||||||
|
The way it's done is difficult to explain, so there
|
||||||
|
won't be many comments below.
|
||||||
|
@param league_cup The pointer to the cup or league the fixtures
|
||||||
|
belong to.
|
||||||
|
@param cup_round The round of the cup the fixtures belong to
|
||||||
|
or -1 if we have a league.
|
||||||
|
@param teams The pointer array containing pointers
|
||||||
|
to the teams. */
|
||||||
|
void
|
||||||
|
fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
gint first_week, week_gap, clid, first_fixture;
|
||||||
|
gboolean home_advantage, second_leg, decisive;
|
||||||
|
League *league = NULL;
|
||||||
|
Cup *cup = NULL;
|
||||||
|
gint len = teams->len;
|
||||||
|
GArray *fixtures = NULL;
|
||||||
|
|
||||||
|
teams = misc_randomise_g_pointer_array(teams);
|
||||||
|
|
||||||
|
if(cup_round == -1)
|
||||||
|
{
|
||||||
|
league = (League*)league_cup;
|
||||||
|
first_week = league->first_week;
|
||||||
|
week_gap = league->week_gap;
|
||||||
|
fixtures = league->fixtures;
|
||||||
|
clid = league->id;
|
||||||
|
home_advantage = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cup = (Cup*)league_cup;
|
||||||
|
first_week = cup_get_first_week_of_cup_round(cup, cup_round);
|
||||||
|
week_gap = cup->week_gap;
|
||||||
|
fixtures = cup->fixtures;
|
||||||
|
clid = cup->id;
|
||||||
|
home_advantage = (!g_array_index(cup->rounds, CupRound, cup_round).neutral);
|
||||||
|
}
|
||||||
|
|
||||||
|
second_leg = decisive = FALSE;
|
||||||
|
first_fixture = fixtures->len;
|
||||||
|
|
||||||
|
if(first_week < 1)
|
||||||
|
{
|
||||||
|
g_warning("fixture_write_round_robin: first week is not positive: %d\n", first_week);
|
||||||
|
main_exit_program(EXIT_FIXTURE_WRITE_ERROR, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(len % 2 != 0)
|
||||||
|
main_exit_program(EXIT_FIXTURE_WRITE_ERROR,
|
||||||
|
"fixture_write_round_robin: round robin for an odd number of teams is not supported.\n");
|
||||||
|
|
||||||
|
/* first half of fixtures */
|
||||||
|
for(i=0;i<len - 1;i++)
|
||||||
|
fixture_write_round_robin_matchday(fixtures, cup_round, teams, i,
|
||||||
|
first_week + i * week_gap,
|
||||||
|
fixture_get_free_round(first_week + i * week_gap, clid),
|
||||||
|
clid, home_advantage, second_leg, decisive);
|
||||||
|
|
||||||
|
/* second half of fixtures */
|
||||||
|
for(i = 0; i < len - 1; i++)
|
||||||
|
for(j = 0; j < len / 2; j++)
|
||||||
|
fixture_write(fixtures, g_array_index(fixtures, Fixture, first_fixture + i * (len / 2) + j).teams[1],
|
||||||
|
g_array_index(fixtures, Fixture, first_fixture + i * (len / 2) + j).teams[0],
|
||||||
|
first_week + (len - 1 + i) * week_gap,
|
||||||
|
fixture_get_free_round(first_week + (len - 1 + i) * week_gap, clid),
|
||||||
|
clid, cup_round, home_advantage, second_leg, decisive);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Write one matchday of round robin games.
|
||||||
|
@param fixtures The fixture array we add the fixtures to.
|
||||||
|
@param cup_round The round of the cup the fixtures belong to
|
||||||
|
or -1 if we have a league.
|
||||||
|
@param teams The array containing the pointers
|
||||||
|
of the teams participating.
|
||||||
|
@param special The special team.
|
||||||
|
@param week_number The week the matchday takes place.
|
||||||
|
@param week_round_number The week_round the matchday takes place.
|
||||||
|
@param clid The id of the league or cup.
|
||||||
|
@param home_advantage Whether there's home advantage.
|
||||||
|
@param second_leg Whether this is the second leg of a round.
|
||||||
|
@param decisive Whether the match has to have a winner. */
|
||||||
|
void
|
||||||
|
fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *teams,
|
||||||
|
gint special, gint week_number, gint week_round_number,
|
||||||
|
gint clid, gboolean home_advantage, gboolean second_leg,
|
||||||
|
gboolean decisive)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
gint len = teams->len / 2;
|
||||||
|
gpointer home[len], away[len];
|
||||||
|
|
||||||
|
home[0] = g_ptr_array_index(teams, len * 2 - 1);
|
||||||
|
away[0] = g_ptr_array_index(teams, special);
|
||||||
|
|
||||||
|
for(i=1;i<len;i++)
|
||||||
|
{
|
||||||
|
home[i] = g_ptr_array_index(teams, (special + i) % (len * 2 - 1));
|
||||||
|
away[i] =
|
||||||
|
g_ptr_array_index(teams, (special + i + (len - 1 - i) * 2 + 1) % (len * 2 - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(special % 2)
|
||||||
|
for(i=0;i<len;i++)
|
||||||
|
misc_swap_gpointer(&(home[i]), &(away[i]));
|
||||||
|
|
||||||
|
for(i=0;i<len;i++)
|
||||||
|
fixture_write(fixtures, (Team*)home[i], (Team*)away[i], week_number, week_round_number,
|
||||||
|
clid, cup_round, home_advantage, second_leg, decisive);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Write fixtures for a knockout round, e.g. home/away games.
|
||||||
|
@param teams The teams participating.
|
||||||
|
@param cup The cup the fixtures belong to.
|
||||||
|
@param cup_round The index of the cup round. */
|
||||||
|
void
|
||||||
|
fixture_write_knockout_round(GPtrArray *teams, Cup *cup, gint cup_round)
|
||||||
|
{
|
||||||
|
gint i, len = teams->len;
|
||||||
|
gint first_week = cup_get_first_week_of_cup_round(cup, cup_round);
|
||||||
|
CupRound *round = &g_array_index(cup->rounds, CupRound, cup_round);
|
||||||
|
gint bye_len = math_get_bye_len(teams->len);
|
||||||
|
|
||||||
|
if(len % 2 != 0)
|
||||||
|
main_exit_program(EXIT_FIXTURE_WRITE_ERROR,
|
||||||
|
"fixture_write_knockout_round: odd number of teams.\n");
|
||||||
|
|
||||||
|
teams = misc_randomise_g_pointer_array(teams);
|
||||||
|
|
||||||
|
if(bye_len != 0)
|
||||||
|
for(i=0;i<bye_len;i++)
|
||||||
|
{
|
||||||
|
/*d*/
|
||||||
|
/* printf("bye %d %s\n", i, ((Team*)g_ptr_array_index(teams, len - bye_len + i))->name->str); */
|
||||||
|
g_ptr_array_add(cup->bye, g_ptr_array_index(teams, len - bye_len + i));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
free_g_ptr_array(&cup->bye);
|
||||||
|
|
||||||
|
for(i=0; i<(len - bye_len) / 2; i++)
|
||||||
|
fixture_write(cup->fixtures, (Team*)g_ptr_array_index(teams, i),
|
||||||
|
(Team*)g_ptr_array_index(teams, i + (len - bye_len) / 2), first_week,
|
||||||
|
fixture_get_free_round(first_week, cup->id), cup->id, cup_round,
|
||||||
|
!round->neutral, FALSE, (!round->home_away && round->replay == 0));/*todo: adjust
|
||||||
|
round->replay */
|
||||||
|
if(round->home_away)
|
||||||
|
for(i=0; i<(len - bye_len) / 2; i++)
|
||||||
|
fixture_write(cup->fixtures, (Team*)g_ptr_array_index(teams, i + (len - bye_len) / 2),
|
||||||
|
(Team*)g_ptr_array_index(teams, i), first_week + cup->week_gap,
|
||||||
|
fixture_get_free_round(first_week + cup->week_gap, cup->id), cup->id,
|
||||||
|
cup_round, !round->neutral, TRUE, TRUE);
|
||||||
|
|
||||||
|
cup->next_fixture_update_week =
|
||||||
|
g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_number;
|
||||||
|
cup->next_fixture_update_week_round =
|
||||||
|
g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_round_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Write a fixture and append it to a fixture array.
|
||||||
|
@param fixtures The fixture array.
|
||||||
|
@param home_team The pointer of the home team.
|
||||||
|
@param away_team The pointer of the away team.
|
||||||
|
@param week_number The week it takes place.
|
||||||
|
@param week_round_number The week_round it takes place.
|
||||||
|
@param clid The id of the league or cup.
|
||||||
|
@param cup_round The index of the cup round or -1 if it's a league.
|
||||||
|
@param home_advantage Whether there's home advantage.
|
||||||
|
@param second_leg Whether this is the second leg of a round.
|
||||||
|
@param decisive Whether the match has to have a winner. */
|
||||||
|
void
|
||||||
|
fixture_write(GArray *fixtures, Team *home_team, Team *away_team, gint week_number,
|
||||||
|
gint week_round_number, gint clid, gint cup_round, gboolean home_advantage,
|
||||||
|
gboolean second_leg, gboolean decisive)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
Fixture new;
|
||||||
|
|
||||||
|
new.clid = clid;
|
||||||
|
new.round = cup_round;
|
||||||
|
new.week_number = week_number;
|
||||||
|
new.week_round_number = week_round_number;
|
||||||
|
new.teams[0] = (Team*)home_team;
|
||||||
|
new.teams[1] = (Team*)away_team;
|
||||||
|
for(i=0;i<3;i++)
|
||||||
|
new.result[0][i] = new.result[1][i] = 0;
|
||||||
|
|
||||||
|
new.home_advantage = home_advantage;
|
||||||
|
new.second_leg = second_leg;
|
||||||
|
new.decisive = decisive;
|
||||||
|
new.attendance = 0;
|
||||||
|
|
||||||
|
g_array_append_val(fixtures, new);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the round of the week which doesn't contain
|
||||||
|
any matches yet except for matches of the cup with the given
|
||||||
|
id.
|
||||||
|
@param week_number The week we examine.
|
||||||
|
@param clid The id of the cup we search a free round for.
|
||||||
|
@return A round number. If the clid belongs to a league this is always 1. */
|
||||||
|
gint
|
||||||
|
fixture_get_free_round(gint week_number, gint clid)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
gint max_round = 1;
|
||||||
|
|
||||||
|
if(clid < ID_CUP_START)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
for(i=0;i<cps->len;i++)
|
||||||
|
if(cp(i).id != clid)
|
||||||
|
for(j=0;j<cp(i).fixtures->len;j++)
|
||||||
|
if(g_array_index(cp(i).fixtures, Fixture, j).week_number == week_number &&
|
||||||
|
g_array_index(cp(i).fixtures, Fixture, j).week_round_number == max_round + 1)
|
||||||
|
max_round = MAX(max_round,
|
||||||
|
g_array_index(cp(i).fixtures, Fixture, j).week_round_number);
|
||||||
|
|
||||||
|
return max_round + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check whether the date of a fixture is earlier
|
||||||
|
than of a second one.
|
||||||
|
@param fix1 The first fixture.
|
||||||
|
@param fix2 The second fixture.
|
||||||
|
@return TRUE if fix1 is earlier than fix2, FALSE otherwise. */
|
||||||
|
gboolean
|
||||||
|
query_fixture_is_earlier(const Fixture *fix1, const Fixture *fix2)
|
||||||
|
{
|
||||||
|
return (fix1->week_number < fix2->week_number ||
|
||||||
|
(fix1->week_number == fix2->week_number &&
|
||||||
|
fix1->week_round_number < fix2->week_round_number));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Find out whether the current result of the fixture
|
||||||
|
is a draw. This is a bit tricky because of second-leg games.
|
||||||
|
In general (as a definition), fixtures with 'decisive' FALSE
|
||||||
|
are never drawn.
|
||||||
|
@param fix The pointer to the fixture.
|
||||||
|
@return TRUE or FALSE. */
|
||||||
|
gboolean
|
||||||
|
query_fixture_is_draw(const Fixture *fix)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check whether the user's team participates.
|
||||||
|
@param fix The fixture we check.
|
||||||
|
@return TRUE or FALSE. */
|
||||||
|
gboolean
|
||||||
|
query_my_team_involved(const Fixture *fix)
|
||||||
|
{
|
||||||
|
return (fix->teams[0] == my_team || fix->teams[1] == my_team);
|
||||||
|
}
|
||||||
|
@@ -2,67 +2,46 @@
|
|||||||
#define FIXTURE_H
|
#define FIXTURE_H
|
||||||
|
|
||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
|
#include "cup_struct.h"
|
||||||
|
#include "fixture_struct.h"
|
||||||
|
#include "league_struct.h"
|
||||||
|
|
||||||
/** Possible goal types. */
|
void
|
||||||
enum GoalType
|
fixture_write_league_fixtures(League *league);
|
||||||
{
|
|
||||||
GOAL_TYPE_REGULAR= 0,
|
|
||||||
GOAL_TYPE_OWN,
|
|
||||||
GOAL_TYPE_PENALTY,
|
|
||||||
GOAL_TYPE_PENALTY_MISSED,
|
|
||||||
GOAL_TYPE_PENALTY_SAVE,
|
|
||||||
GOAL_TYPE_PENALTY_POST,
|
|
||||||
GOAL_TYPE_PENALTY_CROSS,
|
|
||||||
GOAL_TYPE_END
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Possible goal times. */
|
void
|
||||||
enum GoalTime
|
fixture_write_cup_fixtures(Cup *cup);
|
||||||
{
|
|
||||||
/** In regulation. */
|
|
||||||
GOAL_TIME_REGULATION = 0,
|
|
||||||
/** In extra time. */
|
|
||||||
GOAL_TIME_EXTRA,
|
|
||||||
/** In penalty shoot-out. */
|
|
||||||
GOAL_TIME_PENALTY,
|
|
||||||
GOAL_TIME_END
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Structure representing a goal. */
|
void
|
||||||
typedef struct
|
fixture_write_cup_round_robin(Cup *cup, gint cup_round);
|
||||||
{
|
|
||||||
gint minute, /**< The minute it happened. */
|
|
||||||
team_number, /**< The team that scored (0 or 1). */
|
|
||||||
time, /**< Whether it was in regulation, extra time or penalties. */
|
|
||||||
type; /** What kind of goal it was (e.g. penalty). */
|
|
||||||
|
|
||||||
/** Name of the scorer. */
|
void
|
||||||
GString *scorer_name;
|
fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams);
|
||||||
} Goal;
|
|
||||||
|
|
||||||
/** Structure representing a fixture, or, in other words,
|
void
|
||||||
a match. */
|
fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *teams,
|
||||||
typedef struct
|
gint special, gint week_number, gint week_round_number,
|
||||||
{
|
gint clid, gboolean home_advantage, gboolean second_leg,
|
||||||
/** The cup or league the fixture belongs to. */
|
gboolean decisive);
|
||||||
gint clid;
|
|
||||||
/** The round (in a cup) the fixture belongs to. */
|
void
|
||||||
gint round;
|
fixture_write_knockout_round(GPtrArray *teams, Cup *cup, gint cup_round);
|
||||||
/** When it takes place. */
|
|
||||||
gint week_number, week_round_number;
|
void
|
||||||
/** The teams involved. */
|
fixture_write(GArray *fixtures, Team *home_team, Team *away_team, gint week_number,
|
||||||
gint team_clid[2], team_id[2];
|
gint week_round_number, gint clid, gint cup_round, gboolean home_advantage,
|
||||||
/** The number of goals for each team in
|
gboolean second_leg, gboolean decisive);
|
||||||
regulation, extra time and penalty shoot-out. */
|
|
||||||
gint result[2][3];
|
gint
|
||||||
/** Whether there's home advantage, this is second leg,
|
fixture_get_free_round(gint week_number, gint clid);
|
||||||
or the game has to be decided. */
|
|
||||||
gboolean home_advantage, second_leg, decisive;
|
gboolean
|
||||||
/** How many people attended and whether there were
|
query_fixture_is_earlier(const Fixture *fix1, const Fixture *fix2);
|
||||||
special events. */
|
|
||||||
gint attendance, stadium_event;
|
gboolean
|
||||||
/** The goals that were scored. */
|
query_fixture_is_draw(const Fixture *fix);
|
||||||
GArray *goals;
|
|
||||||
} Fixture;
|
gboolean
|
||||||
|
query_my_team_involved(const Fixture *fix);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
30
src/fixture_struct.h
Normal file
30
src/fixture_struct.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef FIXTURE_STRUCT_H
|
||||||
|
#define FIXTURE_STRUCT_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
|
#include "team_struct.h"
|
||||||
|
|
||||||
|
/** Structure representing a fixture, or, in other words,
|
||||||
|
a match. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/** The cup or league the fixture belongs to. */
|
||||||
|
gint clid;
|
||||||
|
/** The round (in a cup) the fixture belongs to. */
|
||||||
|
gint round;
|
||||||
|
/** When it takes place. */
|
||||||
|
gint week_number, week_round_number;
|
||||||
|
/** The teams involved. */
|
||||||
|
Team *teams[2];
|
||||||
|
/** The number of goals for each team in
|
||||||
|
regulation, extra time and penalty shoot-out. */
|
||||||
|
gint result[2][3];
|
||||||
|
/** Whether there's home advantage, this is second leg,
|
||||||
|
or the game has to be decided. */
|
||||||
|
gboolean home_advantage, second_leg, decisive;
|
||||||
|
/** How many people attended and whether there were
|
||||||
|
special events. */
|
||||||
|
gint attendance;
|
||||||
|
} Fixture;
|
||||||
|
|
||||||
|
#endif
|
128
src/free.c
128
src/free.c
@@ -4,33 +4,7 @@
|
|||||||
#include "league.h"
|
#include "league.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
/** Free a GString if it isn't NULL.
|
|
||||||
@param string The string to be freed. */
|
|
||||||
void
|
|
||||||
free_g_string(GString **string)
|
|
||||||
{
|
|
||||||
if(*string == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_string_free(*string, TRUE);
|
|
||||||
|
|
||||||
*string = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Free a GArray if it isn't NULL.
|
|
||||||
@param array The array to be freed. */
|
|
||||||
void
|
|
||||||
free_g_array(GArray **array)
|
|
||||||
{
|
|
||||||
if(*array == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_array_free(*array, TRUE);
|
|
||||||
|
|
||||||
*array = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Free all memory allocated by the program.
|
Free all memory allocated by the program.
|
||||||
@@ -42,8 +16,28 @@ free_memory(void)
|
|||||||
free_variables();
|
free_variables();
|
||||||
free_country();
|
free_country();
|
||||||
free_g_string(&font_name);
|
free_g_string(&font_name);
|
||||||
|
free_live_game(&live_game);
|
||||||
|
free_live_game(&live_game_temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Free a live game variable. */
|
||||||
|
void
|
||||||
|
free_live_game(LiveGame *match)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
window_destroy(&match->window);
|
||||||
|
|
||||||
|
if(match->units == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(i=0;i<match->units->len;i++)
|
||||||
|
free_g_string(&g_array_index(match->units, LiveGameUnit, i).event.commentary);
|
||||||
|
|
||||||
|
free_g_array(&match->units);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Free the main variable of the game, #country.
|
Free the main variable of the game, #country.
|
||||||
*/
|
*/
|
||||||
@@ -109,6 +103,8 @@ free_league(League *league)
|
|||||||
|
|
||||||
for(i=0;i<3;i++)
|
for(i=0;i<3;i++)
|
||||||
free_g_array(arrays[i]);
|
free_g_array(arrays[i]);
|
||||||
|
|
||||||
|
free_g_array(&league->fixtures);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Free the memory occupied by a teams array.
|
/** Free the memory occupied by a teams array.
|
||||||
@@ -209,6 +205,32 @@ free_cup(Cup *cup)
|
|||||||
|
|
||||||
for(i=0;i<3;i++)
|
for(i=0;i<3;i++)
|
||||||
free_g_array(arrays[i]);
|
free_g_array(arrays[i]);
|
||||||
|
|
||||||
|
free_g_array(&cup->fixtures);
|
||||||
|
|
||||||
|
free_g_ptr_array(&cup->bye);
|
||||||
|
free_g_ptr_array(&cup->user_teams);
|
||||||
|
|
||||||
|
free_cup_tables(cup->tables);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Free the memory occupied by the cup tables.
|
||||||
|
@param tables The array containing the tables. */
|
||||||
|
void
|
||||||
|
free_cup_tables(GArray *tables)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if(tables == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(i=0;i<tables->len;i++)
|
||||||
|
{
|
||||||
|
free_g_string(&g_array_index(tables, Table, i).name);
|
||||||
|
free_g_array(&g_array_index(tables, Table, i).elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
free_g_array(&tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,22 +247,9 @@ free_cup_choose_team(CupChooseTeam *cup_choose_team)
|
|||||||
void
|
void
|
||||||
free_variables(void)
|
free_variables(void)
|
||||||
{
|
{
|
||||||
gint i, j;
|
|
||||||
GArray **arrays[2] =
|
|
||||||
{&transfer_list,
|
|
||||||
&fixtures};
|
|
||||||
|
|
||||||
free_g_string_array(&player_names);
|
free_g_string_array(&player_names);
|
||||||
|
|
||||||
if(fixtures != NULL)
|
free_g_array(&transfer_list);
|
||||||
for(i=0;i<fixtures->len;i++)
|
|
||||||
for(j=0;j<g_array_index(fixtures, Fixture, i).goals->len;j++)
|
|
||||||
free_g_string(&g_array_index(
|
|
||||||
g_array_index(
|
|
||||||
fixtures, Fixture, i).goals, Goal, j).scorer_name);
|
|
||||||
|
|
||||||
for(i=0;i<2;i++)
|
|
||||||
free_g_array(arrays[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,6 +267,43 @@ free_g_string_array(GPtrArray **array)
|
|||||||
for(i=0;i<(*array)->len;i++)
|
for(i=0;i<(*array)->len;i++)
|
||||||
free_g_string((GString**)&g_ptr_array_index(*array, i));
|
free_g_string((GString**)&g_ptr_array_index(*array, i));
|
||||||
|
|
||||||
|
free_g_ptr_array(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Free a GString if it isn't NULL.
|
||||||
|
@param string The string to be freed. */
|
||||||
|
void
|
||||||
|
free_g_string(GString **string)
|
||||||
|
{
|
||||||
|
if(*string == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_string_free(*string, TRUE);
|
||||||
|
|
||||||
|
*string = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Free a GArray if it isn't NULL.
|
||||||
|
@param array The array to be freed. */
|
||||||
|
void
|
||||||
|
free_g_array(GArray **array)
|
||||||
|
{
|
||||||
|
if(*array == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_array_free(*array, TRUE);
|
||||||
|
|
||||||
|
*array = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Free a GPtrArray if it isn't NULL.
|
||||||
|
@param array The array to be freed. */
|
||||||
|
void
|
||||||
|
free_g_ptr_array(GPtrArray **array)
|
||||||
|
{
|
||||||
|
if(*array == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
g_ptr_array_free(*array, TRUE);
|
g_ptr_array_free(*array, TRUE);
|
||||||
|
|
||||||
*array = NULL;
|
*array = NULL;
|
||||||
|
10
src/free.h
10
src/free.h
@@ -4,12 +4,16 @@
|
|||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
#include "cup_struct.h"
|
#include "cup_struct.h"
|
||||||
#include "league_struct.h"
|
#include "league_struct.h"
|
||||||
|
#include "live_game_struct.h"
|
||||||
#include "player_struct.h"
|
#include "player_struct.h"
|
||||||
#include "team_struct.h"
|
#include "team_struct.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
free_g_array(GArray **array);
|
free_g_array(GArray **array);
|
||||||
|
|
||||||
|
void
|
||||||
|
free_g_ptr_array(GPtrArray **array);
|
||||||
|
|
||||||
void
|
void
|
||||||
free_g_string(GString **string);
|
free_g_string(GString **string);
|
||||||
|
|
||||||
@@ -37,6 +41,9 @@ free_cups_array(GArray **cups);
|
|||||||
void
|
void
|
||||||
free_cup(Cup *cup);
|
free_cup(Cup *cup);
|
||||||
|
|
||||||
|
void
|
||||||
|
free_cup_tables(GArray *tables);
|
||||||
|
|
||||||
void
|
void
|
||||||
free_cup_choose_team(CupChooseTeam *cup_choose_team);
|
free_cup_choose_team(CupChooseTeam *cup_choose_team);
|
||||||
|
|
||||||
@@ -49,4 +56,7 @@ free_g_string_array(GPtrArray **array);
|
|||||||
void
|
void
|
||||||
free_player(Player *pl);
|
free_player(Player *pl);
|
||||||
|
|
||||||
|
void
|
||||||
|
free_live_game(LiveGame *match);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
164
src/game.c
164
src/game.c
@@ -0,0 +1,164 @@
|
|||||||
|
#include "fixture.h"
|
||||||
|
#include "game.h"
|
||||||
|
#include "maths.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include "team.h"
|
||||||
|
#include "variables.h"
|
||||||
|
|
||||||
|
/** Influence in % of the game style towards more attack.
|
||||||
|
@see game_get_values() */
|
||||||
|
#define CONSTANT_GAME_STYLE_FACTOR 0.075
|
||||||
|
/** How much a defender's worth when the team's defending or attacking.
|
||||||
|
@see game_get_player_contribution() */
|
||||||
|
#define CONSTANT_GAME_PLAYER_WEIGHT_DEFENDER_DEFEND 1
|
||||||
|
#define CONSTANT_GAME_PLAYER_WEIGHT_DEFENDER_ATTACK 0.25
|
||||||
|
/** How much a forward's worth when the team's defending or attacking.
|
||||||
|
@see game_get_player_contribution() */
|
||||||
|
#define CONSTANT_GAME_PLAYER_WEIGHT_FORWARD_DEFEND 0.2
|
||||||
|
#define CONSTANT_GAME_PLAYER_WEIGHT_FORWARD_ATTACK 1.3
|
||||||
|
/** How much a midfielder is worth both attacking and defending.
|
||||||
|
@see game_get_player_contribution() */
|
||||||
|
#define CONSTANT_GAME_PLAYER_WEIGHT_MIDFIELDER 0.625
|
||||||
|
|
||||||
|
/** Calculate attacking, defending and goalie values for the two teams
|
||||||
|
of a fixture.
|
||||||
|
@param fix The fixture we calculate.
|
||||||
|
@param team_value The place to store the values.
|
||||||
|
@param home_advantage The home advantage factor.
|
||||||
|
@see #GameTeamValue
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
game_get_values(const Fixture *fix, gfloat team_values[][GAME_TEAM_VALUE_END],
|
||||||
|
gfloat home_advantage)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
Team *tm[2] = {fix->teams[0], fix->teams[1]};
|
||||||
|
gfloat style_factor;
|
||||||
|
|
||||||
|
printf("\nhome %.2f\n", home_advantage);
|
||||||
|
for(i=0;i<2;i++)
|
||||||
|
{
|
||||||
|
for(j=0;j<GAME_TEAM_VALUE_END;j++)
|
||||||
|
team_values[i][j] = 0;
|
||||||
|
|
||||||
|
style_factor = (gfloat)tm[i]->style * CONSTANT_GAME_STYLE_FACTOR;
|
||||||
|
|
||||||
|
team_values[i][GAME_TEAM_VALUE_GOALIE] =
|
||||||
|
game_get_player_contribution(player_of(tm[i], 0), FALSE) *
|
||||||
|
(1 + home_advantage * (i == 0)) *
|
||||||
|
(1 + CONSTANT_PLAYER_BOOST_SKILL_EFFECT * (tm[i] == my_team && options[OPT_BOOL_BOOST] == 1));
|
||||||
|
|
||||||
|
for(j=1;j<11;j++)
|
||||||
|
{
|
||||||
|
team_values[i][GAME_TEAM_VALUE_ATTACK] +=
|
||||||
|
game_get_player_contribution(player_of(tm[i], j), TRUE);
|
||||||
|
team_values[i][GAME_TEAM_VALUE_DEFEND] +=
|
||||||
|
game_get_player_contribution(player_of(tm[i], j), FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
team_values[i][GAME_TEAM_VALUE_ATTACK] *=
|
||||||
|
((1 + style_factor) * (1 + home_advantage * (i == 0)) *
|
||||||
|
(1 + CONSTANT_PLAYER_BOOST_SKILL_EFFECT * (tm[i] == my_team && options[OPT_BOOL_BOOST] == 1)));
|
||||||
|
team_values[i][GAME_TEAM_VALUE_DEFEND] *=
|
||||||
|
((1 - style_factor) * (1 + home_advantage * (i == 0)) *
|
||||||
|
(1 + CONSTANT_PLAYER_BOOST_SKILL_EFFECT * (tm[i] == my_team && options[OPT_BOOL_BOOST] == 1)));
|
||||||
|
|
||||||
|
printf("%s %.1f %.1f\n", tm[i]->name->str, team_values[i][GAME_TEAM_VALUE_ATTACK],
|
||||||
|
team_values[i][GAME_TEAM_VALUE_DEFEND]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the contribution of a player to the attack, defend or
|
||||||
|
goalie value of his team.
|
||||||
|
@param pl The player.
|
||||||
|
@param attack Whether we have attack or defend value.
|
||||||
|
@return The player's contribution depending on position and
|
||||||
|
fitness. */
|
||||||
|
gfloat
|
||||||
|
game_get_player_contribution(const Player *pl, gboolean attack)
|
||||||
|
{
|
||||||
|
gfloat weights[4] =
|
||||||
|
{1,
|
||||||
|
(attack) ? CONSTANT_GAME_PLAYER_WEIGHT_DEFENDER_ATTACK : CONSTANT_GAME_PLAYER_WEIGHT_DEFENDER_DEFEND,
|
||||||
|
CONSTANT_GAME_PLAYER_WEIGHT_MIDFIELDER,
|
||||||
|
(attack) ? CONSTANT_GAME_PLAYER_WEIGHT_FORWARD_ATTACK : CONSTANT_GAME_PLAYER_WEIGHT_FORWARD_DEFEND};
|
||||||
|
|
||||||
|
return (gfloat)(pl->cskill * powf((gfloat)pl->fitness / 100, CONSTANT_GAME_PLAYER_FITNESS_EXPONENT) *
|
||||||
|
weights[pl->pos]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a random attacking or defending player
|
||||||
|
or the player that has to shoot the number_of_penalty'th penalty.
|
||||||
|
@param tm The team we examine.
|
||||||
|
@param player_type Whether we concentrate on attacking or defending players
|
||||||
|
or would like to have a penalty shooting player.
|
||||||
|
@param number_of_penalty Which penalty has to be taken (1st, 2nd etc.)
|
||||||
|
@param not_this_one A player to exclude.
|
||||||
|
@return A player index. */
|
||||||
|
gint
|
||||||
|
game_get_player(const Team *tm, gint player_type, gint number_of_penalty, gint not_this_one)
|
||||||
|
{
|
||||||
|
gint i, player = not_this_one;
|
||||||
|
gfloat weights[3];
|
||||||
|
gfloat probs[10];
|
||||||
|
gfloat rndom;
|
||||||
|
|
||||||
|
if(player_type == GAME_PLAYER_TYPE_ATTACKER)
|
||||||
|
{
|
||||||
|
weights[0] = 0.25;
|
||||||
|
weights[1] = 0.5;
|
||||||
|
weights[2] = 1;
|
||||||
|
}
|
||||||
|
else if(player_type == GAME_PLAYER_TYPE_ATTACKING)
|
||||||
|
{
|
||||||
|
weights[0] = 0.5;
|
||||||
|
weights[1] = 1;
|
||||||
|
weights[2] = 1;
|
||||||
|
}
|
||||||
|
else if(player_type == GAME_PLAYER_TYPE_DEFENDER)
|
||||||
|
{
|
||||||
|
weights[0] = 1;
|
||||||
|
weights[1] = 0.5;
|
||||||
|
weights[2] = 0.25;
|
||||||
|
}
|
||||||
|
else if(player_type == GAME_PLAYER_TYPE_INJURY)
|
||||||
|
weights[0] = -1;
|
||||||
|
else if(player_type == GAME_PLAYER_TYPE_PENALTY)
|
||||||
|
return 10;
|
||||||
|
|
||||||
|
game_get_player_probs(tm->players, probs, weights);
|
||||||
|
|
||||||
|
while(player == not_this_one)
|
||||||
|
{
|
||||||
|
rndom = math_rnd(0, probs[9]);
|
||||||
|
|
||||||
|
if(rndom < probs[0])
|
||||||
|
player = player_of(tm, 0)->id;
|
||||||
|
else
|
||||||
|
for(i=1;i<10;i++)
|
||||||
|
if(rndom < probs[i] && rndom > probs[i - 1])
|
||||||
|
player = player_of(tm, i + 1)->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
game_get_player_probs(GArray *players, gfloat *probs, gfloat *weights)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if(weights[0] == -1)
|
||||||
|
for(i=0;i<10;i++)
|
||||||
|
probs[i] = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
probs[0] = (gfloat)g_array_index(players, Player, 1).cskill *
|
||||||
|
powf((gfloat)g_array_index(players, Player, 1).fitness, CONSTANT_GAME_PLAYER_FITNESS_EXPONENT) *
|
||||||
|
weights[g_array_index(players, Player, 0).pos - 1];
|
||||||
|
for(i=1;i<10;i++)
|
||||||
|
probs[i] = probs[i - 1] + (gfloat)g_array_index(players, Player, i + 1).cskill *
|
||||||
|
powf((gfloat)g_array_index(players, Player, i + 1).fitness, CONSTANT_GAME_PLAYER_FITNESS_EXPONENT) *
|
||||||
|
weights[g_array_index(players, Player, i + 1).pos - 1];;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
50
src/game.h
50
src/game.h
@@ -0,0 +1,50 @@
|
|||||||
|
#ifndef GAME_H
|
||||||
|
#define GAME_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
|
#include "fixture_struct.h"
|
||||||
|
#include "player_struct.h"
|
||||||
|
|
||||||
|
/** Influence of the fitness on the player contribution.
|
||||||
|
The higher the worse. @see game_get_player_contribution() */
|
||||||
|
#define CONSTANT_GAME_PLAYER_FITNESS_EXPONENT 0.25
|
||||||
|
/* #define CONSTANT_GAME_HOME_ADVANTAGE_LOWER 0.04 */
|
||||||
|
/* #define CONSTANT_GAME_HOME_ADVANTAGE_UPPER 0.08 */
|
||||||
|
#define CONSTANT_GAME_HOME_ADVANTAGE_LOWER 0.0
|
||||||
|
#define CONSTANT_GAME_HOME_ADVANTAGE_UPPER 0.0
|
||||||
|
|
||||||
|
/** Indices for the team_value array.
|
||||||
|
@see game_get_values() */
|
||||||
|
enum GameTeamValue
|
||||||
|
{
|
||||||
|
GAME_TEAM_VALUE_ATTACK = 0,
|
||||||
|
GAME_TEAM_VALUE_DEFEND,
|
||||||
|
GAME_TEAM_VALUE_GOALIE,
|
||||||
|
GAME_TEAM_VALUE_END
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Player types. @see game_get_player() */
|
||||||
|
enum GamePlayerType
|
||||||
|
{
|
||||||
|
GAME_PLAYER_TYPE_ATTACKER = 0,
|
||||||
|
GAME_PLAYER_TYPE_ATTACKING,
|
||||||
|
GAME_PLAYER_TYPE_DEFENDER,
|
||||||
|
GAME_PLAYER_TYPE_PENALTY,
|
||||||
|
GAME_PLAYER_TYPE_INJURY,
|
||||||
|
GAME_PLAYER_TYPE_END
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
game_get_values(const Fixture *fix, gfloat team_values[][GAME_TEAM_VALUE_END],
|
||||||
|
gfloat home_advantage);
|
||||||
|
|
||||||
|
gfloat
|
||||||
|
game_get_player_contribution(const Player *pl, gboolean attack);
|
||||||
|
|
||||||
|
gint
|
||||||
|
game_get_player(const Team *tm, gint player_type, gint number_of_penalty, gint not_this_one);
|
||||||
|
|
||||||
|
void
|
||||||
|
game_get_player_probs(GArray *players, gfloat *probs, gfloat *weights);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -3,4 +3,13 @@
|
|||||||
|
|
||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
|
|
||||||
|
/** Possible values for the status variable. */
|
||||||
|
enum StatusValue
|
||||||
|
{
|
||||||
|
STATUS_NONE = 0,
|
||||||
|
STATUS_MAIN,
|
||||||
|
STATUS_BROWSE_TEAMS,
|
||||||
|
STATUS_END
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
1578
src/interface.c
1578
src/interface.c
File diff suppressed because it is too large
Load Diff
54
src/league.c
54
src/league.c
@@ -1,3 +1,5 @@
|
|||||||
|
#include "cup_struct.h"
|
||||||
|
#include "fixture_struct.h"
|
||||||
#include "league.h"
|
#include "league.h"
|
||||||
#include "team.h"
|
#include "team.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
@@ -27,8 +29,10 @@ league_new(void)
|
|||||||
|
|
||||||
new.teams = g_array_new(FALSE, FALSE, sizeof(Team));
|
new.teams = g_array_new(FALSE, FALSE, sizeof(Team));
|
||||||
|
|
||||||
|
new.fixtures = g_array_new(FALSE, FALSE, sizeof(Fixture));
|
||||||
|
|
||||||
new.table.name = g_string_new("");
|
new.table.name = g_string_new("");
|
||||||
new.table.league_id = new.id;
|
new.table.clid = new.id;
|
||||||
new.table.elements = g_array_new(FALSE, FALSE, sizeof(TableElement));
|
new.table.elements = g_array_new(FALSE, FALSE, sizeof(TableElement));
|
||||||
|
|
||||||
new.first_week = new.week_gap = 1;
|
new.first_week = new.week_gap = 1;
|
||||||
@@ -78,3 +82,51 @@ league_new_id(void)
|
|||||||
g_warning("league_new_id: didn't find a free numerical id.");
|
g_warning("league_new_id: didn't find a free numerical id.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return a nullified table element.
|
||||||
|
@see #TableElement */
|
||||||
|
TableElement
|
||||||
|
league_table_element_new(Team *team)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
TableElement new;
|
||||||
|
|
||||||
|
new.team = team;
|
||||||
|
|
||||||
|
for(i=0;i<TABLE_END;i++)
|
||||||
|
new.values[i] = 0;
|
||||||
|
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the array index of the given league or cup id.
|
||||||
|
@param clid The id of the league or cup.
|
||||||
|
@return The index in the leagues or cups array. */
|
||||||
|
gint
|
||||||
|
league_cup_get_index_from_clid(gint clid)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
gint index = -1;
|
||||||
|
|
||||||
|
if(clid < ID_CUP_START)
|
||||||
|
{
|
||||||
|
for(i=0;i<ligs->len;i++)
|
||||||
|
if(lig(i).id == clid)
|
||||||
|
{
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
for(i=0;i<cps->len;i++)
|
||||||
|
if(cp(i).id == clid)
|
||||||
|
{
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(index == -1)
|
||||||
|
g_warning("league_cup_get_index_from_clid: couldn't find league or cup with index %d\n", clid);
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
@@ -13,4 +13,10 @@ prom_rel_element_new(void);
|
|||||||
gint
|
gint
|
||||||
league_new_id(void);
|
league_new_id(void);
|
||||||
|
|
||||||
|
TableElement
|
||||||
|
league_table_element_new(Team *team);
|
||||||
|
|
||||||
|
gint
|
||||||
|
league_cup_get_index_from_clid(gint clid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#ifndef LEAGUE_STRUCT_H
|
#ifndef LEAGUE_STRUCT_H
|
||||||
#define LEAGUE_STRUCT_H
|
#define LEAGUE_STRUCT_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
#include "table_struct.h"
|
#include "table_struct.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,6 +68,8 @@ typedef struct
|
|||||||
/** League table.
|
/** League table.
|
||||||
@see Table */
|
@see Table */
|
||||||
Table table;
|
Table table;
|
||||||
|
/** The fixtures of a season for the league. */
|
||||||
|
GArray *fixtures;
|
||||||
} League;
|
} League;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
1168
src/live_game.c
Normal file
1168
src/live_game.c
Normal file
File diff suppressed because it is too large
Load Diff
82
src/live_game.h
Normal file
82
src/live_game.h
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
#ifndef LIVE_GAME_H
|
||||||
|
#define LIVE_GAME_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
|
#include "live_game_struct.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_calculate_fixture(Fixture *fix);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
query_live_game_event_is_break(gint minute, gint time);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
query_live_game_penalties_over(void);
|
||||||
|
|
||||||
|
gint
|
||||||
|
live_game_get_break(void);
|
||||||
|
|
||||||
|
gint
|
||||||
|
live_game_get_time(const LiveGameUnit *unit);
|
||||||
|
|
||||||
|
gint
|
||||||
|
live_game_get_minute(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_create_unit(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_fill_new_unit(LiveGameUnit *new);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_create_start_unit(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_evaluate_unit(LiveGameUnit *unit);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_event_foul(gboolean general);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_event_lost_possession(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_event_injury(gint player, gboolean create_new);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_event_stadium(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_event_scoring_chance(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_event_penalty();
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_event_general(gboolean create_new);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_event_free_kick(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_event_send_off(gint player);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_generate_commentary(LiveGameUnit *unit);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_event_duel(void);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
query_live_game_second_yellow(gint team, gint player);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_reset(Fixture *fix);
|
||||||
|
|
||||||
|
gint
|
||||||
|
live_game_unit_get_minute(const LiveGameUnit *unit);
|
||||||
|
|
||||||
|
void
|
||||||
|
live_game_create_stats(void);
|
||||||
|
|
||||||
|
#endif
|
164
src/live_game_struct.h
Normal file
164
src/live_game_struct.h
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
#ifndef LIVE_GAME_STRUCT_H
|
||||||
|
#define LIVE_GAME_STRUCT_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
|
#include "fixture.h"
|
||||||
|
#include "game.h"
|
||||||
|
|
||||||
|
/** Events happening during a live game.
|
||||||
|
@see #LiveGameEvent
|
||||||
|
@see #LiveGameUnit */
|
||||||
|
enum LiveGameEventType
|
||||||
|
{
|
||||||
|
/** This is the 'main' event, nothing in
|
||||||
|
particular is happening; one of the teams
|
||||||
|
is in possession of the ball. */
|
||||||
|
LIVE_GAME_EVENT_GENERAL = 0,
|
||||||
|
LIVE_GAME_EVENT_START_MATCH,
|
||||||
|
LIVE_GAME_EVENT_HALF_TIME,
|
||||||
|
LIVE_GAME_EVENT_EXTRA_TIME,
|
||||||
|
LIVE_GAME_EVENT_END_MATCH,
|
||||||
|
LIVE_GAME_EVENT_LOST_POSSESSION,
|
||||||
|
LIVE_GAME_EVENT_SCORING_CHANCE,
|
||||||
|
LIVE_GAME_EVENT_PENALTY,
|
||||||
|
LIVE_GAME_EVENT_FREE_KICK,
|
||||||
|
LIVE_GAME_EVENT_GOAL,
|
||||||
|
LIVE_GAME_EVENT_OWN_GOAL,
|
||||||
|
LIVE_GAME_EVENT_POST,
|
||||||
|
LIVE_GAME_EVENT_MISSED,
|
||||||
|
LIVE_GAME_EVENT_SAVE,
|
||||||
|
LIVE_GAME_EVENT_CROSS_BAR,
|
||||||
|
LIVE_GAME_EVENT_FOUL,
|
||||||
|
LIVE_GAME_EVENT_FOUL_YELLOW,
|
||||||
|
LIVE_GAME_EVENT_FOUL_RED,
|
||||||
|
LIVE_GAME_EVENT_FOUL_RED_INJURY,
|
||||||
|
LIVE_GAME_EVENT_SEND_OFF,
|
||||||
|
LIVE_GAME_EVENT_INJURY,
|
||||||
|
/** An injury that permits the player to
|
||||||
|
continue after some brief time. */
|
||||||
|
LIVE_GAME_EVENT_TEMP_INJURY,
|
||||||
|
LIVE_GAME_EVENT_PENALTIES,
|
||||||
|
LIVE_GAME_EVENT_STADIUM,
|
||||||
|
LIVE_GAME_EVENT_STADIUM_BREAKDOWN,
|
||||||
|
LIVE_GAME_EVENT_STADIUM_FIRE,
|
||||||
|
LIVE_GAME_EVENT_STADIUM_RIOTS,
|
||||||
|
LIVE_GAME_EVENT_SUBSTITUTION,
|
||||||
|
LIVE_GAME_EVENT_STRUCTURE_CHANGE,
|
||||||
|
LIVE_GAME_EVENT_STYLE_CHANGE,
|
||||||
|
/* LIVE_GAME_EVENT_, */
|
||||||
|
/* LIVE_GAME_EVENT_, */
|
||||||
|
LIVE_GAME_EVENT_END
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Indices for the int_values in the
|
||||||
|
#LiveGameEvent struct. */
|
||||||
|
enum LiveGameEventValue1
|
||||||
|
{
|
||||||
|
LIVE_GAME_EVENT_VALUE_TEAM = 0,
|
||||||
|
LIVE_GAME_EVENT_VALUE_PLAYER,
|
||||||
|
LIVE_GAME_EVENT_VALUE_PLAYER2,
|
||||||
|
LIVE_GAME_EVENT_VALUE_CHANCE_CONVERTED,
|
||||||
|
LIVE_GAME_EVENT_VALUE1_END
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Indices for the int_values in
|
||||||
|
#LiveGameEvent struct. */
|
||||||
|
enum LiveGameEventValue2
|
||||||
|
{
|
||||||
|
LIVE_GAME_EVENT_VALUE_NEW_STRUCTURE = LIVE_GAME_EVENT_VALUE_TEAM + 1,
|
||||||
|
LIVE_GAME_EVENT_VALUE_OLD_STRUCTURE,
|
||||||
|
LIVE_GAME_EVENT_VALUE_NEW_STYLE = LIVE_GAME_EVENT_VALUE_NEW_STRUCTURE,
|
||||||
|
LIVE_GAME_EVENT_VALUE_OLD_STYLE,
|
||||||
|
LIVE_GAME_EVENT_VALUE2_END
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Indices for the time variable of th
|
||||||
|
#LiveGameUnit struct. */
|
||||||
|
enum LiveGameUnitTime
|
||||||
|
{
|
||||||
|
LIVE_GAME_UNIT_TIME_FIRST_HALF = 0,
|
||||||
|
LIVE_GAME_UNIT_TIME_SECOND_HALF,
|
||||||
|
LIVE_GAME_UNIT_TIME_EXTRA_TIME,
|
||||||
|
LIVE_GAME_UNIT_TIME_PENALTIES,
|
||||||
|
LIVE_GAME_UNIT_TIME_END
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Indices for the values in #LiveGameStats. */
|
||||||
|
enum LiveGameStatValue
|
||||||
|
{
|
||||||
|
LIVE_GAME_STAT_VALUE_GOALS = 0,
|
||||||
|
LIVE_GAME_STAT_VALUE_SHOTS,
|
||||||
|
LIVE_GAME_STAT_VALUE_POSSESSION,
|
||||||
|
LIVE_GAME_STAT_VALUE_PENALTIES,
|
||||||
|
LIVE_GAME_STAT_VALUE_FOULS,
|
||||||
|
LIVE_GAME_STAT_VALUE_CARDS,
|
||||||
|
LIVE_GAME_STAT_VALUE_REDS,
|
||||||
|
LIVE_GAME_STAT_VALUE_INJURIES,
|
||||||
|
LIVE_GAME_STAT_VALUE_END
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Some stats for a live game like ball possession,
|
||||||
|
shots on goal etc. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gfloat possession;
|
||||||
|
gint values[2][LIVE_GAME_STAT_VALUE_END];
|
||||||
|
|
||||||
|
} LiveGameStats;
|
||||||
|
|
||||||
|
/** A struct telling us what's happening at
|
||||||
|
a certain moment in a game. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/** @see #LiveGameEventType */
|
||||||
|
gint type;
|
||||||
|
/** @see #LiveGameEventValue1
|
||||||
|
@see #LiveGameEventValue2 */
|
||||||
|
gint values[MAX(LIVE_GAME_EVENT_VALUE1_END, LIVE_GAME_EVENT_VALUE2_END)];
|
||||||
|
/** The commentary for the event. */
|
||||||
|
GString *commentary;
|
||||||
|
|
||||||
|
} LiveGameEvent;
|
||||||
|
|
||||||
|
/** A struct representing a fraction of a live game. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/** Tells us which of the teams is in possession
|
||||||
|
of the ball and how long already. This is used
|
||||||
|
to calculate the probability of a scoring chance. */
|
||||||
|
gint possession, possession_time;
|
||||||
|
/** Which minute of the game and which part of
|
||||||
|
the game. If 'minute' is -1 we have an event
|
||||||
|
like a substitution that doesn't count as a
|
||||||
|
match time consuming event. @see #GameUnitTime */
|
||||||
|
gint minute, time;
|
||||||
|
|
||||||
|
/** The event belonging to the game unit. */
|
||||||
|
LiveGameEvent event;
|
||||||
|
|
||||||
|
} LiveGameUnit;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/** The fixture that belongs to the game. */
|
||||||
|
Fixture *fix;
|
||||||
|
/** Substitutions left for the teams. */
|
||||||
|
gint subs_left[2];
|
||||||
|
/** The team that started the game, 0 or 1. */
|
||||||
|
gint started_game;
|
||||||
|
/** We keep track of the stadium events because
|
||||||
|
there shouldn't be more than one of them in a game. */
|
||||||
|
gboolean stadium_event;
|
||||||
|
/** Attacking, defending etc. values for both teams.
|
||||||
|
@see #GameTeamValue */
|
||||||
|
gfloat team_values[2][GAME_TEAM_VALUE_END];
|
||||||
|
/** The home advantage factor. */
|
||||||
|
gfloat home_advantage;
|
||||||
|
/** The array of units. @see #GameUnit */
|
||||||
|
GArray *units;
|
||||||
|
LiveGameStats stats;
|
||||||
|
GtkWidget *window;
|
||||||
|
|
||||||
|
} LiveGame;
|
||||||
|
|
||||||
|
#endif
|
22
src/main.c
22
src/main.c
@@ -12,7 +12,6 @@
|
|||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize some global variables. Most of them get nullified.
|
Initialize some global variables. Most of them get nullified.
|
||||||
*/
|
*/
|
||||||
@@ -21,11 +20,19 @@ main_init_variables(void)
|
|||||||
{
|
{
|
||||||
ligs = cps = NULL;
|
ligs = cps = NULL;
|
||||||
country.name = country.symbol = country.sid = NULL;
|
country.name = country.symbol = country.sid = NULL;
|
||||||
fixtures = NULL;
|
|
||||||
transfer_list = NULL;
|
transfer_list = NULL;
|
||||||
player_names = NULL;
|
player_names = NULL;
|
||||||
|
my_team = NULL;
|
||||||
|
|
||||||
font_name = g_string_new("0");
|
font_name = g_string_new("0");
|
||||||
|
debug = FALSE;
|
||||||
|
|
||||||
|
live_game.units = g_array_new(FALSE, FALSE, sizeof(LiveGameUnit));
|
||||||
|
live_game.window = NULL;
|
||||||
|
live_game_temp.units = g_array_new(FALSE, FALSE, sizeof(LiveGameUnit));
|
||||||
|
live_game_temp.window = NULL;
|
||||||
|
|
||||||
|
popups_active = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,21 +86,26 @@ main (gint argc, gchar *argv[])
|
|||||||
|
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
|
|
||||||
main_exit_program(EXIT_OK);
|
main_exit_program(EXIT_OK, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Exit the program with the given exit code. Try to
|
/** Exit the program with the given exit code and message. Try to
|
||||||
destroy all widgets and free all memory first.
|
destroy all widgets and free all memory first.
|
||||||
@param exit_code The number we return to the shell.
|
@param exit_code The number we return to the shell.
|
||||||
|
@param exit_message The message we print.
|
||||||
@return The exit code of the program. */
|
@return The exit code of the program. */
|
||||||
void
|
void
|
||||||
main_exit_program(gint exit_code)
|
main_exit_program(gint exit_code, gchar *exit_message)
|
||||||
{
|
{
|
||||||
if(gtk_main_level() > 0)
|
if(gtk_main_level() > 0)
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
|
|
||||||
free_memory();
|
free_memory();
|
||||||
|
|
||||||
|
if(exit_message != NULL)
|
||||||
|
g_warning(exit_message);
|
||||||
|
|
||||||
exit(exit_code);
|
exit(exit_code);
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,6 @@ void
|
|||||||
main_init_variables(void);
|
main_init_variables(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
main_exit_program(gint exit_code);
|
main_exit_program(gint exit_code, gchar *exit_message);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
29
src/maths.c
29
src/maths.c
@@ -150,3 +150,32 @@ math_generate_permutation(gint *array, gint start, gint end)
|
|||||||
for(i=0;i<end - start;i++)
|
for(i=0;i<end - start;i++)
|
||||||
misc_swap_int(&array[i], &array[math_rndi(i, end - start)]);
|
misc_swap_int(&array[i], &array[math_rndi(i, end - start)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** This function tells us how many teams from 'number' teams
|
||||||
|
have to be left away to obtain a power of 2. */
|
||||||
|
gint
|
||||||
|
math_get_bye_len(gint number)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
for(i=10;i>=0;i--)
|
||||||
|
if((gint)powf(2, i) <= number)
|
||||||
|
break;
|
||||||
|
|
||||||
|
return number - (gint)powf(2, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the sum of the integers in the array.
|
||||||
|
@param array The integer array.
|
||||||
|
@param max The size of the array.
|
||||||
|
@return The sum of all the integers in the array. */
|
||||||
|
gint
|
||||||
|
math_sum_int_array(gint *array, gint max)
|
||||||
|
{
|
||||||
|
gint i, sum = 0;
|
||||||
|
|
||||||
|
for(i=0;i<max;i++)
|
||||||
|
sum += array[i];
|
||||||
|
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
@@ -27,4 +27,10 @@ math_round_integer(gint number, gint places);
|
|||||||
void
|
void
|
||||||
math_generate_permutation(gint *array, gint start, gint end);
|
math_generate_permutation(gint *array, gint start, gint end);
|
||||||
|
|
||||||
|
gint
|
||||||
|
math_get_bye_len(gint number);
|
||||||
|
|
||||||
|
gint
|
||||||
|
math_sum_int_array(gint *array, gint max);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
93
src/misc.c
93
src/misc.c
@@ -1,5 +1,6 @@
|
|||||||
#include "free.h"
|
#include "free.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "maths.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,22 +11,23 @@
|
|||||||
@param abort_program Whether or not we continue or exit the program.
|
@param abort_program Whether or not we continue or exit the program.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
misc_print_error(GError *error, gboolean abort_program)
|
misc_print_error(GError **error, gboolean abort_program)
|
||||||
{
|
{
|
||||||
gchar buf[SMALL];
|
gchar buf[SMALL];
|
||||||
|
|
||||||
if(error == NULL)
|
if(*error == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sprintf(buf, "%s", error->message);
|
sprintf(buf, "%s", (*error)->message);
|
||||||
|
|
||||||
g_warning("error message: %s\n", buf);
|
g_warning("error message: %s\n", buf);
|
||||||
/*d*/
|
/*d*/
|
||||||
/* show_popup_window(buf); */
|
/* show_popup_window(buf); */
|
||||||
g_error_free(error);
|
g_error_free(*error);
|
||||||
|
*error = NULL;
|
||||||
|
|
||||||
if(abort_program)
|
if(abort_program)
|
||||||
main_exit_program(EXIT_PRINT_ERROR);
|
main_exit_program(EXIT_PRINT_ERROR, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Swap two integers.
|
/** Swap two integers.
|
||||||
@@ -40,6 +42,18 @@ misc_swap_int(gint *first, gint *second)
|
|||||||
*second = swap;
|
*second = swap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Swap two pointers.
|
||||||
|
@param first The first pointer.
|
||||||
|
@param second The second pointer. */
|
||||||
|
void
|
||||||
|
misc_swap_gpointer(gpointer *first, gpointer *second)
|
||||||
|
{
|
||||||
|
gpointer swap = *first;
|
||||||
|
|
||||||
|
*first = *second;
|
||||||
|
*second = swap;
|
||||||
|
}
|
||||||
|
|
||||||
/** Transform a string containing white spaces into an array of strings without
|
/** Transform a string containing white spaces into an array of strings without
|
||||||
white spaces.
|
white spaces.
|
||||||
@param string The string containing white spaces.
|
@param string The string containing white spaces.
|
||||||
@@ -83,3 +97,72 @@ misc_separate_strings(gchar *string)
|
|||||||
|
|
||||||
return string_array;
|
return string_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Write a pointer array randomly into another one and free
|
||||||
|
the original one.
|
||||||
|
@param array The array to randomise.
|
||||||
|
@return A new pointer array containing the items in random order. */
|
||||||
|
GPtrArray*
|
||||||
|
misc_randomise_g_pointer_array(GPtrArray *array)
|
||||||
|
{
|
||||||
|
GPtrArray *new = g_ptr_array_new();
|
||||||
|
gint order[array->len];
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
math_generate_permutation(order, 0, array->len - 1);
|
||||||
|
|
||||||
|
for(i=0;i<array->len;i++)
|
||||||
|
g_ptr_array_add(new, g_ptr_array_index(array, order[i]));
|
||||||
|
|
||||||
|
g_ptr_array_free(array, TRUE);
|
||||||
|
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Print a thousands-grouped output of 'number' into 'buf',
|
||||||
|
like 2 234 345 instead of 2234345.
|
||||||
|
@param number The number to print.
|
||||||
|
@buf The buffer to hold the number.
|
||||||
|
@append Whether to overwrite the buffer or append. */
|
||||||
|
void
|
||||||
|
misc_print_grouped_int(gint number, gchar *buf, gboolean append)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
gchar buf2[SMALL];
|
||||||
|
gint length = 0;
|
||||||
|
gfloat copy = (gfloat)(abs(number));
|
||||||
|
gint number2 = abs(number);
|
||||||
|
|
||||||
|
if(!append)
|
||||||
|
strcpy(buf, "");
|
||||||
|
|
||||||
|
while(copy >= 1)
|
||||||
|
{
|
||||||
|
copy /= 10;
|
||||||
|
length++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(length > 9)
|
||||||
|
{
|
||||||
|
sprintf(buf2, "%d", number);
|
||||||
|
strcat(buf, buf2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = length; i > 0; i--)
|
||||||
|
{
|
||||||
|
sprintf(buf2, "%d", math_get_place(number2, i));
|
||||||
|
strcat(buf, buf2);
|
||||||
|
if(i % 3 == 1)
|
||||||
|
strcat(buf, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(number < 0)
|
||||||
|
{
|
||||||
|
sprintf(buf2, "- ");
|
||||||
|
strcat(buf2, buf);
|
||||||
|
sprintf(buf, "%s", buf2);
|
||||||
|
}
|
||||||
|
else if(number == 0)
|
||||||
|
strcat(buf, "0");
|
||||||
|
}
|
||||||
|
11
src/misc.h
11
src/misc.h
@@ -4,12 +4,21 @@
|
|||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
misc_print_error(GError *error, gboolean abort_program);
|
misc_print_error(GError **error, gboolean abort_program);
|
||||||
|
|
||||||
void
|
void
|
||||||
misc_swap_int(gint *first, gint *second);
|
misc_swap_int(gint *first, gint *second);
|
||||||
|
|
||||||
|
void
|
||||||
|
misc_swap_gpointer(gpointer *first, gpointer *second);
|
||||||
|
|
||||||
GPtrArray*
|
GPtrArray*
|
||||||
misc_separate_strings(gchar *string);
|
misc_separate_strings(gchar *string);
|
||||||
|
|
||||||
|
GPtrArray*
|
||||||
|
misc_randomise_g_pointer_array(GPtrArray *array);
|
||||||
|
|
||||||
|
void
|
||||||
|
misc_print_grouped_int(gint number, gchar *buf, gboolean append);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
#include "misc_callback_func.h"
|
#include "misc_callback_func.h"
|
||||||
#include "start_end.h"
|
#include "start_end.h"
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
#include "team.h"
|
||||||
#include "treeview.h"
|
#include "treeview.h"
|
||||||
|
#include "user.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
|
#include "window.h"
|
||||||
#include "xml_country.h"
|
#include "xml_country.h"
|
||||||
|
|
||||||
|
|
||||||
/* show the teams from the leagues in the country in
|
/* show the teams from the leagues in the country in
|
||||||
the startup window */
|
the startup window */
|
||||||
void
|
void
|
||||||
@@ -56,9 +58,17 @@ misc_callback_start_game(GtkWidget *widget)
|
|||||||
{
|
{
|
||||||
GtkTreeView *treeview =
|
GtkTreeView *treeview =
|
||||||
GTK_TREE_VIEW(lookup_widget(widget, "treeview_startup"));
|
GTK_TREE_VIEW(lookup_widget(widget, "treeview_startup"));
|
||||||
|
GtkWidget *window_startup =
|
||||||
|
lookup_widget(widget, "window_startup");
|
||||||
|
|
||||||
my_team_clid = treeview_get_index(treeview, 0);
|
my_team = treeview_get_pointer(treeview, 2);
|
||||||
my_team_id = treeview_get_index(treeview, 1);
|
|
||||||
|
|
||||||
start_new_game();
|
start_new_game();
|
||||||
|
|
||||||
|
user_set_up_my_team_new_game(widget);
|
||||||
|
|
||||||
|
window_destroy(&window_startup);
|
||||||
|
|
||||||
|
window_show_main();
|
||||||
|
|
||||||
|
treeview_show_user_player_list(1);
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,8 @@
|
|||||||
#include "free.h"
|
#include "free.h"
|
||||||
#include "misc_callback_func.h"
|
#include "misc_callback_func.h"
|
||||||
#include "misc_callbacks.h"
|
#include "misc_callbacks.h"
|
||||||
|
#include "variables.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
on_team_selection_cancel_clicked (GtkButton *button,
|
on_team_selection_cancel_clicked (GtkButton *button,
|
||||||
@@ -190,7 +192,7 @@ void
|
|||||||
on_button_live_close_clicked (GtkButton *button,
|
on_button_live_close_clicked (GtkButton *button,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
window_destroy(&live_game.window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -215,3 +217,18 @@ on_combo_country_entry_changed (GtkEditable *editable,
|
|||||||
|
|
||||||
misc_callback_show_team_list(GTK_WIDGET(editable), entry_text);
|
misc_callback_show_team_list(GTK_WIDGET(editable), entry_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
on_button_pause_clicked (GtkButton *button,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
on_button_resume_clicked (GtkButton *button,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
|
#ifndef MISC_CALLBACS_H
|
||||||
|
#define MISC_CALLBACS_H
|
||||||
|
|
||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
#include "misc_interface.h"
|
#include "misc_interface.h"
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
@@ -103,3 +106,13 @@ on_button_help_close_clicked (GtkButton *button,
|
|||||||
void
|
void
|
||||||
on_combo_country_entry_changed (GtkEditable *editable,
|
on_combo_country_entry_changed (GtkEditable *editable,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_button_pause_clicked (GtkButton *button,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_button_resume_clicked (GtkButton *button,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -41,11 +41,6 @@ create_window_startup (void)
|
|||||||
GSList *team_selection_radio1_group = NULL;
|
GSList *team_selection_radio1_group = NULL;
|
||||||
GtkWidget *team_selection_radio2;
|
GtkWidget *team_selection_radio2;
|
||||||
GtkWidget *team_selection_radio3;
|
GtkWidget *team_selection_radio3;
|
||||||
GtkWidget *eventbox2;
|
|
||||||
GtkWidget *hbox50;
|
|
||||||
GtkWidget *radiobutton_cl;
|
|
||||||
GtkWidget *radiobutton_cwc;
|
|
||||||
GtkWidget *radiobutton_uefa;
|
|
||||||
GtkWidget *hseparator11;
|
GtkWidget *hseparator11;
|
||||||
GtkWidget *vbox34;
|
GtkWidget *vbox34;
|
||||||
GtkWidget *label69;
|
GtkWidget *label69;
|
||||||
@@ -158,38 +153,6 @@ create_window_startup (void)
|
|||||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (team_selection_radio3), team_selection_radio1_group);
|
gtk_radio_button_set_group (GTK_RADIO_BUTTON (team_selection_radio3), team_selection_radio1_group);
|
||||||
team_selection_radio1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (team_selection_radio3));
|
team_selection_radio1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (team_selection_radio3));
|
||||||
|
|
||||||
eventbox2 = gtk_event_box_new ();
|
|
||||||
gtk_widget_show (eventbox2);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox2), eventbox2, FALSE, FALSE, 0);
|
|
||||||
|
|
||||||
hbox50 = gtk_hbox_new (FALSE, 0);
|
|
||||||
gtk_widget_show (hbox50);
|
|
||||||
gtk_container_add (GTK_CONTAINER (eventbox2), hbox50);
|
|
||||||
|
|
||||||
radiobutton_cl = gtk_radio_button_new_with_mnemonic (NULL, _("CL"));
|
|
||||||
gtk_widget_show (radiobutton_cl);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox50), radiobutton_cl, FALSE, FALSE, 0);
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (radiobutton_cl), 3);
|
|
||||||
gtk_tooltips_set_tip (tooltips, radiobutton_cl, _("Play only in Champions' League / Copa Libertadores"), NULL);
|
|
||||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_cl), team_selection_radio1_group);
|
|
||||||
team_selection_radio1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_cl));
|
|
||||||
|
|
||||||
radiobutton_cwc = gtk_radio_button_new_with_mnemonic (NULL, _("CWC / Conm."));
|
|
||||||
gtk_widget_show (radiobutton_cwc);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox50), radiobutton_cwc, FALSE, FALSE, 0);
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (radiobutton_cwc), 3);
|
|
||||||
gtk_tooltips_set_tip (tooltips, radiobutton_cwc, _("Play only in Cup Winners' Cup / Copa Conmebol"), NULL);
|
|
||||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_cwc), team_selection_radio1_group);
|
|
||||||
team_selection_radio1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_cwc));
|
|
||||||
|
|
||||||
radiobutton_uefa = gtk_radio_button_new_with_mnemonic (NULL, _("UEFA / Sul-Americana"));
|
|
||||||
gtk_widget_show (radiobutton_uefa);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox50), radiobutton_uefa, FALSE, FALSE, 0);
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (radiobutton_uefa), 3);
|
|
||||||
gtk_tooltips_set_tip (tooltips, radiobutton_uefa, _("Play only in UEFA Cup / Copa Sul-Americana"), NULL);
|
|
||||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_uefa), team_selection_radio1_group);
|
|
||||||
team_selection_radio1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_uefa));
|
|
||||||
|
|
||||||
hseparator11 = gtk_hseparator_new ();
|
hseparator11 = gtk_hseparator_new ();
|
||||||
gtk_widget_show (hseparator11);
|
gtk_widget_show (hseparator11);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox2), hseparator11, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox2), hseparator11, FALSE, FALSE, 0);
|
||||||
@@ -431,11 +394,6 @@ create_window_startup (void)
|
|||||||
GLADE_HOOKUP_OBJECT (window_startup, team_selection_radio1, "team_selection_radio1");
|
GLADE_HOOKUP_OBJECT (window_startup, team_selection_radio1, "team_selection_radio1");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, team_selection_radio2, "team_selection_radio2");
|
GLADE_HOOKUP_OBJECT (window_startup, team_selection_radio2, "team_selection_radio2");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, team_selection_radio3, "team_selection_radio3");
|
GLADE_HOOKUP_OBJECT (window_startup, team_selection_radio3, "team_selection_radio3");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, eventbox2, "eventbox2");
|
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, hbox50, "hbox50");
|
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, radiobutton_cl, "radiobutton_cl");
|
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, radiobutton_cwc, "radiobutton_cwc");
|
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, radiobutton_uefa, "radiobutton_uefa");
|
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, hseparator11, "hseparator11");
|
GLADE_HOOKUP_OBJECT (window_startup, hseparator11, "hseparator11");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, vbox34, "vbox34");
|
GLADE_HOOKUP_OBJECT (window_startup, vbox34, "vbox34");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, label69, "label69");
|
GLADE_HOOKUP_OBJECT (window_startup, label69, "label69");
|
||||||
@@ -478,6 +436,7 @@ create_window_startup (void)
|
|||||||
GLADE_HOOKUP_OBJECT (window_startup, label5, "label5");
|
GLADE_HOOKUP_OBJECT (window_startup, label5, "label5");
|
||||||
GLADE_HOOKUP_OBJECT_NO_REF (window_startup, tooltips, "tooltips");
|
GLADE_HOOKUP_OBJECT_NO_REF (window_startup, tooltips, "tooltips");
|
||||||
|
|
||||||
|
gtk_widget_grab_focus (treeview_startup);
|
||||||
gtk_window_add_accel_group (GTK_WINDOW (window_startup), accel_group);
|
gtk_window_add_accel_group (GTK_WINDOW (window_startup), accel_group);
|
||||||
|
|
||||||
return window_startup;
|
return window_startup;
|
||||||
@@ -852,114 +811,176 @@ create_font_sel_window (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
create_live_window (void)
|
create_window_live (void)
|
||||||
{
|
{
|
||||||
GtkWidget *live_window;
|
GtkWidget *window_live;
|
||||||
GtkWidget *vbox23;
|
GtkWidget *vbox36;
|
||||||
GtkWidget *hscale_tendency;
|
|
||||||
GtkWidget *scrolledwindow_live;
|
|
||||||
GtkWidget *treeview_live;
|
|
||||||
GtkWidget *progressbar_live;
|
GtkWidget *progressbar_live;
|
||||||
GtkWidget *hruler_live;
|
GtkWidget *hruler_live;
|
||||||
GtkWidget *vbox26;
|
GtkWidget *hbox50;
|
||||||
GtkWidget *check_live_window_show_live;
|
GtkWidget *vbox38;
|
||||||
GtkWidget *check_live_window_tendency;
|
GtkWidget *scrolledwindow8;
|
||||||
|
GtkWidget *treeview_result;
|
||||||
|
GtkWidget *scrolledwindow9;
|
||||||
|
GtkWidget *treeview_commentary;
|
||||||
|
GtkWidget *hbox48;
|
||||||
|
GtkWidget *button_pause;
|
||||||
|
GtkWidget *alignment16;
|
||||||
|
GtkWidget *hbox51;
|
||||||
|
GtkWidget *image56;
|
||||||
|
GtkWidget *label72;
|
||||||
|
GtkWidget *button_resume;
|
||||||
|
GtkWidget *alignment17;
|
||||||
|
GtkWidget *hbox52;
|
||||||
|
GtkWidget *image57;
|
||||||
|
GtkWidget *label73;
|
||||||
GtkWidget *button_live_close;
|
GtkWidget *button_live_close;
|
||||||
GtkAccelGroup *accel_group;
|
GtkAccelGroup *accel_group;
|
||||||
GtkTooltips *tooltips;
|
|
||||||
|
|
||||||
tooltips = gtk_tooltips_new ();
|
|
||||||
|
|
||||||
accel_group = gtk_accel_group_new ();
|
accel_group = gtk_accel_group_new ();
|
||||||
|
|
||||||
live_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
window_live = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (live_window), 6);
|
gtk_container_set_border_width (GTK_CONTAINER (window_live), 6);
|
||||||
gtk_window_set_title (GTK_WINDOW (live_window), _("Live game"));
|
gtk_window_set_title (GTK_WINDOW (window_live), _("Live game"));
|
||||||
gtk_window_set_position (GTK_WINDOW (live_window), GTK_WIN_POS_CENTER);
|
gtk_window_set_position (GTK_WINDOW (window_live), GTK_WIN_POS_CENTER);
|
||||||
gtk_window_set_default_size (GTK_WINDOW (live_window), 450, 550);
|
gtk_window_set_default_size (GTK_WINDOW (window_live), 450, 550);
|
||||||
|
|
||||||
vbox23 = gtk_vbox_new (FALSE, 0);
|
vbox36 = gtk_vbox_new (FALSE, 0);
|
||||||
gtk_widget_show (vbox23);
|
gtk_widget_show (vbox36);
|
||||||
gtk_container_add (GTK_CONTAINER (live_window), vbox23);
|
gtk_container_add (GTK_CONTAINER (window_live), vbox36);
|
||||||
|
|
||||||
hscale_tendency = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0.5, 0, 1, 0, 0, 0)));
|
|
||||||
gtk_widget_show (hscale_tendency);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox23), hscale_tendency, FALSE, FALSE, 0);
|
|
||||||
gtk_scale_set_draw_value (GTK_SCALE (hscale_tendency), FALSE);
|
|
||||||
|
|
||||||
scrolledwindow_live = gtk_scrolled_window_new (NULL, NULL);
|
|
||||||
gtk_widget_show (scrolledwindow_live);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox23), scrolledwindow_live, TRUE, TRUE, 0);
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow_live), 2);
|
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_live), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
||||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow_live), GTK_SHADOW_IN);
|
|
||||||
|
|
||||||
treeview_live = gtk_tree_view_new ();
|
|
||||||
gtk_widget_show (treeview_live);
|
|
||||||
gtk_container_add (GTK_CONTAINER (scrolledwindow_live), treeview_live);
|
|
||||||
|
|
||||||
progressbar_live = gtk_progress_bar_new ();
|
progressbar_live = gtk_progress_bar_new ();
|
||||||
gtk_widget_show (progressbar_live);
|
gtk_widget_show (progressbar_live);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox23), progressbar_live, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox36), progressbar_live, FALSE, FALSE, 0);
|
||||||
|
|
||||||
hruler_live = gtk_hruler_new ();
|
hruler_live = gtk_hruler_new ();
|
||||||
gtk_widget_show (hruler_live);
|
gtk_widget_show (hruler_live);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox23), hruler_live, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox36), hruler_live, FALSE, TRUE, 0);
|
||||||
gtk_widget_set_sensitive (hruler_live, FALSE);
|
gtk_widget_set_sensitive (hruler_live, FALSE);
|
||||||
gtk_ruler_set_range (GTK_RULER (hruler_live), 0, 120, 55.0685, 0);
|
gtk_ruler_set_range (GTK_RULER (hruler_live), 0, 120, 77.2603, 120);
|
||||||
|
|
||||||
vbox26 = gtk_vbox_new (FALSE, 0);
|
hbox50 = gtk_hbox_new (FALSE, 3);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox23), vbox26, FALSE, FALSE, 0);
|
gtk_widget_show (hbox50);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (vbox26), 4);
|
gtk_box_pack_start (GTK_BOX (vbox36), hbox50, TRUE, TRUE, 0);
|
||||||
|
|
||||||
check_live_window_show_live = gtk_check_button_new_with_mnemonic (_("Show live games"));
|
vbox38 = gtk_vbox_new (FALSE, 3);
|
||||||
gtk_widget_show (check_live_window_show_live);
|
gtk_widget_show (vbox38);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox26), check_live_window_show_live, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox50), vbox38, TRUE, TRUE, 0);
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_live_window_show_live), TRUE);
|
|
||||||
|
|
||||||
check_live_window_tendency = gtk_check_button_new_with_mnemonic (_("Show tendency bar"));
|
scrolledwindow8 = gtk_scrolled_window_new (NULL, NULL);
|
||||||
gtk_widget_show (check_live_window_tendency);
|
gtk_widget_show (scrolledwindow8);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox26), check_live_window_tendency, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox38), scrolledwindow8, FALSE, TRUE, 0);
|
||||||
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow8), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow8), GTK_SHADOW_ETCHED_IN);
|
||||||
|
|
||||||
button_live_close = gtk_button_new_from_stock ("gtk-close");
|
treeview_result = gtk_tree_view_new ();
|
||||||
gtk_widget_show (button_live_close);
|
gtk_widget_show (treeview_result);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox26), button_live_close, FALSE, FALSE, 0);
|
gtk_container_add (GTK_CONTAINER (scrolledwindow8), treeview_result);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (button_live_close), 2);
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview_result), FALSE);
|
||||||
gtk_tooltips_set_tip (tooltips, button_live_close, _("Esc"), NULL);
|
|
||||||
gtk_widget_add_accelerator (button_live_close, "clicked", accel_group,
|
scrolledwindow9 = gtk_scrolled_window_new (NULL, NULL);
|
||||||
GDK_Escape, 0,
|
gtk_widget_show (scrolledwindow9);
|
||||||
GTK_ACCEL_VISIBLE);
|
gtk_box_pack_start (GTK_BOX (vbox38), scrolledwindow9, TRUE, TRUE, 0);
|
||||||
gtk_widget_add_accelerator (button_live_close, "clicked", accel_group,
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow9), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
GDK_Return, 0,
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow9), GTK_SHADOW_ETCHED_IN);
|
||||||
GTK_ACCEL_VISIBLE);
|
|
||||||
gtk_widget_add_accelerator (button_live_close, "clicked", accel_group,
|
treeview_commentary = gtk_tree_view_new ();
|
||||||
|
gtk_widget_show (treeview_commentary);
|
||||||
|
gtk_container_add (GTK_CONTAINER (scrolledwindow9), treeview_commentary);
|
||||||
|
|
||||||
|
hbox48 = gtk_hbox_new (FALSE, 4);
|
||||||
|
gtk_widget_show (hbox48);
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox36), hbox48, FALSE, TRUE, 5);
|
||||||
|
|
||||||
|
button_pause = gtk_button_new ();
|
||||||
|
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_space, 0,
|
||||||
GTK_ACCEL_VISIBLE);
|
GTK_ACCEL_VISIBLE);
|
||||||
|
|
||||||
g_signal_connect ((gpointer) live_window, "delete_event",
|
alignment16 = gtk_alignment_new (0.5, 0.5, 0, 0);
|
||||||
|
gtk_widget_show (alignment16);
|
||||||
|
gtk_container_add (GTK_CONTAINER (button_pause), alignment16);
|
||||||
|
|
||||||
|
hbox51 = gtk_hbox_new (FALSE, 2);
|
||||||
|
gtk_widget_show (hbox51);
|
||||||
|
gtk_container_add (GTK_CONTAINER (alignment16), hbox51);
|
||||||
|
|
||||||
|
image56 = gtk_image_new_from_stock ("gtk-no", GTK_ICON_SIZE_BUTTON);
|
||||||
|
gtk_widget_show (image56);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox51), image56, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
label72 = gtk_label_new_with_mnemonic (_("Pause"));
|
||||||
|
gtk_widget_show (label72);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox51), label72, FALSE, FALSE, 0);
|
||||||
|
gtk_label_set_justify (GTK_LABEL (label72), GTK_JUSTIFY_LEFT);
|
||||||
|
|
||||||
|
button_resume = gtk_button_new ();
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox48), button_resume, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
alignment17 = gtk_alignment_new (0.5, 0.5, 0, 0);
|
||||||
|
gtk_widget_show (alignment17);
|
||||||
|
gtk_container_add (GTK_CONTAINER (button_resume), alignment17);
|
||||||
|
|
||||||
|
hbox52 = gtk_hbox_new (FALSE, 2);
|
||||||
|
gtk_widget_show (hbox52);
|
||||||
|
gtk_container_add (GTK_CONTAINER (alignment17), hbox52);
|
||||||
|
|
||||||
|
image57 = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_BUTTON);
|
||||||
|
gtk_widget_show (image57);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox52), image57, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
label73 = gtk_label_new_with_mnemonic (_("Resume"));
|
||||||
|
gtk_widget_show (label73);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox52), label73, FALSE, FALSE, 0);
|
||||||
|
gtk_label_set_justify (GTK_LABEL (label73), GTK_JUSTIFY_LEFT);
|
||||||
|
|
||||||
|
button_live_close = gtk_button_new_from_stock ("gtk-close");
|
||||||
|
gtk_widget_show (button_live_close);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox48), button_live_close, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_set_sensitive (button_live_close, FALSE);
|
||||||
|
|
||||||
|
g_signal_connect ((gpointer) window_live, "delete_event",
|
||||||
G_CALLBACK (on_live_window_delete_event),
|
G_CALLBACK (on_live_window_delete_event),
|
||||||
NULL);
|
NULL);
|
||||||
|
g_signal_connect ((gpointer) button_pause, "clicked",
|
||||||
|
G_CALLBACK (on_button_pause_clicked),
|
||||||
|
NULL);
|
||||||
|
g_signal_connect ((gpointer) button_resume, "clicked",
|
||||||
|
G_CALLBACK (on_button_resume_clicked),
|
||||||
|
NULL);
|
||||||
g_signal_connect ((gpointer) button_live_close, "clicked",
|
g_signal_connect ((gpointer) button_live_close, "clicked",
|
||||||
G_CALLBACK (on_button_live_close_clicked),
|
G_CALLBACK (on_button_live_close_clicked),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* Store pointers to all widgets, for use by lookup_widget(). */
|
/* Store pointers to all widgets, for use by lookup_widget(). */
|
||||||
GLADE_HOOKUP_OBJECT_NO_REF (live_window, live_window, "live_window");
|
GLADE_HOOKUP_OBJECT_NO_REF (window_live, window_live, "window_live");
|
||||||
GLADE_HOOKUP_OBJECT (live_window, vbox23, "vbox23");
|
GLADE_HOOKUP_OBJECT (window_live, vbox36, "vbox36");
|
||||||
GLADE_HOOKUP_OBJECT (live_window, hscale_tendency, "hscale_tendency");
|
GLADE_HOOKUP_OBJECT (window_live, progressbar_live, "progressbar_live");
|
||||||
GLADE_HOOKUP_OBJECT (live_window, scrolledwindow_live, "scrolledwindow_live");
|
GLADE_HOOKUP_OBJECT (window_live, hruler_live, "hruler_live");
|
||||||
GLADE_HOOKUP_OBJECT (live_window, treeview_live, "treeview_live");
|
GLADE_HOOKUP_OBJECT (window_live, hbox50, "hbox50");
|
||||||
GLADE_HOOKUP_OBJECT (live_window, progressbar_live, "progressbar_live");
|
GLADE_HOOKUP_OBJECT (window_live, vbox38, "vbox38");
|
||||||
GLADE_HOOKUP_OBJECT (live_window, hruler_live, "hruler_live");
|
GLADE_HOOKUP_OBJECT (window_live, scrolledwindow8, "scrolledwindow8");
|
||||||
GLADE_HOOKUP_OBJECT (live_window, vbox26, "vbox26");
|
GLADE_HOOKUP_OBJECT (window_live, treeview_result, "treeview_result");
|
||||||
GLADE_HOOKUP_OBJECT (live_window, check_live_window_show_live, "check_live_window_show_live");
|
GLADE_HOOKUP_OBJECT (window_live, scrolledwindow9, "scrolledwindow9");
|
||||||
GLADE_HOOKUP_OBJECT (live_window, check_live_window_tendency, "check_live_window_tendency");
|
GLADE_HOOKUP_OBJECT (window_live, treeview_commentary, "treeview_commentary");
|
||||||
GLADE_HOOKUP_OBJECT (live_window, button_live_close, "button_live_close");
|
GLADE_HOOKUP_OBJECT (window_live, hbox48, "hbox48");
|
||||||
GLADE_HOOKUP_OBJECT_NO_REF (live_window, tooltips, "tooltips");
|
GLADE_HOOKUP_OBJECT (window_live, button_pause, "button_pause");
|
||||||
|
GLADE_HOOKUP_OBJECT (window_live, alignment16, "alignment16");
|
||||||
|
GLADE_HOOKUP_OBJECT (window_live, hbox51, "hbox51");
|
||||||
|
GLADE_HOOKUP_OBJECT (window_live, image56, "image56");
|
||||||
|
GLADE_HOOKUP_OBJECT (window_live, label72, "label72");
|
||||||
|
GLADE_HOOKUP_OBJECT (window_live, button_resume, "button_resume");
|
||||||
|
GLADE_HOOKUP_OBJECT (window_live, alignment17, "alignment17");
|
||||||
|
GLADE_HOOKUP_OBJECT (window_live, hbox52, "hbox52");
|
||||||
|
GLADE_HOOKUP_OBJECT (window_live, image57, "image57");
|
||||||
|
GLADE_HOOKUP_OBJECT (window_live, label73, "label73");
|
||||||
|
GLADE_HOOKUP_OBJECT (window_live, button_live_close, "button_live_close");
|
||||||
|
|
||||||
gtk_window_add_accel_group (GTK_WINDOW (live_window), accel_group);
|
gtk_window_add_accel_group (GTK_WINDOW (window_live), accel_group);
|
||||||
|
|
||||||
return live_window;
|
return window_live;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
|
@@ -6,5 +6,5 @@ GtkWidget* create_window_startup (void);
|
|||||||
GtkWidget* create_popup_window (void);
|
GtkWidget* create_popup_window (void);
|
||||||
GtkWidget* create_fsel_window (void);
|
GtkWidget* create_fsel_window (void);
|
||||||
GtkWidget* create_font_sel_window (void);
|
GtkWidget* create_font_sel_window (void);
|
||||||
GtkWidget* create_live_window (void);
|
GtkWidget* create_window_live (void);
|
||||||
GtkWidget* create_help_window (void);
|
GtkWidget* create_help_window (void);
|
||||||
|
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef OPTION_H
|
||||||
|
#define OPTION_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
123
src/player.c
123
src/player.c
@@ -28,7 +28,7 @@
|
|||||||
team for players 13 to CONSTANT_TEAM_MAX_PLAYERS.
|
team for players 13 to CONSTANT_TEAM_MAX_PLAYERS.
|
||||||
Player 11 is always the second goalie. */
|
Player 11 is always the second goalie. */
|
||||||
#define CONSTANT_PLAYER_POS_BOUND1 15
|
#define CONSTANT_PLAYER_POS_BOUND1 15
|
||||||
#define CONSTANT_PLAYER_POS_BOUND2 17
|
#define CONSTANT_PLAYER_POS_BOUND2 18
|
||||||
|
|
||||||
/** Bounds for the contract time at player generation. */
|
/** Bounds for the contract time at player generation. */
|
||||||
#define CONSTANT_PLAYER_CONTRACT_LOWER 52
|
#define CONSTANT_PLAYER_CONTRACT_LOWER 52
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
The player's skill can deviate from this value by #CONSTANT_PLAYER_AVERAGE_SKILL_VARIANCE %
|
The player's skill can deviate from this value by #CONSTANT_PLAYER_AVERAGE_SKILL_VARIANCE %
|
||||||
@return A newly created player. */
|
@return A newly created player. */
|
||||||
Player
|
Player
|
||||||
player_new(const Team *tm, gint average_skill)
|
player_new(Team *tm, gint average_skill)
|
||||||
{
|
{
|
||||||
gfloat skill_factor =
|
gfloat skill_factor =
|
||||||
math_rnd(1 - CONSTANT_PLAYER_AVERAGE_SKILL_VARIANCE,
|
math_rnd(1 - CONSTANT_PLAYER_AVERAGE_SKILL_VARIANCE,
|
||||||
@@ -70,8 +70,6 @@ player_new(const Team *tm, gint average_skill)
|
|||||||
|
|
||||||
new.name =
|
new.name =
|
||||||
g_string_new(((GString*)g_ptr_array_index(player_names, math_rndi(0, player_names->len - 1)))->str);
|
g_string_new(((GString*)g_ptr_array_index(player_names, math_rndi(0, player_names->len - 1)))->str);
|
||||||
new.clid = tm->clid;
|
|
||||||
new.team_id = tm->id;
|
|
||||||
new.id = player_new_id(tm->players);
|
new.id = player_new_id(tm->players);
|
||||||
new.pos = player_get_position_from_structure(tm->structure, tm->players->len);
|
new.pos = player_get_position_from_structure(tm->structure, tm->players->len);
|
||||||
new.cpos = new.pos;
|
new.cpos = new.pos;
|
||||||
@@ -87,7 +85,8 @@ player_new(const Team *tm, gint average_skill)
|
|||||||
new.talent = player_new_talent(new.skill);
|
new.talent = player_new_talent(new.skill);
|
||||||
new.etal = player_estimate_talent(&new);
|
new.etal = player_estimate_talent(&new);
|
||||||
new.fitness = math_rndi(CONSTANT_PLAYER_FITNESS_LOWER, CONSTANT_PLAYER_FITNESS_UPPER);
|
new.fitness = math_rndi(CONSTANT_PLAYER_FITNESS_LOWER, CONSTANT_PLAYER_FITNESS_UPPER);
|
||||||
new.health = new.recovery = new.goals = new.games = 0;
|
new.health = new.recovery = 0;
|
||||||
|
new.games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals));
|
||||||
new.value = player_assign_value(&new);
|
new.value = player_assign_value(&new);
|
||||||
new.wage = player_assign_wage(&new);
|
new.wage = player_assign_wage(&new);
|
||||||
new.contract = math_rndi(CONSTANT_PLAYER_CONTRACT_LOWER, CONSTANT_PLAYER_CONTRACT_UPPER);
|
new.contract = math_rndi(CONSTANT_PLAYER_CONTRACT_LOWER, CONSTANT_PLAYER_CONTRACT_UPPER);
|
||||||
@@ -95,6 +94,7 @@ player_new(const Team *tm, gint average_skill)
|
|||||||
new.cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard));
|
new.cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard));
|
||||||
/* todo: make player history struct. */
|
/* todo: make player history struct. */
|
||||||
new.history = NULL;
|
new.history = NULL;
|
||||||
|
new.team = tm;
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
@@ -248,11 +248,16 @@ player_copy(const Player *source, Player *dest)
|
|||||||
*dest = *source;
|
*dest = *source;
|
||||||
dest->name = g_string_new(source->name->str);
|
dest->name = g_string_new(source->name->str);
|
||||||
dest->cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard));
|
dest->cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard));
|
||||||
|
dest->games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals));
|
||||||
dest->history = NULL;
|
dest->history = NULL;
|
||||||
|
|
||||||
for(i=0;i<source->cards->len;i++)
|
for(i=0;i<source->cards->len;i++)
|
||||||
g_array_append_val(dest->cards,
|
g_array_append_val(dest->cards,
|
||||||
g_array_index(source->cards, PlayerCard, i));
|
g_array_index(source->cards, PlayerCard, i));
|
||||||
|
|
||||||
|
for(i=0;i<source->games_goals->len;i++)
|
||||||
|
g_array_append_val(dest->games_goals,
|
||||||
|
g_array_index(source->games_goals, PlayerGamesGoals, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copy a player into a team in a way that allows us to
|
/** Copy a player into a team in a way that allows us to
|
||||||
@@ -269,3 +274,111 @@ player_append_to_array(const Player *pl, Team *tm)
|
|||||||
|
|
||||||
g_array_append_val(tm->players, new_player);
|
g_array_append_val(tm->players, new_player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Remove a player from a team. */
|
||||||
|
void
|
||||||
|
player_remove_from_team(Team *tm, gint player_number)
|
||||||
|
{
|
||||||
|
free_player(&g_array_index(tm->players, Player, player_number));
|
||||||
|
|
||||||
|
g_array_remove_index(tm->players, player_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the pointer to the player given by the ids.
|
||||||
|
@param clid The cup/league id of the team.
|
||||||
|
@param team_id The id of the team.
|
||||||
|
@param id The id of the player.
|
||||||
|
@return A pointer to the player or NULL if he wasn't to be found. */
|
||||||
|
Player*
|
||||||
|
player_of_ids(gint clid, gint team_id, gint id)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
Team *tm = team_get_pointer_from_ids(clid, team_id);
|
||||||
|
Player *pl = NULL;
|
||||||
|
|
||||||
|
if(tm != NULL)
|
||||||
|
{
|
||||||
|
for(i=0;i<tm->players->len;i++)
|
||||||
|
if(g_array_index(tm->players, Player, i).id == id)
|
||||||
|
{
|
||||||
|
pl = &g_array_index(tm->players, Player, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pl == NULL)
|
||||||
|
g_warning("player_of_ids: didn't find player with ids %d and %d and %d\n",
|
||||||
|
clid, team_id, 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. */
|
||||||
|
gint
|
||||||
|
player_all_games_goals(const Player *pl, gboolean goals)
|
||||||
|
{
|
||||||
|
gint i, sum = 0;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a pointer to the number'th player of the team.
|
||||||
|
@param tm The team.
|
||||||
|
@param number The player number.
|
||||||
|
@return A pointer to the player or NULL. */
|
||||||
|
Player*
|
||||||
|
player_of(const Team *tm, gint number)
|
||||||
|
{
|
||||||
|
if(tm->players->len <= number)
|
||||||
|
{
|
||||||
|
g_warning("player_of: Player list of team %s too short for number %d.\n",
|
||||||
|
tm->name->str, number);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &g_array_index(tm->players, Player, number);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Return a pointer to the player with specified id of the team.
|
||||||
|
@param tm The team.
|
||||||
|
@param id The player's id.
|
||||||
|
@return A pointer to the player or NULL. */
|
||||||
|
Player*
|
||||||
|
player_of_id(const Team *tm, gint id)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
for(i=0;i<tm->players->len;i++)
|
||||||
|
if(g_array_index(tm->players, Player, i).id == id)
|
||||||
|
return &g_array_index(tm->players, Player, i);
|
||||||
|
|
||||||
|
g_warning("player_of_id: didn't find player with id %d of team %s\n", id, tm->name->str);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
23
src/player.h
23
src/player.h
@@ -5,11 +5,8 @@
|
|||||||
#include "player_struct.h"
|
#include "player_struct.h"
|
||||||
#include "team_struct.h"
|
#include "team_struct.h"
|
||||||
|
|
||||||
/** Highest skill and talent a player can have. */
|
|
||||||
#define CONSTANT_PLAYER_MAX_SKILL 99
|
|
||||||
|
|
||||||
Player
|
Player
|
||||||
player_new(const Team *tm, gint average_skill);
|
player_new(Team *tm, gint average_skill);
|
||||||
|
|
||||||
gint
|
gint
|
||||||
player_new_id(const GArray *players);
|
player_new_id(const GArray *players);
|
||||||
@@ -35,4 +32,22 @@ player_copy(const Player *source, Player *dest);
|
|||||||
void
|
void
|
||||||
player_append_to_array(const Player *pl, Team *tm);
|
player_append_to_array(const Player *pl, Team *tm);
|
||||||
|
|
||||||
|
void
|
||||||
|
player_remove_from_team(Team *tm, gint player_number);
|
||||||
|
|
||||||
|
gint
|
||||||
|
player_all_games_goals(const Player *pl, gboolean goals);
|
||||||
|
|
||||||
|
gint
|
||||||
|
player_all_cards(const Player *pl);
|
||||||
|
|
||||||
|
Player*
|
||||||
|
player_of_ids(gint clid, gint team_id, gint id);
|
||||||
|
|
||||||
|
Player*
|
||||||
|
player_of(const Team *tm, gint number);
|
||||||
|
|
||||||
|
Player*
|
||||||
|
player_of_id(const Team *tm, gint id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,8 +1,27 @@
|
|||||||
#ifndef PLAYER_STRUCT_H
|
#ifndef PLAYER_STRUCT_H
|
||||||
#define PLAYER_STRUCT_H
|
#define PLAYER_STRUCT_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
|
#include "team_struct.h"
|
||||||
|
|
||||||
|
/** Highest skill and talent a player can have. */
|
||||||
|
#define CONSTANT_PLAYER_MAX_SKILL 99
|
||||||
|
/** Influence of boost on player's skill. */
|
||||||
|
#define CONSTANT_PLAYER_BOOST_SKILL_EFFECT 0.3
|
||||||
|
/** Influence of boost on player's fitness decay. */
|
||||||
|
#define CONSTANT_PLAYER_BOOST_FITNESS_EFFECT 1.0
|
||||||
|
/** Influence of boost on injury probability. */
|
||||||
|
#define CONSTANT_PLAYER_BOOST_INJURY_EFFECT 1.0
|
||||||
|
/** Influence of boost on cards probability. */
|
||||||
|
#define CONSTANT_PLAYER_BOOST_CARD_EFFECT 1.0
|
||||||
|
|
||||||
|
/** The influence of the fitness on the current skill.
|
||||||
|
This determines the player's contribution to the team
|
||||||
|
during a game. The higher the value the bigger the influence. */
|
||||||
|
#define CONSTANT_PLAYER_FITNESS_IMPACT_ON_SKILL 0.25
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Player attribute indices.
|
Player positions.
|
||||||
*/
|
*/
|
||||||
enum PlayerPos
|
enum PlayerPos
|
||||||
{
|
{
|
||||||
@@ -20,13 +39,32 @@ enum PlayerPos
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/** Numerical id of the league or cup. */
|
/** Numerical id of the league or cup. */
|
||||||
gint league_cup_id;
|
gint clid;
|
||||||
/** Number of yellow cards. */
|
/** Number of yellow cards. */
|
||||||
gint yellow;
|
gint yellow;
|
||||||
/** Number of weeks the player is banned. */
|
/** Number of weeks the player is banned. */
|
||||||
gint red;
|
gint red;
|
||||||
} PlayerCard;
|
} PlayerCard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Goals and games in different leagues and cups are counted separately for players.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/** Numerical id of the league or cup. */
|
||||||
|
gint clid;
|
||||||
|
/** Number of games the player played. */
|
||||||
|
gint games;
|
||||||
|
/** Number of goals (scored for field players or conceded for goalies). */
|
||||||
|
gint goals;
|
||||||
|
} PlayerGamesGoals;
|
||||||
|
|
||||||
|
enum PlayerInjury
|
||||||
|
{
|
||||||
|
PLAYER_INJURY_NONE = 0,
|
||||||
|
PLAYER_INJURY_END
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Representation of a player.
|
Representation of a player.
|
||||||
@see #PlayerAttributes
|
@see #PlayerAttributes
|
||||||
@@ -44,23 +82,56 @@ typedef struct
|
|||||||
talent, /**< Talent. The peak ability (which isn't always reached). */
|
talent, /**< Talent. The peak ability (which isn't always reached). */
|
||||||
etal, /**< Estimated talent (the user never sees the actual talent). */
|
etal, /**< Estimated talent (the user never sees the actual talent). */
|
||||||
fitness, /**< Fitness. Between 0 and 99. */
|
fitness, /**< Fitness. Between 0 and 99. */
|
||||||
health, /**< Health. An integer signifying an injury or good health. */
|
health, /**< Health. An integer signifying an injury or good health. @see #PlayerInjury */
|
||||||
recovery, /**< Weeks until the player gets healthy. */
|
recovery, /**< Weeks until the player gets healthy. */
|
||||||
clid, /**< Cup or league id of the player's team. */
|
|
||||||
team_id, /**< Id of the player's team. */
|
|
||||||
id, /**< Id of the player within the team. */
|
id, /**< Id of the player within the team. */
|
||||||
value, /**< Value of the player. */
|
value, /**< Value of the player. */
|
||||||
wage, /**< Wage of the player. */
|
wage, /**< Wage of the player. */
|
||||||
contract, /**< The number of weeks until the player's contract expires. */
|
contract, /**< The number of weeks until the player's contract expires. */
|
||||||
lsu, /**< Last skill update. Number of weeks since the player skill was last updated. */
|
lsu; /**< Last skill update. Number of weeks since the player skill was last updated. */
|
||||||
goals, /**< Number of goals (scored for field players or conceded for goalies). */
|
|
||||||
games; /**< Number of games the player played. */
|
|
||||||
|
|
||||||
/** array of cards; one item per league and cup.
|
/** Array of games and goals; one item per league and cup.
|
||||||
|
@see PlayerGamesGoals */
|
||||||
|
GArray *games_goals;
|
||||||
|
|
||||||
|
/** Array of cards; one item per league and cup.
|
||||||
@see PlayerCard*/
|
@see PlayerCard*/
|
||||||
GArray *cards;
|
GArray *cards;
|
||||||
/** Player history. To be specified. */
|
/** Player history. To be specified. */
|
||||||
GArray *history;
|
GArray *history;
|
||||||
|
|
||||||
|
/** Pointer to the player's team. */
|
||||||
|
Team *team;
|
||||||
} Player;
|
} Player;
|
||||||
|
|
||||||
|
/** Enum for player attributes that can be shown in a player list. */
|
||||||
|
enum PlayerListAttributeValue
|
||||||
|
{
|
||||||
|
PLAYER_LIST_ATTRIBUTE_NAME = 0,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_CPOS,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_POS,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_CSKILL,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_SKILL,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_FITNESS,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_GAMES,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_GOALS,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_STATUS,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_CARDS,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_AGE,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_ETAL,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_VALUE,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_WAGE,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_CONTRACT,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_TEAM,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_LEAGUE_CUP,
|
||||||
|
PLAYER_LIST_ATTRIBUTE_END
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A struct telling us which player attributes to show in a player list.
|
||||||
|
@see #PlayerListAttributeValue*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gboolean on_off[PLAYER_LIST_ATTRIBUTE_END];
|
||||||
|
} PlayerListAttribute;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#include "cup.h"
|
#include "cup.h"
|
||||||
|
#include "file.h"
|
||||||
#include "fixture.h"
|
#include "fixture.h"
|
||||||
#include "league.h"
|
#include "league.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@@ -10,13 +11,12 @@
|
|||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include "xml_name.h"
|
#include "xml_name.h"
|
||||||
|
|
||||||
|
|
||||||
/** Generate the teams etc. */
|
/** Generate the teams etc. */
|
||||||
void
|
void
|
||||||
start_new_game(void)
|
start_new_game(void)
|
||||||
{
|
{
|
||||||
start_write_variables();
|
|
||||||
xml_name_read(PLAYER_NAMES_FILE, -1);
|
xml_name_read(PLAYER_NAMES_FILE, -1);
|
||||||
|
start_write_variables();
|
||||||
start_generate_league_teams();
|
start_generate_league_teams();
|
||||||
start_new_season();
|
start_new_season();
|
||||||
xml_name_read(PLAYER_NAMES_FILE, 1000);
|
xml_name_read(PLAYER_NAMES_FILE, 1000);
|
||||||
@@ -26,7 +26,16 @@ start_new_game(void)
|
|||||||
void
|
void
|
||||||
start_new_season(void)
|
start_new_season(void)
|
||||||
{
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
xml_name_read(PLAYER_NAMES_FILE, 1000);
|
||||||
start_load_cup_teams();
|
start_load_cup_teams();
|
||||||
|
|
||||||
|
for(i=0;i<ligs->len;i++)
|
||||||
|
fixture_write_league_fixtures(&lig(i));
|
||||||
|
|
||||||
|
for(i=0;i<cps->len;i++)
|
||||||
|
fixture_write_cup_fixtures(&cp(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fill some global variables with default values at the
|
/** Fill some global variables with default values at the
|
||||||
@@ -34,11 +43,13 @@ start_new_season(void)
|
|||||||
void
|
void
|
||||||
start_write_variables(void)
|
start_write_variables(void)
|
||||||
{
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
season = week = week_round = 1;
|
season = week = week_round = 1;
|
||||||
scout = physio = QUALITY_AVERAGE;
|
scout = physio = QUALITY_AVERAGE;
|
||||||
|
|
||||||
fixtures = g_array_new(FALSE, FALSE, sizeof(Fixture));
|
|
||||||
transfer_list = g_array_new(FALSE, FALSE, sizeof(TransferPlayer));
|
transfer_list = g_array_new(FALSE, FALSE, sizeof(TransferPlayer));
|
||||||
|
file_load_conf_file();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generate the teams in the leagues. */
|
/** Generate the teams in the leagues. */
|
||||||
@@ -49,10 +60,8 @@ start_generate_league_teams(void)
|
|||||||
Team *tm;
|
Team *tm;
|
||||||
|
|
||||||
if(ligs->len == 0)
|
if(ligs->len == 0)
|
||||||
{
|
main_exit_program(EXIT_NO_LEAGUES,
|
||||||
g_warning("start_generate_league_teams: no leagues found. there must be at least one league in the game.\n");
|
"start_generate_league_teams: no leagues found. there must be at least one league in the game.\n");
|
||||||
main_exit_program(EXIT_NO_LEAGUES);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0;i<ligs->len;i++)
|
for(i=0;i<ligs->len;i++)
|
||||||
{
|
{
|
||||||
@@ -81,19 +90,20 @@ start_load_cup_teams(void)
|
|||||||
cup_load_choose_teams(&cp(i));
|
cup_load_choose_teams(&cp(i));
|
||||||
cup_load_choose_team_user(&cp(i));
|
cup_load_choose_team_user(&cp(i));
|
||||||
|
|
||||||
for(j=0;j<cp(i).teams->len;j++)
|
/*d*/
|
||||||
{
|
/* for(j=0;j<cp(i).teams->len;j++) */
|
||||||
printf("%d %s clid %d id %d\n", j,
|
/* { */
|
||||||
g_array_index(cp(i).teams, Team, j).name->str,
|
/* printf("%d %s clid %d id %d\n", j, */
|
||||||
g_array_index(cp(i).teams, Team, j).clid,
|
/* g_array_index(cp(i).teams, Team, j).name->str, */
|
||||||
g_array_index(cp(i).teams, Team, j).id);
|
/* g_array_index(cp(i).teams, Team, j).clid, */
|
||||||
printf("%s %d %d\n",
|
/* g_array_index(cp(i).teams, Team, j).id); */
|
||||||
g_array_index(g_array_index(cp(i).teams, Team, j).players,
|
/* } */
|
||||||
Player, 0).name->str,
|
/* for(j=0;j<cp(i).user_teams->len;j++) */
|
||||||
g_array_index(g_array_index(cp(i).teams, Team, j).players,
|
/* { */
|
||||||
Player, 0).skill,
|
/* printf("%d %s clid %d id %d\n", j, */
|
||||||
g_array_index(g_array_index(cp(i).teams, Team, j).players,
|
/* ((Team*)g_ptr_array_index(cp(i).user_teams, j))->name->str, */
|
||||||
Player, 0).talent);
|
/* ((Team*)g_ptr_array_index(cp(i).user_teams, j))->clid, */
|
||||||
}
|
/* ((Team*)g_ptr_array_index(cp(i).user_teams, j))->id); */
|
||||||
|
/* } */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
#ifndef TABLE_STRUCT_H
|
#ifndef TABLE_STRUCT_H
|
||||||
#define TABLE_STRUCT_H
|
#define TABLE_STRUCT_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
|
#include "team_struct.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Table element values.
|
Table element values.
|
||||||
@see TableElement
|
@see TableElement
|
||||||
@@ -25,7 +28,7 @@ enum TableElementValues
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
gint team_id;
|
Team *team;
|
||||||
gint values[TABLE_END];
|
gint values[TABLE_END];
|
||||||
} TableElement;
|
} TableElement;
|
||||||
|
|
||||||
@@ -36,7 +39,7 @@ typedef struct
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GString *name;
|
GString *name;
|
||||||
gint league_id;
|
gint clid;
|
||||||
GArray *elements;
|
GArray *elements;
|
||||||
} Table;
|
} Table;
|
||||||
|
|
||||||
|
254
src/team.c
254
src/team.c
@@ -1,4 +1,5 @@
|
|||||||
#include "cup.h"
|
#include "cup.h"
|
||||||
|
#include "fixture.h"
|
||||||
#include "free.h"
|
#include "free.h"
|
||||||
#include "league.h"
|
#include "league.h"
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
/** Kinda hard to explain.
|
/** Kinda hard to explain.
|
||||||
@see team_generate_players()
|
@see team_generate_players()
|
||||||
@see player_generate() */
|
@see player_generate() */
|
||||||
#define CONSTANT_TEAM_SKILL_VARIANCE 0.075
|
#define CONSTANT_TEAM_SKILL_VARIANCE 0.2//0.075
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Generate a team with default values, e.g.
|
Generate a team with default values, e.g.
|
||||||
@@ -43,10 +44,11 @@ team_new(void)
|
|||||||
Team new;
|
Team new;
|
||||||
|
|
||||||
new.name = g_string_new("");
|
new.name = g_string_new("");
|
||||||
|
new.symbol = g_string_new("");
|
||||||
|
|
||||||
new.clid = new.id = -1;
|
new.clid = new.id = -1;
|
||||||
new.structure = team_assign_playing_structure();
|
new.structure = 442;//team_assign_playing_structure();
|
||||||
new.style = team_assign_playing_style();
|
new.style = 0;//team_assign_playing_style();
|
||||||
|
|
||||||
new.stadium = team_stadium_new();
|
new.stadium = team_stadium_new();
|
||||||
|
|
||||||
@@ -120,22 +122,11 @@ team_stadium_new(void)
|
|||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Decide whether the team specified is the user's team.
|
|
||||||
@param tm The team we check
|
|
||||||
@return TRUE if the team is the user's team, FALSE otherwise. */
|
|
||||||
gboolean
|
|
||||||
is_my_team(const Team *tm)
|
|
||||||
{
|
|
||||||
return (tm->clid == my_team_clid && tm->id == my_team_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill the players array of the team.
|
/* Fill the players array of the team.
|
||||||
@param tm The team that gets filled. */
|
@param tm The team that gets filled. */
|
||||||
void
|
void
|
||||||
team_generate_players(Team *tm)
|
team_generate_players(Team *tm)
|
||||||
{
|
{
|
||||||
/*d*/
|
|
||||||
Player pl;
|
|
||||||
gint i;
|
gint i;
|
||||||
gfloat skill_factor = math_rnd(1 - CONSTANT_TEAM_SKILL_VARIANCE,
|
gfloat skill_factor = math_rnd(1 - CONSTANT_TEAM_SKILL_VARIANCE,
|
||||||
1 + CONSTANT_TEAM_SKILL_VARIANCE);
|
1 + CONSTANT_TEAM_SKILL_VARIANCE);
|
||||||
@@ -159,22 +150,6 @@ team_generate_players(Team *tm)
|
|||||||
new = player_new(tm, average_skill);
|
new = player_new(tm, average_skill);
|
||||||
g_array_append_val(tm->players, new);
|
g_array_append_val(tm->players, new);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*d*/
|
|
||||||
/* if(tm->id == 0) */
|
|
||||||
/* { */
|
|
||||||
/* printf("%s %p\n\n", tm->name->str, tm); */
|
|
||||||
/* for(i=0;i<tm->players->len;i++) */
|
|
||||||
/* { */
|
|
||||||
/* pl = g_array_index(tm->players, Player, i); */
|
|
||||||
/* printf("%d %s sk %d tal %d etal %d\n", i, */
|
|
||||||
/* pl.name->str, pl.skill, pl.talent, pl.etal); */
|
|
||||||
/* printf("fit %d val %d wag %d con %.1f lsu %d goa %d gam %d\n", */
|
|
||||||
/* pl.fitness, pl.value, */
|
|
||||||
/* pl.wage, (gfloat)pl.contract / 52, pl.lsu, pl.goals, pl.games); */
|
|
||||||
/* } */
|
|
||||||
/* printf("\n");printf("\n"); */
|
|
||||||
/* } */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a certain value from the league or cup struct
|
/** Return a certain value from the league or cup struct
|
||||||
@@ -185,7 +160,7 @@ team_generate_players(Team *tm)
|
|||||||
gint
|
gint
|
||||||
team_return_league_cup_value_int(const Team *tm, gint value_type)
|
team_return_league_cup_value_int(const Team *tm, gint value_type)
|
||||||
{
|
{
|
||||||
gint idx = tm->clid % 1000;
|
gint idx = league_cup_get_index_from_clid(tm->clid);
|
||||||
|
|
||||||
if(tm->clid >= ID_CUP_START)
|
if(tm->clid >= ID_CUP_START)
|
||||||
switch(value_type)
|
switch(value_type)
|
||||||
@@ -233,6 +208,50 @@ team_return_league_cup_value_int(const Team *tm, gint value_type)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Print name or short name or such of the team's league or cup
|
||||||
|
into a string.
|
||||||
|
@param tm The pointer to the team.
|
||||||
|
@param value_type Determines which value we want; @see #LeagueCupValue
|
||||||
|
@param buf The buffer we print the string into. */
|
||||||
|
void
|
||||||
|
team_get_league_cup_string(const Team *tm, gint value_type, gchar *buf)
|
||||||
|
{
|
||||||
|
gint idx = league_cup_get_index_from_clid(tm->clid);
|
||||||
|
|
||||||
|
if(tm->clid >= ID_CUP_START)
|
||||||
|
switch(value_type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
sprintf(buf, "%s", lig(idx).name->str);
|
||||||
|
break;
|
||||||
|
case LEAGUE_CUP_VALUE_SHORT_NAME:
|
||||||
|
sprintf(buf, "%s", lig(idx).short_name->str);
|
||||||
|
break;
|
||||||
|
case LEAGUE_CUP_VALUE_SID:
|
||||||
|
sprintf(buf, "%s", lig(idx).sid->str);
|
||||||
|
break;
|
||||||
|
case LEAGUE_CUP_VALUE_SYMBOL:
|
||||||
|
sprintf(buf, "%s", lig(idx).symbol->str);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
switch(value_type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
sprintf(buf, "%s", cp(idx).name->str);
|
||||||
|
break;
|
||||||
|
case LEAGUE_CUP_VALUE_SHORT_NAME:
|
||||||
|
sprintf(buf, "%s", cp(idx).short_name->str);
|
||||||
|
break;
|
||||||
|
case LEAGUE_CUP_VALUE_SID:
|
||||||
|
sprintf(buf, "%s", cp(idx).sid->str);
|
||||||
|
break;
|
||||||
|
case LEAGUE_CUP_VALUE_SYMBOL:
|
||||||
|
sprintf(buf, "%s", cp(idx).symbol->str);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Copy a team to another team. The destination team
|
/** Copy a team to another team. The destination team
|
||||||
has to be a fully allocated team (because it gets
|
has to be a fully allocated team (because it gets
|
||||||
freed before we copy).
|
freed before we copy).
|
||||||
@@ -299,15 +318,186 @@ team_append_to_array_with_ids(const Team *tm, GArray *teams_array, gint clid, gi
|
|||||||
@return TRUE if the team's already participating in a cup,
|
@return TRUE if the team's already participating in a cup,
|
||||||
FALSE otherwise. */
|
FALSE otherwise. */
|
||||||
gboolean
|
gboolean
|
||||||
is_in_international_cups(const Team *tm)
|
query_is_in_international_cups(const Team *tm)
|
||||||
{
|
{
|
||||||
gint i, j;
|
gint i, j;
|
||||||
|
|
||||||
for(i=0;i<cps->len;i++)
|
for(i=0;i<cps->len;i++)
|
||||||
|
{
|
||||||
for(j=0;j<cp(i).teams->len;j++)
|
for(j=0;j<cp(i).teams->len;j++)
|
||||||
if(cp(i).type == CUP_TYPE_INTERNATIONAL &&
|
if(cp(i).type == CUP_TYPE_INTERNATIONAL &&
|
||||||
strcmp(tm->name->str, g_array_index(cp(i).teams, Team, j).name->str) == 0)
|
strcmp(tm->name->str, g_array_index(cp(i).teams, Team, j).name->str) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
for(j=0;j<cp(i).user_teams->len;j++)
|
||||||
|
if(tm == g_ptr_array_index(cp(i).user_teams, j))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Check whether a team participates in a cup.
|
||||||
|
@param tm The team.
|
||||||
|
@param cup The cup.
|
||||||
|
@return TRUE or FALSE. */
|
||||||
|
gboolean
|
||||||
|
query_is_in_cup(const Team *tm, const Cup *cup)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if(tm->clid >= ID_CUP_START)
|
||||||
|
return (tm->clid == cup->id);
|
||||||
|
|
||||||
|
if(cup->type == CUP_TYPE_INTERNATIONAL)
|
||||||
|
{
|
||||||
|
for(i=0;i<cup->user_teams->len;i++)
|
||||||
|
if(tm == g_ptr_array_index(cup->user_teams, i))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0;i<cup->fixtures->len;i++)
|
||||||
|
if(tm == g_array_index(cup->fixtures, Fixture, i).teams[0] ||
|
||||||
|
tm == g_array_index(cup->fixtures, Fixture, i).teams[1])
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a GPtrArray containing the pointers
|
||||||
|
to the teams from the teams array.
|
||||||
|
@param teams The teams array we use.
|
||||||
|
@return A GPtrArray containing pointers to the teams. */
|
||||||
|
GPtrArray*
|
||||||
|
team_get_pointers_from_array(const GArray *teams)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
GPtrArray *team_pointers = g_ptr_array_new();
|
||||||
|
|
||||||
|
for(i=0;i<teams->len;i++)
|
||||||
|
g_ptr_array_add(team_pointers, (gpointer)&g_array_index(teams, Team, i));
|
||||||
|
|
||||||
|
return team_pointers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a pointer array containing the teams from
|
||||||
|
the leagues that are specified in the choose_teams array.
|
||||||
|
@param choose_teams The choose_team array.
|
||||||
|
@return A pointer array containing team pointers. */
|
||||||
|
GPtrArray*
|
||||||
|
team_get_pointers_from_choose_teams(const GArray *choose_teams)
|
||||||
|
{
|
||||||
|
gint i, j, k;
|
||||||
|
CupChooseTeam *ct = NULL;
|
||||||
|
GPtrArray *teams = g_ptr_array_new();
|
||||||
|
|
||||||
|
for(i=0;i<choose_teams->len;i++)
|
||||||
|
{
|
||||||
|
ct = &g_array_index(choose_teams, CupChooseTeam, i);
|
||||||
|
for(j=0;j<ligs->len;j++)
|
||||||
|
if(strcmp(ct->sid->str, lig(j).sid->str) == 0)
|
||||||
|
{
|
||||||
|
if(ct->number_of_teams == -1)
|
||||||
|
for(k=0;k<lig(j).teams->len;k++)
|
||||||
|
g_ptr_array_add(teams, &g_array_index(lig(j).teams, Team, k));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gint order[ct->end_idx - ct->start_idx + 1];
|
||||||
|
|
||||||
|
for(k=0;k<ct->end_idx - ct->start_idx + 1;k++)
|
||||||
|
order[k] = k;
|
||||||
|
|
||||||
|
if(ct->randomly)
|
||||||
|
math_generate_permutation(order, 0, ct->end_idx - ct->start_idx);
|
||||||
|
|
||||||
|
for(k=0;k<ct->number_of_teams;k++)
|
||||||
|
g_ptr_array_add(teams, &g_array_index(lig(j).teams, Team, order[k]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return teams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the pointer to the team belonging to
|
||||||
|
the two ids.
|
||||||
|
@param clid The league/cup id of the team.
|
||||||
|
@param id The id of the team.
|
||||||
|
@return The pointer to the team. */
|
||||||
|
Team*
|
||||||
|
team_get_pointer_from_ids(gint clid, gint id)
|
||||||
|
{
|
||||||
|
if(clid < ID_CUP_START)
|
||||||
|
return &g_array_index(lig(clid % 1000).teams, Team, id);
|
||||||
|
else
|
||||||
|
return &g_array_index(cp(clid % 1000).teams, Team, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the players of the team in a pointer array.
|
||||||
|
@param tm The team we examine.
|
||||||
|
@return The players of the team in an array. */
|
||||||
|
GPtrArray*
|
||||||
|
team_get_player_pointers(const Team *tm)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
GPtrArray *players = g_ptr_array_new();
|
||||||
|
|
||||||
|
for(i=0;i<tm->players->len;i++)
|
||||||
|
g_ptr_array_add(players, (gpointer)&g_array_index(tm->players, Player, i));
|
||||||
|
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a pointer to the next fixture the team plays in.
|
||||||
|
@param tm The team we examine.
|
||||||
|
@return The pointer to the fixture or NULL if none is found. */
|
||||||
|
Fixture*
|
||||||
|
team_get_next_fixture(const Team *tm)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
Fixture *fix = NULL;
|
||||||
|
|
||||||
|
for(i=0;i<ligs->len;i++)
|
||||||
|
{
|
||||||
|
if(lig(i).id == tm->clid)
|
||||||
|
{
|
||||||
|
for(j=0;j<lig(i).fixtures->len;j++)
|
||||||
|
if((g_array_index(lig(i).fixtures, Fixture, j).teams[0] == tm ||
|
||||||
|
g_array_index(lig(i).fixtures, Fixture, j).teams[1] == tm) &&
|
||||||
|
(fix == NULL || query_fixture_is_earlier(fix, &g_array_index(lig(i).fixtures, Fixture, j))))
|
||||||
|
fix = &g_array_index(lig(i).fixtures, Fixture, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0;i<cps->len;i++)
|
||||||
|
{
|
||||||
|
if(cp(i).type == CUP_TYPE_NATIONAL ||
|
||||||
|
query_is_in_cup(tm, &cp(i)))
|
||||||
|
{
|
||||||
|
for(j=0;j<cp(i).fixtures->len;j++)
|
||||||
|
if((g_array_index(cp(i).fixtures, Fixture, j).teams[0] == tm ||
|
||||||
|
g_array_index(cp(i).fixtures, Fixture, j).teams[1] == tm) &&
|
||||||
|
(fix == NULL || query_fixture_is_earlier(fix, &g_array_index(cp(i).fixtures, Fixture, j))))
|
||||||
|
fix = &g_array_index(cp(i).fixtures, Fixture, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Calculate the average cskill of the first 11 players.
|
||||||
|
@param tm The team we examine.
|
||||||
|
@return The average skill. */
|
||||||
|
gfloat
|
||||||
|
team_average_cskill(const Team *tm)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
gfloat sum = 0;
|
||||||
|
|
||||||
|
for(i=0;i<MIN(11, tm->players->len);i++)
|
||||||
|
sum += ((gfloat)player_of(tm, i)->cskill * powf((gfloat)player_of(tm, i)->fitness / 100, 0.25));
|
||||||
|
|
||||||
|
return sum / (gfloat)(i - 1);
|
||||||
|
}
|
||||||
|
30
src/team.h
30
src/team.h
@@ -2,6 +2,8 @@
|
|||||||
#define TEAM_H
|
#define TEAM_H
|
||||||
|
|
||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
|
#include "cup_struct.h"
|
||||||
|
#include "fixture_struct.h"
|
||||||
#include "team_struct.h"
|
#include "team_struct.h"
|
||||||
|
|
||||||
/** Maximum number of players in a team. */
|
/** Maximum number of players in a team. */
|
||||||
@@ -20,7 +22,7 @@ Stadium
|
|||||||
team_stadium_new(void);
|
team_stadium_new(void);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
is_my_team(const Team *tm);
|
query_is_my_team(const Team *tm);
|
||||||
|
|
||||||
void
|
void
|
||||||
team_generate_players(Team *tm);
|
team_generate_players(Team *tm);
|
||||||
@@ -28,6 +30,9 @@ team_generate_players(Team *tm);
|
|||||||
gint
|
gint
|
||||||
team_return_league_cup_value_int(const Team *tm, gint value_type);
|
team_return_league_cup_value_int(const Team *tm, gint value_type);
|
||||||
|
|
||||||
|
void
|
||||||
|
team_get_league_cup_string(const Team *tm, gint value_type, gchar *buf);
|
||||||
|
|
||||||
void
|
void
|
||||||
team_copy(const Team *source, Team *dest);
|
team_copy(const Team *source, Team *dest);
|
||||||
|
|
||||||
@@ -38,6 +43,27 @@ void
|
|||||||
team_append_to_array_with_ids(const Team *tm, GArray *teams_array, gint clid, gint id);
|
team_append_to_array_with_ids(const Team *tm, GArray *teams_array, gint clid, gint id);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
is_in_international_cups(const Team *tm);
|
query_is_in_international_cups(const Team *tm);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
query_is_in_cup(const Team *tm, const Cup *cup);
|
||||||
|
|
||||||
|
GPtrArray*
|
||||||
|
team_get_pointers_from_array(const GArray *teams);
|
||||||
|
|
||||||
|
GPtrArray*
|
||||||
|
team_get_pointers_from_choose_teams(const GArray *choose_teams);
|
||||||
|
|
||||||
|
Team*
|
||||||
|
team_get_pointer_from_ids(gint clid, gint id);
|
||||||
|
|
||||||
|
GPtrArray*
|
||||||
|
team_get_player_pointers(const Team *tm);
|
||||||
|
|
||||||
|
Fixture*
|
||||||
|
team_get_next_fixture(const Team *tm);
|
||||||
|
|
||||||
|
gfloat
|
||||||
|
team_average_cskill(const Team *tm);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
#ifndef TEAM_STRUCT_H
|
#ifndef TEAM_STRUCT_H
|
||||||
#define TEAM_STRUCT_H
|
#define TEAM_STRUCT_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Playing styles for teams.
|
Playing styles for teams.
|
||||||
@see The match result calculating functions.
|
@see The match result calculating functions.
|
||||||
@@ -51,6 +53,7 @@ typedef struct
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GString *name;
|
GString *name;
|
||||||
|
GString *symbol;
|
||||||
|
|
||||||
gint clid, /**< Numerical id of the league or cup the team belongs to. */
|
gint clid, /**< Numerical id of the league or cup the team belongs to. */
|
||||||
id, /**< Id of the team. */
|
id, /**< Id of the team. */
|
||||||
|
542
src/treeview.c
542
src/treeview.c
@@ -1,10 +1,18 @@
|
|||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "file.h"
|
||||||
|
#include "free.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "league.h"
|
#include "league.h"
|
||||||
|
#include "live_game.h"
|
||||||
|
#include "maths.h"
|
||||||
|
#include "misc.h"
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
#include "team.h"
|
#include "team.h"
|
||||||
#include "treeview.h"
|
#include "treeview.h"
|
||||||
|
#include "treeview_cell.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
/** Return the number in the 'column'th column of the currently
|
/** Return the number in the 'column'th column of the currently
|
||||||
selected row of the treeview.
|
selected row of the treeview.
|
||||||
@@ -29,6 +37,30 @@ treeview_get_index(GtkTreeView *treeview, gint column)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return the pointer in the 'column'th column of the currently
|
||||||
|
selected row of the treeview.
|
||||||
|
@param treeview The treeview argument.
|
||||||
|
@param column The column we'd like to get the content of.
|
||||||
|
@return The pointer in the given column of the selected row.
|
||||||
|
*/
|
||||||
|
/*d*/
|
||||||
|
gpointer
|
||||||
|
treeview_get_pointer(GtkTreeView *treeview, gint column)
|
||||||
|
{
|
||||||
|
gpointer ptr;
|
||||||
|
GtkTreeSelection *selection =
|
||||||
|
gtk_tree_view_get_selection(treeview);
|
||||||
|
GtkTreeModel *model;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
gtk_tree_selection_get_selected(selection, &model, &iter);
|
||||||
|
|
||||||
|
gtk_tree_model_get(model, &iter, column,
|
||||||
|
&ptr, -1);
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all columns from a GTK treeview. I didn't find a better way
|
* Removes all columns from a GTK treeview. I didn't find a better way
|
||||||
* to completely clear a treeview :-/.
|
* to completely clear a treeview :-/.
|
||||||
@@ -58,6 +90,25 @@ treeview_clear(GtkTreeView *treeview)
|
|||||||
i));
|
i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return number of given column or -1 if not found or on error.
|
||||||
|
@param col The column pointer.
|
||||||
|
@return The index of the column within the treeview. */
|
||||||
|
gint
|
||||||
|
treeview_get_col_number_column (GtkTreeViewColumn *col)
|
||||||
|
{
|
||||||
|
GList *cols;
|
||||||
|
gint num;
|
||||||
|
|
||||||
|
g_return_val_if_fail ( col != NULL, -1 );
|
||||||
|
g_return_val_if_fail ( col->tree_view != NULL, -1 );
|
||||||
|
|
||||||
|
cols = gtk_tree_view_get_columns(GTK_TREE_VIEW(col->tree_view));
|
||||||
|
num = g_list_index(cols, (gpointer) col);
|
||||||
|
g_list_free(cols);
|
||||||
|
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates the model for the treeview in the team selection window.
|
Creates the model for the treeview in the team selection window.
|
||||||
The model contains a list of all the teams from the leagues in
|
The model contains a list of all the teams from the leagues in
|
||||||
@@ -70,30 +121,80 @@ treeview_clear(GtkTreeView *treeview)
|
|||||||
GtkTreeModel*
|
GtkTreeModel*
|
||||||
treeview_create_team_selection_list(gboolean show_cup_teams)
|
treeview_create_team_selection_list(gboolean show_cup_teams)
|
||||||
{
|
{
|
||||||
gint i, j;
|
gint i, j, cnt = 1;
|
||||||
GtkListStore *liststore;
|
GtkListStore *liststore;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
GdkPixbuf *symbol = NULL;
|
||||||
|
GError *error = NULL;
|
||||||
|
gchar *symbol_file = NULL;
|
||||||
|
|
||||||
liststore = gtk_list_store_new(4,
|
liststore = gtk_list_store_new(4,
|
||||||
G_TYPE_INT,
|
G_TYPE_INT,
|
||||||
G_TYPE_INT,
|
GDK_TYPE_PIXBUF,
|
||||||
G_TYPE_STRING,
|
G_TYPE_POINTER,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
|
|
||||||
for(i=0;i<ligs->len;i++)
|
for(i=0;i<ligs->len;i++)
|
||||||
{
|
{
|
||||||
|
if(strlen(lig(i).symbol->str) != 0)
|
||||||
|
{
|
||||||
|
symbol_file = file_find_support_file(lig(i).symbol->str);
|
||||||
|
if(symbol_file != NULL)
|
||||||
|
{
|
||||||
|
symbol = gdk_pixbuf_new_from_file(symbol_file, &error);
|
||||||
|
g_free(symbol_file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
symbol = NULL;
|
||||||
|
misc_print_error(&error, FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
symbol = NULL;
|
||||||
|
|
||||||
for(j=0;j<lig(i).teams->len;j++)
|
for(j=0;j<lig(i).teams->len;j++)
|
||||||
{
|
{
|
||||||
gtk_list_store_append(liststore, &iter);
|
gtk_list_store_append(liststore, &iter);
|
||||||
gtk_list_store_set(liststore, &iter,
|
gtk_list_store_set(liststore, &iter,
|
||||||
0, lig(i).id,
|
0, cnt++,
|
||||||
1, g_array_index(lig(i).teams, Team, j).id,
|
1, symbol,
|
||||||
2, g_array_index(lig(i).teams, Team, j).name->str,
|
2, (gpointer)&g_array_index(lig(i).teams, Team, j),
|
||||||
3, lig(i).name->str,
|
3, lig(i).name->str,
|
||||||
-1);
|
-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!show_cup_teams)
|
||||||
|
return GTK_TREE_MODEL(liststore);
|
||||||
|
|
||||||
|
for(i=0;i<cps->len;i++)
|
||||||
|
if(cp(i).type == CUP_TYPE_INTERNATIONAL)
|
||||||
|
for(j=0;j<cp(i).teams->len;j++)
|
||||||
|
{
|
||||||
|
if(strlen(g_array_index(cp(i).teams, Team, j).symbol->str) != 0)
|
||||||
|
{
|
||||||
|
symbol_file =
|
||||||
|
file_find_support_file(g_array_index(cp(i).teams, Team, j).symbol->str);
|
||||||
|
if(symbol_file != NULL)
|
||||||
|
{
|
||||||
|
symbol = gdk_pixbuf_new_from_file(symbol_file, &error);
|
||||||
|
g_free(symbol_file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
symbol = NULL;
|
||||||
|
misc_print_error(&error, FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
symbol = NULL;
|
||||||
|
|
||||||
|
gtk_list_store_append(liststore, &iter);
|
||||||
|
gtk_list_store_set(liststore, &iter,
|
||||||
|
0, cnt++,
|
||||||
|
1, symbol,
|
||||||
|
2, (gpointer)&g_array_index(cp(i).teams, Team, j),
|
||||||
|
3, cp(i).name->str,
|
||||||
|
-1);
|
||||||
|
}
|
||||||
|
|
||||||
return GTK_TREE_MODEL(liststore);
|
return GTK_TREE_MODEL(liststore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,9 +215,8 @@ treeview_set_up_team_selection_treeview (GtkTreeView *treeview)
|
|||||||
|
|
||||||
gtk_tree_view_set_rules_hint(treeview, TRUE);
|
gtk_tree_view_set_rules_hint(treeview, TRUE);
|
||||||
|
|
||||||
/* League id column */
|
/* Numbering the teams */
|
||||||
col = gtk_tree_view_column_new();
|
col = gtk_tree_view_column_new();
|
||||||
gtk_tree_view_column_set_title(col, _("LID"));
|
|
||||||
gtk_tree_view_append_column(treeview, col);
|
gtk_tree_view_append_column(treeview, col);
|
||||||
renderer = gtk_cell_renderer_text_new();
|
renderer = gtk_cell_renderer_text_new();
|
||||||
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
@@ -125,31 +225,26 @@ treeview_set_up_team_selection_treeview (GtkTreeView *treeview)
|
|||||||
if(strcmp(font_name->str, "0") != 0)
|
if(strcmp(font_name->str, "0") != 0)
|
||||||
g_object_set(renderer, "font", font_name->str, NULL);
|
g_object_set(renderer, "font", font_name->str, NULL);
|
||||||
|
|
||||||
/* Team id column */
|
/* Flags */
|
||||||
col = gtk_tree_view_column_new();
|
col = gtk_tree_view_column_new();
|
||||||
gtk_tree_view_column_set_title(col, _("TID"));
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_pixbuf_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
|
gtk_tree_view_column_add_attribute(col, renderer,
|
||||||
|
"pixbuf", 1);
|
||||||
|
|
||||||
|
/* Team column */
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_column_set_title(col, _("Team"));
|
||||||
gtk_tree_view_append_column(treeview, col);
|
gtk_tree_view_append_column(treeview, col);
|
||||||
renderer = gtk_cell_renderer_text_new();
|
renderer = gtk_cell_renderer_text_new();
|
||||||
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
gtk_tree_view_column_add_attribute(col, renderer,
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
||||||
"text", 1);
|
treeview_cell_team_selection,
|
||||||
if(strcmp(font_name->str, "0") != 0)
|
GINT_TO_POINTER(2), NULL);
|
||||||
g_object_set(renderer, "font", font_name->str, NULL);
|
/* League column */
|
||||||
|
|
||||||
/* Team name column */
|
|
||||||
col = gtk_tree_view_column_new();
|
col = gtk_tree_view_column_new();
|
||||||
gtk_tree_view_column_set_title(col, _("Team name"));
|
gtk_tree_view_column_set_title(col, _("League"));
|
||||||
gtk_tree_view_append_column(treeview, col);
|
|
||||||
renderer = gtk_cell_renderer_text_new();
|
|
||||||
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
||||||
gtk_tree_view_column_add_attribute(col, renderer,
|
|
||||||
"text", 2);
|
|
||||||
if(strcmp(font_name->str, "0") != 0)
|
|
||||||
g_object_set(renderer, "font", font_name->str, NULL);
|
|
||||||
|
|
||||||
/* league column */
|
|
||||||
col = gtk_tree_view_column_new();
|
|
||||||
gtk_tree_view_column_set_title(col, _("League name"));
|
|
||||||
gtk_tree_view_append_column(treeview, col);
|
gtk_tree_view_append_column(treeview, col);
|
||||||
renderer = gtk_cell_renderer_text_new();
|
renderer = gtk_cell_renderer_text_new();
|
||||||
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
@@ -182,3 +277,392 @@ treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams)
|
|||||||
gtk_tree_path_new_from_string("0"));
|
gtk_tree_path_new_from_string("0"));
|
||||||
g_object_unref(team_list);
|
g_object_unref(team_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Create the list store for a player list.
|
||||||
|
@param players The array containing the players.
|
||||||
|
@param attributes An array containing the attributes we show.
|
||||||
|
@param max The size of the attribute array.
|
||||||
|
@param separator Whether we draw a blank line after the 11th player. */
|
||||||
|
GtkTreeModel*
|
||||||
|
treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboolean show_separator)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
GtkListStore *liststore;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GType types[max + 1];
|
||||||
|
|
||||||
|
types[0] = G_TYPE_INT;
|
||||||
|
for(i=0;i<max;i++)
|
||||||
|
types[i + 1] = G_TYPE_POINTER;
|
||||||
|
|
||||||
|
liststore = gtk_list_store_newv(max + 1, types);
|
||||||
|
|
||||||
|
for(i=0;i<players->len;i++)
|
||||||
|
{
|
||||||
|
gtk_list_store_append(liststore, &iter);
|
||||||
|
if(show_separator && i == 11)
|
||||||
|
{
|
||||||
|
gtk_list_store_set(liststore, &iter, 0, CONSTANT_TREEVIEW_CELL_INT_EMPTY, -1);
|
||||||
|
for(j=0;j<max;j++)
|
||||||
|
gtk_list_store_set(liststore, &iter, j + 1, NULL, -1);
|
||||||
|
|
||||||
|
gtk_list_store_append(liststore, &iter);
|
||||||
|
gtk_list_store_set(liststore, &iter, 0, i + 1, -1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
gtk_list_store_set(liststore, &iter, 0, i + 1, -1);
|
||||||
|
|
||||||
|
for(j=0;j<max;j++)
|
||||||
|
gtk_list_store_set(liststore, &iter, j + 1, g_ptr_array_index(players, i), -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (GtkTreeModel*)liststore;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set up the tree view for a player list */
|
||||||
|
void
|
||||||
|
treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
GtkTreeViewColumn *col;
|
||||||
|
GtkCellRenderer *renderer;
|
||||||
|
gchar *titles[PLAYER_LIST_ATTRIBUTE_END] =
|
||||||
|
{_("Name"),
|
||||||
|
_("CPos"),
|
||||||
|
_("Pos"),
|
||||||
|
_("CSk"),
|
||||||
|
_("Sk"),
|
||||||
|
_("Fit"),
|
||||||
|
_("Ga"),
|
||||||
|
_("Go"),
|
||||||
|
_("Status"),
|
||||||
|
_("YC"),
|
||||||
|
_("Age"),
|
||||||
|
_("Etal"),
|
||||||
|
_("Value"),
|
||||||
|
_("Wage"),
|
||||||
|
_("Contract"),
|
||||||
|
_("Team"),
|
||||||
|
_("League")};
|
||||||
|
|
||||||
|
gtk_tree_selection_set_mode(
|
||||||
|
gtk_tree_view_get_selection(treeview),
|
||||||
|
GTK_SELECTION_SINGLE);
|
||||||
|
|
||||||
|
/* number the players */
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
||||||
|
treeview_cell_int_to_cell,
|
||||||
|
NULL, NULL);
|
||||||
|
for(i=0;i<max;i++)
|
||||||
|
{
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_column_set_title(col, titles[attributes[i]]);
|
||||||
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
||||||
|
treeview_cell_player_to_cell,
|
||||||
|
GINT_TO_POINTER(attributes[i]),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if(attributes[i] != PLAYER_LIST_ATTRIBUTE_NAME)
|
||||||
|
{
|
||||||
|
gtk_tree_view_column_set_alignment(col, 0.5);
|
||||||
|
g_object_set(renderer, "xalign", 0.5,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Fill a treeview with the players from the pointer array. Show
|
||||||
|
player attributes according to 'attrib'.
|
||||||
|
@param treeview The treeview we fill.
|
||||||
|
@param players The pointer array with the players. We free it afterwards.
|
||||||
|
@param attrib The #PlayerListAttrib that determines which attributes to show.
|
||||||
|
@param show_separator Whether we draw a blank line after the 11th player. */
|
||||||
|
void
|
||||||
|
treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListAttribute attribute,
|
||||||
|
gboolean show_separator)
|
||||||
|
{
|
||||||
|
gint i, cnt = 0;
|
||||||
|
gint columns = math_sum_int_array(attribute.on_off, PLAYER_LIST_ATTRIBUTE_END);
|
||||||
|
gint attributes[columns];
|
||||||
|
GtkTreeModel *model = NULL;
|
||||||
|
|
||||||
|
treeview_clear(treeview);
|
||||||
|
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
||||||
|
|
||||||
|
for(i=0;i<PLAYER_LIST_ATTRIBUTE_END;i++)
|
||||||
|
if(attribute.on_off[i])
|
||||||
|
attributes[cnt++] = i;
|
||||||
|
|
||||||
|
treeview_set_up_player_list(treeview, attributes, columns);
|
||||||
|
|
||||||
|
model = treeview_create_player_list(players, attributes, columns, show_separator);
|
||||||
|
|
||||||
|
gtk_tree_view_set_model(treeview, model);
|
||||||
|
g_object_unref(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Show the list of the user's players in the left view.
|
||||||
|
@param player_list The tab we use. */
|
||||||
|
void
|
||||||
|
treeview_show_user_player_list(gint player_list)
|
||||||
|
{
|
||||||
|
GtkWidget *treeview = (player_list == 1) ?
|
||||||
|
lookup_widget(main_window, "player_list1") :
|
||||||
|
lookup_widget(main_window, "player_list2");
|
||||||
|
|
||||||
|
treeview_show_player_list(GTK_TREE_VIEW(treeview), team_get_player_pointers(my_team),
|
||||||
|
player_list_attributes[(player_list != 1)], TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Show a live game unit in the live game window.
|
||||||
|
@param unit The unit we show. */
|
||||||
|
void
|
||||||
|
treeview_live_game_show_game_unit(const LiveGameUnit *unit)
|
||||||
|
{
|
||||||
|
GtkProgressBar *progress_bar;
|
||||||
|
|
||||||
|
if(live_game.window == NULL)
|
||||||
|
{
|
||||||
|
live_game.window = window_create(WINDOW_LIVE);
|
||||||
|
treeview_live_game_show_initial_commentary(unit);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
treeview_live_game_show_commentary(unit);
|
||||||
|
|
||||||
|
treeview_live_game_show_result(unit);
|
||||||
|
|
||||||
|
progress_bar = GTK_PROGRESS_BAR(lookup_widget(live_game.window, "progressbar_live"));
|
||||||
|
gtk_progress_bar_set_fraction(progress_bar, (gfloat)live_game_unit_get_minute(unit) / 120);
|
||||||
|
usleep(500);
|
||||||
|
while(gtk_events_pending())
|
||||||
|
gtk_main_iteration();
|
||||||
|
|
||||||
|
if(unit->event.type == LIVE_GAME_EVENT_END_MATCH)
|
||||||
|
gtk_widget_set_sensitive(lookup_widget(live_game.window, "button_live_close"), TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Show the commentary and the minute belonging to the unit.
|
||||||
|
@param unit The #LiveGameUnit we show. */
|
||||||
|
void
|
||||||
|
treeview_live_game_show_commentary(const LiveGameUnit *unit)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adjustment =
|
||||||
|
gtk_scrolled_window_get_vadjustment(
|
||||||
|
GTK_SCROLLED_WINDOW(lookup_widget(live_game.window,
|
||||||
|
"scrolledwindow9")));
|
||||||
|
GtkListStore *liststore =
|
||||||
|
GTK_LIST_STORE(
|
||||||
|
gtk_tree_view_get_model(GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_commentary"))));
|
||||||
|
GtkTreeIter iter;
|
||||||
|
gchar buf[SMALL];
|
||||||
|
|
||||||
|
sprintf(buf, "%d.", live_game_unit_get_minute(unit));
|
||||||
|
gtk_list_store_prepend(liststore, &iter);
|
||||||
|
gtk_list_store_set(liststore, &iter, 0, buf, 1, NULL,
|
||||||
|
2, unit->event.commentary->str, -1);
|
||||||
|
|
||||||
|
adjustment->value = adjustment->lower - adjustment->page_size;
|
||||||
|
gtk_adjustment_value_changed(adjustment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create the list store for the live game
|
||||||
|
commentary treeview.
|
||||||
|
@param unit The unit we show.
|
||||||
|
@return The liststore. */
|
||||||
|
GtkTreeModel*
|
||||||
|
treeview_live_game_create_init_commentary(const LiveGameUnit *unit)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
GtkListStore *liststore;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GdkPixbuf *symbol = NULL;
|
||||||
|
GError *error = NULL;
|
||||||
|
gchar *symbol_file = NULL;
|
||||||
|
gchar buf[SMALL];
|
||||||
|
|
||||||
|
liststore = gtk_list_store_new(3,
|
||||||
|
G_TYPE_STRING,
|
||||||
|
GDK_TYPE_PIXBUF,
|
||||||
|
G_TYPE_STRING);
|
||||||
|
|
||||||
|
sprintf(buf, "%d.", unit->minute);
|
||||||
|
/*todo: icons*/
|
||||||
|
gtk_list_store_append(liststore, &iter);
|
||||||
|
gtk_list_store_set(liststore, &iter, 0, buf, 1, NULL, 2,
|
||||||
|
unit->event.commentary->str, -1);
|
||||||
|
|
||||||
|
return GTK_TREE_MODEL(liststore);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set up the commentary treeview for the live game. */
|
||||||
|
void
|
||||||
|
treeview_live_game_set_up_commentary(void)
|
||||||
|
{
|
||||||
|
GtkTreeView *treeview =
|
||||||
|
GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_commentary"));
|
||||||
|
GtkTreeViewColumn *col;
|
||||||
|
GtkCellRenderer *renderer;
|
||||||
|
|
||||||
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
||||||
|
GTK_SELECTION_NONE);
|
||||||
|
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
|
gtk_tree_view_column_add_attribute(col, renderer,
|
||||||
|
"text", 0);
|
||||||
|
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_pixbuf_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
|
gtk_tree_view_column_add_attribute(col, renderer,
|
||||||
|
"pixbuf", 1);
|
||||||
|
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
|
gtk_tree_view_column_add_attribute(col, renderer,
|
||||||
|
"text", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Show the first commentary of the live game
|
||||||
|
@param unit The #LiveGameUnit we show. */
|
||||||
|
void
|
||||||
|
treeview_live_game_show_initial_commentary(const LiveGameUnit *unit)
|
||||||
|
{
|
||||||
|
GtkTreeView *treeview =
|
||||||
|
GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_commentary"));
|
||||||
|
GtkTreeModel *model = NULL;
|
||||||
|
|
||||||
|
treeview_clear(treeview);
|
||||||
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
||||||
|
|
||||||
|
treeview_live_game_set_up_commentary();
|
||||||
|
|
||||||
|
model = treeview_live_game_create_init_commentary(unit);
|
||||||
|
|
||||||
|
gtk_tree_view_set_model(treeview, model);
|
||||||
|
g_object_unref(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Fill the liststore for the live game result treeview.
|
||||||
|
@param unit The current live game unit.
|
||||||
|
@return The liststore we created. */
|
||||||
|
GtkTreeModel*
|
||||||
|
treeview_live_game_create_result(const LiveGameUnit *unit)
|
||||||
|
{
|
||||||
|
GtkListStore *liststore;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GdkPixbuf *symbol = NULL;
|
||||||
|
GError *error = NULL;
|
||||||
|
gchar *symbol_file = NULL;
|
||||||
|
|
||||||
|
symbol_file =
|
||||||
|
file_find_support_file("possession_ball.png");
|
||||||
|
if(symbol_file != NULL)
|
||||||
|
{
|
||||||
|
symbol = gdk_pixbuf_new_from_file(symbol_file, &error);
|
||||||
|
g_free(symbol_file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
symbol = NULL;
|
||||||
|
misc_print_error(&error, FALSE);
|
||||||
|
|
||||||
|
liststore = gtk_list_store_new(5,
|
||||||
|
GDK_TYPE_PIXBUF,
|
||||||
|
G_TYPE_POINTER,
|
||||||
|
G_TYPE_POINTER,
|
||||||
|
G_TYPE_POINTER,
|
||||||
|
GDK_TYPE_PIXBUF);
|
||||||
|
|
||||||
|
gtk_list_store_append(liststore, &iter);
|
||||||
|
gtk_list_store_set(liststore, &iter, 0, NULL, 1, (gpointer)live_game.fix,
|
||||||
|
2, (gpointer)live_game.fix, 3, (gpointer)live_game.fix, 4, NULL, -1);
|
||||||
|
|
||||||
|
gtk_list_store_set(liststore, &iter, 0 + (unit->possession == 1) * 4, symbol, -1);
|
||||||
|
|
||||||
|
return GTK_TREE_MODEL(liststore);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set up the treeview columns for the result. */
|
||||||
|
void
|
||||||
|
treeview_live_game_set_up_result(void)
|
||||||
|
{
|
||||||
|
GtkTreeView *treeview =
|
||||||
|
GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_result"));
|
||||||
|
GtkTreeViewColumn *col;
|
||||||
|
GtkCellRenderer *renderer;
|
||||||
|
|
||||||
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
||||||
|
GTK_SELECTION_NONE);
|
||||||
|
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_pixbuf_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
||||||
|
gtk_tree_view_column_add_attribute(col, renderer,
|
||||||
|
"pixbuf", 0);
|
||||||
|
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
||||||
|
treeview_cell_live_game_result,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
||||||
|
treeview_cell_live_game_result,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
||||||
|
treeview_cell_live_game_result,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_append_column(treeview, col);
|
||||||
|
renderer = gtk_cell_renderer_pixbuf_new();
|
||||||
|
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
||||||
|
gtk_tree_view_column_add_attribute(col, renderer,
|
||||||
|
"pixbuf", 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Write the current result of the live game into
|
||||||
|
the corresponding treeview.
|
||||||
|
@param unit The current live game unit. */
|
||||||
|
void
|
||||||
|
treeview_live_game_show_result(const LiveGameUnit *unit)
|
||||||
|
{
|
||||||
|
GtkTreeView *treeview =
|
||||||
|
GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_result"));
|
||||||
|
GtkTreeModel *model = NULL;
|
||||||
|
|
||||||
|
treeview_clear(treeview);
|
||||||
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
||||||
|
|
||||||
|
treeview_live_game_set_up_result();
|
||||||
|
|
||||||
|
model = treeview_live_game_create_result(unit);
|
||||||
|
|
||||||
|
gtk_tree_view_set_model(treeview, model);
|
||||||
|
g_object_unref(model);
|
||||||
|
}
|
||||||
|
@@ -2,13 +2,21 @@
|
|||||||
#define TREEVIEW_H
|
#define TREEVIEW_H
|
||||||
|
|
||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
|
#include "live_game_struct.h"
|
||||||
|
#include "player_struct.h"
|
||||||
|
|
||||||
gint
|
gint
|
||||||
treeview_get_index(GtkTreeView *treeview, gint column);
|
treeview_get_index(GtkTreeView *treeview, gint column);
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
treeview_get_pointer(GtkTreeView *treeview, gint column);
|
||||||
|
|
||||||
void
|
void
|
||||||
treeview_clear(GtkTreeView *treeview);
|
treeview_clear(GtkTreeView *treeview);
|
||||||
|
|
||||||
|
gint
|
||||||
|
treeview_get_col_number_column (GtkTreeViewColumn *col);
|
||||||
|
|
||||||
GtkTreeModel*
|
GtkTreeModel*
|
||||||
treeview_create_team_selection_list(gboolean show_cup_teams);
|
treeview_create_team_selection_list(gboolean show_cup_teams);
|
||||||
|
|
||||||
@@ -18,4 +26,44 @@ treeview_set_up_team_selection_treeview (GtkTreeView *treeview);
|
|||||||
void
|
void
|
||||||
treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams);
|
treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams);
|
||||||
|
|
||||||
|
GtkTreeModel*
|
||||||
|
treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboolean show_separator);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListAttribute attribute,
|
||||||
|
gboolean show_separator);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_show_user_player_list(gint player_list);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_live_game_show_game_unit(const LiveGameUnit *unit);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_live_game_show_commentary(const LiveGameUnit *unit);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_live_game_show_initial_commentary(const LiveGameUnit *unit);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_live_game_show_teams(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_live_game_set_up_commentary(void);
|
||||||
|
|
||||||
|
GtkTreeModel*
|
||||||
|
treeview_live_game_create_init_commentary(const LiveGameUnit *unit);
|
||||||
|
|
||||||
|
GtkTreeModel*
|
||||||
|
treeview_live_game_create_result(const LiveGameUnit *unit);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_live_game_set_up_result(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_live_game_show_result(const LiveGameUnit *unit);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -0,0 +1,421 @@
|
|||||||
|
#include "maths.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include "team.h"
|
||||||
|
#include "treeview.h"
|
||||||
|
#include "treeview_cell.h"
|
||||||
|
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_BG "Black"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_FG "White"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_DEFENDER_BG "Darkgreen"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_DEFENDER_FG "White"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_MIDFIELDER_BG "Darkblue"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_MIDFIELDER_FG "White"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_FORWARD_BG "Darkred"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_FORWARD_FG "White"
|
||||||
|
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_INJURY "Lightgreen"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BANNED "Red"
|
||||||
|
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW1 85
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW2 70
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW3 60
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_NORMAL "DarkGreen"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW1 "DarkOrange"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW2 "OrangeRed"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW3 "Red"
|
||||||
|
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW1 52
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW2 40
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW3 20
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_NORMAL "DarkGreen"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW1 "DarkOrange"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW2 "OrangeRed"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW3 "Red"
|
||||||
|
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BAD_CSKILL_BG "Lightblue"
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BAD_CSKILL_FG "Red"
|
||||||
|
|
||||||
|
/** Font attributes for the live game window result. */
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_LIVE_GAME_RESULT_ATTRIBUTES "weight='bold' size='large'"
|
||||||
|
|
||||||
|
/* #define CONSTANT_TREEVIEW_CELL_COLOR_ "" */
|
||||||
|
/* #define CONSTANT_TREEVIEW_CELL_COLOR_ "" */
|
||||||
|
/* #define CONSTANT_TREEVIEW_CELL_COLOR_ "" */
|
||||||
|
/* #define CONSTANT_TREEVIEW_CELL_COLOR_ "" */
|
||||||
|
|
||||||
|
|
||||||
|
/** Render a cell in the team selection treeview.
|
||||||
|
@see The GTK reference. */
|
||||||
|
void
|
||||||
|
treeview_cell_team_selection(GtkTreeViewColumn *col,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gint column = GPOINTER_TO_INT(user_data);
|
||||||
|
gpointer team_pointer;
|
||||||
|
|
||||||
|
if(strcmp(font_name->str, "0") != 0)
|
||||||
|
g_object_set(renderer, "font", font_name->str, NULL);
|
||||||
|
|
||||||
|
gtk_tree_model_get(model, iter, column, &team_pointer, -1);
|
||||||
|
|
||||||
|
if(column == 2)
|
||||||
|
g_object_set(renderer, "text", ((Team*)team_pointer)->name->str, NULL);
|
||||||
|
else
|
||||||
|
g_warning("treeview_cell_team_selection: unknown column: %d\n", column);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Render an integer. This is only so that we know when to draw nothing.
|
||||||
|
@see #CONSTANT_TREEVIEW_CELL_INT_EMPTY */
|
||||||
|
void
|
||||||
|
treeview_cell_int_to_cell(GtkTreeViewColumn *col,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gint column = GPOINTER_TO_INT(user_data);
|
||||||
|
gint value;
|
||||||
|
gchar buf[SMALL];
|
||||||
|
|
||||||
|
if(strcmp(font_name->str, "0") != 0)
|
||||||
|
g_object_set(renderer, "font", font_name->str, NULL);
|
||||||
|
|
||||||
|
gtk_tree_model_get(model, iter, column, &value, -1);
|
||||||
|
|
||||||
|
if(value == CONSTANT_TREEVIEW_CELL_INT_EMPTY)
|
||||||
|
strcpy(buf, "");
|
||||||
|
else
|
||||||
|
sprintf(buf, "%d", value);
|
||||||
|
|
||||||
|
g_object_set(renderer, "text", buf, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Render a player list cell. */
|
||||||
|
void
|
||||||
|
treeview_cell_player_to_cell(GtkTreeViewColumn *col,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
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(font_name->str, "0") != 0)
|
||||||
|
g_object_set(renderer, "font", font_name->str, NULL);
|
||||||
|
|
||||||
|
strcpy(fg_color, "black");
|
||||||
|
strcpy(bg_color, "white");
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
strcpy(buf, pl->name->str);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_CPOS:
|
||||||
|
treeview_cell_player_pos_to_cell(renderer, buf, pl->cpos);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_POS:
|
||||||
|
treeview_cell_player_pos_to_cell(renderer, buf, pl->pos);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_CSKILL:
|
||||||
|
sprintf(buf, "%d", pl->cskill);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_SKILL:
|
||||||
|
sprintf(buf, "%d", pl->skill);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_FITNESS:
|
||||||
|
treeview_cell_player_fitness_to_cell(renderer, buf, pl->fitness);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_GAMES:
|
||||||
|
/*todo*/
|
||||||
|
treeview_cell_player_games_goals_to_cell(buf, pl, FALSE);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_GOALS:
|
||||||
|
treeview_cell_player_games_goals_to_cell(buf, pl, TRUE);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_STATUS:
|
||||||
|
treeview_cell_player_status_to_cell(renderer, buf, pl);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_CARDS:
|
||||||
|
treeview_cell_player_cards_to_cell(buf, pl);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_AGE:
|
||||||
|
sprintf(buf, "%d", (gint)rint((gfloat)pl->age / 52));
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_ETAL:
|
||||||
|
sprintf(buf, "%d", pl->etal);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_VALUE:
|
||||||
|
misc_print_grouped_int(pl->value, buf, FALSE);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_WAGE:
|
||||||
|
misc_print_grouped_int(pl->wage, buf, FALSE);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_CONTRACT:
|
||||||
|
treeview_cell_player_contract_to_cell(renderer, buf, pl->contract);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_TEAM:
|
||||||
|
sprintf(buf, "%s", pl->team->name->str);
|
||||||
|
break;
|
||||||
|
case PLAYER_LIST_ATTRIBUTE_LEAGUE_CUP:
|
||||||
|
team_get_league_cup_string(pl->team, LEAGUE_CUP_VALUE_NAME, buf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_set(renderer, "text", buf, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Render a cell of a player contract.
|
||||||
|
@param renderer The cell renderer.
|
||||||
|
@param buf The string the cell will contain.
|
||||||
|
@param contract_time The contract time in weeks. */
|
||||||
|
void
|
||||||
|
treeview_cell_player_contract_to_cell(GtkCellRenderer *renderer, gchar *buf, gint contract_time)
|
||||||
|
{
|
||||||
|
sprintf(buf, "%.1f", (gfloat)contract_time / 52);
|
||||||
|
|
||||||
|
if(contract_time < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW3)
|
||||||
|
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW3, NULL);
|
||||||
|
else if(contract_time < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW2)
|
||||||
|
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW2, NULL);
|
||||||
|
else if(contract_time < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW1)
|
||||||
|
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW1, NULL);
|
||||||
|
else
|
||||||
|
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_NORMAL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Render a cell of player yellow cards.
|
||||||
|
@param buf The string the cell will contain.
|
||||||
|
@param pl The pointer to the player. */
|
||||||
|
void
|
||||||
|
treeview_cell_player_cards_to_cell(gchar *buf, const Player *pl)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
Fixture *fix =
|
||||||
|
team_get_next_fixture(pl->team);
|
||||||
|
|
||||||
|
if(fix == NULL)
|
||||||
|
{
|
||||||
|
if(pl->cards->len == 0)
|
||||||
|
strcpy(buf, "0");
|
||||||
|
else
|
||||||
|
sprintf(buf, "%d(%d)", g_array_index(pl->cards, PlayerCard, 0).yellow,
|
||||||
|
player_all_cards(pl));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0;i<pl->cards->len;i++)
|
||||||
|
if(g_array_index(pl->cards, PlayerCard, 0).clid == fix->clid)
|
||||||
|
{
|
||||||
|
sprintf(buf, "%d(%d)", g_array_index(pl->cards, PlayerCard, i).yellow,
|
||||||
|
player_all_cards(pl));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(buf, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Render a cell of player status.
|
||||||
|
@param render The cell renderer.
|
||||||
|
@param buf The string the cell will contain.
|
||||||
|
@param pl The pointer to the player. */
|
||||||
|
void
|
||||||
|
treeview_cell_player_status_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
Fixture *fix = team_get_next_fixture(pl->team);
|
||||||
|
|
||||||
|
if(pl->health != PLAYER_INJURY_NONE)
|
||||||
|
{
|
||||||
|
sprintf(buf, _("INJ(%d)"), pl->recovery);
|
||||||
|
g_object_set(renderer, "background",
|
||||||
|
CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_INJURY, NULL);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fix == NULL)
|
||||||
|
{
|
||||||
|
strcpy(buf, "OK");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0;i<pl->cards->len;i++)
|
||||||
|
if(g_array_index(pl->cards, PlayerCard, 0).clid == fix->clid)
|
||||||
|
{
|
||||||
|
sprintf(buf, _("BAN(%d)"), g_array_index(pl->cards, PlayerCard, 0).red);
|
||||||
|
g_object_set(renderer, "background",
|
||||||
|
CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BANNED, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(buf, "OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Render a cell of player games or goals.
|
||||||
|
@param buf The string the cell will contain.
|
||||||
|
@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)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
Fixture *fix = team_get_next_fixture(pl->team);
|
||||||
|
|
||||||
|
if(fix == NULL)
|
||||||
|
{
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(buf, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Render a cell of player fitness.
|
||||||
|
@param render The cell renderer.
|
||||||
|
@param buf The string the cell will contain.
|
||||||
|
@param fitness The fitness of the player. */
|
||||||
|
void
|
||||||
|
treeview_cell_player_fitness_to_cell(GtkCellRenderer *renderer, gchar *buf, gint fitness)
|
||||||
|
{
|
||||||
|
sprintf(buf, "%d%%", fitness);
|
||||||
|
|
||||||
|
if(fitness < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW3)
|
||||||
|
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW3, NULL);
|
||||||
|
else if(fitness < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW2)
|
||||||
|
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW2, NULL);
|
||||||
|
else if(fitness < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW1)
|
||||||
|
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW1, NULL);
|
||||||
|
else
|
||||||
|
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_NORMAL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Render a cell of player position or cposition.
|
||||||
|
@param render The cell renderer.
|
||||||
|
@param buf The string the cell will contain.
|
||||||
|
@param pos The position of the player. */
|
||||||
|
void
|
||||||
|
treeview_cell_player_pos_to_cell(GtkCellRenderer *renderer, gchar *buf, gint pos)
|
||||||
|
{
|
||||||
|
switch(pos)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
strcpy(buf, "G");
|
||||||
|
g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_BG,
|
||||||
|
"foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_FG, NULL);
|
||||||
|
break;
|
||||||
|
case PLAYER_POS_DEFENDER:
|
||||||
|
strcpy(buf, "D");
|
||||||
|
g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_DEFENDER_BG,
|
||||||
|
"foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_DEFENDER_FG, NULL);
|
||||||
|
break;
|
||||||
|
case PLAYER_POS_MIDFIELDER:
|
||||||
|
strcpy(buf, "M");
|
||||||
|
g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_MIDFIELDER_BG,
|
||||||
|
"foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_MIDFIELDER_FG, NULL);
|
||||||
|
break;
|
||||||
|
case PLAYER_POS_FORWARD:
|
||||||
|
strcpy(buf, "F");
|
||||||
|
g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_FORWARD_BG,
|
||||||
|
"foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_FORWARD_FG, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Render a cell of player cskill.
|
||||||
|
@param render The cell renderer.
|
||||||
|
@param buf The string the cell will contain.
|
||||||
|
@param pl The pointer to the player. */
|
||||||
|
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,
|
||||||
|
CONSTANT_PLAYER_FITNESS_IMPACT_ON_SKILL)));
|
||||||
|
|
||||||
|
if(pl->cskill < pl->skill)
|
||||||
|
g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BAD_CSKILL_BG,
|
||||||
|
"foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BAD_CSKILL_FG, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Render the result (team names and goals) in the live game view. */
|
||||||
|
void
|
||||||
|
treeview_cell_live_game_result(GtkTreeViewColumn *col,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
gint i, result[2];
|
||||||
|
gint column = treeview_get_col_number_column(col);
|
||||||
|
gchar buf[SMALL];
|
||||||
|
Fixture *fix;
|
||||||
|
|
||||||
|
if(strcmp(font_name->str, "0") != 0)
|
||||||
|
g_object_set(renderer, "font", font_name->str, NULL);
|
||||||
|
|
||||||
|
strcpy(buf, "");
|
||||||
|
|
||||||
|
gtk_tree_model_get(model, iter, column, &fix, -1);
|
||||||
|
|
||||||
|
if(fix != NULL)
|
||||||
|
{
|
||||||
|
for(i=0;i<2;i++)
|
||||||
|
result[i] = math_sum_int_array(fix->result[i], 3);
|
||||||
|
|
||||||
|
if(column== 1 || column == 3)
|
||||||
|
sprintf(buf, "<span %s>%s</span>", CONSTANT_TREEVIEW_CELL_LIVE_GAME_RESULT_ATTRIBUTES,
|
||||||
|
fix->teams[column == 3]->name->str);
|
||||||
|
else
|
||||||
|
sprintf(buf, "<span %s>%d : %d</span>", CONSTANT_TREEVIEW_CELL_LIVE_GAME_RESULT_ATTRIBUTES,
|
||||||
|
result[0], result[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_set(renderer, "markup", buf, NULL);
|
||||||
|
}
|
||||||
|
@@ -0,0 +1,59 @@
|
|||||||
|
#ifndef TREEVIEW_CELL_H
|
||||||
|
#define TREEVIEW_CELL_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
|
#include "variables.h"
|
||||||
|
|
||||||
|
/** The integer that the cell data functions will interpret as an empty string. */
|
||||||
|
#define CONSTANT_TREEVIEW_CELL_INT_EMPTY -5
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_cell_team_selection(GtkTreeViewColumn *col,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
|
||||||
|
/** Render an integer. This is only so that we know when to draw nothing. */
|
||||||
|
void
|
||||||
|
treeview_cell_int_to_cell(GtkTreeViewColumn *col,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
/** Render a player list cell. */
|
||||||
|
void
|
||||||
|
treeview_cell_player_to_cell(GtkTreeViewColumn *col,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_cell_player_contract_to_cell(GtkCellRenderer *renderer, gchar *buf, gint contract_time);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_cell_player_cards_to_cell(gchar *buf, const Player *pl);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_cell_player_fitness_to_cell(GtkCellRenderer *renderer, gchar *buf, gint fitness);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_cell_player_pos_to_cell(GtkCellRenderer *renderer, gchar *buf, gint pos);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_cell_live_game_result(GtkTreeViewColumn *col,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
80
src/user.c
Normal file
80
src/user.c
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#include "league.h"
|
||||||
|
#include "maths.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include "support.h"
|
||||||
|
#include "team.h"
|
||||||
|
#include "user.h"
|
||||||
|
|
||||||
|
/** These determine how the initial money of the user
|
||||||
|
depends on the size of the stadium. */
|
||||||
|
#define CONSTANT_INITIAL_MONEY_LOWER 80
|
||||||
|
#define CONSTANT_INITIAL_MONEY_UPPER 110
|
||||||
|
|
||||||
|
/** Move the user's team to top or bottom league
|
||||||
|
at the beginning of a new game and set up the user's team. */
|
||||||
|
void
|
||||||
|
user_set_up_my_team_new_game(GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GtkWidget *radiobutton1 =
|
||||||
|
lookup_widget(widget, "team_selection_radio1");
|
||||||
|
GtkWidget *radiobutton2 =
|
||||||
|
lookup_widget(widget, "team_selection_radio2");
|
||||||
|
gchar buf[SMALL];
|
||||||
|
gint rndom, max, lig_idx = -1;
|
||||||
|
|
||||||
|
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton2)))
|
||||||
|
user_set_up_my_team();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton1)) &&
|
||||||
|
lig(0).id != my_team->clid)
|
||||||
|
lig_idx = 0;
|
||||||
|
else if(lig(ligs->len - 1).id != my_team->clid)
|
||||||
|
lig_idx = ligs->len - 1;
|
||||||
|
|
||||||
|
max = lig(lig_idx).teams->len - 1;
|
||||||
|
rndom = math_rndi(0, max);
|
||||||
|
sprintf(buf, "%s", g_array_index(lig(lig_idx).teams, Team, rndom).name->str);
|
||||||
|
g_string_printf(g_array_index(lig(lig_idx).teams, Team, rndom).name, "%s",
|
||||||
|
my_team->name->str);
|
||||||
|
g_string_printf(my_team->name, "%s", buf);
|
||||||
|
|
||||||
|
my_team = &g_array_index(lig(lig_idx).teams, Team, rndom);
|
||||||
|
|
||||||
|
user_set_up_my_team();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set up finances, reomve some players etc. for a new user team. */
|
||||||
|
void
|
||||||
|
user_set_up_my_team(void)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
|
||||||
|
for(i=PLAYER_POS_DEFENDER; i<=PLAYER_POS_FORWARD; i++)
|
||||||
|
for(j=my_team->players->len - 1; j > 10; j--)
|
||||||
|
if(g_array_index(my_team->players, Player, j).pos == i)
|
||||||
|
{
|
||||||
|
player_remove_from_team(my_team, j);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
scout = physio = QUALITY_AVERAGE;
|
||||||
|
|
||||||
|
user_set_up_finances();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set up the user's finances when he's got a new team.*/
|
||||||
|
void
|
||||||
|
user_set_up_finances(void)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
for(i=0; i<FIN_END;i++)
|
||||||
|
finances[i] = 0;
|
||||||
|
|
||||||
|
finances[FIN_MONEY] =
|
||||||
|
math_round_integer(my_team->stadium.capacity *
|
||||||
|
math_rndi(CONSTANT_INITIAL_MONEY_LOWER,
|
||||||
|
CONSTANT_INITIAL_MONEY_UPPER), 2);
|
||||||
|
}
|
16
src/user.h
Normal file
16
src/user.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef USER_H
|
||||||
|
#define USER_H
|
||||||
|
|
||||||
|
#include "bygfoot.h"
|
||||||
|
#include "variables.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
user_set_up_my_team_new_game(GtkWidget *widget);
|
||||||
|
|
||||||
|
void
|
||||||
|
user_set_up_my_team(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
user_set_up_finances(void);
|
||||||
|
|
||||||
|
#endif
|
@@ -1,4 +1,8 @@
|
|||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
|
#include "enums.h"
|
||||||
|
#include "live_game_struct.h"
|
||||||
|
#include "player_struct.h"
|
||||||
|
#include "team_struct.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main variable of the game.
|
* The main variable of the game.
|
||||||
@@ -7,7 +11,7 @@
|
|||||||
Country country;
|
Country country;
|
||||||
|
|
||||||
/** The id of the league or cup of the user's team and its numerical id. */
|
/** The id of the league or cup of the user's team and its numerical id. */
|
||||||
gint my_team_clid, my_team_id;
|
Team *my_team;
|
||||||
|
|
||||||
/** The season, week and week round numbers.
|
/** The season, week and week round numbers.
|
||||||
We keep track of the time in the game with these variables. */
|
We keep track of the time in the game with these variables. */
|
||||||
@@ -17,9 +21,17 @@ gint season, week, week_round;
|
|||||||
@see #Quality */
|
@see #Quality */
|
||||||
gint scout, physio;
|
gint scout, physio;
|
||||||
|
|
||||||
/** The array containing the fixtures.
|
/** The user's finances. @see #FinanceValue */
|
||||||
@see Fixture */
|
gint finances[FIN_END];
|
||||||
GArray *fixtures;
|
/** The user's settings. @see #OptionValue */
|
||||||
|
gint options[OPT_END];
|
||||||
|
/** The attributes shown in the player lists.
|
||||||
|
@see #PlayerListAttribute
|
||||||
|
@see #PlayerListAttributeValue */
|
||||||
|
PlayerListAttribute player_list_attributes[3];
|
||||||
|
|
||||||
|
/** Some counters. @see #CounterValue */
|
||||||
|
gint counters[COUNT_END];
|
||||||
|
|
||||||
/** The array containing players to be transfered.
|
/** The array containing players to be transfered.
|
||||||
@see TransferPlayer */
|
@see TransferPlayer */
|
||||||
@@ -28,13 +40,25 @@ GArray *transfer_list;
|
|||||||
/** The font used in treeviews. */
|
/** The font used in treeviews. */
|
||||||
GString *font_name;
|
GString *font_name;
|
||||||
|
|
||||||
|
/** Whether we are in debug mode. */
|
||||||
|
gboolean debug;
|
||||||
|
|
||||||
|
/** These help us keep track of what's happening. */
|
||||||
|
gint status, status2, status3, status4, status5;
|
||||||
|
|
||||||
/** An array of player names that we keep in memory. */
|
/** An array of player names that we keep in memory. */
|
||||||
GPtrArray *player_names;
|
GPtrArray *player_names;
|
||||||
|
|
||||||
/** The pointer to the main window of the game. */
|
/** The pointer to the main window of the game. */
|
||||||
GtkWidget *main_window;
|
GtkWidget *main_window;
|
||||||
|
|
||||||
/** All the open windows in the game.
|
/** With this we keep track of the number of popup
|
||||||
@see window_create()
|
windows and make the main window sensitive or
|
||||||
@see window_destroy() */
|
insensitive, depending. */
|
||||||
GList *windows;
|
gint popups_active;
|
||||||
|
|
||||||
|
/** The variable for the latest user live game. @see #Game */
|
||||||
|
LiveGame live_game;
|
||||||
|
|
||||||
|
/** The variable for non-user games (which aren't shown). */
|
||||||
|
LiveGame live_game_temp;
|
||||||
|
68
src/window.c
68
src/window.c
@@ -1,19 +1,11 @@
|
|||||||
#include "window.h"
|
#include "file.h"
|
||||||
|
#include "free.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "misc_interface.h"
|
#include "misc_interface.h"
|
||||||
#include "file.h"
|
|
||||||
#include "free.h"
|
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
#include "variables.h"
|
||||||
/** These are used to keep track of open windows.
|
#include "window.h"
|
||||||
@see window_create() */
|
|
||||||
enum Windows
|
|
||||||
{
|
|
||||||
WINDOW_MAIN = 0,
|
|
||||||
WINDOW_STARTUP,
|
|
||||||
WINDOW_END
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Show the country selection window. All files with prefix
|
Show the country selection window. All files with prefix
|
||||||
@@ -31,13 +23,10 @@ window_show_startup(void)
|
|||||||
GList *combo_strings = NULL;
|
GList *combo_strings = NULL;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
sprintf(country_dir, "%s/.bygfoot/definitions/", g_get_home_dir());
|
file_get_definitions_dir(country_dir);
|
||||||
|
|
||||||
dir_contents = file_dir_get_contents((const gchar*)country_dir, "country_");
|
dir_contents = file_dir_get_contents((const gchar*)country_dir, "country_");
|
||||||
|
|
||||||
if(dir_contents == NULL)
|
|
||||||
main_exit_program(EXIT_DIR_OPEN_FAILED);
|
|
||||||
|
|
||||||
for(i=0;i<dir_contents->len;i++)
|
for(i=0;i<dir_contents->len;i++)
|
||||||
combo_strings = g_list_append(combo_strings,
|
combo_strings = g_list_append(combo_strings,
|
||||||
((GString*)g_ptr_array_index(dir_contents, i))->str);
|
((GString*)g_ptr_array_index(dir_contents, i))->str);
|
||||||
@@ -47,6 +36,15 @@ window_show_startup(void)
|
|||||||
free_g_string_array(&dir_contents);
|
free_g_string_array(&dir_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Create and show the main window. */
|
||||||
|
void
|
||||||
|
window_show_main(void)
|
||||||
|
{
|
||||||
|
main_window = window_create(WINDOW_MAIN);
|
||||||
|
|
||||||
|
gtk_widget_show(main_window);
|
||||||
|
}
|
||||||
|
|
||||||
/** Set 'Bygfoot x.y.z' into the title of a window.
|
/** Set 'Bygfoot x.y.z' into the title of a window.
|
||||||
@param window The window widget pointer.
|
@param window The window widget pointer.
|
||||||
@see #VERS */
|
@see #VERS */
|
||||||
@@ -71,19 +69,57 @@ window_create(gint window_type)
|
|||||||
{
|
{
|
||||||
GtkWidget *window = NULL;
|
GtkWidget *window = NULL;
|
||||||
|
|
||||||
|
popups_active++;
|
||||||
|
|
||||||
switch(window_type)
|
switch(window_type)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
if(main_window == NULL)
|
||||||
|
{
|
||||||
window = create_main_window();
|
window = create_main_window();
|
||||||
|
popups_active--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
window = main_window;
|
||||||
window_set_version(window);
|
window_set_version(window);
|
||||||
break;
|
break;
|
||||||
case WINDOW_STARTUP:
|
case WINDOW_STARTUP:
|
||||||
window = create_window_startup();
|
window = create_window_startup();
|
||||||
window_set_version(window);
|
window_set_version(window);
|
||||||
break;
|
break;
|
||||||
|
case WINDOW_LIVE:
|
||||||
|
window = create_window_live();
|
||||||
|
window_set_version(window);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_show(window);
|
gtk_widget_show(window);
|
||||||
|
|
||||||
|
if(popups_active != 0 && main_window != NULL)
|
||||||
|
gtk_widget_set_sensitive(main_window, FALSE);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Destroy a window widget and set the popups and
|
||||||
|
main window sensitivity correctly.
|
||||||
|
@param window The window we destroy. */
|
||||||
|
void
|
||||||
|
window_destroy(GtkWidget **window)
|
||||||
|
{
|
||||||
|
if(*window == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(*window != main_window)
|
||||||
|
{
|
||||||
|
popups_active--;
|
||||||
|
|
||||||
|
if(popups_active == 0 && main_window != NULL)
|
||||||
|
gtk_widget_set_sensitive(main_window, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_destroy(*window);
|
||||||
|
|
||||||
|
*window = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
16
src/window.h
16
src/window.h
@@ -3,13 +3,29 @@
|
|||||||
|
|
||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
|
|
||||||
|
/** These are used to keep track of open windows.
|
||||||
|
@see window_create() */
|
||||||
|
enum Windows
|
||||||
|
{
|
||||||
|
WINDOW_MAIN = 0,
|
||||||
|
WINDOW_STARTUP,
|
||||||
|
WINDOW_LIVE,
|
||||||
|
WINDOW_END
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
window_show_startup(void);
|
window_show_startup(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
window_show_main(void);
|
||||||
|
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
window_set_version(GtkWidget *window);
|
window_set_version(GtkWidget *window);
|
||||||
|
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
window_create(gint window_type);
|
window_create(gint window_type);
|
||||||
|
|
||||||
|
void
|
||||||
|
window_destroy(GtkWidget **window);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -173,7 +173,7 @@ xml_country_read(const gchar *country_name)
|
|||||||
if(!g_file_get_contents(file_name, &file_contents, &length, &error))
|
if(!g_file_get_contents(file_name, &file_contents, &length, &error))
|
||||||
{
|
{
|
||||||
g_warning("xml_country_read: error reading file %s\n", file_name);
|
g_warning("xml_country_read: error reading file %s\n", file_name);
|
||||||
misc_print_error(error, FALSE);
|
misc_print_error(&error, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +192,6 @@ xml_country_read(const gchar *country_name)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_critical("xml_country_read: error parsing file %s\n", buf);
|
g_critical("xml_country_read: error parsing file %s\n", buf);
|
||||||
misc_print_error(error, TRUE);
|
misc_print_error(&error, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -343,7 +343,7 @@ xml_cup_read(const gchar *cup_name, GArray *cups)
|
|||||||
if(!g_file_get_contents(file_name, &file_contents, &length, &error))
|
if(!g_file_get_contents(file_name, &file_contents, &length, &error))
|
||||||
{
|
{
|
||||||
g_warning("xml_cup_read: error reading file %s\n", file_name);
|
g_warning("xml_cup_read: error reading file %s\n", file_name);
|
||||||
misc_print_error(error, FALSE);
|
misc_print_error(&error, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,6 +363,6 @@ xml_cup_read(const gchar *cup_name, GArray *cups)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_critical("xml_cup_read: error parsing file %s\n", buf);
|
g_critical("xml_cup_read: error parsing file %s\n", buf);
|
||||||
misc_print_error(error, TRUE);
|
misc_print_error(&error, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -134,6 +134,7 @@ xml_league_read_start_element (GMarkupParseContext *context,
|
|||||||
else if(strcmp(element_name, TAG_TEAM) == 0)
|
else if(strcmp(element_name, TAG_TEAM) == 0)
|
||||||
{
|
{
|
||||||
new_team = team_new();
|
new_team = team_new();
|
||||||
|
g_string_printf(new_team.symbol, "%s", new_league.symbol->str);
|
||||||
new_team.clid = new_league.id;
|
new_team.clid = new_league.id;
|
||||||
new_team.id = team_cnt++;
|
new_team.id = team_cnt++;
|
||||||
g_array_append_val(new_league.teams, new_team);
|
g_array_append_val(new_league.teams, new_team);
|
||||||
@@ -158,6 +159,8 @@ xml_league_read_end_element (GMarkupParseContext *context,
|
|||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
TableElement new_table_element;
|
||||||
|
|
||||||
if(strcmp(element_name, TAG_NAME) == 0 ||
|
if(strcmp(element_name, TAG_NAME) == 0 ||
|
||||||
strcmp(element_name, TAG_SHORT_NAME) == 0 ||
|
strcmp(element_name, TAG_SHORT_NAME) == 0 ||
|
||||||
strcmp(element_name, TAG_SID) == 0 ||
|
strcmp(element_name, TAG_SID) == 0 ||
|
||||||
@@ -181,7 +184,12 @@ xml_league_read_end_element (GMarkupParseContext *context,
|
|||||||
strcmp(element_name, TAG_PROM_REL_ELEMENT_DEST_SID) == 0)
|
strcmp(element_name, TAG_PROM_REL_ELEMENT_DEST_SID) == 0)
|
||||||
state = STATE_PROM_REL_ELEMENT;
|
state = STATE_PROM_REL_ELEMENT;
|
||||||
else if(strcmp(element_name, TAG_TEAM) == 0)
|
else if(strcmp(element_name, TAG_TEAM) == 0)
|
||||||
|
{
|
||||||
state = STATE_TEAMS;
|
state = STATE_TEAMS;
|
||||||
|
new_table_element = league_table_element_new(
|
||||||
|
&g_array_index(new_league.teams, Team, new_league.teams->len - 1));
|
||||||
|
g_array_append_val(new_league.table.elements, new_table_element);
|
||||||
|
}
|
||||||
else if(strcmp(element_name, TAG_TEAM_NAME) == 0)
|
else if(strcmp(element_name, TAG_TEAM_NAME) == 0)
|
||||||
state = STATE_TEAM;
|
state = STATE_TEAM;
|
||||||
else if(strcmp(element_name, TAG_LEAGUE) != 0)
|
else if(strcmp(element_name, TAG_LEAGUE) != 0)
|
||||||
@@ -211,7 +219,10 @@ xml_league_read_text (GMarkupParseContext *context,
|
|||||||
value = (gint)g_ascii_strtod(buf, NULL);
|
value = (gint)g_ascii_strtod(buf, NULL);
|
||||||
|
|
||||||
if(state == STATE_NAME)
|
if(state == STATE_NAME)
|
||||||
|
{
|
||||||
g_string_printf(new_league.name, "%s", buf);
|
g_string_printf(new_league.name, "%s", buf);
|
||||||
|
g_string_printf(new_league.table.name, "%s", buf);
|
||||||
|
}
|
||||||
else if(state == STATE_SHORT_NAME)
|
else if(state == STATE_SHORT_NAME)
|
||||||
g_string_printf(new_league.short_name, "%s", buf);
|
g_string_printf(new_league.short_name, "%s", buf);
|
||||||
else if(state == STATE_SID)
|
else if(state == STATE_SID)
|
||||||
@@ -286,7 +297,7 @@ xml_league_read(const gchar *league_name, GArray *leagues)
|
|||||||
if(!g_file_get_contents(file_name, &file_contents, &length, &error))
|
if(!g_file_get_contents(file_name, &file_contents, &length, &error))
|
||||||
{
|
{
|
||||||
g_warning("xml_league_read: error reading file %s\n", file_name);
|
g_warning("xml_league_read: error reading file %s\n", file_name);
|
||||||
misc_print_error(error, FALSE);
|
misc_print_error(&error, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,6 +317,6 @@ xml_league_read(const gchar *league_name, GArray *leagues)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_critical("xml_league_read: error parsing file %s\n", buf);
|
g_critical("xml_league_read: error parsing file %s\n", buf);
|
||||||
misc_print_error(error, TRUE);
|
misc_print_error(&error, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
#define XML_LEAGUE_H
|
#define XML_LEAGUE_H
|
||||||
|
|
||||||
#include "bygfoot.h"
|
#include "bygfoot.h"
|
||||||
#include "team_struct.h"
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xml_league_read_start_element (GMarkupParseContext *context,
|
xml_league_read_start_element (GMarkupParseContext *context,
|
||||||
|
@@ -107,7 +107,7 @@ xml_name_read(const gchar *names_file, gint number_of_names)
|
|||||||
if(!g_file_get_contents(file_name, &file_contents, &length, &error))
|
if(!g_file_get_contents(file_name, &file_contents, &length, &error))
|
||||||
{
|
{
|
||||||
g_warning("xml_name_read: error reading file %s\n", file_name);
|
g_warning("xml_name_read: error reading file %s\n", file_name);
|
||||||
misc_print_error(error, FALSE);
|
misc_print_error(&error, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ xml_name_read(const gchar *names_file, gint number_of_names)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_critical("xml_name_read: error parsing file %s\n", buf);
|
g_critical("xml_name_read: error parsing file %s\n", buf);
|
||||||
misc_print_error(error, TRUE);
|
misc_print_error(&error, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(number_of_names == -1)
|
if(number_of_names == -1)
|
||||||
|
@@ -4,115 +4,81 @@
|
|||||||
# Most of these options are uncommented because their meaning
|
# Most of these options are uncommented because their meaning
|
||||||
# is rather clear if you take a look at the options window in the game.
|
# is rather clear if you take a look at the options window in the game.
|
||||||
|
|
||||||
|
confirm_new_week_round 1
|
||||||
confirm_new_week 1
|
|
||||||
confirm_unfit 1
|
confirm_unfit 1
|
||||||
confirm_quit 1
|
confirm_quit 1
|
||||||
save_will_ovewrite 1
|
save_will_ovewrite 1
|
||||||
|
show_live_game 0
|
||||||
# whether a summary of your games is shown or the league results
|
|
||||||
# at the beginning of a new week
|
|
||||||
new_week_show_my_games 1
|
|
||||||
|
|
||||||
show_live_game 1
|
|
||||||
live_game_duration 0
|
live_game_duration 0
|
||||||
show_tendency_bar 1
|
show_tendency_bar 1
|
||||||
|
|
||||||
maximize_main_window 1
|
maximize_main_window 1
|
||||||
|
|
||||||
# whether transfer list notification's switched on
|
|
||||||
notify_transfer 0
|
notify_transfer 0
|
||||||
|
notify_pos -1
|
||||||
notify_goalie 1
|
notify_league_upper -1
|
||||||
notify_defender 1
|
notify_league_lower -1
|
||||||
notify_midfielder 1
|
notify_cups 0
|
||||||
notify_forward 1
|
notify_age_upper 36
|
||||||
notify_league_one 1
|
notify_age_lower 18
|
||||||
notify_league_two 1
|
notify_skill_upper 99
|
||||||
notify_league_three 1
|
notify_skill_lower 1
|
||||||
notify_league_four 1
|
notify_etal_upper 99
|
||||||
notify_league_five 1
|
notify_etal_lower 1
|
||||||
notify_league_international 1
|
notify_value -1
|
||||||
|
|
||||||
# the following entries are to be read like this: 1737 means
|
|
||||||
# lower bound 17 and upper bound 37; 1099 means lower bound 1.0 and
|
|
||||||
# upper bound 9.9.
|
|
||||||
# if the value's < 0, the attribute doesn't play a role when notifying.
|
|
||||||
notify_age 1737
|
|
||||||
notify_skill 1099
|
|
||||||
notify_estimated_talent 1099
|
|
||||||
|
|
||||||
notify_value 1500000
|
|
||||||
notify_position 1
|
|
||||||
|
|
||||||
# whether or not league is considered when looking
|
|
||||||
# for player on the transfer list matching the criteria
|
|
||||||
notify_league_bool 1
|
|
||||||
show_job_offers 1
|
show_job_offers 1
|
||||||
|
|
||||||
# 1 moving 2 static 3 off
|
|
||||||
message_style 1
|
message_style 1
|
||||||
prefer_messages 0
|
prefer_messages 0
|
||||||
|
autosave 0
|
||||||
# if < 0, it's switched off. if > 0, value is the number of weeks
|
autosave_interval 3
|
||||||
# between autosaves.
|
sort_transfer_list 0
|
||||||
autosave -3
|
sort_transfer_attribute 1
|
||||||
|
|
||||||
skip_weeks 1
|
|
||||||
|
|
||||||
# if < 0, switched off. if > 10, sorting order is ascending.
|
|
||||||
# if the value is X or 1X, X can signify:
|
|
||||||
# 1 position 2 skill 3 age 4 estimated talent 5 league
|
|
||||||
sort_transfer_list -1
|
|
||||||
|
|
||||||
reaarrange_adapts 1
|
reaarrange_adapts 1
|
||||||
swap_adapts 1
|
swap_adapts 1
|
||||||
fitness_colors 1
|
|
||||||
|
|
||||||
show_attribute_name 1
|
|
||||||
show_attribute_current_position 1
|
|
||||||
show_attribute_position 1
|
|
||||||
show_attribute_current_skill 1
|
|
||||||
show_attribute_skill 1
|
|
||||||
show_attribute_fitness 1
|
|
||||||
show_attribute_games 1
|
|
||||||
show_attribute_goals 1
|
|
||||||
show_attribute_status 1
|
|
||||||
show_attribute_age 0
|
|
||||||
show_attribute_estimated_talent 0
|
|
||||||
show_attribute_booked 0
|
|
||||||
show_attribute_value 0
|
|
||||||
show_attribute_wage 0
|
|
||||||
show_attribute_team 0
|
|
||||||
show_attribute_league 0
|
|
||||||
|
|
||||||
# attributes for the second player list
|
|
||||||
|
|
||||||
show_attribute_two_name 1
|
|
||||||
show_attribute_two_current_position 0
|
|
||||||
show_attribute_two_position 1
|
|
||||||
show_attribute_two_current_skill 0
|
|
||||||
show_attribute_two_skill 1
|
|
||||||
show_attribute_two_fitness 0
|
|
||||||
show_attribute_two_games 0
|
|
||||||
show_attribute_two_goals 0
|
|
||||||
show_attribute_two_status 0
|
|
||||||
show_attribute_two_age 1
|
|
||||||
show_attribute_two_estimated_talent 1
|
|
||||||
show_attribute_two_booked 0
|
|
||||||
show_attribute_two_value 1
|
|
||||||
show_attribute_two_wage 1
|
|
||||||
show_attribute_two_team 0
|
|
||||||
show_attribute_two_league 0
|
|
||||||
|
|
||||||
history_team_interval 5
|
history_team_interval 5
|
||||||
history_player_interval 7
|
history_player_interval 10
|
||||||
history_team_max 75
|
history_team_max 30
|
||||||
history_player_max 50
|
history_player_max 20
|
||||||
history_team_delete 0
|
history_team_delete 0
|
||||||
history_player_delete 0
|
history_player_delete 0
|
||||||
|
|
||||||
boost 0
|
boost 0
|
||||||
|
compress 1
|
||||||
|
objective 1
|
||||||
|
penalty_shooter -1
|
||||||
|
|
||||||
|
pl1_att_name 1
|
||||||
|
pl1_att_cpos 1
|
||||||
|
pl1_att_pos 1
|
||||||
|
pl1_att_cskill 1
|
||||||
|
pl1_att_skill 1
|
||||||
|
pl1_att_fitness 1
|
||||||
|
pl1_att_games 1
|
||||||
|
pl1_att_goals 1
|
||||||
|
pl1_att_status 1
|
||||||
|
pl1_att_cards 0
|
||||||
|
pl1_att_age 1
|
||||||
|
pl1_att_etal 1
|
||||||
|
pl1_att_value 0
|
||||||
|
pl1_att_wage 0
|
||||||
|
pl1_att_contract 0
|
||||||
|
pl1_att_team 0
|
||||||
|
pl1_att_league_cup 0
|
||||||
|
|
||||||
|
pl2_att_name 1
|
||||||
|
pl2_att_cpos 0
|
||||||
|
pl2_att_pos 1
|
||||||
|
pl2_att_cskill 0
|
||||||
|
pl2_att_skill 1
|
||||||
|
pl2_att_fitness 0
|
||||||
|
pl2_att_games 0
|
||||||
|
pl2_att_goals 0
|
||||||
|
pl2_att_status 1
|
||||||
|
pl2_att_cards 0
|
||||||
|
pl2_att_age 1
|
||||||
|
pl2_att_etal 1
|
||||||
|
pl2_att_value 1
|
||||||
|
pl2_att_wage 1
|
||||||
|
pl2_att_contract 1
|
||||||
|
pl2_att_team 0
|
||||||
|
pl2_att_league_cup 0
|
||||||
|
|
||||||
# font name; if 0, the default system font's used
|
# font name; if 0, the default system font's used
|
||||||
font_name 0
|
font_name 0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<league>
|
<league>
|
||||||
|
|
||||||
<sid>england3</sid>
|
<sid>england4</sid>
|
||||||
<name>Football League Two</name>
|
<name>Football League Two</name>
|
||||||
<short_name>F. L. Two</short_name>
|
<short_name>F. L. Two</short_name>
|
||||||
<symbol>flag_en.png</symbol>
|
<symbol>flag_en.png</symbol>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<league>
|
<league>
|
||||||
|
|
||||||
<sid>england4</sid>
|
<sid>england5</sid>
|
||||||
<name>Nationwide Conference</name>
|
<name>Nationwide Conference</name>
|
||||||
<short_name>Nat. Conf.</short_name>
|
<short_name>Nat. Conf.</short_name>
|
||||||
<symbol>flag_en.png</symbol>
|
<symbol>flag_en.png</symbol>
|
||||||
|
BIN
support_files/pixmaps/possession_ball.png
Normal file
BIN
support_files/pixmaps/possession_ball.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 592 B |
Reference in New Issue
Block a user