doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEModifierGroup.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 "GEModifierGroup.h"
33 
35  rvGEModifier ( "Group", NULL )
36 {
37 }
38 
40 {
41  int i;
42 
43  for ( i = 0; i < mModifiers.Num(); i ++ )
44  {
45  delete mModifiers[i];
46  }
47 
48  mModifiers.Clear ( );
49 }
50 
52 {
53  // All modifiers must be the same type
54  assert ( !mModifiers.Num() || !idStr::Icmp ( mod->GetName ( ), mModifiers[0]->GetName ( ) ) );
55 
56  if ( !mModifiers.Num ( ) )
57  {
58  mName = mod->GetName ( );
59  }
60 
61  mModifiers.Append ( mod );
62  return true;
63 }
64 
66 {
67  int i;
68 
69  for ( i = 0; i < mModifiers.Num(); i ++ )
70  {
71  if ( !mModifiers[i]->IsValid ( ) )
72  {
73  return false;
74  }
75  }
76 
77  return true;
78 }
79 
81 {
82  int i;
83 
84  for ( i = 0; i < mModifiers.Num(); i ++ )
85  {
86  mModifiers[i]->Apply ( );
87  }
88 
89  return true;
90 }
91 
93 {
94  int i;
95 
96  for ( i = 0; i < mModifiers.Num(); i ++ )
97  {
98  mModifiers[i]->Undo ( );
99  }
100 
101  return true;
102 }
103 
105 {
106  rvGEModifierGroup* merge = (rvGEModifierGroup*) mergebase;
107  int i;
108 
109  if ( mModifiers.Num() != merge->mModifiers.Num ( ) )
110  {
111  return false;
112  }
113 
114  // Double check the merge is possible
115  for ( i = 0; i < mModifiers.Num(); i ++ )
116  {
117  if ( mModifiers[i]->GetWindow() != merge->mModifiers[i]->GetWindow() )
118  {
119  return false;
120  }
121 
122  if ( idStr::Icmp ( mModifiers[i]->GetName ( ), merge->mModifiers[i]->GetName ( ) ) )
123  {
124  return false;
125  }
126 
127  if ( !mModifiers[i]->CanMerge ( merge->mModifiers[i] ) )
128  {
129  return false;
130  }
131  }
132 
133  return true;
134 }
135 
137 {
138  rvGEModifierGroup* merge = (rvGEModifierGroup*) mergebase;
139  int i;
140 
141  // Double check the merge is possible
142  for ( i = 0; i < mModifiers.Num(); i ++ )
143  {
144  mModifiers[i]->Merge ( merge->mModifiers[i] );
145  }
146 
147  return true;
148 }
assert(prefInfo.fullscreenBtn)
virtual const char * GetName(void)
Definition: GEModifier.h:70
virtual bool Apply(void)
idWindow * GetWindow(void)
Definition: GEModifier.h:65
int i
Definition: process.py:33
int Icmp(const char *text) const
Definition: Str.h:667
virtual bool Merge(rvGEModifier *merge)
bool Append(rvGEModifier *mod)
#define NULL
Definition: Lib.h:88
idList< rvGEModifier * > mModifiers
int Append(const type &obj)
Definition: List.h:646
idStr mName
Definition: GEModifier.h:57
int Num(void) const
Definition: List.h:265
virtual bool CanMerge(rvGEModifier *merge)
virtual bool Undo(void)
virtual bool IsValid(void)
void Clear(void)
Definition: List.h:184