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 <fstream> 00013 #include <iostream> 00014 #include <GL/gl.h> 00015 #include <glibmm/miscutils.h> 00016 00017 #include "ReplayStartMenuItem.h" 00018 #include "../Engine/ReplayReader.h" 00019 #include "../Graphics/Window.h" 00020 #include <Debug.h> 00021 00022 namespace UI 00023 { 00024 00025 ReplayStartMenuItem::ReplayStartMenuItem(std::wstring label) 00026 : GameStartMenuItem(label, "") 00027 { 00028 } 00029 00030 ReplayStartMenuItem::~ReplayStartMenuItem() 00031 { 00032 } 00033 00034 void ReplayStartMenuItem::activate() 00035 { 00036 assert(main_loop); 00037 DEBUG_MESSAGE("Replaying from a file."); 00038 std::ifstream replay_file((Glib::get_user_config_dir() + "/racer_last_replay").c_str()); 00039 if (replay_file.fail()) 00040 { 00041 // cannot load file 00042 std::cerr << "Unable to access the last replay. Perhaps it was never recorded?" 00043 << std::endl; 00044 return; 00045 } 00046 glPushAttrib(GL_ALL_ATTRIB_BITS); 00047 Engine::ReplayReader replay(replay_file); 00048 main_loop->push_scene(*(replay.get_scene())); 00049 glPopAttrib(); 00050 // reset viewport incase the window was resized during the game. 00051 glViewport(0, 0, Graphics::Window::get_instance().get_width(), 00052 Graphics::Window::get_instance().get_height()); 00053 } 00054 00055 00056 }
Generated at Mon Sep 6 00:41:13 2010 by Doxygen version 1.4.7 for Racer version svn335.