-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenu_main.cpp
84 lines (71 loc) · 2.3 KB
/
menu_main.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
/*
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 "menu_main.hpp"
#include "battle.hpp"
#include "boot.hpp"
#include "editor.hpp"
#include "events.hpp"
#include "graphics.hpp"
#include "menu.hpp"
#include "mission.hpp"
//events_engine
using events_engine::mouse;
using events_engine::MOUSE_X;
using events_engine::MOUSE_Y;
using events_engine::MOUSE_BUTTON;
// video_engine
using video_engine::screen;
SDL_Rect background_pos, menu_pos, logo_pos;
Menu *main_menu;
// Set's all the position variables that the menu needs.
void setPositions(void) {
menu_pos.x = 700;
menu_pos.y = 450;
menu_pos.w = 108;
menu_pos.h = 22;
background_pos.x = 0;
background_pos.y = 0;
background_pos.w = 1024;
background_pos.h = 768;
logo_pos.x = 120;
logo_pos.y = 15;
logo_pos.w = 777;
logo_pos.h = 385;
}
// Draws the menu's background
void drawBackground(void) {
screen->draw("wesnoth", background_pos);
screen->draw("heroes-logo", logo_pos);
screen->write("v0.1.2", 965, 735);
screen->write("Dedicated to Patricia Ruiz for being next to me all this time.", 200, 500);
screen->write("I will never be able to thank you enough.", 200, 520);
}
// Creates the menu.
void createMenu(void) {
main_menu = new Menu(menu_pos);
main_menu->addButton("Mission 1", mission1);
main_menu->addButton("Mission 2", mission2);
main_menu->addButton("Mission 3", mission3);
main_menu->addButton("Battle", createDefaultBattle);
main_menu->addButton("Editor", startEditor);
main_menu->addButton("Quit", quit);
main_menu->setBackground(drawBackground);
}
// Creates and starts the main menu.
void startMainMenu(void) {
setPositions();
createMenu();
main_menu->start();
delete main_menu;
}