summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaldfir2012-03-16 02:38:22 -0700
committerCaldfir2012-03-16 02:38:22 -0700
commit0539996f01e34b9238d6d14ddb164c12037bd775 (patch)
treed050db94dcfdf2d13ec937d7df77490ffc3f296e
parent89b6ecb6d01f92f0df2ea23ef6a9fff796167f07 (diff)
downloadstonesense-0539996f01e34b9238d6d14ddb164c12037bd775.tar.gz
stonesense-0539996f01e34b9238d6d14ddb164c12037bd775.tar.bz2
stonesense-0539996f01e34b9238d6d14ddb164c12037bd775.tar.xz
Fixed a careless versioning issue and cleaned up how status icons/profession icons/creature names interact.
-rw-r--r--Creatures.cpp114
-rw-r--r--GUI.cpp123
-rw-r--r--UserInput.cpp2
-rw-r--r--commonTypes.h2
4 files changed, 59 insertions, 182 deletions
diff --git a/Creatures.cpp b/Creatures.cpp
index 533d079..414e615 100644
--- a/Creatures.cpp
+++ b/Creatures.cpp
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "common.h"
#include "Creatures.h"
#include "WorldSegment.h"
#include "CreatureConfiguration.h"
@@ -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;
@@ -266,11 +269,11 @@ void DrawCreature(int drawx, int drawy, t_unit* creature, Block * b){
else if(creature->current_job.active && creature->current_job.jobType == 52)
statusIcons.push_back(17);
}
-
c_sprite * sprite = GetCreatureSpriteMap( creature );
- //if(creature->x == 151 && creature->y == 145)
- // int j = 10;
+
+ unsigned int offsety = config.show_creature_names ? al_get_font_line_height(font) : 0;
+
sprite->draw_world(creature->x,creature->y, creature->z, b);
if(statusIcons.size())
{
@@ -278,15 +281,17 @@ void DrawCreature(int drawx, int drawy, t_unit* creature, Block * b){
{
unsigned int sheetx = 16 * (statusIcons[i] % 7);
unsigned int sheety = 16 * (statusIcons[i] / 7);
- al_draw_bitmap_region(IMGStatusSheet, sheetx, sheety, 16, 16, drawx - (statusIcons.size()*8) + (16*i) + (SPRITEWIDTH/2), drawy - (16 + WALLHEIGHT + al_get_font_line_height(font)), 0);
+ al_draw_bitmap_region(IMGStatusSheet, sheetx, sheety, 16, 16, drawx - (statusIcons.size()*8) + (16*i) + (SPRITEWIDTH*config.scale/2), drawy - (16 + WALLHEIGHT*config.scale + offsety), 0);
}
}
+
+ offsety += config.show_creature_moods ? 16 : 0;
+
if(config.show_creature_jobs)
{
unsigned int sheetx = 16 * (creature->profession % 7);
unsigned int sheety = 16 * (creature->profession / 7);
- unsigned int offsety = statusIcons.size() ? 16 : 0;
- al_draw_bitmap_region(IMGStatusSheet, sheetx, sheety, 16, 16, drawx + (SPRITEWIDTH/2), drawy - (16 + WALLHEIGHT + al_get_font_line_height(font)) - offsety, 0);
+ al_draw_bitmap_region(IMGStatusSheet, sheetx, sheety, 16, 16, drawx -8 + (SPRITEWIDTH*config.scale/2), drawy - (16 + WALLHEIGHT*config.scale + offsety), 0);
}
}
@@ -411,69 +416,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
diff --git a/GUI.cpp b/GUI.cpp
index 01a622a..83fd333 100644
--- a/GUI.cpp
+++ b/GUI.cpp
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include <assert.h>
#include <vector>
using namespace std;
@@ -499,127 +499,28 @@ 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));
}
}
}
- if(1) //just so it has it's own scope
+ //just so it has it's own scope
{
char strCreature[150] = {0};
generateCreatureDebugString( b->creature, strCreature );
diff --git a/UserInput.cpp b/UserInput.cpp
index c15b695..7f5f735 100644
--- a/UserInput.cpp
+++ b/UserInput.cpp
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "common.h"
#include "GUI.h"
#include "BuildingConfiguration.h"
#include "ContentLoader.h"
diff --git a/commonTypes.h b/commonTypes.h
index 982b9a7..630be63 100644
--- a/commonTypes.h
+++ b/commonTypes.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "common.h"
#include "SpriteColors.h"