Live game development.

This commit is contained in:
gyboth 2005-03-10 20:59:39 +00:00
parent 83898c68f1
commit aace8d7782
32 changed files with 939 additions and 375 deletions

View File

@ -98,7 +98,7 @@
<signal name="activate" handler="on_start_editor_activate" last_modification_time="Sun, 30 May 2004 19:58:16 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image189">
<widget class="GtkImage" id="image194">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@ -119,7 +119,7 @@
<signal name="activate" handler="on_start_update_activate" last_modification_time="Mon, 13 Sep 2004 12:30:42 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image190">
<widget class="GtkImage" id="image195">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">1</property>
@ -168,7 +168,7 @@
<signal name="activate" handler="on_menu_preferences_activate" last_modification_time="Sun, 02 Jan 2005 15:30:45 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image191">
<widget class="GtkImage" id="image196">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@ -312,7 +312,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">All Out Defend</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="active">True</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:16:56 GMT"/>
</widget>
</child>
@ -322,7 +322,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Defend</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="active">True</property>
<property name="group">menu_all_out_defend</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:17:07 GMT"/>
</widget>
@ -333,7 +333,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Balanced</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="active">True</property>
<property name="group">menu_all_out_defend</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:17:14 GMT"/>
</widget>
@ -344,7 +344,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Attack</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="active">True</property>
<property name="group">menu_all_out_defend</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:17:20 GMT"/>
</widget>
@ -379,7 +379,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Best</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="active">True</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:15:47 GMT"/>
</widget>
</child>
@ -389,7 +389,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Good</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="active">True</property>
<property name="group">menu_scout_best</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:15:35 GMT"/>
</widget>
@ -400,7 +400,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Average</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="active">True</property>
<property name="group">menu_scout_best</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:15:54 GMT"/>
</widget>
@ -435,7 +435,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Best</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="active">True</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:16:14 GMT"/>
</widget>
</child>
@ -445,7 +445,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Good</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="active">True</property>
<property name="group">menu_physio_best</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:16:21 GMT"/>
</widget>
@ -456,7 +456,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Average</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="active">True</property>
<property name="group">menu_physio_best</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:16:28 GMT"/>
</widget>
@ -478,43 +478,43 @@
</child>
<child>
<widget class="GtkMenuItem" id="menu_boost_anti_boost">
<widget class="GtkMenuItem" id="menu_boost">
<property name="visible">True</property>
<property name="label" translatable="yes">Boost/Anti-boost</property>
<property name="label" translatable="yes">Boost</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu_boost_anti_menu">
<widget class="GtkMenu" id="menu_boost_menu">
<child>
<widget class="GtkRadioMenuItem" id="menu_boost_anti">
<widget class="GtkRadioMenuItem" id="menu_boost_on">
<property name="visible">True</property>
<property name="label" translatable="yes">Anti-boost</property>
<property name="label" translatable="yes">On</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Tue, 08 Mar 2005 17:01:43 GMT"/>
<property name="active">True</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Tue, 08 Mar 2005 16:37:57 GMT"/>
</widget>
</child>
<child>
<widget class="GtkRadioMenuItem" id="menu_boost_normal">
<widget class="GtkRadioMenuItem" id="menu_boost_off">
<property name="visible">True</property>
<property name="label" translatable="yes">Normal</property>
<property name="label" translatable="yes">Off</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="group">menu_boost_anti</property>
<property name="group">menu_boost_on</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Tue, 08 Mar 2005 16:37:48 GMT"/>
</widget>
</child>
<child>
<widget class="GtkRadioMenuItem" id="menu_boost">
<widget class="GtkRadioMenuItem" id="menu_boost_anti">
<property name="visible">True</property>
<property name="label" translatable="yes">Boost</property>
<property name="label" translatable="yes">Anti</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="group">menu_boost_anti</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Tue, 08 Mar 2005 16:37:57 GMT"/>
<property name="active">True</property>
<property name="group">menu_boost_on</property>
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Tue, 08 Mar 2005 17:01:43 GMT"/>
</widget>
</child>
</widget>
@ -627,7 +627,7 @@
<accelerator key="F9" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image192">
<widget class="GtkImage" id="image197">
<property name="visible">True</property>
<property name="stock">gtk-go-forward</property>
<property name="icon_size">1</property>
@ -649,7 +649,7 @@
<accelerator key="F8" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image193">
<widget class="GtkImage" id="image198">
<property name="visible">True</property>
<property name="stock">gtk-go-back</property>
<property name="icon_size">1</property>
@ -671,7 +671,7 @@
<accelerator key="F12" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image194">
<widget class="GtkImage" id="image199">
<property name="visible">True</property>
<property name="stock">gtk-justify-fill</property>
<property name="icon_size">1</property>

View File

@ -1170,6 +1170,80 @@
</packing>
</child>
<child>
<widget class="GtkButton" id="button_show_stats">
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_show_stats_clicked" last_modification_time="Thu, 10 Mar 2005 17:20:14 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment20">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox56">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image60">
<property name="visible">True</property>
<property name="stock">gtk-select-color</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="label77">
<property name="visible">True</property>
<property name="label" translatable="yes">_Show stats</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_live_close">
<property name="visible">True</property>

View File

@ -1815,12 +1815,12 @@
</child>
</widget>
<widget class="GtkWindow" id="progressbar_window">
<widget class="GtkWindow" id="window_progress">
<property name="visible">True</property>
<property name="title" translatable="yes">window1</property>
<property name="type">GTK_WINDOW_POPUP</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="modal">True</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>

View File

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

View File

@ -603,8 +603,9 @@ on_menu_team_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
player_of(usr(0).tm, 10)->cskill = 0;
player_of(usr(0).tm, 10)->health = 10;
/*d*/
/* player_of(usr(0).tm, 10)->cskill = 0; */
/* player_of(usr(0).tm, 10)->health = 10; */
game_gui_read_radio_items(widget);

View File

@ -79,13 +79,24 @@ free_option_array(GArray **array, gboolean reset)
void
free_live_game(LiveGame *match)
{
gint i;
gint i, j, k;
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);
for(i=0;i<2;i++)
{
for(j=0;j<LIVE_GAME_STAT_ARRAY_END;j++)
{
for(k=0;k<match->stats.players[j][i]->len;k++)
free_g_string((GString**)&g_ptr_array_index(match->stats.players[j][i], k));
free_g_ptr_array(&match->stats.players[j][i]);
}
}
free_g_array(&match->units);
}

View File

