Index: src/gui.h =================================================================== --- src/gui.h (revision 14156) +++ src/gui.h (working copy) @@ -76,5 +76,7 @@ void ShowBuildTownWindow(); void ShowMusicWindow(); +/* player_gui.cpp */ +bool UIAdjustLoan(bool increase); #endif /* GUI_H */ Index: src/player_gui.cpp =================================================================== --- src/player_gui.cpp (revision 14156) +++ src/player_gui.cpp (working copy) @@ -116,6 +116,16 @@ DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING); } +// Adjust the loan as when the user clicks the button in the finances dialog (ie. including ctrl handling). +bool UIAdjustLoan(bool increase) +{ + if (increase) { + return DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY)); + } + + return DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN)); +} + enum PlayerFinancesWindowWidgets { PFW_WIDGET_TOGGLE_SIZE = 2, PFW_WIDGET_INCREASE_LOAN = 6, @@ -198,6 +208,15 @@ DrawPlayerEconomyStats(p, this->small); } + virtual void OnMouseWheel(int wheel) + { + switch (GetWidgetFromPos(this, _cursor.pos.x - left, _cursor.pos.y - top)) { + case PFW_WIDGET_INCREASE_LOAN: + case PFW_WIDGET_REPAY_LOAN: + UIAdjustLoan(wheel < 0); + } + } + virtual void OnClick(Point pt, int widget) { switch (widget) { @@ -215,11 +234,11 @@ break; case PFW_WIDGET_INCREASE_LOAN: /* increase loan */ - DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY)); + UIAdjustLoan(true); break; case PFW_WIDGET_REPAY_LOAN: /* repay loan */ - DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN)); + UIAdjustLoan(false); break; } } Index: src/statusbar_gui.cpp =================================================================== --- src/statusbar_gui.cpp (revision 14156) +++ src/statusbar_gui.cpp (working copy) @@ -19,6 +19,8 @@ #include "variables.h" #include "window_func.h" #include "statusbar_gui.h" +#include "command_func.h" +#include "gui.h" #include "table/strings.h" #include "table/sprites.h" @@ -63,6 +65,10 @@ return x > 0; } +enum MainStatusWidgets { + MSW_MONEY = 2 +}; + struct StatusBarWindow : Window { bool saving; int ticker_scroll; @@ -138,6 +144,13 @@ } } + virtual void OnMouseWheel(int wheel) + { + if (GetWidgetFromPos(this, _cursor.pos.x - left, _cursor.pos.y - top) == MSW_MONEY) { + UIAdjustLoan (wheel < 0); + } + } + virtual void OnTick() { if (_pause_game) return;