diff --git a/bygfoot_misc3.glade b/bygfoot_misc3.glade index 5f1fcfe6..b203034c 100644 --- a/bygfoot_misc3.glade +++ b/bygfoot_misc3.glade @@ -1206,7 +1206,7 @@ True 2 - 4 + 3 False 2 2 @@ -1267,131 +1267,6 @@ - - - True - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 0 0 0 1 10 0 - - - - 1 - 2 - 0 - 1 - - - - - - - True - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 1 0 0 1 10 0 - - - 1 - 2 - 1 - 2 - - - - - - - True - True - GTK_RELIEF_NORMAL - True - - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-execute - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Calculate start week - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - - - - 3 - 4 - 1 - 2 - fill - - - - True @@ -1465,8 +1340,8 @@ - 3 - 4 + 2 + 3 0 1 fill @@ -1475,67 +1350,128 @@ - + True - False - 0 + True + GTK_RELIEF_NORMAL + True + - + True - Week - False - False - GTK_JUSTIFY_LEFT - False - False 0.5 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - + 0 + 0 + 0 + 0 + 0 + 0 - - - True - label14 - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 3 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + + + True + False + 2 + + + + True + gtk-execute + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Calculate start week + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + - - 0 - False - False - 2 3 + 1 + 2 + fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 0 1 10 0 + + + 1 + 2 0 1 - fill + expand + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 0 1 10 0 + + + 1 + 2 + 1 + 2 + expand + diff --git a/src/Makefile.am b/src/Makefile.am index bd33f5b8..a4a6ee6d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/bygfoot.h b/src/bygfoot.h index 33c45ed5..550821cd 100644 --- a/src/bygfoot.h +++ b/src/bygfoot.h @@ -168,7 +168,6 @@ typedef struct *bets, *splash, *training_camp, - *league_table, *alr; /** The position of the horizontal divider is stored here. */ diff --git a/src/callbacks.c b/src/callbacks.c index 9e5ac4b8..ceb0c4a0 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -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(); } - diff --git a/src/finance.c b/src/finance.c index c506192f..a5a76c39 100644 --- a/src/finance.c +++ b/src/finance.c @@ -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; +} diff --git a/src/finance.h b/src/finance.h index 9b45761d..de967357 100644 --- a/src/finance.h +++ b/src/finance.h @@ -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 diff --git a/src/fixture.c b/src/fixture.c index b3121bdf..64deef8d 100644 --- a/src/fixture.c +++ b/src/fixture.c @@ -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;ilen;i++) + week_nr = MAX(week_nr, g_array_index(acp(i)->fixtures, Fixture, acp(i)->fixtures->len - 1).week_number); + + return week_nr; +} diff --git a/src/fixture.h b/src/fixture.h index f39672e8..e6e274cc 100644 --- a/src/fixture.h +++ b/src/fixture.h @@ -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 diff --git a/src/misc3_callbacks.c b/src/misc3_callbacks.c index 58c627c6..26054601 100644 --- a/src/misc3_callbacks.c +++ b/src/misc3_callbacks.c @@ -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; } + diff --git a/src/misc3_callbacks.h b/src/misc3_callbacks.h index ba2ba30a..a5e8cfa9 100644 --- a/src/misc3_callbacks.h +++ b/src/misc3_callbacks.h @@ -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 + diff --git a/src/misc3_interface.c b/src/misc3_interface.c index 8e9565c8..450b2a61 100644 --- a/src/misc3_interface.c +++ b/src/misc3_interface.c @@ -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"); diff --git a/src/options_callbacks.c b/src/options_callbacks.c index 3003a2af..0d782f02 100644 --- a/src/options_callbacks.c +++ b/src/options_callbacks.c @@ -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, ¤t_user.options); } diff --git a/src/window.c b/src/window.c index 958aafde..655e1afe 100644 --- a/src/window.c +++ b/src/window.c @@ -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"))); } diff --git a/src/window.h b/src/window.h index b6b5f738..a02fb7a8 100644 --- a/src/window.h +++ b/src/window.h @@ -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); diff --git a/support_files/bygfoot.conf b/support_files/bygfoot.conf index 592a085c..2b384ec4 100644 --- a/support_files/bygfoot.conf +++ b/support_files/bygfoot.conf @@ -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