Automatic loan repayment.

This commit is contained in:
gyboth 2008-11-07 20:43:38 +00:00
parent ef5a5ff1c2
commit 0c61e64b26
15 changed files with 279 additions and 402 deletions

View File

@ -1206,7 +1206,7 @@
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">4</property>
<property name="n_columns">3</property>
<property name="homogeneous">False</property>
<property name="row_spacing">2</property>
<property name="column_spacing">2</property>
@ -1267,131 +1267,6 @@
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton_start_week">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">False</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">0 0 0 1 10 0</property>
<signal name="changed" handler="on_spinbutton_start_week_changed" last_modification_time="Thu, 06 Nov 2008 16:38:31 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton_weekly_installment">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">False</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">1 0 0 1 10 0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_calculate_start_week">
<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_calculate_start_week_clicked" last_modification_time="Thu, 06 Nov 2008 16:38:52 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment7">
<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="hbox16">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="stock">gtk-execute</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="label21">
<property name="visible">True</property>
<property name="label" translatable="yes">Calculate start week</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>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">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="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_calculate_installment">
<property name="visible">True</property>
@ -1465,8 +1340,8 @@
</child>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
@ -1475,67 +1350,128 @@
</child>
<child>
<widget class="GtkHBox" id="hbox17">
<widget class="GtkButton" id="button_calculate_start_week">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</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_calculate_start_week_clicked" last_modification_time="Thu, 06 Nov 2008 16:38:52 GMT"/>
<child>
<widget class="GtkLabel" id="label26">
<widget class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
<property name="label" translatable="yes">Week</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<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="GtkLabel" id="label_start_week">
<property name="visible">True</property>
<property name="label" translatable="yes">label14</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">3</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
<child>
<widget class="GtkHBox" id="hbox16">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="stock">gtk-execute</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="label21">
<property name="visible">True</property>
<property name="label" translatable="yes">Calculate start week</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>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton_start_week">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">False</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">0 0 0 1 10 0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options">fill</property>
<property name="x_options">expand</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton_weekly_installment">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">False</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">1 0 0 1 10 0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">expand</property>
<property name="y_options"></property>
</packing>
</child>
</widget>

View File

@ -26,8 +26,6 @@ bygfoot_SOURCES = \
language.c callbacks.h free.h language.h lg_commentary.h misc.h option.h variables.h window.h \
lg_commentary.c cup.h file.h fixture.h free.h language.h league.h lg_commentary.h live_game.h main.h maths.h misc.h option.h player.h team.h variables.h xml_lg_commentary.h \
league.c cup.h free.h league.h main.h maths.h misc.h option.h player.h stat.h table.h team.h user.h variables.h \
league_table_callbacks.c league_table_callbacks.h league_table_interface.h window.h \
league_table_interface.c league_table_callbacks.h league_table_interface.h \
live_game.c callbacks.h fixture.h free.h game_gui.h game.h league.h lg_commentary.h live_game.h main.h maths.h misc_callback_func.h misc.h option.h player.h strategy.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 language.h load_save.h misc.h option.h support.h user.h variables.h window.h xml.h xml_loadsave_cup.h xml_loadsave_jobs.h xml_loadsave_league.h xml_loadsave_leagues_cups.h xml_loadsave_misc.h xml_loadsave_season_stats.h xml_loadsave_transfers.h xml_loadsave_users.h \
main.c bet_struct.h debug.h file.h free.h job_struct.h language.h lg_commentary.h live_game.h load_save.h main.h misc_callbacks.h misc.h name_struct.h option.h start_end.h stat_struct.h strategy_struct.h transfer_struct.h variables.h window.h xml_strategy.h \

View File

@ -168,7 +168,6 @@ typedef struct
*bets,
*splash,
*training_camp,
*league_table,
*alr;
/** The position of the horizontal divider is stored here. */

View File

