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

OpenTTD Source 13.2.1

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
20 static FVideoDriver_Null iFVideoDriver_Null;
21
22 const char *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 #endif
28
29 this->UpdateAutoResolution();
30
31 this->ticks = GetDriverParamInt(parm, "ticks", 1000);
32 _screen.width = _screen.pitch = _cur_resolution.width;
33 _screen.height = _cur_resolution.height;
34 _screen.dst_ptr = nullptr;
35 ScreenSizeChanged();
36
37 /* Do not render, nor blit */
38 Debug(misc, 1, "Forcing blitter 'null'...");
39 BlitterFactory::SelectBlitter("null");
40 return nullptr;
41 }
42
43 void VideoDriver_Null::Stop() { }
44
45 void VideoDriver_Null::MakeDirty(int left, int top, int width, int height) {}
46
47 void VideoDriver_Null::MainLoop()
48 {
49 uint i;
50
51 for (i = 0; i < this->ticks; i++) {
52 ::GameLoop();
53 ::InputLoop();
54 ::UpdateWindows();
55 }
56
57 /* If requested, make a save just before exit. The normal exit-flow is
58 * not triggered from this driver, so we have to do this manually. */
59 if (_settings_client.gui.autosave_on_exit) {
60 DoExitSave();
61 }
62 }
63
64 bool VideoDriver_Null::ChangeResolution(int w, int h) { return false; }
65
66 bool VideoDriver_Null::ToggleFullscreen(bool fs) { return false; }
DoExitSave
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
Definition: saveload.cpp:3344
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:140
BlitterFactory::SelectBlitter
static Blitter * SelectBlitter(const std::string &name)
Find the requested blitter and return its class.
Definition: factory.hpp:98
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
VideoDriver_Null::ToggleFullscreen
bool ToggleFullscreen(bool fullscreen) override
Change the full screen setting.
Definition: null_v.cpp:66
VideoDriver_Null::Start
const char * Start(const StringList &param) override
Start this driver.
Definition: null_v.cpp:22
VideoDriver_Null::ticks
uint ticks
Amount of ticks to run.
Definition: null_v.h:18
UpdateWindows
void UpdateWindows()
Update the continuously changing contents of the windows, such as the viewports.
Definition: window.cpp:3075
VideoDriver::InputLoop
virtual void InputLoop()
Handle input logic, is CTRL pressed, should we fast-forward, etc.
Definition: video_driver.hpp:257
iFVideoDriver_Null
static FVideoDriver_Null iFVideoDriver_Null
Factory for the null video driver.
Definition: null_v.cpp:20
StringList
std::vector< std::string > StringList
Type for a list of strings.
Definition: string_type.h:59
VideoDriver_Null::ChangeResolution
bool ChangeResolution(int w, int h) override
Change the resolution of the window.
Definition: null_v.cpp:64
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:82
VideoDriver::UpdateAutoResolution
void UpdateAutoResolution()
Apply resolution auto-detection and clamp to sensible defaults.
Definition: video_driver.hpp:242
Debug
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
VideoDriver_Null::MakeDirty
void MakeDirty(int left, int top, int width, int height) override
Mark a particular area dirty.
Definition: null_v.cpp:45
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:43
VideoDriver_Null::MainLoop
void MainLoop() override
Perform the actual drawing.
Definition: null_v.cpp:47
_cur_resolution
Dimension _cur_resolution
The current resolution.
Definition: driver.cpp:32
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:604