1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2025-06-05 21:49:20 +02:00

Live game development.

This commit is contained in:
gyboth
2005-03-11 12:17:48 +00:00
parent aace8d7782
commit e3ee5be2c7
14 changed files with 482 additions and 204 deletions

View File

@@ -928,29 +928,100 @@
<property name="spacing">3</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow8">
<widget class="GtkHBox" id="hbox57">
<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>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkTreeView" id="treeview_result">
<widget class="GtkEventBox" id="eventbox_poss0">
<property name="visible">True</property>
<property name="visible_window">True</property>
<property name="above_child">False</property>
<child>
<widget class="GtkLabel" id="label78">
<property name="visible">True</property>
<property name="label" translatable="yes"> </property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</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="scrolledwindow8">
<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>
<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">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkEventBox" id="eventbox_poss1">
<property name="visible">True</property>
<property name="visible_window">True</property>
<property name="above_child">False</property>
<child>
<widget class="GtkLabel" id="label79">
<property name="visible">True</property>
<property name="label" translatable="yes"> </property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
</packing>
</child>
@@ -973,23 +1044,103 @@
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow9">
<widget class="GtkNotebook" id="notebook1">
<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>
<property name="show_tabs">True</property>
<property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<child>
<widget class="GtkTreeView" id="treeview_commentary">
<widget class="GtkScrolledWindow" id="scrolledwindow9">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="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="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label80">
<property name="visible">True</property>
<property name="label" translatable="yes">Commentary</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow11">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview_stats">
<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="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label81">
<property name="visible">True</property>
<property name="label" translatable="yes">Statistics</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
@@ -1170,80 +1321,6 @@
</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

@@ -91,10 +91,10 @@ free_live_game(LiveGame *match)
{
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));
for(k=0;k<match->stats.players[i][j]->len;k++)
free_g_string((GString**)&g_ptr_array_index(match->stats.players[i][j], k));
free_g_ptr_array(&match->stats.players[j][i]);
free_g_ptr_array(&match->stats.players[i][j]);
}
}

View File

