Data Structures | Typedefs | Enumerations | Functions | Variables

# cheat_gui.cpp File Reference

GUI related to cheating. More...

`#include "stdafx.h"`
`#include "command_func.h"`
`#include "cheat_type.h"`
`#include "company_base.h"`
`#include "company_func.h"`
`#include "date_func.h"`
`#include "saveload/saveload.h"`
`#include "textbuf_gui.h"`
`#include "window_gui.h"`
`#include "string_func.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "rail_gui.h"`
`#include "gui.h"`
`#include "company_gui.h"`
`#include "widgets/cheat_widget.h"`
`#include "table/sprites.h"`

Go to the source code of this file.

## Data Structures
struct | CheatEntry
| Information of a cheat. More...
struct | CheatWindow
| GUI for the cheats. More...
## Typedefs
typedef int32 | CheckButtonClick (int32 p1, int32 p2)
| Signature of handler function when user clicks at a cheat.
## Enumerations
enum | CheatNumbers { CHT_MONEY, CHT_CHANGE_COMPANY, CHT_EXTRA_DYNAMITE, CHT_CROSSINGTUNNELS, CHT_NO_JETCRASH, CHT_SETUP_PROD, CHT_CHANGE_DATE, CHT_NUM_CHEATS }
| Available cheats. More...
## Functions
static int32 | ClickMoneyCheat (int32 p1, int32 p2)
| Handle cheating of money.
static int32 | ClickChangeCompanyCheat (int32 p1, int32 p2)
| Handle changing of company.
static int32 | ClickSetProdCheat (int32 p1, int32 p2)
| Allow (or disallow) changing production of all industries.
void | EnginesMonthlyLoop ()
static int32 | ClickChangeDateCheat (int32 p1, int32 p2)
| Handle changing of the current year.
| assert_compile (CHT_NUM_CHEATS==lengthof(_cheats_ui))
void | ShowCheatWindow ()
| Open cheat window.
## Variables
static int32 | _money_cheat_amount = 10000000
| The 'amount' to cheat with.
static const CheatEntry | _cheats_ui []
| The available cheats.
static const NWidgetPart | _nested_cheat_widgets []
| Widget definitions of the cheat GUI.
static const WindowDesc | _cheats_desc (WDP_AUTO, 0, 0, WC_CHEATS, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_cheat_widgets, lengthof(_nested_cheat_widgets))
| Window description of the cheats GUI.

## Detailed Description

GUI related to cheating.

Definition in file cheat_gui.cpp.

## Typedef Documentation

typedef int32 CheckButtonClick(int32 p1, int32 p2)

Signature of handler function when user clicks at a cheat.

Parameters:

  | p1 | The new value.
  | p2 | Change direction (+1, +1), `0` for boolean settings.

Definition at line 130 of file cheat_gui.cpp.

## Enumeration Type Documentation

enum CheatNumbers

Available cheats.

Enumerator:

  CHT_MONEY | Change amount of money.
  CHT_CHANGE_COMPANY | Switch company.
  CHT_EXTRA_DYNAMITE | Dynamite anything.
  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_CHANGE_DATE | Do time traveling.
  CHT_NUM_CHEATS | Number of cheats.

Definition at line 113 of file cheat_gui.cpp.

## Function Documentation

static int32 ClickChangeCompanyCheat | ( | int32 | p1,
|  | int32 | p2 |
| ) |  |  | `[static]`

Handle changing of company.

Parameters:

  | p1 | company to set to
  | p2 | is -1 or +1 (down/up)

Returns:
  The new company.

Definition at line 61 of file cheat_gui.cpp.

References _local_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetPoolSize(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), and SetLocalCompany().

static int32 ClickChangeDateCheat | ( | int32 | p1,
|  | int32 | p2 |
| ) |  |  | `[static]`

Handle changing of the current year.

Parameters:

  | p1 | Unused.
  | p2 | +1 (increase) or -1 (decrease).

Returns:
  New year.

Definition at line 95 of file cheat_gui.cpp.

References _cur_year, _date, _date_fract, Clamp(), ConvertDateToYMD(), ConvertYMDToDate(), YearMonthDay::day, InvalidateWindowClassesData(), MAX_YEAR, MIN_YEAR, YearMonthDay::month, ResetSignalVariant(), SetDate(), SetWindowDirty(), WC_BUILD_OBJECT, WC_BUILD_STATION, and WC_STATUS_BAR.

static int32 ClickMoneyCheat | ( | int32 | p1,
|  | int32 | p2 |
| ) |  |  | `[static]`

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.

Parameters:

  | p1 | not used.
  | p2 | is -1 or +1 (down/up)

Returns:
  Amount of money cheat.

Definition at line 49 of file cheat_gui.cpp.

References _money_cheat_amount, CMD_MONEY_CHEAT, and DoCommandP().

static int32 ClickSetProdCheat | ( | int32 | p1,
|  | int32 | p2 |
| ) |  |  | `[static]`

Allow (or disallow) changing production of all industries.

Parameters:

  | p1 | new value
  | p2 | unused

Returns:
  New value allwing change of industry production.

Definition at line 80 of file cheat_gui.cpp.

References _cheats, InvalidateWindowClassesData(), Cheats::setup_prod, Cheat::value, and WC_INDUSTRY_VIEW.

void ShowCheatWindow | ( |  | ) |

Open cheat window.

Definition at line 359 of file cheat_gui.cpp.

References _cheats_desc, DeleteWindowById(), and WC_CHEATS.

Referenced by MainToolbarWindow::OnKeyPress().

## Variable Documentation

const WindowDesc _cheats_desc(WDP_AUTO, 0, 0, WC_CHEATS, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_cheat_widgets, lengthof(_nested_cheat_widgets))`[static]`

Window description of the cheats GUI.

Referenced by ShowCheatWindow().

const CheatEntry _cheats_ui[]`[static]`

Initial value:

     {
      {SLE_INT32, STR_CHEAT_MONEY,           &_money_cheat_amount,                    &_cheats.money.been_used,            &ClickMoneyCheat         },
      {SLE_UINT8, STR_CHEAT_CHANGE_COMPANY,  &_local_company,                         &_cheats.switch_company.been_used,   &ClickChangeCompanyCheat },
      {SLE_BOOL,  STR_CHEAT_EXTRA_DYNAMITE,  &_cheats.magic_bulldozer.value,          &_cheats.magic_bulldozer.been_used,  NULL                     },
      {SLE_BOOL,  STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value,         &_cheats.crossing_tunnels.been_used, NULL                     },
      {SLE_BOOL,  STR_CHEAT_NO_JETCRASH,     &_cheats.no_jetcrash.value,              &_cheats.no_jetcrash.been_used,      NULL                     },
      {SLE_BOOL,  STR_CHEAT_SETUP_PROD,      &_cheats.setup_prod.value,               &_cheats.setup_prod.been_used,       &ClickSetProdCheat       },
      {SLE_INT32, STR_CHEAT_CHANGE_DATE,     &_cur_year,                              &_cheats.change_date.been_used,      &ClickChangeDateCheat    },
    }

The available cheats.

Order matches with the values of CheatNumbers

Definition at line 145 of file cheat_gui.cpp.

int32 _money_cheat_amount = 10000000`[static]`

The 'amount' to cheat with.

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.

Definition at line 38 of file cheat_gui.cpp.

Referenced by ClickMoneyCheat().

const NWidgetPart _nested_cheat_widgets[]`[static]`

Initial value:

     {
      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(),
    }

Widget definitions of the cheat GUI.

Definition at line 158 of file cheat_gui.cpp.