doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MaterialDocManager.h
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 #pragma once
29 
30 #include "MaterialEditor.h"
31 #include "MaterialModifier.h"
32 #include "MaterialDoc.h"
33 
34 class MaterialView;
35 
36 #define MAX_UNDOREDO 32
37 
42 
43 public:
44  MaterialDocManager(void);
45  ~MaterialDocManager(void);
46 
47  //Reg/UnReg Material Views
51 
52  //Material Selection
53  void SetSelectedMaterial(idMaterial* material);
55 
56  //State Checking Methods
57  bool DoesFileNeedApply(const char* filename);
58  bool DoesAnyNeedApply();
59  bool IsFileModified(const char* filename);
60  bool IsAnyModified();
61 
62  //Adding or deleting a material
63  void AddMaterial(const char* name, const char* filename, const char* sourceText = NULL, bool addUndo = true);
64  void RedoAddMaterial(const char* name, bool clearData = true);
65  void DeleteMaterial(MaterialDoc* material, bool addUndo = true);
66 
67  //Applying
68  void ApplyMaterial(MaterialDoc* materialDoc);
69  void ApplyFile(const char* filename);
70  void ApplyAll();
71 
72  //Saving
73  void SaveMaterial(MaterialDoc* material);
74  void SaveFile(const char* filename);
75  void SaveAllMaterials();
76 
77  //File Reloading
78  void ReloadFile(const char *filename);
79 
80 
81  //Used to get and/or create a MaterialDoc object for editing
82  MaterialDoc* CreateMaterialDoc(const char* materialName);
85 
86  //Copy Paste
87  void CopyMaterial(MaterialDoc* materialDoc = NULL, bool cut = false);
88  void ClearCopy();
89  bool IsCopyMaterial();
91  void PasteMaterial(const char* name, const char* filename);
92 
93  void CopyStage(MaterialDoc* materialDoc, int stageNum);
94  void ClearCopyStage();
95  bool IsCopyStage();
96  void PasteStage(MaterialDoc* materialDoc);
97  void GetCopyStageInfo(int& type, idStr& name);
98 
99  //Undo/Redo
100  void Undo();
101  bool IsUndoAvailable();
102  void ClearUndo();
103  void Redo();
104  bool IsRedoAvailable();
105  void ClearRedo();
106  void AddMaterialUndoModifier(MaterialModifier* mod, bool clearRedo = true);
108 
109  //Searching
110  bool FindMaterial(const char* name, MaterialSearchData_t* searchData, bool checkName);
111 
112  //Misc
114 
115 protected:
116 
120  enum {
134  };
135  void NotifyViews(MaterialDoc* materialDoc, int notifyType, ... );
136 
137  //Doc Notification members
138  friend MaterialDoc;
139  void MaterialChanged(MaterialDoc* materialDoc);
140  void MaterialApplied(MaterialDoc* materialDoc);
141  void MaterialSaved(MaterialDoc* materialDoc);
142  void MaterialNameChanged(const char* oldName, MaterialDoc* materialDoc);
143  void StageAdded(MaterialDoc* materialDoc, int stageNum);
144  void StageDeleted(MaterialDoc* materialDoc, int stageNum);
145  void StageMoved(MaterialDoc* materialDoc, int from, int to);
146  void AttributeChanged(MaterialDoc* materialDoc, int stage, const char* attribName);
147 
148 protected:
152 
155 
156  //Copy/Paste
159 
160  //Copy/Paste Stage
163 };
bool IsRedoAvailable()
Returns true if a redo operation is available.
MaterialDoc * GetInProgressDoc(idMaterial *material)
Checks the current list of in progress MaterialDoc objects to see if a MaterialDoc object already exi...
bool IsCopyMaterial()
Returns true if there is a material in the copy buffer.
void ClearCopy()
Clears the copy buffer for a material.
bool IsCopyStage()
Returns true if there is a stage in the copy buffer.
idStr GetUniqueMaterialName(idStr name)
Returns a unique material name given a base name.
void DeleteMaterial(MaterialDoc *material, bool addUndo=true)
Deletes a material.
void ApplyAll()
Applies all materials that have been changed.
idStr GetCopyMaterialName()
Returns the name of the material in the copy buffer.
void SaveAllMaterials()
Saves all materials that have been changed.
idList< MaterialView * > materialViews
void MaterialSaved(MaterialDoc *materialDoc)
Called when a material has been saved and notifies all views of the save.
void StageDeleted(MaterialDoc *materialDoc, int stageNum)
Called when a stage has been deleted and notifies all views of the change.
void RegisterMaterialView(MaterialView *view)
Registers an object to receive notifications about changes made to materials.
void GetCopyStageInfo(int &type, idStr &name)
Returns information about the stage in the copy buffer.
idList< MaterialModifier * > undoModifiers
Base class for modifications that can be made to a material that can be undone and redone...
void ClearCopyStage()
Clears the copy buffer for copied stages.
void Undo()
Performs the first available undo operation.
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
~MaterialDocManager(void)
Destructor for MaterialDocManager.
void NotifyViews(MaterialDoc *materialDoc, int notifyType,...)
Notifies all registered views of a material event.
bool DoesFileNeedApply(const char *filename)
Returns true if the specified file needs to be applied and false otherwise.
idHashTable< MaterialDoc * > inProgressMaterials
void UnRegisterMaterialView(MaterialView *view)
Tells the MaterialDocManager to stop sending notifications to a view.
Responsible for managing a single material that is being viewed and/or edited.
Definition: MaterialDoc.h:67
void AddMaterialUndoModifier(MaterialModifier *mod, bool clearRedo=true)
Adds an undo operation to the undo buffer.
MaterialView Interface.
Definition: MaterialView.h:38
void UnRegisterAllMaterialViews()
Unregisters all of the views that are registered to get material change notifications.
void StageAdded(MaterialDoc *materialDoc, int stageNum)
Called when a stage is added and notifies all views of the addition.
void CopyStage(MaterialDoc *materialDoc, int stageNum)
Prepares a material stage for a copy/paste operation.
#define NULL
Definition: Lib.h:88
void SaveFile(const char *filename)
Saves all materials in the specified file.
idList< MaterialModifier * > redoModifiers
void AddMaterialRedoModifier(MaterialModifier *mod)
Adds a redo operation to the redo buffer.
MaterialDoc * CreateMaterialDoc(const char *materialName)
Creates a MaterialDoc object for the specified material name.
void PasteStage(MaterialDoc *materialDoc)
Performs a paste operation of the stage in the copy buffer.
void ClearUndo()
Clears the entire undo buffer.
void MaterialChanged(MaterialDoc *materialDoc)
Called when a material has been edited and notifies all views of the change.
void SaveMaterial(MaterialDoc *material)
Saves a single material.
void Redo()
Performs the first available redo operation.
void MaterialApplied(MaterialDoc *materialDoc)
Called when a material has been applied and notifies all views of the apply.
MaterialDocManager(void)
Constructor for MaterialDocManager.
void ApplyMaterial(MaterialDoc *materialDoc)
Applys changes to a material.
Structure used to store the user defined search parameters.
void SetSelectedMaterial(idMaterial *material)
Tells the MaterialDocManager which material has been selected for editing.
void PasteMaterial(const char *name, const char *filename)
Performs a material paste operation for a material in the copy buffer.
void AttributeChanged(MaterialDoc *materialDoc, int stage, const char *attribName)
Called when a material attribute has been edited and notifies all views of the change.
void StageMoved(MaterialDoc *materialDoc, int from, int to)
Called when a stage has been movied and notifies all views of the change.
bool IsFileModified(const char *filename)
Returns true if the specified file has been modified.
void ClearRedo()
Clears the redo buffer.
const GLcharARB * name
Definition: glext.h:3629
Definition: Str.h:116
bool DoesAnyNeedApply()
Returns true if any material needs to be applied.
void ReloadFile(const char *filename)
Reloads a specified file.
Responsible for managing the materials that are being viewed and/or edited.
MaterialDoc * currentMaterial
void ApplyFile(const char *filename)
Applies all materials in the specified filename.
void AddMaterial(const char *name, const char *filename, const char *sourceText=NULL, bool addUndo=true)
Adds a material.
bool IsUndoAvailable()
Returns true if an undo operation is available.
void CopyMaterial(MaterialDoc *materialDoc=NULL, bool cut=false)
Prepares a material for a copy/cut and paste operations.
MaterialDoc * GetCurrentMaterialDoc()
bool IsAnyModified()
Returns true if any material has been modified.
void RedoAddMaterial(const char *name, bool clearData=true)
Used to redo an add material and undo a delete material.
Dictionary representation of a Material Stage.
Definition: MaterialDoc.h:37
void MaterialNameChanged(const char *oldName, MaterialDoc *materialDoc)
Called when a material name has been changed and notifies all views of the change.
bool FindMaterial(const char *name, MaterialSearchData_t *searchData, bool checkName)
Searches for a material that matches the specified search data.