@@ -1,7 +1,7 @@
#include "fixture.h"
#include "game.h"
#include "game_gui.h"
#include "live_game_struct.h"
#include "live_game.h"
#include "maths.h"
#include "misc.h"
#include "option.h"
@@ -792,11 +792,10 @@ game_create_stats_players(gpointer live_game)
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",
sprintf(buf, "%s %d%s",
((GString*)g_ptr_array_index(
stats->players[LIVE_GAME_STAT_ARRAY_SCORERS][array_index], j))->str,
minute);
strcat(buf, buf2);
minute, buf2);
g_string_printf(((GString*)g_ptr_array_index(
stats->players[LIVE_GAME_STAT_ARRAY_SCORERS][array_index], j)),
"%s", buf);
@@ -810,9 +809,8 @@ game_create_stats_players(gpointer live_game)
}
else
{
sprintf(buf, "%s %d", player_of_id(match->fix->teams[team], player)->name->str,
minute);
strcat(buf, buf2);
sprintf(buf, "%s %d%s", player_of_id(match->fix->teams[team], player)->name->str,
minute, 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);
@@ -846,3 +844,143 @@ game_create_stats_players(gpointer live_game)
}
}
}
/** Update the live game stats using the live game unit.
@param live_game_stats Pointer to the live game.
@param live_game_unit The live game unit. */
void
game_update_stats(gpointer live_game, gconstpointer live_game_unit)
{
gint i;
LiveGameStats *stats = &((LiveGame*)live_game)->stats;
const LiveGameUnit *unit = (const LiveGameUnit*)live_game_unit;
if(unit->minute != -1)
stats->values[unit->possession][LIVE_GAME_STAT_VALUE_POSSESSION]++;
if(unit->event.type == LIVE_GAME_EVENT_SCORING_CHANCE ||
unit->event.type == LIVE_GAME_EVENT_FREE_KICK)
stats->values[unit->possession][LIVE_GAME_STAT_VALUE_SHOTS]++;
else if(unit->event.type == LIVE_GAME_EVENT_PENALTY)
stats->values[unit->possession][LIVE_GAME_STAT_VALUE_PENALTIES]++;
else if(unit->event.type == LIVE_GAME_EVENT_INJURY)
{
stats->values[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_INJURIES]++;
game_update_stats_player(live_game, live_game_unit);
}
else if(unit->event.type == LIVE_GAME_EVENT_FOUL ||
unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW ||
unit->event.type == LIVE_GAME_EVENT_FOUL_RED ||
unit->event.type == LIVE_GAME_EVENT_FOUL_RED_INJURY)
{
stats->values[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_FOULS]++;
if(unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW)
{
stats->values[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_CARDS]++;
game_update_stats_player(live_game, live_game_unit);
}
}
else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF)
{
stats->values[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_REDS]++;
game_update_stats_player(live_game, live_game_unit);
}
else if(unit->event.type == LIVE_GAME_EVENT_GOAL &&
live_game_unit_before(unit, -1)->event.type != LIVE_GAME_EVENT_PENALTY)
{
stats->values[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]][LIVE_GAME_STAT_VALUE_GOALS_REGULAR]++;
game_update_stats_player(live_game, live_game_unit);
}
for(i=0;i<2;i++)
stats->values[i][LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE] =
(stats->values[i][LIVE_GAME_STAT_VALUE_SHOTS] > 0) ?
(gint)rint(((gfloat)stats->values[i][LIVE_GAME_STAT_VALUE_GOALS_REGULAR] /
(gfloat)stats->values[i][LIVE_GAME_STAT_VALUE_SHOTS]) * 100) : 0;
}
/** Update the player array in the live game stats.
@param live_game Pointer to the live game.
@param team The team of the player.
@param player The player id.
@param type The type of the stat. */
void
game_update_stats_player(gpointer live_game, gconstpointer live_game_unit)
{
gint i;
gchar buf[SMALL], buf2[SMALL];
LiveGameStats *stats = &((LiveGame*)live_game)->stats;
const LiveGameUnit *unit = (const LiveGameUnit*)live_game_unit;
gint minute = live_game_unit_get_minute(unit), array_index = -1;
gboolean own_goal;
gint team = unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM],
player = unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER],
player2 = unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2];
const Team *tm[2] = {((LiveGame*)live_game)->fix->teams[0],
((LiveGame*)live_game)->fix->teams[1]};
GString *new = NULL;
GPtrArray *players = NULL;
if(unit->event.type == LIVE_GAME_EVENT_GOAL ||
unit->event.type == LIVE_GAME_EVENT_OWN_GOAL)
{
own_goal = (unit->event.type == LIVE_GAME_EVENT_OWN_GOAL);
array_index = (own_goal) ? !team : team;
if(live_game_unit_before(unit, -1)->event.type == LIVE_GAME_EVENT_PENALTY)
strcpy(buf2, " (P)");
else if(live_game_unit_before(unit, -1)->event.type == LIVE_GAME_EVENT_FREE_KICK)
strcpy(buf2, " (FK)");
else if(unit->event.type == LIVE_GAME_EVENT_OWN_GOAL)
strcpy(buf2, " (OG)");
else
strcpy(buf2, "");
for(i=0;i<stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS]->len;i++)
{
if(g_str_has_prefix(((GString*)g_ptr_array_index(
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i))->str,
player_of_id(tm[team], player)->name->str))
{
sprintf(buf, "%s %d%s",
((GString*)g_ptr_array_index(
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i))->str,
minute, buf2);
g_string_printf(((GString*)g_ptr_array_index(
stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], i)),
"%s", buf);
return;
}
}
sprintf(buf, "%s %d%s", player_of_id(tm[team], player)->name->str,
minute, buf2);
new = g_string_new(buf);
g_ptr_array_add(stats->players[array_index][LIVE_GAME_STAT_ARRAY_SCORERS], new);
}
else
{
strcpy(buf, "");
if(unit->event.type == LIVE_GAME_EVENT_INJURY)
{
sprintf(buf, "%s", player_of_id(tm[team], player)->name->str);
players = stats->players[team][LIVE_GAME_STAT_ARRAY_INJURED];
}
else if(unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW)
{
sprintf(buf, "%s", player_of_id(tm[team], player2)->name->str);
players = stats->players[team][LIVE_GAME_STAT_ARRAY_YELLOWS];
}
else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF)
{
sprintf(buf, "%s", player_of_id(tm[team], player)->name->str);
players = stats->players[team][LIVE_GAME_STAT_ARRAY_REDS];
}
if(strlen(buf) > 0)
{
new = g_string_new(buf);
g_ptr_array_add(players, new);
}
}
}

