Automatic loan repayment.

This commit is contained in:
gyboth 2008-11-09 09:36:55 +00:00
parent bbe46fb8ad
commit d9990117f4
5 changed files with 203 additions and 91 deletions

View File

@ -1012,6 +1012,81 @@
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="spacing">7</property> <property name="spacing">7</property>
<child>
<widget class="GtkHBox" id="hbox17">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">3</property>
<child>
<widget class="GtkLabel" id="label26">
<property name="visible">True</property>
<property name="label" translatable="yes">Your debt:</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>
<child>
<widget class="GtkLabel" id="label_alr_debt">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<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>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator7">
<property name="height_request">10</property>
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child> <child>
<widget class="GtkLabel" id="label22"> <widget class="GtkLabel" id="label22">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -153,7 +153,7 @@ finance_update_user_weekly(User *user)
if(user->counters[COUNT_USER_LOAN] > -1) if(user->counters[COUNT_USER_LOAN] > -1)
user->counters[COUNT_USER_LOAN]--; user->counters[COUNT_USER_LOAN]--;
if(user->counters[COUNT_USER_LOAN] == 0 && debug < 50 && user->alr_start_week == 0) if(user->counters[COUNT_USER_LOAN] == 0 && debug < 50)
user_event_add(user, EVENT_TYPE_WARNING, -1, -1, NULL, user_event_add(user, EVENT_TYPE_WARNING, -1, -1, NULL,
_("You have to pay back your loan this week.")); _("You have to pay back your loan this week."));

View File

