GameStartMenuItem.cpp

Go to the documentation of this file.
00001 
00005 /* Copyright © 2009, 2010 James Legg.
00006     This program is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 */
00011 
00012 #include "GameStartMenuItem.h"
00013 
00014 #include <fstream>
00015 #include <GL/gl.h>
00016 
00017 #include "../Engine/LoadScene.h"
00018 #include "CarSelectScene.h"
00019 #include "../Engine/InputHandler.h"
00020 #include "../Graphics/Window.h"
00021 #include <Debug.h>
00022 
00023 namespace UI
00024 {
00025 
00026 GameStartMenuItem::GameStartMenuItem(std::wstring label,
00027                                      std::string filename)
00028     :   MenuItem(label)
00029     ,   filename(filename)
00030     ,   main_loop(0)
00031 {
00032 }
00033 
00034 GameStartMenuItem::~GameStartMenuItem()
00035 {
00036 }
00037 
00038 void GameStartMenuItem::activate()
00039 {
00040     assert(main_loop);
00041     glPushAttrib(GL_ALL_ATTRIB_BITS);
00042         // select cars
00043         CarSelectScene car_select_scene;
00044         main_loop->push_scene(car_select_scene);
00045         // If that was not cancelled, start the game now?
00046         if (!car_select_scene.get_canceled())
00047         {
00048             Engine::LoadScene<> load_scene(car_select_scene.get_choice(),
00049                                            filename,
00050                                            1);
00051             main_loop->push_scene(load_scene);
00052         }
00053     glPopAttrib();
00054     // reset viewport incase the window was resized during the game.
00055     glViewport(0, 0, Graphics::Window::get_instance().get_width(),
00056                      Graphics::Window::get_instance().get_height());
00057 }
00058 
00059 void GameStartMenuItem::set_main_loop(MainLoop & main_loop_in)
00060 {
00061     main_loop = &main_loop_in;
00062 }
00063 
00064 }

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:13 2010 by Doxygen version 1.4.7 for Racer version svn335.