OpenTTD Source  20240919-master-gdf0233f4c2
null_v.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "../stdafx.h"
11 #include "../gfx_func.h"
12 #include "../blitter/factory.hpp"
13 #include "../saveload/saveload.h"
14 #include "../window_func.h"
15 #include "null_v.h"
16 
17 #include "../safeguards.h"
18 
21 
22 std::optional<std::string_view> VideoDriver_Null::Start(const StringList &parm)
23 {
24 #ifdef _MSC_VER
25  /* Disable the MSVC assertion message box. */
26  _set_error_mode(_OUT_TO_STDERR);
27  _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
28  _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
29 #endif
30 
31  this->UpdateAutoResolution();
32 
33  this->ticks = GetDriverParamInt(parm, "ticks", 1000);
34  _screen.width = _screen.pitch = _cur_resolution.width;
35  _screen.height = _cur_resolution.height;
36  _screen.dst_ptr = nullptr;
37  ScreenSizeChanged();
38 
39  /* Do not render, nor blit */
40  Debug(misc, 1, "Forcing blitter 'null'...");
42  return std::nullopt;
43 }
44 
46 
47 void VideoDriver_Null::MakeDirty(int, int, int, int) {}
48 
50 {
51  uint i;
52 
53  for (i = 0; i < this->ticks; i++) {
54  ::GameLoop();
55  ::InputLoop();
57  }
58 
59  /* If requested, make a save just before exit. The normal exit-flow is
60  * not triggered from this driver, so we have to do this manually. */
62  DoExitSave();
63  }
64 }
65 
66 bool VideoDriver_Null::ChangeResolution(int, int) { return false; }
67 
68 bool VideoDriver_Null::ToggleFullscreen(bool) { return false; }
DoExitSave
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
Definition: saveload.cpp:3201
GUISettings::autosave_on_exit
bool autosave_on_exit
save an autosave when you quit the game, but do not ask "Do you really want to quit?...
Definition: settings_type.h:171
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:56
VideoDriver_Null::ToggleFullscreen
bool ToggleFullscreen(bool fullscreen) override
Change the full screen setting.
Definition: null_v.cpp:68
VideoDriver_Null::ticks
uint ticks
Amount of ticks to run.
Definition: null_v.h:18
Debug
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
UpdateWindows
void UpdateWindows()
Update the continuously changing contents of the windows, such as the viewports.
Definition: window.cpp:3047
VideoDriver::InputLoop
virtual void InputLoop()
Handle input logic, is CTRL pressed, should we fast-forward, etc.
Definition: video_driver.hpp:259
iFVideoDriver_Null
static FVideoDriver_Null iFVideoDriver_Null
Factory for the null video driver.
Definition: null_v.cpp:20
VideoDriver_Null::Start
std::optional< std::string_view > Start(const StringList &param) override
Start this driver.
Definition: null_v.cpp:22
StringList
std::vector< std::string > StringList
Type for a list of strings.
Definition: string_type.h:60
VideoDriver_Null::ChangeResolution
bool ChangeResolution(int w, int h) override
Change the resolution of the window.
Definition: null_v.cpp:66
null_v.h
GetDriverParamInt
int GetDriverParamInt(const StringList &parm, const char *name, int def)
Get an integer parameter the list of parameters.
Definition: driver.cpp:76
BlitterFactory::SelectBlitter
static Blitter * SelectBlitter(const std::string_view name)
Find the requested blitter and return its class.
Definition: factory.hpp:96
VideoDriver::UpdateAutoResolution
void UpdateAutoResolution()
Apply resolution auto-detection and clamp to sensible defaults.
Definition: video_driver.hpp:244
VideoDriver_Null::MakeDirty
void MakeDirty(int left, int top, int width, int height) override
Mark a particular area dirty.
Definition: null_v.cpp:47
FVideoDriver_Null
Factory the null video driver.
Definition: null_v.h:37
VideoDriver_Null::Stop
void Stop() override
Stop this driver.
Definition: null_v.cpp:45
VideoDriver_Null::MainLoop
void MainLoop() override
Perform the actual drawing.
Definition: null_v.cpp:49
_cur_resolution
Dimension _cur_resolution
The current resolution.
Definition: driver.cpp:26
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:611