@@ -18,7 +18,9 @@
#include "date_func.h"
#include "saveload/saveload.h"
#include "window_gui.h"
#include "querystring_gui.h"
#include "newgrf.h"
#include "string_func.h"
#include "strings_func.h"
#include "window_func.h"
#include "rail_gui.h"
@@ -325,13 +327,22 @@ struct CheatWindow : Window {
bool rtl = _current_text_dir == TD_RTL;
if (rtl) x = wid->current_x - x;
/* Not clicking a button? */
if (!IsInsideMM(x, 20, 40) || btn >= lengthof(_cheats_ui)) return;
if (btn >= lengthof(_cheats_ui)) return;
const CheatEntry *ce = &_cheats_ui[btn];
int value = (int32)ReadValue(ce->variable, ce->type);
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;
}
if (!IsInsideMM(x, 20, 40)) return;
*ce->been_used = true;
switch (ce->type) {
@@ -361,6 +372,21 @@ struct CheatWindow : Window {
this->clicked = 0;
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);
value = ce->proc(value, value - oldvalue);
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
};
/** Window description of the cheats GUI. */
@@ -1430,6 +1430,7 @@ STR_CHEAT_SWITCH_CLIMATE_SUB_ARCTIC_LAND
STR_CHEAT_SWITCH_CLIMATE_SUB_TROPICAL_LANDSCAPE :Sub-tropical landscape
STR_CHEAT_SWITCH_CLIMATE_TOYLAND_LANDSCAPE :Toyland landscape
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}
# Livery window
Status change: