The Battle for Wesnoth  1.17.12+dev
fake_display.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2022
3  by Pauli Nieminen <paniemin@cc.hut.fi>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #define GETTEXT_DOMAIN "wesnoth-test"
17 
19 
20 #include "game_board.hpp"
21 #include "game_config_view.hpp"
22 #include "game_display.hpp"
23 #include "reports.hpp"
24 #include "video.hpp"
25 
26 namespace wb
27 {
28 class manager;
29 }
30 
31 namespace test_utils
32 {
34 {
36 
42 
44 
45 public:
46  static fake_display_manager* get_manager();
47  game_display& get_display();
48 
50  // ~fake_display_manager();
51 };
52 
53 fake_display_manager* fake_display_manager::manager_ = 0;
54 
55 fake_display_manager* fake_display_manager::get_manager()
56 {
57  if(!manager_) {
58  manager_ = new fake_display_manager();
59  }
60 
61  return manager_;
62 }
63 
64 fake_display_manager::fake_display_manager()
65  : dummy_cfg_()
66  , dummy_cfg2_()
67  , dummy_board_(dummy_cfg2_)
68  , main_event_context_()
69  , disp_(dummy_board_, std::shared_ptr<wb::manager>(), dummy_reports, "", dummy_cfg_)
70 {
72 }
73 
75 {
76  return disp_;
77 }
78 
79 game_display& get_fake_display(const int width, const int height)
80 {
82 
83  if(width >= 0 && height >= 0) {
84  video::set_resolution({width, height});
85  }
86 
87  return display;
88 }
89 
90 } // namespace test_utils
void init(fake type)
Initialize the video subsystem.
Definition: video.cpp:87
Game board class.
Definition: game_board.hpp:52
game_display & get_fake_display(const int width, const int height)
Gets a fake test display.
static fake_display_manager * get_manager()
STL namespace.
Unit and team statistics.
bool set_resolution(const point &resolution)
Set the window resolution.
Definition: video.cpp:789
static fake_display_manager * manager_
const events::event_context main_event_context_
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:60
Definition: display.hpp:49