[Igarden-commit] Garden/source/PlanTool ActiveMaterial.h, 1.10, 1.10.2.1 ActiveMaterial.cpp, 1.45,
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2006-11-02 23:47:27
|
Update of /cvsroot/igarden/Garden/source/PlanTool In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv28961 Modified Files: Tag: Release_branch_v1 ActiveMaterial.h ActiveMaterial.cpp Log Message: Add new non-plant material types Index: ActiveMaterial.cpp =================================================================== RCS file: /cvsroot/igarden/Garden/source/PlanTool/ActiveMaterial.cpp,v retrieving revision 1.45 retrieving revision 1.45.2.1 diff -C2 -d -r1.45 -r1.45.2.1 *** ActiveMaterial.cpp 1 Jul 2006 23:17:32 -0000 1.45 --- ActiveMaterial.cpp 2 Nov 2006 23:47:24 -0000 1.45.2.1 *************** *** 62,65 **** --- 62,76 ---- const long kActiveMenuFont = 139; + const long kSeparatorItem = 3; + const long kAccentMenuItem = 4; + const long kDeckMenuItem = 5; + const long kNaturalMenuItem = 6; + const long kOtherMenuItem = 7; + const long kStairMenuItem = 8; + const long kStructureMenuItem = 9; + const long kWalkMenuItem = 10; + const long kWallMenuItem = 11; + const long kWaterMenuItem = 12; + BEGINDISPATCH(ActiveMaterial,XGView) DISPATCHTABLE(KXGAppPostEvent,ActiveMaterial::UseIdleTime) *************** *** 196,200 **** return _backgrounds.Length() + 1; case kHardscapeItems: ! return _hardscape.Length() + 1; default: return 0; --- 207,212 ---- return _backgrounds.Length() + 1; case kHardscapeItems: ! MyAssert(_hardscapeIndex < (sizeof(_hardscape)/sizeof(hardscapeElem_t))); ! return _hardscape[_hardscapeIndex].elem.Length() + 1; default: return 0; *************** *** 222,229 **** return _backgrounds[index-1]; case kHardscapeItems: if(index == 0) return 0; else ! return _hardscape[index-1]; default: return 0; --- 234,242 ---- return _backgrounds[index-1]; case kHardscapeItems: + MyAssert(_hardscapeIndex < (sizeof(_hardscape)/sizeof(hardscapeElem_t))); if(index == 0) return 0; else ! return (_hardscape[_hardscapeIndex]).elem[index-1]; default: return 0; *************** *** 301,305 **** _palettePopup->Insert(1,"All in this plot"); _palettePopup->Insert(2,"Backgrounds"); ! _palettePopup->Insert(3,"Non-Plant"); popupInfo.fViewID = kMaterialSelectMenu; --- 314,327 ---- _palettePopup->Insert(1,"All in this plot"); _palettePopup->Insert(2,"Backgrounds"); ! _palettePopup->Insert(3,"-"); ! _palettePopup->Insert(kAccentMenuItem,"Accents"); ! _palettePopup->Insert(kDeckMenuItem,"Decks and Patios"); ! _palettePopup->Insert(kNaturalMenuItem,"Natural Items"); ! _palettePopup->Insert(kOtherMenuItem,"Other Hardscape"); ! _palettePopup->Insert(kStairMenuItem,"Stairs"); ! _palettePopup->Insert(kStructureMenuItem,"Structures"); ! _palettePopup->Insert(kWalkMenuItem,"Walks"); ! _palettePopup->Insert(kWallMenuItem,"Walls and Fences"); ! _palettePopup->Insert(kWaterMenuItem,"Water Features"); popupInfo.fViewID = kMaterialSelectMenu; *************** *** 388,425 **** _needsUIUpdate = false; ! SourceMaterialFile *sources; ! UInt32 n, numMaterials, var, numVariants; ! Material *mat, *varMat; ! ! sources = SourceMaterialFile::GetSourceDatabase(); ! numMaterials = DBPersist::NumRows(sources, kMaterialBodyCID); ! for(n = 0; n < numMaterials; n++) ! { ! mat = new Material(sources, n); ! if((mat->GetMaterialType() & kMajorMaterialType) == kMaterialTypeBackground) ! { ! _backgrounds.push_back(mat); ! } ! else if((mat->GetMaterialType() & kMajorMaterialType) == kMaterialTypeStructure) ! { ! numVariants = mat->NumVariants(); ! for(var = 0; var < numVariants; var++) ! { ! Variant *variant; ! variantID_t vid; ! ! variant = mat->GetIndexedVariant(var); ! variant->GetVariantID(vid); ! varMat = mat->CloneAsVariant(vid); ! _hardscape.push_back(varMat); ! } ! ! _hardscape.push_back(mat); ! } ! else ! { ! delete mat; ! } ! } } // --------------------------------------------------------------------------- --- 410,414 ---- _needsUIUpdate = false; ! RebuildHardscapeMenu(); } // --------------------------------------------------------------------------- *************** *** 536,539 **** --- 525,577 ---- } } + + // --------------------------------------------------------------------------- + /// RebuildHardscapeMenu + // + void ActiveMaterial::RebuildHardscapeMenu() + { + SourceMaterialFile *sources; + UInt32 n, numMaterials, var, numVariants; + Material *mat, *varMat; + uint32 index; + + sources = SourceMaterialFile::GetSourceDatabase(); + numMaterials = DBPersist::NumRows(sources, kMaterialBodyCID); + for(n = 0; n < numMaterials; n++) + { + mat = new Material(sources, n); + if((mat->GetMaterialType() & kMajorMaterialType) == kMaterialTypeBackground) + { + _backgrounds.push_back(mat); + } + else if((mat->GetMaterialType() & kMajorMaterialType) == kMaterialTypeHardscape) + { + index = mat->GetMaterialType() & kMinorMaterialType; + printf("Mat %s is index %ld\n", mat->GetCommonName().c_str(), index); + if(index > (sizeof(_hardscape)/sizeof(hardscapeElem_t))) + index = kMaterialTypeHardscape & kMinorMaterialType; + + + numVariants = mat->NumVariants(); + for(var = 0; var < numVariants; var++) + { + Variant *variant; + variantID_t vid; + + variant = mat->GetIndexedVariant(var); + variant->GetVariantID(vid); + varMat = mat->CloneAsVariant(vid); + _hardscape[index].elem.push_back(varMat); + } + + _hardscape[index].elem.push_back(mat); + } + else + { + delete mat; + } + } + } + // --------------------------------------------------------------------------- // void ActiveMaterial::PickMaterial( UInt32 index ) *************** *** 753,783 **** case 0: _paletteType = kUsePalette; - if(GetNumMaterials() > 0) - PickMaterial(0); - result = 0; break; case 1: _paletteType = kInThisPlot; RebuildPlotPalette(); - if(GetNumMaterials() > 0) - PickMaterial(0); - result = 0; break; case 2: _paletteType = kBackgroundItems; RebuildPlotPalette(); - if(GetNumMaterials() > 0) - PickMaterial(0); - result = 0; break; case 3: _paletteType = kHardscapeItems; RebuildPlotPalette(); - if(GetNumMaterials() > 0) - PickMaterial(0); - result = 0; break; } UpdateMaterialPaletteMenu(); break; --- 791,858 ---- case 0: _paletteType = kUsePalette; break; case 1: _paletteType = kInThisPlot; RebuildPlotPalette(); break; case 2: _paletteType = kBackgroundItems; RebuildPlotPalette(); break; case 3: + return -1; // Drop out completely, it's the separator + case kAccentMenuItem: _paletteType = kHardscapeItems; + _hardscapeIndex = kMaterialTypeAccents & kMinorMaterialType; + RebuildPlotPalette(); + break; + case kDeckMenuItem: + _paletteType = kHardscapeItems; + _hardscapeIndex = kMaterialTypeDeckPatio & kMinorMaterialType; + RebuildPlotPalette(); + break; + case kNaturalMenuItem: + _paletteType = kHardscapeItems; + _hardscapeIndex = kMaterialTypeNaturalItems & kMinorMaterialType; + RebuildPlotPalette(); + break; + case kOtherMenuItem: + _paletteType = kHardscapeItems; + _hardscapeIndex = kMaterialTypeHardscape & kMinorMaterialType; + RebuildPlotPalette(); + break; + case kStairMenuItem: + _paletteType = kHardscapeItems; + _hardscapeIndex = kMaterialTypeSteps & kMinorMaterialType; + RebuildPlotPalette(); + break; + case kStructureMenuItem: + _paletteType = kHardscapeItems; + _hardscapeIndex = kMaterialTypeStructure & kMinorMaterialType; + RebuildPlotPalette(); + break; + case kWalkMenuItem: + _paletteType = kHardscapeItems; + _hardscapeIndex = kMaterialTypeWalks & kMinorMaterialType; + RebuildPlotPalette(); + break; + case kWallMenuItem: + _paletteType = kHardscapeItems; + _hardscapeIndex = kMaterialTypeWallsFences & kMinorMaterialType; + RebuildPlotPalette(); + break; + case kWaterMenuItem: + _paletteType = kHardscapeItems; + _hardscapeIndex = kMaterialTypeWaterFeature & kMinorMaterialType; RebuildPlotPalette(); break; } + if(_hardscapeIndex > (sizeof(_hardscape)/sizeof(hardscapeElem_t))) + _hardscapeIndex = kMaterialTypeHardscape & kMinorMaterialType; + UpdateMaterialPaletteMenu(); + if(GetNumMaterials() > 0) + PickMaterial(0); + result = 0; break; Index: ActiveMaterial.h =================================================================== RCS file: /cvsroot/igarden/Garden/source/PlanTool/ActiveMaterial.h,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -C2 -d -r1.10 -r1.10.2.1 *** ActiveMaterial.h 28 Oct 2005 11:33:56 -0000 1.10 --- ActiveMaterial.h 2 Nov 2006 23:47:24 -0000 1.10.2.1 *************** *** 49,58 **** typedef enum { ! kInThisPlot, ! kUsePalette, ! kBackgroundItems, ! kHardscapeItems } paletteType_t; class ActiveMaterial : public XGView , public XGDropper { --- 49,63 ---- typedef enum { ! kInThisPlot = 0, ! kUsePalette = 1, ! kBackgroundItems = 2, ! kHardscapeItems = 3 } paletteType_t; + typedef struct + { + materialArray_t elem; + } hardscapeElem_t; + class ActiveMaterial : public XGView , public XGDropper { *************** *** 91,94 **** --- 96,100 ---- Material* GetIndexedMaterial(UInt32 index); void RebuildPlotPalette(); + void RebuildHardscapeMenu(); private: // methods *************** *** 108,112 **** MaterialCollection* _topPalette; XGDynArray<Material*> _backgrounds; ! XGDynArray<Material*> _hardscape; bool _needsUIUpdate; materialID_t _newUpdateID; --- 114,119 ---- MaterialCollection* _topPalette; XGDynArray<Material*> _backgrounds; ! uint32 _hardscapeIndex; ! hardscapeElem_t _hardscape[10]; bool _needsUIUpdate; materialID_t _newUpdateID; |