diff options
| author | Japa Illo | 2012-03-15 12:53:19 +0100 |
|---|---|---|
| committer | Japa Illo | 2012-03-15 12:53:19 +0100 |
| commit | 1bd9b2a540e52795cd3a9fbc402a1ee9736e1b70 (patch) | |
| tree | 5a07fe3d331f690950327d0923e61bb78e3b7cc1 | |
| parent | 42de27ed582314bfb08fbf4ae61f6bdd8fb5fb8f (diff) | |
| download | stonesense-1bd9b2a540e52795cd3a9fbc402a1ee9736e1b70.tar.gz stonesense-1bd9b2a540e52795cd3a9fbc402a1ee9736e1b70.tar.bz2 stonesense-1bd9b2a540e52795cd3a9fbc402a1ee9736e1b70.tar.xz | |
Got dyes to be detected properly. Also made the equipment drawing far neater.
Removed zoom in smoothing. it just looks bad.
Signed-off-by: Japa Illo <japa.mala.illo@gmail.com>
| -rw-r--r-- | Block.h | 11 | ||||
| -rw-r--r-- | Creatures.cpp | 98 | ||||
| -rw-r--r-- | GUI.cpp | 119 | ||||
| -rw-r--r-- | Occlusion_Test.cpp | 10 | ||||
| -rw-r--r-- | SpriteObjects.cpp | 118 | ||||
| -rw-r--r-- | main.cpp | 4 | ||||
| -rw-r--r-- | resources/creatures/clothed_Dwarves.xml | 1 |
7 files changed, 80 insertions, 281 deletions
@@ -3,6 +3,8 @@ #include "common.h"
#include "SpriteObjects.h"
#include "TileTypes.h"
+#include "df/item_type.h"
+
class WorldSegment;
struct Effect
@@ -20,13 +22,8 @@ struct Worn_Item struct Unit_Inventory
{
- std::vector<Worn_Item> Weapons;
- std::vector<Worn_Item> Armor;
- std::vector<Worn_Item> Shoes;
- std::vector<Worn_Item> Shield;
- std::vector<Worn_Item> Helm;
- std::vector<Worn_Item> Gloves;
- std::vector<Worn_Item> Pants;
+ //[item_type][item_subtype][item_number]
+ std::vector<std::vector<std::vector<Worn_Item>>> item;
};
diff --git a/Creatures.cpp b/Creatures.cpp index 0c5a906..5e1781c 100644 --- a/Creatures.cpp +++ b/Creatures.cpp @@ -9,6 +9,9 @@ #include "DataDefs.h"
#include "df/world.h"
#include "df/unit_inventory_item.h"
+#include "df/item_constructed.h"
+#include "df/itemimprovement.h"
+#include "df/itemimprovement_threadst.h"
//vector<t_matgloss> v_creatureNames;
//vector<CreatureConfiguration> creatureTypes;
@@ -403,69 +406,40 @@ void ReadCreaturesToSegment( DFHack::Core& DF, WorldSegment* segment) item_type::item_type type = item->getType();
int8_t armor = item->getEffectiveArmorLevel();
- //FIXME: this could be made nicer. Somehow
- switch (item->getType())
- {
- case item_type::WEAPON:
- if(!b->inv)
- b->inv = new(Unit_Inventory);
- if(b->inv->Weapons.size() <= item->getSubtype())
- b->inv->Weapons.resize(item->getSubtype()+1);
- b->inv->Weapons[item->getSubtype()].matt.type = item->getActualMaterial();
- b->inv->Weapons[item->getSubtype()].matt.index = item->getActualMaterialIndex();
- break;
- case item_type::ARMOR:
- if(!b->inv)
- b->inv = new(Unit_Inventory);
- if(b->inv->Armor.size() <= item->getSubtype())
- b->inv->Armor.resize(item->getSubtype()+1);
- b->inv->Armor[item->getSubtype()].matt.type = item->getActualMaterial();
- b->inv->Armor[item->getSubtype()].matt.index = item->getActualMaterialIndex();
- break;
- case item_type::SHOES:
- if(!b->inv)
- b->inv = new(Unit_Inventory);
- if(b->inv->Shoes.size() <= item->getSubtype())
- b->inv->Shoes.resize(item->getSubtype()+1);
- b->inv->Shoes[item->getSubtype()].matt.type = item->getActualMaterial();
- b->inv->Shoes[item->getSubtype()].matt.index = item->getActualMaterialIndex();
- break;
- case item_type::SHIELD:
- if(!b->inv)
- b->inv = new(Unit_Inventory);
- if(b->inv->Shield.size() <= item->getSubtype())
- b->inv->Shield.resize(item->getSubtype()+1);
- b->inv->Shield[item->getSubtype()].matt.type = item->getActualMaterial();
- b->inv->Shield[item->getSubtype()].matt.index = item->getActualMaterialIndex();
- break;
- case item_type::HELM:
- if(!b->inv)
- b->inv = new(Unit_Inventory);
- if(b->inv->Helm.size() <= item->getSubtype())
- b->inv->Helm.resize(item->getSubtype()+1);
- b->inv->Helm[item->getSubtype()].matt.type = item->getActualMaterial();
- b->inv->Helm[item->getSubtype()].matt.index = item->getActualMaterialIndex();
- break;
- case item_type::GLOVES:
- if(!b->inv)
- b->inv = new(Unit_Inventory);
- if(b->inv->Gloves.size() <= item->getSubtype())
- b->inv->Gloves.resize(item->getSubtype()+1);
- b->inv->Gloves[item->getSubtype()].matt.type = item->getActualMaterial();
- b->inv->Gloves[item->getSubtype()].matt.index = item->getActualMaterialIndex();
- break;
- case item_type::PANTS:
- if(!b->inv)
- b->inv = new(Unit_Inventory);
- if(b->inv->Pants.size() <= item->getSubtype())
- b->inv->Pants.resize(item->getSubtype()+1);
- b->inv->Pants[item->getSubtype()].matt.type = item->getActualMaterial();
- b->inv->Pants[item->getSubtype()].matt.index = item->getActualMaterialIndex();
- break;
- default:
- // something unexpected. Should we react at all?
- break;
+
+ Worn_Item equipment;
+
+ equipment.matt.type = item->getActualMaterial();
+ equipment.matt.index = item->getActualMaterialIndex();
+
+ if(item->isDyed())
+ {
+ auto Constructed_Item = virtual_cast<df::item_constructed>(item);
+ if(Constructed_Item)
+ {
+ for(int idex = 0; idex < Constructed_Item->improvements.size(); idex++)
+ {
+ if(!Constructed_Item->improvements[idex])
+ continue;
+ if(Constructed_Item->improvements[idex]->getType() != improvement_type::THREAD)
+ continue;
+ auto Improvement_Thread = virtual_cast<df::itemimprovement_threadst>(Constructed_Item->improvements[idex]);
+ if(!Improvement_Thread)
+ continue;
+ equipment.matt.type = Improvement_Thread->dye.mat_type;
+ equipment.matt.index = Improvement_Thread->dye.mat_index;
+ }
+ }
}
+
+ //FIXME: this could be made nicer. Somehow
+ if(!b->inv)
+ b->inv = new(Unit_Inventory);
+ if(b->inv->item.size() <= type)
+ b->inv->item.resize(type+1);
+ if(b->inv->item[type].size() <= item->getSubtype())
+ b->inv->item[type].resize(item->getSubtype()+1);
+ b->inv->item[type][item->getSubtype()].push_back(equipment);
}
// need a new tempcreature now
// old tempcreature should be deleted when b is
@@ -498,123 +498,24 @@ void drawDebugCursorAndInfo(WorldSegment * segment) //Inventories!
if(b->inv)
{
- if(!b->inv->Weapons.empty())
+ for(int item_type_idex = 0; item_type_idex < b->inv->item.size(); item_type_idex++)
{
+ if(b->inv->item[item_type_idex].empty())
+ continue;
draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- "Weapons:");
- for(int ind = 0; ind < b->inv->Weapons.size(); ind++)
+ "%s:", ENUM_KEY_STR(item_type, (item_type::item_type)item_type_idex));
+ for(int ind = 0; ind < b->inv->item[item_type_idex].size(); ind++)
{
- if(b->inv->Weapons[ind].matt.type < 0)
+ if(b->inv->item[item_type_idex][ind].empty())
continue;
- MaterialInfo mat;
- mat.decode(b->inv->Weapons[ind].matt.type,b->inv->Weapons[ind].matt.index);
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- " %s - %s/%s",
- mat.getToken().c_str(),
- ENUM_KEY_STR(item_type, item_type::WEAPON),
- get_item_subtype(item_type::WEAPON,ind));
- }
- }
- if(!b->inv->Armor.empty())
- {
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- "Armor:");
- for(int ind = 0; ind < b->inv->Armor.size(); ind++)
- {
- if(b->inv->Armor[ind].matt.type < 0)
- continue;
- MaterialInfo mat;
- mat.decode(b->inv->Armor[ind].matt.type,b->inv->Armor[ind].matt.index);
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- " %s - %s/%s",
- mat.getToken().c_str(),
- ENUM_KEY_STR(item_type, item_type::ARMOR),
- get_item_subtype(item_type::ARMOR,ind));
- }
- }
- if(!b->inv->Shoes.empty())
- {
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- "Shoes:");
- for(int ind = 0; ind < b->inv->Shoes.size(); ind++)
- {
- if(b->inv->Shoes[ind].matt.type < 0)
- continue;
- MaterialInfo mat;
- mat.decode(b->inv->Shoes[ind].matt.type,b->inv->Shoes[ind].matt.index);
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- " %s - %s/%s",
- mat.getToken().c_str(),
- ENUM_KEY_STR(item_type, item_type::SHOES),
- get_item_subtype(item_type::SHOES,ind));
- }
- }
- if(!b->inv->Shield.empty())
- {
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- "Shield:");
- for(int ind = 0; ind < b->inv->Shield.size(); ind++)
- {
- if(b->inv->Shield[ind].matt.type < 0)
- continue;
- MaterialInfo mat;
- mat.decode(b->inv->Shield[ind].matt.type,b->inv->Shield[ind].matt.index);
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- " %s - %s/%s",
- mat.getToken().c_str(),
- ENUM_KEY_STR(item_type, item_type::SHIELD),
- get_item_subtype(item_type::SHIELD,ind));
- }
- }
- if(!b->inv->Helm.empty())
- {
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- "Headwear:");
- for(int ind = 0; ind < b->inv->Helm.size(); ind++)
- {
- if(b->inv->Helm[ind].matt.type < 0)
- continue;
- MaterialInfo mat;
- mat.decode(b->inv->Helm[ind].matt.type,b->inv->Helm[ind].matt.index);
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- " %s - %s/%s",
- mat.getToken().c_str(),
- ENUM_KEY_STR(item_type, item_type::HELM),
- get_item_subtype(item_type::HELM,ind));
- }
- }
- if(!b->inv->Gloves.empty())
- {
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- "Gloves:");
- for(int ind = 0; ind < b->inv->Gloves.size(); ind++)
- {
- if(b->inv->Gloves[ind].matt.type < 0)
- continue;
- MaterialInfo mat;
- mat.decode(b->inv->Gloves[ind].matt.type,b->inv->Gloves[ind].matt.index);
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- " %s - %s/%s",
- mat.getToken().c_str(),
- ENUM_KEY_STR(item_type, item_type::GLOVES),
- get_item_subtype(item_type::GLOVES,ind));
- }
- }
- if(!b->inv->Pants.empty())
- {
- draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- "Pants:");
- for(int ind = 0; ind < b->inv->Pants.size(); ind++)
- {
- if(b->inv->Pants[ind].matt.type < 0)
+ if(b->inv->item[item_type_idex][ind][0].matt.type < 0)
continue;
MaterialInfo mat;
- mat.decode(b->inv->Pants[ind].matt.type,b->inv->Pants[ind].matt.index);
+ mat.decode(b->inv->item[item_type_idex][ind][0].matt.type,b->inv->item[item_type_idex][ind][0].matt.index);
draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- " %s - %s/%s",
+ " %s - %s",
mat.getToken().c_str(),
- ENUM_KEY_STR(item_type, item_type::PANTS),
- get_item_subtype(item_type::PANTS,ind));
+ get_item_subtype((item_type::item_type)item_type_idex,ind));
}
}
}
diff --git a/Occlusion_Test.cpp b/Occlusion_Test.cpp index 59494f9..7c8061e 100644 --- a/Occlusion_Test.cpp +++ b/Occlusion_Test.cpp @@ -43,7 +43,7 @@ void mask_center(Block * b, int offset) return;
if(!is_block_solid(b))
return;
- if(b->tileShapeBasic==tiletype_shape_basic::Wall && b->tileMaterial != tiletype_shape::BROOK_BED)
+ if(b->tileShapeBasic==tiletype_shape_basic::Wall && b->tileMaterial != tiletype_material::BROOK)
{
if(offset >= 0)
{
@@ -57,10 +57,10 @@ void mask_center(Block * b, int offset) }
}
else if(
- b->tileShapeBasic==tiletype_shape_basic::Floor ||
- b->tileShapeBasic==tiletype_shape_basic::Ramp ||
- b->tileMaterial != tiletype_shape::BROOK_BED
- )
+ (b->tileShapeBasic==tiletype_shape_basic::Floor ||
+ b->tileShapeBasic==tiletype_shape_basic::Ramp) &&
+ b->tileMaterial != tiletype_material::BROOK
+ ) //this needs to ignore brooks. This may have been a bug.
{
if(offset >= 0)
{
diff --git a/SpriteObjects.cpp b/SpriteObjects.cpp index 31d7fb5..9c1bed0 100644 --- a/SpriteObjects.cpp +++ b/SpriteObjects.cpp @@ -718,67 +718,18 @@ void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset, {
if(!b->inv)
goto draw_subsprite;
- switch (itemtype)
- {
- case item_type::WEAPON:
- if(b->inv->Weapons.empty())
- goto draw_subsprite;
- if(itemsubtype >= b->inv->Weapons.size())
- goto draw_subsprite;
- if(b->inv->Weapons[itemsubtype].matt.type == INVALID_INDEX)
- goto draw_subsprite;
- break;
- case item_type::ARMOR:
- if(b->inv->Armor.empty())
- goto draw_subsprite;
- if(itemsubtype >= b->inv->Armor.size())
- goto draw_subsprite;
- if(b->inv->Armor[itemsubtype].matt.type == INVALID_INDEX)
- goto draw_subsprite;
- break;
- case item_type::SHOES:
- if(b->inv->Shoes.empty())
- goto draw_subsprite;
- if(itemsubtype >= b->inv->Shoes.size())
- goto draw_subsprite;
- if(b->inv->Shoes[itemsubtype].matt.type == INVALID_INDEX)
- goto draw_subsprite;
- break;
- case item_type::SHIELD:
- if(b->inv->Shield.empty())
- goto draw_subsprite;
- if(itemsubtype >= b->inv->Shield.size())
- goto draw_subsprite;
- if(b->inv->Shield[itemsubtype].matt.type == INVALID_INDEX)
- goto draw_subsprite;
- break;
- case item_type::HELM:
- if(b->inv->Helm.empty())
- goto draw_subsprite;
- if(itemsubtype >= b->inv->Helm.size())
- goto draw_subsprite;
- if(b->inv->Helm[itemsubtype].matt.type == INVALID_INDEX)
- goto draw_subsprite;
- break;
- case item_type::GLOVES:
- if(b->inv->Gloves.empty())
- goto draw_subsprite;
- if(itemsubtype >= b->inv->Gloves.size())
- goto draw_subsprite;
- if(b->inv->Gloves[itemsubtype].matt.type == INVALID_INDEX)
- goto draw_subsprite;
- break;
- case item_type::PANTS:
- if(b->inv->Pants.empty())
- goto draw_subsprite;
- if(itemsubtype >= b->inv->Pants.size())
- goto draw_subsprite;
- if(b->inv->Pants[itemsubtype].matt.type == INVALID_INDEX)
- goto draw_subsprite;
- break;
- default:
+ if(b->inv->item.empty())
+ goto draw_subsprite;
+ if(b->inv->item.size() <= itemtype)
+ goto draw_subsprite;
+ if(b->inv->item[itemtype].empty())
+ goto draw_subsprite;
+ if(itemsubtype >= b->inv->item[itemtype].size())
+ goto draw_subsprite;
+ if(b->inv->item[itemtype][itemsubtype].empty())
+ goto draw_subsprite;
+ if(b->inv->item[itemtype][itemsubtype][0].matt.type == INVALID_INDEX)
goto draw_subsprite;
- }
}
@@ -871,7 +822,7 @@ void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset, al_draw_scaled_bitmap(IMGObjectSheet,
TILEWIDTH * SPRITEFLOOR_CUTOFF, 0,
SPRITEWIDTH, SPRITEWIDTH,
- drawx+offset_x, (drawy+offset_y-((SPRITEHEIGHT-WALL_CUTOFF_HEIGHT)/2))*config.scale,
+ drawx+offset_x, (drawy+offset_y-(((SPRITEHEIGHT-WALL_CUTOFF_HEIGHT)/2)*config.scale)),
SPRITEWIDTH*config.scale, SPRITEWIDTH*config.scale, 0);
}
else if ((chop && (halftile == HALFTILEYES)) || (!chop && (halftile == HALFTILENO)) || (!chop && (halftile == HALFTILECHOP)) || (halftile == HALFTILEBOTH))
@@ -1066,41 +1017,16 @@ ALLEGRO_COLOR c_sprite::get_color(void* block) if(itemsubtype >=0)
{
//FIXME: need a way to get a material for generic types.
- switch(itemtype)
- {
- case -1:
- return al_map_rgb(255, 255, 255);
- case item_type::WEAPON:
- if(itemsubtype < b->inv->Weapons.size())
- return lookupMaterialColor(b->inv->Weapons[itemsubtype].matt.type, b->inv->Weapons[itemsubtype].matt.index);
- break;
- case item_type::ARMOR:
- if(itemsubtype < b->inv->Armor.size())
- return lookupMaterialColor(b->inv->Armor[itemsubtype].matt.type, b->inv->Armor[itemsubtype].matt.index);
- break;
- case item_type::SHOES:
- if(itemsubtype < b->inv->Shoes.size())
- return lookupMaterialColor(b->inv->Shoes[itemsubtype].matt.type, b->inv->Shoes[itemsubtype].matt.index);
- break;
- case item_type::SHIELD:
- if(itemsubtype < b->inv->Shield.size())
- return lookupMaterialColor(b->inv->Shield[itemsubtype].matt.type, b->inv->Shield[itemsubtype].matt.index);
- break;
- case item_type::GLOVES:
- if(itemsubtype < b->inv->Weapons.size())
- return lookupMaterialColor(b->inv->Gloves[itemsubtype].matt.type, b->inv->Gloves[itemsubtype].matt.index);
- break;
- case item_type::PANTS:
- if(itemsubtype < b->inv->Pants.size())
- return lookupMaterialColor(b->inv->Pants[itemsubtype].matt.type, b->inv->Pants[itemsubtype].matt.index);
- break;
- case item_type::HELM:
- if(itemsubtype < b->inv->Helm.size())
- return lookupMaterialColor(b->inv->Helm[itemsubtype].matt.type, b->inv->Helm[itemsubtype].matt.index);
- break;
- default:
- return al_map_rgb(255, 255, 255);
- }
+ //errors here give pink.
+ if(itemtype == -1)
+ return al_map_rgb(255, 0, 0);
+ if(b->inv->item.size() <= itemtype)
+ return al_map_rgb(0, 255, 0);
+ if(b->inv->item[itemtype].size() <= itemsubtype)
+ 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);
}
else return al_map_rgb(255,255,255);
default:
@@ -430,8 +430,8 @@ static void * stonesense_thread(ALLEGRO_THREAD * main_thread, void * parms) SetTitle("Stonesense");
if(config.software)
- al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP|ALLEGRO_ALPHA_TEST|ALLEGRO_MIN_LINEAR|ALLEGRO_MAG_LINEAR|ALLEGRO_MIPMAP);
- else al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR|ALLEGRO_MAG_LINEAR|ALLEGRO_MIPMAP);
+ al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP|ALLEGRO_ALPHA_TEST|ALLEGRO_MIN_LINEAR|ALLEGRO_MIPMAP);
+ else al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR|ALLEGRO_MIPMAP);
ALLEGRO_PATH * p = al_create_path("stonesense/stonesense.png");
IMGIcon = load_bitmap_withWarning(al_path_cstr(p, ALLEGRO_NATIVE_PATH_SEP));
diff --git a/resources/creatures/clothed_Dwarves.xml b/resources/creatures/clothed_Dwarves.xml index c89aef4..9962ea4 100644 --- a/resources/creatures/clothed_Dwarves.xml +++ b/resources/creatures/clothed_Dwarves.xml @@ -20,6 +20,7 @@ <subsprite sheetIndex="86" equipment_class="HELM" equipment_name="ITEM_HELM_CAP" color="equipment"/> <subsprite sheetIndex="87" equipment_class="SHOES" equipment_name="ITEM_SHOES_SHOES" color="equipment"/> <subsprite sheetIndex="89" equipment_class="PANTS" equipment_name="ITEM_PANTS_SKIRT" color="equipment"/> + <subsprite sheetIndex="89" equipment_class="PANTS" equipment_name="ITEM_PANTS_PANTS" color="equipment"/> <subsprite sheetIndex="88" equipment_class="ARMOR" equipment_name="ITEM_ARMOR_MAIL_SHIRT" color="equipment"/> </variant> </creature> |
