Game.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2004-2006 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #include "pent_include.h"
00020 
00021 #include "Game.h"
00022 #include "U8Game.h"
00023 #include "RemorseGame.h"
00024 #include "SettingManager.h"
00025 #include "PaletteManager.h"
00026 #include "Kernel.h"
00027 #include "MainMenuProcess.h"
00028 
00029 Game* Game::game = 0;
00030 
00031 Game::Game()
00032 {
00033         assert(game == 0);
00034         game = this;
00035 }
00036 
00037 Game::~Game()
00038 {
00039         assert(game == this);
00040         game = 0;
00041 }
00042 
00043 
00044 // static
00045 Game* Game::createGame(GameInfo* info)
00046 {
00047         switch (info->type) {
00048         case GameInfo::GAME_U8:
00049                 return new U8Game();
00050         case GameInfo::GAME_REMORSE:
00051                 return new RemorseGame();
00052         default:
00053                 CANT_HAPPEN_MSG("createGame: invalid game");
00054         }
00055 
00056         return 0;
00057 }
00058 
00059 uint32 Game::I_playEndgame(const uint8* args, unsigned int /*argsize*/)
00060 {
00061         SettingManager* settingman = SettingManager::get_instance();
00062         settingman->set("endgame", true);
00063         settingman->write();
00064 
00065         PaletteManager* palman = PaletteManager::get_instance();
00066         palman->untransformPalette(PaletteManager::Pal_Game);
00067 
00068         Process* menuproc = new MainMenuProcess();
00069         Kernel::get_instance()->addProcess(menuproc);
00070 
00071         ProcId moviepid = Game::get_instance()->playEndgameMovie();
00072         Process* movieproc = Kernel::get_instance()->getProcess(moviepid);
00073         if (movieproc) {
00074                 menuproc->waitFor(movieproc);
00075         }
00076 
00077         return 0;
00078 }

Generated on Fri Jul 27 22:27:15 2007 for pentagram by  doxygen 1.4.7