Cheats window: Allow clicking money text to enter quantity
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
#include "order_base.h"
|
#include "order_base.h"
|
||||||
|
#include "currency.h"
|
||||||
|
|
||||||
#include "widgets/cheat_widget.h"
|
#include "widgets/cheat_widget.h"
|
||||||
|
|
||||||
@@ -391,6 +392,11 @@ struct CheatWindow : Window {
|
|||||||
SetDParam(0, value);
|
SetDParam(0, value);
|
||||||
ShowQueryString(STR_JUST_INT, STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
|
ShowQueryString(STR_JUST_INT, STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
|
||||||
return;
|
return;
|
||||||
|
} else if (btn == CHT_MONEY && x >= 20 + this->box_width + SETTING_BUTTON_WIDTH) {
|
||||||
|
clicked_widget = CHT_MONEY;
|
||||||
|
SetDParam(0, value);
|
||||||
|
ShowQueryString(STR_JUST_INT, STR_CHEAT_EDIT_MONEY_QUERY_CAPT, 20, this, CS_NUMERAL_SIGNED, QSF_ACCEPT_UNCHANGED);
|
||||||
|
return;
|
||||||
} else if (ce->type == SLF_NOT_IN_SAVE && x >= 20 + this->box_width + SETTING_BUTTON_WIDTH) {
|
} else if (ce->type == SLF_NOT_IN_SAVE && x >= 20 + this->box_width + SETTING_BUTTON_WIDTH) {
|
||||||
clicked_widget = btn;
|
clicked_widget = btn;
|
||||||
uint64 val = (uint64)ReadValue(ce->variable, SLE_UINT64);
|
uint64 val = (uint64)ReadValue(ce->variable, SLE_UINT64);
|
||||||
@@ -465,6 +471,11 @@ struct CheatWindow : Window {
|
|||||||
DoCommandP(0, (uint32)clicked_widget, (uint32)Clamp<uint64>(atof(tmp_buffer) * 65536.0, 1 << 16, MAX_INFLATION), CMD_CHEAT_SETTING);
|
DoCommandP(0, (uint32)clicked_widget, (uint32)Clamp<uint64>(atof(tmp_buffer) * 65536.0, 1 << 16, MAX_INFLATION), CMD_CHEAT_SETTING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (ce->mode == CNM_MONEY) {
|
||||||
|
if (!_networking) *ce->been_used = true;
|
||||||
|
DoCommandP(0, (strtoll(str, nullptr, 10) / _currency->rate), 0, _network_server || _network_settings_access ? CMD_MONEY_CHEAT_ADMIN : CMD_MONEY_CHEAT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_networking) return;
|
if (_networking) return;
|
||||||
int oldvalue = (int32)ReadValue(ce->variable, ce->type);
|
int oldvalue = (int32)ReadValue(ce->variable, ce->type);
|
||||||
|
@@ -2177,6 +2177,7 @@ STR_CHEAT_CROSSINGTUNNELS :{LTBLUE}Tunnels
|
|||||||
STR_CHEAT_NO_JETCRASH :{LTBLUE}Jetplanes will not crash (frequently) on small airports: {ORANGE}{STRING}
|
STR_CHEAT_NO_JETCRASH :{LTBLUE}Jetplanes will not crash (frequently) on small airports: {ORANGE}{STRING}
|
||||||
STR_CHEAT_EDIT_MAX_HL :{LTBLUE}Edit the maximum map height: {ORANGE}{NUM}
|
STR_CHEAT_EDIT_MAX_HL :{LTBLUE}Edit the maximum map height: {ORANGE}{NUM}
|
||||||
STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT :{WHITE}Edit the maximum height of mountains on the map
|
STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT :{WHITE}Edit the maximum height of mountains on the map
|
||||||
|
STR_CHEAT_EDIT_MONEY_QUERY_CAPT :{WHITE}Increase or decrease money
|
||||||
STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE :Temperate landscape
|
STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE :Temperate landscape
|
||||||
STR_CHEAT_SWITCH_CLIMATE_SUB_ARCTIC_LANDSCAPE :Sub-arctic landscape
|
STR_CHEAT_SWITCH_CLIMATE_SUB_ARCTIC_LANDSCAPE :Sub-arctic landscape
|
||||||
STR_CHEAT_SWITCH_CLIMATE_SUB_TROPICAL_LANDSCAPE :Sub-tropical landscape
|
STR_CHEAT_SWITCH_CLIMATE_SUB_TROPICAL_LANDSCAPE :Sub-tropical landscape
|
||||||
|
@@ -490,6 +490,7 @@ bool IsValidChar(WChar key, CharSetFilter afilter)
|
|||||||
switch (afilter) {
|
switch (afilter) {
|
||||||
case CS_ALPHANUMERAL: return IsPrintable(key);
|
case CS_ALPHANUMERAL: return IsPrintable(key);
|
||||||
case CS_NUMERAL: return (key >= '0' && key <= '9');
|
case CS_NUMERAL: return (key >= '0' && key <= '9');
|
||||||
|
case CS_NUMERAL_SIGNED: return (key >= '0' && key <= '9') || key == '-';
|
||||||
#if !defined(STRGEN) && !defined(SETTINGSGEN)
|
#if !defined(STRGEN) && !defined(SETTINGSGEN)
|
||||||
case CS_NUMERAL_DECIMAL: return (key >= '0' && key <= '9') || key == '.' || key == '-' || key == GetDecimalSeparatorChar();
|
case CS_NUMERAL_DECIMAL: return (key >= '0' && key <= '9') || key == '.' || key == '-' || key == GetDecimalSeparatorChar();
|
||||||
#else
|
#else
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
enum CharSetFilter {
|
enum CharSetFilter {
|
||||||
CS_ALPHANUMERAL, ///< Both numeric and alphabetic and spaces and stuff
|
CS_ALPHANUMERAL, ///< Both numeric and alphabetic and spaces and stuff
|
||||||
CS_NUMERAL, ///< Only numeric ones
|
CS_NUMERAL, ///< Only numeric ones
|
||||||
|
CS_NUMERAL_SIGNED, ///< Only numeric ones, and minus/negative
|
||||||
CS_NUMERAL_DECIMAL, ///< Only numeric, decimal separaters, and minus/negative
|
CS_NUMERAL_DECIMAL, ///< Only numeric, decimal separaters, and minus/negative
|
||||||
CS_NUMERAL_SPACE, ///< Only numbers and spaces
|
CS_NUMERAL_SPACE, ///< Only numbers and spaces
|
||||||
CS_ALPHA, ///< Only alphabetic values
|
CS_ALPHA, ///< Only alphabetic values
|
||||||
|
Reference in New Issue
Block a user