Debian Codegraph @

src/menumanager.cpp

raw symbols SCIP
1 #include "menumanager.h"
2
3 #include "ui/menusystem.h"
4 #include "ui/menu.h"
5 #include "ui/menuaction.h"
6
7 #include "controloptions.h"
8 #include "gameoptions.h"
9 #include "videooptions.h"
10
11 #include "input.h"
12 #include "main.h"
13 #include "sdl_driver.h"
14
15 MenuManager::MenuManager(Main &newMain)
16 : main(newMain)
17 {
18 menuSystem = new MenuSystem(main.getSDLDriver().getSDLInput());
19
20 controlOptions = new ControlOptions(main);
21 videoOptions = new VideoOptions();
22 gameOptions = new GameOptions();
23
24 Menu *m = new Menu(Menu::NONE, "qonk");
25 m->addLink("singleplayer", Menu::SINGLEPLAYER);
26 m->addLink("multiplayer", Menu::MULTIPLAYER);
27 m->addLink("options", Menu::OPTIONS);
28 m->addAction("quit", new QuitAction(main));
29 menuSystem->addMenu(Menu::MAIN, m);
30
31 m = new Menu(Menu::MAIN, "singleplayer");
32 m->addAction("planets", gameOptions->getPlanetsAction());
33 m->addAction("enemies", gameOptions->getPlayersAction());
34 m->addAction("show enemies", gameOptions->getEnemyVisibilityAction());
35 m->addAction("start game", gameOptions->getStartSinglePlayerGameAction(main));
36 m->addBackLink();
37 menuSystem->addMenu(Menu::SINGLEPLAYER, m);
38
39 m = new Menu(Menu::MAIN, "multiplayer");
40 m->addLink("this is not", Menu::NONE);
41 m->addLink("yet implemented.", Menu::NONE);
42 m->addBackLink();
43 menuSystem->addMenu(Menu::MULTIPLAYER, m);
44
45 m = new Menu(Menu::MAIN, "options");
46 m->addLink("audio", Menu::AUDIO_OPTIONS);
47 m->addLink("video", Menu::VIDEO_OPTIONS);
48 m->addLink("controls", Menu::CONTROL_OPTIONS);
49 m->addBackLink();
50 menuSystem->addMenu(Menu::OPTIONS, m);
51
52 m = new Menu(Menu::OPTIONS, "audio");
53 m->addLink("this is not", Menu::NONE);
54 m->addLink("yet implemented.", Menu::NONE);
55 m->addBackLink();
56 menuSystem->addMenu(Menu::AUDIO_OPTIONS, m);
57
58 m = new Menu(Menu::OPTIONS, "video");
59 m->addAction("screen size:", videoOptions->getScreenSizeAction());
60 m->addAction("toggle fullscreen", videoOptions->getToggleFullscreenAction());
61 m->addAction("apply", videoOptions->getApplyVideoOptionsAction(main));
62 m->addBackLink();
63 menuSystem->addMenu(Menu::VIDEO_OPTIONS, m);
64
65 m = new Menu(Menu::OPTIONS, "controls", 10);
66 m->addAction("select all", controlOptions->getControlAction(GA_SELECT_ALL));
67 m->addAction("show enemies", controlOptions->getControlAction(GA_TOGGLE_ENEMY_VISIBILITY));
68 m->addAction("selection", controlOptions->getControlAction(GA_SELECTION));
69 m->addAction("cursor up", controlOptions->getControlAction(GA_CURSOR_UP));
70 m->addAction("cursor down", controlOptions->getControlAction(GA_CURSOR_DOWN));
71 m->addAction("cursor left", controlOptions->getControlAction(GA_CURSOR_LEFT));
72 m->addAction("cursor right", controlOptions->getControlAction(GA_CURSOR_RIGHT));
73 m->addAction("select nearest", controlOptions->getControlAction(GA_SELECT_NEAREST_PLANET));
74 m->addAction("move to nearest", controlOptions->getControlAction(GA_MOVE_TO_NEAREST_PLANET));
75 m->addAction("single ship mode", controlOptions->getControlAction(GA_SET_FLEET_STRENGTH_SINGLE));
76 m->addBackLink();
77 menuSystem->addMenu(Menu::CONTROL_OPTIONS, m);
78
79 menuSystem->resize();
80
81 menuSystem->enter();
82 }
83
84 MenuManager::~MenuManager()
85 {
86 delete menuSystem;
87
88 delete gameOptions;
89 delete videoOptions;
90 }
91
92 void
93 MenuManager::showSinglePlayerMenu()
94 {
95 menuSystem->enter(Menu::SINGLEPLAYER);
96 }
97
98 void
99 MenuManager::show()
100 {
101 menuSystem->enter();
102 }
103
104 void
105 MenuManager::hide()
106 {
107 menuSystem->enter(Menu::NONE);
108 }
109
110 bool
111 MenuManager::isVisible() const
112 {
113 return menuSystem->isVisible();
114 }
115
116 void
117 MenuManager::resize()
118 {
119 menuSystem->resize();
120 }
121
122 void
123 MenuManager::render()
124 {
125 menuSystem->render();
126 }
127
128 bool
129 MenuManager::update()
130 {
131 return menuSystem->update();
132 }
133
134 void
135 MenuManager::senseFinished(bool b)
136 {
137 if (b)
138 menuSystem->invoke();
139 else
140 menuSystem->cancel();
141 }
142
143 void
144 QuitAction::invoke()
145 {
146 main.quit();
147 }