OpenTTD Source: src/video/null_v.cpp Source File

OpenTTD Source 15.3

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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
20 static FVideoDriver_Null iFVideoDriver_Null;
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
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'...");
41 BlitterFactory::SelectBlitter("null");
42 return std::nullopt;
43}
44
45 void VideoDriver_Null::Stop() { }
46
47 void VideoDriver_Null::MakeDirty(int, int, int, int) {}
48
49 void VideoDriver_Null::MainLoop()
50{
51 uint i;
52
53 for (i = 0; i < this->ticks; i++) {
54 ::GameLoop();
55 ::InputLoop();
56 ::UpdateWindows();
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. */
61 if (_settings_client.gui.autosave_on_exit) {
62 DoExitSave();
63 }
64}
65
66 bool VideoDriver_Null::ChangeResolution(int, int) { return false; }
67
68 bool VideoDriver_Null::ToggleFullscreen(bool) { return false; }
BlitterFactory::SelectBlitter
static Blitter * SelectBlitter(std::string_view name)
Find the requested blitter and return its class.
Definition factory.hpp:96
FVideoDriver_Null
Factory the null video driver.
Definition null_v.h:37
VideoDriver_Null::ticks
uint ticks
Amount of ticks to run.
Definition null_v.h:18
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
VideoDriver_Null::ChangeResolution
bool ChangeResolution(int w, int h) override
Change the resolution of the window.
Definition null_v.cpp:66
VideoDriver_Null::MakeDirty
void MakeDirty(int left, int top, int width, int height) override
Mark a particular area dirty.
Definition null_v.cpp:47
VideoDriver_Null::ToggleFullscreen
bool ToggleFullscreen(bool fullscreen) override
Change the full screen setting.
Definition null_v.cpp:68
VideoDriver_Null::Start
std::optional< std::string_view > Start(const StringList &param) override
Start this driver.
Definition null_v.cpp:22
VideoDriver::InputLoop
virtual void InputLoop()
Handle input logic, is CTRL pressed, should we fast-forward, etc.
Definition video_driver.hpp:244
VideoDriver::UpdateAutoResolution
void UpdateAutoResolution()
Apply resolution auto-detection and clamp to sensible defaults.
Definition video_driver.hpp:229
Debug
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Definition debug.h:37
GetDriverParamInt
int GetDriverParamInt(const StringList &parm, std::string_view name, int def)
Get an integer parameter the list of parameters.
Definition driver.cpp:79
_cur_resolution
Dimension _cur_resolution
The current resolution.
Definition driver.cpp:29
UpdateWindows
void UpdateWindows()
Update the continuously changing contents of the windows, such as the viewports.
Definition window.cpp:3127
iFVideoDriver_Null
static FVideoDriver_Null iFVideoDriver_Null
Factory for the null video driver.
Definition null_v.cpp:20
null_v.h
Base of the video driver that doesn't blit.
DoExitSave
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
Definition saveload.cpp:3367
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
StringList
std::vector< std::string > StringList
Type for a list of strings.
Definition string_type.h:60
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition settings_type.h:650
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:197