mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 18:40:29 +00:00
(svn r21388) -Feature [FS#4289]: Allow entering of the new year in a text box when cheating the year.
This commit is contained in:
parent
4a35dafcd2
commit
fd2f1399d4
@ -18,7 +18,9 @@
|
|||||||
#include "date_func.h"
|
#include "date_func.h"
|
||||||
#include "saveload/saveload.h"
|
#include "saveload/saveload.h"
|
||||||
#include "window_gui.h"
|
#include "window_gui.h"
|
||||||
|
#include "querystring_gui.h"
|
||||||
#include "newgrf.h"
|
#include "newgrf.h"
|
||||||
|
#include "string_func.h"
|
||||||
#include "strings_func.h"
|
#include "strings_func.h"
|
||||||
#include "window_func.h"
|
#include "window_func.h"
|
||||||
#include "rail_gui.h"
|
#include "rail_gui.h"
|
||||||
@ -325,13 +327,22 @@ struct CheatWindow : Window {
|
|||||||
bool rtl = _current_text_dir == TD_RTL;
|
bool rtl = _current_text_dir == TD_RTL;
|
||||||
if (rtl) x = wid->current_x - x;
|
if (rtl) x = wid->current_x - x;
|
||||||
|
|
||||||
/* Not clicking a button? */
|
if (btn >= lengthof(_cheats_ui)) return;
|
||||||
if (!IsInsideMM(x, 20, 40) || btn >= lengthof(_cheats_ui)) return;
|
|
||||||
|
|
||||||
const CheatEntry *ce = &_cheats_ui[btn];
|
const CheatEntry *ce = &_cheats_ui[btn];
|
||||||
int value = (int32)ReadValue(ce->variable, ce->type);
|
int value = (int32)ReadValue(ce->variable, ce->type);
|
||||||
int oldvalue = value;
|
int oldvalue = value;
|
||||||
|
|
||||||
|
if (btn == CHT_CHANGE_DATE && x >= 40) {
|
||||||
|
/* Click at the date text directly. */
|
||||||
|
SetDParam(0, value);
|
||||||
|
ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, 100, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Not clicking a button? */
|
||||||
|
if (!IsInsideMM(x, 20, 40)) return;
|
||||||
|
|
||||||
*ce->been_used = true;
|
*ce->been_used = true;
|
||||||
|
|
||||||
switch (ce->type) {
|
switch (ce->type) {
|
||||||
@ -361,6 +372,21 @@ struct CheatWindow : Window {
|
|||||||
this->clicked = 0;
|
this->clicked = 0;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void OnQueryTextFinished(char *str)
|
||||||
|
{
|
||||||
|
/* Was 'cancel' pressed or nothing entered? */
|
||||||
|
if (str == NULL || StrEmpty(str)) return;
|
||||||
|
|
||||||
|
const CheatEntry *ce = &_cheats_ui[CHT_CHANGE_DATE];
|
||||||
|
int oldvalue = (int32)ReadValue(ce->variable, ce->type);
|
||||||
|
int value = atoi(str);
|
||||||
|
*ce->been_used = true;
|
||||||
|
value = ce->proc(value, value - oldvalue);
|
||||||
|
|
||||||
|
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
|
||||||
|
this->SetDirty();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Window description of the cheats GUI. */
|
/** Window description of the cheats GUI. */
|
||||||
|
@ -1430,6 +1430,7 @@ STR_CHEAT_SWITCH_CLIMATE_SUB_ARCTIC_LANDSCAPE :Sub-arctic land
|
|||||||
STR_CHEAT_SWITCH_CLIMATE_SUB_TROPICAL_LANDSCAPE :Sub-tropical landscape
|
STR_CHEAT_SWITCH_CLIMATE_SUB_TROPICAL_LANDSCAPE :Sub-tropical landscape
|
||||||
STR_CHEAT_SWITCH_CLIMATE_TOYLAND_LANDSCAPE :Toyland landscape
|
STR_CHEAT_SWITCH_CLIMATE_TOYLAND_LANDSCAPE :Toyland landscape
|
||||||
STR_CHEAT_CHANGE_DATE :{LTBLUE}Change date: {ORANGE}{DATE_SHORT}
|
STR_CHEAT_CHANGE_DATE :{LTBLUE}Change date: {ORANGE}{DATE_SHORT}
|
||||||
|
STR_CHEAT_CHANGE_DATE_QUERY_CAPT :{WHITE}Change current year
|
||||||
STR_CHEAT_SETUP_PROD :{LTBLUE}Enable modifying production values: {ORANGE}{STRING1}
|
STR_CHEAT_SETUP_PROD :{LTBLUE}Enable modifying production values: {ORANGE}{STRING1}
|
||||||
|
|
||||||
# Livery window
|
# Livery window
|
||||||
|
Loading…
Reference in New Issue
Block a user