OpenTTD Source 20241224-master-gf74b0cf984
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
22std::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
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
47void VideoDriver_Null::MakeDirty(int, int, int, int) {}
48
50{
51 uint i;
52
53 for (i = 0; i < this->ticks; i++) {
54 ::GameLoop();
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
66bool VideoDriver_Null::ChangeResolution(int, int) { return false; }
67
68bool VideoDriver_Null::ToggleFullscreen(bool) { return false; }
static Blitter * SelectBlitter(const std::string_view name)
Find the requested blitter and return its class.
Definition factory.hpp:96
Factory the null video driver.
Definition null_v.h:37
uint ticks
Amount of ticks to run.
Definition null_v.h:18
void Stop() override
Stop this driver.
Definition null_v.cpp:45
void MainLoop() override
Perform the actual drawing.
Definition null_v.cpp:49
bool ChangeResolution(int w, int h) override
Change the resolution of the window.
Definition null_v.cpp:66
void MakeDirty(int left, int top, int width, int height) override
Mark a particular area dirty.
Definition null_v.cpp:47
bool ToggleFullscreen(bool fullscreen) override
Change the full screen setting.
Definition null_v.cpp:68
std::optional< std::string_view > Start(const StringList &param) override
Start this driver.
Definition null_v.cpp:22
virtual void InputLoop()
Handle input logic, is CTRL pressed, should we fast-forward, etc.
void UpdateAutoResolution()
Apply resolution auto-detection and clamp to sensible defaults.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
Definition debug.h:37
int GetDriverParamInt(const StringList &parm, const char *name, int def)
Get an integer parameter the list of parameters.
Definition driver.cpp:76
Dimension _cur_resolution
The current resolution.
Definition driver.cpp:26
void UpdateWindows()
Update the continuously changing contents of the windows, such as the viewports.
Definition window.cpp:3056
static FVideoDriver_Null iFVideoDriver_Null
Factory for the null video driver.
Definition null_v.cpp:20
Base of the video driver that doesn't blit.
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:56
std::vector< std::string > StringList
Type for a list of strings.
Definition string_type.h:60
GUISettings gui
settings related to the GUI
bool autosave_on_exit
save an autosave when you quit the game, but do not ask "Do you really want to quit?...