@ -28,6 +28,7 @@
#include "callbacks.h"
#include "callback_func.h"
#include "debug.h"
#include "fixture.h"
#include "free.h"
#include "game.h"
#include "game_gui.h"
@ -1306,11 +1307,15 @@ on_automatic_loan_repayment_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
if(current_user.debt == 0)
{
game_gui_print_message(_("You are not in debt."));
return;
}
{
game_gui_print_message(_("You are not in debt."));
return;
}
else if(week >= fixture_get_last_scheduled_week() - 1)
{
game_gui_print_message(_("It's too late in the season for automatic loan repayment."));
return;
}
window_show_alr();
}

View File

@ -25,6 +25,7 @@
#include "callbacks.h"
#include "finance.h"
#include "fixture.h"
#include "game_gui.h"
#include "league.h"
#include "maths.h"
@ -389,3 +390,47 @@ finance_update_current_interest(void)
else if(current_interest > const_float("float_finance_interest_upper"))
current_interest = const_float("float_finance_interest_upper");
}
/** Calculate the weekly installment for an automatic loan repayment
depending on the start week. */
gint
finance_calculate_alr_weekly_installment(gint start_week)
{
gfloat debt_start;
gfloat interest_factor;
gfloat installment;
gint weekly_installment;
debt_start = current_user.debt * powf(1 + current_user.debt_interest, (gfloat)(start_week - week));
interest_factor = 1 /
powf(1 + current_user.debt_interest, (gfloat)(const_int("int_finance_payback_weeks") - start_week + week + 1)) /
current_user.debt_interest;
installment = -debt_start / (1 / current_user.debt_interest - interest_factor + 1);
weekly_installment = (gint)rint(installment);
printf("start %.2f intfac %.2f inst %.2f winst %d\n", debt_start, interest_factor, installment, weekly_installment);
return (weekly_installment > installment) ? weekly_installment : weekly_installment + 1;
}
/** Calculate the start week for an automatic loan repayment
depending on the weekly installment. */
gint
finance_calculate_alr_start_week(gint weekly_installment)
{
gint upper;
gint start_week;
gint installment;
upper = MIN(week + current_user.counters[COUNT_USER_LOAN] - 1, fixture_get_last_scheduled_week());
for(start_week = week + 1; start_week <= upper; start_week++)
{
installment = finance_calculate_alr_weekly_installment(start_week);
if(installment > weekly_installment)
return start_week - 1;
}
return start_week - 1;
}

View File

@ -59,4 +59,10 @@ finance_assign_game_money(const Fixture *fix);
void
finance_update_current_interest(void);
gint
finance_calculate_alr_weekly_installment(gint start_week);
gint
finance_calculate_alr_start_week(gint weekly_installment);
#endif

View File

@ -1406,3 +1406,16 @@ fixture_count_matchdays(const GArray *fixtures)
return count + (fixtures->len != 0);
}
/** Return the last week there are fixtures written for. */
gint
fixture_get_last_scheduled_week(void)
{
gint i;
gint week_nr = 0;
for(i=0;i<acps->len;i++)
week_nr = MAX(week_nr, g_array_index(acp(i)->fixtures, Fixture, acp(i)->fixtures->len - 1).week_number);
return week_nr;
}

View File

@ -159,5 +159,7 @@ fixture_get_goals_to_win(const Fixture *fix, const Team *tm);
gint
fixture_count_matchdays(const GArray *fixtures);
gint
fixture_get_last_scheduled_week(void);
#endif

View File

@ -24,7 +24,9 @@
*/
#include "bet.h"
#include "finance.h"
#include "fixture.h"
#include "gui.h"
#include "main.h"
#include "misc_callback_func.h"
#include "misc3_callbacks.h"
@ -229,20 +231,19 @@ on_button_splash_hint_next_clicked (GtkButton *button,
}
void
on_spinbutton_start_week_changed (GtkEditable *editable,
gpointer user_data)
{
gui_label_set_text_from_int(GTK_LABEL(lookup_widget(window.alr, "label_start_week")),
week + 1, FALSE);
}
void
on_button_calculate_start_week_clicked (GtkButton *button,
gpointer user_data)
{
gint start_week;
start_week = finance_calculate_alr_start_week(
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(window.alr, "spinbutton_weekly_installment"))));
printf("startweek %d\n", start_week);
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(lookup_widget(window.alr, "spinbutton_start_week")), (gfloat)start_week);
}
@ -251,7 +252,15 @@ on_button_calculate_installment_clicked
(GtkButton *button,
gpointer user_data)
{
gint weekly_installment;
weekly_installment = finance_calculate_alr_weekly_installment(
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(window.alr, "spinbutton_start_week"))));
printf("inst %d\n", weekly_installment);
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(lookup_widget(window.alr, "spinbutton_weekly_installment")), (gfloat)weekly_installment);
}
@ -279,3 +288,4 @@ on_window_alr_delete_event (GtkWidget *widget,
return TRUE;
}