@ -1,26 +1,26 @@
/* /*
misc2_callbacks.c misc2_callbacks.c
Bygfoot Football Manager -- a small and simple GTK2-based Bygfoot Football Manager -- a small and simple GTK2-based
football management game. football management game.
http://bygfoot.sourceforge.net http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include "bet.h" #include "bet.h"
@ -135,32 +135,34 @@ on_button_digits_ok_clicked (GtkButton *button,
switch(stat1) switch(stat1)
{ {
case STATUS_GET_LOAN: case STATUS_GET_LOAN:
finance_get_loan(values[0]); finance_get_loan(values[0]);
on_menu_show_finances_activate(NULL, NULL); on_menu_show_finances_activate(NULL, NULL);
break; break;
case STATUS_PAY_LOAN: case STATUS_PAY_LOAN:
finance_pay_loan(&current_user, values[0]); finance_pay_loan(&current_user, values[0]);
on_menu_show_finances_activate(NULL, NULL); on_menu_show_finances_activate(NULL, NULL);
break; if(current_user.debt != 0 && current_user.alr_start_week != 0)
case STATUS_SHOW_TRANSFER_LIST: window_show_yesno(_("Adjust repayment schedule?"));
if(transfer_add_offer(stat2, current_user.tm, values[0], values[1])) break;
game_gui_print_message(_("Your offer has been updated.")); case STATUS_SHOW_TRANSFER_LIST:
else if(transfer_add_offer(stat2, current_user.tm, values[0], values[1]))
game_gui_print_message(_("Your offer will be considered next week.")); game_gui_print_message(_("Your offer has been updated."));
break; else
case STATUS_CUSTOM_STRUCTURE: game_gui_print_message(_("Your offer will be considered next week."));
destroy_window = misc2_callback_change_structure(values[1]); break;
if(destroy_window && stat0 == STATUS_LIVE_GAME_PAUSE) case STATUS_CUSTOM_STRUCTURE:
gtk_widget_set_sensitive(window.main, TRUE); destroy_window = misc2_callback_change_structure(values[1]);
break; if(destroy_window && stat0 == STATUS_LIVE_GAME_PAUSE)
case STATUS_SET_YA_PERCENTAGE: gtk_widget_set_sensitive(window.main, TRUE);
current_user.youth_academy.percentage = values[1]; break;
break; case STATUS_SET_YA_PERCENTAGE:
case STATUS_PLACE_BET: current_user.youth_academy.percentage = values[1];
if(!bet_place(stat2, stat3, values[0])) break;
destroy_window = FALSE; case STATUS_PLACE_BET:
break; if(!bet_place(stat2, stat3, values[0]))
destroy_window = FALSE;
break;
} }
if(destroy_window) if(destroy_window)
@ -209,43 +211,46 @@ on_button_yesno_yes_clicked (GtkButton *button,
switch(stat1) switch(stat1)
{ {
default: default:
g_warning("on_button_yesno_yes_clicked: unknown status %d\n", stat1); g_warning("on_button_yesno_yes_clicked: unknown status %d\n", stat1);
break; break;
case STATUS_FIRE_PLAYER: case STATUS_PAY_LOAN:
player_remove_from_team(current_user.tm, stat2); on_automatic_loan_repayment_activate(NULL, NULL);
current_user.money -= stat3; break;
current_user.money_out[1][MON_OUT_COMPENSATIONS] -= stat3; case STATUS_FIRE_PLAYER:
treeview_show_user_player_list(); player_remove_from_team(current_user.tm, stat2);
game_gui_set_main_window_header(); current_user.money -= stat3;
break; current_user.money_out[1][MON_OUT_COMPENSATIONS] -= stat3;
case STATUS_USER_MANAGEMENT: treeview_show_user_player_list();
user_remove(stat2, TRUE); game_gui_set_main_window_header();
treeview_show_users( break;
GTK_TREE_VIEW(lookup_widget(window.user_management, case STATUS_USER_MANAGEMENT:
"treeview_user_management_users"))); user_remove(stat2, TRUE);
treeview_show_team_list( treeview_show_users(
GTK_TREE_VIEW(lookup_widget(window.user_management, GTK_TREE_VIEW(lookup_widget(window.user_management,
"treeview_user_management_teams")), "treeview_user_management_users")));
FALSE, FALSE); treeview_show_team_list(
break; GTK_TREE_VIEW(lookup_widget(window.user_management,
case STATUS_QUERY_UNFIT: "treeview_user_management_teams")),
load_save_autosave(); FALSE, FALSE);
callback_show_next_live_game(); break;
break; case STATUS_QUERY_UNFIT:
case STATUS_QUERY_QUIT: load_save_autosave();
main_exit_program(EXIT_OK, NULL); callback_show_next_live_game();
break; break;
case STATUS_QUERY_USER_NO_TURN: case STATUS_QUERY_QUIT:
load_save_autosave(); main_exit_program(EXIT_OK, NULL);
callback_show_next_live_game(); break;
break; case STATUS_QUERY_USER_NO_TURN:
case STATUS_QUERY_KICK_YOUTH: load_save_autosave();
free_player(&g_array_index(current_user.youth_academy.players, Player, selected_row)); callback_show_next_live_game();
g_array_remove_index(current_user.youth_academy.players, selected_row); break;
on_menu_show_youth_academy_activate(NULL, NULL); case STATUS_QUERY_KICK_YOUTH:
selected_row = -1; free_player(&g_array_index(current_user.youth_academy.players, Player, selected_row));
break; g_array_remove_index(current_user.youth_academy.players, selected_row);
on_menu_show_youth_academy_activate(NULL, NULL);
selected_row = -1;
break;
} }
if(stat4 == STATUS_SHOW_EVENT) if(stat4 == STATUS_SHOW_EVENT)
@ -310,8 +315,8 @@ on_button_user_management_add_clicked (GtkButton *button,
void void
on_button_user_management_close_clicked on_button_user_management_close_clicked
(GtkButton *button, (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
window_destroy(&window.user_management); window_destroy(&window.user_management);
on_button_back_to_main_clicked(NULL, NULL); on_button_back_to_main_clicked(NULL, NULL);
@ -320,9 +325,9 @@ on_button_user_management_close_clicked
gboolean gboolean
on_treeview_user_management_users_button_press_event on_treeview_user_management_users_button_press_event
(GtkWidget *widget, (GtkWidget *widget,
GdkEventButton *event, GdkEventButton *event,
gpointer user_data) gpointer user_data)
{ {
gchar buf[SMALL]; gchar buf[SMALL];
gint idx = -1; gint idx = -1;
@ -347,10 +352,10 @@ on_treeview_user_management_users_button_press_event
void void
on_treeview_user_management_teams_row_activated on_treeview_user_management_teams_row_activated
(GtkTreeView *treeview, (GtkTreeView *treeview,
GtkTreePath *path, GtkTreePath *path,
GtkTreeViewColumn *column, GtkTreeViewColumn *column,
gpointer user_data) gpointer user_data)
{ {
on_button_user_management_add_clicked(NULL, NULL); on_button_user_management_add_clicked(NULL, NULL);
} }

View File

@ -502,6 +502,10 @@ create_window_alr (void)
{ {
GtkWidget *window_alr; GtkWidget *window_alr;
GtkWidget *vbox5; GtkWidget *vbox5;
GtkWidget *hbox17;
GtkWidget *label26;
GtkWidget *label_alr_debt;
GtkWidget *hseparator7;
GtkWidget *label22; GtkWidget *label22;
GtkWidget *table2; GtkWidget *table2;
GtkWidget *label23; GtkWidget *label23;
@ -544,6 +548,23 @@ create_window_alr (void)
gtk_container_add (GTK_CONTAINER (window_alr), vbox5); gtk_container_add (GTK_CONTAINER (window_alr), vbox5);
gtk_container_set_border_width (GTK_CONTAINER (vbox5), 5); gtk_container_set_border_width (GTK_CONTAINER (vbox5), 5);
hbox17 = gtk_hbox_new (FALSE, 3);
gtk_widget_show (hbox17);
gtk_box_pack_start (GTK_BOX (vbox5), hbox17, FALSE, FALSE, 0);
label26 = gtk_label_new (_("Your debt:"));
gtk_widget_show (label26);
gtk_box_pack_start (GTK_BOX (hbox17), label26, FALSE, FALSE, 0);
label_alr_debt = gtk_label_new ("");
gtk_widget_show (label_alr_debt);
gtk_box_pack_start (GTK_BOX (hbox17), label_alr_debt, FALSE, FALSE, 0);
hseparator7 = gtk_hseparator_new ();
gtk_widget_show (hseparator7);
gtk_box_pack_start (GTK_BOX (vbox5), hseparator7, FALSE, FALSE, 0);
gtk_widget_set_size_request (hseparator7, -1, 10);
label22 = gtk_label_new (_("Current settings:")); label22 = gtk_label_new (_("Current settings:"));
gtk_widget_show (label22); gtk_widget_show (label22);
gtk_box_pack_start (GTK_BOX (vbox5), label22, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox5), label22, FALSE, FALSE, 0);
@ -712,6 +733,10 @@ create_window_alr (void)
/* Store pointers to all widgets, for use by lookup_widget(). */ /* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (window_alr, window_alr, "window_alr"); GLADE_HOOKUP_OBJECT_NO_REF (window_alr, window_alr, "window_alr");
GLADE_HOOKUP_OBJECT (window_alr, vbox5, "vbox5"); GLADE_HOOKUP_OBJECT (window_alr, vbox5, "vbox5");
GLADE_HOOKUP_OBJECT (window_alr, hbox17, "hbox17");
GLADE_HOOKUP_OBJECT (window_alr, label26, "label26");
GLADE_HOOKUP_OBJECT (window_alr, label_alr_debt, "label_alr_debt");
GLADE_HOOKUP_OBJECT (window_alr, hseparator7, "hseparator7");
GLADE_HOOKUP_OBJECT (window_alr, label22, "label22"); GLADE_HOOKUP_OBJECT (window_alr, label22, "label22");
GLADE_HOOKUP_OBJECT (window_alr, table2, "table2"); GLADE_HOOKUP_OBJECT (window_alr, table2, "table2");
GLADE_HOOKUP_OBJECT (window_alr, label23, "label23"); GLADE_HOOKUP_OBJECT (window_alr, label23, "label23");

View File

@ -1018,12 +1018,19 @@ window_show_training_camp(void)
void void
window_show_alr(void) window_show_alr(void)
{ {
gchar weekly_installment[SMALL],
debt[SMALL];
window_create(WINDOW_ALR); window_create(WINDOW_ALR);
misc_print_grouped_int(current_user.alr_weekly_installment, weekly_installment);
misc_print_grouped_int(-current_user.debt, debt);
gui_label_set_text_from_int(GTK_LABEL(lookup_widget(window.alr, "label_current_start_week")), gui_label_set_text_from_int(GTK_LABEL(lookup_widget(window.alr, "label_current_start_week")),
current_user.alr_start_week, FALSE); current_user.alr_start_week, FALSE);
gui_label_set_text_from_int(GTK_LABEL(lookup_widget(window.alr, "label_current_weekly_installment")), gtk_label_set_text(GTK_LABEL(lookup_widget(window.alr, "label_current_weekly_installment")), weekly_installment);
current_user.alr_weekly_installment, FALSE); gtk_label_set_text(GTK_LABEL(lookup_widget(window.alr, "label_alr_debt")), debt);
gtk_spin_button_set_range(GTK_SPIN_BUTTON(lookup_widget(window.alr, "spinbutton_start_week")), gtk_spin_button_set_range(GTK_SPIN_BUTTON(lookup_widget(window.alr, "spinbutton_start_week")),
week + 1, MIN(week + current_user.counters[COUNT_USER_LOAN], fixture_get_last_scheduled_week())); week + 1, MIN(week + current_user.counters[COUNT_USER_LOAN], fixture_get_last_scheduled_week()));
gtk_spin_button_set_range(GTK_SPIN_BUTTON(lookup_widget(window.alr, "spinbutton_weekly_installment")), gtk_spin_button_set_range(GTK_SPIN_BUTTON(lookup_widget(window.alr, "spinbutton_weekly_installment")),