OpenTTD Source  20240915-master-g3784a3d3d6
main_gui.cpp File Reference
#include "stdafx.h"
#include "currency.h"
#include "spritecache.h"
#include "window_gui.h"
#include "window_func.h"
#include "textbuf_gui.h"
#include "viewport_func.h"
#include "command_func.h"
#include "console_gui.h"
#include "progress.h"
#include "transparency_gui.h"
#include "map_func.h"
#include "sound_func.h"
#include "transparency.h"
#include "strings_func.h"
#include "zoom_func.h"
#include "company_base.h"
#include "company_func.h"
#include "toolbar_gui.h"
#include "statusbar_gui.h"
#include "linkgraph/linkgraph_gui.h"
#include "tilehighlight_func.h"
#include "hotkeys.h"
#include "error.h"
#include "news_gui.h"
#include "misc_cmd.h"
#include "timer/timer.h"
#include "timer/timer_window.h"
#include "saveload/saveload.h"
#include "widgets/main_widget.h"
#include "network/network.h"
#include "network/network_func.h"
#include "network/network_gui.h"
#include "network/network_base.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  MainWindow
 

Enumerations

enum  {
  GHK_QUIT, GHK_ABANDON, GHK_CONSOLE, GHK_BOUNDING_BOXES,
  GHK_DIRTY_BLOCKS, GHK_WIDGET_OUTLINES, GHK_CENTER, GHK_CENTER_ZOOM,
  GHK_RESET_OBJECT_TO_PLACE, GHK_DELETE_WINDOWS, GHK_DELETE_NONVITAL_WINDOWS, GHK_DELETE_ALL_MESSAGES,
  GHK_REFRESH_SCREEN, GHK_CRASH, GHK_MONEY, GHK_UPDATE_COORDS,
  GHK_TOGGLE_TRANSPARENCY, GHK_TOGGLE_INVISIBILITY = GHK_TOGGLE_TRANSPARENCY + 9, GHK_TRANSPARENCY_TOOLBAR = GHK_TOGGLE_INVISIBILITY + 8, GHK_TRANSPARANCY,
  GHK_CHAT, GHK_CHAT_ALL, GHK_CHAT_COMPANY, GHK_CHAT_SERVER,
  GHK_CLOSE_NEWS, GHK_CLOSE_ERROR
}
 

Functions

bool HandlePlacePushButton (Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
 This code is shared for the majority of the pushbuttons. More...
 
void CcPlaySound_EXPLOSION (Commands, const CommandCost &result, TileIndex tile)
 
bool DoZoomInOutWindow (ZoomStateChange how, Window *w)
 Zooms a viewport in a window in or out. More...
 
void ZoomInOrOutToCursorWindow (bool in, Window *w)
 
void FixTitleGameZoom (int zoom_adjust)
 
bool IsQuitKey (uint16_t keycode)
 Does the given keycode match one of the keycodes bound to 'quit game'? More...
 
void ShowSelectGameWindow ()
 
void SetupColoursAndInitialWindow ()
 Initialise the default colours (remaps and the likes), and load the main windows.
 
void ShowVitalWindows ()
 Show the vital in-game windows.
 
void GameSizeChanged ()
 Size of the application screen changed. More...
 

Variables

static constexpr NWidgetPart _nested_main_window_widgets []
 
static WindowDesc _main_window_desc (WDP_MANUAL, nullptr, 0, 0, WC_MAIN_WINDOW, WC_NONE, WDF_NO_CLOSE, _nested_main_window_widgets, &MainWindow::hotkeys)
 

Detailed Description

Handling of the main viewport.

Definition in file main_gui.cpp.

Function Documentation

◆ DoZoomInOutWindow()

bool DoZoomInOutWindow ( ZoomStateChange  how,
Window w 
)

Zooms a viewport in a window in or out.

Parameters
howZooming direction.
wWindow owning the viewport.
Returns
Returns true if zooming step could be done, false if further zooming is not possible.
Note
No button handling or what so ever is done.

Definition at line 93 of file main_gui.cpp.

References _settings_client, ViewportData::dest_scrollpos_x, ViewportData::dest_scrollpos_y, ClientSettings::gui, Window::InvalidateData(), ViewportData::scrollpos_x, ViewportData::scrollpos_y, Window::viewport, Viewport::virtual_height, Viewport::virtual_left, Viewport::virtual_top, Viewport::virtual_width, Viewport::zoom, ZOOM_IN, GUISettings::zoom_max, GUISettings::zoom_min, ZOOM_NONE, and ZOOM_OUT.

Referenced by DEF_CONSOLE_CMD(), and MaxZoomInOut().

◆ GameSizeChanged()

void GameSizeChanged ( )

Size of the application screen changed.

Adapt the game screen-size, re-allocate the open windows, and repaint everything

Definition at line 589 of file main_gui.cpp.

References _cur_resolution.

Referenced by VideoDriver_SDL_Base::ClientSizeChanged().

◆ HandlePlacePushButton()

bool HandlePlacePushButton ( Window w,
WidgetID  widget,
CursorID  cursor,
HighLightStyle  mode 
)

This code is shared for the majority of the pushbuttons.

Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters

Parameters
wWindow which called the function
widgetID of the widget (=button) that called this function
cursorHow should the cursor image change? E.g. cursor with depot image in it
modeTile highlighting mode, e.g. drawing a rectangle or a dot on the ground
Returns
true if the button is clicked, false if it's unclicked

Definition at line 63 of file main_gui.cpp.

References _settings_client, SoundSettings::click_beep, Window::IsWidgetDisabled(), and ClientSettings::sound.

◆ IsQuitKey()

bool IsQuitKey ( uint16_t  keycode)

Does the given keycode match one of the keycodes bound to 'quit game'?

Parameters
keycodeThe keycode that was pressed by the user.
Returns
True iff the keycode matches one of the hotkeys for 'quit'.

Definition at line 534 of file main_gui.cpp.

Variable Documentation

◆ _nested_main_window_widgets

constexpr NWidgetPart _nested_main_window_widgets[]
staticconstexpr
Initial value:
= {
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_M_VIEWPORT), SetResize(1, 1),
}

Definition at line 177 of file main_gui.cpp.

WID_M_VIEWPORT
@ WID_M_VIEWPORT
Main window viewport.
Definition: main_widget.h:15
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1128
NWID_VIEWPORT
@ NWID_VIEWPORT
Nested widget containing a viewport.
Definition: widget_type.h:83
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1311