mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-01-31 07:54:50 +01:00
"Sponsorship money."
This commit is contained in:
parent
fe2c828cd5
commit
e777937956
@ -2119,4 +2119,244 @@
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget class="GtkWindow" id="window_sponsors">
|
||||
<property name="border_width">5</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">window1</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="default_width">450</property>
|
||||
<property name="default_height">350</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<signal name="delete_event" handler="on_window_sponsors_delete_event" last_modification_time="Mon, 20 Jun 2005 08:23:37 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox48">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">3</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label_sponsors">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">There are a few companies interested in sponsoring your team. Please select one:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow12">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="treeview_sponsors">
|
||||
<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>
|
||||
<signal name="row_activated" handler="on_treeview_sponsors_row_activated" last_modification_time="Mon, 20 Jun 2005 08:13:28 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox71">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">3</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_sponsors">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_button_sponsors_clicked" last_modification_time="Sun, 19 Jun 2005 15:49:37 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment23">
|
||||
<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="hbox73">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">2</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image63">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-apply</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label117">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Accept</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_sponsors_wait">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">If you don't like any of the sponsors, you can go a few weeks without sponsor and wait for new offers.</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_button_sponsors_wait_clicked" last_modification_time="Mon, 20 Jun 2005 09:26:58 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment22">
|
||||
<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="hbox72">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">2</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image62">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-go-forward</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="label116">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Reject for now</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
||||
|
583
po/bygfoot.pot
583
po/bygfoot.pot
File diff suppressed because it is too large
Load Diff
@ -29,13 +29,13 @@ bygfoot_SOURCES = \
|
||||
main.c file.h free.h language.h live_game.h main.h misc_callbacks.h name_struct.h option.h stat_struct.h transfer_struct.h variables.h window.h \
|
||||
maths.c maths.h misc.h variables.h \
|
||||
misc.c main.h maths.h misc.h \
|
||||
misc_callbacks.c callback_func.h callbacks.h game_gui.h game.h gui.h live_game.h load_save.h main.h misc_callback_func.h misc_callbacks.h option.h user.h variables.h window.h xml_country.h \
|
||||
misc_callbacks.c callback_func.h callbacks.h game_gui.h game.h gui.h live_game.h load_save.h main.h maths.h misc_callback_func.h misc_callbacks.h option.h user.h variables.h window.h xml_country.h \
|
||||
misc_callback_func.c callbacks.h finance.h game_gui.h game.h gui.h load_save.h maths.h misc_callback_func.h option.h start_end.h support.h treeview.h treeview_helper.h user.h variables.h window.h xml_country.h xml_name.h \
|
||||
misc_interface.c misc_callbacks.h misc_interface.h support.h \
|
||||
misc2_callbacks.c callback_func.h callbacks.h debug.h finance.h game_gui.h load_save.h main.h misc2_callback_func.h misc2_callbacks.h misc2_interface.h player.h support.h transfer.h treeview.h treeview_helper.h user.h window.h \
|
||||
misc2_callback_func.c callbacks.h file.h finance.h game_gui.h maths.h misc2_callback_func.h option.h player.h support.h team.h transfer.h treeview.h treeview_helper.h user.h window.h \
|
||||
misc2_interface.c misc2_callbacks.h misc2_interface.h support.h \
|
||||
name.c name.h option.h variables.h xml_name.h \
|
||||
name.c main.h name.h option.h variables.h xml_name.h \
|
||||
option.c main.h option.h variables.h \
|
||||
option_gui.c callbacks.h file.h game_gui.h language.h option_gui.h option.h support.h treeview.h user.h variables.h \
|
||||
options_callbacks.c file.h option_gui.h options_callbacks.h options_interface.h support.h user.h variables.h window.h \
|
||||
@ -49,7 +49,7 @@ bygfoot_SOURCES = \
|
||||
transfer.c cup.h finance.h free.h game_gui.h main.h maths.h misc.h option.h player.h support.h team.h transfer.h treeview.h user.h \
|
||||
treeview.c cup.h finance.h fixture.h free.h game.h language.h league.h live_game.h maths.h misc.h option.h player.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 transfer.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 main.h maths.h misc.h option.h player.h team.h transfer.h treeview.h user.h window.h \
|
||||
user.c cup.h finance.h fixture.h free.h game_gui.h league.h live_game.h main.h maths.h misc.h name.h option.h player.h support.h team.h transfer.h treeview.h user.h window.h \
|
||||
window.c callbacks.h file.h finance.h free.h game_gui.h gui.h interface.h league.h live_game.h load_save.h main.h misc2_interface.h misc_callback_func.h misc_interface.h option_gui.h option.h options_interface.h support.h transfer.h treeview.h treeview_helper.h user.h window.h \
|
||||
xml.c cup.h file.h free.h gui.h league.h misc.h option.h support.h table.h transfer_struct.h user.h variables.h xml.h xml_loadsave_cup.h xml_loadsave_fixtures.h xml_loadsave_league.h xml_loadsave_league_stat.h xml_loadsave_live_game.h xml_loadsave_table.h xml_loadsave_teams.h xml_loadsave_transfers.h xml_loadsave_users.h \
|
||||
xml_loadsave_cup.c cup.h file.h misc.h table.h team.h xml.h xml_loadsave_cup.h xml_loadsave_fixtures.h xml_loadsave_table.h xml_loadsave_teams.h \
|
||||
|
@ -123,6 +123,7 @@ typedef struct
|
||||
*user_management,
|
||||
*wdebug,
|
||||
*help,
|
||||
*transfer_dialog;
|
||||
*transfer_dialog,
|
||||
*sponsors;
|
||||
} Windows;
|
||||
#endif
|
||||
|
12
src/debug.c
12
src/debug.c
@ -18,24 +18,28 @@ debug_action(const gchar *text, gint value)
|
||||
else if(g_str_has_prefix(text, "cap"))
|
||||
{
|
||||
current_user.tm->stadium.capacity += value;
|
||||
sprintf(message, "Stadium capacity changed by %d.", value);
|
||||
sprintf(message, "Stadium capacity changed by %d. New: %d.", value,
|
||||
current_user.tm->stadium.capacity);
|
||||
}
|
||||
else if(g_str_has_prefix(text, "saf"))
|
||||
{
|
||||
current_user.tm->stadium.safety += ((gfloat)value / 100);
|
||||
current_user.tm->stadium.safety =
|
||||
CLAMP(current_user.tm->stadium.safety, 0, 1);
|
||||
sprintf(message, "Stadium safety changed by %d.", value);
|
||||
sprintf(message, "Stadium safety changed by %d. New: %.2f", value,
|
||||
current_user.tm->stadium.safety);
|
||||
}
|
||||
else if(g_str_has_prefix(text, "mon"))
|
||||
{
|
||||
current_user.money += value;
|
||||
sprintf(message, "Money changed by %d.", value);
|
||||
sprintf(message, "Money changed by %d. New: %d.", value,
|
||||
current_user.money);
|
||||
}
|
||||
else if(g_str_has_prefix(text, "suc"))
|
||||
{
|
||||
current_user.counters[COUNT_USER_SUCCESS] += value;
|
||||
sprintf(message, "Success counter changed by %d.", value);
|
||||
sprintf(message, "Success counter changed by %d. New: %d.", value,
|
||||
current_user.counters[COUNT_USER_SUCCESS]);
|
||||
}
|
||||
else if(g_str_has_prefix(text, "help"))
|
||||
{
|
||||
|
@ -101,6 +101,7 @@ enum Status0Value
|
||||
STATUS_QUERY_QUIT,
|
||||
STATUS_QUERY_USER_NO_TURN,
|
||||
STATUS_GENERATE_TEAMS,
|
||||
STATUS_SPONSOR_CONTINUE,
|
||||
STATUS_END
|
||||
};
|
||||
|
||||
|
@ -59,4 +59,7 @@ file_compress_files(const gchar *destfile, const gchar *prefix);
|
||||
void
|
||||
file_decompress(const gchar *filename);
|
||||
|
||||
GPtrArray*
|
||||
file_get_name_files(void);
|
||||
|
||||
#endif
|
||||
|
@ -39,6 +39,21 @@ finance_update_user_weekly(User *user)
|
||||
}
|
||||
}
|
||||
|
||||
user->money += user->sponsor.benefit;
|
||||
user->money_in[1][MON_IN_SPONSOR] += user->sponsor.benefit;
|
||||
user->sponsor.contract = MAX(user->sponsor.contract - 1, 0);
|
||||
|
||||
if(user->counters[COUNT_USER_NEW_SPONSOR] > 1)
|
||||
user->counters[COUNT_USER_NEW_SPONSOR]--;
|
||||
else if(user->sponsor.contract == 4 &&
|
||||
math_rnd(0, 1) < ((1 - const_float("float_sponsor_continue_prob")) /
|
||||
(2 * (gfloat)const_int("int_user_success_offer_limit")) *
|
||||
user->counters[COUNT_USER_SUCCESS]) +
|
||||
(1 - (1 - const_float("float_sponsor_continue_prob")) / 2))
|
||||
user->counters[COUNT_USER_NEW_SPONSOR] = -1;
|
||||
else if(user->sponsor.contract == 0)
|
||||
user->counters[COUNT_USER_NEW_SPONSOR] = 1;
|
||||
|
||||
if(query_team_plays(tm, week - 1, 1))
|
||||
for(i=0;i<tm->players->len;i++)
|
||||
{
|
||||
|
@ -111,6 +111,7 @@ free_user(User *user)
|
||||
gint i;
|
||||
|
||||
free_g_string(&user->name);
|
||||
free_g_string(&user->sponsor.name);
|
||||
free_live_game(&user->live_game);
|
||||
free_option_list(&user->options, FALSE);
|
||||
|
||||
|
@ -277,9 +277,9 @@ game_initialize(Fixture *fix)
|
||||
player_games_goals_set(&g_array_index(fix->teams[i]->players, Player, j), fix->clid,
|
||||
PLAYER_VALUE_GAMES, 1);
|
||||
g_array_index(fix->teams[i]->players, Player, j).career[PLAYER_VALUE_GAMES]++;
|
||||
}
|
||||
|
||||
g_array_index(fix->teams[i]->players, Player, j).participation = TRUE;
|
||||
g_array_index(fix->teams[i]->players, Player, j).participation = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,6 +339,11 @@ game_gui_show_main(void)
|
||||
}
|
||||
else
|
||||
treeview_show_next_opponent();
|
||||
|
||||
if(current_user.counters[COUNT_USER_NEW_SPONSOR] == 1)
|
||||
user_show_sponsors();
|
||||
else if(current_user.counters[COUNT_USER_NEW_SPONSOR] == -1)
|
||||
user_show_sponsor_continue();
|
||||
}
|
||||
|
||||
/** Print a message into the main window entry. */
|
||||
|
@ -205,6 +205,8 @@ misc2_callback_add_user(void)
|
||||
g_array_append_val(users, new_user);
|
||||
|
||||
user_set_up_team(&usr(users->len - 1));
|
||||
usr(users->len - 1).counters[COUNT_USER_NEW_SPONSOR] = 1;
|
||||
|
||||
file_load_user_conf_file(&usr(users->len - 1));
|
||||
|
||||
treeview_show_users(GTK_TREE_VIEW(lookup_widget(window.user_management, "treeview_user_management_users")));
|
||||
|
@ -246,6 +246,7 @@ on_button_user_management_close_clicked
|
||||
gpointer user_data)
|
||||
{
|
||||
window_destroy(&window.user_management, FALSE);
|
||||
on_button_back_to_main_clicked(NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ misc_callback_start_game(void)
|
||||
window_destroy(&window.startup, TRUE);
|
||||
|
||||
window_create(WINDOW_MAIN);
|
||||
|
||||
|
||||
game_gui_show_main();
|
||||
}
|
||||
|
||||
@ -245,3 +245,25 @@ misc_callback_startup_load(const gchar *filename)
|
||||
else
|
||||
gtk_widget_show(window.startup);
|
||||
}
|
||||
|
||||
|
||||
/** The user has chosen a new sponsor. */
|
||||
void
|
||||
misc_callback_new_sponsor(void)
|
||||
{
|
||||
GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.sponsors, "treeview_sponsors"));
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gchar *name;
|
||||
gint contract, benefit;
|
||||
|
||||
gtk_tree_selection_get_selected(GTK_TREE_SELECTION(gtk_tree_view_get_selection(treeview)),
|
||||
&model, &iter);
|
||||
gtk_tree_model_get(model, &iter, 0, &name, 1, &contract, 2, &benefit, -1);
|
||||
|
||||
g_string_printf(current_user.sponsor.name, name);
|
||||
current_user.sponsor.contract = contract * 4;
|
||||
current_user.sponsor.benefit = benefit;
|
||||
|
||||
current_user.counters[COUNT_USER_NEW_SPONSOR] = 0;
|
||||
}
|
||||
|
@ -27,4 +27,7 @@ misc_callback_update_stadium_window(gboolean capacity);
|
||||
void
|
||||
misc_callback_startup_load(const gchar *filename);
|
||||
|
||||
void
|
||||
misc_callback_new_sponsor(void);
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "live_game.h"
|
||||
#include "load_save.h"
|
||||
#include "main.h"
|
||||
#include "maths.h"
|
||||
#include "misc_callback_func.h"
|
||||
#include "misc_callbacks.h"
|
||||
#include "option.h"
|
||||
@ -313,3 +314,51 @@ on_spinbutton_speed_button_press_event (GtkWidget *widget,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
on_button_sponsors_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
misc_callback_new_sponsor();
|
||||
|
||||
window_destroy(&window.sponsors, FALSE);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
on_treeview_sponsors_row_activated (GtkTreeView *treeview,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column,
|
||||
gpointer user_data)
|
||||
{
|
||||
on_button_sponsors_clicked(NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
on_window_sponsors_delete_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
on_button_sponsors_wait_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
if(stat1 != STATUS_SPONSOR_CONTINUE)
|
||||
{
|
||||
g_string_printf(current_user.sponsor.name, _("None"));
|
||||
current_user.sponsor.contract = 0;
|
||||
current_user.sponsor.benefit = 0;
|
||||
current_user.counters[COUNT_USER_NEW_SPONSOR] =
|
||||
math_rndi(const_int("int_sponsor_without_weeks_lower"),
|
||||
const_int("int_sponsor_without_weeks_upper"));
|
||||
}
|
||||
else
|
||||
current_user.counters[COUNT_USER_NEW_SPONSOR] = 0;
|
||||
|
||||
window_destroy(&window.sponsors, FALSE);
|
||||
}
|
||||
|
@ -115,3 +115,37 @@ on_spinbutton_speed_button_press_event (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer user_data);
|
||||
#endif
|
||||
|
||||
void
|
||||
on_button_sponsors_clicked (GtkButton *button,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
on_treeview_sponsors_row_activated (GtkTreeView *treeview,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean
|
||||
on_window_sponsors_delete_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean
|
||||
on_window_sponsors_delete_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
on_treeview_sponsors_row_activated (GtkTreeView *treeview,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
on_button_sponsors_clicked (GtkButton *button,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
on_button_sponsors_wait_clicked (GtkButton *button,
|
||||
gpointer user_data);
|
||||
|
@ -1090,3 +1090,132 @@ create_window_file_chooser (void)
|
||||
return window_file_chooser;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
create_window_sponsors (void)
|
||||
{
|
||||
GtkWidget *window_sponsors;
|
||||
GtkWidget *vbox48;
|
||||
GtkWidget *label_sponsors;
|
||||
GtkWidget *scrolledwindow12;
|
||||
GtkWidget *treeview_sponsors;
|
||||
GtkWidget *hbox71;
|
||||
GtkWidget *button_sponsors;
|
||||
GtkWidget *alignment23;
|
||||
GtkWidget *hbox73;
|
||||
GtkWidget *image63;
|
||||
GtkWidget *label117;
|
||||
GtkWidget *button_sponsors_wait;
|
||||
GtkWidget *alignment22;
|
||||
GtkWidget *hbox72;
|
||||
GtkWidget *image62;
|
||||
GtkWidget *label116;
|
||||
GtkTooltips *tooltips;
|
||||
|
||||
tooltips = gtk_tooltips_new ();
|
||||
|
||||
window_sponsors = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window_sponsors), 5);
|
||||
gtk_window_set_title (GTK_WINDOW (window_sponsors), _("window1"));
|
||||
gtk_window_set_position (GTK_WINDOW (window_sponsors), GTK_WIN_POS_CENTER);
|
||||
gtk_window_set_modal (GTK_WINDOW (window_sponsors), TRUE);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window_sponsors), 450, 350);
|
||||
|
||||
vbox48 = gtk_vbox_new (FALSE, 3);
|
||||
gtk_widget_show (vbox48);
|
||||
gtk_container_add (GTK_CONTAINER (window_sponsors), vbox48);
|
||||
|
||||
label_sponsors = gtk_label_new (_("There are a few companies interested in sponsoring your team. Please select one:"));
|
||||
gtk_widget_show (label_sponsors);
|
||||
gtk_box_pack_start (GTK_BOX (vbox48), label_sponsors, FALSE, FALSE, 0);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label_sponsors), TRUE);
|
||||
|
||||
scrolledwindow12 = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolledwindow12);
|
||||
gtk_box_pack_start (GTK_BOX (vbox48), scrolledwindow12, TRUE, TRUE, 0);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow12), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow12), GTK_SHADOW_IN);
|
||||
|
||||
treeview_sponsors = gtk_tree_view_new ();
|
||||
gtk_widget_show (treeview_sponsors);
|
||||
gtk_container_add (GTK_CONTAINER (scrolledwindow12), treeview_sponsors);
|
||||
|
||||
hbox71 = gtk_hbox_new (FALSE, 3);
|
||||
gtk_widget_show (hbox71);
|
||||
gtk_box_pack_start (GTK_BOX (vbox48), hbox71, FALSE, FALSE, 0);
|
||||
|
||||
button_sponsors = gtk_button_new ();
|
||||
gtk_widget_show (button_sponsors);
|
||||
gtk_box_pack_start (GTK_BOX (hbox71), button_sponsors, TRUE, TRUE, 0);
|
||||
|
||||
alignment23 = gtk_alignment_new (0.5, 0.5, 0, 0);
|
||||
gtk_widget_show (alignment23);
|
||||
gtk_container_add (GTK_CONTAINER (button_sponsors), alignment23);
|
||||
|
||||
hbox73 = gtk_hbox_new (FALSE, 2);
|
||||
gtk_widget_show (hbox73);
|
||||
gtk_container_add (GTK_CONTAINER (alignment23), hbox73);
|
||||
|
||||
image63 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON);
|
||||
gtk_widget_show (image63);
|
||||
gtk_box_pack_start (GTK_BOX (hbox73), image63, FALSE, FALSE, 0);
|
||||
|
||||
label117 = gtk_label_new_with_mnemonic (_("Accept"));
|
||||
gtk_widget_show (label117);
|
||||
gtk_box_pack_start (GTK_BOX (hbox73), label117, FALSE, FALSE, 0);
|
||||
|
||||
button_sponsors_wait = gtk_button_new ();
|
||||
gtk_widget_show (button_sponsors_wait);
|
||||
gtk_box_pack_start (GTK_BOX (hbox71), button_sponsors_wait, TRUE, TRUE, 0);
|
||||
gtk_tooltips_set_tip (tooltips, button_sponsors_wait, _("If you don't like any of the sponsors, you can go a few weeks without sponsor and wait for new offers."), NULL);
|
||||
|
||||
alignment22 = gtk_alignment_new (0.5, 0.5, 0, 0);
|
||||
gtk_widget_show (alignment22);
|
||||
gtk_container_add (GTK_CONTAINER (button_sponsors_wait), alignment22);
|
||||
|
||||
hbox72 = gtk_hbox_new (FALSE, 2);
|
||||
gtk_widget_show (hbox72);
|
||||
gtk_container_add (GTK_CONTAINER (alignment22), hbox72);
|
||||
|
||||
image62 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_BUTTON);
|
||||
gtk_widget_show (image62);
|
||||
gtk_box_pack_start (GTK_BOX (hbox72), image62, FALSE, FALSE, 0);
|
||||
|
||||
label116 = gtk_label_new_with_mnemonic (_("Reject for now"));
|
||||
gtk_widget_show (label116);
|
||||
gtk_box_pack_start (GTK_BOX (hbox72), label116, FALSE, FALSE, 0);
|
||||
|
||||
g_signal_connect ((gpointer) window_sponsors, "delete_event",
|
||||
G_CALLBACK (on_window_sponsors_delete_event),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) treeview_sponsors, "row_activated",
|
||||
G_CALLBACK (on_treeview_sponsors_row_activated),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) button_sponsors, "clicked",
|
||||
G_CALLBACK (on_button_sponsors_clicked),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) button_sponsors_wait, "clicked",
|
||||
G_CALLBACK (on_button_sponsors_wait_clicked),
|
||||
NULL);
|
||||
|
||||
/* Store pointers to all widgets, for use by lookup_widget(). */
|
||||
GLADE_HOOKUP_OBJECT_NO_REF (window_sponsors, window_sponsors, "window_sponsors");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, vbox48, "vbox48");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, label_sponsors, "label_sponsors");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, scrolledwindow12, "scrolledwindow12");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, treeview_sponsors, "treeview_sponsors");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, hbox71, "hbox71");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, button_sponsors, "button_sponsors");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, alignment23, "alignment23");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, hbox73, "hbox73");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, image63, "image63");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, label117, "label117");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, button_sponsors_wait, "button_sponsors_wait");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, alignment22, "alignment22");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, hbox72, "hbox72");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, image62, "image62");
|
||||
GLADE_HOOKUP_OBJECT (window_sponsors, label116, "label116");
|
||||
GLADE_HOOKUP_OBJECT_NO_REF (window_sponsors, tooltips, "tooltips");
|
||||
|
||||
return window_sponsors;
|
||||
}
|
||||
|
||||
|
@ -7,3 +7,4 @@ GtkWidget* create_window_font_sel (void);
|
||||
GtkWidget* create_window_live (void);
|
||||
GtkWidget* create_window_stadium (void);
|
||||
GtkWidget* create_window_file_chooser (void);
|
||||
GtkWidget* create_window_sponsors (void);
|
||||
|
32
src/name.c
32
src/name.c
@ -1,3 +1,4 @@
|
||||
#include "main.h"
|
||||
#include "name.h"
|
||||
#include "option.h"
|
||||
#include "variables.h"
|
||||
@ -81,3 +82,34 @@ name_shorten_list(NameList *namelist)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Find the namelist with the given sid. */
|
||||
NameList*
|
||||
name_get_list_from_sid(const gchar *sid)
|
||||
{
|
||||
gint i;
|
||||
NameList new;
|
||||
|
||||
for(i=0;i<name_lists->len;i++)
|
||||
if(strcmp(sid, nli(i).sid->str) == 0)
|
||||
return &nli(i);
|
||||
|
||||
new.sid = NULL;
|
||||
new.first_names = new.last_names = NULL;
|
||||
|
||||
xml_name_read(sid, &new);
|
||||
|
||||
if(new.sid == NULL)
|
||||
{
|
||||
g_warning("name_get_list_from_sid: namelist with sid %s not found", sid);
|
||||
main_exit_program(EXIT_POINTER_NOT_FOUND, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
name_shorten_list(&new);
|
||||
g_array_append_val(name_lists, new);
|
||||
return &nli(name_lists->len - 1);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -21,4 +21,7 @@ name_get(const gchar *names_file);
|
||||
GString*
|
||||
name_get_from_list(const NameList *namelist);
|
||||
|
||||
NameList*
|
||||
name_get_list_from_sid(const gchar *sid);
|
||||
|
||||
#endif
|
||||
|
@ -499,8 +499,10 @@ player_swap(Team *tm1, gint player_number1, Team *tm2, gint player_number2)
|
||||
if(stat0 == STATUS_LIVE_GAME_PAUSE)
|
||||
{
|
||||
clid = usr(stat2).live_game.fix->clid;
|
||||
if((player_number1 < 11 && player_is_banned(player_of_idx_team(tm1, player_number1)) > 0) ||
|
||||
(player_number2 < 11 && player_is_banned(player_of_idx_team(tm2, player_number2)) > 0))
|
||||
if((player_number1 < 11 && player_is_banned(player_of_idx_team(tm1, player_number1)) > 0 &&
|
||||
player_of_idx_team(tm1, player_number1)->participation) ||
|
||||
(player_number2 < 11 && player_is_banned(player_of_idx_team(tm2, player_number2)) > 0 &&
|
||||
player_of_idx_team(tm2, player_number2)->participation))
|
||||
{
|
||||
game_gui_show_warning(_("You can't replace a banned player."));
|
||||
return;
|
||||
|
@ -112,12 +112,14 @@ team_generate_players_stadium(Team *tm)
|
||||
for(i=0;i<const_int("int_team_cpu_players");i++)
|
||||
{
|
||||
new = player_new(tm, average_skill, TRUE);
|
||||
wages += new.wage;
|
||||
g_array_append_val(tm->players, new);
|
||||
|
||||
if(i > 2)
|
||||
wages += new.wage;
|
||||
}
|
||||
|
||||
tm->stadium.average_attendance = tm->stadium.possible_attendance =
|
||||
tm->stadium.games = 0;
|
||||
tm->stadium.games = 0;
|
||||
tm->stadium.safety =
|
||||
math_rnd(const_float("float_team_stadium_safety_lower"),
|
||||
const_float("float_team_stadium_safety_upper"));
|
||||
|
@ -162,6 +162,7 @@ treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams,
|
||||
GtkTreeModel *team_list =
|
||||
treeview_create_team_selection_list(show_cup_teams, show_user_teams);
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string("0");
|
||||
|
||||
treeview_helper_clear(treeview);
|
||||
|
||||
@ -170,9 +171,9 @@ treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams,
|
||||
gtk_tree_view_set_model(treeview, team_list);
|
||||
|
||||
selection = gtk_tree_view_get_selection(treeview);
|
||||
gtk_tree_selection_select_path(selection,
|
||||
gtk_tree_path_new_from_string("0"));
|
||||
gtk_tree_selection_select_path(selection, path);
|
||||
g_object_unref(team_list);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
|
||||
/** Create the list store for a player list.
|
||||
@ -1239,7 +1240,8 @@ treeview_create_finances(const User* user)
|
||||
*out = user->money_out[0];
|
||||
gchar *in_titles[MON_IN_TRANSFERS] =
|
||||
{_("Prize money"),
|
||||
_("Ticket income")};
|
||||
_("Ticket income"),
|
||||
_("Sponsorship")};
|
||||
gchar *out_titles[MON_OUT_TRANSFERS] =
|
||||
{_("Wages"),
|
||||
_("Physio"),
|
||||
@ -1328,6 +1330,18 @@ treeview_create_finances(const User* user)
|
||||
gtk_list_store_append(ls, &iter);
|
||||
gtk_list_store_set(ls, &iter, 0, "", 1, "", 2, "", -1);
|
||||
|
||||
gtk_list_store_append(ls, &iter);
|
||||
gtk_list_store_set(ls, &iter, 0, _("Sponsor"), 1, user->sponsor.name->str,
|
||||
2, "", -1);
|
||||
|
||||
misc_print_grouped_int(user->sponsor.benefit, buf, FALSE);
|
||||
sprintf(buf2, _("%.1f months / %s"), ((gfloat)user->sponsor.contract) / 4, buf);
|
||||
gtk_list_store_append(ls, &iter);
|
||||
gtk_list_store_set(ls, &iter, 0, _("Contract / Money"), 1, buf2, 2, "", -1);
|
||||
|
||||
gtk_list_store_append(ls, &iter);
|
||||
gtk_list_store_set(ls, &iter, 0, "", 1, "", 2, "", -1);
|
||||
|
||||
treeview_create_stadium_summary(ls);
|
||||
|
||||
return GTK_TREE_MODEL(ls);
|
||||
@ -2341,3 +2355,80 @@ treeview_show_language_combo(void)
|
||||
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_languages), idx + 1);
|
||||
}
|
||||
|
||||
GtkTreeModel*
|
||||
treeview_create_sponsors(const GArray *sponsors)
|
||||
{
|
||||
gint i;
|
||||
GtkListStore *ls = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_INT,
|
||||
G_TYPE_INT);
|
||||
GtkTreeIter iter;
|
||||
|
||||
for(i=0;i<sponsors->len;i++)
|
||||
{
|
||||
gtk_list_store_append(ls, &iter);
|
||||
gtk_list_store_set(ls, &iter,
|
||||
0, g_array_index(sponsors, UserSponsor, i).name->str,
|
||||
1, g_array_index(sponsors, UserSponsor, i).contract / 4,
|
||||
2, g_array_index(sponsors, UserSponsor, i).benefit,
|
||||
-1);
|
||||
}
|
||||
|
||||
for(i=1;i<3;i++)
|
||||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), i,
|
||||
treeview_helper_int_compare, GINT_TO_POINTER(i), NULL);
|
||||
|
||||
return GTK_TREE_MODEL(ls);
|
||||
}
|
||||
|
||||
void
|
||||
treeview_set_up_sponsors(GtkTreeView *treeview)
|
||||
{
|
||||
gint i;
|
||||
GtkTreeViewColumn *col;
|
||||
GtkCellRenderer *renderer;
|
||||
gchar *titles[3] =
|
||||
{_("Company"),
|
||||
_("Contract length\n(Months)"),
|
||||
_("Money / week")};
|
||||
|
||||
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
||||
GTK_SELECTION_BROWSE);
|
||||
gtk_tree_view_set_rules_hint(treeview, TRUE);
|
||||
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
||||
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
col = gtk_tree_view_column_new();
|
||||
gtk_tree_view_column_set_title(col, titles[i]);
|
||||
gtk_tree_view_append_column(treeview, col);
|
||||
renderer = treeview_helper_cell_renderer_text_new();
|
||||
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||
gtk_tree_view_column_add_attribute(col, renderer,
|
||||
"markup", i);
|
||||
|
||||
if(i > 0)
|
||||
{
|
||||
g_object_set(renderer, "xalign", 0.5, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(col, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Show a list of sponsor offers. */
|
||||
void
|
||||
treeview_show_sponsors(const GArray *sponsors)
|
||||
{
|
||||
GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.sponsors,
|
||||
"treeview_sponsors"));
|
||||
GtkTreeModel *model = treeview_create_sponsors(sponsors);
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string("0");
|
||||
|
||||
treeview_helper_clear(treeview);
|
||||
|
||||
treeview_set_up_sponsors(treeview);
|
||||
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(model));
|
||||
gtk_tree_selection_select_path(gtk_tree_view_get_selection(treeview), path);
|
||||
g_object_unref(model);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
|
@ -207,4 +207,13 @@ treeview_show_leagues_combo(void);
|
||||
void
|
||||
treeview_show_language_combo(void);
|
||||
|
||||
GtkTreeModel*
|
||||
treeview_create_sponsors(const GArray *sponsors);
|
||||
|
||||
void
|
||||
treeview_set_up_sponsors(GtkTreeView *treeview);
|
||||
|
||||
void
|
||||
treeview_show_sponsors(const GArray *sponsors);
|
||||
|
||||
#endif
|
||||
|
@ -1233,3 +1233,18 @@ treeview_helper_live_game_result(GtkTreeViewColumn *col,
|
||||
|
||||
g_object_set(renderer, "markup", buf, NULL);
|
||||
}
|
||||
|
||||
gint
|
||||
treeview_helper_int_compare(GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint column = GPOINTER_TO_INT(user_data);
|
||||
gint value1, value2;
|
||||
|
||||
gtk_tree_model_get(model, a, column, &value1, -1);
|
||||
gtk_tree_model_get(model, b, column, &value2, -1);
|
||||
|
||||
return misc_int_compare(value1, value2);
|
||||
}
|
||||
|
@ -141,4 +141,10 @@ treeview_helper_player_info_career_to_cell(GtkCellRenderer *renderer, const Play
|
||||
gchar*
|
||||
treeview_helper_get_user_history_icon(gint history_type);
|
||||
|
||||
gint
|
||||
treeview_helper_int_compare(GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data);
|
||||
|
||||
#endif
|
||||
|
134
src/user.c
134
src/user.c
@ -1,4 +1,5 @@
|
||||
#include "cup.h"
|
||||
#include "finance.h"
|
||||
#include "fixture.h"
|
||||
#include "free.h"
|
||||
#include "game_gui.h"
|
||||
@ -7,8 +8,10 @@
|
||||
#include "main.h"
|
||||
#include "maths.h"
|
||||
#include "misc.h"
|
||||
#include "name.h"
|
||||
#include "option.h"
|
||||
#include "player.h"
|
||||
#include "support.h"
|
||||
#include "team.h"
|
||||
#include "transfer.h"
|
||||
#include "treeview.h"
|
||||
@ -32,6 +35,9 @@ user_new(void)
|
||||
new.options.list = NULL;
|
||||
new.options.datalist = NULL;
|
||||
|
||||
new.sponsor.name = g_string_new("");
|
||||
new.sponsor.contract = new.sponsor.benefit = -1;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -67,6 +73,8 @@ user_set_up_team_new_game(User *user)
|
||||
|
||||
user_set_up_team(user);
|
||||
}
|
||||
|
||||
user->counters[COUNT_USER_NEW_SPONSOR] = 1;
|
||||
}
|
||||
|
||||
/** Set up finances, remove some players etc. for a new user team.
|
||||
@ -723,3 +731,129 @@ query_user_no_turn(void)
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/** Get a random sponsor for the user. */
|
||||
UserSponsor
|
||||
user_get_sponsor(const User *user)
|
||||
{
|
||||
UserSponsor new;
|
||||
gint suc_factor = (current_user.counters[COUNT_USER_SUCCESS] < 0) ? -1 : 1;
|
||||
gchar *names[18] =
|
||||
{_(" Systems"),
|
||||
_(" Communications"),
|
||||
_(" Holdings"),
|
||||
_(" Industries"),
|
||||
_(" Company"),
|
||||
_(" Telecommunications"),
|
||||
_(" Labs"),
|
||||
_(" Technologies"),
|
||||
_(" Chemicals"),
|
||||
_(" Energy"),
|
||||
_(" Bank"),
|
||||
_(" Products"),
|
||||
_(" Software"),
|
||||
_(" Scientific"),
|
||||
_(" Financial"),
|
||||
_(" Petroleum"),
|
||||
_(" Restaurants"),
|
||||
_(" Data Systems")};
|
||||
gchar *short_names[7] =
|
||||
{_(" Ltd."),
|
||||
_(" Assoc."),
|
||||
_(" Co."),
|
||||
_(" Ent."),
|
||||
_(" & Co."),
|
||||
_(" Corp."),
|
||||
_(" Group")};
|
||||
gchar *name_add[3] =
|
||||
{_(" & Sons"),
|
||||
_(" & Daughters"),
|
||||
_(" Bros.")};
|
||||
|
||||
new.name = g_string_new(name_get_random_last_name(name_get_list_from_sid(user->tm->names_file->str)));
|
||||
if(math_rnd(0, 1) < 0.2)
|
||||
g_string_append(new.name, name_add[math_rndi(0, 2)]);
|
||||
g_string_append(new.name, names[math_rndi(0, 17)]);
|
||||
if(math_rnd(0, 1) < 0.7)
|
||||
g_string_append(new.name, short_names[math_rndi(0, 6)]);
|
||||
|
||||
new.contract = 4 * math_rndi(9, 36);
|
||||
new.benefit = (gint)rint((((const_float("float_sponsor_wage_percentage_upper") -
|
||||
const_float("float_sponsor_wage_percentage_lower")) /
|
||||
(2 * (gfloat)const_int("int_user_success_offer_limit"))) *
|
||||
(gfloat)current_user.counters[COUNT_USER_SUCCESS]
|
||||
+ ((const_float("float_sponsor_wage_percentage_upper") -
|
||||
const_float("float_sponsor_wage_percentage_lower")) / 2)) *
|
||||
(1 + suc_factor *
|
||||
((gfloat)new.contract / 52 - 1) * const_float("float_sponsor_contract_length_factor")) *
|
||||
(finance_wage_unit(current_user.tm) * current_user.tm->players->len));
|
||||
new.benefit = math_round_integer(new.benefit, 2);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/** Show a list of sponsors for the user to choose from. */
|
||||
void
|
||||
user_show_sponsors(void)
|
||||
{
|
||||
gint i, num_offers;
|
||||
GArray *sponsors = g_array_new(FALSE, FALSE, sizeof(UserSponsor));
|
||||
UserSponsor sponsor;
|
||||
|
||||
if(ABS(current_user.counters[COUNT_USER_SUCCESS]) >=
|
||||
const_int("int_user_success_offer_limit"))
|
||||
num_offers = (current_user.counters[COUNT_USER_SUCCESS] < 0) ?
|
||||
const_int("int_sponsor_offers_lower") :
|
||||
const_int("int_sponsor_offers_upper");
|
||||
else
|
||||
num_offers = (gint)rint(((gfloat)(const_int("int_sponsor_offers_upper") -
|
||||
const_int("int_sponsor_offers_lower")) /
|
||||
(2 * (gfloat)const_int("int_user_success_offer_limit"))) *
|
||||
(gfloat)current_user.counters[COUNT_USER_SUCCESS]
|
||||
+ ((gfloat)(const_int("int_sponsor_offers_upper") -
|
||||
const_int("int_sponsor_offers_lower")) / 2) + 1);
|
||||
|
||||
num_offers += math_rndi(-1, 1);
|
||||
if(num_offers <= 0)
|
||||
num_offers = 1;
|
||||
|
||||
for(i=0;i<num_offers;i++)
|
||||
{
|
||||
sponsor = user_get_sponsor(¤t_user);
|
||||
g_array_append_val(sponsors, sponsor);
|
||||
}
|
||||
|
||||
window_create(WINDOW_SPONSORS);
|
||||
|
||||
treeview_show_sponsors(sponsors);
|
||||
|
||||
for(i=0;i<num_offers;i++)
|
||||
g_string_free(g_array_index(sponsors, UserSponsor, i).name, TRUE);
|
||||
g_array_free(sponsors, TRUE);
|
||||
}
|
||||
|
||||
/** The current sponsor offers to continue. */
|
||||
void
|
||||
user_show_sponsor_continue(void)
|
||||
{
|
||||
GArray *sponsors = g_array_new(FALSE, FALSE, sizeof(UserSponsor));
|
||||
UserSponsor sponsor;
|
||||
|
||||
sponsor = user_get_sponsor(¤t_user);
|
||||
|
||||
g_string_printf(sponsor.name, current_user.sponsor.name->str);
|
||||
|
||||
g_array_append_val(sponsors, sponsor);
|
||||
|
||||
window_create(WINDOW_SPONSORS);
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(lookup_widget(window.sponsors, "label_sponsors")),
|
||||
_("Your current sponsor is satisfied with your results and would like to renew the contract."));
|
||||
|
||||
treeview_show_sponsors(sponsors);
|
||||
|
||||
g_string_free(g_array_index(sponsors, UserSponsor, 0).name, TRUE);
|
||||
g_array_free(sponsors, TRUE);
|
||||
|
||||
stat1 = STATUS_SPONSOR_CONTINUE;
|
||||
}
|
||||
|
10
src/user.h
10
src/user.h
@ -78,4 +78,14 @@ user_job_offer(User *user);
|
||||
gboolean
|
||||
query_user_no_turn(void);
|
||||
|
||||
void
|
||||
user_show_sponsors(void);
|
||||
|
||||
UserSponsor
|
||||
user_get_sponsor(const User *user);
|
||||
|
||||
void
|
||||
user_show_sponsor_continue(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -13,7 +13,8 @@ enum MonIn
|
||||
{
|
||||
MON_IN_PRIZE = 0,
|
||||
MON_IN_TICKET,
|
||||
MON_IN_TRANSFERS,
|
||||
MON_IN_SPONSOR,
|
||||
MON_IN_TRANSFERS,
|
||||
MON_IN_END
|
||||
};
|
||||
|
||||
@ -46,9 +47,52 @@ enum CounterValue
|
||||
COUNT_USER_STADIUM_SAFETY, /**< Counter for increasing stadium safety. */
|
||||
COUNT_USER_SHOW_RES, /**< Whether the latest result is shown when the main window gets refreshed. */
|
||||
COUNT_USER_TOOK_TURN, /**< Whether the user took his turn in a week round. */
|
||||
COUNT_USER_NEW_SPONSOR, /**< A new sponsor offer has to be shown. */
|
||||
COUNT_USER_END
|
||||
};
|
||||
|
||||
/** 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_CHAMPION,
|
||||
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;
|
||||
|
||||
/** A user sponsor. */
|
||||
typedef struct
|
||||
{
|
||||
GString *name;
|
||||
gint benefit; /**< Money per week. */
|
||||
gint contract; /**< Contract length in weeks. */
|
||||
} UserSponsor;
|
||||
|
||||
/** A structure representing a human player. */
|
||||
typedef struct
|
||||
{
|
||||
@ -77,6 +121,8 @@ typedef struct
|
||||
gint scout, physio;
|
||||
/** The variable for the latest user live game. @see #Game */
|
||||
LiveGame live_game;
|
||||
|
||||
UserSponsor sponsor;
|
||||
} User;
|
||||
|
||||
enum EventType
|
||||
@ -118,38 +164,4 @@ 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_CHAMPION,
|
||||
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
|
||||
|
23
src/window.c
23
src/window.c
@ -80,7 +80,8 @@ window_show_startup(void)
|
||||
gtk_combo_box_set_model(GTK_COMBO_BOX(combo_country), model);
|
||||
g_object_unref(model);
|
||||
|
||||
gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(combo_country), 1);
|
||||
if(gtk_combo_box_entry_get_text_column(GTK_COMBO_BOX_ENTRY(combo_country)) == -1)
|
||||
gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(combo_country), 1);
|
||||
gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo_country));
|
||||
|
||||
renderer = gtk_cell_renderer_pixbuf_new();
|
||||
@ -103,6 +104,7 @@ window_show_file_sel(void)
|
||||
gchar buf[SMALL];
|
||||
const gchar *home = g_get_home_dir();
|
||||
gchar *filename = NULL;
|
||||
GtkFileFilter *filter;
|
||||
|
||||
window_create(WINDOW_FILE_CHOOSER);
|
||||
|
||||
@ -113,6 +115,17 @@ window_show_file_sel(void)
|
||||
gtk_file_chooser_set_action(GTK_FILE_CHOOSER(window.file_chooser),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
|
||||
filter = gtk_file_filter_new();
|
||||
gtk_file_filter_set_name(filter, _("Bygfoot Save Files"));
|
||||
gtk_file_filter_add_pattern(filter, "*.zip");
|
||||
gtk_file_filter_add_pattern(filter, "last_save");
|
||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window.file_chooser), filter);
|
||||
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_set_name(filter, _("All Files"));
|
||||
gtk_file_filter_add_pattern(filter, "*");
|
||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window.file_chooser), filter);
|
||||
|
||||
if(strlen(save_file->str) > 0)
|
||||
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(window.file_chooser),
|
||||
save_file->str);
|
||||
@ -492,6 +505,14 @@ window_create(gint window_type)
|
||||
wind = window.transfer_dialog;
|
||||
strcpy(buf, _("Transfer offer"));
|
||||
break;
|
||||
case WINDOW_SPONSORS:
|
||||
if(window.sponsors != NULL)
|
||||
g_warning("window_create: called on already existing window\n");
|
||||
else
|
||||
window.sponsors = create_window_sponsors();
|
||||
wind = window.sponsors;
|
||||
strcpy(buf, _("Sponsorship offers"));
|
||||
break;
|
||||
}
|
||||
|
||||
if(window_type != WINDOW_FILE_CHOOSER)
|
||||
|
@ -24,6 +24,7 @@ enum Windows
|
||||
WINDOW_DEBUG,
|
||||
WINDOW_HELP,
|
||||
WINDOW_TRANSFER_DIALOG,
|
||||
WINDOW_SPONSORS,
|
||||
WINDOW_END
|
||||
};
|
||||
|
||||
|
@ -33,6 +33,9 @@ enum
|
||||
TAG_USER_EVENT_VALUE1,
|
||||
TAG_USER_EVENT_VALUE2,
|
||||
TAG_USER_EVENT_VALUE_STRING,
|
||||
TAG_USER_SPONSOR_NAME,
|
||||
TAG_USER_SPONSOR_CONTRACT,
|
||||
TAG_USER_SPONSOR_BENEFIT,
|
||||
TAG_END
|
||||
};
|
||||
|
||||
@ -102,6 +105,9 @@ xml_loadsave_users_end_element (GMarkupParseContext *context,
|
||||
tag == TAG_USER_MONEY_OUTS ||
|
||||
tag == TAG_USER_SCOUT ||
|
||||
tag == TAG_USER_PHYSIO ||
|
||||
tag == TAG_USER_SPONSOR_NAME ||
|
||||
tag == TAG_USER_SPONSOR_CONTRACT ||
|
||||
tag == TAG_USER_SPONSOR_BENEFIT ||
|
||||
tag == TAG_NAME ||
|
||||
tag == TAG_TEAM_ID ||
|
||||
tag == TAG_USER_HISTORY ||
|
||||
@ -177,6 +183,12 @@ xml_loadsave_users_text (GMarkupParseContext *context,
|
||||
new_user.scout = int_value;
|
||||
else if(state == TAG_USER_PHYSIO)
|
||||
new_user.physio = int_value;
|
||||
else if(state == TAG_USER_SPONSOR_NAME)
|
||||
g_string_printf(new_user.sponsor.name, buf);
|
||||
else if(state == TAG_USER_SPONSOR_CONTRACT)
|
||||
new_user.sponsor.contract = int_value;
|
||||
else if(state == TAG_USER_SPONSOR_BENEFIT)
|
||||
new_user.sponsor.benefit = int_value;
|
||||
else if(state == TAG_USER_COUNTER)
|
||||
new_user.counters[idx] = int_value;
|
||||
else if(state == TAG_USER_MONEY_IN)
|
||||
@ -275,6 +287,10 @@ xml_loadsave_users_write(const gchar *prefix)
|
||||
xml_write_int(fil, usr(i).scout, TAG_USER_SCOUT, I1);
|
||||
xml_write_int(fil, usr(i).physio, TAG_USER_PHYSIO, I1);
|
||||
|
||||
xml_write_g_string(fil, usr(i).sponsor.name, TAG_USER_SPONSOR_NAME, I1);
|
||||
xml_write_int(fil, usr(i).sponsor.contract, TAG_USER_SPONSOR_CONTRACT, I1);
|
||||
xml_write_int(fil, usr(i).sponsor.benefit, TAG_USER_SPONSOR_BENEFIT, I1);
|
||||
|
||||
for(j=0;j<COUNT_USER_END;j++)
|
||||
xml_write_int(fil, usr(i).counters[j], TAG_USER_COUNTER, I1);
|
||||
|
||||
|
@ -79,11 +79,11 @@ float_team_stadium_safety_upper 10000
|
||||
# ticket price; this determines together with
|
||||
# the player wages the size of the stadium at
|
||||
# generation
|
||||
int_team_stadium_ticket_price 30
|
||||
int_team_stadium_ticket_price 25
|
||||
|
||||
# factor for stadium size; this determines the income
|
||||
# of the user teams
|
||||
float_team_stadium_size_wage_factor 21000
|
||||
float_team_stadium_size_wage_factor 18000
|
||||
|
||||
# stadium safety deterioration values (per game)
|
||||
float_game_stadium_safety_deterioration_lower 20
|
||||
@ -741,3 +741,27 @@ float_name_random_list_prob 2000
|
||||
string_language_names English Deutsch Nederlands
|
||||
string_language_codes C de_DE nl_NL
|
||||
string_language_symbols flag_england.png flag_germany.png flag_nl.png
|
||||
|
||||
# lower and upper limits of which percentage
|
||||
# of the player wages a sponsor pays; the actual
|
||||
# value depends on the team's success
|
||||
float_sponsor_wage_percentage_lower 2000
|
||||
float_sponsor_wage_percentage_upper 7000
|
||||
|
||||
# percentage difference between shorter and longer
|
||||
# contracts. whether this counts positively or negatively
|
||||
# depends on whether the success counter is positive or negative
|
||||
float_sponsor_contract_length_factor 1200
|
||||
|
||||
# lower and upper limits for number of sponsor offers
|
||||
int_sponsor_offers_lower 1
|
||||
int_sponsor_offers_upper 5
|
||||
|
||||
# limits for weeks without sponsor
|
||||
int_sponsor_without_weeks_lower 3
|
||||
int_sponsor_without_weeks_upper 6
|
||||
|
||||
# probability that the current sponsor wants
|
||||
# to continue engagement if the team is completely
|
||||
# unsuccessful
|
||||
float_sponsor_continue_prob 1000
|
||||
|
Loading…
x
Reference in New Issue
Block a user