Changeset - r16647:5a3abb315d22
[Not reviewed]
master
0 2 0
alberth - 13 years ago 2010-12-04 21:51:02
alberth@openttd.org
(svn r21388) -Feature [FS#4289]: Allow entering of the new year in a text box when cheating the year.
2 files changed with 29 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/cheat_gui.cpp
Show inline comments
 
@@ -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;
 
		}
 

	
 
		/* Not clicking a button? */
 
		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);
 
		*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. */
src/lang/english.txt
Show inline comments
 
@@ -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
0 comments (0 inline, 0 general)