@@ -15,7 +15,6 @@ namespace tt
15
15
namespace
16
16
{
17
17
18
-
19
18
void createMenu (TextList& menuItems,
20
19
const std::vector<std::string>& textlist,
21
20
sf::RenderTarget& window,
@@ -177,7 +176,8 @@ IntroScreen::IntroScreen( ResourceManager& resmgr,
177
176
//
178
177
createMenu (_menuItems,
179
178
{
180
- " Play Game" ,
179
+ " New Game" ,
180
+ " Load Game" ,
181
181
" Settings" ,
182
182
" Exit Game"
183
183
}, _window, _font);
@@ -193,8 +193,27 @@ IntroScreen::IntroScreen( ResourceManager& resmgr,
193
193
tt::AudioLocator::sound ()->cacheAudio (TOMWILLKILL_SOUND);
194
194
}
195
195
196
+ void IntroScreen::draw ()
197
+ {
198
+ Screen::draw ();
199
+ if (_gui) _gui->draw ();
200
+ }
201
+
196
202
PollResult IntroScreen::poll (const sf::Event& e)
197
203
{
204
+ if (_gui)
205
+ {
206
+ _gui->handleEvent (e);
207
+
208
+ if (e.type == sf::Event::KeyReleased
209
+ && e.key .code == sf::Keyboard::Escape)
210
+ {
211
+ _gui.reset ();
212
+ }
213
+
214
+ return {};
215
+ }
216
+
198
217
if (e.type == sf::Event::KeyReleased
199
218
&& e.key .code == sf::Keyboard::Up)
200
219
{
@@ -225,17 +244,65 @@ PollResult IntroScreen::poll(const sf::Event& e)
225
244
default :
226
245
break ;
227
246
228
- case 0 : // play game
247
+ case 0 : // new game
229
248
{
230
249
return {true , { ScreenActionType::CHANGE_SCREEN, SCREEN_LOADING }};
231
250
}
232
251
233
- case 1 : // settings
252
+ case 1 : // load game
253
+ {
254
+ _gui = std::make_unique<tgui::Gui>(_window);
255
+
256
+ auto windowSize = _window.getSize ();
257
+ auto halfWindowWidth = windowSize.x / 2 ;
258
+
259
+ auto child = tgui::ChildWindow::create ();
260
+ child->setClientSize ({500 , 200 });
261
+ auto xpos = (_window.getSize ().x / 2 ) - (child->getSize ().x / 2 );
262
+ auto ypos = (_window.getSize ().y / 2 ) - (child->getSize ().y / 2 );
263
+ child->setPosition (xpos, ypos);
264
+ child->setTitleButtons (tgui::ChildWindow::TitleButton::None);
265
+ _gui->add (child);
266
+
267
+ auto editLbl = tgui::Label::create (" Enter name for new game" );
268
+ editLbl->setPosition (20 ,20 );
269
+ editLbl->setTextSize (30 );
270
+ child->add (editLbl);
271
+
272
+ auto editBox = tgui::EditBox::create ();
273
+ editBox->setPosition (20 ,75 );
274
+ editBox->setTextSize (30 );
275
+ editBox->setSize (460 ,35 );
276
+ child->add (editBox);
277
+
278
+ auto okBtn = tgui::Button::create (" Ok" );
279
+ okBtn->setWidgetName (" sds" );
280
+ okBtn->setSize (50 , 45 );
281
+ xpos = (child->getSize ().x / 2 ) - (okBtn->getSize ().x + 20 );
282
+ okBtn->setPosition (xpos, 125 );
283
+ child->add (okBtn);
284
+
285
+ auto cancelBtn = tgui::Button::create (" Cancel" );
286
+ cancelBtn->setSize (65 , 45 );
287
+ xpos = (child->getSize ().x / 2 ) + 20 ;
288
+ cancelBtn->setPosition (xpos, 125 );
289
+ cancelBtn->onPress ([=]
290
+ {
291
+ _gui.reset ();
292
+ });
293
+ child->add (cancelBtn);
294
+
295
+ editBox->setFocused (true );
296
+
297
+ break ;
298
+ }
299
+
300
+ case 2 : // settings
234
301
{
235
302
return {true , { ScreenActionType::CHANGE_SCREEN, SCREEN_SETTINGS }};
236
303
}
237
304
238
- case 2 : // exit
305
+ case 3 : // exit
239
306
{
240
307
tt::AudioLocator::music ()->stop (BACKGROUND_SONG);
241
308
tt::AudioLocator::sound ()->play (TOMWILLKILL_SOUND);
0 commit comments