Index: src/lang/english.txt =================================================================== --- src/lang/english.txt (revision 22930) +++ src/lang/english.txt (working copy) @@ -2693,6 +2693,9 @@ STR_FINANCES_BORROW_TOOLTIP :{BLACK}Increase size of loan. Ctrl+Click borrows as much as possible STR_FINANCES_REPAY_BUTTON :{BLACK}Repay {CURRENCY} STR_FINANCES_REPAY_TOOLTIP :{BLACK}Repay part of loan. Ctrl+Click repays as much loan as possible +STR_FINANCES_SET_LOAN_BUTTON :{BLACK}Set loan amount +STR_FINANCES_SET_LOAN_TOOLTIP :{BLACK}Set size of loan +STR_FINANCES_SET_LOAN_QUERY_CAPTION :{WHITE}Loan amount (will round up) # Company view STR_COMPANY_VIEW_CAPTION :{WHITE}{COMPANY} {BLACK}{COMPANYNUM} Index: src/company_gui.cpp =================================================================== --- src/company_gui.cpp (revision 22930) +++ src/company_gui.cpp (working copy) @@ -137,6 +137,8 @@ CFW_MAXLOAN_VALUE, ///< Max loan widget CFW_SEL_BUTTONS, ///< Selection of buttons CFW_INCREASE_LOAN, ///< Increase loan + CFW_SEL_SET_LOAN_BUTTON, ///< Selection of set loan button + CFW_SET_LOAN, ///< Set loan amount CFW_REPAY_LOAN, ///< Decrease loan }; @@ -275,6 +277,9 @@ NWidget(NWID_SELECTION, INVALID_COLOUR, CFW_SEL_BUTTONS), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, CFW_INCREASE_LOAN), SetFill(1, 0), SetDataTip(STR_FINANCES_BORROW_BUTTON, STR_FINANCES_BORROW_TOOLTIP), + NWidget(NWID_SELECTION, INVALID_COLOUR, CFW_SEL_SET_LOAN_BUTTON), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, CFW_SET_LOAN), SetFill(1, 0), SetDataTip(STR_FINANCES_SET_LOAN_BUTTON, STR_FINANCES_SET_LOAN_TOOLTIP), + EndContainer(), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, CFW_REPAY_LOAN), SetFill(1, 0), SetDataTip(STR_FINANCES_REPAY_BUTTON, STR_FINANCES_REPAY_TOOLTIP), EndContainer(), EndContainer(), @@ -399,6 +404,7 @@ int plane = this->small ? SZSP_NONE : 0; this->GetWidget(CFW_SEL_PANEL)->SetDisplayedPlane(plane); this->GetWidget(CFW_SEL_MAXLOAN)->SetDisplayedPlane(plane); + this->GetWidget(CFW_SEL_SET_LOAN_BUTTON)->SetDisplayedPlane(plane); CompanyID company = (CompanyID)this->window_number; plane = (company != _local_company) ? SZSP_NONE : 0; @@ -430,6 +436,7 @@ const Company *c = Company::Get(company); bool can_increase_loan = c->current_loan < _economy.max_loan, can_repay_loan = c->current_loan > 0 && c->money >= LOAN_INTERVAL; this->SetWidgetDisabledState(CFW_INCREASE_LOAN, !can_increase_loan); // Borrow button only shows when there is any more money to loan. + this->SetWidgetDisabledState(CFW_SET_LOAN, !can_increase_loan && !can_repay_loan); // Set button only shows when loan can be adjusted. this->SetWidgetDisabledState(CFW_REPAY_LOAN, !can_repay_loan); // Repay button only shows when there is any more money to repay, and can be repaid. } @@ -464,9 +471,22 @@ DoCommandP(0, loan >> 32, loan, CMD_SET_LOAN | CMD_MSG(STR_ERROR_CAN_T_REPAY_LOAN)); break; } + + case CFW_SET_LOAN: // set loan + SetDParam(0, c->current_loan); + ShowQueryString(STR_JUST_INT, STR_FINANCES_SET_LOAN_QUERY_CAPTION, 24, this, CS_NUMERAL, QSF_NONE); + break; } } + virtual void OnQueryTextFinished(char *str) + { + if (str == NULL) return; + + Money loan = ((Money)atoll(str) + LOAN_INTERVAL - 1) / LOAN_INTERVAL * LOAN_INTERVAL; + DoCommandP(0, loan >> 32, loan, CMD_SET_LOAN | CMD_MSG(STR_ERROR_CAN_T_SET_LOAN)); + } + virtual void OnHundredthTick() { const Company *c = Company::Get((CompanyID)this->window_number);