Update to 14.0-beta1
This commit is contained in:
+88
-83
@@ -12,7 +12,6 @@
|
||||
#include "cheat_type.h"
|
||||
#include "company_base.h"
|
||||
#include "company_func.h"
|
||||
#include "date_func.h"
|
||||
#include "saveload/saveload.h"
|
||||
#include "vehicle_base.h"
|
||||
#include "textbuf_gui.h"
|
||||
@@ -30,6 +29,9 @@
|
||||
#include "error.h"
|
||||
#include "misc_cmd.h"
|
||||
#include "core/geometry_func.hpp"
|
||||
#include "timer/timer.h"
|
||||
#include "timer/timer_game_calendar.h"
|
||||
#include "timer/timer_game_economy.h"
|
||||
|
||||
#include "widgets/cheat_widget.h"
|
||||
|
||||
@@ -43,37 +45,36 @@
|
||||
* This variable is semantically a constant value, but because the cheat
|
||||
* code requires to be able to write to the variable it is not constified.
|
||||
*/
|
||||
static int32 _money_cheat_amount = 10000000;
|
||||
static int32_t _money_cheat_amount = 10000000;
|
||||
|
||||
/**
|
||||
* Handle cheating of money.
|
||||
* Note that the amount of money of a company must be changed through a command
|
||||
* rather than by setting a variable. Since the cheat data structure expects a
|
||||
* variable, the amount of given/taken money is used for this purpose.
|
||||
* @param p1 not used.
|
||||
* @param p2 is -1 or +1 (down/up)
|
||||
* @param change_direction is -1 or +1 (down/up)
|
||||
* @return Amount of money cheat.
|
||||
*/
|
||||
static int32 ClickMoneyCheat(int32 p1, int32 p2)
|
||||
static int32_t ClickMoneyCheat(int32_t, int32_t change_direction)
|
||||
{
|
||||
Command<CMD_MONEY_CHEAT>::Post(p2 * _money_cheat_amount);
|
||||
Command<CMD_MONEY_CHEAT>::Post(Money(_money_cheat_amount) * change_direction);
|
||||
return _money_cheat_amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle changing of company.
|
||||
* @param p1 company to set to
|
||||
* @param p2 is -1 or +1 (down/up)
|
||||
* @param new_value company to set to
|
||||
* @param change_direction is -1 or +1 (down/up)
|
||||
* @return The new company.
|
||||
*/
|
||||
static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
|
||||
static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction)
|
||||
{
|
||||
while ((uint)p1 < Company::GetPoolSize()) {
|
||||
if (Company::IsValidID((CompanyID)p1)) {
|
||||
SetLocalCompany((CompanyID)p1);
|
||||
while ((uint)new_value < Company::GetPoolSize()) {
|
||||
if (Company::IsValidID((CompanyID)new_value)) {
|
||||
SetLocalCompany((CompanyID)new_value);
|
||||
return _local_company;
|
||||
}
|
||||
p1 += p2;
|
||||
new_value += change_direction;
|
||||
}
|
||||
|
||||
return _local_company;
|
||||
@@ -81,60 +82,68 @@ static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
|
||||
|
||||
/**
|
||||
* Allow (or disallow) changing production of all industries.
|
||||
* @param p1 new value
|
||||
* @param p2 unused
|
||||
* @param new_value new value
|
||||
* @return New value allowing change of industry production.
|
||||
*/
|
||||
static int32 ClickSetProdCheat(int32 p1, int32 p2)
|
||||
static int32_t ClickSetProdCheat(int32_t new_value, int32_t)
|
||||
{
|
||||
_cheats.setup_prod.value = (p1 != 0);
|
||||
_cheats.setup_prod.value = (new_value != 0);
|
||||
InvalidateWindowClassesData(WC_INDUSTRY_VIEW);
|
||||
return _cheats.setup_prod.value;
|
||||
}
|
||||
|
||||
extern void EnginesMonthlyLoop();
|
||||
extern void CalendarEnginesMonthlyLoop();
|
||||
|
||||
/**
|
||||
* Handle changing of the current year.
|
||||
* @param p1 Unused.
|
||||
* @param p2 +1 (increase) or -1 (decrease).
|
||||
* @param new_value The chosen year to change to.
|
||||
* @return New year.
|
||||
*/
|
||||
static int32 ClickChangeDateCheat(int32 p1, int32 p2)
|
||||
static int32_t ClickChangeDateCheat(int32_t new_value, int32_t)
|
||||
{
|
||||
YearMonthDay ymd;
|
||||
ConvertDateToYMD(_date, &ymd);
|
||||
/* Don't allow changing to an invalid year, or the current year. */
|
||||
auto new_year = Clamp(TimerGameCalendar::Year(new_value), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
|
||||
if (new_year == TimerGameCalendar::year) return TimerGameCalendar::year.base();
|
||||
|
||||
p1 = Clamp(p1, MIN_YEAR, MAX_YEAR);
|
||||
if (p1 == _cur_year) return _cur_year;
|
||||
TimerGameCalendar::YearMonthDay ymd = TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::date);
|
||||
TimerGameCalendar::Date new_calendar_date = TimerGameCalendar::ConvertYMDToDate(new_year, ymd.month, ymd.day);
|
||||
/* Keep economy and calendar dates synced. */
|
||||
TimerGameEconomy::Date new_economy_date = new_calendar_date.base();
|
||||
|
||||
Date new_date = ConvertYMDToDate(p1, ymd.month, ymd.day);
|
||||
for (auto v : Vehicle::Iterate()) v->ShiftDates(new_date - _date);
|
||||
LinkGraphSchedule::instance.ShiftDates(new_date - _date);
|
||||
SetDate(new_date, _date_fract);
|
||||
EnginesMonthlyLoop();
|
||||
/* Shift cached dates before we change the date. */
|
||||
for (auto v : Vehicle::Iterate()) v->ShiftDates(new_economy_date - TimerGameEconomy::date);
|
||||
LinkGraphSchedule::instance.ShiftDates(new_economy_date - TimerGameEconomy::date);
|
||||
|
||||
/* Now it's safe to actually change the date. */
|
||||
TimerGameCalendar::SetDate(new_calendar_date, TimerGameCalendar::date_fract);
|
||||
|
||||
/* If not using wallclock units, we keep economy date in sync with calendar date and must change it also. */
|
||||
if (!TimerGameEconomy::UsingWallclockUnits()) TimerGameEconomy::SetDate(new_economy_date, TimerGameEconomy::date_fract);
|
||||
|
||||
CalendarEnginesMonthlyLoop();
|
||||
SetWindowDirty(WC_STATUS_BAR, 0);
|
||||
InvalidateWindowClassesData(WC_BUILD_STATION, 0);
|
||||
InvalidateWindowClassesData(WC_BUS_STATION, 0);
|
||||
InvalidateWindowClassesData(WC_TRUCK_STATION, 0);
|
||||
InvalidateWindowClassesData(WC_BUILD_OBJECT, 0);
|
||||
ResetSignalVariant();
|
||||
return _cur_year;
|
||||
return TimerGameCalendar::year.base();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow (or disallow) a change of the maximum allowed heightlevel.
|
||||
* @param p1 new value
|
||||
* @param p2 unused
|
||||
* @param new_value new value
|
||||
* @return New value (or unchanged old value) of the maximum
|
||||
* allowed heightlevel value.
|
||||
*/
|
||||
static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
|
||||
static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t)
|
||||
{
|
||||
p1 = Clamp(p1, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT);
|
||||
new_value = Clamp(new_value, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT);
|
||||
|
||||
/* Check if at least one mountain on the map is higher than the new value.
|
||||
* If yes, disallow the change. */
|
||||
for (TileIndex t = 0; t < MapSize(); t++) {
|
||||
if ((int32)TileHeight(t) > p1) {
|
||||
for (TileIndex t = 0; t < Map::Size(); t++) {
|
||||
if ((int32_t)TileHeight(t) > new_value) {
|
||||
ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
|
||||
/* Return old, unchanged value */
|
||||
return _settings_game.construction.map_height_limit;
|
||||
@@ -142,7 +151,7 @@ static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
|
||||
}
|
||||
|
||||
/* Execute the change and reload GRF Data */
|
||||
_settings_game.construction.map_height_limit = p1;
|
||||
_settings_game.construction.map_height_limit = new_value;
|
||||
ReloadNewGRFData();
|
||||
|
||||
/* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
|
||||
@@ -159,6 +168,7 @@ enum CheatNumbers {
|
||||
CHT_CROSSINGTUNNELS, ///< Allow tunnels to cross each other.
|
||||
CHT_NO_JETCRASH, ///< Disable jet-airplane crashes.
|
||||
CHT_SETUP_PROD, ///< Allow manually editing of industry production.
|
||||
CHT_STATION_RATING, ///< Fix station ratings at 100%.
|
||||
CHT_EDIT_MAX_HL, ///< Edit maximum allowed heightlevel
|
||||
CHT_CHANGE_DATE, ///< Do time traveling.
|
||||
|
||||
@@ -167,10 +177,10 @@ enum CheatNumbers {
|
||||
|
||||
/**
|
||||
* Signature of handler function when user clicks at a cheat.
|
||||
* @param p1 The new value.
|
||||
* @param p2 Change direction (+1, +1), \c 0 for boolean settings.
|
||||
* @param new_value The new value.
|
||||
* @param change_direction Change direction (+1, +1), \c 0 for boolean settings.
|
||||
*/
|
||||
typedef int32 CheckButtonClick(int32 p1, int32 p2);
|
||||
typedef int32_t CheckButtonClick(int32_t new_value, int32_t change_direction);
|
||||
|
||||
/** Information of a cheat. */
|
||||
struct CheatEntry {
|
||||
@@ -192,24 +202,22 @@ static const CheatEntry _cheats_ui[] = {
|
||||
{SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
|
||||
{SLE_BOOL, STR_CHEAT_STATION_RATING, &_cheats.station_rating.value, &_cheats.station_rating.been_used, nullptr },
|
||||
{SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.map_height_limit, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
|
||||
{SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
|
||||
{SLE_INT32, STR_CHEAT_CHANGE_DATE, &TimerGameCalendar::year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
|
||||
};
|
||||
|
||||
static_assert(CHT_NUM_CHEATS == lengthof(_cheats_ui));
|
||||
|
||||
/** Widget definitions of the cheat GUI. */
|
||||
static const NWidgetPart _nested_cheat_widgets[] = {
|
||||
static constexpr NWidgetPart _nested_cheat_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CHEATS, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_C_PANEL), SetDataTip(0x0, STR_CHEATS_TOOLTIP), EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY, WID_C_NOTE), SetFill(1, 1), SetDataTip(STR_CHEATS_NOTE, STR_NULL), SetPadding(WidgetDimensions::unscaled.frametext),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_C_PANEL), EndContainer(),
|
||||
};
|
||||
|
||||
/** GUI for the cheats. */
|
||||
@@ -217,7 +225,6 @@ struct CheatWindow : Window {
|
||||
int clicked;
|
||||
int clicked_widget;
|
||||
uint line_height;
|
||||
Dimension box; ///< Dimension of box sprite
|
||||
Dimension icon; ///< Dimension of company icon sprite
|
||||
|
||||
CheatWindow(WindowDesc *desc) : Window(desc)
|
||||
@@ -227,11 +234,10 @@ struct CheatWindow : Window {
|
||||
|
||||
void OnInit() override
|
||||
{
|
||||
this->box = maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED));
|
||||
this->icon = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||
{
|
||||
if (widget != WID_C_PANEL) return;
|
||||
|
||||
@@ -239,21 +245,17 @@ struct CheatWindow : Window {
|
||||
int y = ir.top;
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
uint box_left = rtl ? ir.right - this->box.width - WidgetDimensions::scaled.hsep_wide : ir.left + WidgetDimensions::scaled.hsep_wide;
|
||||
uint button_left = rtl ? ir.right - this->box.width - WidgetDimensions::scaled.hsep_wide * 2 - SETTING_BUTTON_WIDTH : ir.left + this->box.width + WidgetDimensions::scaled.hsep_wide * 2;
|
||||
uint text_left = ir.left + (rtl ? 0 : WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH);
|
||||
uint text_right = ir.right - (rtl ? WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH : 0);
|
||||
uint button_left = rtl ? ir.right - SETTING_BUTTON_WIDTH : ir.left;
|
||||
uint text_left = ir.left + (rtl ? 0 : WidgetDimensions::scaled.hsep_wide + SETTING_BUTTON_WIDTH);
|
||||
uint text_right = ir.right - (rtl ? WidgetDimensions::scaled.hsep_wide + SETTING_BUTTON_WIDTH : 0);
|
||||
|
||||
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
|
||||
int box_y_offset = (this->line_height - this->box.height) / 2;
|
||||
int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
|
||||
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
|
||||
int icon_y_offset = (this->line_height - this->icon.height) / 2;
|
||||
|
||||
for (int i = 0; i != lengthof(_cheats_ui); i++) {
|
||||
const CheatEntry *ce = &_cheats_ui[i];
|
||||
|
||||
DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, box_left, y + box_y_offset);
|
||||
|
||||
switch (ce->type) {
|
||||
case SLE_BOOL: {
|
||||
bool on = (*(bool*)ce->variable);
|
||||
@@ -264,21 +266,19 @@ struct CheatWindow : Window {
|
||||
}
|
||||
|
||||
default: {
|
||||
int32 val = (int32)ReadValue(ce->variable, ce->type);
|
||||
char buf[512];
|
||||
int32_t val = (int32_t)ReadValue(ce->variable, ce->type);
|
||||
|
||||
/* Draw [<][>] boxes for settings of an integer-type */
|
||||
DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true);
|
||||
|
||||
switch (ce->str) {
|
||||
/* Display date for change date cheat */
|
||||
case STR_CHEAT_CHANGE_DATE: SetDParam(0, _date); break;
|
||||
case STR_CHEAT_CHANGE_DATE: SetDParam(0, TimerGameCalendar::date); break;
|
||||
|
||||
/* Draw coloured flag for change company cheat */
|
||||
case STR_CHEAT_CHANGE_COMPANY: {
|
||||
SetDParam(0, val + 1);
|
||||
GetString(buf, STR_CHEAT_CHANGE_COMPANY, lastof(buf));
|
||||
uint offset = WidgetDimensions::scaled.hsep_indent + GetStringBoundingBox(buf).width;
|
||||
uint offset = WidgetDimensions::scaled.hsep_indent + GetStringBoundingBox(ce->str).width;
|
||||
DrawCompanyIcon(_local_company, rtl ? text_right - offset - WidgetDimensions::scaled.hsep_indent : text_left + offset, y + icon_y_offset);
|
||||
break;
|
||||
}
|
||||
@@ -295,7 +295,7 @@ struct CheatWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
{
|
||||
if (widget != WID_C_PANEL) return;
|
||||
|
||||
@@ -314,14 +314,14 @@ struct CheatWindow : Window {
|
||||
switch (ce->str) {
|
||||
/* Display date for change date cheat */
|
||||
case STR_CHEAT_CHANGE_DATE:
|
||||
SetDParam(0, ConvertYMDToDate(MAX_YEAR, 11, 31));
|
||||
SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 11, 31));
|
||||
width = std::max(width, GetStringBoundingBox(ce->str).width);
|
||||
break;
|
||||
|
||||
/* Draw coloured flag for change company cheat */
|
||||
case STR_CHEAT_CHANGE_COMPANY:
|
||||
SetDParamMaxValue(0, MAX_COMPANIES);
|
||||
width = std::max(width, GetStringBoundingBox(ce->str).width + WidgetDimensions::scaled.hsep_wide * 4);
|
||||
width = std::max(width, GetStringBoundingBox(ce->str).width + WidgetDimensions::scaled.hsep_wide);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -333,35 +333,36 @@ struct CheatWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
this->line_height = std::max(this->box.height, this->icon.height);
|
||||
this->line_height = std::max<uint>(this->line_height, SETTING_BUTTON_HEIGHT);
|
||||
this->line_height = std::max<uint>(this->line_height, FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.framerect.Vertical();
|
||||
this->line_height = std::max<uint>(this->icon.height, SETTING_BUTTON_HEIGHT);
|
||||
this->line_height = std::max<uint>(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical();
|
||||
|
||||
size->width = width + WidgetDimensions::scaled.hsep_wide * 4 + this->box.width + SETTING_BUTTON_WIDTH /* stuff on the left */ + WidgetDimensions::scaled.hsep_wide * 2 /* extra spacing on right */;
|
||||
size->width = width + WidgetDimensions::scaled.hsep_wide * 2 + SETTING_BUTTON_WIDTH;
|
||||
size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui);
|
||||
}
|
||||
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
{
|
||||
if (widget != WID_C_PANEL) return;
|
||||
|
||||
Rect r = this->GetWidget<NWidgetBase>(WID_C_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
|
||||
uint btn = (pt.y - r.top) / this->line_height;
|
||||
uint x = pt.x - r.left;
|
||||
int x = pt.x - r.left;
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
if (rtl) x = r.Width() - 1 - x;
|
||||
|
||||
if (btn >= lengthof(_cheats_ui)) return;
|
||||
|
||||
const CheatEntry *ce = &_cheats_ui[btn];
|
||||
int value = (int32)ReadValue(ce->variable, ce->type);
|
||||
int value = (int32_t)ReadValue(ce->variable, ce->type);
|
||||
int oldvalue = value;
|
||||
|
||||
if (btn == CHT_CHANGE_DATE && x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH) {
|
||||
if (btn == CHT_CHANGE_DATE && x >= SETTING_BUTTON_WIDTH) {
|
||||
/* Click at the date text directly. */
|
||||
clicked_widget = CHT_CHANGE_DATE;
|
||||
SetDParam(0, value);
|
||||
ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
|
||||
return;
|
||||
} else if (btn == CHT_EDIT_MAX_HL && x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH) {
|
||||
} else if (btn == CHT_EDIT_MAX_HL && x >= SETTING_BUTTON_WIDTH) {
|
||||
clicked_widget = CHT_EDIT_MAX_HL;
|
||||
SetDParam(0, value);
|
||||
ShowQueryString(STR_JUST_INT, STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
|
||||
@@ -369,7 +370,7 @@ struct CheatWindow : Window {
|
||||
}
|
||||
|
||||
/* Not clicking a button? */
|
||||
if (!IsInsideMM(x, WidgetDimensions::scaled.hsep_wide * 2 + this->box.width, WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH)) return;
|
||||
if (!IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) return;
|
||||
|
||||
*ce->been_used = true;
|
||||
|
||||
@@ -381,14 +382,14 @@ struct CheatWindow : Window {
|
||||
|
||||
default:
|
||||
/* Take whatever the function returns */
|
||||
value = ce->proc(value + ((x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
|
||||
value = ce->proc(value + ((x >= SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
|
||||
|
||||
/* The first cheat (money), doesn't return a different value. */
|
||||
if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
|
||||
if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
|
||||
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
|
||||
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64_t)value);
|
||||
|
||||
this->SetTimeout();
|
||||
|
||||
@@ -407,22 +408,26 @@ struct CheatWindow : Window {
|
||||
if (str == nullptr || StrEmpty(str)) return;
|
||||
|
||||
const CheatEntry *ce = &_cheats_ui[clicked_widget];
|
||||
int oldvalue = (int32)ReadValue(ce->variable, ce->type);
|
||||
int oldvalue = (int32_t)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);
|
||||
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64_t)value);
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
IntervalTimer<TimerGameCalendar> daily_interval = {{TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [this](auto) {
|
||||
this->SetDirty();
|
||||
}};
|
||||
};
|
||||
|
||||
/** Window description of the cheats GUI. */
|
||||
static WindowDesc _cheats_desc(
|
||||
static WindowDesc _cheats_desc(__FILE__, __LINE__,
|
||||
WDP_AUTO, "cheats", 0, 0,
|
||||
WC_CHEATS, WC_NONE,
|
||||
0,
|
||||
_nested_cheat_widgets, lengthof(_nested_cheat_widgets)
|
||||
std::begin(_nested_cheat_widgets), std::end(_nested_cheat_widgets)
|
||||
);
|
||||
|
||||
/** Open cheat window. */
|
||||
|
||||
Reference in New Issue
Block a user