summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJapa Illo2012-03-26 22:03:09 +0200
committerJapa Illo2012-03-26 22:03:09 +0200
commit4d146bbbba642b08465d8ee275612f29bfbbe7ed (patch)
treeb7721d2d64d338ee5b57be967ade98f0b9740c8c
parentdf37cc7e59b3cf5fadfa680a68793b91810a30ff (diff)
downloadstonesense-4d146bbbba642b08465d8ee275612f29bfbbe7ed.tar.gz
stonesense-4d146bbbba642b08465d8ee275612f29bfbbe7ed.tar.bz2
stonesense-4d146bbbba642b08465d8ee275612f29bfbbe7ed.tar.xz
Put in sprites for all the items, also made errors go to the console.
Signed-off-by: Japa Illo <japa.mala.illo@gmail.com>
-rw-r--r--Block.cpp1
-rw-r--r--Block.h1
-rw-r--r--ContentLoader.cpp2
-rw-r--r--Creatures.cpp1
-rw-r--r--ItemConfiguration.cpp78
-rw-r--r--ItemConfiguration.h2
-rw-r--r--SpriteObjects.cpp4
-rw-r--r--main.cpp6
-rw-r--r--resources/items/BARREL.xml5
-rw-r--r--resources/items/BIN.xml5
-rw-r--r--resources/items/WOOD.xml5
-rw-r--r--resources/items/index.txt4
-rw-r--r--resources/items/items.pngbin10354 -> 10628 bytes
-rw-r--r--resources/items/items.xml84
14 files changed, 139 insertions, 59 deletions
diff --git a/Block.cpp b/Block.cpp
index 4327792..dd1f2b7 100644
--- a/Block.cpp
+++ b/Block.cpp
@@ -37,6 +37,7 @@ Worn_Item::Worn_Item()
{
matt.index = -1;
matt.type = -1;
+ dyed = 0;
}
Block::Block(WorldSegment* ownerSegment)
diff --git a/Block.h b/Block.h
index 15ac6eb..a3d8f58 100644
--- a/Block.h
+++ b/Block.h
@@ -16,6 +16,7 @@ struct Effect
struct Worn_Item
{
DFHack::t_matglossPair matt;
+ bool dyed;
int8_t rating;
Worn_Item();
};
diff --git a/ContentLoader.cpp b/ContentLoader.cpp
index 94a7e00..6a57118 100644
--- a/ContentLoader.cpp
+++ b/ContentLoader.cpp
@@ -375,7 +375,7 @@ bool ContentLoader::parseContentXMLFile( const char* filepath ){
runningResult &= parseColorContent( elemRoot );
else if( elementType.compare( "fluids" ) == 0 )
runningResult &= parseFluidContent( elemRoot );
- else if( elementType.compare( "item" ) == 0 )
+ else if( elementType.compare( "items" ) == 0 )
runningResult &= parseItemContent( elemRoot );
else
contentError("Unrecognised root element",elemRoot);
diff --git a/Creatures.cpp b/Creatures.cpp
index 414e615..ee80b20 100644
--- a/Creatures.cpp
+++ b/Creatures.cpp
@@ -438,6 +438,7 @@ void ReadCreaturesToSegment( DFHack::Core& DF, WorldSegment* segment)
continue;
equipment.matt.type = Improvement_Thread->dye.mat_type;
equipment.matt.index = Improvement_Thread->dye.mat_index;
+ equipment.dyed = 1;
}
}
}
diff --git a/ItemConfiguration.cpp b/ItemConfiguration.cpp
index 49553c0..ebdeedb 100644
--- a/ItemConfiguration.cpp
+++ b/ItemConfiguration.cpp
@@ -16,34 +16,53 @@ ItemConfiguration::~ItemConfiguration()
subItems.clear();
}
-
bool addSingleItemConfig( TiXmlElement* elemRoot)
{
- const char* strGameID = elemRoot->Attribute("game_type");
- const char* strGameSub = elemRoot->Attribute("game_subtype");
-
- if (strGameID == NULL || strGameID[0] == 0)
- {
- contentError("<item> node must game_type attribute",elemRoot);
- return false;
- }
+ int basefile = INVALID_INDEX;
+ const char* filename = elemRoot->Attribute("file");
+ if (filename != NULL && filename[0] != 0)
+ {
+ basefile = loadConfigImgFile((char*)filename,elemRoot);
+ if(basefile == -1) return false;
+ }
+
+
+ TiXmlElement* elemFloor = elemRoot->FirstChildElement("item");
+ while( elemFloor )
+ {
+ parseItemElement( elemFloor, basefile);
+ elemFloor = elemFloor->NextSiblingElement("item");
+ }
+ return true;
+}
+
+bool parseItemElement( TiXmlElement* elemRoot, int basefile)
+{
+ const char* strGameID = elemRoot->Attribute("game_type");
+ const char* strGameSub = elemRoot->Attribute("game_subtype");
+
+ if (strGameID == NULL || strGameID[0] == 0)
+ {
+ contentError("<item> node must game_type attribute",elemRoot);
+ return false;
+ }
item_type::item_type main_type = (item_type::item_type) INVALID_INDEX;
- int subtype = INVALID_INDEX;
- string game_type_s;
- FOR_ENUM_ITEMS(item_type,i)
- {
- game_type_s = strGameID;
- if (game_type_s == ENUM_KEY_STR(item_type,i))
- {
- main_type = i;
- break;
- }
- }
- if(main_type == (item_type::item_type) INVALID_INDEX)
- {
- contentError("<item> unknown game_type value",elemRoot);
- return false;
- }
+ int subtype = INVALID_INDEX;
+ string game_type_s;
+ FOR_ENUM_ITEMS(item_type,i)
+ {
+ game_type_s = strGameID;
+ if (game_type_s == ENUM_KEY_STR(item_type,i))
+ {
+ main_type = i;
+ break;
+ }
+ }
+ if(main_type == (item_type::item_type) INVALID_INDEX)
+ {
+ contentError("<item> unknown game_type value",elemRoot);
+ return false;
+ }
if(strGameSub && strGameSub[0] != 0)
{
@@ -62,15 +81,6 @@ bool addSingleItemConfig( TiXmlElement* elemRoot)
else subtype = itemdef.subtype;
}
- int basefile = -1;
-
- const char* filename = elemRoot->Attribute("file");
- if (filename != NULL && filename[0] != 0)
- {
- basefile = loadConfigImgFile((char*)filename, elemRoot);
- if(basefile == -1) return false;
- }
-
c_sprite sprite;
diff --git a/ItemConfiguration.h b/ItemConfiguration.h
index 3fd8b80..92ea46b 100644
--- a/ItemConfiguration.h
+++ b/ItemConfiguration.h
@@ -23,5 +23,5 @@ public:
};
bool addSingleItemConfig( TiXmlElement* elemRoot);
-
+bool parseItemElement( TiXmlElement* elemRoot, int basefile);
void flushItemConfig(vector<ItemConfiguration *> &config); \ No newline at end of file
diff --git a/SpriteObjects.cpp b/SpriteObjects.cpp
index 1896e4a..ff5af5e 100644
--- a/SpriteObjects.cpp
+++ b/SpriteObjects.cpp
@@ -1026,11 +1026,11 @@ ALLEGRO_COLOR c_sprite::get_color(void* block)
return al_map_rgb(255, 255, 0);
if(b->inv->item[itemtype][itemsubtype].empty())
return al_map_rgb(0, 0, 255);
- return lookupMaterialColor(b->inv->item[itemtype][itemsubtype][0].matt.type, b->inv->item[itemtype][itemsubtype][0].matt.index);
+ return lookupMaterialColor(b->inv->item[itemtype][itemsubtype][0].matt.type, b->inv->item[itemtype][itemsubtype][0].matt.index, b->inv->item[itemtype][itemsubtype][0].dyed);
}
else return al_map_rgb(255,255,255);
case ShadeItem:
- return lookupMaterialColor(b->Item.matt.type, b->Item.matt.index);
+ return lookupMaterialColor(b->Item.matt.type, b->Item.matt.index, b->Item.dyed);
default:
return al_map_rgb(255, 255, 255);
} ;
diff --git a/main.cpp b/main.cpp
index fd6d9e8..f3d6e9d 100644
--- a/main.cpp
+++ b/main.cpp
@@ -81,12 +81,12 @@ ALLEGRO_BITMAP* load_bitmap_withWarning(const char* path)
void LogError(const char* msg, ...){
va_list arglist;
va_start(arglist, msg);
- // char buf[200] = {0};
- // vsprintf(buf, msg, arglist);
+ char buf[512] = {0};
+ vsprintf(buf, msg, arglist);
+ Core::printerr(buf);
FILE* fp = fopen( "Stonesense.log", "a");
if(fp)
vfprintf( fp, msg, arglist );
-// Core::printerr(msg, arglist);
va_end(arglist);
fclose(fp);
}
diff --git a/resources/items/BARREL.xml b/resources/items/BARREL.xml
deleted file mode 100644
index 01a7c6e..0000000
--- a/resources/items/BARREL.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" ?>
-
-
-<item file="items.png" game_type="BARREL" index = "69" color="item">
-</item>
diff --git a/resources/items/BIN.xml b/resources/items/BIN.xml
deleted file mode 100644
index fa564a9..0000000
--- a/resources/items/BIN.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" ?>
-
-
-<item file="items.png" game_type="BIN" index = "70" color="item">
-</item>
diff --git a/resources/items/WOOD.xml b/resources/items/WOOD.xml
deleted file mode 100644
index 73084d4..0000000
--- a/resources/items/WOOD.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" ?>
-
-
-<item file="items.png" game_type="WOOD" index = "0" color="item">
-</item>
diff --git a/resources/items/index.txt b/resources/items/index.txt
index 202f1c9..2d1ed4a 100644
--- a/resources/items/index.txt
+++ b/resources/items/index.txt
@@ -1,3 +1 @@
-BARREL.xml
-BIN.xml
-WOOD.xml
+items.xml
diff --git a/resources/items/items.png b/resources/items/items.png
index a8b878d..13b87d7 100644
--- a/resources/items/items.png
+++ b/resources/items/items.png
Binary files differ
diff --git a/resources/items/items.xml b/resources/items/items.xml
new file mode 100644
index 0000000..c499957
--- /dev/null
+++ b/resources/items/items.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<items file="items.png">
+ <item game_type="BAR" sheetIndex="23" color="item" />
+ <item game_type="SMALLGEM" sheetIndex="16" />
+ <item game_type="BLOCKS" sheetIndex="76" />
+ <item game_type="ROUGH" sheetIndex="16" />
+ <item game_type="BOULDER" sheetIndex="1" color="item" />
+ <item game_type="WOOD" sheetIndex="0" color="item" />
+ <item game_type="DOOR" sheetIndex="49" color="item" />
+ <item game_type="FLOODGATE" sheetIndex="51" color="item" />
+ <item game_type="BED" sheetIndex="48" color="item" />
+ <item game_type="CHAIR" sheetIndex="45" color="item" />
+ <item game_type="CHAIN" sheetIndex="21" color="item" />
+ <item game_type="FLASK" sheetIndex="18" />
+ <item game_type="GOBLET" sheetIndex="28" color="item" />
+ <item game_type="INSTRUMENT" sheetIndex="40" />
+ <item game_type="TOY" sheetIndex="80" />
+ <item game_type="WINDOW" sheetIndex="55" />
+ <item game_type="CAGE" sheetIndex="22" />
+ <item game_type="BARREL" sheetIndex="69" color="item" />
+ <item game_type="BUCKET" sheetIndex="7" />
+ <item game_type="ANIMALTRAP" sheetIndex="81" />
+ <item game_type="TABLE" sheetIndex="46" color="item" />
+ <item game_type="COFFIN" sheetIndex="82" color="item" />
+ <item game_type="STATUE" sheetIndex="53" color="item" />
+ <item game_type="CORPSE" sheetIndex="35" />
+ <item game_type="WEAPON" sheetIndex="31" />
+ <item game_type="ARMOR" sheetIndex="67" />
+ <item game_type="SHOES" sheetIndex="13" />
+ <item game_type="SHIELD" sheetIndex="12" />
+ <item game_type="HELM" sheetIndex="68" />
+ <item game_type="GLOVES" sheetIndex="14" />
+ <item game_type="BOX" sheetIndex="58" color="item" />
+ <item game_type="BIN" sheetIndex="70" color="item" />
+ <item game_type="ARMORSTAND" sheetIndex="56" />
+ <item game_type="WEAPONRACK" sheetIndex="57" />
+ <item game_type="CABINET" sheetIndex="47" />
+ <item game_type="FIGURINE" sheetIndex="41" color="item" />
+ <item game_type="AMULET" sheetIndex="42" />
+ <item game_type="SCEPTER" sheetIndex="27" />
+ <item game_type="AMMO" sheetIndex="8" />
+ <item game_type="CROWN" sheetIndex="39" color="item" />
+ <item game_type="RING" sheetIndex="29" color="item" />
+ <item game_type="EARRING" sheetIndex="29" />
+ <item game_type="BRACELET" sheetIndex="38" color="item" />
+ <item game_type="GEM" sheetIndex="17" />
+ <item game_type="ANVIL" sheetIndex="52" />
+ <item game_type="CORPSEPIECE" sheetIndex="34" />
+ <item game_type="REMAINS" sheetIndex="34" />
+ <item game_type="MEAT" sheetIndex="24" />
+ <item game_type="FISH" sheetIndex="24" />
+ <item game_type="FISH_RAW" sheetIndex="72" />
+ <!-- 50: vermin -->
+ <!-- 51: pet vermin -->
+ <item game_type="SEEDS" sheetIndex="73" />
+ <item game_type="PLANT" sheetIndex="44" />
+ <item game_type="SKIN_TANNED" sheetIndex="19" />
+ <item game_type="LEAVES" sheetIndex="77" />
+ <item game_type="THREAD" sheetIndex="37" color="item" />
+ <item game_type="CLOTH" sheetIndex="36" color="item" />
+ <item game_type="TOTEM" sheetIndex="30" />
+ <item game_type="PANTS" sheetIndex="66" />
+ <item game_type="BACKPACK" sheetIndex="71" />
+ <item game_type="QUIVER" sheetIndex="9" />
+ <item game_type="CATAPULTPARTS" sheetIndex="84" />
+ <item game_type="BALLISTAPARTS" sheetIndex="84" />
+ <item game_type="SIEGEAMMO" sheetIndex="85" />
+ <item game_type="BALLISTAARROWHEAD" sheetIndex="78" />
+ <item game_type="TRAPPARTS" sheetIndex="32" color="item" />
+ <item game_type="TRAPCOMP" sheetIndex="33" color="item" />
+ <item game_type="DRINK" sheetIndex="74" />
+ <item game_type="POWDER_MISC" sheetIndex="75" />
+ <item game_type="CHEESE" sheetIndex="79" />
+ <item game_type="FOOD" sheetIndex="26" />
+ <item game_type="LIQUID_MISC" sheetIndex="74" />
+ <item game_type="COIN" sheetIndex="73" />
+ <item game_type="GLOB" sheetIndex="25" />
+ <!-- 75: rock -->
+ <item game_type="PIPE_SECTION" sheetIndex="86" color="item" />
+ <item game_type="HATCH_COVER" sheetIndex="50" color="item" />
+ <item game_type="GRATE" sheetIndex="54" color="item" />
+ <item game_type="QUERN" sheetIndex="83" color="item" />
+ <item game_type="MILLSTONE" sheetIndex="83" color="item" />
+</items> \ No newline at end of file