doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MaterialModifier.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 #include "../../idlib/precompiled.h"
29 #pragma hdrstop
30 
31 #include "MaterialModifier.h"
32 #include "MaterialDocManager.h"
33 #include "MaterialTreeView.h"
34 
36 //MaterialModifier
38 
42 MaterialModifier::MaterialModifier(MaterialDocManager* manager, const char* materialName) {
43  this->manager = manager;
44  this->materialName = materialName;
45 }
46 
48 //AttributeMaterialModifier
50 
54 AttributeMaterialModifier::AttributeMaterialModifier(MaterialDocManager* manager, const char* materialName, int stage, const char* key)
55 : MaterialModifier(manager, materialName) {
56 
57  this->stage = stage;
58  this->key = key;
59 
60 }
61 
63 //AttributeMaterialModifierString
65 
69 AttributeMaterialModifierString::AttributeMaterialModifierString(MaterialDocManager* manager, const char* materialName, int stage, const char* key, const char* value, const char* oldValue)
70 : AttributeMaterialModifier(manager, materialName, stage, key) {
71 
72  this->value = value;
73  this->oldValue = oldValue;
74 }
75 
81  material->SetAttribute(stage, key, oldValue, false);
82 }
83 
89  material->SetAttribute(stage, key, value, false);
90 }
91 
93 //AttributeMaterialModifierBool
95 
99 AttributeMaterialModifierBool::AttributeMaterialModifierBool(MaterialDocManager* manager, const char* materialName, int stage, const char* key, bool value, bool oldValue)
100 : AttributeMaterialModifier(manager, materialName, stage, key) {
101 
102  this->value = value;
103  this->oldValue = oldValue;
104 }
105 
111  material->SetAttributeBool(stage, key, oldValue, false);
112 }
113 
119  material->SetAttributeBool(stage, key, value, false);
120 }
121 
123 //StageMoveModifier
125 
129 StageMoveModifier::StageMoveModifier(MaterialDocManager* manager, const char* materialName, int from, int to)
130 : MaterialModifier(manager, materialName) {
131  this->from = from;
132  this->to = to;
133 }
134 
140  material->MoveStage(to, from, false);
141 }
142 
148  material->MoveStage(from, to, false);
149 }
150 
152 //StageDeleteModifier
154 
158 StageDeleteModifier::StageDeleteModifier(MaterialDocManager* manager, const char* materialName, int stageNum, idDict stageData)
159 : MaterialModifier(manager, materialName) {
160  this->stageNum = stageNum;
161  this->stageData = stageData;
162 }
163 
168 
170  material->InsertStage(stageNum, stageData.GetInt("stagetype"), stageData.GetString("name"), false);
171  material->SetData(stageNum, &stageData);
172 
173 }
174 
180  material->RemoveStage(stageNum, false);
181 }
182 
184 //StageInsertModifier
186 
190 StageInsertModifier::StageInsertModifier(MaterialDocManager* manager, const char* materialName, int stageNum, int stageType, const char* stageName)
191 : MaterialModifier(manager, materialName) {
192  this->stageNum = stageNum;
193  this->stageType = stageType;
194  this->stageName = stageName;
195 }
196 
201 
203  material->RemoveStage(stageNum, false);
204 }
205 
211  material->InsertStage(stageNum, stageType, stageName, false);
212 }
213 
215 //AddMaterialModifier
217 
221 AddMaterialModifier::AddMaterialModifier(MaterialDocManager* manager, const char* materialName, const char* materialFile)
222 : MaterialModifier(manager, materialName) {
223  this->materialFile = materialFile;
224 }
225 
231  manager->DeleteMaterial(material, false);
232 }
233 
239 }
240 
242 //DeleteMaterialModifier
244 
249 : MaterialModifier(manager, materialName) {
250 }
251 
256 
258 }
259 
264 
266  manager->DeleteMaterial(material, false);
267 }
268 
269 
271 //MoveMaterialModifier
273 
277 MoveMaterialModifier::MoveMaterialModifier(MaterialDocManager* manager, const char* materialName, const char* materialFile, const char* copyMaterial)
278 : MaterialModifier(manager, materialName) {
279  this->materialFile = materialFile;
280  this->copyMaterial = copyMaterial;
281 }
282 
287 
288  //Delete New Material
290  manager->DeleteMaterial(material, false);
291 
292  //RedoAdd Old Material
294 }
295 
300  //Delete Old Material
302  manager->DeleteMaterial(material, false);
303 
304  //Redo Add New Material
306 }
307 
309 //RenameMaterialModifier
311 
314 RenameMaterialModifier::RenameMaterialModifier(MaterialDocManager* manager, const char* materialName, const char* oldName)
315 : MaterialModifier(manager, materialName) {
316  this->oldName = oldName;
317 }
318 
323 
325  material->SetMaterialName(oldName, false);
326 }
327 
332 
334  material->SetMaterialName(materialName, false);
335 }
336 
338 //AddMaterialFolderModifier
340 
343 AddMaterialFolderModifier::AddMaterialFolderModifier(MaterialDocManager* manager, const char* materialName, MaterialTreeView* view, HTREEITEM item, HTREEITEM parent)
344 : MaterialModifier(manager, materialName) {
345  this->view = view;
346  this->item = item;
347  this->parent = parent;
348 }
349 
354  view->DeleteFolder(item, false);
355 }
356 
362 }
363 
365 //RenameMaterialFolderModifier
367 
371 RenameMaterialFolderModifier::RenameMaterialFolderModifier(MaterialDocManager* manager, const char* materialName, MaterialTreeView* view, HTREEITEM item, const char* oldName)
372 : MaterialModifier(manager, materialName) {
373  this->view = view;
374  this->item = item;
375  this->oldName = oldName;
376 }
377 
383 }
384 
390 }
391 
392 
394 //DeleteMaterialFolderModifier
396 
400 DeleteMaterialFolderModifier::DeleteMaterialFolderModifier(MaterialDocManager* manager, const char* materialName, MaterialTreeView* view, HTREEITEM parent, idStrList* affectedMaterials)
401 : MaterialModifier(manager, materialName) {
402  this->view = view;
403  this->parent = parent;
404  this->affectedMaterials = *affectedMaterials;
405 }
406 
411 
412  //Add the folder back and save the folder position for the redo
414 
415  //Add each of the children back
416  for(int i = 0; i < affectedMaterials.Num(); i++) {
418  }
419 }
420 
425 
426  view->DeleteFolder(item, false);
427 }
428 
GLsizei const GLfloat * value
Definition: glext.h:3614
int GetInt(const char *key, const char *defaultString="0") const
Definition: Dict.h:252
MaterialDocManager * manager
Base class for Undo/Redo operations for attribute changes.
virtual void Undo()
Performs an undo operation of a deleted material folder.
virtual void Redo()
Performs a redo operation of a renamed material folder.
void DeleteMaterial(MaterialDoc *material, bool addUndo=true)
Deletes a material.
virtual void Redo()
Performs a redo operation of a string attribute change.
virtual void Redo()
Performs a redo operation of a renamed material.
RenameMaterialFolderModifier(MaterialDocManager *manager, const char *materialName, MaterialTreeView *view, HTREEITEM item, const char *oldName)
Constructor for RenameMaterialFolderModifier.
virtual void Redo()
Performs a redo operation of a moved stage.
Base class for modifications that can be made to a material that can be undone and redone...
virtual void Undo()
Performs an undo operation of a deleted material.
void MoveStage(int from, int to, bool addUndo=true)
Moves a stage from one location to another.
virtual void Undo()
Performs an undo operation of a string attribute change.
HTREEITEM AddFolder(const char *name, HTREEITEM parent)
Adds a new material folder.
int i
Definition: process.py:33
virtual void Undo()
Performs an undo operation of a stage move.
StageInsertModifier(MaterialDocManager *manager, const char *materialName, int stageNum, int stageType, const char *stageName)
Constructor for StageInsertModifier.
virtual void Undo()
Performs an undo operation of a boolean attribute change.
StageDeleteModifier(MaterialDocManager *manager, const char *materialName, int stageNum, idDict stageData)
Constructor for StageDeleteModifier.
void RemoveStage(int stage, bool addUndo=true)
Removes a stage from the material.
void InsertStage(int stage, int stageType, const char *stageName, bool addUndo=true)
Inserts a new stage to the material at a specified location.
AddMaterialModifier(MaterialDocManager *manager, const char *materialName, const char *materialFile)
Constructor for AddMaterialModifier.
StageMoveModifier(MaterialDocManager *manager, const char *materialName, int from, int to)
Constructor for StageMoveModifier.
virtual void Redo()
Performs a redo operation of a moved material.
void SetAttribute(int stage, const char *attribName, const char *value, bool addUndo=true)
Sets an attribute string in the material or a stage.
DeleteMaterialFolderModifier(MaterialDocManager *manager, const char *materialName, MaterialTreeView *view, HTREEITEM parent, idStrList *affectedMaterials)
Constructor for DeleteMaterialFolderModifier.
Responsible for managing a single material that is being viewed and/or edited.
Definition: MaterialDoc.h:67
void DeleteFolder(HTREEITEM item, bool addUndo=true)
Deletes a given folder.
const char * GetString(const char *key, const char *defaultString="") const
Definition: Dict.h:240
AddMaterialFolderModifier(MaterialDocManager *manager, const char *materialName, MaterialTreeView *view, HTREEITEM item, HTREEITEM parent)
Constructor for AddMaterialFolderModifier.
DeleteMaterialModifier(MaterialDocManager *manager, const char *materialName)
Constructor for DeleteMaterialModifier.
virtual void Redo()
Performs a redo operation of an inserted stage.
AttributeMaterialModifierString(MaterialDocManager *manager, const char *materialName, int stage, const char *key, const char *value, const char *oldValue)
Constructor for AttributeMaterialModifierString.
Definition: Dict.h:65
void SetMaterialName(const char *materialName, bool addUndo=true)
Sets the material name.
RenameMaterialModifier(MaterialDocManager *manager, const char *materialName, const char *oldName)
Constructor for RenameMaterialModifier.
virtual void Redo()
Performs a redo operation of an added material.
virtual void Undo()
Performs an undo operation of a renamed material folder.
virtual void Undo()
Performs an undo operation of a moved material.
MaterialDoc * CreateMaterialDoc(const char *materialName)
Creates a MaterialDoc object for the specified material name.
virtual void Undo()
Performs an undo operation of an added material folder.
MoveMaterialModifier(MaterialDocManager *manager, const char *materialName, const char *materialFile, const char *copyMaterial)
Constructor for MoveMaterialModifier.
void SetAttributeBool(int stage, const char *attribName, bool value, bool addUndo=true)
Sets an attribute bool in the material or a stage.
virtual void Undo()
Performs an undo operation of a renamed material.
virtual void Undo()
Performs an undo operation of an inserted stage.
virtual void Undo()
Performs an undo operation of an added material.
A tree view of all the materials that have been defined.
virtual void Redo()
Performs a redo operation of a deleted stage.
void SetData(int stage, idDict *data)
Sets the entire dictionary for a material or stage.
int Num(void) const
Definition: List.h:265
virtual void Redo()
Performs a redo operation of a boolean attribute change.
virtual void Redo()
Performs a redo operation of a deleted material.
Responsible for managing the materials that are being viewed and/or edited.
AttributeMaterialModifierBool(MaterialDocManager *manager, const char *materialName, int stage, const char *key, bool value, bool oldValue)
Constructor for AttributeMaterialModifierBool.
virtual void Undo()
Performs an undo operation of a deleted stage.
AttributeMaterialModifier(MaterialDocManager *manager, const char *materialName, int stage, const char *key)
Constructor for AttributeMaterialModifier.
virtual void Redo()
Performs a redo operation of an added material folder.
MaterialModifier(MaterialDocManager *manager, const char *materialName)
Constructor for MaterialModifier.
virtual void Redo()
Performs a redo operation of a deleted material folder.
void RenameFolder(HTREEITEM item, const char *name)
Renames a material folder.
void RedoAddMaterial(const char *name, bool clearData=true)
Used to redo an add material and undo a delete material.