@ -1,6 +1,7 @@
#include "fixture.h"
#include "game.h"
#include "game_gui.h"
#include "live_game_struct.h"
#include "maths.h"
#include "misc.h"
#include "option.h"
@ -54,12 +55,12 @@ game_get_values(const Fixture *fix, gfloat team_values[][GAME_TEAM_VALUE_END],
((1 + style_factor) * (1 + home_advantage * (i == 0)) *
(1 + const_float("float_player_boost_skill_effect") * tm[i]->boost));
printf("%s attack %.1f midf %.1f defend %.1f style %d struct %d\n",
tm[i]->name->str,
team_values[i][GAME_TEAM_VALUE_ATTACK],
team_values[i][GAME_TEAM_VALUE_MIDFIELD],
team_values[i][GAME_TEAM_VALUE_DEFEND],
tm[i]->style, tm[i]->structure);
/* printf("%s attack %.1f midf %.1f defend %.1f style %d struct %d\n", */
/* tm[i]->name->str, */
/* team_values[i][GAME_TEAM_VALUE_ATTACK], */
/* team_values[i][GAME_TEAM_VALUE_MIDFIELD], */
/* team_values[i][GAME_TEAM_VALUE_DEFEND], */
/* tm[i]->style, tm[i]->structure); */
}
}
@ -232,9 +233,14 @@ game_initialize(Fixture *fix)
for(i=0;i<2;i++)
for(j=0;j<11;j++)
{
if(player_of(fix->teams[i], j)->cskill > 0)
game_player_increase(fix->clid, player_of(fix->teams[i], j),
GAME_PLAYER_INCREASE_GAMES);
if(player_card_get(player_of(fix->teams[i], j), fix->clid, PLAYER_CARD_RED) > 0)
player_card_set(player_of(fix->teams[i], j), fix->clid, PLAYER_CARD_RED, -1, TRUE);
}
}
/** Save the team states in the current live game
@ -572,48 +578,6 @@ game_player_get_ban_duration(void)
return -1;
}
/** Send off a player. Choose number of weeks banned randomly.
@param clid League or cup id of the match.
@param pl The player.
@param red Whether it's a red or a yellow card.
@param second_yellow Whether this is only a yellow. */
void
game_player_card(gint clid, Player *pl, gboolean red, gboolean second_yellow)
{
gint i;
PlayerCard new;
if(red)
pl->cskill = 0;
for(i=0;i<pl->cards->len;i++)
if(g_array_index(pl->cards, PlayerCard, i).clid == clid)
{
if(red)
{
if(second_yellow)
{
g_array_index(pl->cards, PlayerCard, i).yellow = 0;
g_array_index(pl->cards, PlayerCard, i).red = 1;
}
else
g_array_index(pl->cards, PlayerCard, i).red =
game_player_get_ban_duration();
}
else
g_array_index(pl->cards, PlayerCard, i).yellow++;
return;
}
new.clid = clid;
new.red = 0;
new.yellow = 0;
g_array_append_val(pl->cards, new);
game_player_card(clid, pl, red, second_yellow);
}
/** Find out whether we make a sub after a send-off.
@param tm The team.
@param player The player index.
@ -675,7 +639,210 @@ game_decrease_fitness(const Fixture *fix)
gint i, j;
for(i=0;i<2;i++)
for(j=0;j<11;j++)
if(player_of(fix->teams[i], j)->cskill > 0)
player_decrease_fitness(player_of(fix->teams[i], j));
{
if(team_is_user(fix->teams[i]) != -1)
for(j=0;j<11;j++)
if(player_of(fix->teams[i], j)->cskill > 0)
player_decrease_fitness(player_of(fix->teams[i], j));
}
}
/** Assemble some stats like ball possession or shots
on goal.
@param live_game The pointer to the match.
@see #LiveGameStats */
void
game_create_stats(gpointer live_game)
{
LiveGame *match = (LiveGame*)live_game;
gint i, possession[2] = {0, 0}, reg_goals[2] = {0, 0};
LiveGameStats *stat = &match->stats;
game_create_stats_players(live_game);
for(i=0;i<LIVE_GAME_STAT_VALUE_END;i++)
stat->values[0][i] =
stat->values[1][i] = 0;
for(i=0;i<2;i++)
stat->values[i][LIVE_GAME_STAT_VALUE_GOALS_REGULAR] =
math_sum_int_array(match->fix->result[i], 2);
for(i=0;i<match->units->len;i++)
{
if(g_array_index(match->units, LiveGameUnit, i).event.type ==
LIVE_GAME_EVENT_PENALTIES)
break;
if(g_array_index(match->units, LiveGameUnit, i).minute != -1)
possession[g_array_index(match->units, LiveGameUnit, i).possession]++;
if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_SCORING_CHANCE ||
g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_FREE_KICK)
stat->values[g_array_index(match->units, LiveGameUnit, i).possession][LIVE_GAME_STAT_VALUE_SHOTS]++;
else if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_PENALTY)
stat->values[g_array_index(match->units, LiveGameUnit, i).possession]
[LIVE_GAME_STAT_VALUE_PENALTIES]++;
else if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_INJURY)
stat->values[g_array_index(match->units, LiveGameUnit, i).event.values[LIVE_GAME_EVENT_VALUE_TEAM]]
[LIVE_GAME_STAT_VALUE_INJURIES]++;
else if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_FOUL ||
g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_FOUL_YELLOW ||
g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_FOUL_RED ||
g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_FOUL_RED_INJURY)
{
stat->values[g_array_index(match->units, LiveGameUnit, i).event.values[LIVE_GAME_EVENT_VALUE_TEAM]]
[LIVE_GAME_STAT_VALUE_FOULS]++;
if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_FOUL_YELLOW)
stat->values[g_array_index(match->units, LiveGameUnit, i).
event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_CARDS]++;
}
else if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_SEND_OFF)
stat->values[g_array_index(match->units, LiveGameUnit, i).event.values[LIVE_GAME_EVENT_VALUE_TEAM]]
[LIVE_GAME_STAT_VALUE_REDS]++;
else if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_GOAL &&
g_array_index(match->units, LiveGameUnit, i - 1).event.type != LIVE_GAME_EVENT_PENALTY)
reg_goals[g_array_index(match->units, LiveGameUnit, i).
event.values[LIVE_GAME_EVENT_VALUE_TEAM]]++;
}
for(i=0;i<2;i++)
{
stat->values[i][LIVE_GAME_STAT_VALUE_POSSESSION] =
(gint)rint((gfloat)possession[i] / (gfloat)(possession[0] + possession[1]) * 100);
stat->values[i][LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE] =
(stat->values[i][LIVE_GAME_STAT_VALUE_SHOTS] > 0) ?
(gint)rint(((gfloat)reg_goals[i] / (gfloat)stat->values[i][LIVE_GAME_STAT_VALUE_SHOTS])
* 100) : 0;
}
/*d*/
printf("goals reg\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_GOALS_REGULAR],
stat->values[1][LIVE_GAME_STAT_VALUE_GOALS_REGULAR]);
printf("shots\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_SHOTS],
stat->values[1][LIVE_GAME_STAT_VALUE_SHOTS]);
printf("shotperc\t %d%% \t %d%%\n", stat->values[0][LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE],
stat->values[1][LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE]);
printf("poss\t %d%% \t %d%%\n", stat->values[0][LIVE_GAME_STAT_VALUE_POSSESSION],
stat->values[1][LIVE_GAME_STAT_VALUE_POSSESSION]);
printf("pen.\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_PENALTIES],
stat->values[1][LIVE_GAME_STAT_VALUE_PENALTIES]);
printf("fouls\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_FOULS],
stat->values[1][LIVE_GAME_STAT_VALUE_FOULS]);
printf("cards\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_CARDS],
stat->values[1][LIVE_GAME_STAT_VALUE_CARDS]);
printf("reds\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_REDS],
stat->values[1][LIVE_GAME_STAT_VALUE_REDS]);
printf("inj.\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_INJURIES],
stat->values[1][LIVE_GAME_STAT_VALUE_INJURIES]);
}
/** Create arrays containing the names of the
goal scorers and sent off and injured players.
@param live_game The live game we examine. */
void
game_create_stats_players(gpointer live_game)
{
gint i, j;
LiveGame *match = (LiveGame*)live_game;
LiveGameStats *stats = &match->stats;
gint limit = const_int("int_team_max_players");
gint scorer_ids[2][limit];
gint cnt[2] = {0, 0};
gint team, player, player2, array_index;
gint minute = 0;
gchar buf[SMALL], buf2[SMALL];
GString *new = NULL;
gboolean own_goal;
GPtrArray *players = NULL;
for(i=0;i<limit;i++)
scorer_ids[0][i] = scorer_ids[1][i] = -1;
for(i=0;i<match->units->len;i++)
{
if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_PENALTIES)
return;
minute = MAX(minute, g_array_index(match->units, LiveGameUnit, i).minute);
team = g_array_index(match->units, LiveGameUnit, i).event.values[LIVE_GAME_EVENT_VALUE_TEAM];
player = g_array_index(match->units, LiveGameUnit, i).event.values[LIVE_GAME_EVENT_VALUE_PLAYER];
player2 = g_array_index(match->units, LiveGameUnit, i).event.values[LIVE_GAME_EVENT_VALUE_PLAYER2];
if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_GOAL ||
g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_OWN_GOAL)
{
own_goal = (g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_OWN_GOAL);
array_index = (own_goal) ? !team : team;
if(g_array_index(match->units, LiveGameUnit, i - 1).event.type == LIVE_GAME_EVENT_PENALTY)
strcpy(buf2, " (P)");
else if(g_array_index(match->units, LiveGameUnit, i - 1).event.type == LIVE_GAME_EVENT_FREE_KICK)
strcpy(buf2, " (FK)");
else if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_OWN_GOAL)
strcpy(buf2, " (OG)");
else
strcpy(buf2, "");
if(query_integer_is_in_array(player + (100 * own_goal), scorer_ids[array_index], 0, limit))
{
for(j=0;j<stats->players[LIVE_GAME_STAT_ARRAY_SCORERS][array_index]->len;j++)
{
if(g_str_has_prefix(((GString*)g_ptr_array_index(
stats->players[LIVE_GAME_STAT_ARRAY_SCORERS][array_index], j))->str,
player_of_id(match->fix->teams[team], player)->name->str))
{
sprintf(buf, "%s %d",
((GString*)g_ptr_array_index(
stats->players[LIVE_GAME_STAT_ARRAY_SCORERS][array_index], j))->str,
minute);
strcat(buf, buf2);
g_string_printf(((GString*)g_ptr_array_index(
stats->players[LIVE_GAME_STAT_ARRAY_SCORERS][array_index], j)),
"%s", buf);
break;
}
if(j == stats->players[LIVE_GAME_STAT_ARRAY_SCORERS][array_index]->len)
g_warning("game_create_stats_scorers: didn't find scorer %d (team %d)\n",
player, team);
}
}
else
{
sprintf(buf, "%s %d", player_of_id(match->fix->teams[team], player)->name->str,
minute);
strcat(buf, buf2);
new = g_string_new(buf);
g_ptr_array_add(stats->players[LIVE_GAME_STAT_ARRAY_SCORERS][array_index], new);
scorer_ids[array_index][cnt[array_index]] = player + (100 * own_goal);
cnt[array_index]++;
}
}
else
{
strcpy(buf, "");
if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_INJURY)
{
sprintf(buf, "%s", player_of_id(match->fix->teams[team], player)->name->str);
players = stats->players[LIVE_GAME_STAT_ARRAY_INJURED][team];
}
else if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_FOUL_YELLOW)
{
sprintf(buf, "%s", player_of_id(match->fix->teams[team], player2)->name->str);
players = stats->players[LIVE_GAME_STAT_ARRAY_YELLOWS][team];
}
else if(g_array_index(match->units, LiveGameUnit, i).event.type == LIVE_GAME_EVENT_SEND_OFF)
{
sprintf(buf, "%s", player_of_id(match->fix->teams[team], player)->name->str);
players = stats->players[LIVE_GAME_STAT_ARRAY_REDS][team];
}
if(strlen(buf) > 0)
{
new = g_string_new(buf);
g_ptr_array_add(players, new);
}
}
}
}

View File

@ -81,13 +81,19 @@ game_get_foul_possession_factor(gboolean boost1, gboolean boost2);
gint
game_find_to_substitute(const Team *tm);
void
game_player_card(gint clid, Player *pl, gboolean red, gboolean second_yellow);
void
game_substitute_player_send_off(Team *tm, gint player_number,
gint *to_substitute, gint *substitute);
void
game_decrease_fitness(const Fixture *fix);
gint
game_player_get_ban_duration(void);
void
game_create_stats(gpointer live_game);
void
game_create_stats_players(gpointer live_game);
#endif

View File

