doom3-gpl
Doom 3 GPL source release
|
Responsible for managing a single material that is being viewed and/or edited. More...
#include <MaterialDoc.h>
Public Types | |
enum | { STAGE_TYPE_NORMAL, STAGE_TYPE_SPECIALMAP } |
Define the types of stages in a material. More... | |
Public Member Functions | |
MaterialDoc (void) | |
Constructor for MaterialDoc. More... | |
~MaterialDoc (void) | |
Destructor for MaterialDoc. More... | |
void | SetRenderMaterial (idMaterial *material, bool parseMaterial=true, bool parseRenderMatierial=false) |
Initializes the MaterialDoc instance with a specific idMaterial. More... | |
int | GetStageCount () |
Returns the number of stages in this material. More... | |
int | FindStage (int stageType, const char *name) |
Returns the index of the stage with the specified type and name or -1 if the stage does not exist. More... | |
MEStage_t | GetStage (int stage) |
Returns a copy of the specified stage. More... | |
void | EnableStage (int stage, bool enabled) |
Specifies the enabled state of a single stage. More... | |
void | EnableAllStages (bool enabled) |
Sets the enabled state of all stages. More... | |
bool | IsStageEnabled (int stage) |
Returns the enabled state of a stage. More... | |
const char * | GetAttribute (int stage, const char *attribName, const char *defaultString="") |
Returns an attribute string from the material or a stage. More... | |
int | GetAttributeInt (int stage, const char *attribName, const char *defaultString="0") |
Returns an attribute int from the material or a stage. More... | |
float | GetAttributeFloat (int stage, const char *attribName, const char *defaultString="0") |
Returns an attribute float from the material or a stage. More... | |
bool | GetAttributeBool (int stage, const char *attribName, const char *defaultString="0") |
Returns an attribute bool from the material or a stage. More... | |
void | SetAttribute (int stage, const char *attribName, const char *value, bool addUndo=true) |
Sets an attribute string in the material or a stage. More... | |
void | SetAttributeInt (int stage, const char *attribName, int value, bool addUndo=true) |
Sets an attribute int in the material or a stage. More... | |
void | SetAttributeFloat (int stage, const char *attribName, float value, bool addUndo=true) |
Sets an attribute float in the material or a stage. More... | |
void | SetAttributeBool (int stage, const char *attribName, bool value, bool addUndo=true) |
Sets an attribute bool in the material or a stage. More... | |
void | SetMaterialName (const char *materialName, bool addUndo=true) |
Sets the material name. More... | |
void | SetData (int stage, idDict *data) |
Sets the entire dictionary for a material or stage. More... | |
void | SourceModify (SourceModifyOwner *owner) |
Called when the editor modifies the source of the material. More... | |
bool | IsSourceModified () |
Returns true if the source text of this material has been edited. More... | |
void | ApplySourceModify (idStr &text) |
Applies any source changes to the edit representation of the material. More... | |
const char * | GetEditSourceText () |
Returns the appropriate source for the editing. More... | |
void | AddStage (int stageType, const char *stageName, bool addUndo=true) |
Adds a stage to the material. More... | |
void | InsertStage (int stage, int stageType, const char *stageName, bool addUndo=true) |
Inserts a new stage to the material at a specified location. More... | |
void | RemoveStage (int stage, bool addUndo=true) |
Removes a stage from the material. More... | |
void | ClearStages () |
Removes all stages from the material. More... | |
void | MoveStage (int from, int to, bool addUndo=true) |
Moves a stage from one location to another. More... | |
void | ApplyMaterialChanges (bool force=false) |
Applies any changes to the material. More... | |
void | Save () |
Saves the material. More... | |
void | Delete () |
Deletes the material. More... | |
Protected Member Functions | |
void | OnMaterialChanged () |
Sets the proper internal states and notifies the MaterialDocManager once a material has been changed. More... | |
void | ParseMaterialText (const char *source) |
Passes text to a render material for parsing. More... | |
void | ParseMaterial (idLexer *src) |
Parses the source text from an idMaterial and initializes the editor dictionary representation of the material. More... | |
void | ParseStage (idLexer *src) |
Parses a single stage from the source text from an idMaterial and initializes the editor dictionary representation of the material. More... | |
void | AddSpecialMapStage (const char *stageName, const char *map) |
Adds a special stage to the material. More... | |
bool | ParseMaterialDef (idToken *token, idLexer *src, int type, idDict *dict) |
Finds the appropriate material definition for the supplied token and initializes the internal dictionary data. More... | |
void | ClearEditMaterial () |
Cleans up the edit material by deleting the stage data structures. More... | |
const char * | GenerateSourceText () |
Writes the internal dictionary data to the standard format. More... | |
void | ReplaceSourceText () |
Writes the internal dictionary data to the standard format and replaces the idMaterial source text with the newly generated text. More... | |
void | WriteStage (int stage, idFile_Memory *file) |
Writes a single stage. More... | |
void | WriteSpecialMapStage (int stage, idFile_Memory *file) |
Writes a single special stage. More... | |
void | WriteMaterialDef (int stage, idFile_Memory *file, int type, int indent) |
Writes a set of material attributes to a file. More... | |
Responsible for managing a single material that is being viewed and/or edited.
Definition at line 67 of file MaterialDoc.h.
anonymous enum |
Define the types of stages in a material.
Enumerator | |
---|---|
STAGE_TYPE_NORMAL | |
STAGE_TYPE_SPECIALMAP |
Definition at line 89 of file MaterialDoc.h.
MaterialDoc::MaterialDoc | ( | void | ) |
Constructor for MaterialDoc.
Definition at line 37 of file MaterialDoc.cpp.
MaterialDoc::~MaterialDoc | ( | void | ) |
Destructor for MaterialDoc.
Definition at line 46 of file MaterialDoc.cpp.
Adds a special stage to the material.
stageName | The name of the special stage bumpmap, diffusemap or specularmap |
map | The map for the special stage. |
Definition at line 769 of file MaterialDoc.cpp.
Adds a stage to the material.
stageType | The type of the stage: normal or special. |
stageName | The name of the stage. |
addUndo | Flag that specifies if the system should add an undo operation. |
Definition at line 456 of file MaterialDoc.cpp.
Applies any changes to the material.
force | If true then the material will be applied regardless of the number of changes. |
Definition at line 571 of file MaterialDoc.cpp.
Applies any source changes to the edit representation of the material.
Definition at line 404 of file MaterialDoc.cpp.
|
protected |
Cleans up the edit material by deleting the stage data structures.
Definition at line 835 of file MaterialDoc.cpp.
void MaterialDoc::ClearStages | ( | ) |
Removes all stages from the material.
Definition at line 525 of file MaterialDoc.cpp.
void MaterialDoc::Delete | ( | ) |
Deletes the material.
Definition at line 626 of file MaterialDoc.cpp.
Sets the enabled state of all stages.
enabled | The enabled state. |
Definition at line 141 of file MaterialDoc.cpp.
Specifies the enabled state of a single stage.
stage | The stage to change. |
enabled | The enabled state. |
Definition at line 129 of file MaterialDoc.cpp.
Returns the index of the stage with the specified type and name or -1 if the stage does not exist.
stageType | The type of stage to find. |
name | The name of the stage to find. |
Definition at line 103 of file MaterialDoc.cpp.
|
protected |
Writes the internal dictionary data to the standard format.
Definition at line 847 of file MaterialDoc.cpp.
const char * MaterialDoc::GetAttribute | ( | int | stage, |
const char * | attribName, | ||
const char * | defaultString = "" |
||
) |
Returns an attribute string from the material or a stage.
stage | The stage or -1 for the material. |
attribName | The name of the attribute. |
defaultString | The default value if the attribute is not specified. |
Definition at line 162 of file MaterialDoc.cpp.
bool MaterialDoc::GetAttributeBool | ( | int | stage, |
const char * | attribName, | ||
const char * | defaultString = "0" |
||
) |
Returns an attribute bool from the material or a stage.
stage | The stage or -1 for the material. |
attribName | The name of the attribute. |
defaultString | The default value if the attribute is not specified. |
Definition at line 211 of file MaterialDoc.cpp.
float MaterialDoc::GetAttributeFloat | ( | int | stage, |
const char * | attribName, | ||
const char * | defaultString = "0" |
||
) |
Returns an attribute float from the material or a stage.
stage | The stage or -1 for the material. |
attribName | The name of the attribute. |
defaultString | The default value if the attribute is not specified. |
Definition at line 195 of file MaterialDoc.cpp.
int MaterialDoc::GetAttributeInt | ( | int | stage, |
const char * | attribName, | ||
const char * | defaultString = "0" |
||
) |
Returns an attribute int from the material or a stage.
stage | The stage or -1 for the material. |
attribName | The name of the attribute. |
defaultString | The default value if the attribute is not specified. |
Definition at line 179 of file MaterialDoc.cpp.
const char * MaterialDoc::GetEditSourceText | ( | ) |
Returns the appropriate source for the editing.
Definition at line 445 of file MaterialDoc.cpp.
Returns a copy of the specified stage.
stage | The stage to return. |
Definition at line 118 of file MaterialDoc.cpp.
int MaterialDoc::GetStageCount | ( | ) |
Returns the number of stages in this material.
Definition at line 93 of file MaterialDoc.cpp.
void MaterialDoc::InsertStage | ( | int | stage, |
int | stageType, | ||
const char * | stageName, | ||
bool | addUndo = true |
||
) |
Inserts a new stage to the material at a specified location.
stage | The location to insert the stage. |
stageType | The type of the stage: normal or special. |
stageName | The name of the stage. |
addUndo | Flag that specifies if the system should add an undo operation. |
Definition at line 481 of file MaterialDoc.cpp.
bool MaterialDoc::IsSourceModified | ( | ) |
Returns true if the source text of this material has been edited.
Definition at line 397 of file MaterialDoc.cpp.
Returns the enabled state of a stage.
stage | The stage to check. |
Definition at line 151 of file MaterialDoc.cpp.
Moves a stage from one location to another.
from | The original location of the stage. |
to | The new location of the stage. |
addUndo | Flag that specifies if the system should add an undo operation. |
Definition at line 539 of file MaterialDoc.cpp.
|
protected |
Sets the proper internal states and notifies the MaterialDocManager once a material has been changed.
Definition at line 635 of file MaterialDoc.cpp.
Parses the source text from an idMaterial and initializes the editor dictionary representation of the material.
src | The idLexer object that contains the material text. |
Definition at line 673 of file MaterialDoc.cpp.
|
protected |
Finds the appropriate material definition for the supplied token and initializes the internal dictionary data.
token | The token to lookup |
src | The idLexer that contains the material source text. |
type | The type of attribute grouping to use material, stage or special stage. |
dict | The dictionary to initialize. |
Definition at line 786 of file MaterialDoc.cpp.
Passes text to a render material for parsing.
source | The text that sould be applied to the idMaterial. |
Definition at line 648 of file MaterialDoc.cpp.
Parses a single stage from the source text from an idMaterial and initializes the editor dictionary representation of the material.
src | The idLexer object that contains the material text. |
Definition at line 721 of file MaterialDoc.cpp.
Removes a stage from the material.
stage | The stage to remove. |
addUndo | Flag that specifies if the system should add an undo operation. |
Definition at line 504 of file MaterialDoc.cpp.
|
protected |
Writes the internal dictionary data to the standard format and replaces the idMaterial source text with the newly generated text.
Definition at line 876 of file MaterialDoc.cpp.
Saves the material.
Definition at line 599 of file MaterialDoc.cpp.
void MaterialDoc::SetAttribute | ( | int | stage, |
const char * | attribName, | ||
const char * | value, | ||
bool | addUndo = true |
||
) |
Sets an attribute string in the material or a stage.
stage | The stage or -1 for the material. |
attribName | The name of the attribute. |
value | The value to set. |
addUndo | Flag that specifies if the system should add an undo operation. |
Definition at line 228 of file MaterialDoc.cpp.
void MaterialDoc::SetAttributeBool | ( | int | stage, |
const char * | attribName, | ||
bool | value, | ||
bool | addUndo = true |
||
) |
Sets an attribute bool in the material or a stage.
stage | The stage or -1 for the material. |
attribName | The name of the attribute. |
value | The value to set. |
addUndo | Flag that specifies if the system should add an undo operation. |
Definition at line 316 of file MaterialDoc.cpp.
void MaterialDoc::SetAttributeFloat | ( | int | stage, |
const char * | attribName, | ||
float | value, | ||
bool | addUndo = true |
||
) |
Sets an attribute float in the material or a stage.
stage | The stage or -1 for the material. |
attribName | The name of the attribute. |
value | The value to set. |
addUndo | Flag that specifies if the system should add an undo operation. |
Definition at line 289 of file MaterialDoc.cpp.
void MaterialDoc::SetAttributeInt | ( | int | stage, |
const char * | attribName, | ||
int | value, | ||
bool | addUndo = true |
||
) |
Sets an attribute int in the material or a stage.
stage | The stage or -1 for the material. |
attribName | The name of the attribute. |
value | The value to set. |
addUndo | Flag that specifies if the system should add an undo operation. |
Definition at line 262 of file MaterialDoc.cpp.
Sets the entire dictionary for a material or stage.
stage | The stage or -1 for the material. |
data | The dictionary to copy. |
Definition at line 371 of file MaterialDoc.cpp.
Sets the material name.
materialName | The new name of the material. |
addUndo | Flag that specifies if the system should add an undo operation. |
Definition at line 347 of file MaterialDoc.cpp.
void MaterialDoc::SetRenderMaterial | ( | idMaterial * | material, |
bool | parseMaterial = true , |
||
bool | parseRenderMatierial = false |
||
) |
Initializes the MaterialDoc instance with a specific idMaterial.
This method will parse the material into the internal dictionary representation and optionally allow the idMaterial object to reparse the source.
material | The idMaterial instance to use. |
parseMaterial | Flag to determine if the material should be parsed into the editor representation. |
parseRenderMaterial | Flag to determine if the idMaterial object should be reparsed. |
Definition at line 58 of file MaterialDoc.cpp.
void MaterialDoc::SourceModify | ( | SourceModifyOwner * | owner | ) |
Called when the editor modifies the source of the material.
text | The new source text. |
Definition at line 387 of file MaterialDoc.cpp.
|
protected |
Writes a set of material attributes to a file.
stage | The stage to write or -1 for the material. |
file | The file where the stage should be wirtten. |
type | The attribute grouping to use. |
indent | The number of tabs to indent the text. |
Definition at line 924 of file MaterialDoc.cpp.
|
protected |
Writes a single special stage.
stage | The stage to write. |
file | The file where the stage should be wirtten |
Definition at line 910 of file MaterialDoc.cpp.
|
protected |
Writes a single stage.
stage | The stage to write. |
file | The file where the stage should be wirtten |
Definition at line 885 of file MaterialDoc.cpp.
bool MaterialDoc::applyWaiting |
Definition at line 76 of file MaterialDoc.h.
bool MaterialDoc::deleted |
Definition at line 77 of file MaterialDoc.h.
MEMaterial_t MaterialDoc::editMaterial |
Definition at line 73 of file MaterialDoc.h.
MaterialDocManager* MaterialDoc::manager |
Definition at line 70 of file MaterialDoc.h.
bool MaterialDoc::modified |
Definition at line 75 of file MaterialDoc.h.
idStr MaterialDoc::name |
Definition at line 71 of file MaterialDoc.h.
idMaterial* MaterialDoc::renderMaterial |
Definition at line 72 of file MaterialDoc.h.
bool MaterialDoc::sourceModify |
Definition at line 79 of file MaterialDoc.h.
SourceModifyOwner* MaterialDoc::sourceModifyOwner |
Definition at line 80 of file MaterialDoc.h.