doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EndLevel.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
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.
13 
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.
18 
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/>.
21 
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.
23 
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.
25 
26 ===========================================================================
27 */
28 
29 #include "../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "Game_local.h"
33 
34 /*
35 
36  game_endlevel.cpp
37 
38  This entity is targeted to complete a level, and it also handles
39  running the stats and moving the camera.
40 
41 */
42 
43 
45  EVENT( EV_Activate, idTarget_EndLevel::Event_Trigger )
47 
48 /*
49 ================
50 idTarget_EndLevel::Spawn
51 ================
52 */
53 void idTarget_EndLevel::Spawn( void ) {
54  idStr guiName;
55 
56  gui = NULL;
57  noGui = spawnArgs.GetBool("noGui");
58  if (!noGui) {
59  spawnArgs.GetString( "guiName", "guis/EndLevel.gui", guiName );
60 
61  if (guiName.Length()) {
62  gui = idUserInterface::FindGui( guiName, true, false, true );
63  }
64  }
65 
66  buttonsReleased = false;
67  readyToExit = false;
68 
69  exitCommand = "";
70 }
71 
72 /*
73 ================
74 idTarget_EndLevel::~idTarget_EndLevel()
75 ================
76 */
78  //FIXME: need to go to smart ptrs for gui allocs or the unique method
79  //delete gui;
80 }
81 
82 /*
83 ================
84 idTarget_EndLevel::Event_Trigger
85 ================
86 */
88  if ( gameLocal.endLevel ) {
89  return;
90  }
91 
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;
95 
96  // grab the activating player view position
97  idPlayer *player = (idPlayer *)(activator);
98 
99  initialViewOrg = player->GetEyePosition();
100  initialViewAngles = idVec3( player->viewAngles[0], player->viewAngles[1], player->viewAngles[2] );
101 
102  // kill all the sounds
104 
105  if ( noGui ) {
106  readyToExit = true;
107  }
108 }
109 
110 /*
111 ================
112 idTarget_EndLevel::Draw
113 ================
114 */
116 
117  if (noGui) {
118  return;
119  }
120 
122 
123  memset( &renderView, 0, sizeof( renderView ) );
124 
125  renderView.width = SCREEN_WIDTH;
126  renderView.height = SCREEN_HEIGHT;
127  renderView.x = 0;
128  renderView.y = 0;
129 
130  renderView.fov_x = 90;
131  renderView.fov_y = gameLocal.CalcFovY( renderView.fov_x );
132  renderView.time = gameLocal.time;
133 
134 #if 0
135  renderView.vieworg = initialViewOrg;
136  renderView.viewaxis = idAngles(initialViewAngles).toMat3();
137 #else
138  renderView.vieworg = renderEntity.origin;
139  renderView.viewaxis = renderEntity.axis;
140 #endif
141 
142  gameRenderWorld->RenderScene( &renderView );
143 
144  // draw the gui on top of the 3D view
146 }
147 
148 /*
149 ================
150 idTarget_EndLevel::PlayerCommand
151 ================
152 */
153 void idTarget_EndLevel::PlayerCommand( int buttons ) {
154  if ( !( buttons & BUTTON_ATTACK ) ) {
155  buttonsReleased = true;
156  return;
157  }
158  if ( !buttonsReleased ) {
159  return;
160  }
161 
162  // we will exit at the end of the next game frame
163  readyToExit = true;
164 }
165 
166 /*
167 ================
168 idTarget_EndLevel::ExitCommand
169 ================
170 */
172  if ( !readyToExit ) {
173  return NULL;
174  }
175 
176  idStr nextMap;
177 
178  if (spawnArgs.GetString( "nextMap", "", nextMap )) {
179  sprintf( exitCommand, "map %s", nextMap.c_str() );
180  } else {
181  exitCommand = "";
182  }
183 
184  return exitCommand;
185 }
renderEntity_t renderEntity
Definition: Entity.h:371
bool buttonsReleased
Definition: EndLevel.h:58
const idEventDef EV_Activate("activate","e")
int Length(void) const
Definition: Str.h:702
const int SCREEN_HEIGHT
Definition: RenderSystem.h:154
idVec3 GetEyePosition(void) const
Definition: Vector.h:316
idDict spawnArgs
Definition: Entity.h:122
void Event_Trigger(idEntity *activator)
Definition: EndLevel.cpp:87
idSoundWorld * gameSoundWorld
Definition: Game_local.cpp:56
#define EVENT(event, function)
Definition: Class.h:53
const int BUTTON_ATTACK
Definition: UsercmdGen.h:44
const char * GetString(const char *key, const char *defaultString="") const
Definition: Dict.h:240
#define NULL
Definition: Lib.h:88
const char * ExitCommand()
Definition: EndLevel.cpp:171
virtual void Redraw(int time)=0
idGameLocal gameLocal
Definition: Game_local.cpp:64
#define END_CLASS
Definition: Class.h:54
idVec3 initialViewAngles
Definition: EndLevel.h:53
idStr exitCommand
Definition: EndLevel.h:50
idVec3 vieworg
Definition: RenderWorld.h:215
renderView_t * renderView
Definition: Entity.h:129
const int SCREEN_WIDTH
Definition: RenderSystem.h:153
idUserInterface * gui
Definition: EndLevel.h:56
idAngles viewAngles
Definition: Player.h:258
void PlayerCommand(int buttons)
Definition: EndLevel.cpp:153
#define CLASS_DECLARATION(nameofsuperclass, nameofclass)
Definition: Class.h:110
Definition: Str.h:116
idVec3 initialViewOrg
Definition: EndLevel.h:52
const char * c_str(void) const
Definition: Str.h:487
virtual void RenderScene(const renderView_t *renderView)=0
idRenderWorld * gameRenderWorld
Definition: Game_local.cpp:55
idMat3 viewaxis
Definition: RenderWorld.h:216
int sprintf(idStr &string, const char *fmt,...)
Definition: Str.cpp:1528
virtual void StopAllSounds(void)=0