View File

@@ -96,4 +96,10 @@ game_create_stats(gpointer live_game);
void
game_create_stats_players(gpointer live_game);
void
game_update_stats(gpointer live_game, gconstpointer live_game_unit);
void
game_update_stats_player(gpointer live_game, gconstpointer live_game_unit);
#endif

View File

@@ -1,5 +1,6 @@
#include <unistd.h>
#include "file.h"
#include "game_gui.h"
#include "gui.h"
#include "league.h"
@@ -25,7 +26,9 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit)
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_show_stats = lookup_widget(window.live, "button_show_stats");
*eventbox_poss[2] = {lookup_widget(window.live, "eventbox_poss0"),
lookup_widget(window.live, "eventbox_poss1")};
GdkColor color;
if(unit->event.type == LIVE_GAME_EVENT_START_MATCH)
treeview_live_game_show_initial_commentary(unit);
@@ -34,6 +37,10 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit)
treeview_live_game_show_result(unit);
gdk_color_parse (const_str("string_live_game_possession_color"), &color);
gtk_widget_modify_bg(eventbox_poss[unit->possession], GTK_STATE_NORMAL, &color);
gtk_widget_modify_bg(eventbox_poss[!unit->possession], GTK_STATE_NORMAL, NULL);
game_gui_live_game_set_hscale(unit,
GTK_HSCALE(lookup_widget(window.live, "hscale_area")));
@@ -49,14 +56,12 @@ 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)

View File

@@ -8,6 +8,7 @@
#include "misc_callback_func.h"
#include "option.h"
#include "player.h"
#include "support.h"
#include "table.h"
#include "team.h"
#include "treeview.h"
@@ -57,8 +58,8 @@ live_game_calculate_fixture(Fixture *fix)
if(stat0 != STATUS_LIVE_GAME_PAUSE)
{
if(fixture_user_team_involved(fix) != -1)
game_create_stats(match);
/* if(fixture_user_team_involved(fix) != -1) */
/* game_create_stats(match); */
if(query_fixture_has_tables(fix))
table_update(fix);
@@ -1099,6 +1100,40 @@ live_game_unit_get_minute(const LiveGameUnit *unit)
return -1;
}
/** Return the unit before or after the specified one.
@param unit The unit specified.
@param gap How many units to skip. */
LiveGameUnit*
live_game_unit_before(const LiveGameUnit* unit, gint gap)
{
gint i;
if(gap < 0)
{
for(i=unis->len - 1;i>=0;i--)
if(&uni(i) == unit)
{
if(i - gap > 0)
return &uni(i - gap);
else
g_warning("live_game_unit_before: no unit found for gap %d\n", gap);
}
}
else
{
for(i=unis->len - 1;i>=0;i--)
if(&uni(i) == unit)
{
if(i + gap < unis->len)
return &uni(i + gap);
else
g_warning("live_game_unit_before: no unit found for gap %d\n", gap);
}
}
return NULL;
}
/** Free the live game variable before we begin a new live game.
@param fix The fixture we'll show. */
void
@@ -1121,10 +1156,14 @@ live_game_reset(Fixture *fix)
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->stats.players[0][i] = g_ptr_array_new();
match->stats.players[1][i] = g_ptr_array_new();
}
for(i=0;i<LIVE_GAME_STAT_VALUE_END;i++)
match->stats.values[0][i] =
match->stats.values[1][i] = 0;
match->fix = fix;
match->subs_left[0] = match->subs_left[1] = 3;
match->stadium_event = FALSE;
@@ -1386,8 +1425,6 @@ live_game_finish_unit(void)
{
LiveGameUnit *unit = &last_unit;
live_game_generate_commentary(unit);
if(unit->minute != -1 && unit->time != LIVE_GAME_UNIT_TIME_PENALTIES &&
fixture_user_team_involved(match->fix) != -1)
{
@@ -1397,6 +1434,18 @@ live_game_finish_unit(void)
treeview_show_user_player_list(&usr(current_user), 1);
}
if(fixture_user_team_involved(match->fix) != -1)
{
if(unit->time != LIVE_GAME_UNIT_TIME_PENALTIES)
{
game_update_stats(match, unit);
treeview_show_game_stats(GTK_TREE_VIEW(lookup_widget(window.live, "treeview_stats")),
match);
}
live_game_generate_commentary(unit);
}
if(show)
game_gui_live_game_show_unit(unit);
}

