40 #include "table/strings.h"
86 switch (this->align_h) {
87 case LEFT: p.x = this->
position.x;
break;
91 switch (this->align_v) {
92 case TOP: p.y = this->
position.y;
break;
108 uint mouse_idle_time;
109 Point mouse_idle_pos;
120 const char *sign_langauge =
"^T\\s*([0-9]+)\\s*([-+A-Z0-9]+)\\s*([0-9]+)";
121 std::regex re(sign_langauge, std::regex_constants::icase);
124 std::vector<SignID> signs_to_delete;
128 if (std::regex_search(sign->name, match, re)) {
135 vc.
delay = std::stoi(match[3].str()) * 1000;
141 for (
char c : match[2].str()) {
143 if (id_type == ID_VEHICLE) {
148 switch (toupper(c)) {
151 case 'T': vc.
align_v = IntroGameViewportCommand::TOP;
break;
152 case 'M': vc.
align_v = IntroGameViewportCommand::MIDDLE;
break;
153 case 'B': vc.
align_v = IntroGameViewportCommand::BOTTOM;
break;
154 case 'L': vc.
align_h = IntroGameViewportCommand::LEFT;
break;
155 case 'C': vc.
align_h = IntroGameViewportCommand::CENTRE;
break;
156 case 'R': vc.
align_h = IntroGameViewportCommand::RIGHT;
break;
158 case 'V': id_type = ID_VEHICLE; vc.
vehicle = 0;
break;
165 signs_to_delete.push_back(sign->index);
173 std::sort(signs_to_delete.begin(), signs_to_delete.end(), [](
SignID a,
SignID b) { return a > b; });
174 for (
SignID sign_id : signs_to_delete) {
187 this->cur_viewport_command_index = SIZE_MAX;
188 this->cur_viewport_command_time = 0;
189 this->mouse_idle_time = 0;
190 this->mouse_idle_pos = _cursor.
pos;
193 void OnRealtimeTick(uint delta_ms)
override
199 bool suppress_panning =
true;
200 if (this->mouse_idle_pos.x != _cursor.
pos.x || this->mouse_idle_pos.y != _cursor.
pos.y) {
201 this->mouse_idle_pos = _cursor.
pos;
202 this->mouse_idle_time = 2000;
203 }
else if (this->mouse_idle_time > delta_ms) {
204 this->mouse_idle_time -= delta_ms;
206 this->mouse_idle_time = 0;
207 suppress_panning =
false;
211 bool changed_command =
false;
214 this->cur_viewport_command_index = 0;
215 changed_command =
true;
218 this->cur_viewport_command_time += delta_ms;
221 this->cur_viewport_command_time = 0;
222 changed_command =
true;
234 if (!changed_command && suppress_panning)
return;
237 if (changed_command) FixTitleGameZoom(vc.
zoom_adjust);
247 const double t = this->cur_viewport_command_time / (double)vc.
delay;
248 pos.x = pos.x + (
int)(t * (pos2.x - pos.x));
249 pos.y = pos.y + (int)(t * (pos2.y - pos.y));
267 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
269 if (!gui_scope)
return;
285 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
313 bool changed =
false;
317 changed |= wid->UpdateMultilineWidgetSize(
GetString(STR_INTRO_BASESET), 3);
322 changed |= wid->UpdateMultilineWidgetSize(
GetString(STR_INTRO_TRANSLATION), 3);
328 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
352 ShowNetworkGameWindow();
380 static constexpr
NWidgetPart _nested_select_game_widgets[] = {
463 _nested_select_game_widgets
466 void ShowSelectGameWindow()
471 static void AskExitGameCallback(
Window *,
bool confirmed)
483 STR_QUIT_ARE_YOU_SURE_YOU_WANT_TO_EXIT_OPENTTD,
491 static void AskExitToGameMenuCallback(
Window *,
bool confirmed)
499 void AskExitToGameMenu()
502 STR_ABANDON_GAME_CAPTION,
503 (_game_mode != GM_EDITOR) ? STR_ABANDON_GAME_QUERY : STR_ABANDON_SCENARIO_QUERY,
505 AskExitToGameMenuCallback,
void ShowAIConfigWindow()
Open the AI config window.
Window for configuring the AIs
@ EXIT
User is exiting the application.
void Transmit(Reason reason, bool blocking=false)
Transmit the survey.
Functions related to errors.
void ClearErrorMessages()
Clear all errors from the queue.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
@ WL_ERROR
Errors (eg. saving/loading failed)
@ FT_SCENARIO
old or new scenario
@ FT_HEIGHTMAP
heightmap file
@ FT_SAVEGAME
old or new savegame
@ SLO_LOAD
File is being loaded.
Declarations for savegames operations.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
void ShowGSConfigWindow()
Open the GS config window.
Window for configuring the Games
Functions related to world/map generation.
void SetNewLandscapeType(uint8_t landscape)
Changes landscape type and sets genworld window dirty.
static const uint32_t GENERATE_NEW_SEED
Create a new random seed.
void StartScenarioEditor()
Start with a scenario editor.
void StartNewGameWithoutGUI(uint32_t seed)
Start a normal game without the GUI.
void ShowGenerateLandscape()
Start with a normal game.
bool _ctrl_pressed
Is Ctrl pressed?
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
SwitchMode _switch_mode
The next mainloop command.
Functions related to the gfx engine.
@ SA_CENTER
Center both horizontally and vertically.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
GUI functions that shouldn't be here.
void ShowGameSettings()
Open advanced settings window.
void ShowGameOptions()
Open the game options window.
GUI to access manuals and related.
Declaration of functions and types defined in highscore.h and highscore_gui.h.
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
Functions related to OTTD's landscape.
Point RemapCoords(int x, int y, int z)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
Types related to the landscape.
Information about languages and their files.
const LanguageMetadata * _current_language
The currently loaded language.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
bool _is_network_server
Does this client wants to be a network-server?
bool _network_available
is network mode available?
Basic functions/variables used all over the place.
Part of the network protocol handling content distribution.
void ShowNetworkContentListWindow(ContentVector *cv=nullptr, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
GUIs related to networking.
Part of the network protocol handling opt-in survey.
uint _missing_extra_graphics
Number of sprites provided by the fallback extra GRF, i.e. missing in the baseset.
GRFConfig * _grfconfig_newgame
First item in list of default GRF set up.
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
@ SM_MENU
Switch to game intro menu.
declaration of OTTD revision dependent variables
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
ClientSettings _settings_client
The current settings for this game.
uint16_t SignID
The type of the IDs of signs.
This file contains all sprite-related enums and defines.
Definition of base types and functions in a cross-platform compatible way.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Functions related to OTTD's strings.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
GUISettings gui
settings related to the GUI
Point pos
logical mouse position
Dimensions (a width and height) of a rectangle in 2D.
uint8_t missing_strings_threshold
the number of missing strings before showing the warning
uint8_t landscape
the landscape we're currently in
GameCreationSettings game_creation
settings used during the creation of a game (map)
A viewport command for the main menu background (intro game).
int zoom_adjust
Adjustment to zoom level from base zoom level.
Point PositionForViewport(const Viewport *vp)
Calculate effective position.
uint delay
Delay until next command.
VehicleID vehicle
Vehicle to follow, or INVALID_VEHICLE if not following a vehicle.
bool pan_to_next
If true, do a smooth pan from this position to the next.
AlignmentH align_h
Horizontal alignment.
AlignmentH
Horizontal alignment value.
AlignmentV
Vertical alignment value.
AlignmentV align_v
Vertical alignment.
int command_index
Sequence number of the command (order they are performed in).
Point position
Calculated world coordinate to position viewport top-left at.
Coordinates of a point in 2D.
static Titem * Get(size_t index)
Returns Titem with given index.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
void ReadIntroGameViewportCommands()
Find and parse all viewport command signs.
std::vector< IntroGameViewportCommand > intro_viewport_commands
Vector of viewport commands parsed.
void OnResize() override
Called after the window got resized.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
size_t cur_viewport_command_index
Index of currently active viewport command.
uint cur_viewport_command_time
Time spent (milliseconds) on current viewport command.
void OnInit() override
Notification that the nested widget tree gets initialized.
int32_t z_pos
z coordinate.
int32_t y_pos
y coordinate.
int32_t x_pos
x coordinate.
int32_t dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
int32_t scrollpos_y
Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport).
int32_t dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
int32_t scrollpos_x
Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport).
Data structure for viewport, display of a part of the world.
int virtual_width
width << zoom
int virtual_height
height << zoom
High level window description.
Data structure for an opened window.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
ResizeInfo resize
Resize information.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
ViewportData * viewport
Pointer to viewport data, if present.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
WindowFlags flags
Window flags.
Stuff related to the text buffer GUI.
Base class for all vehicles.
uint32_t VehicleID
The type all our vehicle IDs have.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
void UpdateViewportPosition(Window *w, uint32_t delta_ms)
Update the viewport position being displayed.
Functions related to (drawing on) viewports.
Window * GetMainWindow()
Get the main window, i.e.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ WF_CENTERED
Window is centered and shall stay centered after ReInit.
@ WDF_NO_CLOSE
This window can't be interactively closed.
@ WDP_CENTER
Center the window.
@ WC_SELECT_GAME
Select game window; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.