diff options
author | truelight <truelight@openttd.org> | 2004-08-12 17:49:16 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2004-08-12 17:49:16 +0000 |
commit | 210ada1b514a173de5a2426f99cd25c95b23efaf (patch) | |
tree | acb434304df44af2e1d0721b08cad09b677cf847 /settings_gui.c | |
parent | 4b0d4dd3fe13e78e1766ac06ab891f9d39f1d0aa (diff) | |
download | openttd-210ada1b514a173de5a2426f99cd25c95b23efaf.tar.xz |
(svn r27) -Fix: [1006715] Autorenew issues
-Add: PE_CURRENCY to patchmenu
Diffstat (limited to 'settings_gui.c')
-rw-r--r-- | settings_gui.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/settings_gui.c b/settings_gui.c index 646b137d8..ebdc3f09f 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -659,8 +659,8 @@ typedef struct PatchEntry { byte flags; // selector flags StringID str; // string with descriptive text void *variable; // pointer to the variable - int16 min,max; // range for spinbox setting - uint16 step; // step for spinbox + int32 min,max; // range for spinbox setting + uint32 step; // step for spinbox } PatchEntry; enum { @@ -669,6 +669,7 @@ enum { PE_INT16 = 2, PE_UINT16 = 3, PE_INT32 = 4, + PE_CURRENCY = 5, PF_0ISDIS = 1, PF_NOCOMMA = 2, @@ -706,7 +707,9 @@ static const PatchEntry _patches_vehicles[] = { {PE_BOOL, 0, STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES, &_patches.never_expire_vehicles}, {PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_LOST_TRAIN_DAYS, &_patches.lost_train_days, 180, 720, 60}, - {PE_BOOL, 0, STR_CONFIG_AUTORENEW_VEHICLE, &_patches.autorenew}, + {PE_BOOL, 0, STR_CONFIG_PATCHES_AUTORENEW_VEHICLE, &_patches.autorenew}, + {PE_INT16, 0, STR_CONFIG_PATCHES_AUTORENEW_MONTHS, &_patches.autorenew_months, -12, 12, 1}, + {PE_CURRENCY, 0, STR_CONFIG_PATCHES_AUTORENEW_MONEY, &_patches.autorenew_money, 0, 2000000, 100000}, {PE_UINT8, 0, STR_CONFIG_PATCHES_MAX_TRAINS, &_patches.max_trains, 0, 240, 10}, {PE_UINT8, 0, STR_CONFIG_PATCHES_MAX_ROADVEH, &_patches.max_roadveh, 0, 240, 10}, @@ -764,6 +767,8 @@ static const PatchPage _patches_page[] = { {_patches_ai, lengthof(_patches_ai) }, }; +extern uint GetCurrentCurrencyRate(); + static int32 ReadPE(const PatchEntry*pe) { switch(pe->type) { @@ -772,6 +777,7 @@ static int32 ReadPE(const PatchEntry*pe) case PE_INT16: return *(int16*)pe->variable; case PE_UINT16: return *(uint16*)pe->variable; case PE_INT32: return *(int32*)pe->variable; + case PE_CURRENCY: return (*(int64*)pe->variable) * GetCurrentCurrencyRate(); default: NOT_REACHED(); } @@ -816,6 +822,15 @@ static void WritePE(const PatchEntry *pe, int32 val) else *(int32*)pe->variable = val; break; + + case PE_CURRENCY: val /= GetCurrentCurrencyRate(); + if ((int64)val > (int64)pe->max) + *(int64*)pe->variable = (int64)pe->max; + else if ((int64)val < (int64)pe->min) + *(int64*)pe->variable = (int64)pe->min; + else + *(int64*)pe->variable = val; + break; default: NOT_REACHED(); } @@ -852,12 +867,17 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) DrawStringCentered(x+20, y+1, STR_681A, 0); val = ReadPE(pe); + if (pe->type == PE_CURRENCY) + val /= GetCurrentCurrencyRate(); disabled = ((val == 0) && (pe->flags & PF_0ISDIS)); if (disabled) { SET_DPARAM16(0, STR_CONFIG_PATCHES_DISABLED); } else { SET_DPARAM32(1, val); - SET_DPARAM16(0, pe->flags & PF_NOCOMMA ? STR_CONFIG_PATCHES_INT32 : STR_7024); + if (pe->type == PE_CURRENCY) + SET_DPARAM16(0, STR_CONFIG_PATCHES_CURRENCY); + else + SET_DPARAM16(0, pe->flags & PF_NOCOMMA ? STR_CONFIG_PATCHES_INT32 : STR_7024); } } DrawString(30, y+1, (pe->str)+disabled, 0); @@ -898,6 +918,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) case PE_INT16: case PE_UINT16: case PE_INT32: + case PE_CURRENCY: // don't allow too fast scrolling if ((w->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) { _left_button_clicked = false; |