View File

@@ -103,4 +103,7 @@ live_game_event_team_change(gint team_number, gint event_type);
void
live_game_finish_unit(void);
LiveGameUnit*
live_game_unit_before(const LiveGameUnit* unit, gint gap);
#endif

View File

@@ -125,7 +125,7 @@ typedef struct
{
gfloat possession;
gint values[2][LIVE_GAME_STAT_VALUE_END];
GPtrArray *players[LIVE_GAME_STAT_ARRAY_END][2];
GPtrArray *players[2][LIVE_GAME_STAT_ARRAY_END];
} LiveGameStats;
/** A struct telling us what's happening at

View File

@@ -247,14 +247,3 @@ 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,8 +112,4 @@ 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

@@ -530,11 +530,21 @@ create_window_live (void)
GtkWidget *progressbar_live;
GtkWidget *hbox50;
GtkWidget *vbox38;
GtkWidget *hbox57;
GtkWidget *eventbox_poss0;
GtkWidget *label78;
GtkWidget *scrolledwindow8;
GtkWidget *treeview_result;
GtkWidget *eventbox_poss1;
GtkWidget *label79;
GtkWidget *hscale_area;
GtkWidget *notebook1;
GtkWidget *scrolledwindow9;
GtkWidget *treeview_commentary;
GtkWidget *label80;
GtkWidget *scrolledwindow11;
GtkWidget *treeview_stats;
GtkWidget *label81;
GtkWidget *hbox48;
GtkWidget *button_pause;
GtkWidget *alignment16;
@@ -546,11 +556,6 @@ 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;
@@ -580,9 +585,21 @@ create_window_live (void)
gtk_widget_show (vbox38);
gtk_box_pack_start (GTK_BOX (hbox50), vbox38, TRUE, TRUE, 0);
hbox57 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox57);
gtk_box_pack_start (GTK_BOX (vbox38), hbox57, FALSE, FALSE, 0);
eventbox_poss0 = gtk_event_box_new ();
gtk_widget_show (eventbox_poss0);
gtk_box_pack_start (GTK_BOX (hbox57), eventbox_poss0, FALSE, TRUE, 0);
label78 = gtk_label_new (_(" "));
gtk_widget_show (label78);
gtk_container_add (GTK_CONTAINER (eventbox_poss0), label78);
scrolledwindow8 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow8);
gtk_box_pack_start (GTK_BOX (vbox38), scrolledwindow8, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox57), scrolledwindow8, TRUE, 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);
@@ -591,14 +608,26 @@ create_window_live (void)
gtk_container_add (GTK_CONTAINER (scrolledwindow8), treeview_result);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview_result), FALSE);
eventbox_poss1 = gtk_event_box_new ();
gtk_widget_show (eventbox_poss1);
gtk_box_pack_start (GTK_BOX (hbox57), eventbox_poss1, FALSE, TRUE, 0);
label79 = gtk_label_new (_(" "));
gtk_widget_show (label79);
gtk_container_add (GTK_CONTAINER (eventbox_poss1), label79);
hscale_area = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (5, 0, 10, 0, 0, 0)));
gtk_widget_show (hscale_area);
gtk_box_pack_start (GTK_BOX (vbox38), hscale_area, FALSE, TRUE, 0);
gtk_scale_set_draw_value (GTK_SCALE (hscale_area), FALSE);
notebook1 = gtk_notebook_new ();
gtk_widget_show (notebook1);
gtk_box_pack_start (GTK_BOX (vbox38), notebook1, TRUE, TRUE, 0);
scrolledwindow9 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow9);
gtk_box_pack_start (GTK_BOX (vbox38), scrolledwindow9, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (notebook1), scrolledwindow9);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow9), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow9), GTK_SHADOW_ETCHED_IN);
@@ -606,6 +635,24 @@ create_window_live (void)
gtk_widget_show (treeview_commentary);
gtk_container_add (GTK_CONTAINER (scrolledwindow9), treeview_commentary);
label80 = gtk_label_new (_("Commentary"));
gtk_widget_show (label80);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), label80);
scrolledwindow11 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow11);
gtk_container_add (GTK_CONTAINER (notebook1), scrolledwindow11);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow11), GTK_SHADOW_IN);
treeview_stats = gtk_tree_view_new ();
gtk_widget_show (treeview_stats);
gtk_container_add (GTK_CONTAINER (scrolledwindow11), treeview_stats);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview_stats), FALSE);
label81 = gtk_label_new (_("Statistics"));
gtk_widget_show (label81);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 1), label81);
hbox48 = gtk_hbox_new (FALSE, 4);
gtk_widget_show (hbox48);
gtk_box_pack_start (GTK_BOX (vbox36), hbox48, FALSE, TRUE, 5);
@@ -655,25 +702,6 @@ 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);
@@ -694,9 +722,6 @@ 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);
@@ -710,11 +735,21 @@ create_window_live (void)
GLADE_HOOKUP_OBJECT (window_live, progressbar_live, "progressbar_live");
GLADE_HOOKUP_OBJECT (window_live, hbox50, "hbox50");
GLADE_HOOKUP_OBJECT (window_live, vbox38, "vbox38");
GLADE_HOOKUP_OBJECT (window_live, hbox57, "hbox57");
GLADE_HOOKUP_OBJECT (window_live, eventbox_poss0, "eventbox_poss0");
GLADE_HOOKUP_OBJECT (window_live, label78, "label78");
GLADE_HOOKUP_OBJECT (window_live, scrolledwindow8, "scrolledwindow8");
GLADE_HOOKUP_OBJECT (window_live, treeview_result, "treeview_result");
GLADE_HOOKUP_OBJECT (window_live, eventbox_poss1, "eventbox_poss1");
GLADE_HOOKUP_OBJECT (window_live, label79, "label79");
GLADE_HOOKUP_OBJECT (window_live, hscale_area, "hscale_area");
GLADE_HOOKUP_OBJECT (window_live, notebook1, "notebook1");
GLADE_HOOKUP_OBJECT (window_live, scrolledwindow9, "scrolledwindow9");
GLADE_HOOKUP_OBJECT (window_live, treeview_commentary, "treeview_commentary");
GLADE_HOOKUP_OBJECT (window_live, label80, "label80");
GLADE_HOOKUP_OBJECT (window_live, scrolledwindow11, "scrolledwindow11");
GLADE_HOOKUP_OBJECT (window_live, treeview_stats, "treeview_stats");
GLADE_HOOKUP_OBJECT (window_live, label81, "label81");
GLADE_HOOKUP_OBJECT (window_live, hbox48, "hbox48");
GLADE_HOOKUP_OBJECT (window_live, button_pause, "button_pause");
GLADE_HOOKUP_OBJECT (window_live, alignment16, "alignment16");
@@ -726,11 +761,6 @@ 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

@@ -649,26 +649,15 @@ treeview_live_game_create_result(const LiveGameUnit *unit)
{
GtkListStore *liststore;
GtkTreeIter iter;
GdkPixbuf *symbol = NULL;
symbol =
treeview_pixbuf_from_filename("possession_ball.png");
liststore = gtk_list_store_new(5,
GDK_TYPE_PIXBUF,
liststore = gtk_list_store_new(3,
G_TYPE_POINTER,
G_TYPE_POINTER,
G_TYPE_POINTER,
GDK_TYPE_PIXBUF);
G_TYPE_POINTER);
gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, NULL, 1, (gpointer)usr(stat2).live_game.fix,
2, (gpointer)unit, 3, (gpointer)usr(stat2).live_game.fix, 4, NULL, -1);
gtk_list_store_set(liststore, &iter, 0 + (unit->possession == 1) * 4, symbol, -1);
if(symbol != NULL)
g_object_unref(symbol);
gtk_list_store_set(liststore, &iter, 0, (gpointer)usr(stat2).live_game.fix,
1, (gpointer)unit, 2, (gpointer)usr(stat2).live_game.fix, -1);
return GTK_TREE_MODEL(liststore);
}
@@ -685,13 +674,6 @@ treeview_live_game_set_up_result(void)
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();
@@ -715,13 +697,6 @@ treeview_live_game_set_up_result(void)
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
@@ -886,17 +861,18 @@ treeview_create_game_stats(LiveGame *live_game)
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++)
for(i=0;i<MAX(stats->players[0][k]->len,
stats->players[1][k]->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)
if(i < stats->players[j][k]->len)
{
sprintf(buf3, "%s%s%s", buf[0],
((GString*)g_ptr_array_index(stats->players[k][j], i))->str,
((GString*)g_ptr_array_index(stats->players[j][k], i))->str,
buf[1]);
gtk_list_store_set(liststore, &iter, j * 2, buf3, -1);
}
@@ -909,8 +885,14 @@ treeview_create_game_stats(LiveGame *live_game)
for(i=0;i<LIVE_GAME_STAT_VALUE_END;i++)
{
for(j=0;j<2;j++)
sprintf(buf[j], "%d", stats->values[j][i]);
if(i != LIVE_GAME_STAT_VALUE_POSSESSION)
for(j=0;j<2;j++)
sprintf(buf[j], "%d", stats->values[j][i]);
else
for(j=0;j<2;j++)
sprintf(buf[j], "%d", (gint)rint(100 * ((gfloat)stats->values[j][i] /
((gfloat)stats->values[0][i] +
(gfloat)stats->values[1][i]))));
gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, buf[0],

View File

@@ -395,14 +395,14 @@ treeview_cell_live_game_result(GtkTreeViewColumn *col,
strcpy(buf, "");
if(column == 1 || column == 3)
if(column == 0 || column == 2)
{
gtk_tree_model_get(model, iter, column, &fix, -1);
sprintf(buf, "<span %s>%s</span>",
const_str("string_treeview_cell_live_game_result_attributes"),
fix->teams[column == 3]->name->str);
fix->teams[column == 2]->name->str);
}
else if(column == 2)
else if(column == 1)
{
gtk_tree_model_get(model, iter, column, &unit, -1);
sprintf(buf, "<span %s>%d : %d</span>",

View File

@@ -375,6 +375,9 @@ string_treeview_cell_color_player_bad_cskill_fg red
# font attributes for the live game window result.
string_treeview_cell_live_game_result_attributes weight='bold' size='large'
# colour indicating ball possession during a live game
string_live_game_possession_color darkblue
# icons used in live games
string_live_game_event_start_match_icon whistle.png
string_live_game_event_lost_possession_icon