xoreos  0.0.5
game.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include <cassert>
26 
27 #include "src/events/events.h"
28 
29 #include "src/aurora/talkman.h"
30 
31 #include "src/graphics/graphics.h"
32 #include "src/graphics/font.h"
33 
36 
38 
39 #include "src/engines/sonic/game.h"
40 #include "src/engines/sonic/util.h"
43 
44 namespace Engines {
45 
46 namespace Sonic {
47 
48 Game::Game(SonicEngine &engine, ::Engines::Console &console) :
49  _engine(&engine), _console(&console) {
50 
52  _engine->getLanguage(language);
53 
54  _guiFont = loadFont("guifont", "jillcan13sh", false);
55 
56  if (language == Aurora::kLanguageJapanese)
57  _quoteFont = loadFont("quotefont", "jillcan12sh", false);
58  else
59  _quoteFont = loadFont("quotefont", "jillcan12rg", true);
60 }
61 
63 }
64 
66  assert(_module);
67 
68  return *_module;
69 }
70 
71 void Game::run() {
72  if (!showLicenseSplash())
73  return;
74  if (!showTitle())
75  return;
76  if (!showMainMenu())
77  return;
78  if (!showQuote())
79  return;
80  if (!showChapter1())
81  return;
82 
83  _module.reset(new Module(*_console));
84 
85  runModule();
86 
87  _module.reset();
88 }
89 
91  _module->run();
92 }
93 
95  while (!EventMan.quitRequested()) {
96  Events::Event event;
97  while (EventMan.pollEvent(event)) {
98  if (event.type == Events::kEventMouseUp)
99  return true;
100  }
101 
102  EventMan.delay(10);
103  }
104 
105  return !EventMan.quitRequested();
106 }
107 
109  Graphics::Aurora::GUIQuad top("nintendosplash" , 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);
110  Graphics::Aurora::GUIQuad bot("actimaginesplash", 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);
111 
114 
115  GfxMan.lockFrame();
116  top.show();
117  bot.show();
118  GfxMan.unlockFrame();
119 
120  if (!waitClick())
121  return false;
122 
123  GfxMan.lockFrame();
124  top.hide();
125  bot.hide();
126 
127  return true;
128 }
129 
131  Graphics::Aurora::GUIQuad top("introscr_top", 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);
132  Graphics::Aurora::GUIQuad bot("introscr_bot", 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);
133 
136 
137  top.show();
138  bot.show();
139  GfxMan.unlockFrame();
140 
141  if (!waitClick())
142  return false;
143 
144  GfxMan.lockFrame();
145  top.hide();
146  bot.hide();
147 
148  return true;
149 }
150 
152  Graphics::Aurora::GUIQuad top("introscr_top" , 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);
153  Graphics::Aurora::GUIQuad bot("startupscrbot", 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);
154 
155  top.setPosition(kTopScreenX , kTopScreenY , 0.0f);
157 
158  top.show();
159  bot.show();
160 
161 
162  Graphics::Aurora::TextureHandle buttonTexture = loadNCGR("main_pnl_off", "gui_main_pnl", 8, 2,
163  "00", "01", "02", "03", "04", (const char *) 0, (const char *) 0, (const char *) 0,
164  "10", "11", "12", "13", "14", "15", "16", "17");
165 
166  Graphics::Aurora::GUIQuad button(buttonTexture, 0.0f, 0.0f, 240.0f, 48.0f, 0.0f, 1.0f, 1.0f, 0.0f);
167 
168  button.setPosition(-120.0f, -120.0f, -1.0f);
169  button.show();
170 
171 
172  Graphics::Aurora::Text buttonText(_guiFont, 240.0f, 48.0f, TalkMan.getString(15860), 1.0f, 1.0f, 1.0f, 1.0f,
174  buttonText.setPosition(-120.0f, -120.0f, -2.0f);
175  buttonText.show();
176 
177 
178  Graphics::Aurora::Text helpText(_guiFont, kScreenWidth, kScreenHeight, TalkMan.getString(18707), 1.0f, 1.0f, 1.0f, 1.0f,
180  helpText.setPosition(kBottomScreenX, kBottomScreenY, -2.0f);
181  helpText.show();
182 
183 
184  GfxMan.unlockFrame();
185 
186  if (!waitClick())
187  return false;
188 
189  GfxMan.lockFrame();
190  helpText.hide();
191  buttonText.hide();
192  button.hide();
193  top.hide();
194  bot.hide();
195 
196  return true;
197 }
198 
201  _engine->getLanguage(language);
202 
203  Common::UString quote = TalkMan.getString(21712);
204 
205  const float halign = (language == Aurora::kLanguageJapanese) ?
207  Graphics::Aurora::Text quoteText(_quoteFont, kScreenWidth, kScreenHeight, quote, 1.0f, 1.0f, 1.0f, 1.0f,
209 
210  quoteText.setPosition(kTopScreenX, kTopScreenY, 0.0f);
211  quoteText.show();
212 
213  GfxMan.unlockFrame();
214 
215  if (!waitClick())
216  return false;
217 
218  GfxMan.lockFrame();
219  quoteText.hide();
220 
221  return true;
222 }
223 
225  Graphics::Aurora::GUIQuad top("chap1scr_top", 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);
226  Graphics::Aurora::GUIQuad bot("chap1scr_bot", 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);
227 
230 
231  top.show();
232  bot.show();
233  GfxMan.unlockFrame();
234 
235  if (!waitClick())
236  return false;
237 
238  GfxMan.lockFrame();
239  top.hide();
240  bot.hide();
241  GfxMan.unlockFrame();
242 
243  return true;
244 }
245 
246 } // End of namespace Sonic
247 
248 } // End of namespace Engines
static const float kScreenHeight
Definition: types.h:35
Graphics::Aurora::TextureHandle loadNCGR(const Common::UString &name, const Common::UString &nclr, uint32 width, uint32 height,...)
Definition: util.cpp:50
virtual void show()
Show the object.
Definition: renderable.cpp:114
The global graphics manager.
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
virtual void hide()
Hide the object.
Definition: renderable.cpp:123
bool showMainMenu()
Definition: game.cpp:151
A class holding an UTF-8 string.
Definition: ustring.h:48
Common::ScopedPtr< Module > _module
Definition: game.h:54
Graphics::Aurora::FontHandle loadFont(const Common::UString &name, const Common::UString &nftr, bool invert)
Definition: util.cpp:87
A text object.
::Engines::Console * _console
Definition: game.h:56
The context handling the gameplay in Sonic Chronicles: The Dark Brotherhood.
SonicEngine * _engine
Definition: game.h:52
bool showChapter1()
Definition: game.cpp:224
Engine class handling Sonic Chronicles: The Dark Brotherhood.
Language
Definition: language.h:46
SDL_Event Event
Definition: types.h:42
static const float kBottomScreenX
Definition: types.h:40
bool getLanguage(Aurora::Language &language) const
Return the game&#39;s current language.
Definition: sonic.cpp:135
Mouse button was released.
Definition: types.h:50
A text object.
Definition: text.h:42
void setPosition(float x, float y, float z=-FLT_MAX)
Definition: text.cpp:172
static const float kScreenWidth
Definition: types.h:34
The global events manager.
const float kHAlignLeft
Definition: types.h:42
bool showLicenseSplash()
Definition: game.cpp:108
static const float kBottomScreenY
Definition: types.h:41
Generic Aurora engines (debug) console.
bool waitClick()
Definition: game.cpp:94
const float kVAlignBottom
Definition: types.h:48
const float kHAlignCenter
Definition: types.h:43
#define EventMan
Shortcut for accessing the events manager.
Definition: events.h:210
const float kVAlignMiddle
Definition: types.h:47
Sonic Chronicles: The Dark Brotherhood utility functions.
The context needed to run a Sonic Chronicles: The Dark Brotherhood module.
A Sonic module.
Definition: module.h:45
void runModule()
Definition: game.cpp:90
The global talk manager for Aurora strings.
Game(SonicEngine &engine, ::Engines::Console &console)
Definition: game.cpp:48
static const float kTopScreenX
Definition: types.h:37
void setPosition(float x, float y, float z=-FLT_MAX)
Set the current position of the quad.
Definition: guiquad.cpp:116
A textured quad for a GUI element.
A handle to a texture.
Definition: texturehandle.h:51
Graphics::Aurora::FontHandle _quoteFont
Definition: game.h:59
Module & getModule()
Return the module context.
Definition: game.cpp:65
A font.
static const float kTopScreenY
Definition: types.h:38
#define GfxMan
Shortcut for accessing the graphics manager.
Definition: graphics.h:299
Graphics::Aurora::FontHandle _guiFont
Definition: game.h:58