@ -24,7 +24,8 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit)
GtkProgressBar *progress_bar;
GtkWidget *button_pause = lookup_widget(window.live, "button_pause"),
*button_resume = lookup_widget(window.live, "button_resume"),
*button_live_close = lookup_widget(window.live, "button_live_close");
*button_live_close = lookup_widget(window.live, "button_live_close"),
*button_show_stats = lookup_widget(window.live, "button_show_stats");
if(unit->event.type == LIVE_GAME_EVENT_START_MATCH)
treeview_live_game_show_initial_commentary(unit);
@ -48,12 +49,14 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit)
if(unit->event.type == LIVE_GAME_EVENT_START_MATCH)
{
gtk_widget_set_sensitive(button_live_close, FALSE);
gtk_widget_hide(button_show_stats);
gtk_widget_show(button_pause);
gtk_widget_hide(button_resume);
}
else if(unit->event.type == LIVE_GAME_EVENT_END_MATCH)
{
gtk_widget_set_sensitive(lookup_widget(window.live, "button_live_close"), TRUE);
gtk_widget_show(button_show_stats);
gtk_widget_hide(lookup_widget(window.live, "button_pause"));
}
else if(unit->event.type == LIVE_GAME_EVENT_PENALTIES)
@ -148,8 +151,8 @@ game_gui_get_radio_items(GtkWidget **style, GtkWidget **scout,
physio[3] = lookup_widget(window.main, "menu_physio_bad");
boost[0] = lookup_widget(window.main, "menu_boost_anti");
boost[1] = lookup_widget(window.main, "menu_boost_normal");
boost[2] = lookup_widget(window.main, "menu_boost");
boost[1] = lookup_widget(window.main, "menu_boost_off");
boost[2] = lookup_widget(window.main, "menu_boost_on");
}
/** Set information like season, user, week etc. into the appropriate labels. */

View File

@ -1,6 +1,8 @@
#include "gui.h"
#include "misc.h"
#include "support.h"
#include "variables.h"
#include "window.h"
/* Set into or append an integer into a label.
@param label The label.
@ -50,3 +52,33 @@ gui_label_set_text_from_float(GtkLabel *label, gfloat number,
gtk_label_set_text(label, buf);
}
/* Show a window with a progress bar.
@param value The value of the progress bar. If set to 1
or < 0 the progress bar window gets destroyed.
@param text The text to show in the progress bar. */
void
gui_show_progress(gfloat value, gchar *text)
{
GtkProgressBar *progressbar = NULL;
if(value == 1 || value < 0)
{
window_destroy(&window.progress, FALSE);
return;
}
if(window.progress == NULL)
window_create(WINDOW_PROGRESS);
progressbar = GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"));
if(value >= 0 && value < 1)
gtk_progress_bar_set_fraction(progressbar, value);
else
gtk_progress_bar_pulse(progressbar);
if(text != NULL)
gtk_progress_bar_set_text(progressbar, text);
while(gtk_events_pending())
gtk_main_iteration();
}

View File

@ -10,4 +10,7 @@ void
gui_label_set_text_from_float(GtkLabel *label, gfloat number,
gboolean append, gint precision);
void
gui_show_progress(gfloat value, gchar *text);
#endif

View File

