diff options
| author | Japa | 2010-05-04 10:54:06 +0000 |
|---|---|---|
| committer | Japa | 2010-05-04 10:54:06 +0000 |
| commit | 4a51199a91b37a97edca760ffa22629499fd8d83 (patch) | |
| tree | a84f3f5d37263034d38b347ed5d48a28319c6497 /ContentLoader.cpp | |
| parent | 6f188cc32530c8a422f1223741acb81ae7535c4d (diff) | |
| download | stonesense-4a51199a91b37a97edca760ffa22629499fd8d83.tar.gz stonesense-4a51199a91b37a97edca760ffa22629499fd8d83.tar.bz2 stonesense-4a51199a91b37a97edca760ffa22629499fd8d83.tar.xz | |
updated to the latest DFhack, added the functionality to have seperate sprites for blocks, boulders, etc.
Diffstat (limited to 'ContentLoader.cpp')
| -rw-r--r-- | ContentLoader.cpp | 82 |
1 files changed, 46 insertions, 36 deletions
diff --git a/ContentLoader.cpp b/ContentLoader.cpp index c5ada45..933860a 100644 --- a/ContentLoader.cpp +++ b/ContentLoader.cpp @@ -42,9 +42,9 @@ void DumpPrefessionNamesToDisk(vector<string> material, const char* filename){ }
bool ContentLoader::Load(API& DF){
/*draw_textf_border(font,
- al_get_bitmap_width(al_get_target_bitmap())/2,
- al_get_bitmap_height(al_get_target_bitmap())/2,
- ALLEGRO_ALIGN_CENTRE, "Loading...");
+ al_get_bitmap_width(al_get_target_bitmap())/2,
+ al_get_bitmap_height(al_get_target_bitmap())/2,
+ ALLEGRO_ALIGN_CENTRE, "Loading...");
al_flip_display();*/
//flush old config
flushBuildingConfig(&buildingConfigs);
@@ -70,13 +70,10 @@ bool ContentLoader::Load(API& DF){ //// make a copy for our use
//classIdStrings = *tempClasses;
- DFHack::Materials * Mats = DF.getMaterials(); - if(inorganicMaterials.empty()) - Mats->ReadInorganicMaterials (inorganicMaterials); - if(organicMaterials.empty()) - Mats->ReadOrganicMaterials (organicMaterials); - if(creatureMaterials.empty()) - Mats->ReadCreatureTypes (creatureMaterials);
+ Mats = DF.getMaterials(); + Mats->ReadInorganicMaterials(); + Mats->ReadOrganicMaterials (); + Mats->ReadCreatureTypes ();
Bld = DF.getBuildings();
DFHack::memory_info *mem = DF.getMemoryInfo();
if(professionStrings.empty())
@@ -115,7 +112,7 @@ bool ContentLoader::Load(API& DF){ //DumpPrefessionNamesToDisk(professionStrings, "priofessiondump.txt");
//DumpPrefessionNamesToDisk(classIdStrings, "buildingdump.txt");
//DumpMaterialNamesToDisk(inorganicMaterials, "DUMPSES.txt");
- //DumpMaterialNamesToDisk(creatureMaterials, "creaturedump.txt");
+ //DumpMaterialNamesToDisk(Mats->race, "creaturedump.txt");
//DF.Resume();
@@ -154,8 +151,8 @@ bool ContentLoader::parseContentIndexFile( char* filepath ) /*
al_clear_to_color(al_map_rgb(0,0,0));
draw_textf_border(font, al_get_bitmap_width(al_get_target_bitmap())/2,
- al_get_bitmap_height(al_get_target_bitmap())/2,
- ALLEGRO_ALIGN_CENTRE, "Loading %s...", filepath);
+ al_get_bitmap_height(al_get_target_bitmap())/2,
+ ALLEGRO_ALIGN_CENTRE, "Loading %s...", filepath);
al_flip_display();
*/
string line;
@@ -230,8 +227,8 @@ bool ContentLoader::parseContentXMLFile( char* filepath ){ /*
al_clear_to_color(al_map_rgb(0,0,0));
draw_textf_border(font, al_get_bitmap_width(al_get_target_bitmap())/2,
- al_get_bitmap_height(al_get_target_bitmap())/2,
- ALLEGRO_ALIGN_CENTRE, "Loading %s...", filepath);
+ al_get_bitmap_height(al_get_target_bitmap())/2,
+ ALLEGRO_ALIGN_CENTRE, "Loading %s...", filepath);
al_flip_display();*/
TiXmlDocument doc( filepath );
if(!doc.LoadFile())
@@ -279,11 +276,11 @@ bool ContentLoader::parseCreatureContent(TiXmlElement* elemRoot ){ }
bool ContentLoader::parseShrubContent(TiXmlElement* elemRoot ){
- return addSingleVegetationConfig( elemRoot, &shrubConfigs, organicMaterials );
+ return addSingleVegetationConfig( elemRoot, &shrubConfigs, Mats->organic );
}
bool ContentLoader::parseTreeContent(TiXmlElement* elemRoot ){
- return addSingleVegetationConfig( elemRoot, &treeConfigs, organicMaterials );
+ return addSingleVegetationConfig( elemRoot, &treeConfigs, Mats->organic );
}
bool ContentLoader::parseTerrainContent(TiXmlElement* elemRoot ){
@@ -382,19 +379,19 @@ int lookupMaterialIndex(int matType, const char* strValue) // for appropriate elements, look up subtype
if (matType == INORGANIC)
{
- typeVector=&(contentLoader.inorganicMaterials);
+ typeVector=&(contentLoader.Mats->inorganic);
}
else if (matType == WOOD)
{
- typeVector=&(contentLoader.organicMaterials);
+ typeVector=&(contentLoader.Mats->organic);
}
else if (matType == PLANTCLOTH)
{
- typeVector=&(contentLoader.organicMaterials);
+ typeVector=&(contentLoader.Mats->organic);
}
else if (matType == LEATHER)
{
- typeVector=&(contentLoader.creatureMaterials);
+ typeVector=&(contentLoader.Mats->race);
}
else
{
@@ -433,19 +430,19 @@ const char *lookupMaterialName(int matType,int matIndex) // for appropriate elements, look up subtype
if (matType == INORGANIC)
{
- typeVector=&(contentLoader.inorganicMaterials);
+ typeVector=&(contentLoader.Mats->inorganic);
}
else if (matType == WOOD)
{
- typeVector=&(contentLoader.organicMaterials);
+ typeVector=&(contentLoader.Mats->organic);
}
else if (matType == PLANTCLOTH)
{
- typeVector=&(contentLoader.organicMaterials);
+ typeVector=&(contentLoader.Mats->organic);
}
else if (matType == LEATHER)
{
- typeVector=&(contentLoader.creatureMaterials);
+ typeVector=&(contentLoader.Mats->race);
}
else
{
@@ -463,12 +460,29 @@ const char *lookupTreeName(int matIndex) return NULL;
vector<t_matgloss>* typeVector;
// for appropriate elements, look up subtype
- typeVector=&(contentLoader.organicMaterials);
+ typeVector=&(contentLoader.Mats->organic);
if (matIndex >= typeVector->size())
return NULL;
return (*typeVector)[matIndex].id;
}
+const char * lookupFormName(int formType)
+{
+ switch (formType)
+ {
+ case constr_bar:
+ return "bar";
+ case constr_block:
+ return "block";
+ case constr_boulder:
+ return "boulder";
+ case constr_logs:
+ return "log";
+ default:
+ return NULL;
+ }
+}
+
uint8_t lookupMaterialFore(int matType,int matIndex)
{
if (matIndex < 0)
@@ -489,8 +503,8 @@ uint8_t lookupMaterialFore(int matType,int matIndex) //}
//else
//{
- //maybe allow some more in later
- return NULL;
+ //maybe allow some more in later
+ return NULL;
//}
if (matIndex >= typeVector->size())
return NULL;
@@ -517,8 +531,8 @@ uint8_t lookupMaterialBack(int matType,int matIndex) //}
//else
//{
- //maybe allow some more in later
- return NULL;
+ //maybe allow some more in later
+ return NULL;
//}
if (matIndex >= typeVector->size())
return NULL;
@@ -545,8 +559,8 @@ uint8_t lookupMaterialBright(int matType,int matIndex) //}
//else
//{
- //maybe allow some more in later
- return NULL;
+ //maybe allow some more in later
+ return NULL;
//}
if (matIndex >= typeVector->size())
return NULL;
@@ -575,10 +589,6 @@ void ContentLoader::flushCreatureConfig() }
// make big enough to hold all creatures
creatureConfigs.clear();
- if (num <= creatureMaterials.size())
- {
- creatureConfigs.resize(creatureMaterials.size()+1,NULL);
- }
}
ALLEGRO_COLOR lookupMaterialColor(int matType,int matIndex)
{
|
