2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #include "../idlib/precompiled.h"
32 #include "Game_local.h"
38 This entity is targeted to complete a level, and it also handles
39 running the stats and moving the camera.
44 CLASS_DECLARATION( idEntity, idTarget_EndLevel )
45 EVENT( EV_Activate, idTarget_EndLevel::Event_Trigger )
50 idTarget_EndLevel::Spawn
53 void idTarget_EndLevel::Spawn( void ) {
57 noGui = spawnArgs.GetBool("noGui");
59 spawnArgs.GetString( "guiName", "guis/EndLevel.gui", guiName );
61 if (guiName.Length()) {
62 gui = idUserInterface::FindGui( guiName, true, false, true );
66 buttonsReleased = false;
74 idTarget_EndLevel::~idTarget_EndLevel()
77 idTarget_EndLevel::~idTarget_EndLevel() {
78 //FIXME: need to go to smart ptrs for gui allocs or the unique method
84 idTarget_EndLevel::Event_Trigger
87 void idTarget_EndLevel::Event_Trigger( idEntity *activator ) {
88 if ( gameLocal.endLevel ) {
92 // mark the endLevel, which will modify some game actions
93 // and pass control to us for drawing the stats and camera position
94 gameLocal.endLevel = this;
96 // grab the activating player view position
97 idPlayer *player = (idPlayer *)(activator);
99 initialViewOrg = player->GetEyePosition();
100 initialViewAngles = idVec3( player->viewAngles[0], player->viewAngles[1], player->viewAngles[2] );
102 // kill all the sounds
103 gameSoundWorld->StopAllSounds();
112 idTarget_EndLevel::Draw
115 void idTarget_EndLevel::Draw() {
121 renderView_t renderView;
123 memset( &renderView, 0, sizeof( renderView ) );
125 renderView.width = SCREEN_WIDTH;
126 renderView.height = SCREEN_HEIGHT;
130 renderView.fov_x = 90;
131 renderView.fov_y = gameLocal.CalcFovY( renderView.fov_x );
132 renderView.time = gameLocal.time;
135 renderView.vieworg = initialViewOrg;
136 renderView.viewaxis = idAngles(initialViewAngles).toMat3();
138 renderView.vieworg = renderEntity.origin;
139 renderView.viewaxis = renderEntity.axis;
142 gameRenderWorld->RenderScene( &renderView );
144 // draw the gui on top of the 3D view
145 gui->Redraw(gameLocal.time);
150 idTarget_EndLevel::PlayerCommand
153 void idTarget_EndLevel::PlayerCommand( int buttons ) {
154 if ( !( buttons & BUTTON_ATTACK ) ) {
155 buttonsReleased = true;
158 if ( !buttonsReleased ) {
162 // we will exit at the end of the next game frame
168 idTarget_EndLevel::ExitCommand
171 const char *idTarget_EndLevel::ExitCommand() {
172 if ( !readyToExit ) {
178 if (spawnArgs.GetString( "nextMap", "", nextMap )) {
179 sprintf( exitCommand, "map %s", nextMap.c_str() );