OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
77 new_value += change_direction;
116 TimerGameEconomy::Date new_economy_date = new_calendar_date.base();
243 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
257 int icon_y_offset = (this->line_height - this->icon.height) / 2;
267 SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
275 DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2),
true,
true);
282 case STR_CHEAT_CHANGE_COMPANY: {
295 DrawString(text_left, text_right, y + text_y_offset, ce->
str);
297 y += this->line_height;
318 case STR_CHEAT_CHANGE_DATE:
324 case STR_CHEAT_CHANGE_COMPANY:
345 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
350 uint btn = (pt.y - r.top) / this->line_height;
351 int x = pt.x - r.left;
353 if (rtl) x = r.
Width() - 1 - x;
359 int oldvalue = value;
382 if (ce->
proc !=
nullptr) ce->
proc(value, 0);
407 void OnQueryTextFinished(std::optional<std::string> str)
override
410 if (!str.has_value() || str->empty())
return;
414 int value = atoi(str->c_str());
416 value = ce->
proc(value, value - oldvalue);
VarType type
type of selector
static constexpr NWidgetPart _nested_cheat_widgets[]
Widget definitions of the cheat GUI.
void DrawArrowButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Cheat no_jetcrash
no jet will crash on small airports anymore
Cheat crossing_tunnels
allow tunnels that cross each other
Cheat magic_bulldozer
dynamite industries, objects
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Dimensions (a width and height) of a rectangle in 2D.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
Cheat edit_max_hl
edit the maximum heightlevel; this is a cheat because of the fact that it needs to reset NewGRF game ...
@ QSF_ACCEPT_UNCHANGED
return success even when the text didn't change
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
static DateFract date_fract
Fractional part of the day.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
@ WC_INDUSTRY_VIEW
Industry view; Window numbers:
Dimension icon
Dimension of company icon sprite.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Owner
Enum for all companies/owners.
void CalendarEnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
Cheat setup_prod
setup raw-material production in game
void SetLocalCompany(CompanyID new_company)
Sets the local company and updates the settings that are set on a per-company basis to reflect the co...
@ CHT_CHANGE_COMPANY
Switch company.
static DateFract date_fract
Fractional part of the day.
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Templated helper to make a type-safe 'typedef' representing a single POD value.
@ WC_BUILD_STATION
Build station; Window numbers:
static int32_t ClickChangeDateCheat(int32_t new_value, int32_t)
Handle changing of the current year.
static int32_t ClickSetProdCheat(int32_t new_value, int32_t)
Allow (or disallow) changing production of all industries.
@ WC_CHEATS
Cheat window; Window numbers:
bool * been_used
has this cheat been used before?
@ CHT_MONEY
Change amount of money.
int64_t ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
CheatNumbers
Available cheats.
High level window description.
static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t)
Allow (or disallow) a change of the maximum allowed heightlevel.
static WindowDesc _cheats_desc(WDP_AUTO, "cheats", 0, 0, WC_CHEATS, WC_NONE, 0, _nested_cheat_widgets)
Window description of the cheats GUI.
static size_t GetPoolSize()
Returns first unused index.
@ CHT_EDIT_MAX_HL
Edit maximum allowed heightlevel.
@ WDP_AUTO
Find a place automatically.
void OnTimeout() override
Called when this window's timeout has been reached.
ResizeInfo resize
Resize information.
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
@ FS_NORMAL
Index of the normal font in the font tables.
Cheat money
get rich or poor
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
CheckButtonClick * proc
procedure
static const uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
uint8_t map_height_limit
the maximum allowed heightlevel
Cheats _cheats
All the cheats.
@ CHT_NUM_CHEATS
Number of cheats.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
@ WC_TRUCK_STATION
Build truck station; Window numbers:
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ WC_BUS_STATION
Build bus station; Window numbers:
int32_t CheckButtonClick(int32_t new_value, int32_t change_direction)
Signature of handler function when user clicks at a cheat.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
#define lengthof(array)
Return the length of an fixed size array.
void * variable
pointer to the variable
static void SetDate(Date date, DateFract fract)
Set the date.
Coordinates of a point in 2D.
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
void OnInit() override
Notification that the nested widget tree gets initialized.
static const CheatEntry _cheats_ui[]
The available cheats.
bool value
tells if the bool cheat is active or not
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
static int32_t _money_cheat_amount
The 'amount' to cheat with.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
@ CHT_STATION_RATING
Fix station ratings at 100%.
static const uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
StringID str
string with descriptive text
static debug_inline uint Size()
Get the size of the map.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
@ CHT_SETUP_PROD
Allow manually editing of industry production.
Cheat change_date
changes date ingame
void ResetSignalVariant(int32_t)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
The absolute minimum year in OTTD.
@ CHT_NO_JETCRASH
Disable jet-airplane crashes.
@ WL_ERROR
Errors (eg. saving/loading failed)
static void SetDate(Date date, DateFract fract)
Set the date.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
int width
width of the window (number of pixels to the right in x direction)
@ WC_BUILD_OBJECT
Build object; Window numbers:
static debug_inline uint TileHeight(Tile tile)
Returns the height of a tile.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
@ CHT_CROSSINGTUNNELS
Allow tunnels to cross each other.
static Date date
Current date in days (day counter).
ConstructionSettings construction
construction of things in-game
Cheat station_rating
Fix station ratings at 100%.
Data structure for an opened window.
@ MAX_COMPANIES
Maximum number of companies.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
bool been_used
has this cheat been used before?
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
int Width() const
Get width of Rect.
Specification of a rectangle with absolute coordinates of all edges.
static int32_t ClickMoneyCheat(int32_t, int32_t change_direction)
Handle cheating of money.
Cheat switch_company
change to another company
@ WC_SMALLMAP
Small map; Window numbers:
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
@ TD_RTL
Text is written right-to-left by default.
@ CHT_CHANGE_DATE
Do time traveling.
TextDirection _current_text_dir
Text direction of the currently selected language.
@ CS_NUMERAL
Only numeric ones.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
void WriteValue(void *ptr, VarType conv, int64_t val)
Write the value of a setting.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
@ CHT_EXTRA_DYNAMITE
Dynamite anything.
void ShowCheatWindow()
Open cheat window.
static Year year
Current year, starting at 0.
static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction)
Handle changing of company.
static Date date
Current date in days (day counter).