-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboot.cpp
88 lines (73 loc) · 2.71 KB
/
boot.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
This file is part of Heroes of Wesnoth.
Copyright (C) 2007, 2008, 2009 Jon Ander Peñalba <[email protected]>
Heroes of Wesnoth is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.
Heroes of Wesnoth 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Heroes of Wesnoth. If not, see <http://www.gnu.org/licenses/>
*/
#include "boot.hpp"
#include <ctime>
#include "tinyxml/tinyxml.h"
#include "events.hpp"
#include "graphics.hpp"
#include "xml_manager.hpp"
// events_engine
using events_engine::input;
// video_engine
using video_engine::screen;
// Loads the engine's global objects.
void startEngine(const bool fullscreen, const int width, const int height) {
screen = video_engine::Graphics::getInstance();
screen->createWindow(fullscreen, width, height);
input = events_engine::Events::getInstance();
}
// Loads the images that will be used almost every
// time the game is executed.
void loadMainImages(void) {
screen->newImage("alpha", 50);
screen->newImage("button");
screen->newImage("button-active");
screen->newImage("button-pressed");
screen->newImage("heroes-logo");
screen->newImage("wesnoth");
screen->newImage("cursors/normal");
screen->newImage("cursors/attack");
screen->newImage("cursors/move");
screen->newImage("cursors/select-illegal");
screen->newImage("cursors/wait");
}
// Loads the XML configuration files.
void loadXmlFiles(void) {
XmlManager* xml = XmlManager::getInstance();
// Load the XML files that need IDs
const char* files_with_id[] = { HEROES_XML_FILE,
ITEMS_XML_FILE,
TERRAIN_XML_FILE,
UNITS_XML_FILE };
int size = sizeof(files_with_id)/sizeof(files_with_id[0]);
for (int i=0; i<size; i++)
xml->loadFile(files_with_id[i], true);
// Load the rest of XML files
const char* other_files[] = { SMOOTH_IMAGES_XML_FILE,
SMOOTH_RULES_XML_FILE };
size = sizeof(other_files)/sizeof(other_files[0]);
for (int j=0; j<size; j++)
xml->loadFile(other_files[j], false);
}
// Starts the engine and loads the main images.
void boot(const bool fullscreen, const int width, const int height) {
srand( time(NULL) ); // Set seed for random numbers
startEngine(fullscreen, width, height);
loadMainImages();
loadXmlFiles();
}
// Exits the game.
void quit(void) {
exit(EXIT_SUCCESS);
}