28 #include "../../idlib/precompiled.h"
66 if(parseRenderMatierial) {
67 char *declText = (
char *) _alloca( material->
GetTextLength() + 1 );
81 char *declText = (
char *) _alloca( material->
GetTextLength() + 1 );
85 src.
LoadMemory(declText, strlen(declText),
"Material");
108 if(stageType == type && !localname.
Icmp(name))
232 if(orig.
Icmp(value)) {
248 dict->
Set(attribName, value);
275 dict->
SetInt(attribName, value);
335 dict->
SetBool(attribName, value);
428 src.
Warning(
"Missing decl name" );
686 if ( token ==
"}" ) {
694 if ( !token.
Icmp(
"diffusemap" ) ) {
700 else if ( !token.
Icmp(
"specularmap" ) ) {
705 else if ( !token.
Icmp(
"bumpmap" ) ) {
710 else if( token ==
"{" ) {
738 if ( token ==
"}" ) {
746 if(!token.
Icmp(
"name")) {
790 for(
int i = 0;
i < defs->
Num();
i++) {
791 if(!token->
Icmp((*defs)[
i]->dictName)) {
793 switch((*defs)[
i]->type) {
798 if((*defs)[i]->quotes) {
802 dict->
Set((*defs)[i]->dictName, str);
808 dict->
SetBool((*defs)[i]->dictName,
true);
815 dict->
Set((*defs)[i]->dictName, str);
822 dict->
Set((*defs)[i]->dictName, str);
852 "\tGenerated by the Material Editor.\n"
853 "\tType 'materialeditor' at the console to launch the material editor.\n"
927 for(
int i = 0;
i < indent;
i++) {
932 for(
int i = 0;
i < defs->
Num();
i++) {
933 switch((*defs)[
i]->type) {
938 if((*defs)[
i]->quotes)
Undo/Redo operation for stage moves.
Undo/Redo operation for string attribute changes.
void EnableStage(int stage, bool enabled)
Specifies the enabled state of a single stage.
const char * ReadRestOfLine(idStr &out)
void ClearEditMaterial()
Cleans up the edit material by deleting the stage data structures.
float GetFloat(const char *key, const char *defaultString="0") const
GLsizei const GLfloat * value
int GetInt(const char *key, const char *defaultString="0") const
assert(prefInfo.fullscreenBtn)
void StripLeading(const char c)
void Delete()
Deletes the material.
void Save()
Saves the material.
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...
idMaterial * renderMaterial
void WriteMaterialDef(int stage, idFile_Memory *file, int type, int indent)
Writes a set of material attributes to a file.
void SourceModify(SourceModifyOwner *owner)
Called when the editor modifies the source of the material.
bool ParseMaterialDef(idToken *token, idLexer *src, int type, idDict *dict)
Finds the appropriate material definition for the supplied token and initializes the internal diction...
void SetAttributeFloat(int stage, const char *attribName, float value, bool addUndo=true)
Sets an attribute float in the material or a stage.
void SetAttributeInt(int stage, const char *attribName, int value, bool addUndo=true)
Sets an attribute int in the material or a stage.
void StripTrailing(const char c)
void MaterialSaved(MaterialDoc *materialDoc)
Called when a material has been saved and notifies all views of the save.
void OnMaterialChanged()
Sets the proper internal states and notifies the MaterialDocManager once a material has been changed...
void StageDeleted(MaterialDoc *materialDoc, int stageNum)
Called when a stage has been deleted and notifies all views of the change.
Undo/Redo operation for boolean attribute changes.
void ReplaceSourceText()
Writes the internal dictionary data to the standard format and replaces the idMaterial source text wi...
const char * GetName(void) const
virtual bool Parse(const char *text, const int textLength)
GLuint GLuint GLsizei GLenum type
const char * GenerateSourceText()
Writes the internal dictionary data to the standard format.
void Set(const char *key, const char *value)
void MoveStage(int from, int to, bool addUndo=true)
Moves a stage from one location to another.
bool Save(const char *fileName=NULL)
Undo/Redo operation for stage deletes.
void ApplyMaterialChanges(bool force=false)
Applies any changes to the material.
void SetFloat(const char *key, float val)
void Copy(const idDict &other)
int Icmp(const char *text) const
SourceModifyOwner * sourceModifyOwner
void RemoveStage(int stage, bool addUndo=true)
Removes a stage from the material.
void WriteSpecialMapStage(int stage, idFile_Memory *file)
Writes a single special stage.
int ExpectAnyToken(idToken *token)
void ParseMaterial(idLexer *src)
Parses the source text from an idMaterial and initializes the editor dictionary representation of the...
void InsertStage(int stage, int stageType, const char *stageName, bool addUndo=true)
Inserts a new stage to the material at a specified location.
const char * GetEditSourceText()
Returns the appropriate source for the editing.
GLsizei GLsizei GLcharARB * source
void WriteStage(int stage, idFile_Memory *file)
Writes a single stage.
void SetAttribute(int stage, const char *attribName, const char *value, bool addUndo=true)
Sets an attribute string in the material or a stage.
void AddSpecialMapStage(const char *stageName, const char *map)
Adds a special stage to the material.
const char * GetString(const char *key, const char *defaultString="") const
void AddMaterialUndoModifier(MaterialModifier *mod, bool clearRedo=true)
Adds an undo operation to the undo buffer.
const char * GetDataPtr(void) const
void StageAdded(MaterialDoc *materialDoc, int stageNum)
Called when a stage is added and notifies all views of the addition.
bool GetBool(const char *key, const char *defaultString="0") const
void AddStage(int stageType, const char *stageName, bool addUndo=true)
Adds a stage to the material.
bool IsSourceModified()
Returns true if the source text of this material has been edited.
void SetMaterialName(const char *materialName, bool addUndo=true)
Sets the material name.
GLsizei GLsizei GLenum GLenum const GLvoid * data
int GetStageCount()
Returns the number of stages in this material.
int GetAttributeInt(int stage, const char *attribName, const char *defaultString="0")
Returns an attribute int from the material or a stage.
void ClearUndo()
Clears the entire undo buffer.
virtual int WriteFloatString(const char *fmt,...) id_attribute((format(printf
void MaterialChanged(MaterialDoc *materialDoc)
Called when a material has been edited and notifies all views of the change.
void SetBool(const char *key, bool val)
void ParseStage(idLexer *src)
Parses a single stage from the source text from an idMaterial and initializes the editor dictionary r...
int LoadMemory(const char *ptr, int length, const char *name, int startLine=1)
void MaterialApplied(MaterialDoc *materialDoc)
Called when a material has been applied and notifies all views of the apply.
Undo/Redo operation for renaming materials.
void SetAttributeBool(int stage, const char *attribName, bool value, bool addUndo=true)
Sets an attribute bool in the material or a stage.
void SetText(const char *text)
idDeclManager * declManager
const char * GetAttribute(int stage, const char *attribName, const char *defaultString="")
Returns an attribute string from the material or a stage.
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.
Undo/Redo operation for stage inserts.
int Insert(const type &obj, int index=0)
int Append(const type &obj)
void void Warning(const char *str,...) id_attribute((format(printf
void SetInt(const char *key, int val)
MaterialDocManager * manager
void ParseMaterialText(const char *source)
Passes text to a render material for parsing.
void SetData(int stage, idDict *data)
Sets the entire dictionary for a material or stage.
bool GetAttributeBool(int stage, const char *attribName, const char *defaultString="0")
Returns an attribute bool from the material or a stage.
bool RemoveIndex(int index)
void EnableAllStages(bool enabled)
Sets the enabled state of all stages.
void ClearRedo()
Clears the redo buffer.
Implemented by the edit window that is responsible for modifying the material source text...
~MaterialDoc(void)
Destructor for MaterialDoc.
HWND GetMaterialEditorWindow()
Returns the handle to the main Material Editor Window.
const char * c_str(void) const
int SkipUntilString(const char *string)
void SetRenderMaterial(idMaterial *material, bool parseMaterial=true, bool parseRenderMatierial=false)
Initializes the MaterialDoc instance with a specific idMaterial.
void ApplySourceModify(idStr &text)
Applies any source changes to the edit representation of the material.
float GetAttributeFloat(int stage, const char *attribName, const char *defaultString="0")
Returns an attribute float from the material or a stage.
static MaterialDefList * GetMaterialDefs(int type)
Returns the MaterialDefList for the specified attribute grouping.
void GetText(char *text) const
char * va(const char *fmt,...)
MEMaterial_t editMaterial
MEStage_t GetStage(int stage)
Returns a copy of the specified stage.
virtual idStr GetSourceText()
bool IsStageEnabled(int stage)
Returns the enabled state of a stage.
int ReadToken(idToken *token)
int GetTextLength(void) const
Dictionary representation of a Material Stage.
void ClearStages()
Removes all stages from the material.
idList< MEStage_t * > stages
void MaterialNameChanged(const char *oldName, MaterialDoc *materialDoc)
Called when a material name has been changed and notifies all views of the change.
virtual bool RenameDecl(declType_t type, const char *oldName, const char *newName)=0
MaterialDoc(void)
Constructor for MaterialDoc.