@ -42,15 +42,15 @@ create_main_window (void)
GtkWidget *trennlinie1;
GtkWidget *separatormenuitem1;
GtkWidget *start_editor;
GtkWidget *image189;
GtkWidget *image194;
GtkWidget *start_update;
GtkWidget *image190;
GtkWidget *image195;
GtkWidget *trennlinie2;
GtkWidget *menu_quit;
GtkWidget *menu_options;
GtkWidget *menu_options_menu;
GtkWidget *menu_preferences;
GtkWidget *image191;
GtkWidget *image196;
GtkWidget *trennlinie7;
GtkWidget *menu_notify;
GtkWidget *menu_job_offers;
@ -87,12 +87,12 @@ create_main_window (void)
GtkWidget *menu_physio_good;
GtkWidget *menu_physio_average;
GtkWidget *menu_physio_bad;
GtkWidget *menu_boost_anti_boost;
GtkWidget *menu_boost_anti_menu;
GSList *menu_boost_anti_group = NULL;
GtkWidget *menu_boost_anti;
GtkWidget *menu_boost_normal;
GtkWidget *menu_boost;
GtkWidget *menu_boost_menu;
GSList *menu_boost_on_group = NULL;
GtkWidget *menu_boost_on;
GtkWidget *menu_boost_off;
GtkWidget *menu_boost_anti;
GtkWidget *menu_custom_structure;
GtkWidget *trennlinie8;
GtkWidget *menu_browse_teams;
@ -106,11 +106,11 @@ create_main_window (void)
GtkWidget *menu_user;
GtkWidget *menu_user_menu;
GtkWidget *menu_next_user;
GtkWidget *image192;
GtkWidget *image197;
GtkWidget *menu_previous_user;
GtkWidget *image193;
GtkWidget *image198;
GtkWidget *menu_manage_users;
GtkWidget *image194;
GtkWidget *image199;
GtkWidget *menu_finances_stadium;
GtkWidget *menu_finances_stadium_menu;
GtkWidget *menu_increase_capacity;
@ -266,17 +266,17 @@ create_main_window (void)
gtk_widget_show (start_editor);
gtk_container_add (GTK_CONTAINER (menu_file_menu), start_editor);
image189 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
gtk_widget_show (image189);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_editor), image189);
image194 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
gtk_widget_show (image194);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_editor), image194);
start_update = gtk_image_menu_item_new_with_mnemonic (_("Start Bygfoot Online Update"));
gtk_widget_show (start_update);
gtk_container_add (GTK_CONTAINER (menu_file_menu), start_update);
image190 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_MENU);
gtk_widget_show (image190);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_update), image190);
image195 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_MENU);
gtk_widget_show (image195);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_update), image195);
trennlinie2 = gtk_separator_menu_item_new ();
gtk_widget_show (trennlinie2);
@ -298,9 +298,9 @@ create_main_window (void)
gtk_widget_show (menu_preferences);
gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_preferences);
image191 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
gtk_widget_show (image191);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image191);
image196 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
gtk_widget_show (image196);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image196);
trennlinie7 = gtk_separator_menu_item_new ();
gtk_widget_show (trennlinie7);
@ -368,21 +368,25 @@ create_main_window (void)
menu_all_out_defend_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_all_out_defend));
gtk_widget_show (menu_all_out_defend);
gtk_container_add (GTK_CONTAINER (menu_playing_style_menu), menu_all_out_defend);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_all_out_defend), TRUE);
menu_defend = gtk_radio_menu_item_new_with_mnemonic (menu_all_out_defend_group, _("Defend"));
menu_all_out_defend_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_defend));
gtk_widget_show (menu_defend);
gtk_container_add (GTK_CONTAINER (menu_playing_style_menu), menu_defend);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_defend), TRUE);
menu_balanced = gtk_radio_menu_item_new_with_mnemonic (menu_all_out_defend_group, _("Balanced"));
menu_all_out_defend_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_balanced));
gtk_widget_show (menu_balanced);
gtk_container_add (GTK_CONTAINER (menu_playing_style_menu), menu_balanced);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_balanced), TRUE);
menu_attack = gtk_radio_menu_item_new_with_mnemonic (menu_all_out_defend_group, _("Attack"));
menu_all_out_defend_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_attack));
gtk_widget_show (menu_attack);
gtk_container_add (GTK_CONTAINER (menu_playing_style_menu), menu_attack);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_attack), TRUE);
menu_all_out_attack = gtk_radio_menu_item_new_with_mnemonic (menu_all_out_defend_group, _("All Out Attack"));
menu_all_out_defend_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_all_out_attack));
@ -401,16 +405,19 @@ create_main_window (void)
menu_scout_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_scout_best));
gtk_widget_show (menu_scout_best);
gtk_container_add (GTK_CONTAINER (menu_scout_menu), menu_scout_best);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_scout_best), TRUE);
menu_scout_good = gtk_radio_menu_item_new_with_mnemonic (menu_scout_best_group, _("Good"));
menu_scout_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_scout_good));
gtk_widget_show (menu_scout_good);
gtk_container_add (GTK_CONTAINER (menu_scout_menu), menu_scout_good);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_scout_good), TRUE);
menu_scout_average = gtk_radio_menu_item_new_with_mnemonic (menu_scout_best_group, _("Average"));
menu_scout_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_scout_average));
gtk_widget_show (menu_scout_average);
gtk_container_add (GTK_CONTAINER (menu_scout_menu), menu_scout_average);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_scout_average), TRUE);
menu_scout_bad = gtk_radio_menu_item_new_with_mnemonic (menu_scout_best_group, _("Bad"));
menu_scout_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_scout_bad));
@ -429,16 +436,19 @@ create_main_window (void)
menu_physio_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_physio_best));
gtk_widget_show (menu_physio_best);
gtk_container_add (GTK_CONTAINER (menu_physio_menu), menu_physio_best);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_physio_best), TRUE);
menu_physio_good = gtk_radio_menu_item_new_with_mnemonic (menu_physio_best_group, _("Good"));
menu_physio_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_physio_good));
gtk_widget_show (menu_physio_good);
gtk_container_add (GTK_CONTAINER (menu_physio_menu), menu_physio_good);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_physio_good), TRUE);
menu_physio_average = gtk_radio_menu_item_new_with_mnemonic (menu_physio_best_group, _("Average"));
menu_physio_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_physio_average));
gtk_widget_show (menu_physio_average);
gtk_container_add (GTK_CONTAINER (menu_physio_menu), menu_physio_average);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_physio_average), TRUE);
menu_physio_bad = gtk_radio_menu_item_new_with_mnemonic (menu_physio_best_group, _("Bad"));
menu_physio_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_physio_bad));
@ -446,28 +456,30 @@ create_main_window (void)
gtk_container_add (GTK_CONTAINER (menu_physio_menu), menu_physio_bad);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_physio_bad), TRUE);
menu_boost_anti_boost = gtk_menu_item_new_with_mnemonic (_("Boost/Anti-boost"));
gtk_widget_show (menu_boost_anti_boost);
gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_boost_anti_boost);
menu_boost_anti_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_boost_anti_boost), menu_boost_anti_menu);
menu_boost_anti = gtk_radio_menu_item_new_with_mnemonic (menu_boost_anti_group, _("Anti-boost"));
menu_boost_anti_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_boost_anti));
gtk_widget_show (menu_boost_anti);
gtk_container_add (GTK_CONTAINER (menu_boost_anti_menu), menu_boost_anti);
menu_boost_normal = gtk_radio_menu_item_new_with_mnemonic (menu_boost_anti_group, _("Normal"));
menu_boost_anti_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_boost_normal));
gtk_widget_show (menu_boost_normal);
gtk_container_add (GTK_CONTAINER (menu_boost_anti_menu), menu_boost_normal);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_boost_normal), TRUE);
menu_boost = gtk_radio_menu_item_new_with_mnemonic (menu_boost_anti_group, _("Boost"));
menu_boost_anti_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_boost));
menu_boost = gtk_menu_item_new_with_mnemonic (_("Boost"));
gtk_widget_show (menu_boost);
gtk_container_add (GTK_CONTAINER (menu_boost_anti_menu), menu_boost);
gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_boost);
menu_boost_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_boost), menu_boost_menu);
menu_boost_on = gtk_radio_menu_item_new_with_mnemonic (menu_boost_on_group, _("On"));
menu_boost_on_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_boost_on));
gtk_widget_show (menu_boost_on);
gtk_container_add (GTK_CONTAINER (menu_boost_menu), menu_boost_on);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_boost_on), TRUE);
menu_boost_off = gtk_radio_menu_item_new_with_mnemonic (menu_boost_on_group, _("Off"));
menu_boost_on_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_boost_off));
gtk_widget_show (menu_boost_off);
gtk_container_add (GTK_CONTAINER (menu_boost_menu), menu_boost_off);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_boost_off), TRUE);
menu_boost_anti = gtk_radio_menu_item_new_with_mnemonic (menu_boost_on_group, _("Anti"));
menu_boost_on_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_boost_anti));
gtk_widget_show (menu_boost_anti);
gtk_container_add (GTK_CONTAINER (menu_boost_menu), menu_boost_anti);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_boost_anti), TRUE);
menu_custom_structure = gtk_menu_item_new_with_mnemonic (_("Enter custom structure"));
gtk_widget_show (menu_custom_structure);
@ -523,9 +535,9 @@ create_main_window (void)
GDK_F9, 0,
GTK_ACCEL_VISIBLE);
image192 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
gtk_widget_show (image192);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image192);
image197 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
gtk_widget_show (image197);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image197);
menu_previous_user = gtk_image_menu_item_new_with_mnemonic (_("Previous user"));
gtk_widget_show (menu_previous_user);
@ -534,9 +546,9 @@ create_main_window (void)
GDK_F8, 0,
GTK_ACCEL_VISIBLE);
image193 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU);
gtk_widget_show (image193);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image193);
image198 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU);
gtk_widget_show (image198);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image198);
menu_manage_users = gtk_image_menu_item_new_with_mnemonic (_("Manage users"));
gtk_widget_show (menu_manage_users);
@ -545,9 +557,9 @@ create_main_window (void)
GDK_F12, 0,
GTK_ACCEL_VISIBLE);
image194 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU);
gtk_widget_show (image194);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image194);
image199 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU);
gtk_widget_show (image199);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image199);
menu_finances_stadium = gtk_menu_item_new_with_mnemonic (_("FinStad"));
gtk_widget_show (menu_finances_stadium);
@ -1090,15 +1102,15 @@ create_main_window (void)
g_signal_connect ((gpointer) menu_physio_bad, "button_press_event",
G_CALLBACK (on_menu_team_button_press_event),
NULL);
g_signal_connect ((gpointer) menu_boost_on, "button_press_event",
G_CALLBACK (on_menu_team_button_press_event),
NULL);
g_signal_connect ((gpointer) menu_boost_off, "button_press_event",
G_CALLBACK (on_menu_team_button_press_event),
NULL);
g_signal_connect ((gpointer) menu_boost_anti, "button_press_event",
G_CALLBACK (on_menu_team_button_press_event),
NULL);
g_signal_connect ((gpointer) menu_boost_normal, "button_press_event",
G_CALLBACK (on_menu_team_button_press_event),
NULL);
g_signal_connect ((gpointer) menu_boost, "button_press_event",
G_CALLBACK (on_menu_team_button_press_event),
NULL);
g_signal_connect ((gpointer) menu_custom_structure, "activate",
G_CALLBACK (on_menu_custom_structure_activate),
NULL);
@ -1209,15 +1221,15 @@ create_main_window (void)
GLADE_HOOKUP_OBJECT (main_window, trennlinie1, "trennlinie1");
GLADE_HOOKUP_OBJECT (main_window, separatormenuitem1, "separatormenuitem1");
GLADE_HOOKUP_OBJECT (main_window, start_editor, "start_editor");
GLADE_HOOKUP_OBJECT (main_window, image189, "image189");
GLADE_HOOKUP_OBJECT (main_window, image194, "image194");
GLADE_HOOKUP_OBJECT (main_window, start_update, "start_update");
GLADE_HOOKUP_OBJECT (main_window, image190, "image190");
GLADE_HOOKUP_OBJECT (main_window, image195, "image195");
GLADE_HOOKUP_OBJECT (main_window, trennlinie2, "trennlinie2");
GLADE_HOOKUP_OBJECT (main_window, menu_quit, "menu_quit");
GLADE_HOOKUP_OBJECT (main_window, menu_options, "menu_options");
GLADE_HOOKUP_OBJECT (main_window, menu_options_menu, "menu_options_menu");
GLADE_HOOKUP_OBJECT (main_window, menu_preferences, "menu_preferences");
GLADE_HOOKUP_OBJECT (main_window, image191, "image191");
GLADE_HOOKUP_OBJECT (main_window, image196, "image196");
GLADE_HOOKUP_OBJECT (main_window, trennlinie7, "trennlinie7");
GLADE_HOOKUP_OBJECT (main_window, menu_notify, "menu_notify");
GLADE_HOOKUP_OBJECT (main_window, menu_job_offers, "menu_job_offers");
@ -1251,11 +1263,11 @@ create_main_window (void)
GLADE_HOOKUP_OBJECT (main_window, menu_physio_good, "menu_physio_good");
GLADE_HOOKUP_OBJECT (main_window, menu_physio_average, "menu_physio_average");
GLADE_HOOKUP_OBJECT (main_window, menu_physio_bad, "menu_physio_bad");
GLADE_HOOKUP_OBJECT (main_window, menu_boost_anti_boost, "menu_boost_anti_boost");
GLADE_HOOKUP_OBJECT (main_window, menu_boost_anti_menu, "menu_boost_anti_menu");
GLADE_HOOKUP_OBJECT (main_window, menu_boost_anti, "menu_boost_anti");
GLADE_HOOKUP_OBJECT (main_window, menu_boost_normal, "menu_boost_normal");
GLADE_HOOKUP_OBJECT (main_window, menu_boost, "menu_boost");
GLADE_HOOKUP_OBJECT (main_window, menu_boost_menu, "menu_boost_menu");
GLADE_HOOKUP_OBJECT (main_window, menu_boost_on, "menu_boost_on");
GLADE_HOOKUP_OBJECT (main_window, menu_boost_off, "menu_boost_off");
GLADE_HOOKUP_OBJECT (main_window, menu_boost_anti, "menu_boost_anti");
GLADE_HOOKUP_OBJECT (main_window, menu_custom_structure, "menu_custom_structure");
GLADE_HOOKUP_OBJECT (main_window, trennlinie8, "trennlinie8");
GLADE_HOOKUP_OBJECT (main_window, menu_browse_teams, "menu_browse_teams");
@ -1269,11 +1281,11 @@ create_main_window (void)
GLADE_HOOKUP_OBJECT (main_window, menu_user, "menu_user");
GLADE_HOOKUP_OBJECT (main_window, menu_user_menu, "menu_user_menu");
GLADE_HOOKUP_OBJECT (main_window, menu_next_user, "menu_next_user");
GLADE_HOOKUP_OBJECT (main_window, image192, "image192");
GLADE_HOOKUP_OBJECT (main_window, image197, "image197");
GLADE_HOOKUP_OBJECT (main_window, menu_previous_user, "menu_previous_user");
GLADE_HOOKUP_OBJECT (main_window, image193, "image193");
GLADE_HOOKUP_OBJECT (main_window, image198, "image198");
GLADE_HOOKUP_OBJECT (main_window, menu_manage_users, "menu_manage_users");
GLADE_HOOKUP_OBJECT (main_window, image194, "image194");
GLADE_HOOKUP_OBJECT (main_window, image199, "image199");
GLADE_HOOKUP_OBJECT (main_window, menu_finances_stadium, "menu_finances_stadium");
GLADE_HOOKUP_OBJECT (main_window, menu_finances_stadium_menu, "menu_finances_stadium_menu");
GLADE_HOOKUP_OBJECT (main_window, menu_increase_capacity, "menu_increase_capacity");

View File

@ -1,6 +1,7 @@
#include "enums.h"
#include "fixture.h"
#include "free.h"
#include "game.h"
#include "game_gui.h"
#include "live_game.h"
#include "maths.h"
@ -56,7 +57,8 @@ live_game_calculate_fixture(Fixture *fix)
if(stat0 != STATUS_LIVE_GAME_PAUSE)
{
live_game_create_stats();
if(fixture_user_team_involved(fix) != -1)
game_create_stats(match);
if(query_fixture_has_tables(fix))
table_update(fix);
@ -305,8 +307,8 @@ live_game_event_foul(void)
live_game_event_injury(!foul_team, fouled_player, TRUE);
}
else if(type == LIVE_GAME_EVENT_FOUL_YELLOW)
game_player_card(match->fix->clid, player_of_id(tm[foul_team], foul_player),
FALSE, FALSE);
player_card_set(player_of_id(tm[foul_team], foul_player),
match->fix->clid, PLAYER_CARD_YELLOW, 1, TRUE);
if(last_unit.area == LIVE_GAME_UNIT_AREA_ATTACK && foul_team ==
last_unit.possession)
@ -380,8 +382,16 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
last_unit.event.type = LIVE_GAME_EVENT_INJURY;
if(math_rnd(0, 1) < const_float("float_live_game_injury_is_temp"))
{
last_unit.event.type = LIVE_GAME_EVENT_TEMP_INJURY;
player_of_id(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->fitness =
MAX(0, player_of_id(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->fitness -
math_rndi(const_int("int_live_game_temp_injury_fitness_decrease_lower"),
const_int("int_live_game_temp_injury_fitness_decrease_upper")));
}
live_game_finish_unit();
if(last_unit.event.type == LIVE_GAME_EVENT_INJURY)
@ -455,12 +465,13 @@ live_game_event_scoring_chance(void)
if(opt_int("int_opt_debug"))
printf("live_game_event_scoring_chance\n");
if(math_rnd(0, 1) < const_float("float_live_game_scoring_chance_is_own_goal"))
{
last_unit.event.type = LIVE_GAME_EVENT_OWN_GOAL;
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
game_get_player(tm[!last_unit.possession], last_unit.area, 0, -1, FALSE);
game_get_player(tm[!last_unit.possession], GAME_PLAYER_TYPE_DEFEND, 0, -1, FALSE);
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = !last_unit.possession;
match->fix->result[last_unit.possession][res_idx]++;
last_unit.result[last_unit.possession]++;
}
@ -496,7 +507,8 @@ live_game_event_scoring_chance(void)
live_game_finish_unit();
live_game_event_duel();
if(last_unit.event.type != LIVE_GAME_EVENT_OWN_GOAL)
live_game_event_duel();
}
/** Calculate a penalty event. */
@ -741,7 +753,12 @@ live_game_event_send_off(gint team, gint player, gboolean second_yellow)
live_game_finish_unit();
game_player_card(match->fix->clid, player_of_id(tm[team], player), TRUE, second_yellow);
player_of_id(tm[team], player)->cskill = 0;
if(second_yellow)
player_card_set(player_of_id(tm[team], player), match->fix->clid, PLAYER_CARD_RED, 1, FALSE);
else
player_card_set(player_of_id(tm[team], player), match->fix->clid, PLAYER_CARD_RED,
game_player_get_ban_duration(), FALSE);
if(match->subs_left[team] > 0)
{
@ -846,6 +863,7 @@ live_game_event_duel(void)
new.minute = -1;
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1;
new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = new.possession;
new.event.commentary = g_string_new("duel");
@ -1086,6 +1104,7 @@ live_game_unit_get_minute(const LiveGameUnit *unit)
void
live_game_reset(Fixture *fix)
{
gint i;
match = (fixture_user_team_involved(fix) != -1) ?
&usr(fixture_user_team_involved(fix)).live_game : &live_game_temp;
show = (fixture_user_team_involved(fix) != -1 &&
@ -1099,6 +1118,12 @@ live_game_reset(Fixture *fix)
free_live_game(match);
unis = g_array_new(FALSE, FALSE, sizeof(LiveGameUnit));
for(i=0;i<LIVE_GAME_STAT_ARRAY_END;i++)
{
match->stats.players[i][0] = g_ptr_array_new();
match->stats.players[i][1] = g_ptr_array_new();
}
match->fix = fix;
match->subs_left[0] = match->subs_left[1] = 3;
@ -1263,91 +1288,41 @@ live_game_generate_commentary(LiveGameUnit *unit)
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str,
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure);
break;
case LIVE_GAME_EVENT_STYLE_CHANGE:
g_string_printf(commentary, "%s changes style to %s.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str,
team_style_to_char(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->style));
case LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND:
g_string_printf(commentary, "%s changes style to ALL OUT DEFEND.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
break;
case LIVE_GAME_EVENT_STYLE_CHANGE_DEFEND:
g_string_printf(commentary, "%s changes style to DEFEND.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
break;
case LIVE_GAME_EVENT_STYLE_CHANGE_BALANCED:
g_string_printf(commentary, "%s changes style to BALANCED.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
break;
case LIVE_GAME_EVENT_STYLE_CHANGE_ATTACK:
g_string_printf(commentary, "%s changes style to ATTACK.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
break;
case LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_ATTACK:
g_string_printf(commentary, "%s changes style to ALL OUT ATTACK.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
break;
case LIVE_GAME_EVENT_BOOST_CHANGE_ANTI:
g_string_printf(commentary, "%s changes boost to ANTI.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
break;
case LIVE_GAME_EVENT_BOOST_CHANGE_OFF:
g_string_printf(commentary, "%s changes boost to OFF.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
break;
case LIVE_GAME_EVENT_BOOST_CHANGE_ON:
g_string_printf(commentary, "%s changes boost to ON.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
break;
case LIVE_GAME_EVENT_BOOST_CHANGE:
if(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->boost == 1)
g_string_printf(commentary, "%s changes boost to ON.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
else if(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->boost == 0)
g_string_printf(commentary, "%s changes (anti-)boost to OFF.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
else
g_string_printf(commentary, "%s changes anti-boost to ON.",
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
}
}
/** Assemble some stats like ball possession or shots
on goal. @see #LiveGameStats */
void
live_game_create_stats(void)
{
gint i, possession[2] = {0, 0};
LiveGameStats *stat = &match->stats;
for(i=0;i<LIVE_GAME_STAT_VALUE_END;i++)
stat->values[0][i] =
stat->values[1][i] = 0;
stat->values[0][LIVE_GAME_STAT_VALUE_GOALS] =
math_sum_int_array(match->fix->result[0], 2);
stat->values[1][LIVE_GAME_STAT_VALUE_GOALS] =
math_sum_int_array(match->fix->result[1], 2);
for(i=0;i<unis->len;i++)
{
if(uni(i).minute != -1)
possession[uni(i).possession]++;
if(uni(i).event.type == LIVE_GAME_EVENT_SCORING_CHANCE ||
uni(i).event.type == LIVE_GAME_EVENT_FREE_KICK)
stat->values[uni(i).possession][LIVE_GAME_STAT_VALUE_SHOTS]++;
else if(uni(i).event.type == LIVE_GAME_EVENT_PENALTY &&
uni(i).time != LIVE_GAME_UNIT_TIME_PENALTIES)
stat->values[uni(i).possession][LIVE_GAME_STAT_VALUE_PENALTIES]++;
else if(uni(i).event.type == LIVE_GAME_EVENT_INJURY ||
uni(i).event.type == LIVE_GAME_EVENT_TEMP_INJURY)
stat->values[uni(i).possession][LIVE_GAME_STAT_VALUE_INJURIES]++;
else if(uni(i).event.type == LIVE_GAME_EVENT_FOUL ||
uni(i).event.type == LIVE_GAME_EVENT_FOUL_YELLOW ||
uni(i).event.type == LIVE_GAME_EVENT_FOUL_RED ||
uni(i).event.type == LIVE_GAME_EVENT_FOUL_RED_INJURY)
{
stat->values[!uni(i).possession][LIVE_GAME_STAT_VALUE_FOULS]++;
if(uni(i).event.type == LIVE_GAME_EVENT_FOUL_YELLOW)
stat->values[!uni(i).possession][LIVE_GAME_STAT_VALUE_CARDS]++;
}
else if(uni(i).event.type == LIVE_GAME_EVENT_SEND_OFF)
stat->values[!uni(i).possession][LIVE_GAME_STAT_VALUE_REDS]++;
}
stat->values[0][LIVE_GAME_STAT_VALUE_POSSESSION] =
(gint)rint((gfloat)possession[0] / (gfloat)(possession[0] + possession[1]) * 100);
stat->values[1][LIVE_GAME_STAT_VALUE_POSSESSION] =
100 - stat->values[0][LIVE_GAME_STAT_VALUE_POSSESSION];
/*d*/
/* printf("goals\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_GOALS], */
/* stat->values[1][LIVE_GAME_STAT_VALUE_GOALS]); */
/* printf("shots\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_SHOTS], */
/* stat->values[1][LIVE_GAME_STAT_VALUE_SHOTS]); */
/* printf("poss\t %d%% \t %d%%\n", stat->values[0][LIVE_GAME_STAT_VALUE_POSSESSION], */
/* stat->values[1][LIVE_GAME_STAT_VALUE_POSSESSION]); */
/* printf("pen.\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_PENALTIES], */
/* stat->values[1][LIVE_GAME_STAT_VALUE_PENALTIES]); */
/* printf("fouls\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_FOULS], */
/* stat->values[1][LIVE_GAME_STAT_VALUE_FOULS]); */
/* printf("cards\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_CARDS], */
/* stat->values[1][LIVE_GAME_STAT_VALUE_CARDS]); */
/* printf("reds\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_REDS], */
/* stat->values[1][LIVE_GAME_STAT_VALUE_REDS]); */
/* printf("inj.\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_INJURIES], */
/* stat->values[1][LIVE_GAME_STAT_VALUE_INJURIES]); */
}
/** Calculate which area the ball is going to be in in
the next unit.
@param unit The previous unit.
@ -1413,10 +1388,11 @@ live_game_finish_unit(void)
live_game_generate_commentary(unit);
if(unit->minute != -1 && unit->time != LIVE_GAME_UNIT_TIME_PENALTIES)
if(unit->minute != -1 && unit->time != LIVE_GAME_UNIT_TIME_PENALTIES &&
fixture_user_team_involved(match->fix) != -1)
{
game_decrease_fitness(match->fix);
if(stat2 == current_user &&
if(stat2 == current_user && show &&
unit->minute % const_int("int_live_game_player_list_refresh") == 0)
treeview_show_user_player_list(&usr(current_user), 1);
}
@ -1500,10 +1476,12 @@ live_game_resume(void)
live_game_event_team_change(i, LIVE_GAME_EVENT_STRUCTURE_CHANGE);
if(tm[i]->style != usr(stat2).live_game.team_state[i].style)
live_game_event_team_change(i, LIVE_GAME_EVENT_STYLE_CHANGE);
live_game_event_team_change(i, LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND +
tm[i]->style + 2);
if(tm[i]->boost != usr(stat2).live_game.team_state[i].boost)
live_game_event_team_change(i, LIVE_GAME_EVENT_BOOST_CHANGE);
live_game_event_team_change(i, LIVE_GAME_EVENT_BOOST_CHANGE_ANTI +
tm[i]->boost + 1);
}
live_game_calculate_fixture(usr(stat2).live_game.fix);

View File

@ -2,7 +2,6 @@
#define LIVE_GAME_STRUCT_H
#include "bygfoot.h"
#include "fixture.h"
#include "game.h"
/** Events happening during a live game.
@ -44,8 +43,14 @@ enum LiveGameEventType
LIVE_GAME_EVENT_STADIUM_RIOTS,
LIVE_GAME_EVENT_SUBSTITUTION,
LIVE_GAME_EVENT_STRUCTURE_CHANGE,
LIVE_GAME_EVENT_STYLE_CHANGE,
LIVE_GAME_EVENT_BOOST_CHANGE,
LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND,
LIVE_GAME_EVENT_STYLE_CHANGE_DEFEND,
LIVE_GAME_EVENT_STYLE_CHANGE_BALANCED,
LIVE_GAME_EVENT_STYLE_CHANGE_ATTACK,
LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_ATTACK,
LIVE_GAME_EVENT_BOOST_CHANGE_ANTI,
LIVE_GAME_EVENT_BOOST_CHANGE_OFF,
LIVE_GAME_EVENT_BOOST_CHANGE_ON,
LIVE_GAME_EVENT_END
};
@ -85,8 +90,9 @@ enum LiveGameUnitTime
/** Indices for the values in #LiveGameStats. */
enum LiveGameStatValue
{
LIVE_GAME_STAT_VALUE_GOALS = 0,
LIVE_GAME_STAT_VALUE_GOALS_REGULAR = 0,
LIVE_GAME_STAT_VALUE_SHOTS,
LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE,
LIVE_GAME_STAT_VALUE_POSSESSION,
LIVE_GAME_STAT_VALUE_PENALTIES,
LIVE_GAME_STAT_VALUE_FOULS,
@ -104,13 +110,22 @@ enum LiveGameUnitArea
LIVE_GAME_UNIT_AREA_END
};
enum LiveGameStatArray
{
LIVE_GAME_STAT_ARRAY_SCORERS = 0,
LIVE_GAME_STAT_ARRAY_REDS,
LIVE_GAME_STAT_ARRAY_YELLOWS,
LIVE_GAME_STAT_ARRAY_INJURED,
LIVE_GAME_STAT_ARRAY_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];
GPtrArray *players[LIVE_GAME_STAT_ARRAY_END][2];
} LiveGameStats;
/** A struct telling us what's happening at

View File

@ -869,24 +869,25 @@ create_graph_window (void)
}
GtkWidget*
create_progressbar_window (void)
create_window_progress (void)
{
GtkWidget *progressbar_window;
GtkWidget *window_progress;
GtkWidget *progressbar;
progressbar_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_title (GTK_WINDOW (progressbar_window), _("window1"));
gtk_window_set_position (GTK_WINDOW (progressbar_window), GTK_WIN_POS_CENTER);
window_progress = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_title (GTK_WINDOW (window_progress), _("window1"));
gtk_window_set_position (GTK_WINDOW (window_progress), GTK_WIN_POS_CENTER);
gtk_window_set_modal (GTK_WINDOW (window_progress), TRUE);
progressbar = gtk_progress_bar_new ();
gtk_widget_show (progressbar);
gtk_container_add (GTK_CONTAINER (progressbar_window), progressbar);
gtk_container_add (GTK_CONTAINER (window_progress), progressbar);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (progressbar_window, progressbar_window, "progressbar_window");
GLADE_HOOKUP_OBJECT (progressbar_window, progressbar, "progressbar");
GLADE_HOOKUP_OBJECT_NO_REF (window_progress, window_progress, "window_progress");
GLADE_HOOKUP_OBJECT (window_progress, progressbar, "progressbar");
return progressbar_window;
return window_progress;
}
GtkWidget*

View File

@ -5,5 +5,5 @@
GtkWidget* create_stadium_window (void);
GtkWidget* create_job_offer_window (void);
GtkWidget* create_graph_window (void);
GtkWidget* create_progressbar_window (void);
GtkWidget* create_window_progress (void);
GtkWidget* create_window_warning (void);

View File

@ -7,6 +7,7 @@
#include "misc_callback_func.h"
#include "misc_callbacks.h"
#include "option.h"
#include "treeview.h"
#include "user.h"
#include "variables.h"
#include "window.h"
@ -247,3 +248,13 @@ on_treeview_users_button_press_event (GtkWidget *widget,
return FALSE;
}
void
on_button_show_stats_clicked (GtkButton *button,
gpointer user_data)
{
treeview_show_game_stats(GTK_TREE_VIEW(lookup_widget(window.live,
"treeview_commentary")),
&usr(stat2).live_game);
gtk_widget_hide(GTK_WIDGET(button));
}

View File

@ -112,4 +112,8 @@ on_treeview_users_button_press_event (GtkWidget *widget,
void
on_entry_player_name_activate (GtkEntry *entry,
gpointer user_data);
void
on_button_show_stats_clicked (GtkButton *button,
gpointer user_data);
#endif

View File

@ -546,6 +546,11 @@ create_window_live (void)
GtkWidget *hbox52;
GtkWidget *image57;
GtkWidget *label73;
GtkWidget *button_show_stats;
GtkWidget *alignment20;
GtkWidget *hbox56;
GtkWidget *image60;
GtkWidget *label77;
GtkWidget *button_live_close;
GtkObject *spinbutton_speed_adj;
GtkWidget *spinbutton_speed;
@ -650,6 +655,25 @@ create_window_live (void)
gtk_widget_show (label73);
gtk_box_pack_start (GTK_BOX (hbox52), label73, FALSE, FALSE, 0);
button_show_stats = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (hbox48), button_show_stats, FALSE, FALSE, 0);
alignment20 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment20);
gtk_container_add (GTK_CONTAINER (button_show_stats), alignment20);
hbox56 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox56);
gtk_container_add (GTK_CONTAINER (alignment20), hbox56);
image60 = gtk_image_new_from_stock ("gtk-select-color", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image60);
gtk_box_pack_start (GTK_BOX (hbox56), image60, FALSE, FALSE, 0);
label77 = gtk_label_new_with_mnemonic (_("_Show stats"));
gtk_widget_show (label77);
gtk_box_pack_start (GTK_BOX (hbox56), label77, FALSE, FALSE, 0);
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);
@ -670,6 +694,9 @@ create_window_live (void)
g_signal_connect ((gpointer) button_resume, "clicked",
G_CALLBACK (on_button_resume_clicked),
NULL);
g_signal_connect ((gpointer) button_show_stats, "clicked",
G_CALLBACK (on_button_show_stats_clicked),
NULL);
g_signal_connect ((gpointer) button_live_close, "clicked",
G_CALLBACK (on_button_live_close_clicked),
NULL);
@ -699,6 +726,11 @@ create_window_live (void)
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_show_stats, "button_show_stats");
GLADE_HOOKUP_OBJECT (window_live, alignment20, "alignment20");
GLADE_HOOKUP_OBJECT (window_live, hbox56, "hbox56");
GLADE_HOOKUP_OBJECT (window_live, image60, "image60");
GLADE_HOOKUP_OBJECT (window_live, label77, "label77");
GLADE_HOOKUP_OBJECT (window_live, button_live_close, "button_live_close");
GLADE_HOOKUP_OBJECT (window_live, spinbutton_speed, "spinbutton_speed");

View File

@ -583,7 +583,7 @@ player_is_banned(const Player *pl)
{
gint i;
Fixture *fix = team_get_next_fixture(pl->team);
gint yellow_red;
gint yellow_red, yellow, red;
if(fix == NULL)
return 0;
@ -593,18 +593,14 @@ player_is_banned(const Player *pl)
else
yellow_red = cup_from_clid(fix->clid)->yellow_red;
for(i=0;i<pl->cards->len;i++)
if(g_array_index(pl->cards, PlayerCard, 0).clid == fix->clid)
{
if(g_array_index(pl->cards, PlayerCard, 0).red > 0)
return g_array_index(pl->cards, PlayerCard, 0).red;
if(g_array_index(pl->cards, PlayerCard, 0).yellow ==
yellow_red - 1)
return -1;
yellow = player_card_get(pl, fix->clid, PLAYER_CARD_YELLOW);
red = player_card_get(pl, fix->clid, PLAYER_CARD_RED);
return 0;
}
if(red > 0)
return red;
if(yellow == yellow_red - 1)
return -1;
return 0;
}
@ -629,7 +625,7 @@ player_get_game_skill(const Player *pl, gboolean skill)
void
player_decrease_fitness(Player *pl)
{
gint i;
gint i, reduction;
gint age_limits[7] =
{const_int("int_player_fitness_decrease_peak_age_diff1"),
const_int("int_player_fitness_decrease_peak_age_diff2"),
@ -654,5 +650,76 @@ player_decrease_fitness(Player *pl)
if(diff > age_limits[i])
break;
pl->fitness = MAX(0, pl->fitness - reduce[i]);
reduction = (gint)rint((gfloat)reduce[i] *
(1 + pl->team->boost * const_float("float_player_boost_fitness_effect")));
pl->fitness = MAX(0, pl->fitness - reduction);
}
/** Return the number of yellow cards of a player
or the number of weeks banned.
@param pl The player.
@param clid The cup or league id.
@param card_type Whether red or yellow cards. */
gint
player_card_get(const Player *pl, gint clid, gint card_type)
{
gint i;
gint return_value = -1;
for(i=0;i<pl->cards->len;i++)
if(g_array_index(pl->cards, PlayerCard, i).clid == clid)
{
if(card_type == PLAYER_CARD_YELLOW)
return_value = g_array_index(pl->cards, PlayerCard, i).yellow;
else
return_value = g_array_index(pl->cards, PlayerCard, i).red;
break;
}
return return_value;
}
/** Change a card value for the player.
@param pl The player.
@param clid The cup or league id.
@param card_type Whether red or yellow card.
@param value The new value.
@param diff Whether we add the value to the old one or
replace the old value by the new one. */
void
player_card_set(Player *pl, gint clid, gint card_type, gint value, gboolean diff)
{
gint i, *card_value;
PlayerCard new;
for(i=0;i<pl->cards->len;i++)
if(g_array_index(pl->cards, PlayerCard, i).clid == clid)
{
if(card_type == PLAYER_CARD_YELLOW)
card_value = &g_array_index(pl->cards, PlayerCard, i).yellow;
else
card_value = &g_array_index(pl->cards, PlayerCard, i).red;
if(diff)
*card_value += value;
else
*card_value = value;
if(*card_value < 0)
{
g_warning("player_card_set: negative card value; setting to 0\n");
*card_value = 0;
}
return;
}
new.clid = clid;
new.yellow = new.red = 0;
g_array_append_val(pl->cards, new);
player_card_set(pl, clid, card_type, value, diff);
}

View File

@ -12,6 +12,13 @@ enum PlayerCompareAttrib
PLAYER_COMPARE_ATTRIBUTE_END
};
enum PlayerCardType
{
PLAYER_CARD_YELLOW = 0,
PLAYER_CARD_RED,
PLAYER_CARD_END
};
Player
player_new(Team *tm, gint average_skill);
@ -87,4 +94,10 @@ player_get_game_skill(const Player *pl, gboolean skill);
void
player_decrease_fitness(Player *pl);
gint
player_card_get(const Player *pl, gint clid, gint card_type);
void
player_card_set(Player *pl, gint clid, gint card_type, gint value, gboolean diff);
#endif

View File

@ -1,6 +1,7 @@
#include "cup.h"
#include "file.h"
#include "fixture.h"
#include "gui.h"
#include "league.h"
#include "live_game.h"
#include "main.h"
@ -198,19 +199,18 @@ end_week_round_results(void)
{
live_game_calculate_fixture(&g_array_index(cp(i).fixtures, Fixture, j));
/*d*/
printf("%d %d %d %25s %d %d %d - %d %d %d %-25s\n", week, week_round,
g_array_index(cp(i).fixtures, Fixture, j).clid,
g_array_index(cp(i).fixtures, Fixture, j).teams[0]->name->str,
g_array_index(cp(i).fixtures, Fixture, j).result[0][0],
g_array_index(cp(i).fixtures, Fixture, j).result[0][1],
g_array_index(cp(i).fixtures, Fixture, j).result[0][2],
g_array_index(cp(i).fixtures, Fixture, j).result[1][0],
g_array_index(cp(i).fixtures, Fixture, j).result[1][1],
g_array_index(cp(i).fixtures, Fixture, j).result[1][2],
g_array_index(cp(i).fixtures, Fixture, j).teams[1]->name->str);
/* printf("%d %d %d %25s %d %d %d - %d %d %d %-25s\n", week, week_round, */
/* g_array_index(cp(i).fixtures, Fixture, j).clid, */
/* g_array_index(cp(i).fixtures, Fixture, j).teams[0]->name->str, */
/* g_array_index(cp(i).fixtures, Fixture, j).result[0][0], */
/* g_array_index(cp(i).fixtures, Fixture, j).result[0][1], */
/* g_array_index(cp(i).fixtures, Fixture, j).result[0][2], */
/* g_array_index(cp(i).fixtures, Fixture, j).result[1][0], */
/* g_array_index(cp(i).fixtures, Fixture, j).result[1][1], */
/* g_array_index(cp(i).fixtures, Fixture, j).result[1][2], */
/* g_array_index(cp(i).fixtures, Fixture, j).teams[1]->name->str); */
}
}
printf("\n");
}
/** Sort league and cup tables. */

View File

@ -604,29 +604,3 @@ team_rearrange(Team *tm)
player_get_cskill(player_of(tm, i), player_of(tm, i)->cpos) : player_of(tm, i)->skill;
}
}
/** Describe the playing style in words.
@param style The team style.
@return The name of the style. */
gchar*
team_style_to_char(gint style)
{
switch(style)
{
default:
g_warning("team_style_to_char: unknown style %d\n", style);
return NULL;
case PLAYING_STYLE_ALL_OUT_DEFEND:
return _("All Out Defend");
case PLAYING_STYLE_DEFEND:
return _("Defend");
case PLAYING_STYLE_BALANCED:
return _("Balanced");
case PLAYING_STYLE_ATTACK:
return _("Attack");
case PLAYING_STYLE_ALL_OUT_ATTACK:
return _("All Out Attack");
}
return NULL;
}

View File

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

View File

@ -179,10 +179,22 @@ treeview_live_game_icon(gint event_type)
return const_str("string_live_game_event_substitution_icon");
else if(event_type == LIVE_GAME_EVENT_STRUCTURE_CHANGE)
return const_str("string_live_game_event_structure_change_icon");
else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE)
return const_str("string_live_game_event_style_change_icon");
else if(event_type == LIVE_GAME_EVENT_BOOST_CHANGE)
return const_str("string_live_game_event_boost_change_icon");
else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND)
return const_str("string_live_game_event_style_change_all_out_defend_icon");
else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_DEFEND)
return const_str("string_live_game_event_style_change_defend_icon");
else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_BALANCED)
return const_str("string_live_game_event_style_change_balanced_icon");
else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ATTACK)
return const_str("string_live_game_event_style_change_attack_icon");
else if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_ATTACK)
return const_str("string_live_game_event_style_change_all_out_attack_icon");
else if(event_type == LIVE_GAME_EVENT_BOOST_CHANGE_ANTI)
return const_str("string_live_game_event_boost_change_anti_icon");
else if(event_type == LIVE_GAME_EVENT_BOOST_CHANGE_OFF)
return const_str("string_live_game_event_boost_change_off_icon");
else if(event_type == LIVE_GAME_EVENT_BOOST_CHANGE_ON)
return const_str("string_live_game_event_boost_change_on_icon");
else
return "";
}
@ -817,3 +829,136 @@ treeview_show_users_startup(void)
gtk_tree_view_set_model(treeview, model);
g_object_unref(model);
}
/** Fill a model with live game stats.
@param live_game The live game. */
GtkTreeModel*
treeview_create_game_stats(LiveGame *live_game)
{
gint i, j, k;
LiveGameStats *stats = &live_game->stats;
GtkListStore *liststore;
GtkTreeIter iter;
gchar buf[2][SMALL];
gchar buf3[SMALL];
gchar *categories[LIVE_GAME_STAT_VALUE_END] =
{_("Goals (w/o pen.)"),
_("Shots"),
_("Shot %"),
_("Possession"),
_("Penalties"),
_("Fouls"),
_("Yellows"),
_("Reds"),
_("Injuries")};
liststore = gtk_list_store_new(3,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING);
sprintf(buf[0], "%d : %d",
math_sum_int_array(live_game->fix->result[0], 3),
math_sum_int_array(live_game->fix->result[1], 3));
gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, live_game->fix->teams[0]->name->str,
1, buf[0],
2, live_game->fix->teams[1]->name->str,
-1);
for(k=0;k<LIVE_GAME_STAT_ARRAY_END;k++)
{
if(k == LIVE_GAME_STAT_ARRAY_SCORERS)
{
strcpy(buf[0], "");
strcpy(buf[1], "");
}
else
{
strcpy(buf[1], " </span>");
if(k == LIVE_GAME_STAT_ARRAY_INJURED)
sprintf(buf[0], "<span background='%s'> ",
const_str("string_treeview_cell_color_player_injury"));
else if(k == LIVE_GAME_STAT_ARRAY_REDS)
sprintf(buf[0], "<span background='%s'> ",
const_str("string_treeview_cell_color_player_banned"));
else if(k == LIVE_GAME_STAT_ARRAY_YELLOWS)
sprintf(buf[0], "<span background='%s'> ",
const_str("string_treeview_cell_color_player_yellow_danger"));
}
for(i=0;i<MAX(stats->players[k][0]->len,
stats->players[k][1]->len);i++)
{
gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 1, "", -1);
for(j=0;j<2;j++)
{
if(i < stats->players[k][j]->len)
{
sprintf(buf3, "%s%s%s", buf[0],
((GString*)g_ptr_array_index(stats->players[k][j], i))->str,
buf[1]);
gtk_list_store_set(liststore, &iter, j * 2, buf3, -1);
}
}
}
}
gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, "", 1, "", 2, "", -1);
for(i=0;i<LIVE_GAME_STAT_VALUE_END;i++)
{
for(j=0;j<2;j++)
sprintf(buf[j], "%d", stats->values[j][i]);
gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, buf[0],
1, categories[i],
2, buf[1], -1);
}
return GTK_TREE_MODEL(liststore);
}
/** Configure a treeview to show game stats.
@param treeview The treeview. */
void
treeview_set_up_game_stats(GtkTreeView *treeview)
{
gint i;
GtkTreeViewColumn *col;
GtkCellRenderer *renderer;
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
GTK_SELECTION_NONE);
for(i=0;i<3;i++)
{
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,
"markup", i);
g_object_set(renderer, "xalign", 0 + (2 - i) * 0.5,
NULL);
}
}
/** Show the stats of the live game in a treeview.
@param live_game The live game. */
void
treeview_show_game_stats(GtkTreeView *treeview, LiveGame *live_game)
{
GtkTreeModel *model = NULL;
treeview_clear(treeview);
gtk_tree_view_set_headers_visible(treeview, FALSE);
treeview_set_up_game_stats(treeview);
model = treeview_create_game_stats(live_game);
gtk_tree_view_set_model(treeview, model);
g_object_unref(model);
}

