doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEModifierStack.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 "GEApp.h"
33 #include "GEModifierStack.h"
34 
36 {
37  mCurrentModifier = -1;
38 }
39 
41 {
42  Reset ( );
43 }
44 
46 {
47  int i;
48 
49  for ( i = 0; i < mModifiers.Num ( ); i ++ )
50  {
51  delete mModifiers[i];
52  }
53 
54  mModifiers.Clear ( );
55 }
56 
58 {
59  // TODO: Add the modifier and clear all redo modifiers
60  if ( !modifier->IsValid ( ) )
61  {
62  delete modifier;
63  return false;
64  }
65 
66  while ( mCurrentModifier < mModifiers.Num ( ) - 1 )
67  {
68  delete mModifiers[mModifiers.Num()-1];
70  }
71 
72  if ( !mMergeBlock && mModifiers.Num ( ) )
73  {
75 
76  // See if the two modifiers can merge
77  if ( top->GetWindow() == modifier->GetWindow() &&
78  !idStr::Icmp ( top->GetName ( ), modifier->GetName ( ) ) &&
79  top->CanMerge ( modifier ) )
80  {
81  // Merge the two modifiers
82  if ( top->Merge ( modifier ) )
83  {
84  top->Apply ( );
85 
88 
89  delete modifier;
90  return true;
91  }
92  }
93  }
94 
95  mModifiers.Append ( modifier );
97 
98  modifier->Apply ( );
99 
100  mMergeBlock = false;
101 
102  gApp.GetProperties().Update ( );
103  gApp.GetTransformer().Update ( );
104 
105  return true;
106 }
107 
109 {
110  if ( mCurrentModifier < 0 )
111  {
112  return false;
113  }
114 
115  mModifiers[mCurrentModifier]->Undo ( );
117 
118  gApp.GetProperties().Update ( );
119  gApp.GetTransformer().Update ( );
120 
121  return true;
122 }
123 
125 {
126  if ( mCurrentModifier + 1 < mModifiers.Num ( ) )
127  {
129  mModifiers[mCurrentModifier]->Apply ( );
130  }
131 
132  gApp.GetProperties().Update ( );
133  gApp.GetTransformer().Update ( );
134 
135  return true;
136 }
137 
virtual const char * GetName(void)
Definition: GEModifier.h:70
virtual bool CanMerge(rvGEModifier *merge)
Definition: GEModifier.h:75
virtual bool Merge(rvGEModifier *merge)
Definition: GEModifier.h:80
void Update(void)
rvGEProperties & GetProperties(void)
Definition: GEApp.h:153
idWindow * GetWindow(void)
Definition: GEModifier.h:65
int i
Definition: process.py:33
int Icmp(const char *text) const
Definition: Str.h:667
rvGEApp gApp
Definition: guied.cpp:41
rvGETransformer & GetTransformer(void)
Definition: GEApp.h:158
virtual bool Apply(void)=0
virtual bool IsValid(void)
Definition: GEModifier.h:60
GLdouble GLdouble GLdouble top
Definition: qgl.h:273
idList< rvGEModifier * > mModifiers
int Append(const type &obj)
Definition: List.h:646
bool Append(rvGEModifier *modifier)
int Num(void) const
Definition: List.h:265
bool RemoveIndex(int index)
Definition: List.h:849
void Clear(void)
Definition: List.h:184