doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MaterialDoc.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 "MaterialDoc.h"
32 #include "MaterialView.h"
33 
38  modified = false;
39  applyWaiting = false;
40  sourceModify = false;
41 }
42 
48 }
49 
58 void MaterialDoc::SetRenderMaterial(idMaterial* material, bool parseMaterial, bool parseRenderMatierial) {
59 
60  renderMaterial = material;
61 
62 
63  if(!parseMaterial || !renderMaterial)
64  return;
65 
66  if(parseRenderMatierial) {
67  char *declText = (char *) _alloca( material->GetTextLength() + 1 );
68  material->GetText( declText );
69 
70  renderMaterial->GetText(declText);
71  ParseMaterialText(declText);
72 
73  }
74 
76 
77  name = material->GetName();
78 
79  idLexer src;
80 
81  char *declText = (char *) _alloca( material->GetTextLength() + 1 );
82  material->GetText( declText );
83 
84  renderMaterial->GetText(declText);
85  src.LoadMemory(declText, strlen(declText), "Material");
86 
87  ParseMaterial(&src);
88 }
89 
94  return editMaterial.stages.Num();
95 }
96 
103 int MaterialDoc::FindStage(int stageType, const char* name) {
104 
105  for(int i = 0; i < editMaterial.stages.Num(); i++) {
106  int type = GetAttributeInt(i, "stagetype");
107  idStr localname = GetAttribute(i, "name");
108  if(stageType == type && !localname.Icmp(name))
109  return i;
110  }
111  return -1;
112 }
113 
119  assert(stage >= 0 && stage < GetStageCount());
120  return *editMaterial.stages[stage];
121 
122 }
123 
129 void MaterialDoc::EnableStage(int stage, bool enabled) {
130 
131  assert(stage >= 0 && stage < GetStageCount());
132  editMaterial.stages[stage]->enabled = enabled;
133 
135 }
136 
141 void MaterialDoc::EnableAllStages(bool enabled) {
142  for(int i = 0; i < GetStageCount(); i++) {
143  editMaterial.stages[i]->enabled = enabled;
144  }
145 }
146 
152  assert(stage >= 0 && stage < GetStageCount());
153  return editMaterial.stages[stage]->enabled;
154 }
155 
162 const char* MaterialDoc::GetAttribute(int stage, const char* attribName, const char* defaultString) {
163 
164  if(stage == -1) {
165  return editMaterial.materialData.GetString(attribName, defaultString);
166  } else {
167  assert(stage >= 0 && stage < GetStageCount());
168  MEStage_t* pStage = editMaterial.stages[stage];
169  return pStage->stageData.GetString(attribName, defaultString);
170  }
171 }
172 
179 int MaterialDoc::GetAttributeInt(int stage, const char* attribName, const char* defaultString) {
180  if(stage == -1) {
181  return editMaterial.materialData.GetInt(attribName, defaultString);
182  } else {
183  assert(stage >= 0 && stage < GetStageCount());
184  MEStage_t* pStage = editMaterial.stages[stage];
185  return pStage->stageData.GetInt(attribName, defaultString);
186  }
187 }
188 
195 float MaterialDoc::GetAttributeFloat(int stage, const char* attribName, const char* defaultString) {
196  if(stage == -1) {
197  return editMaterial.materialData.GetFloat(attribName, defaultString);
198  } else {
199  assert(stage >= 0 && stage < GetStageCount());
200  MEStage_t* pStage = editMaterial.stages[stage];
201  return pStage->stageData.GetFloat(attribName, defaultString);
202  }
203 }
204 
211 bool MaterialDoc::GetAttributeBool(int stage, const char* attribName, const char* defaultString) {
212  if(stage == -1) {
213  return editMaterial.materialData.GetBool(attribName, defaultString);
214  } else {
215  assert(stage >= 0 && stage < GetStageCount());
216  MEStage_t* pStage = editMaterial.stages[stage];
217  return pStage->stageData.GetBool(attribName, defaultString);
218  }
219 }
220 
228 void MaterialDoc::SetAttribute(int stage, const char* attribName, const char* value, bool addUndo) {
229 
230  //Make sure we need to set the attribute
231  idStr orig = GetAttribute(stage, attribName);
232  if(orig.Icmp(value)) {
233 
234  idDict* dict;
235  if(stage == -1) {
236  dict = &editMaterial.materialData;
237  } else {
238  assert(stage >= 0 && stage < GetStageCount());
239  dict = &editMaterial.stages[stage]->stageData;
240  }
241 
242  if(addUndo) {
243  //Create a new Modifier for this change so we can undo and redo later
244  AttributeMaterialModifierString* mod = new AttributeMaterialModifierString(manager, name, stage, attribName, value, orig);
246  }
247 
248  dict->Set(attribName, value);
249 
250  manager->AttributeChanged(this, stage, attribName);
252  }
253 }
254 
262 void MaterialDoc::SetAttributeInt(int stage, const char* attribName, int value, bool addUndo) {
263  //Make sure we need to set the attribute
264  int orig = GetAttributeInt(stage, attribName);
265  if(orig != value) {
266 
267  idDict* dict;
268  if(stage == -1) {
269  dict = &editMaterial.materialData;
270  } else {
271  assert(stage >= 0 && stage < GetStageCount());
272  dict = &editMaterial.stages[stage]->stageData;
273  }
274 
275  dict->SetInt(attribName, value);
276 
277  manager->AttributeChanged(this, stage, attribName);
279  }
280 }
281 
289 void MaterialDoc::SetAttributeFloat(int stage, const char* attribName, float value, bool addUndo) {
290  //Make sure we need to set the attribute
291  float orig = GetAttributeFloat(stage, attribName);
292  if(orig != value) {
293 
294  idDict* dict;
295  if(stage == -1) {
296  dict = &editMaterial.materialData;
297  } else {
298  assert(stage >= 0 && stage < GetStageCount());
299  dict = &editMaterial.stages[stage]->stageData;
300  }
301 
302  dict->SetFloat(attribName, value);
303 
304  manager->AttributeChanged(this, stage, attribName);
306  }
307 }
308 
316 void MaterialDoc::SetAttributeBool(int stage, const char* attribName, bool value, bool addUndo) {
317  //Make sure we need to set the attribute
318  bool orig = GetAttributeBool(stage, attribName);
319  if(orig != value) {
320 
321  idDict* dict;
322  if(stage == -1) {
323  dict = &editMaterial.materialData;
324  } else {
325  assert(stage >= 0 && stage < GetStageCount());
326  dict = &editMaterial.stages[stage]->stageData;
327  }
328 
329  if(addUndo) {
330  //Create a new Modifier for this change so we can undo and redo later
331  AttributeMaterialModifierBool* mod = new AttributeMaterialModifierBool(manager, name, stage, attribName, value, orig);
333  }
334 
335  dict->SetBool(attribName, value);
336 
337  manager->AttributeChanged(this, stage, attribName);
339  }
340 }
341 
347 void MaterialDoc::SetMaterialName(const char* materialName, bool addUndo) {
348  idStr oldName = name;
349 
350  declManager->RenameDecl(DECL_MATERIAL, oldName, materialName);
352 
353  if(addUndo) {
356  }
357 
358  manager->MaterialNameChanged(oldName, this);
359 
361 
362  //Need to do an instant apply for material name changes
364 }
365 
371 void MaterialDoc::SetData(int stage, idDict* data) {
372  idDict* dict;
373  if(stage == -1) {
374  dict = &editMaterial.materialData;
375  } else {
376  assert(stage >= 0 && stage < GetStageCount());
377  dict = &editMaterial.stages[stage]->stageData;
378  }
379  dict->Clear();
380  dict->Copy(*data);
381 }
382 
388 
389  sourceModifyOwner = owner;
390  sourceModify = true;
392 }
393 
398  return sourceModify;
399 }
400 
405 
406  if(sourceModify) {
407 
408  //Changes in the source need to clear any undo redo buffer because we have no idea what has changed
409  manager->ClearUndo();
410  manager->ClearRedo();
411 
413 
414  idLexer src;
415  src.LoadMemory(text, text.Length(), "Material");
416 
417  src.SetFlags(
418  LEXFL_NOSTRINGCONCAT | // multiple strings seperated by whitespaces are not concatenated
419  LEXFL_NOSTRINGESCAPECHARS | // no escape characters inside strings
420  LEXFL_ALLOWPATHNAMES | // allow path seperators in names
421  LEXFL_ALLOWMULTICHARLITERALS | // allow multi character literals
422  LEXFL_ALLOWBACKSLASHSTRINGCONCAT | // allow multiple strings seperated by '\' to be concatenated
423  LEXFL_NOFATALERRORS // just set a flag instead of fatal erroring
424  );
425 
426  idToken token;
427  if(!src.ReadToken(&token)) {
428  src.Warning( "Missing decl name" );
429  return;
430  }
431 
432  ParseMaterial(&src);
433  sourceModify = false;
434 
435  //Check to see if the name has changed
436  if(token.Icmp(name)) {
437  SetMaterialName(token, false);
438  }
439  }
440 }
441 
446 
447  return GenerateSourceText();
448 }
449 
456 void MaterialDoc::AddStage(int stageType, const char* stageName, bool addUndo) {
457  MEStage_t* newStage = new MEStage_t();
458 
459  int index = editMaterial.stages.Append(newStage);
460  newStage->stageData.Set("name", stageName);
461  newStage->stageData.SetInt("stagetype", stageType);
462  newStage->enabled = true;
463 
464  if(addUndo) {
465  StageInsertModifier* mod = new StageInsertModifier(manager, name, index, stageType, stageName);
467  }
468 
469  manager->StageAdded(this, index);
470 
472 }
473 
481 void MaterialDoc::InsertStage(int stage, int stageType, const char* stageName, bool addUndo) {
482  MEStage_t* newStage = new MEStage_t();
483 
484  editMaterial.stages.Insert(newStage, stage);
485  newStage->stageData.Set("name", stageName);
486  newStage->stageData.SetInt("stagetype", stageType);
487  newStage->enabled = true;
488 
489  if(addUndo) {
490  StageInsertModifier* mod = new StageInsertModifier(manager, name, stage, stageType, stageName);
492  }
493 
494  manager->StageAdded(this, stage);
495 
497 }
498 
504 void MaterialDoc::RemoveStage(int stage, bool addUndo) {
505  assert(stage >= 0 && stage < GetStageCount());
506 
507  if(addUndo) {
508  //Add modifier to undo this operation
509  StageDeleteModifier* mod = new StageDeleteModifier(manager, name, stage, editMaterial.stages[stage]->stageData);
511  }
512 
513  //delete the stage and remove it from the list
514  delete editMaterial.stages[stage];
516 
517  manager->StageDeleted(this, stage);
518 
520 }
521 
526 
527  //Delete each stage and clear the list
528  for(int i = GetStageCount() - 1; i >= 0; i--) {
529  RemoveStage(i);
530  }
531 }
532 
539 void MaterialDoc::MoveStage(int from, int to, bool addUndo) {
540  assert(from >= 0 && from < GetStageCount());
541  assert(to >= 0 && to < GetStageCount());
542 
543  int origFrom = from;
544  int origTo = to;
545 
546  if(from < to)
547  to++;
548 
549  MEStage_t* pMove = editMaterial.stages[from];
550  editMaterial.stages.Insert(pMove, to);
551 
552  if(from > to)
553  from++;
554 
556 
557  manager->StageMoved(this, origFrom, origTo);
558 
559  if(addUndo) {
560  StageMoveModifier *mod = new StageMoveModifier(manager, name, origFrom, origTo);
562  }
563 
565 }
566 
572 
573  if(force || applyWaiting) {
574 
577  ApplySourceModify(text);
578  }
579 
581 
582  char *declText = (char *) _alloca( renderMaterial->GetTextLength() + 1 );
583  renderMaterial->GetText( declText );
584 
585  renderMaterial->GetText(declText);
586 
587  ParseMaterialText(declText);
588 
589  applyWaiting = false;
590 
591  assert(manager);
592  manager->MaterialApplied(this);
593  }
594 }
595 
600 
601  EnableAllStages(true);
602 
603  //Apply the material so that the renderMaterial has the source text
604  if(!deleted) {
605  ApplyMaterialChanges(true);
606  } else {
607  //Replace the text with nothing
608  renderMaterial->SetText(" ");
609  }
610 
611  if(renderMaterial->Save()) {
612 
613  modified = false;
614 
615  //Notify the world
616  assert(manager);
617  manager->MaterialSaved(this);
618  } else {
619  MessageBox(GetMaterialEditorWindow(), va("Unable to save '%s'. It may be read-only", name.c_str()), "Save Error", MB_OK | MB_ICONERROR);
620  }
621 }
622 
627  deleted = true;
628 
630 }
631 
636 
637  modified = true;
638  applyWaiting = true;
639 
640  assert(manager);
641  manager->MaterialChanged(this);
642 }
643 
649 
650  /*idLexer src;
651  src.LoadMemory(source, strlen(source), "material");
652  src.SetFlags(
653  LEXFL_NOSTRINGCONCAT | // multiple strings seperated by whitespaces are not concatenated
654  LEXFL_NOSTRINGESCAPECHARS | // no escape characters inside strings
655  LEXFL_ALLOWPATHNAMES | // allow path seperators in names
656  LEXFL_ALLOWMULTICHARLITERALS | // allow multi character literals
657  LEXFL_ALLOWBACKSLASHSTRINGCONCAT | // allow multiple strings seperated by '\' to be concatenated
658  LEXFL_NOFATALERRORS // just set a flag instead of fatal erroring
659  );
660 
661  //Skip the name becuase the material parsing code expects it
662  src.SkipUntilString("{");*/
663 
664  //Now let the material parse the text
665  renderMaterial->Parse(source, strlen(source));
666 }
667 
674 
675  idToken token;
676 
677  //Parse past the name
678  src->SkipUntilString("{");
679 
680  while ( 1 ) {
681  if ( !src->ExpectAnyToken( &token ) ) {
682  //Todo: Add some error checking here
683  return;
684  }
685 
686  if ( token == "}" ) {
687  break;
688  }
689 
691  continue;
692  }
693 
694  if ( !token.Icmp( "diffusemap" ) ) {
695  //Added as a special stage
696  idStr str;
697  src->ReadRestOfLine( str );
698  AddSpecialMapStage("diffusemap", str);
699  }
700  else if ( !token.Icmp( "specularmap" ) ) {
701  idStr str;
702  src->ReadRestOfLine( str );
703  AddSpecialMapStage("specularmap", str);
704  }
705  else if ( !token.Icmp( "bumpmap" ) ) {
706  idStr str;
707  src->ReadRestOfLine( str );
708  AddSpecialMapStage("bumpmap", str);
709  }
710  else if( token == "{" ) {
711  ParseStage(src);
712  }
713  }
714 }
715 
722 
723  MEStage_t* newStage = new MEStage_t();
724  int index = editMaterial.stages.Append(newStage);
725 
726  newStage->stageData.SetInt("stagetype", STAGE_TYPE_NORMAL);
727  newStage->enabled = true;
728 
729  idToken token;
730 
731  while ( 1 ) {
732 
733  if ( !src->ExpectAnyToken( &token ) ) {
734  //Todo: Add some error checking here
735  return;
736  }
737 
738  if ( token == "}" ) {
739  break;
740  }
741 
743  continue;
744  }
745 
746  if(!token.Icmp("name")) {
747 
748  idStr str;
749  src->ReadRestOfLine( str );
750  str.StripTrailing('\"');
751  str.StripLeading('\"');
752  newStage->stageData.Set("name", str);
753  continue;
754  }
755  }
756 
757  idStr name;
758  newStage->stageData.GetString("name", "", name);
759  if(name.Length() <= 0)
760  newStage->stageData.Set("name", va("Stage %d", index+1));
761 
762 }
763 
769 void MaterialDoc::AddSpecialMapStage(const char* stageName, const char* map) {
770  MEStage_t* newStage = new MEStage_t();
771  int index = editMaterial.stages.Append(newStage);
772  newStage->stageData.Set("name", stageName);
773  newStage->stageData.Set("map", map);
774  newStage->stageData.SetInt("stagetype", STAGE_TYPE_SPECIALMAP);
775  newStage->enabled = true;
776 }
777 
787 
789 
790  for(int i = 0; i < defs->Num(); i++) {
791  if(!token->Icmp((*defs)[i]->dictName)) {
792 
793  switch((*defs)[i]->type) {
795  {
796  idStr str;
797  src->ReadRestOfLine( str );
798  if((*defs)[i]->quotes) {
799  str.StripTrailing('\"');
800  str.StripLeading('\"');
801  }
802  dict->Set((*defs)[i]->dictName, str);
803  }
804  break;
806  {
807  src->SkipRestOfLine();
808  dict->SetBool((*defs)[i]->dictName, true);
809  }
810  break;
812  {
813  idStr str;
814  src->ReadRestOfLine( str );
815  dict->Set((*defs)[i]->dictName, str);
816  }
817  break;
819  {
820  idStr str;
821  src->ReadRestOfLine( str );
822  dict->Set((*defs)[i]->dictName, str);
823  }
824  break;
825  }
826  return true;
827  }
828  }
829  return false;
830 }
831 
836 
837  for(int i = 0; i < GetStageCount(); i++) {
838  delete editMaterial.stages[i];
839  }
842 }
843 
848 
850 
851  f.WriteFloatString("\n\n/*\n"
852  "\tGenerated by the Material Editor.\n"
853  "\tType 'materialeditor' at the console to launch the material editor.\n"
854  "*/\n" );
855 
856  f.WriteFloatString("%s\n", name.c_str());
857  f.WriteFloatString( "{\n" );
859 
860  for(int i = 0; i < editMaterial.stages.Num(); i++) {
861  if(editMaterial.stages[i]->enabled) {
862  WriteStage(i, &f);
863  }
864  }
865 
866  f.WriteFloatString( "}\n" );
867 
868  return f.GetDataPtr();
869 
870 }
871 
878 }
879 
885 void MaterialDoc::WriteStage(int stage, idFile_Memory* file) {
886 
887  //idStr stageName = GetAttribute(stage, "name");
888  int type = GetAttributeInt(stage, "stagetype");
889  //if(!stageName.Icmp("diffusemap") || !stageName.Icmp("specularmap") || !stageName.Icmp("bumpmap")) {
890  if(type == STAGE_TYPE_SPECIALMAP) {
891  WriteSpecialMapStage(stage, file);
892  return;
893  }
894 
895  file->WriteFloatString( "\t{\n" );
896  idStr name = GetAttribute(stage, "name");
897  if(name.Length() > 0) {
898  file->WriteFloatString("\t\tname\t\"%s\"\n", name.c_str());
899  }
901  file->WriteFloatString( "\t}\n" );
902 
903 }
904 
911  idStr stageName = GetAttribute(stage, "name");
912  idStr map = GetAttribute(stage, "map");
913 
914  file->WriteFloatString( "\t%s\t%s\n", stageName.c_str(), map.c_str() );
915 }
916 
924 void MaterialDoc::WriteMaterialDef(int stage, idFile_Memory* file, int type, int indent) {
925 
926  idStr prefix = "";
927  for(int i = 0; i < indent; i++) {
928  prefix += "\t";
929  }
930 
932  for(int i = 0; i < defs->Num(); i++) {
933  switch((*defs)[i]->type) {
935  {
936  idStr attrib = GetAttribute(stage, (*defs)[i]->dictName);
937  if(attrib.Length() > 0) {
938  if((*defs)[i]->quotes)
939  file->WriteFloatString("%s%s\t\"%s\"\n", prefix.c_str(), (*defs)[i]->dictName.c_str(), attrib.c_str());
940  else
941  file->WriteFloatString("%s%s\t%s\n", prefix.c_str(), (*defs)[i]->dictName.c_str(), attrib.c_str());
942  }
943  }
944  break;
946  {
947  if(GetAttributeBool(stage, (*defs)[i]->dictName))
948  file->WriteFloatString("%s%s\t\n",prefix.c_str(), (*defs)[i]->dictName.c_str());
949  }
950  break;
952  {
953  float val = GetAttributeFloat(stage, (*defs)[i]->dictName);
954  file->WriteFloatString("%s%s\t%f\n", prefix.c_str(), (*defs)[i]->dictName.c_str(), val);
955  }
956  break;
958  {
959  int val = GetAttributeInt(stage, (*defs)[i]->dictName);
960  file->WriteFloatString("%s%s\t%d\n", prefix.c_str(), (*defs)[i]->dictName.c_str(), val);
961  }
962  break;
963  }
964  }
965 }
966 
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)
Definition: Lexer.cpp:1197
void ClearEditMaterial()
Cleans up the edit material by deleting the stage data structures.
float GetFloat(const char *key, const char *defaultString="0") const
Definition: Dict.h:248
GLsizei const GLfloat * value
Definition: glext.h:3614
int GetInt(const char *key, const char *defaultString="0") const
Definition: Dict.h:252
assert(prefInfo.fullscreenBtn)
void StripLeading(const char c)
Definition: Str.cpp:469
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...
bool modified
Definition: MaterialDoc.h:75
idMaterial * renderMaterial
Definition: MaterialDoc.h:72
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...
int Length(void) const
Definition: Str.h:702
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)
Definition: Str.cpp:515
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
Definition: DeclManager.h:140
virtual bool Parse(const char *text, const int textLength)
Definition: Material.cpp:2122
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
Definition: Token.h:71
void SetFlags(int flags)
Definition: Lexer.h:298
const char * GenerateSourceText()
Writes the internal dictionary data to the standard format.
GLuint src
Definition: glext.h:5390
bool applyWaiting
Definition: MaterialDoc.h:76
void Set(const char *key, const char *value)
Definition: Dict.cpp:275
void MoveStage(int from, int to, bool addUndo=true)
Moves a stage from one location to another.
bool Save(const char *fileName=NULL)
Definition: Material.cpp:2367
Undo/Redo operation for stage deletes.
void ApplyMaterialChanges(bool force=false)
Applies any changes to the material.
int i
Definition: process.py:33
void SetFloat(const char *key, float val)
Definition: Dict.h:188
void Copy(const idDict &other)
Definition: Dict.cpp:70
int Icmp(const char *text) const
Definition: Str.h:667
SourceModifyOwner * sourceModifyOwner
Definition: MaterialDoc.h:80
bool deleted
Definition: MaterialDoc.h:77
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)
Definition: Lexer.cpp:992
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
Definition: glext.h:3633
void WriteStage(int stage, idFile_Memory *file)
Writes a single stage.
Definition: Lexer.h:137
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.
GLuint index
Definition: glext.h:3476
const char * GetString(const char *key, const char *defaultString="") const
Definition: Dict.h:240
void AddMaterialUndoModifier(MaterialModifier *mod, bool clearRedo=true)
Adds an undo operation to the undo buffer.
const char * GetDataPtr(void) const
Definition: File.h:144
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
Definition: Dict.h:256
Definition: Dict.h:65
idStr name
Definition: MaterialDoc.h:71
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 Clear(void)
Definition: Dict.cpp:201
void SetMaterialName(const char *materialName, bool addUndo=true)
Sets the material name.
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:2853
bool sourceModify
Definition: MaterialDoc.h:79
int GetStageCount()
Returns the number of stages in this material.
Definition: MaterialDoc.cpp:93
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
Definition: File.cpp:294
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)
Definition: Dict.h:196
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)
Definition: Lexer.cpp:1646
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)
Definition: DeclManager.h:180
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)
Definition: List.h:679
int Append(const type &obj)
Definition: List.h:646
void void Warning(const char *str,...) id_attribute((format(printf
Definition: Lexer.cpp:241
void SetInt(const char *key, int val)
Definition: Dict.h:192
MaterialDocManager * manager
Definition: MaterialDoc.h:70
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.
idDict materialData
Definition: MaterialDoc.h:46
tuple f
Definition: idal.py:89
bool GetAttributeBool(int stage, const char *attribName, const char *defaultString="0")
Returns an attribute bool from the material or a stage.
int Num(void) const
Definition: List.h:265
bool RemoveIndex(int index)
Definition: List.h:849
void EnableAllStages(bool enabled)
Sets the enabled state of all stages.
void ClearRedo()
Clears the redo buffer.
const GLcharARB * name
Definition: glext.h:3629
Implemented by the edit window that is responsible for modifying the material source text...
Definition: MaterialDoc.h:53
idDict stageData
Definition: MaterialDoc.h:38
Definition: Str.h:116
~MaterialDoc(void)
Destructor for MaterialDoc.
Definition: MaterialDoc.cpp:46
HWND GetMaterialEditorWindow()
Returns the handle to the main Material Editor Window.
const char * c_str(void) const
Definition: Str.h:487
int SkipUntilString(const char *string)
Definition: Lexer.cpp:1097
void SetRenderMaterial(idMaterial *material, bool parseMaterial=true, bool parseRenderMatierial=false)
Initializes the MaterialDoc instance with a specific idMaterial.
Definition: MaterialDoc.cpp:58
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
Definition: DeclManager.h:174
char * va(const char *fmt,...)
Definition: Str.cpp:1568
MEMaterial_t editMaterial
Definition: MaterialDoc.h:73
Definition: List.h:84
MEStage_t GetStage(int stage)
Returns a copy of the specified stage.
int SkipRestOfLine(void)
Definition: Lexer.cpp:1113
virtual idStr GetSourceText()
Definition: MaterialDoc.h:59
bool IsStageEnabled(int stage)
Returns the enabled state of a stage.
int ReadToken(idToken *token)
Definition: Lexer.cpp:820
int GetTextLength(void) const
Definition: DeclManager.h:177
Dictionary representation of a Material Stage.
Definition: MaterialDoc.h:37
void ClearStages()
Removes all stages from the material.
idList< MEStage_t * > stages
Definition: MaterialDoc.h:47
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
bool enabled
Definition: MaterialDoc.h:39
MaterialDoc(void)
Constructor for MaterialDoc.
Definition: MaterialDoc.cpp:37
void Clear(void)
Definition: List.h:184