summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaldfir2012-03-16 01:47:21 -0700
committerCaldfir2012-03-16 01:47:21 -0700
commit89b6ecb6d01f92f0df2ea23ef6a9fff796167f07 (patch)
treec8f68905d87f56a25946efe95873d2feb1a7650b
parentbb7bcc00c4eb2e46e5d7141fb2d0ce8a30386568 (diff)
downloadstonesense-89b6ecb6d01f92f0df2ea23ef6a9fff796167f07.tar.gz
stonesense-89b6ecb6d01f92f0df2ea23ef6a9fff796167f07.tar.bz2
stonesense-89b6ecb6d01f92f0df2ea23ef6a9fff796167f07.tar.xz
Attempt at getting job icons, similar in bahaviour to the existing status icons into stonesense.
-rw-r--r--Creatures.cpp108
-rw-r--r--GUI.cpp130
-rw-r--r--UserInput.cpp6
-rw-r--r--commonTypes.h3
4 files changed, 196 insertions, 51 deletions
diff --git a/Creatures.cpp b/Creatures.cpp
index 5e1781c..533d079 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,9 +9,6 @@
#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;
@@ -269,6 +266,7 @@ 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)
@@ -283,6 +281,13 @@ void DrawCreature(int drawx, int drawy, t_unit* creature, Block * b){
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);
}
}
+ 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);
+ }
}
void DrawCreatureText(int drawx, int drawy, t_unit* creature ){
@@ -406,40 +411,69 @@ void ReadCreaturesToSegment( DFHack::Core& DF, WorldSegment* segment)
item_type::item_type type = item->getType();
int8_t armor = item->getEffectiveArmorLevel();
-
- 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);
+ 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;
+ }
}
// need a new tempcreature now
// old tempcreature should be deleted when b is
diff --git a/GUI.cpp b/GUI.cpp
index b9e8e4e..01a622a 100644
--- a/GUI.cpp
+++ b/GUI.cpp
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include <assert.h>
#include <vector>
using namespace std;
@@ -56,6 +56,7 @@ ALLEGRO_BITMAP* IMGObjectSheet;
ALLEGRO_BITMAP* IMGCreatureSheet;
ALLEGRO_BITMAP* IMGRampSheet;
ALLEGRO_BITMAP* IMGStatusSheet;
+ALLEGRO_BITMAP* IMGJobSheet;
ALLEGRO_BITMAP* IMGBloodSheet;
ALLEGRO_BITMAP* IMGEngFloorSheet;
ALLEGRO_BITMAP* IMGEngLeftSheet;
@@ -498,28 +499,127 @@ void drawDebugCursorAndInfo(WorldSegment * segment)
//Inventories!
if(b->inv)
{
- for(int item_type_idex = 0; item_type_idex < b->inv->item.size(); item_type_idex++)
+ if(!b->inv->Weapons.empty())
{
- 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,
- "%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++)
+ "Weapons:");
+ for(int ind = 0; ind < b->inv->Weapons.size(); ind++)
{
- if(b->inv->item[item_type_idex][ind].empty())
+ if(b->inv->Weapons[ind].matt.type < 0)
continue;
- if(b->inv->item[item_type_idex][ind][0].matt.type < 0)
+ 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->item[item_type_idex][ind][0].matt.type,b->inv->item[item_type_idex][ind][0].matt.index);
+ 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 - %s/%s",
mat.getToken().c_str(),
- get_item_subtype((item_type::item_type)item_type_idex,ind));
+ 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)
+ continue;
+ MaterialInfo mat;
+ mat.decode(b->inv->Pants[ind].matt.type,b->inv->Pants[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::PANTS),
+ get_item_subtype(item_type::PANTS,ind));
}
}
}
- //just so it has it's own scope
+ if(1) //just so it has it's own scope
{
char strCreature[150] = {0};
generateCreatureDebugString( b->creature, strCreature );
@@ -1035,6 +1135,7 @@ void loadGraphicsFromDisk()
if(!load_from_path(p, "creatures.png", IMGCreatureSheet)) return;
if(!load_from_path(p, "ramps.png", IMGRampSheet)) return;
if(!load_from_path(p, "SSStatusIcons.png", IMGStatusSheet)) return;
+ if(!load_from_path(p, "SSJobIcons.png", IMGJobSheet)) return;
if(!load_from_path(p, "gibs.png", IMGBloodSheet)) return;
if(!load_from_path(p, "engravings_floor.png", IMGEngFloorSheet)) return;
if(!load_from_path(p, "engravings_left.png", IMGEngLeftSheet)) return;
@@ -1069,6 +1170,11 @@ void flushImgFiles()
al_destroy_bitmap(IMGStatusSheet);
IMGStatusSheet = 0;
}
+ if(IMGJobSheet)
+ {
+ al_destroy_bitmap(IMGJobSheet);
+ IMGJobSheet = 0;
+ }
if(IMGEngFloorSheet)
{
al_destroy_bitmap(IMGEngFloorSheet);
diff --git a/UserInput.cpp b/UserInput.cpp
index 45a83c6..c15b695 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"
@@ -232,6 +232,10 @@ void doKeys(int Key)
config.show_creature_moods = !config.show_creature_moods;
timeToReloadSegment = true;
}
+ if(Key == ALLEGRO_KEY_J){
+ config.show_creature_jobs = !config.show_creature_jobs;
+ timeToReloadSegment = true;
+ }
if(Key == ALLEGRO_KEY_C){
config.truncate_walls++;
if (config.truncate_walls > 4) config.truncate_walls = 0;
diff --git a/commonTypes.h b/commonTypes.h
index dde0695..982b9a7 100644
--- a/commonTypes.h
+++ b/commonTypes.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "common.h"
#include "SpriteColors.h"
@@ -189,6 +189,7 @@ typedef struct
bool dayNightCycle;
bool show_creature_moods;
+ bool show_creature_jobs;
bool transparentScreenshots;