View File

@ -59,8 +59,6 @@ on_checkbutton_bet_user_recent_button_press_event
(GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
#endif
gboolean
on_window_splash_delete_event (GtkWidget *widget,
GdkEvent *event,
@ -90,18 +88,13 @@ void
on_button_splash_hint_next_clicked (GtkButton *button,
gpointer user_data);
void
on_spinbutton_start_week_changed (GtkEditable *editable,
gpointer user_data);
void
on_button_calculate_start_week_clicked (GtkButton *button,
gpointer user_data);
void
on_button_calculate_installment_clicked
(GtkButton *button,
gpointer user_data);
void
on_button_calculate_start_week_clicked (GtkButton *button,
gpointer user_data);
void
on_button_alr_confirm_clicked (GtkButton *button,
@ -114,3 +107,6 @@ gboolean
on_window_alr_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
#endif

View File

@ -513,23 +513,20 @@ create_window_alr (void)
GtkWidget *table1;
GtkWidget *label17;
GtkWidget *label18;
GtkObject *spinbutton_start_week_adj;
GtkWidget *spinbutton_start_week;
GtkObject *spinbutton_weekly_installment_adj;
GtkWidget *spinbutton_weekly_installment;
GtkWidget *button_calculate_start_week;
GtkWidget *alignment7;
GtkWidget *hbox16;
GtkWidget *image9;
GtkWidget *label21;
GtkWidget *button_calculate_installment;
GtkWidget *alignment6;
GtkWidget *hbox15;
GtkWidget *image8;
GtkWidget *label20;
GtkWidget *hbox17;
GtkWidget *label26;
GtkWidget *label_start_week;
GtkWidget *button_calculate_start_week;
GtkWidget *alignment7;
GtkWidget *hbox16;
GtkWidget *image9;
GtkWidget *label21;
GtkObject *spinbutton_start_week_adj;
GtkWidget *spinbutton_start_week;
GtkObject *spinbutton_weekly_installment_adj;
GtkWidget *spinbutton_weekly_installment;
GtkWidget *hseparator6;
GtkWidget *hbox11;
GtkWidget *button_alr_confirm;
@ -596,7 +593,7 @@ create_window_alr (void)
gtk_box_pack_start (GTK_BOX (vbox5), label25, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label25), 0, 0.5);
table1 = gtk_table_new (2, 4, FALSE);
table1 = gtk_table_new (2, 3, FALSE);
gtk_widget_show (table1);
gtk_box_pack_start (GTK_BOX (vbox5), table1, FALSE, FALSE, 0);
gtk_table_set_row_spacings (GTK_TABLE (table1), 2);
@ -618,45 +615,9 @@ create_window_alr (void)
gtk_misc_set_alignment (GTK_MISC (label18), 1, 0.5);
gtk_misc_set_padding (GTK_MISC (label18), 3, 0);
spinbutton_start_week_adj = gtk_adjustment_new (0, 0, 0, 1, 10, 0);
spinbutton_start_week = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_start_week_adj), 1, 0);
gtk_widget_show (spinbutton_start_week);
gtk_table_attach (GTK_TABLE (table1), spinbutton_start_week, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
spinbutton_weekly_installment_adj = gtk_adjustment_new (1, 0, 0, 1, 10, 0);
spinbutton_weekly_installment = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_weekly_installment_adj), 1, 0);
gtk_widget_show (spinbutton_weekly_installment);
gtk_table_attach (GTK_TABLE (table1), spinbutton_weekly_installment, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
button_calculate_start_week = gtk_button_new ();
gtk_widget_show (button_calculate_start_week);
gtk_table_attach (GTK_TABLE (table1), button_calculate_start_week, 3, 4, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
alignment7 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment7);
gtk_container_add (GTK_CONTAINER (button_calculate_start_week), alignment7);
hbox16 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox16);
gtk_container_add (GTK_CONTAINER (alignment7), hbox16);
image9 = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image9);
gtk_box_pack_start (GTK_BOX (hbox16), image9, FALSE, FALSE, 0);
label21 = gtk_label_new_with_mnemonic (_("Calculate start week"));
gtk_widget_show (label21);
gtk_box_pack_start (GTK_BOX (hbox16), label21, FALSE, FALSE, 0);
button_calculate_installment = gtk_button_new ();
gtk_widget_show (button_calculate_installment);
gtk_table_attach (GTK_TABLE (table1), button_calculate_installment, 3, 4, 0, 1,
gtk_table_attach (GTK_TABLE (table1), button_calculate_installment, 2, 3, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
@ -676,21 +637,41 @@ create_window_alr (void)
gtk_widget_show (label20);
gtk_box_pack_start (GTK_BOX (hbox15), label20, FALSE, FALSE, 0);
hbox17 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox17);
gtk_table_attach (GTK_TABLE (table1), hbox17, 2, 3, 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (GTK_FILL), 0, 0);
button_calculate_start_week = gtk_button_new ();
gtk_widget_show (button_calculate_start_week);
gtk_table_attach (GTK_TABLE (table1), button_calculate_start_week, 2, 3, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
label26 = gtk_label_new (_("Week"));
gtk_widget_show (label26);
gtk_box_pack_start (GTK_BOX (hbox17), label26, FALSE, FALSE, 0);
alignment7 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment7);
gtk_container_add (GTK_CONTAINER (button_calculate_start_week), alignment7);
label_start_week = gtk_label_new (_("label14"));
gtk_widget_show (label_start_week);
gtk_box_pack_start (GTK_BOX (hbox17), label_start_week, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label_start_week), 0, 0.5);
gtk_misc_set_padding (GTK_MISC (label_start_week), 3, 0);
hbox16 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox16);
gtk_container_add (GTK_CONTAINER (alignment7), hbox16);
image9 = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image9);
gtk_box_pack_start (GTK_BOX (hbox16), image9, FALSE, FALSE, 0);
label21 = gtk_label_new_with_mnemonic (_("Calculate start week"));
gtk_widget_show (label21);
gtk_box_pack_start (GTK_BOX (hbox16), label21, FALSE, FALSE, 0);
spinbutton_start_week_adj = gtk_adjustment_new (0, 0, 0, 1, 10, 0);
spinbutton_start_week = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_start_week_adj), 1, 0);
gtk_widget_show (spinbutton_start_week);
gtk_table_attach (GTK_TABLE (table1), spinbutton_start_week, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_EXPAND),
(GtkAttachOptions) (0), 0, 0);
spinbutton_weekly_installment_adj = gtk_adjustment_new (1, 0, 0, 1, 10, 0);
spinbutton_weekly_installment = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_weekly_installment_adj), 1, 0);
gtk_widget_show (spinbutton_weekly_installment);
gtk_table_attach (GTK_TABLE (table1), spinbutton_weekly_installment, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_EXPAND),
(GtkAttachOptions) (0), 0, 0);
hseparator6 = gtk_hseparator_new ();
gtk_widget_show (hseparator6);
@ -715,15 +696,12 @@ create_window_alr (void)
g_signal_connect ((gpointer) window_alr, "delete_event",
G_CALLBACK (on_window_alr_delete_event),
NULL);
g_signal_connect ((gpointer) spinbutton_start_week, "changed",
G_CALLBACK (on_spinbutton_start_week_changed),
g_signal_connect ((gpointer) button_calculate_installment, "clicked",
G_CALLBACK (on_button_calculate_installment_clicked),
NULL);
g_signal_connect ((gpointer) button_calculate_start_week, "clicked",
G_CALLBACK (on_button_calculate_start_week_clicked),
NULL);
g_signal_connect ((gpointer) button_calculate_installment, "clicked",
G_CALLBACK (on_button_calculate_installment_clicked),
NULL);
g_signal_connect ((gpointer) button_alr_confirm, "clicked",
G_CALLBACK (on_button_alr_confirm_clicked),
NULL);
@ -745,21 +723,18 @@ create_window_alr (void)
GLADE_HOOKUP_OBJECT (window_alr, table1, "table1");
GLADE_HOOKUP_OBJECT (window_alr, label17, "label17");
GLADE_HOOKUP_OBJECT (window_alr, label18, "label18");
GLADE_HOOKUP_OBJECT (window_alr, spinbutton_start_week, "spinbutton_start_week");
GLADE_HOOKUP_OBJECT (window_alr, spinbutton_weekly_installment, "spinbutton_weekly_installment");
GLADE_HOOKUP_OBJECT (window_alr, button_calculate_start_week, "button_calculate_start_week");
GLADE_HOOKUP_OBJECT (window_alr, alignment7, "alignment7");
GLADE_HOOKUP_OBJECT (window_alr, hbox16, "hbox16");
GLADE_HOOKUP_OBJECT (window_alr, image9, "image9");
GLADE_HOOKUP_OBJECT (window_alr, label21, "label21");
GLADE_HOOKUP_OBJECT (window_alr, button_calculate_installment, "button_calculate_installment");
GLADE_HOOKUP_OBJECT (window_alr, alignment6, "alignment6");
GLADE_HOOKUP_OBJECT (window_alr, hbox15, "hbox15");
GLADE_HOOKUP_OBJECT (window_alr, image8, "image8");
GLADE_HOOKUP_OBJECT (window_alr, label20, "label20");
GLADE_HOOKUP_OBJECT (window_alr, hbox17, "hbox17");
GLADE_HOOKUP_OBJECT (window_alr, label26, "label26");
GLADE_HOOKUP_OBJECT (window_alr, label_start_week, "label_start_week");
GLADE_HOOKUP_OBJECT (window_alr, button_calculate_start_week, "button_calculate_start_week");
GLADE_HOOKUP_OBJECT (window_alr, alignment7, "alignment7");
GLADE_HOOKUP_OBJECT (window_alr, hbox16, "hbox16");
GLADE_HOOKUP_OBJECT (window_alr, image9, "image9");
GLADE_HOOKUP_OBJECT (window_alr, label21, "label21");
GLADE_HOOKUP_OBJECT (window_alr, spinbutton_start_week, "spinbutton_start_week");
GLADE_HOOKUP_OBJECT (window_alr, spinbutton_weekly_installment, "spinbutton_weekly_installment");
GLADE_HOOKUP_OBJECT (window_alr, hseparator6, "hseparator6");
GLADE_HOOKUP_OBJECT (window_alr, hbox11, "hbox11");
GLADE_HOOKUP_OBJECT (window_alr, button_alr_confirm, "button_alr_confirm");

View File

@ -61,8 +61,6 @@ on_button_options_ok_clicked (GtkButton *button,
else
sprintf(buf, "%s%sbygfoot_%s.conf", conf_dir, G_DIR_SEPARATOR_S, current_user.name);
printf("%s\n", buf);
file_save_opt_file(buf, &current_user.options);
}

View File

@ -27,13 +27,13 @@
#include "debug.h"
#include "file.h"
#include "finance.h"
#include "fixture.h"
#include "free.h"
#include "game_gui.h"
#include "gui.h"
#include "interface.h"
#include "language.h"
#include "league.h"
#include "league_table_interface.h"
#include "live_game.h"
#include "load_save.h"
#include "main.h"
@ -886,14 +886,6 @@ window_create(gint window_type)
wind = window.training_camp;
strcpy(buf, _("Training camp"));
break;
case WINDOW_LEAGUE_TABLE:
if(window.league_table != NULL)
g_warning("window_create: called on already existing window\n");
else
window.league_table = create_window_training_camp();
wind = window.league_table;
strcpy(buf, _("League table"));
break;
case WINDOW_ALR:
if(window.alr != NULL)
g_warning("window_create: called on already existing window\n");
@ -1019,80 +1011,6 @@ window_show_training_camp(void)
gtk_widget_modify_bg(GTK_WIDGET(hs_camp_points), GTK_STATE_NORMAL, &color);
}
/* Show the league table window for the current user. */
void
window_show_league_table(void)
{
/*
GtkEntry *tfCosts;
GtkWidget *rb_camp1;
GtkWidget *rb_camp2;
GtkWidget *rb_camp3;
GtkLabel *l_costs;
GtkLabel *l_recreation;
GtkLabel *l_training;
GtkLabel *l_camp_points;
GtkHScale *hs_recreation;
GtkHScale *hs_training;
GtkHScale *hs_camp_points;
gchar buf[SMALL];
*/
window_create(WINDOW_LEAGUE_TABLE);
/*
// Initialize entry costs
sprintf(buf, "%d", COSTS_CAMP_1);
tfCosts = GTK_ENTRY(lookup_widget(window.training_camp, "tf_costs"));
gtk_entry_set_text (tfCosts, buf);
// Initialize radio group camp
rb_camp1 = GTK_WIDGET(lookup_widget(window.training_camp, "rb_camp1"));
rb_camp2 = GTK_WIDGET(lookup_widget(window.training_camp, "rb_camp2"));
rb_camp3 = GTK_WIDGET(lookup_widget(window.training_camp, "rb_camp3"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb_camp1), TRUE);
//Initialize labels
l_costs = GTK_LABEL(lookup_widget(window.training_camp, "l_costs"));
l_recreation = GTK_LABEL(lookup_widget(window.training_camp, "l_recreation"));
l_training = GTK_LABEL(lookup_widget(window.training_camp, "l_training"));
l_camp_points = GTK_LABEL(lookup_widget(window.training_camp, "l_camp_points"));
gtk_misc_set_alignment (GTK_MISC(l_costs), 0.0, 0.5);
gtk_misc_set_alignment (GTK_MISC(l_recreation), 0.0, 0.5);
gtk_misc_set_alignment (GTK_MISC(l_training), 0.0, 0.5);
gtk_misc_set_alignment (GTK_MISC(l_camp_points), 0.0, 0.5);
//Initialize hScales
hs_recreation = GTK_HSCALE(lookup_widget(window.training_camp, "hs_recreation"));
hs_training = GTK_HSCALE(lookup_widget(window.training_camp, "hs_training"));
hs_camp_points = GTK_HSCALE(lookup_widget(window.training_camp, "hs_camp_points"));
gtk_range_set_range (GTK_RANGE(hs_recreation), CAMP_SCALE_MIN, CAMP_SCALE_MAX);
gtk_range_set_range (GTK_RANGE(hs_training), CAMP_SCALE_MIN, CAMP_SCALE_MAX);
gtk_range_set_range (GTK_RANGE(hs_camp_points), CAMP_SCALE_MIN, CAMP_SCALE_MAX);
gtk_range_set_value (GTK_RANGE(hs_recreation), CAMP_SCALE_MIN);
gtk_range_set_value (GTK_RANGE(hs_training), CAMP_SCALE_MIN);
gtk_range_set_value (GTK_RANGE(hs_camp_points), CAMP_SCALE_MAX);
gtk_scale_set_digits (GTK_SCALE(hs_recreation), 0);
gtk_scale_set_digits (GTK_SCALE(hs_training), 0);
gtk_scale_set_digits (GTK_SCALE(hs_camp_points), 0);
gtk_widget_set_sensitive (GTK_WIDGET(hs_recreation), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET(hs_training), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET(hs_camp_points), FALSE);
GdkColor color;
//gtk_widget_modify_fg(GTK_WIDGET(hs_recreation), GTK_STATE_INSENSITIVE , NULL);
//gtk_widget_modify_fg(GTK_WIDGET(hs_training), GTK_STATE_INSENSITIVE , NULL);
//gtk_widget_modify_fg(GTK_WIDGET(hs_camp_points), GTK_STATE_INSENSITIVE , NULL);
//gtk_widget_modify_bg(GTK_WIDGET(hs_recreation), GTK_STATE_NORMAL, NULL);
gdk_color_parse("black", &color);
gtk_widget_modify_fg(GTK_WIDGET(hs_recreation), GTK_STATE_INSENSITIVE , &color);
gtk_widget_modify_fg(GTK_WIDGET(hs_training), GTK_STATE_INSENSITIVE , &color);
gtk_widget_modify_fg(GTK_WIDGET(hs_camp_points), GTK_STATE_INSENSITIVE , &color);
gtk_widget_modify_bg(GTK_WIDGET(hs_recreation), GTK_STATE_NORMAL, &color);
gtk_widget_modify_bg(GTK_WIDGET(hs_training), GTK_STATE_NORMAL, &color);
gtk_widget_modify_bg(GTK_WIDGET(hs_camp_points), GTK_STATE_NORMAL, &color);
*/
}
/** Create and set up the debt repayment window. */
void
window_show_alr(void)
@ -1104,10 +1022,7 @@ window_show_alr(void)
gui_label_set_text_from_int(GTK_LABEL(lookup_widget(window.alr, "label_current_weekly_installment")),
current_user.alr_weekly_installment, FALSE);
gtk_spin_button_set_range(GTK_SPIN_BUTTON(lookup_widget(window.alr, "spinbutton_start_week")),
1, current_user.counters[COUNT_USER_LOAN]);
week + 1, MIN(week + current_user.counters[COUNT_USER_LOAN] - 1, fixture_get_last_scheduled_week()));
gtk_spin_button_set_range(GTK_SPIN_BUTTON(lookup_widget(window.alr, "spinbutton_weekly_installment")),
0, -current_user.debt);
gui_label_set_text_from_int(GTK_LABEL(lookup_widget(window.alr, "label_start_week")),
week + 1, FALSE);
0, -current_user.debt * powf(1 + current_user.debt_interest, const_int("int_finance_payback_weeks")));
}

