mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r20901) -Fix/Change: When using non-smooth or newgrf-economy changing production rates does not work (anymore), so allow changing the production multiplier instead.
This commit is contained in:
parent
8a5571a264
commit
c49debbe63
|
@ -642,12 +642,14 @@ class IndustryViewWindow : public Window
|
|||
/** Modes for changing production */
|
||||
enum Editability {
|
||||
EA_NONE, ///< Not alterable
|
||||
EA_MULTIPLIER, ///< Allow changing the production multiplier
|
||||
EA_RATE, ///< Allow changing the production rates
|
||||
};
|
||||
|
||||
/** Specific lines in the info panel */
|
||||
enum InfoLine {
|
||||
IL_NONE, ///< No line
|
||||
IL_MULTIPLIER, ///< Production multiplier
|
||||
IL_RATE1, ///< Production rate of cargo 1
|
||||
IL_RATE2, ///< Production rate of cargo 2
|
||||
};
|
||||
|
@ -747,7 +749,7 @@ public:
|
|||
if (has_accept) y += WD_PAR_VSEP_WIDE;
|
||||
DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
this->production_offset_y = y;
|
||||
if (this->editable == EA_RATE) this->production_offset_y = y;
|
||||
first = false;
|
||||
}
|
||||
|
||||
|
@ -765,6 +767,18 @@ public:
|
|||
y += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
/* Display production multiplier if editable */
|
||||
if (this->editable == EA_MULTIPLIER) {
|
||||
y += WD_PAR_VSEP_WIDE;
|
||||
this->production_offset_y = y;
|
||||
SetDParam(0, RoundDivSU(i->prod_level * 100, PRODLEVEL_DEFAULT));
|
||||
uint x = left + WD_FRAMETEXT_LEFT + 30;
|
||||
DrawString(x, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_PRODUCTION_LEVEL);
|
||||
DrawArrowButtons(left + WD_FRAMETEXT_LEFT, y, COLOUR_YELLOW, (this->clicked_line == IL_MULTIPLIER) ? this->clicked_button : 0,
|
||||
i->prod_level > PRODLEVEL_MINIMUM, i->prod_level < PRODLEVEL_MAXIMUM);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
/* Get the extra message for the GUI */
|
||||
if (HasBit(ind->callback_mask, CBM_IND_WINDOW_MORE_TEXT)) {
|
||||
uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_WINDOW_MORE_TEXT, 0, 0, i, i->type, i->location.tile);
|
||||
|
@ -805,6 +819,10 @@ public:
|
|||
switch (this->editable) {
|
||||
case EA_NONE: break;
|
||||
|
||||
case EA_MULTIPLIER:
|
||||
if (IsInsideBS(pt.y, this->production_offset_y, FONT_HEIGHT_NORMAL)) line = IL_MULTIPLIER;
|
||||
break;
|
||||
|
||||
case EA_RATE:
|
||||
if (pt.y >= this->production_offset_y) {
|
||||
int row = (pt.y - this->production_offset_y) / FONT_HEIGHT_NORMAL;
|
||||
|
@ -824,10 +842,20 @@ public:
|
|||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(widget);
|
||||
int left = nwi->pos_x + WD_FRAMETEXT_LEFT;
|
||||
int right = nwi->pos_x + nwi->current_x - 1 - WD_FRAMERECT_RIGHT;
|
||||
if (IsInsideMM(pt.x, left, left + 20) ) {
|
||||
if (IsInsideMM(pt.x, left, left + 20)) {
|
||||
/* Clicked buttons, decrease or increase production */
|
||||
byte button = (pt.x < left + 10) ? 1 : 2;
|
||||
switch (this->editable) {
|
||||
case EA_MULTIPLIER:
|
||||
if (button == 1) {
|
||||
if (i->prod_level <= PRODLEVEL_MINIMUM) return;
|
||||
i->prod_level = max<uint>(i->prod_level / 2, PRODLEVEL_MINIMUM);
|
||||
} else {
|
||||
if (i->prod_level >= PRODLEVEL_MAXIMUM) return;
|
||||
i->prod_level = minu(i->prod_level * 2, PRODLEVEL_MAXIMUM);
|
||||
}
|
||||
break;
|
||||
|
||||
case EA_RATE:
|
||||
if (button == 1) {
|
||||
if (i->production_rate[line - IL_RATE1] <= 0) return;
|
||||
|
@ -852,6 +880,11 @@ public:
|
|||
/* clicked the text */
|
||||
this->editbox_line = line;
|
||||
switch (this->editable) {
|
||||
case EA_MULTIPLIER:
|
||||
SetDParam(0, RoundDivSU(i->prod_level * 100, PRODLEVEL_DEFAULT));
|
||||
ShowQueryString(STR_JUST_INT, STR_CONFIG_GAME_PRODUCTION_LEVEL, 10, 100, this, CS_ALPHANUMERAL, QSF_NONE);
|
||||
break;
|
||||
|
||||
case EA_RATE:
|
||||
SetDParam(0, i->production_rate[line - IL_RATE1] * 8);
|
||||
ShowQueryString(STR_JUST_INT, STR_CONFIG_GAME_PRODUCTION, 10, 100, this, CS_ALPHANUMERAL, QSF_NONE);
|
||||
|
@ -902,8 +935,17 @@ public:
|
|||
|
||||
Industry *i = Industry::Get(this->window_number);
|
||||
uint value = atoi(str);
|
||||
switch (this->editbox_line) {
|
||||
case IL_NONE: NOT_REACHED();
|
||||
|
||||
i->production_rate[this->editbox_line - IL_RATE1] = ClampU(RoundDivSU(value, 8), 0, 255);
|
||||
case IL_MULTIPLIER:
|
||||
i->prod_level = ClampU(RoundDivSU(value * PRODLEVEL_DEFAULT, 100), PRODLEVEL_MINIMUM, PRODLEVEL_MAXIMUM);
|
||||
break;
|
||||
|
||||
default:
|
||||
i->production_rate[this->editbox_line - IL_RATE1] = ClampU(RoundDivSU(value, 8), 0, 255);
|
||||
break;
|
||||
}
|
||||
UpdateIndustryProduction(i);
|
||||
this->SetDirty();
|
||||
}
|
||||
|
@ -912,7 +954,8 @@ public:
|
|||
{
|
||||
const Industry *i = Industry::Get(this->window_number);
|
||||
if (IsProductionAlterable(i)) {
|
||||
this->editable = EA_RATE;
|
||||
const IndustrySpec *ind = GetIndustrySpec(i->type);
|
||||
this->editable = ind->UsesSmoothEconomy() ? EA_RATE : EA_MULTIPLIER;
|
||||
} else {
|
||||
this->editable = EA_NONE;
|
||||
}
|
||||
|
@ -931,6 +974,9 @@ public:
|
|||
|
||||
static void UpdateIndustryProduction(Industry *i)
|
||||
{
|
||||
const IndustrySpec *indspec = GetIndustrySpec(i->type);
|
||||
if (!indspec->UsesSmoothEconomy()) i->RecomputeProductionMultipliers();
|
||||
|
||||
for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||
if (i->produced_cargo[j] != CT_INVALID) {
|
||||
i->last_month_production[j] = 8 * i->production_rate[j];
|
||||
|
|
|
@ -2724,6 +2724,7 @@ STR_INDUSTRY_VIEW_CAPTION :{WHITE}{INDUSTR
|
|||
STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE :{BLACK}Production last month:
|
||||
STR_INDUSTRY_VIEW_TRANSPORTED :{YELLOW}{CARGO}{RAW_STRING}{BLACK} ({COMMA}% transported)
|
||||
STR_INDUSTRY_VIEW_LOCATION_TOOLTIP :{BLACK}Centre the main view on industry location. Ctrl+Click opens a new viewport on industry location
|
||||
STR_INDUSTRY_VIEW_PRODUCTION_LEVEL :{BLACK}Production level: {YELLOW}{COMMA}%
|
||||
|
||||
############ range for requires starts
|
||||
STR_INDUSTRY_VIEW_REQUIRES_CARGO :{BLACK}Requires: {YELLOW}{STRING}{RAW_STRING}
|
||||
|
@ -2739,6 +2740,7 @@ STR_INDUSTRY_VIEW_PRODUCES_CARGO_CARGO :{BLACK}Produces
|
|||
############ range for produces ends
|
||||
|
||||
STR_CONFIG_GAME_PRODUCTION :{WHITE}Change production (multiple of 8, up to 2040)
|
||||
STR_CONFIG_GAME_PRODUCTION_LEVEL :{WHITE}Change production level (percentage, up to 800%)
|
||||
|
||||
# Vehicle lists
|
||||
STR_VEHICLE_LIST_TRAIN_CAPTION :{WHITE}{STRING2} - {COMMA} Train{P "" s}
|
||||
|
|
|
@ -896,6 +896,12 @@ static bool InvalidateCompanyLiveryWindow(int32 p1)
|
|||
return RedrawScreen(p1);
|
||||
}
|
||||
|
||||
static bool InvalidateIndustryViewWindow(int32 p1)
|
||||
{
|
||||
InvalidateWindowClassesData(WC_INDUSTRY_VIEW);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* A: competitors
|
||||
* B: competitor start time. Deprecated since savegame version 110.
|
||||
|
|
|
@ -40,6 +40,7 @@ static bool ChangeDynamicEngines(int32 p1);
|
|||
static bool StationCatchmentChanged(int32 p1);
|
||||
static bool InvalidateVehTimetableWindow(int32 p1);
|
||||
static bool InvalidateCompanyLiveryWindow(int32 p1);
|
||||
static bool InvalidateIndustryViewWindow(int32 p1);
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
static bool UpdateClientName(int32 p1);
|
||||
|
@ -443,7 +444,7 @@ const SettingDesc _settings[] = {
|
|||
SDT_CONDNULL( 4, 0, 143),
|
||||
SDT_VAR(GameSettings, game_creation.starting_year, SLE_INT32, 0,NC,DEF_START_YEAR,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_SETTING_STARTING_YEAR, NULL),
|
||||
SDT_CONDNULL( 4, 0, 104),
|
||||
SDT_BOOL(GameSettings, economy.smooth_economy, 0, 0, true, STR_CONFIG_SETTING_SMOOTH_ECONOMY, NULL),
|
||||
SDT_BOOL(GameSettings, economy.smooth_economy, 0, 0, true, STR_CONFIG_SETTING_SMOOTH_ECONOMY, InvalidateIndustryViewWindow),
|
||||
SDT_BOOL(GameSettings, economy.allow_shares, 0, 0, false, STR_CONFIG_SETTING_ALLOW_SHARES, NULL),
|
||||
SDT_CONDVAR(GameSettings, economy.feeder_payment_share, SLE_UINT8,134, SL_MAX_VERSION, 0, 0, 75, 0, 100, 0, STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE, NULL),
|
||||
SDT_CONDVAR(GameSettings, economy.town_growth_rate, SLE_UINT8, 54, SL_MAX_VERSION, 0, MS, 2, 0, 4, 0, STR_CONFIG_SETTING_TOWN_GROWTH, NULL),
|
||||
|
|
Loading…
Reference in New Issue