mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-02-11 17:10:40 +01:00
User histories.
This commit is contained in:
parent
844694d652
commit
c852e415c3
@ -64,7 +64,7 @@
|
||||
<accelerator key="l" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image289">
|
||||
<widget class="GtkImage" id="image293">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-open</property>
|
||||
<property name="icon_size">1</property>
|
||||
@ -132,7 +132,7 @@
|
||||
<accelerator key="p" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image290">
|
||||
<widget class="GtkImage" id="image294">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-preferences</property>
|
||||
<property name="icon_size">1</property>
|
||||
@ -643,6 +643,22 @@
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="trennlinie12">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menu_user_show_history">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Show history</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_menu_user_show_history_activate" last_modification_time="Fri, 15 Apr 2005 15:08:24 GMT"/>
|
||||
<accelerator key="h" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="trennlinie9">
|
||||
<property name="visible">True</property>
|
||||
@ -658,7 +674,7 @@
|
||||
<accelerator key="F9" modifiers="0" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image291">
|
||||
<widget class="GtkImage" id="image295">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-go-forward</property>
|
||||
<property name="icon_size">1</property>
|
||||
@ -680,7 +696,7 @@
|
||||
<accelerator key="F8" modifiers="0" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image292">
|
||||
<widget class="GtkImage" id="image296">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-go-back</property>
|
||||
<property name="icon_size">1</property>
|
||||
@ -702,7 +718,7 @@
|
||||
<accelerator key="F12" modifiers="0" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image293">
|
||||
<widget class="GtkImage" id="image297">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-justify-fill</property>
|
||||
<property name="icon_size">1</property>
|
||||
|
@ -10,17 +10,17 @@ bin_PROGRAMS = bygfoot
|
||||
|
||||
bygfoot_SOURCES = \
|
||||
callback_func.c callback_func.h callbacks.h cup.h finance.h fixture.h game_gui.h league.h live_game.h maths.h misc.h option.h player.h start_end.h team.h transfer.h treeview.h user.h window.h \
|
||||
callbacks.c callbacks.h callback_func.h free.h game_gui.h gui.h load_save.h main.h option.h player.h team.h transfer.h treeview.h user.h window.h \
|
||||
callbacks.c callbacks.h callback_func.h free.h game_gui.h gui.h load_save.h main.h option.h player.h team.h transfer.h treeview.h treeview_helper.h user.h window.h \
|
||||
cup.c cup.h fixture.h free.h league.h main.h maths.h misc.h team.h variables.h xml_league.h \
|
||||
file.c file.h free.h main.h misc.h option.h support.h variables.h \
|
||||
finance.c callbacks.h finance.h game_gui.h maths.h option.h player.h team.h user.h \
|
||||
fixture.c cup.h fixture.h free.h league.h main.h maths.h misc.h table.h team.h variables.h \
|
||||
fixture.c cup.h fixture.h free.h league.h main.h maths.h misc.h option.h user.h table.h team.h variables.h \
|
||||
free.c free.h user.h variables.h \
|
||||
game.c cup.h finance.h fixture.h game.h game_gui.h league.h live_game.h maths.h misc.h option.h player.h table.h team.h treeview.h user.h variables.h \
|
||||
game_gui.c file.h callbacks.h file.h game_gui.h gui.h league.h live_game.h maths.h misc.h option.h treeview.h support.h team.h user.h variables.h window.h \
|
||||
gui.c gui.h misc.h support.h variables.h window.h \
|
||||
interface.c callbacks.h interface.h support.h \
|
||||
league.c cup.h league.h maths.h option.h player.h table.h team.h variables.h \
|
||||
league.c cup.h league.h maths.h option.h player.h user.h table.h team.h variables.h \
|
||||
live_game.c fixture.h free.h game.h game_gui.h live_game.h maths.h misc_callback_func.h option.h player.h support.h team.h treeview.h user.h variables.h window.h \
|
||||
load_save.c callbacks.h file.h game_gui.h gui.h load_save.h option.h support.h user.h variables.h xml_loadsave_misc.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_transfers.h xml_loadsave_users.h xml.h \
|
||||
main.c cup_struct.h misc_callbacks.h file.h free.h league_struct.h live_game.h main.h transfer_struct.h variables.h window.h \
|
||||
@ -42,9 +42,9 @@ bygfoot_SOURCES = \
|
||||
table.c cup.h league.h table.h variables.h \
|
||||
team.c cup.h fixture.h game.h game_gui.h league.h maths.h misc.h option.h player.h team.h transfer.h user.h \
|
||||
transfer.c finance.h free.h game_gui.h maths.h option.h player.h support.h team.h transfer.h treeview.h user.h \
|
||||
treeview.c cup.h file.h finance.h fixture.h free.h game.h league.h live_game.h maths.h misc.h player.h option.h support.h team.h transfer.h treeview.h treeview_cell.h user.h \
|
||||
treeview_cell.c cup.h league.h misc.h option.h player.h team.h treeview.h treeview_cell.h user.h variables.h \
|
||||
user.c fixture.h free.h game_gui.h live_game.h maths.h misc.h option.h player.h team.h transfer.h treeview.h user.h window.h \
|
||||
treeview.c cup.h finance.h fixture.h free.h game.h league.h live_game.h maths.h misc.h player.h option.h support.h team.h transfer.h treeview.h treeview_helper.h user.h \
|
||||
treeview_helper.c cup.h file.h fixture.h free.h league.h misc.h option.h player.h support.h team.h treeview.h treeview_helper.h user.h variables.h \
|
||||
user.c cup.h fixture.h free.h game_gui.h league.h live_game.h maths.h misc.h option.h player.h team.h transfer.h treeview.h user.h window.h \
|
||||
window.c file.h finance.h free.h game_gui.h gui.h interface.h main.h misc_interface.h misc2_interface.h option.h support.h user.h window.h \
|
||||
xml.c cup.h file.h free.h gui.h league.h misc.h support.h table.h transfer_struct.h user.h variables.h xml.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_teams.h xml_loadsave_fixtures.h xml_loadsave_table.h xml_loadsave_transfers.h xml_loadsave_users.h \
|
||||
xml_loadsave_misc.c cup.h file.h misc.h variables.h xml.h xml_loadsave_misc.h xml_loadsave_cup.h xml_loadsave_league.h \
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "team.h"
|
||||
#include "transfer.h"
|
||||
#include "treeview.h"
|
||||
#include "treeview_helper.h"
|
||||
#include "user.h"
|
||||
#include "window.h"
|
||||
|
||||
@ -349,7 +350,7 @@ callback_show_team(gint type)
|
||||
|
||||
if(type == SHOW_CURRENT)
|
||||
{
|
||||
tm = (const Team*)treeview_get_pointer(treeview_right, 2);
|
||||
tm = (const Team*)treeview_helper_get_pointer(treeview_right, 2);
|
||||
stat1 = team_get_index(tm);
|
||||
}
|
||||
else if(type == SHOW_NEXT)
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "team.h"
|
||||
#include "transfer.h"
|
||||
#include "treeview.h"
|
||||
#include "treeview_helper.h"
|
||||
#include "user.h"
|
||||
#include "window.h"
|
||||
|
||||
@ -179,8 +180,8 @@ on_player_list1_button_press_event (GtkWidget *widget,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if(treeview_select_row(GTK_TREE_VIEW(widget), event))
|
||||
idx = treeview_get_index(GTK_TREE_VIEW(widget), 0);
|
||||
if(treeview_helper_select_row(GTK_TREE_VIEW(widget), event))
|
||||
idx = treeview_helper_get_index(GTK_TREE_VIEW(widget), 0);
|
||||
|
||||
if(idx < 0 || idx - 1 == selected_row[0])
|
||||
{
|
||||
@ -461,8 +462,8 @@ on_treeview_right_button_press_event (GtkWidget *widget,
|
||||
GTK_SELECTION_NONE)
|
||||
return TRUE;
|
||||
|
||||
if(treeview_select_row(GTK_TREE_VIEW(widget), event))
|
||||
idx = treeview_get_index(GTK_TREE_VIEW(widget), 0);
|
||||
if(treeview_helper_select_row(GTK_TREE_VIEW(widget), event))
|
||||
idx = treeview_helper_get_index(GTK_TREE_VIEW(widget), 0);
|
||||
else
|
||||
return TRUE;
|
||||
|
||||
@ -784,3 +785,13 @@ on_menu_load_last_save_activate (GtkMenuItem *menuitem,
|
||||
{
|
||||
load_save_load_game("last_save");
|
||||
}
|
||||
|
||||
void
|
||||
on_menu_user_show_history_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
stat0 = STATUS_SHOW_USER_HISTORY;
|
||||
treeview_show_user_history();
|
||||
|
||||
gui_set_arrows();
|
||||
}
|
||||
|
@ -236,7 +236,6 @@ on_player_menu_show_info_activate (GtkMenuItem *menuitem,
|
||||
void
|
||||
on_menu_rearrange_team_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data);
|
||||
#endif
|
||||
|
||||
void
|
||||
on_menu_load_last_save_activate (GtkMenuItem *menuitem,
|
||||
@ -245,3 +244,8 @@ on_menu_load_last_save_activate (GtkMenuItem *menuitem,
|
||||
void
|
||||
on_menu_fixtures_week_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
on_menu_user_show_history_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data);
|
||||
#endif
|
||||
|
47
src/cup.c
47
src/cup.c
@ -666,19 +666,11 @@ cup_round_name(const Fixture *fix, gchar *buf)
|
||||
const CupRound *cup_round =
|
||||
&g_array_index(cup->rounds, CupRound, fix->round);
|
||||
|
||||
if(cup_round->round_robin_number_of_groups > 0)
|
||||
cup_get_round_name(cup, fix->round, buf);
|
||||
|
||||
if(cup_round->round_robin_number_of_groups == 0)
|
||||
strcpy(buf, "Round robin");
|
||||
else
|
||||
{
|
||||
if(fix->round == cup->rounds->len - 1)
|
||||
strcpy(buf, _("Final"));
|
||||
else if(fix->round == cup->rounds->len - 2)
|
||||
strcpy(buf, _("Semi-final"));
|
||||
else if(fix->round == cup->rounds->len - 3)
|
||||
strcpy(buf, _("Quarter-final"));
|
||||
else
|
||||
sprintf(buf, _("Last %d"), (gint)rint(powf(2, cup->rounds->len - fix->round)));
|
||||
|
||||
{
|
||||
if(cup_round->home_away)
|
||||
{
|
||||
if(fix->second_leg)
|
||||
@ -691,6 +683,37 @@ cup_round_name(const Fixture *fix, gchar *buf)
|
||||
}
|
||||
}
|
||||
|
||||
/** Return the cup round given by the number. */
|
||||
void
|
||||
cup_get_round_name(const Cup *cup, gint round, gchar *buf)
|
||||
{
|
||||
const CupRound *cup_round =
|
||||
&g_array_index(cup->rounds, CupRound, round);
|
||||
|
||||
if(cup_round->round_robin_number_of_groups > 0)
|
||||
{
|
||||
strcpy(buf, _("Round robin"));
|
||||
return;
|
||||
}
|
||||
|
||||
switch(cup->rounds->len - round)
|
||||
{
|
||||
default:
|
||||
sprintf(buf, "Last %d", (gint)rint(powf(2, cup->rounds->len - round)));
|
||||
break;
|
||||
case 1:
|
||||
strcpy(buf, _("Final"));
|
||||
break;
|
||||
case 2:
|
||||
strcpy(buf, _("Semi-final"));
|
||||
break;
|
||||
case 3:
|
||||
strcpy(buf, _("Quarter-final"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Find out whether it's time to write the
|
||||
fixtures for the supercup. */
|
||||
gboolean
|
||||
|
@ -69,4 +69,7 @@ cup_get_choose_team_league_cup(const CupChooseTeam *ct,
|
||||
gint
|
||||
cup_get_last_week_from_first(const Cup *cup, gint first_week);
|
||||
|
||||
void
|
||||
cup_get_round_name(const Cup *cup, gint round, gchar *buf);
|
||||
|
||||
#endif
|
||||
|
@ -74,6 +74,7 @@ enum Status0Value
|
||||
STATUS_SHOW_TABLES,
|
||||
STATUS_SHOW_FINANCES,
|
||||
STATUS_SHOW_TRANSFER_LIST,
|
||||
STATUS_SHOW_USER_HISTORY,
|
||||
STATUS_GET_LOAN,
|
||||
STATUS_PAY_LOAN,
|
||||
STATUS_SHOW_EVENT,
|
||||
|
@ -81,7 +81,7 @@ finance_update_user_weekly(User *user)
|
||||
_("You have to pay back your loan this week."));
|
||||
if(user->counters[COUNT_USER_POSITIVE] == 0)
|
||||
user_event_add(user, EVENT_TYPE_WARNING, -1, -1, NULL,
|
||||
_("Your bank account has to exceed your drawing credit limit next week."));
|
||||
_("Your bank account has to be above your drawing credit limit next week."));
|
||||
|
||||
if((user->counters[COUNT_USER_LOAN] == -1 && user->debt != 0) ||
|
||||
(user->counters[COUNT_USER_POSITIVE] == -1 &&
|
||||
@ -89,6 +89,8 @@ finance_update_user_weekly(User *user)
|
||||
{
|
||||
new_team = team_get_new(tm, TRUE);
|
||||
user_event_add(user, EVENT_TYPE_FIRE_FINANCE, -1, -1, new_team, NULL);
|
||||
user_history_add(user, USER_HISTORY_FIRE_FINANCES, tm->id,
|
||||
new_team->id, new_team->clid, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "main.h"
|
||||
#include "maths.h"
|
||||
#include "misc.h"
|
||||
#include "option.h"
|
||||
#include "user.h"
|
||||
#include "table.h"
|
||||
#include "team.h"
|
||||
#include "variables.h"
|
||||
@ -1090,7 +1092,11 @@ fixture_get_next_week(gint *week_number, gint *week_round_number)
|
||||
for(i=0;i<ligs->len;i++)
|
||||
{
|
||||
fix = fixture_get_next(lig(i).id, local_week, local_round);
|
||||
if(fix->week_number > local_week && fix->week_number < *week_number)
|
||||
if((fix->week_number > local_week ||
|
||||
(fix->week_number == local_week && fix->week_round_number > local_round)) &&
|
||||
(fix->week_number < *week_number ||
|
||||
(fix->week_number == *week_number && fix->week_round_number < *week_round_number)) &&
|
||||
(fix->clid == current_user.tm->clid || opt_user_int("int_opt_user_show_all_leagues")))
|
||||
{
|
||||
*week_number = fix->week_number;
|
||||
*week_round_number = 1;
|
||||
@ -1132,7 +1138,8 @@ fixture_get_previous_week(gint *week_number, gint *week_round_number)
|
||||
if((fix->week_number < local_week ||
|
||||
(fix->week_number == local_week && fix->week_round_number < local_round)) &&
|
||||
(fix->week_number > *week_number ||
|
||||
(fix->week_number == *week_number && fix->week_round_number > *week_round_number)))
|
||||
(fix->week_number == *week_number && fix->week_round_number > *week_round_number)) &&
|
||||
(fix->clid == current_user.tm->clid || opt_user_int("int_opt_user_show_all_leagues")))
|
||||
{
|
||||
*week_number = fix->week_number;
|
||||
*week_round_number = 1;
|
||||
|
@ -53,6 +53,11 @@ free_user(User *user)
|
||||
free_event(&g_array_index(user->events, Event, i));
|
||||
|
||||
free_g_array(&user->events);
|
||||
|
||||
for(i=0;i<user->history->len;i++)
|
||||
g_string_free(g_array_index(user->history,
|
||||
UserHistory, i).value_string, TRUE);
|
||||
free_g_array(&user->history);
|
||||
}
|
||||
|
||||
/** Free a user event. */
|
||||
|
21
src/game.c
21
src/game.c
@ -872,6 +872,7 @@ void
|
||||
game_post_match(Fixture *fix)
|
||||
{
|
||||
gint i;
|
||||
User *user = NULL;
|
||||
|
||||
if(query_fixture_has_tables(fix))
|
||||
table_update(fix);
|
||||
@ -884,6 +885,26 @@ game_post_match(Fixture *fix)
|
||||
else
|
||||
team_update_post_match(fix->teams[i], fix->clid);
|
||||
}
|
||||
|
||||
if(fix->clid < ID_CUP_START || fixture_user_team_involved(fix) == -1)
|
||||
return;
|
||||
|
||||
user = &usr(fixture_user_team_involved(fix));
|
||||
|
||||
if(fix->round == cup_from_clid(fix->clid)->rounds->len - 1 &&
|
||||
fix == &g_array_index((league_cup_get_fixtures(fix->clid)), Fixture,
|
||||
(league_cup_get_fixtures(fix->clid))->len - 1))
|
||||
{
|
||||
if((Team*)fixture_winner_of(fix, FALSE) == user->tm)
|
||||
user_history_add(user, USER_HISTORY_WIN_FINAL, user->team_id, fix->clid, fix->round,
|
||||
fix->teams[fix->teams[0] != user->tm]->name->str);
|
||||
else
|
||||
user_history_add(user, USER_HISTORY_LOSE_FINAL, user->team_id, fix->clid, fix->round,
|
||||
fix->teams[fix->teams[0] != user->tm]->name->str);
|
||||
}
|
||||
else
|
||||
user_history_add(user, USER_HISTORY_REACH_CUP_ROUND, user->team_id,
|
||||
fix->clid, fix->round, "");
|
||||
}
|
||||
|
||||
/** Reduce stadium capacity and safety after a stadium event.
|
||||
|
@ -38,7 +38,7 @@ create_main_window (void)
|
||||
GtkWidget *menu_new;
|
||||
GtkWidget *menu_open;
|
||||
GtkWidget *menu_load_last_save;
|
||||
GtkWidget *image289;
|
||||
GtkWidget *image293;
|
||||
GtkWidget *menu_save;
|
||||
GtkWidget *menu_save_as;
|
||||
GtkWidget *trennlinie1;
|
||||
@ -46,7 +46,7 @@ create_main_window (void)
|
||||
GtkWidget *menu_options;
|
||||
GtkWidget *menu_options_menu;
|
||||
GtkWidget *menu_preferences;
|
||||
GtkWidget *image290;
|
||||
GtkWidget *image294;
|
||||
GtkWidget *trennlinie7;
|
||||
GtkWidget *menu_job_offers;
|
||||
GtkWidget *menu_live_game;
|
||||
@ -108,13 +108,15 @@ create_main_window (void)
|
||||
GtkWidget *menu_user_menu;
|
||||
GtkWidget *menu_user_show_last_match;
|
||||
GtkWidget *menu_user_show_last_stats;
|
||||
GtkWidget *trennlinie12;
|
||||
GtkWidget *menu_user_show_history;
|
||||
GtkWidget *trennlinie9;
|
||||
GtkWidget *menu_next_user;
|
||||
GtkWidget *image291;
|
||||
GtkWidget *image295;
|
||||
GtkWidget *menu_previous_user;
|
||||
GtkWidget *image292;
|
||||
GtkWidget *image296;
|
||||
GtkWidget *menu_manage_users;
|
||||
GtkWidget *image293;
|
||||
GtkWidget *image297;
|
||||
GtkWidget *menu_finances_stadium;
|
||||
GtkWidget *menu_finances_stadium_menu;
|
||||
GtkWidget *menu_show_finances;
|
||||
@ -244,9 +246,9 @@ create_main_window (void)
|
||||
GDK_l, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image289 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image289);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_load_last_save), image289);
|
||||
image293 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image293);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_load_last_save), image293);
|
||||
|
||||
menu_save = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group);
|
||||
gtk_widget_show (menu_save);
|
||||
@ -279,9 +281,9 @@ create_main_window (void)
|
||||
GDK_p, GDK_CONTROL_MASK,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image290 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image290);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image290);
|
||||
image294 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image294);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image294);
|
||||
|
||||
trennlinie7 = gtk_menu_item_new ();
|
||||
gtk_widget_show (trennlinie7);
|
||||
@ -557,6 +559,18 @@ create_main_window (void)
|
||||
GDK_F2, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
trennlinie12 = gtk_menu_item_new ();
|
||||
gtk_widget_show (trennlinie12);
|
||||
gtk_container_add (GTK_CONTAINER (menu_user_menu), trennlinie12);
|
||||
gtk_widget_set_sensitive (trennlinie12, FALSE);
|
||||
|
||||
menu_user_show_history = gtk_menu_item_new_with_mnemonic (_("Show history"));
|
||||
gtk_widget_show (menu_user_show_history);
|
||||
gtk_container_add (GTK_CONTAINER (menu_user_menu), menu_user_show_history);
|
||||
gtk_widget_add_accelerator (menu_user_show_history, "activate", accel_group,
|
||||
GDK_h, GDK_CONTROL_MASK,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
trennlinie9 = gtk_menu_item_new ();
|
||||
gtk_widget_show (trennlinie9);
|
||||
gtk_container_add (GTK_CONTAINER (menu_user_menu), trennlinie9);
|
||||
@ -569,9 +583,9 @@ create_main_window (void)
|
||||
GDK_F9, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image291 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image291);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image291);
|
||||
image295 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image295);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image295);
|
||||
|
||||
menu_previous_user = gtk_image_menu_item_new_with_mnemonic (_("Previous user"));
|
||||
gtk_widget_show (menu_previous_user);
|
||||
@ -580,9 +594,9 @@ create_main_window (void)
|
||||
GDK_F8, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image292 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image292);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image292);
|
||||
image296 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image296);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image296);
|
||||
|
||||
menu_manage_users = gtk_image_menu_item_new_with_mnemonic (_("Manage users"));
|
||||
gtk_widget_show (menu_manage_users);
|
||||
@ -591,9 +605,9 @@ create_main_window (void)
|
||||
GDK_F12, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image293 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image293);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image293);
|
||||
image297 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image297);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image297);
|
||||
|
||||
menu_finances_stadium = gtk_menu_item_new_with_mnemonic (_("FinStad"));
|
||||
gtk_widget_show (menu_finances_stadium);
|
||||
@ -1154,6 +1168,9 @@ create_main_window (void)
|
||||
g_signal_connect ((gpointer) menu_user_show_last_stats, "activate",
|
||||
G_CALLBACK (on_menu_user_show_last_stats_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) menu_user_show_history, "activate",
|
||||
G_CALLBACK (on_menu_user_show_history_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) menu_next_user, "activate",
|
||||
G_CALLBACK (on_menu_next_user_activate),
|
||||
NULL);
|
||||
@ -1233,7 +1250,7 @@ create_main_window (void)
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_new, "menu_new");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_open, "menu_open");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_load_last_save, "menu_load_last_save");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image289, "image289");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image293, "image293");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_save, "menu_save");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_save_as, "menu_save_as");
|
||||
GLADE_HOOKUP_OBJECT (main_window, trennlinie1, "trennlinie1");
|
||||
@ -1241,7 +1258,7 @@ create_main_window (void)
|
||||
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, image290, "image290");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image294, "image294");
|
||||
GLADE_HOOKUP_OBJECT (main_window, trennlinie7, "trennlinie7");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_job_offers, "menu_job_offers");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_live_game, "menu_live_game");
|
||||
@ -1299,13 +1316,15 @@ create_main_window (void)
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_user_menu, "menu_user_menu");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_user_show_last_match, "menu_user_show_last_match");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_user_show_last_stats, "menu_user_show_last_stats");
|
||||
GLADE_HOOKUP_OBJECT (main_window, trennlinie12, "trennlinie12");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_user_show_history, "menu_user_show_history");
|
||||
GLADE_HOOKUP_OBJECT (main_window, trennlinie9, "trennlinie9");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_next_user, "menu_next_user");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image291, "image291");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image295, "image295");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_previous_user, "menu_previous_user");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image292, "image292");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image296, "image296");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_manage_users, "menu_manage_users");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image293, "image293");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image297, "image297");
|
||||
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_show_finances, "menu_show_finances");
|
||||
|
24
src/league.c
24
src/league.c
@ -3,6 +3,7 @@
|
||||
#include "maths.h"
|
||||
#include "option.h"
|
||||
#include "player.h"
|
||||
#include "user.h"
|
||||
#include "table.h"
|
||||
#include "team.h"
|
||||
#include "variables.h"
|
||||
@ -304,6 +305,18 @@ league_get_team_movements(League *league, GArray *team_movements)
|
||||
new_move.league_idx = league_index_from_sid(g_array_index(elements, PromRelElement, i).dest_sid->str);
|
||||
|
||||
g_array_append_val(team_movements, new_move);
|
||||
|
||||
if(team_is_user(g_array_index(league->table.elements, TableElement, j - 1).team) != -1)
|
||||
{
|
||||
if(g_array_index(elements, PromRelElement, i).type == PROM_REL_PROMOTION)
|
||||
user_history_add(&usr(team_is_user(
|
||||
g_array_index(league->table.elements, TableElement, j - 1).team)),
|
||||
USER_HISTORY_PROMOTED, new_move.tm.id, lig(new_move.league_idx).id, -1, "");
|
||||
else
|
||||
user_history_add(&usr(team_is_user(
|
||||
g_array_index(league->table.elements, TableElement, j - 1).team)),
|
||||
USER_HISTORY_RELEGATED, new_move.tm.id, lig(new_move.league_idx).id, -1, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,6 +354,11 @@ league_get_team_movements(League *league, GArray *team_movements)
|
||||
new_move.tm = *((Team*)g_ptr_array_index(prom_games_teams, i));
|
||||
new_move.league_idx = dest_idx;
|
||||
g_array_append_val(team_movements, new_move);
|
||||
|
||||
if(team_is_user((Team*)g_ptr_array_index(prom_games_teams, i)) != -1)
|
||||
user_history_add(&usr(team_is_user(
|
||||
(Team*)g_ptr_array_index(prom_games_teams, i))),
|
||||
USER_HISTORY_PROMOTED, new_move.tm.id, lig(dest_idx).id, -1, "");
|
||||
}
|
||||
|
||||
if(strlen(league->prom_rel.prom_games_loser_sid->str) > 0)
|
||||
@ -352,6 +370,11 @@ league_get_team_movements(League *league, GArray *team_movements)
|
||||
new_move.tm = *((Team*)g_ptr_array_index(prom_games_teams, i));
|
||||
new_move.league_idx = dest_idx;
|
||||
g_array_append_val(team_movements, new_move);
|
||||
|
||||
if(team_is_user((Team*)g_ptr_array_index(prom_games_teams, i)) != -1)
|
||||
user_history_add(&usr(team_is_user(
|
||||
(Team*)g_ptr_array_index(prom_games_teams, i))),
|
||||
USER_HISTORY_RELEGATED, new_move.tm.id, lig(dest_idx).id, -1, "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -386,7 +409,6 @@ league_season_start(League *league)
|
||||
g_array_index(league->table.elements, TableElement, i).values[j] = 0;
|
||||
}
|
||||
|
||||
/*todo: make teams better if user champion?*/
|
||||
for(i=0;i<league->teams->len;i++)
|
||||
{
|
||||
team_change_factor =
|
||||
|
@ -5,10 +5,10 @@
|
||||
#include "league_struct.h"
|
||||
#include "fixture_struct.h"
|
||||
|
||||
#define league_cup_get_teams(clid) (clid < ID_CUP_START) ? league_from_clid(clid)->teams : cup_from_clid(clid)->teams
|
||||
#define league_cup_get_fixtures(clid) (clid < ID_CUP_START) ? league_from_clid(clid)->fixtures : cup_from_clid(clid)->fixtures
|
||||
#define league_cup_get_teams(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->teams) : (cup_from_clid(clid)->teams)
|
||||
#define league_cup_get_fixtures(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->fixtures) : (cup_from_clid(clid)->fixtures)
|
||||
#define league_cup_get_name_string(clid) (clid < ID_CUP_START) ? league_from_clid(clid)->name->str : cup_from_clid(clid)->name->str
|
||||
#define league_cup_get_yellow_red(clid) (clid < ID_CUP_START) ? league_from_clid(clid)->yellow_red : cup_from_clid(clid)->yellow_red
|
||||
#define league_cup_get_yellow_red(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->yellow_red) : (cup_from_clid(clid)->yellow_red)
|
||||
|
||||
#define league_has_prom_games(league) (strlen(league->prom_rel.prom_games_dest_sid->str) > 0)
|
||||
|
||||
|
@ -28,6 +28,8 @@ main_init_variables(void)
|
||||
transfer_list = NULL;
|
||||
player_names = NULL;
|
||||
|
||||
season = week = week_round = 1;
|
||||
|
||||
for(i=0;i<COUNT_END;i++)
|
||||
counters[i] = 0;
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "support.h"
|
||||
#include "team.h"
|
||||
#include "treeview.h"
|
||||
#include "treeview_helper.h"
|
||||
#include "transfer.h"
|
||||
#include "user.h"
|
||||
#include "window.h"
|
||||
@ -150,7 +151,7 @@ misc2_callback_add_user(void)
|
||||
GTK_ENTRY(lookup_widget(window.user_management, "entry_user_management"));
|
||||
const gchar *user_name = gtk_entry_get_text(entry_user_management);
|
||||
User new_user = user_new();
|
||||
Team *tm = (Team*)treeview_get_pointer(treeview_user_management_teams, 2);
|
||||
Team *tm = (Team*)treeview_helper_get_pointer(treeview_user_management_teams, 2);
|
||||
|
||||
if(strlen(user_name) > 0)
|
||||
g_string_printf(new_user.name, "%s", user_name);
|
||||
@ -160,6 +161,8 @@ misc2_callback_add_user(void)
|
||||
new_user.tm = tm;
|
||||
new_user.team_id = tm->id;
|
||||
|
||||
user_history_add(&new_user, USER_HISTORY_START_GAME, tm->id, tm->clid, -1, "");
|
||||
|
||||
g_array_append_val(users, new_user);
|
||||
|
||||
user_set_up_team(&usr(users->len - 1));
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "support.h"
|
||||
#include "transfer.h"
|
||||
#include "treeview.h"
|
||||
#include "treeview_helper.h"
|
||||
#include "user.h"
|
||||
#include "window.h"
|
||||
|
||||
@ -237,10 +238,10 @@ on_treeview_user_management_users_button_press_event
|
||||
gchar buf[SMALL];
|
||||
gint idx = -1;
|
||||
|
||||
if(!treeview_select_row(GTK_TREE_VIEW(widget), event))
|
||||
if(!treeview_helper_select_row(GTK_TREE_VIEW(widget), event))
|
||||
return TRUE;
|
||||
|
||||
idx = treeview_get_index(GTK_TREE_VIEW(widget), 0) - 1;
|
||||
idx = treeview_helper_get_index(GTK_TREE_VIEW(widget), 0) - 1;
|
||||
|
||||
if(users->len == 1)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "start_end.h"
|
||||
#include "support.h"
|
||||
#include "treeview.h"
|
||||
#include "treeview_helper.h"
|
||||
#include "user.h"
|
||||
#include "variables.h"
|
||||
#include "window.h"
|
||||
@ -65,7 +66,7 @@ misc_callback_add_player(void)
|
||||
GTK_ENTRY(lookup_widget(window.startup, "entry_player_name"));
|
||||
const gchar *player_name = gtk_entry_get_text(entry_player_name);
|
||||
User new_user = user_new();
|
||||
Team *tm = (Team*)treeview_get_pointer(treeview_startup, 2);
|
||||
Team *tm = (Team*)treeview_helper_get_pointer(treeview_startup, 2);
|
||||
|
||||
if(strlen(player_name) > 0)
|
||||
g_string_printf(new_user.name, "%s", player_name);
|
||||
@ -82,6 +83,8 @@ misc_callback_add_player(void)
|
||||
new_user.tm = tm;
|
||||
new_user.team_id = tm->id;
|
||||
|
||||
user_history_add(&new_user, USER_HISTORY_START_GAME, tm->id, tm->clid, -1, "");
|
||||
|
||||
g_array_append_val(users, new_user);
|
||||
|
||||
treeview_show_users(treeview_users);
|
||||
@ -105,10 +108,10 @@ misc_callback_remove_user(GdkEventButton *event)
|
||||
GtkTreeView *treeview_startup =
|
||||
GTK_TREE_VIEW(lookup_widget(window.startup, "treeview_startup"));
|
||||
|
||||
if(!treeview_select_row(treeview_users, event))
|
||||
if(!treeview_helper_select_row(treeview_users, event))
|
||||
return;
|
||||
|
||||
user_remove(treeview_get_index(treeview_users, 0) - 1, FALSE);
|
||||
user_remove(treeview_helper_get_index(treeview_users, 0) - 1, FALSE);
|
||||
|
||||
treeview_show_users(treeview_users);
|
||||
treeview_show_team_list(treeview_startup, FALSE, FALSE);
|
||||
|
675
src/treeview.c
675
src/treeview.c
File diff suppressed because it is too large
Load Diff
@ -8,30 +8,6 @@
|
||||
#include "user_struct.h"
|
||||
#include "table_struct.h"
|
||||
|
||||
gboolean
|
||||
treeview_select_row(GtkTreeView *treeview, GdkEventButton *event);
|
||||
|
||||
GdkPixbuf*
|
||||
treeview_pixbuf_from_filename(gchar *filename);
|
||||
|
||||
GtkCellRenderer*
|
||||
treeview_cell_renderer_text_new(void);
|
||||
|
||||
gchar*
|
||||
treeview_live_game_icon(gint event_type);
|
||||
|
||||
gint
|
||||
treeview_get_index(GtkTreeView *treeview, gint column);
|
||||
|
||||
gpointer
|
||||
treeview_get_pointer(GtkTreeView *treeview, gint column);
|
||||
|
||||
void
|
||||
treeview_clear(GtkTreeView *treeview);
|
||||
|
||||
gint
|
||||
treeview_get_col_number_column (GtkTreeViewColumn *col);
|
||||
|
||||
GtkTreeModel*
|
||||
treeview_create_team_selection_list(gboolean show_cup_teams,
|
||||
gboolean show_user_teams);
|
||||
@ -129,13 +105,6 @@ treeview_create_single_table(GtkListStore *liststore, const Table *table, gint n
|
||||
void
|
||||
treeview_table_write_header(GtkListStore *liststore, gint clid, gint number);
|
||||
|
||||
void
|
||||
treeview_get_table_element_colours(const Table *table, gint idx, gchar *colour_fg,
|
||||
gchar *colour_bg, gboolean user);
|
||||
|
||||
gboolean
|
||||
treeview_get_table_element_colour_cups(const League *league, gint idx, gchar *colour_bg);
|
||||
|
||||
void
|
||||
treeview_show_finances(GtkTreeView *treeview, const User* user);
|
||||
|
||||
@ -148,9 +117,6 @@ treeview_create_finances(const User* user);
|
||||
void
|
||||
treeview_show_player_list_team(GtkTreeView *treeview, const Team *tm, gint scout);
|
||||
|
||||
PlayerListAttribute
|
||||
treeview_get_attributes_from_scout(gint scout);
|
||||
|
||||
void
|
||||
treeview_show_transfer_list(GtkTreeView *treeview);
|
||||
|
||||
@ -181,21 +147,9 @@ treeview_create_league_results(void);
|
||||
void
|
||||
treeview_create_next_opponent_values(GtkListStore *liststore, const Fixture *fix);
|
||||
|
||||
gint
|
||||
treeview_team_compare(GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
treeview_show_all_players(GArray *teams);
|
||||
|
||||
gint
|
||||
treeview_player_compare(GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data);
|
||||
|
||||
GtkTreeModel*
|
||||
treeview_create_preview(void);
|
||||
|
||||
@ -211,19 +165,22 @@ treeview_set_up_player_info(GtkTreeView *treeview);
|
||||
GtkTreeModel*
|
||||
treeview_create_player_info(const Player *pl);
|
||||
|
||||
gint
|
||||
treeview_iter_get_row(GtkTreeModel *model, GtkTreeIter *iter);
|
||||
|
||||
void
|
||||
treeview_create_stadium_summary(GtkListStore *liststore);
|
||||
|
||||
void
|
||||
treeview_show_fixtures_week(gint week_number, gint week_round_number);
|
||||
|
||||
void
|
||||
treeview_show_fixtures_week(gint week_number, gint week_round_number);
|
||||
|
||||
GtkTreeModel*
|
||||
treeview_create_fixtures_week(gint week_number, gint week_round_number);
|
||||
|
||||
void
|
||||
treeview_show_user_history(void);
|
||||
|
||||
void
|
||||
treeview_set_up_user_history(GtkTreeView *treeview);
|
||||
|
||||
GtkTreeModel*
|
||||
treeview_create_user_history(void);
|
||||
|
||||
#endif
|
||||
|
151
src/user.c
151
src/user.c
@ -1,6 +1,8 @@
|
||||
#include "cup.h"
|
||||
#include "fixture.h"
|
||||
#include "free.h"
|
||||
#include "game_gui.h"
|
||||
#include "league.h"
|
||||
#include "live_game.h"
|
||||
#include "maths.h"
|
||||
#include "misc.h"
|
||||
@ -25,6 +27,7 @@ user_new(void)
|
||||
live_game_reset(&new.live_game, NULL, FALSE);
|
||||
|
||||
new.events = g_array_new(FALSE, FALSE, sizeof(Event));
|
||||
new.history = g_array_new(FALSE, FALSE, sizeof(UserHistory));
|
||||
new.options.list = NULL;
|
||||
new.options.datalist = NULL;
|
||||
|
||||
@ -81,6 +84,8 @@ user_set_up_team(User *user)
|
||||
|
||||
user->scout = user->physio = QUALITY_AVERAGE;
|
||||
|
||||
user->tm->style = 0;
|
||||
|
||||
user_set_up_finances(user);
|
||||
user_set_up_counters(user);
|
||||
}
|
||||
@ -353,9 +358,9 @@ user_event_show_next(void)
|
||||
break;
|
||||
case EVENT_TYPE_OVERDRAW:
|
||||
if(event->value1 == 1)
|
||||
sprintf(buf, _("You have overdrawn your bank account. The team owners give you %d weeks to exceed your drawing credit limit again."), const_int("int_finance_overdraw_positive"));
|
||||
sprintf(buf, _("You have overdrawn your bank account. The team owners give you %d weeks to get above your drawing credit limit."), const_int("int_finance_overdraw_positive"));
|
||||
else
|
||||
sprintf(buf, _("You have overdrawn your bank account once again. Bear in mind that after the fourth time you get fired.\nThe team owners give you %d weeks to exceed your drawing credit limit again."), const_int("int_finance_overdraw_positive"));
|
||||
sprintf(buf, _("You have overdrawn your bank account once again. Bear in mind that after the fourth time you get fired.\nThe team owners give you %d weeks to get above your drawing credit limit."), const_int("int_finance_overdraw_positive"));
|
||||
game_gui_show_warning(buf);
|
||||
break;
|
||||
case EVENT_TYPE_TRANSFER_OFFER_REJECTED:
|
||||
@ -465,3 +470,145 @@ query_user_teams_have_unfit(void)
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/** Compare function for history sorting. */
|
||||
gint
|
||||
user_history_compare(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
gint return_value = 0;
|
||||
const UserHistory *his1 = (const UserHistory*)a,
|
||||
*his2 = (const UserHistory*)b;
|
||||
|
||||
if(his1->season < his2->season)
|
||||
return_value = 1;
|
||||
else if(his1->season > his2->season)
|
||||
return_value = -1;
|
||||
else if(his1->week < his2->week)
|
||||
return_value = 1;
|
||||
else if(his1->week > his2->week)
|
||||
return_value = -1;
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/** Add an element to the user history filled with the given values. */
|
||||
void
|
||||
user_history_add(User *user, gint type, gint team_id,
|
||||
gint value1, gint value2, gchar *string)
|
||||
{
|
||||
gint i;
|
||||
UserHistory new_history;
|
||||
UserHistory *his = &new_history;
|
||||
gboolean replace = FALSE;
|
||||
|
||||
|
||||
if(type == USER_HISTORY_WIN_FINAL ||
|
||||
type == USER_HISTORY_LOSE_FINAL ||
|
||||
type == USER_HISTORY_REACH_CUP_ROUND)
|
||||
{
|
||||
for(i=0;i<user->history->len;i++)
|
||||
if((g_array_index(user->history, UserHistory, i).type == USER_HISTORY_WIN_FINAL ||
|
||||
g_array_index(user->history, UserHistory, i).type == USER_HISTORY_LOSE_FINAL ||
|
||||
g_array_index(user->history, UserHistory, i).type == USER_HISTORY_REACH_CUP_ROUND) &&
|
||||
g_array_index(user->history, UserHistory, i).season == season &&
|
||||
g_array_index(user->history, UserHistory, i).team_id == team_id &&
|
||||
g_array_index(user->history, UserHistory, i).value1 == value1)
|
||||
{
|
||||
/** Same cup round. */
|
||||
if(g_array_index(user->history, UserHistory, i).value2 == value2 &&
|
||||
type == USER_HISTORY_REACH_CUP_ROUND)
|
||||
return;
|
||||
|
||||
his = &g_array_index(user->history, UserHistory, i);
|
||||
replace = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
his->season = season;
|
||||
his->week = week;
|
||||
|
||||
/*todo: check for old cup comp */
|
||||
his->type = type;
|
||||
his->team_id = team_id;
|
||||
his->value1 = value1;
|
||||
his->value2 = value2;
|
||||
|
||||
if(replace)
|
||||
{
|
||||
g_string_printf(his->value_string, "%s", string);
|
||||
g_array_sort(user->history, (GCompareFunc)user_history_compare);
|
||||
}
|
||||
else
|
||||
{
|
||||
his->value_string = g_string_new(string);
|
||||
g_array_prepend_val(user->history, *his);
|
||||
}
|
||||
}
|
||||
|
||||
/** Write the text corresponding to the history event
|
||||
into the buffer. */
|
||||
void
|
||||
user_history_to_string(const UserHistory *history, gchar *buf)
|
||||
{
|
||||
gchar buf2[SMALL];
|
||||
|
||||
switch(history->type)
|
||||
{
|
||||
default:
|
||||
g_warning("user_history_to_string: unknown history type %d.\n", history->type);
|
||||
strcpy(buf, "FIXME!!!");
|
||||
case USER_HISTORY_START_GAME:
|
||||
sprintf(buf, "You start the game with %s in the %s.",
|
||||
team_of_id(history->team_id)->name->str,
|
||||
league_cup_get_name_string(history->value1));
|
||||
break;
|
||||
case USER_HISTORY_FIRE_FINANCES:
|
||||
sprintf(buf, "%s fires you because of financial mismanagement.\nYou find a new job with %s in the %s.",
|
||||
team_of_id(history->team_id)->name->str,
|
||||
team_of_id(history->value1)->name->str,
|
||||
league_cup_get_name_string(history->value2));
|
||||
break;
|
||||
case USER_HISTORY_FIRE_FAILURE:
|
||||
sprintf(buf, "%s fires you because of unsuccessfulness.\nYou find a new job with %s in the %s.",
|
||||
team_of_id(history->team_id)->name->str,
|
||||
team_of_id(history->value1)->name->str,
|
||||
league_cup_get_name_string(history->value2));
|
||||
break;
|
||||
case USER_HISTORY_JOB_OFFER_ACCEPTED:
|
||||
sprintf(buf, "%s offer you a job in the %s.\nYou accept the challenge and leave %s.",
|
||||
team_of_id(history->value1)->name->str,
|
||||
league_cup_get_name_string(history->value2),
|
||||
team_of_id(history->team_id)->name->str);
|
||||
break;
|
||||
case USER_HISTORY_END_SEASON:
|
||||
sprintf(buf, "You finish the season in %s on rank %d.",
|
||||
league_cup_get_name_string(history->value1),
|
||||
history->value2);
|
||||
break;
|
||||
case USER_HISTORY_PROMOTED:
|
||||
sprintf(buf, "You get promoted to the %s.",
|
||||
league_cup_get_name_string(history->value1));
|
||||
break;
|
||||
case USER_HISTORY_RELEGATED:
|
||||
sprintf(buf, "You get relegated to the %s.",
|
||||
league_cup_get_name_string(history->value1));
|
||||
break;
|
||||
case USER_HISTORY_WIN_FINAL:
|
||||
sprintf(buf, "You win the %s final against %s.",
|
||||
league_cup_get_name_string(history->value1),
|
||||
history->value_string->str);
|
||||
break;
|
||||
case USER_HISTORY_LOSE_FINAL:
|
||||
sprintf(buf, "You lose in the %s final against %s.",
|
||||
league_cup_get_name_string(history->value1),
|
||||
history->value_string->str);
|
||||
break;
|
||||
case USER_HISTORY_REACH_CUP_ROUND:
|
||||
cup_get_round_name(cup_from_clid(history->value1), history->value2, buf2);
|
||||
sprintf(buf, "You reach the %s (round %d) of the %s.", buf2,
|
||||
history->value2 + 1,
|
||||
league_cup_get_name_string(history->value1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
10
src/user.h
10
src/user.h
@ -69,4 +69,14 @@ user_event_get_index(User *user, gint type, gint value1, gint value2,
|
||||
gboolean
|
||||
query_user_teams_have_unfit(void);
|
||||
|
||||
void
|
||||
user_history_add(User *user, gint type, gint team_id,
|
||||
gint value1, gint value2, gchar *string);
|
||||
|
||||
void
|
||||
user_history_to_string(const UserHistory *history, gchar *buf);
|
||||
|
||||
gint
|
||||
user_history_compare(gconstpointer a, gconstpointer b);
|
||||
|
||||
#endif
|
||||
|
@ -61,6 +61,8 @@ typedef struct
|
||||
OptionList options;
|
||||
/** Events shown each week. */
|
||||
GArray *events;
|
||||
/** User history. */
|
||||
GArray *history;
|
||||
/** User counters (not changeable by the user),
|
||||
like number of weeks until debt has to be paid back. */
|
||||
gint counters[COUNT_USER_END];
|
||||
@ -112,4 +114,38 @@ typedef struct
|
||||
|
||||
} Event;
|
||||
|
||||
|
||||
/** User-related things that get recorded. */
|
||||
enum UserHistoryType
|
||||
{
|
||||
USER_HISTORY_START_GAME = 0,
|
||||
USER_HISTORY_FIRE_FINANCES,
|
||||
USER_HISTORY_FIRE_FAILURE,
|
||||
USER_HISTORY_JOB_OFFER_ACCEPTED,
|
||||
USER_HISTORY_END_SEASON,
|
||||
USER_HISTORY_PROMOTED,
|
||||
USER_HISTORY_RELEGATED,
|
||||
USER_HISTORY_WIN_FINAL,
|
||||
USER_HISTORY_LOSE_FINAL,
|
||||
USER_HISTORY_REACH_CUP_ROUND,
|
||||
USER_HISTORY_END
|
||||
};
|
||||
|
||||
/** A structure holding an element of a user's history,
|
||||
e.g. the event of being fired. */
|
||||
typedef struct
|
||||
{
|
||||
/** When the event happened. */
|
||||
gint season, week;
|
||||
|
||||
/** The type (see #UserHistoryType) and team
|
||||
of the user. */
|
||||
gint type, team_id,
|
||||
/** These can hold various information like
|
||||
team or league/cup ids. */
|
||||
value1, value2;
|
||||
GString *value_string;
|
||||
|
||||
} UserHistory;
|
||||
|
||||
#endif
|
||||
|
@ -20,11 +20,20 @@ enum
|
||||
TAG_USER_MONEY_OUT,
|
||||
TAG_USER_SCOUT,
|
||||
TAG_USER_PHYSIO,
|
||||
TAG_USER_HISTORY,
|
||||
TAG_USER_HISTORY_SEASON,
|
||||
TAG_USER_HISTORY_WEEK,
|
||||
TAG_USER_HISTORY_TYPE,
|
||||
TAG_USER_HISTORY_TEAM_ID,
|
||||
TAG_USER_HISTORY_VALUE1,
|
||||
TAG_USER_HISTORY_VALUE2,
|
||||
TAG_USER_HISTORY_VALUE_STRING,
|
||||
TAG_END
|
||||
};
|
||||
|
||||
gint state, idx_mon_in, idx_mon_out, idx;
|
||||
User new_user;
|
||||
UserHistory new_history;
|
||||
|
||||
void
|
||||
xml_loadsave_users_start_element (GMarkupParseContext *context,
|
||||
@ -88,7 +97,8 @@ xml_loadsave_users_end_element (GMarkupParseContext *context,
|
||||
tag == TAG_USER_SCOUT ||
|
||||
tag == TAG_USER_PHYSIO ||
|
||||
tag == TAG_NAME ||
|
||||
tag == TAG_TEAM_ID)
|
||||
tag == TAG_TEAM_ID ||
|
||||
tag == TAG_USER_HISTORY)
|
||||
{
|
||||
state = TAG_USER;
|
||||
if(tag == TAG_USER_COUNTER)
|
||||
@ -97,6 +107,8 @@ xml_loadsave_users_end_element (GMarkupParseContext *context,
|
||||
idx_mon_out++;
|
||||
else if(tag == TAG_USER_MONEY_INS)
|
||||
idx_mon_in++;
|
||||
else if(tag == TAG_USER_HISTORY)
|
||||
g_array_append_val(new_user.history, new_history);
|
||||
}
|
||||
else if(tag == TAG_USER_MONEY_OUT)
|
||||
{
|
||||
@ -108,6 +120,14 @@ xml_loadsave_users_end_element (GMarkupParseContext *context,
|
||||
state = TAG_USER_MONEY_INS;
|
||||
idx++;
|
||||
}
|
||||
else if(tag == TAG_USER_HISTORY_SEASON ||
|
||||
tag == TAG_USER_HISTORY_WEEK ||
|
||||
tag == TAG_USER_HISTORY_TYPE ||
|
||||
tag == TAG_USER_HISTORY_TEAM_ID ||
|
||||
tag == TAG_USER_HISTORY_VALUE1 ||
|
||||
tag == TAG_USER_HISTORY_VALUE2 ||
|
||||
tag == TAG_USER_HISTORY_VALUE_STRING)
|
||||
state = TAG_USER_HISTORY;
|
||||
else if(tag != TAG_USERS)
|
||||
g_warning("xml_loadsave_users_end_element: unknown tag: %s; I'm in state %d\n",
|
||||
element_name, state);
|
||||
@ -149,6 +169,20 @@ xml_loadsave_users_text (GMarkupParseContext *context,
|
||||
new_user.money_in[idx_mon_in][idx] = int_value;
|
||||
else if(state == TAG_USER_MONEY_OUT)
|
||||
new_user.money_out[idx_mon_out][idx] = int_value;
|
||||
else if(state == TAG_USER_HISTORY_SEASON)
|
||||
new_history.season = int_value;
|
||||
else if(state == TAG_USER_HISTORY_WEEK)
|
||||
new_history.week = int_value;
|
||||
else if(state == TAG_USER_HISTORY_TYPE)
|
||||
new_history.type = int_value;
|
||||
else if(state == TAG_USER_HISTORY_TEAM_ID)
|
||||
new_history.team_id = int_value;
|
||||
else if(state == TAG_USER_HISTORY_VALUE1)
|
||||
new_history.value1 = int_value;
|
||||
else if(state == TAG_USER_HISTORY_VALUE2)
|
||||
new_history.value2 = int_value;
|
||||
else if(state == TAG_USER_HISTORY_VALUE_STRING)
|
||||
new_history.value_string = g_string_new(buf);
|
||||
}
|
||||
|
||||
void
|
||||
@ -238,6 +272,28 @@ xml_loadsave_users_write(const gchar *prefix)
|
||||
fprintf(fil, "%s</_%d>\n", I1, TAG_USER_MONEY_OUTS);
|
||||
}
|
||||
|
||||
for(j=0;j<usr(i).history->len;j++)
|
||||
{
|
||||
fprintf(fil, "%s<_%d>\n", I1, TAG_USER_HISTORY);
|
||||
|
||||
xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).season,
|
||||
TAG_USER_HISTORY_SEASON, I2);
|
||||
xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).week,
|
||||
TAG_USER_HISTORY_WEEK, I2);
|
||||
xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).type,
|
||||
TAG_USER_HISTORY_TYPE, I2);
|
||||
xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).team_id,
|
||||
TAG_USER_HISTORY_TEAM_ID, I2);
|
||||
xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).value1,
|
||||
TAG_USER_HISTORY_VALUE1, I2);
|
||||
xml_write_int(fil, g_array_index(usr(i).history, UserHistory, j).value2,
|
||||
TAG_USER_HISTORY_VALUE2, I2);
|
||||
xml_write_g_string(fil, g_array_index(usr(i).history, UserHistory, j).value_string,
|
||||
TAG_USER_HISTORY_VALUE_STRING, I2);
|
||||
|
||||
fprintf(fil, "%s</_%d>\n", I1, TAG_USER_HISTORY);
|
||||
}
|
||||
|
||||
fprintf(fil, "</_%d>\n", TAG_USER);
|
||||
}
|
||||
|
||||
|
@ -14,14 +14,14 @@ int_opt_autosave_interval 5
|
||||
int_opt_autosave_files 5
|
||||
|
||||
# precision of skill and talent in player lists
|
||||
int_opt_player_precision 2
|
||||
int_opt_player_precision 0
|
||||
|
||||
# refresh rate of the player list during a live game
|
||||
# the smaller the more often the list gets refreshed
|
||||
int_opt_live_game_player_list_refresh 48
|
||||
|
||||
# whether some debugging info's shown (in the console)
|
||||
int_opt_debug 0 #60
|
||||
int_opt_debug 0
|
||||
|
||||
string_opt_player_names_file player_names.xml
|
||||
string_opt_constants_file bygfoot_constants
|
||||
|
@ -156,22 +156,22 @@ float_player_etal_scout_factor 70000
|
||||
|
||||
# fitness limits below which fitness is shown
|
||||
# in orange and red etc.
|
||||
float_treeview_cell_limit_player_fitness_below1 8500
|
||||
float_treeview_cell_limit_player_fitness_below2 7000
|
||||
float_treeview_cell_limit_player_fitness_below3 6000
|
||||
float_treeview_helper_limit_player_fitness_below1 8500
|
||||
float_treeview_helper_limit_player_fitness_below2 7000
|
||||
float_treeview_helper_limit_player_fitness_below3 6000
|
||||
|
||||
# contract limits below which contract time is shown
|
||||
# in orange and red etc.
|
||||
float_treeview_cell_limit_player_contract_below1 10000
|
||||
float_treeview_cell_limit_player_contract_below2 7000
|
||||
float_treeview_cell_limit_player_contract_below3 4000
|
||||
float_treeview_helper_limit_player_contract_below1 10000
|
||||
float_treeview_helper_limit_player_contract_below2 7000
|
||||
float_treeview_helper_limit_player_contract_below3 4000
|
||||
|
||||
# the factor that determines how much money the user has to pay
|
||||
# if he fires a player
|
||||
float_player_fire_wage_factor 100000
|
||||
|
||||
# the integer that the cell data functions will interpret as an empty string.
|
||||
int_treeview_cell_int_empty -5
|
||||
int_treeview_helper_int_empty -5
|
||||
|
||||
# number of results shown in the next opponent
|
||||
# info
|
||||
@ -682,43 +682,43 @@ string_live_game_event_substitution_icon sub.png
|
||||
string_live_game_event_structure_change_icon structure_change.png
|
||||
|
||||
# font attributes for the live game window result.
|
||||
string_treeview_cell_live_game_result_attributes weight='bold' size='large'
|
||||
string_treeview_helper_live_game_result_attributes weight='bold' size='large'
|
||||
|
||||
# colour indicating ball possession during a live game
|
||||
string_live_game_possession_color darkblue
|
||||
|
||||
# default background and foreground in treeviews
|
||||
string_treeview_cell_color_default_background white
|
||||
string_treeview_cell_color_default_foreground black
|
||||
string_treeview_helper_color_default_background white
|
||||
string_treeview_helper_color_default_foreground black
|
||||
|
||||
# player list colours
|
||||
string_treeview_cell_color_player_pos_goalie_bg black
|
||||
string_treeview_cell_color_player_pos_goalie_fg white
|
||||
string_treeview_cell_color_player_pos_defender_bg darkgreen
|
||||
string_treeview_cell_color_player_pos_defender_fg white
|
||||
string_treeview_cell_color_player_pos_midfielder_bg darkblue
|
||||
string_treeview_cell_color_player_pos_midfielder_fg white
|
||||
string_treeview_cell_color_player_pos_forward_bg darkred
|
||||
string_treeview_cell_color_player_pos_forward_fg white
|
||||
string_treeview_helper_color_player_pos_goalie_bg black
|
||||
string_treeview_helper_color_player_pos_goalie_fg white
|
||||
string_treeview_helper_color_player_pos_defender_bg darkgreen
|
||||
string_treeview_helper_color_player_pos_defender_fg white
|
||||
string_treeview_helper_color_player_pos_midfielder_bg darkblue
|
||||
string_treeview_helper_color_player_pos_midfielder_fg white
|
||||
string_treeview_helper_color_player_pos_forward_bg darkred
|
||||
string_treeview_helper_color_player_pos_forward_fg white
|
||||
|
||||
string_treeview_cell_color_player_injury lightgreen
|
||||
string_treeview_cell_color_player_banned red
|
||||
string_treeview_cell_color_player_yellow_danger yellow
|
||||
string_treeview_helper_color_player_injury lightgreen
|
||||
string_treeview_helper_color_player_banned red
|
||||
string_treeview_helper_color_player_yellow_danger yellow
|
||||
|
||||
string_treeview_cell_color_player_fitness_normal darkgreen
|
||||
string_treeview_cell_color_player_fitness_below1 darkorange
|
||||
string_treeview_cell_color_player_fitness_below2 orangered
|
||||
string_treeview_cell_color_player_fitness_below3 red
|
||||
string_treeview_helper_color_player_fitness_normal darkgreen
|
||||
string_treeview_helper_color_player_fitness_below1 darkorange
|
||||
string_treeview_helper_color_player_fitness_below2 orangered
|
||||
string_treeview_helper_color_player_fitness_below3 red
|
||||
|
||||
string_treeview_cell_color_player_contract_normal darkgreen
|
||||
string_treeview_helper_color_player_contract_normal darkgreen
|
||||
# see also the int constants for contract limits
|
||||
string_treeview_cell_color_player_contract_below1 darkorange
|
||||
string_treeview_cell_color_player_contract_below2 orangered
|
||||
string_treeview_cell_color_player_contract_below3 red
|
||||
string_treeview_helper_color_player_contract_below1 darkorange
|
||||
string_treeview_helper_color_player_contract_below2 orangered
|
||||
string_treeview_helper_color_player_contract_below3 red
|
||||
|
||||
# colours for cskill in wrong position
|
||||
string_treeview_cell_color_player_bad_cskill_bg lightblue
|
||||
string_treeview_cell_color_player_bad_cskill_fg red
|
||||
string_treeview_helper_color_player_bad_cskill_bg lightblue
|
||||
string_treeview_helper_color_player_bad_cskill_fg red
|
||||
|
||||
# fixture list colours
|
||||
# the header, e.g. 'champions' league round robin'
|
||||
@ -761,3 +761,16 @@ string_treeview_league_results_away_fg black
|
||||
|
||||
# foreground of own team bar in the opponent preview
|
||||
string_treeview_opponent_value_colour_fg darkgreen
|
||||
|
||||
|
||||
# symbols in the user history view
|
||||
string_treeview_helper_user_history_symbol_start_game
|
||||
string_treeview_helper_user_history_symbol_fire_finances
|
||||
string_treeview_helper_user_history_symbol_fire_failure
|
||||
string_treeview_helper_user_history_symbol_end_season
|
||||
string_treeview_helper_user_history_symbol_win_final
|
||||
string_treeview_helper_user_history_symbol_lose_final
|
||||
string_treeview_helper_user_history_symbol_reach_cup_round
|
||||
string_treeview_helper_user_history_symbol_job_offer_accepted
|
||||
string_treeview_helper_user_history_symbol_promoted
|
||||
string_treeview_helper_user_history_symbol_relegated
|
||||
|
Loading…
x
Reference in New Issue
Block a user