View File

@ -55,7 +55,6 @@ enum Windows
WINDOW_SPLASH,
WINDOW_END,
WINDOW_TRAINING_CAMP,
WINDOW_LEAGUE_TABLE,
WINDOW_ALR
};
@ -129,9 +128,6 @@ window_splash_show_hint(void);
void
window_show_training_camp(void);
void
window_show_league_table(void);
void
window_show_alr(void);

View File

@ -1,38 +1,21 @@
# Bygfoot Football Manager
# Global configuration file
# Most of these options are uncommented because their meaning
# is rather clear if you take a look at the options window in the game.
int_opt_confirm_quit 1
int_opt_confirm_quit 0
int_opt_confirm_unfit 1
int_opt_save_will_overwrite 1
int_opt_save_will_overwrite 0
int_opt_maximize_main_window 1
int_opt_prefer_messages 0
int_opt_progressbar_pics 1
int_opt_skip 1
int_opt_autosave 1
int_opt_autosave_interval 5
int_opt_autosave_files 5
# precision of skill and talent in player lists
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
# some default files
string_opt_player_names_file general
string_opt_constants_file bygfoot_constants
string_opt_appearance_file bygfoot_app
string_opt_default_user_conf_file bygfoot_user.conf
# font name; if empty, the default system font's used
string_opt_font_name
# language used (a code like de_DE)
string_opt_language_code
string_opt_player_names_file general
string_opt_constants_file bygfoot_constants
string_opt_appearance_file bygfoot_app
string_opt_default_user_conf_file bygfoot_user.conf
string_opt_font_name
string_opt_language_code
int_opt_calodds 0
int_opt_load_defs 1
int_opt_randomise_teams 0