View File

@ -84,4 +84,13 @@ treeview_create_users_startup(void);
void
treeview_set_up_users_startup(GtkTreeView *treeview);
GtkTreeModel*
treeview_create_game_stats(LiveGame *live_game);
void
treeview_show_game_stats(GtkTreeView *treeview, LiveGame *live_game);
void
treeview_set_up_game_stats(GtkTreeView *treeview);
#endif

View File

@ -171,7 +171,7 @@ treeview_cell_player_contract_to_cell(GtkCellRenderer *renderer, gchar *buf, gin
void
treeview_cell_player_cards_to_cell(gchar *buf, const Player *pl)
{
gint i;
gint yellow;
Fixture *fix =
team_get_next_fixture(pl->team);
@ -185,24 +185,24 @@ treeview_cell_player_cards_to_cell(gchar *buf, const Player *pl)
sprintf(buf, "%d(%d)", g_array_index(pl->cards, PlayerCard, 0).yellow,
player_all_cards(pl));
else
sprintf(buf, "%d", g_array_index(pl->cards, PlayerCard, 0).yellow);
sprintf(buf, "%d", g_array_index(pl->cards, PlayerCard, 0).yellow);
}
return;
}
for(i=0;i<pl->cards->len;i++)
if(g_array_index(pl->cards, PlayerCard, 0).clid == fix->clid)
{
if(opt_user_int("int_opt_user_show_overall"))
sprintf(buf, "%d(%d)", g_array_index(pl->cards, PlayerCard, i).yellow,
player_all_cards(pl));
else
sprintf(buf, "%d", g_array_index(pl->cards, PlayerCard, i).yellow);
return;
}
yellow = player_card_get(pl, fix->clid, PLAYER_CARD_YELLOW);
strcpy(buf, "0");
if(yellow != -1)
{
if(opt_user_int("int_opt_user_show_overall"))
sprintf(buf, "%d(%d)", yellow,
player_all_cards(pl));
else
sprintf(buf, "%d", yellow);
}
else
strcpy(buf, "0");
}
/** Render a cell of player status.

View File

@ -11,6 +11,7 @@
User
user_new(void)
{
gint i;
User new;
new.name = g_string_new("NONAME");
@ -20,6 +21,10 @@ user_new(void)
new.live_game.units = NULL;
new.live_game.fix = NULL;
for(i=0;i<LIVE_GAME_STAT_ARRAY_END;i++)
new.live_game.stats.players[i][0] =
new.live_game.stats.players[i][1] = NULL;
new.options = g_array_new(FALSE, FALSE, sizeof(Option));
return new;

View File

@ -40,20 +40,6 @@ window_show_startup(void)
free_g_string_array(&dir_contents);
}
/** Set 'Bygfoot x.y.z' into the title of a window.
@param window The window widget pointer.
@see #VERS */
GtkWidget*
window_set_version(GtkWidget *wind)
{
gchar buf[SMALL];
sprintf(buf, "Bygfoot Football Manager %s", VERS);
gtk_window_set_title(GTK_WINDOW(wind), buf);
return wind;
}
/** Create and show a window. Which one depends on the argument.
@param window_type An integer telling us which window to
create.
@ -65,8 +51,11 @@ GtkWidget*
window_create(gint window_type)
{
gint old_popups_active = popups_active;
gchar buf[SMALL];
GtkWidget *wind = NULL;
sprintf(buf, "Bygfoot Football Manager %s", VERS);
switch(window_type)
{
default:
@ -100,6 +89,7 @@ window_create(gint window_type)
popups_active++;
window.live = create_window_live();
}
strcpy(buf, "Bygfoot Live game");
wind = window.live;
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(lookup_widget(wind, "spinbutton_speed")),
@ -113,6 +103,7 @@ window_create(gint window_type)
popups_active++;
window.startup_users = create_window_startup_users();
}
strcpy(buf, "Users");
wind = window.startup_users;
break;
case WINDOW_WARNING:
@ -121,10 +112,19 @@ window_create(gint window_type)
else
window.warning = create_window_warning();
wind = window.warning;
strcpy(buf, "Erm...");
break;
case WINDOW_PROGRESS:
if(window.progress != NULL)
g_warning("window_create: called on already existing window\n");
else
window.progress = create_window_progress();
wind = window.progress;
strcpy(buf, "");
break;
}
window_set_version(wind);
gtk_window_set_title(GTK_WINDOW(wind), buf);
gtk_widget_show(wind);
if(popups_active < old_popups_active && window.main != NULL)

View File

@ -12,15 +12,13 @@ enum Windows
WINDOW_LIVE,
WINDOW_STARTUP_USERS,
WINDOW_WARNING,
WINDOW_PROGRESS,
WINDOW_END
};
void
window_show_startup(void);
GtkWidget*
window_set_version(GtkWidget *window);
GtkWidget*
window_create(gint window_type);

View File

@ -188,8 +188,6 @@ float_live_game_foul_red_injury 50
float_live_game_foul_red 80
float_live_game_foul_yellow 230
gfloat duration[6]={0,0.7,0.85,0.95,0.975,1};
# ban duration probabilities
# should add up to 1000
float_live_game_ban_1 700
@ -246,6 +244,10 @@ int_player_injury_duration_dev_shoulder 5
int_player_injury_duration_ligament 22
int_player_injury_duration_dev_ligament 8
# fitness decrease when injury is temporary
int_live_game_temp_injury_fitness_decrease_lower 200
int_live_game_temp_injury_fitness_decrease_upper 800
# refresh rate of the player list during a live game
# the smaller the more often the list gets refreshed
int_live_game_player_list_refresh 5
@ -374,24 +376,30 @@ string_treeview_cell_color_player_bad_cskill_fg red
string_treeview_cell_live_game_result_attributes weight='bold' size='large'
# icons used in live games
string_live_game_event_start_match_icon
string_live_game_event_start_match_icon whistle.png
string_live_game_event_lost_possession_icon
string_live_game_event_penalty_icon
string_live_game_event_scoring_chance_icon
string_live_game_event_penalty_icon striker.png
string_live_game_event_scoring_chance_icon striker.png
string_live_game_event_goal_icon goal.png
string_live_game_event_own_goal_icon goal.png
string_live_game_event_own_goal_icon own_goal.png
string_live_game_event_post_icon
string_live_game_event_save_icon save.png
string_live_game_event_missed_icon
string_live_game_event_missed_icon miss.png
string_live_game_event_foul_icon
string_live_game_event_foul_yellow_icon yellow.png
string_live_game_event_send_off_icon red.png
string_live_game_event_injury_icon
string_live_game_event_temp_injury_icon
string_live_game_event_injury_icon injury.png
string_live_game_event_temp_injury_icon injury_temp.png
string_live_game_event_stadium_breakdown_icon
string_live_game_event_stadium_fire_icon
string_live_game_event_stadium_riots_icon
string_live_game_event_substitution_icon
string_live_game_event_structure_change_icon
string_live_game_event_style_change_icon
string_live_game_event_boost_change_icon
string_live_game_event_substitution_icon sub.png
string_live_game_event_structure_change_icon structure_change.png
string_live_game_event_style_change_all_out_defend_icon style_change.png
string_live_game_event_style_change_defend_icon style_change.png
string_live_game_event_style_change_balanced_icon style_change.png
string_live_game_event_style_change_attack_icon style_change.png
string_live_game_event_style_change_all_out_attack_icon boost_change.png
string_live_game_event_boost_change_anti_icon boost_change.png
string_live_game_event_boost_change_off_icon style_change.png
string_live_game_event_boost_change_on_icon boost_change.png

View File

@ -6,7 +6,7 @@
int_opt_user_confirm_unfit 1
int_opt_user_show_live_game 1
int_opt_user_live_game_speed 0
int_opt_user_live_game_speed -10
int_opt_user_show_tendency_bar 1
int_opt_user_notify_transfer 0
int_opt_user_notify_pos -1
@ -44,7 +44,7 @@ int_opt_user_pl1_att_games 1
int_opt_user_pl1_att_shots 1
int_opt_user_pl1_att_goals 1
int_opt_user_pl1_att_status 1
int_opt_user_pl1_att_cards 0
int_opt_user_pl1_att_cards 1
int_opt_user_pl1_att_age 1
int_opt_user_pl1_att_etal 1
int_opt_user_pl1_att_value 0