tests/utils/fake_display.cpp

Go to the documentation of this file.
00001 /* $Id: fake_display.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Pauli Nieminen <paniemin@cc.hut.fi>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #define GETTEXT_DOMAIN "wesnoth-test"
00017 
00018 #include "fake_display.hpp"
00019 
00020 #include "game_display.hpp"
00021 #include "tod_manager.hpp"
00022 #include "map.hpp"
00023 #include "unit_map.hpp"
00024 
00025 namespace test_utils {
00026 
00027     class fake_display_manager {
00028         static fake_display_manager* manager_;
00029 
00030         CVideo video_;
00031         unit_map dummy_umap_;
00032         config dummy_cfg_;
00033         gamemap dummy_map_;
00034         tod_manager dummy_tod_;
00035         std::vector<team> dummy_teams_;
00036         const events::event_context main_event_context_;
00037 
00038 
00039         game_display disp_;
00040 
00041         public:
00042         static fake_display_manager* get_manager();
00043         game_display& get_display();
00044 
00045         fake_display_manager();
00046 //      ~fake_display_manager();
00047     };
00048 
00049     fake_display_manager* fake_display_manager::manager_ = 0;
00050 
00051     fake_display_manager* fake_display_manager::get_manager()
00052     {
00053         if (!manager_)
00054         {
00055             manager_ = new fake_display_manager();
00056         }
00057         return manager_;
00058     }
00059 
00060     fake_display_manager::fake_display_manager() :
00061         video_(CVideo::FAKE_TEST),
00062         dummy_umap_(),
00063         dummy_cfg_(),
00064         dummy_map_(dummy_cfg_,""),
00065         dummy_tod_(dummy_cfg_, 0),
00066         dummy_teams_(),
00067         main_event_context_(),
00068         disp_(dummy_umap_, video_, dummy_map_, dummy_tod_,
00069                 dummy_teams_, dummy_cfg_, dummy_cfg_)
00070     {
00071     }
00072 
00073     game_display& fake_display_manager::get_display()
00074     {
00075         return disp_;
00076     }
00077 
00078     game_display& get_fake_display(const int width, const int height)
00079     {
00080         game_display& display =
00081                 fake_display_manager::get_manager()->get_display();
00082 
00083         if(width >= 0 && height >= 0) {
00084             display.video().make_test_fake(width, height);
00085         }
00086 
00087         return display;
00088     }
00089 
00090 
00091 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:54 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs