doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
MaterialDoc Class Reference

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...
 

Public Attributes

MaterialDocManagermanager
 
idStr name
 
idMaterialrenderMaterial
 
MEMaterial_t editMaterial
 
bool modified
 
bool applyWaiting
 
bool deleted
 
bool sourceModify
 
SourceModifyOwnersourceModifyOwner
 

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...
 

Detailed Description

Responsible for managing a single material that is being viewed and/or edited.

Definition at line 67 of file MaterialDoc.h.

Member Enumeration Documentation

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

void MaterialDoc::AddSpecialMapStage ( const char *  stageName,
const char *  map 
)
protected

Adds a special stage to the material.

Parameters
stageNameThe name of the special stage bumpmap, diffusemap or specularmap
mapThe map for the special stage.

Definition at line 769 of file MaterialDoc.cpp.

void MaterialDoc::AddStage ( int  stageType,
const char *  stageName,
bool  addUndo = true 
)

Adds a stage to the material.

Parameters
stageTypeThe type of the stage: normal or special.
stageNameThe name of the stage.
addUndoFlag that specifies if the system should add an undo operation.

Definition at line 456 of file MaterialDoc.cpp.

void MaterialDoc::ApplyMaterialChanges ( bool  force = false)

Applies any changes to the material.

Parameters
forceIf true then the material will be applied regardless of the number of changes.

Definition at line 571 of file MaterialDoc.cpp.

void MaterialDoc::ApplySourceModify ( idStr text)

Applies any source changes to the edit representation of the material.

Definition at line 404 of file MaterialDoc.cpp.

void MaterialDoc::ClearEditMaterial ( )
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.

void MaterialDoc::EnableAllStages ( bool  enabled)

Sets the enabled state of all stages.

Parameters
enabledThe enabled state.

Definition at line 141 of file MaterialDoc.cpp.

void MaterialDoc::EnableStage ( int  stage,
bool  enabled 
)

Specifies the enabled state of a single stage.

Parameters
stageThe stage to change.
enabledThe enabled state.

Definition at line 129 of file MaterialDoc.cpp.

int MaterialDoc::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.

Parameters
stageTypeThe type of stage to find.
nameThe name of the stage to find.

Definition at line 103 of file MaterialDoc.cpp.

const char * MaterialDoc::GenerateSourceText ( )
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.

Parameters
stageThe stage or -1 for the material.
attribNameThe name of the attribute.
defaultStringThe 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.

Parameters
stageThe stage or -1 for the material.
attribNameThe name of the attribute.
defaultStringThe 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.

Parameters
stageThe stage or -1 for the material.
attribNameThe name of the attribute.
defaultStringThe 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.

Parameters
stageThe stage or -1 for the material.
attribNameThe name of the attribute.
defaultStringThe 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.

MEStage_t MaterialDoc::GetStage ( int  stage)

Returns a copy of the specified stage.

Parameters
stageThe 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.

Parameters
stageThe location to insert the stage.
stageTypeThe type of the stage: normal or special.
stageNameThe name of the stage.
addUndoFlag 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.

bool MaterialDoc::IsStageEnabled ( int  stage)

Returns the enabled state of a stage.

Parameters
stageThe stage to check.

Definition at line 151 of file MaterialDoc.cpp.

void MaterialDoc::MoveStage ( int  from,
int  to,
bool  addUndo = true 
)

Moves a stage from one location to another.

Parameters
fromThe original location of the stage.
toThe new location of the stage.
addUndoFlag that specifies if the system should add an undo operation.

Definition at line 539 of file MaterialDoc.cpp.

void MaterialDoc::OnMaterialChanged ( )
protected

Sets the proper internal states and notifies the MaterialDocManager once a material has been changed.

Definition at line 635 of file MaterialDoc.cpp.

void MaterialDoc::ParseMaterial ( idLexer src)
protected

Parses the source text from an idMaterial and initializes the editor dictionary representation of the material.

Parameters
srcThe idLexer object that contains the material text.

Definition at line 673 of file MaterialDoc.cpp.

bool MaterialDoc::ParseMaterialDef ( idToken token,
idLexer src,
int  type,
idDict dict 
)
protected

Finds the appropriate material definition for the supplied token and initializes the internal dictionary data.

Parameters
tokenThe token to lookup
srcThe idLexer that contains the material source text.
typeThe type of attribute grouping to use material, stage or special stage.
dictThe dictionary to initialize.

Definition at line 786 of file MaterialDoc.cpp.

void MaterialDoc::ParseMaterialText ( const char *  source)
protected

Passes text to a render material for parsing.

Parameters
sourceThe text that sould be applied to the idMaterial.

Definition at line 648 of file MaterialDoc.cpp.

void MaterialDoc::ParseStage ( idLexer src)
protected

Parses a single stage from the source text from an idMaterial and initializes the editor dictionary representation of the material.

Parameters
srcThe idLexer object that contains the material text.

Definition at line 721 of file MaterialDoc.cpp.

void MaterialDoc::RemoveStage ( int  stage,
bool  addUndo = true 
)

Removes a stage from the material.

Parameters
stageThe stage to remove.
addUndoFlag that specifies if the system should add an undo operation.

Definition at line 504 of file MaterialDoc.cpp.

void MaterialDoc::ReplaceSourceText ( )
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.

void MaterialDoc::Save ( void  )

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.

Parameters
stageThe stage or -1 for the material.
attribNameThe name of the attribute.
valueThe value to set.
addUndoFlag 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.

Parameters
stageThe stage or -1 for the material.
attribNameThe name of the attribute.
valueThe value to set.
addUndoFlag 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.

Parameters
stageThe stage or -1 for the material.
attribNameThe name of the attribute.
valueThe value to set.
addUndoFlag 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.

Parameters
stageThe stage or -1 for the material.
attribNameThe name of the attribute.
valueThe value to set.
addUndoFlag that specifies if the system should add an undo operation.

Definition at line 262 of file MaterialDoc.cpp.

void MaterialDoc::SetData ( int  stage,
idDict data 
)

Sets the entire dictionary for a material or stage.

Parameters
stageThe stage or -1 for the material.
dataThe dictionary to copy.

Definition at line 371 of file MaterialDoc.cpp.

void MaterialDoc::SetMaterialName ( const char *  materialName,
bool  addUndo = true 
)

Sets the material name.

Parameters
materialNameThe new name of the material.
addUndoFlag 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.

Parameters
materialThe idMaterial instance to use.
parseMaterialFlag to determine if the material should be parsed into the editor representation.
parseRenderMaterialFlag 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.

Parameters
textThe new source text.

Definition at line 387 of file MaterialDoc.cpp.

void MaterialDoc::WriteMaterialDef ( int  stage,
idFile_Memory file,
int  type,
int  indent 
)
protected

Writes a set of material attributes to a file.

Parameters
stageThe stage to write or -1 for the material.
fileThe file where the stage should be wirtten.
typeThe attribute grouping to use.
indentThe number of tabs to indent the text.

Definition at line 924 of file MaterialDoc.cpp.

void MaterialDoc::WriteSpecialMapStage ( int  stage,
idFile_Memory file 
)
protected

Writes a single special stage.

Parameters
stageThe stage to write.
fileThe file where the stage should be wirtten

Definition at line 910 of file MaterialDoc.cpp.

void MaterialDoc::WriteStage ( int  stage,
idFile_Memory file 
)
protected

Writes a single stage.

Parameters
stageThe stage to write.
fileThe file where the stage should be wirtten

Definition at line 885 of file MaterialDoc.cpp.

Member Data Documentation

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.


The documentation for this class was generated from the following files: