Skip to content

Commit

Permalink
Added engravings.
Browse files Browse the repository at this point in the history
  • Loading branch information
RosaryMala committed Apr 3, 2011
1 parent b9c1e81 commit 1a3d5f6
Show file tree
Hide file tree
Showing 24 changed files with 708 additions and 63 deletions.
42 changes: 42 additions & 0 deletions Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Block::Block(WorldSegment* ownerSegment)
downstairborders = 0;
lightborders = 255;
creature = 0;
engraving_character = 0;
}


Expand Down Expand Up @@ -181,6 +182,13 @@ void Block::Draw(){
}
}

//Floor Engravings
if((floorType > 0) && engraving_character && engraving_flags.floor)
{
DrawSpriteFromSheet( engraving_character, IMGEngFloorSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
}


////draw surf
//if(eff_oceanwave > 0)
//{
Expand All @@ -194,6 +202,7 @@ void Block::Draw(){
// al_draw_tinted_bitmap(sprite_webing, drawx, drawy - (WALLHEIGHT), 0);
// al_set_separate_blender(op, src, dst, alpha_op, alpha_src, alpha_dst, color);
//}

//Draw Ramp
if(ramp.type > 0){
spriteobject = GetBlockSpriteMap(ramp.type, material, consForm);
Expand Down Expand Up @@ -319,6 +328,39 @@ void Block::Draw(){
}
}

//Wall Engravings
if((wallType > 0) && engraving_character)
{
if(ownerSegment->rotation == 0)
{
if(engraving_flags.east)
DrawSpriteFromSheet( engraving_character, IMGEngRightSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
if(engraving_flags.south)
DrawSpriteFromSheet( engraving_character, IMGEngLeftSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
}
if(ownerSegment->rotation == 1)
{
if(engraving_flags.north)
DrawSpriteFromSheet( engraving_character, IMGEngRightSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
if(engraving_flags.east)
DrawSpriteFromSheet( engraving_character, IMGEngLeftSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
}
if(ownerSegment->rotation == 2)
{
if(engraving_flags.west)
DrawSpriteFromSheet( engraving_character, IMGEngRightSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
if(engraving_flags.north)
DrawSpriteFromSheet( engraving_character, IMGEngLeftSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
}
if(ownerSegment->rotation == 3)
{
if(engraving_flags.south)
DrawSpriteFromSheet( engraving_character, IMGEngRightSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
if(engraving_flags.west)
DrawSpriteFromSheet( engraving_character, IMGEngLeftSheet, al_map_rgba_f(1.0,1.0,1.0,((engraving_quality + 5.0f) / 10.0f)), drawx, drawy, this );
}
}


if(water.index > 0)
{
Expand Down
44 changes: 24 additions & 20 deletions Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,36 @@ class Block
uint8_t grasslevel;
uint32_t grassmat;

uint8_t engraving_character;
flg_engraving engraving_flags;
uint8_t engraving_quality;

//vector<uint8_t> grasslevels;
//vector<uint32_t> grassmats;

struct BlockEffects //size 40
{
uint16_t count;
uint16_t type;
t_matglossPair material;
int16_t lifetime;
int16_t x_direction;
int16_t y_direction;
uint8_t canCreateNew;//??
struct BlockEffects //size 40
{
uint16_t count;
uint16_t type;
t_matglossPair material;
int16_t lifetime;
int16_t x_direction;
int16_t y_direction;
uint8_t canCreateNew;//??
} blockeffects;

//individual effects
/*int16_t eff_miasma;
int16_t eff_water;
int16_t eff_water2;
int16_t eff_blood;
int16_t eff_dust;
int16_t eff_magma;
int16_t eff_smoke;
int16_t eff_dragonfire;
int16_t eff_fire;
int16_t eff_boiling;
int16_t eff_webing;
/*int16_t eff_miasma;
int16_t eff_water;
int16_t eff_water2;
int16_t eff_blood;
int16_t eff_dust;
int16_t eff_magma;
int16_t eff_smoke;
int16_t eff_dragonfire;
int16_t eff_fire;
int16_t eff_boiling;
int16_t eff_webing;
int16_t eff_oceanwave;*/
struct {
t_building info;
Expand Down
2 changes: 2 additions & 0 deletions Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ int parseIntFromLine( string keyword, string line ){


void parseConfigLine( string line ){
if(line.empty())
return;
char c = line[0];
if( c != '[') return;

Expand Down
9 changes: 8 additions & 1 deletion DwarfIso.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\</OutDir>
Expand Down Expand Up @@ -245,6 +245,13 @@
<ClCompile Include="VegetationConfiguration.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="dfhack\include\dfhack\modules\engravings.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Benchmark|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Extra optimise test|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Test|Win32'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="dfhack\library\argstream\argstream.h" />
<ClInclude Include="Block.h" />
<ClInclude Include="BlockCondition.h" />
Expand Down
69 changes: 47 additions & 22 deletions GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ ALLEGRO_BITMAP* IMGCreatureSheet;
ALLEGRO_BITMAP* IMGRampSheet;
ALLEGRO_BITMAP* IMGStatusSheet;
ALLEGRO_BITMAP* IMGBloodSheet;
ALLEGRO_BITMAP* IMGEngFloorSheet;
ALLEGRO_BITMAP* IMGEngLeftSheet;
ALLEGRO_BITMAP* IMGEngRightSheet;

ALLEGRO_BITMAP* buffer = 0;
ALLEGRO_BITMAP* bigFile = 0;
vector<ALLEGRO_BITMAP*> IMGCache;
Expand Down Expand Up @@ -448,11 +452,11 @@ void drawDebugCursorAndInfo(){
b->building.info.type, b->building.info.vtable,
matName?matName:"Unknown",subMatName?"/":"",subMatName?subMatName:"",
b->building.info.material.type,b->building.info.material.index);

if(b->building.custom_building_type != -1)
{

if(b->building.custom_building_type != -1)
{
draw_textf_border(font, al_map_rgb(255,255,255), 2, al_get_bitmap_height(al_get_target_bitmap())-20-(i--*al_get_font_line_height(font)), 0,
"Custom workshop type %s (%d)", contentLoader.custom_workshop_types[b->building.custom_building_type].c_str(),b->building.custom_building_type);
"Custom workshop type %s (%d)", contentLoader.custom_workshop_types[b->building.custom_building_type].c_str(),b->building.custom_building_type);
}
}

Expand All @@ -471,30 +475,30 @@ void drawDebugCursorAndInfo(){
draw_textf_border(font, al_map_rgb(255,255,255), 2, al_get_bitmap_height(al_get_target_bitmap())-20-(i--*al_get_font_line_height(font)), 0,
"flag1: %s Sex: %d Mood: %d Job: %s", strCreature, b->creature->sex + 1, b->creature->mood, (b->creature->current_job.active?contentLoader.MemInfo->getJob(b->creature->current_job.jobType).c_str():""));
}
catch(exception &e)
{
WriteErr("DFhack exeption: %s\n", e.what());
catch(exception &e)
{
WriteErr("DFhack exeption: %s\n", e.what());
}
if((!config.skipCreatureTypes) && (!config.skipCreatureTypesEx) && (!config.skipDescriptorColors))
{
int yy = al_get_bitmap_height(al_get_target_bitmap())-20-(i--*al_get_font_line_height(font));
int xx = 2;
for(unsigned int j = 0; j<b->creature->nbcolors ; j++)
{
for(unsigned int j = 0; j<b->creature->nbcolors ; j++)
{
if(contentLoader.Mats->raceEx.at(b->creature->race).castes.at(b->creature->caste).ColorModifier.at(j).colorlist.size() > b->creature->color[j])
{
uint32_t cr_color = contentLoader.Mats->raceEx[b->creature->race].castes[b->creature->caste].ColorModifier[j].colorlist[b->creature->color[j]];
if(cr_color < contentLoader.Mats->color.size())
{
draw_textf_border(font,
al_map_rgb_f(
contentLoader.Mats->color[cr_color].r,
contentLoader.Mats->color[cr_color].v,
contentLoader.Mats->color[cr_color].b), xx, yy, 0,
"%s ", contentLoader.Mats->raceEx[b->creature->race].castes[b->creature->caste].ColorModifier[j].part);
xx += get_textf_width(font, "%s ", contentLoader.Mats->raceEx[b->creature->race].castes[b->creature->caste].ColorModifier[j].part);
}
}
{
uint32_t cr_color = contentLoader.Mats->raceEx[b->creature->race].castes[b->creature->caste].ColorModifier[j].colorlist[b->creature->color[j]];
if(cr_color < contentLoader.Mats->color.size())
{
draw_textf_border(font,
al_map_rgb_f(
contentLoader.Mats->color[cr_color].r,
contentLoader.Mats->color[cr_color].v,
contentLoader.Mats->color[cr_color].b), xx, yy, 0,
"%s ", contentLoader.Mats->raceEx[b->creature->race].castes[b->creature->caste].ColorModifier[j].part);
xx += get_textf_width(font, "%s ", contentLoader.Mats->raceEx[b->creature->race].castes[b->creature->caste].ColorModifier[j].part);
}
}
}
}
}
Expand Down Expand Up @@ -826,6 +830,12 @@ void loadGraphicsFromDisk(){
IMGStatusSheet = al_create_sub_bitmap(IMGFilelist[index], 0, 0, al_get_bitmap_width(IMGFilelist[index]), al_get_bitmap_height(IMGFilelist[index]));
index = loadImgFile("gibs.png");
IMGBloodSheet = al_create_sub_bitmap(IMGFilelist[index], 0, 0, al_get_bitmap_width(IMGFilelist[index]), al_get_bitmap_height(IMGFilelist[index]));
index = loadImgFile("engravings_floor.png");
IMGEngFloorSheet = al_create_sub_bitmap(IMGFilelist[index], 0, 0, al_get_bitmap_width(IMGFilelist[index]), al_get_bitmap_height(IMGFilelist[index]));
index = loadImgFile("engravings_left.png");
IMGEngLeftSheet = al_create_sub_bitmap(IMGFilelist[index], 0, 0, al_get_bitmap_width(IMGFilelist[index]), al_get_bitmap_height(IMGFilelist[index]));
index = loadImgFile("engravings_right.png");
IMGEngRightSheet = al_create_sub_bitmap(IMGFilelist[index], 0, 0, al_get_bitmap_width(IMGFilelist[index]), al_get_bitmap_height(IMGFilelist[index]));
createEffectSprites();
}

Expand Down Expand Up @@ -855,6 +865,21 @@ void flushImgFiles()
al_destroy_bitmap(IMGStatusSheet);
IMGStatusSheet = 0;
}
if(IMGEngFloorSheet)
{
al_destroy_bitmap(IMGEngFloorSheet);
IMGEngFloorSheet = 0;
}
if(IMGEngLeftSheet)
{
al_destroy_bitmap(IMGEngLeftSheet);
IMGEngLeftSheet = 0;
}
if(IMGEngRightSheet)
{
al_destroy_bitmap(IMGEngRightSheet);
IMGEngRightSheet = 0;
}
uint32_t numFiles = (uint32_t)IMGFilelist.size();
assert( numFiles == IMGFilenames.size());
for(uint32_t i = 0; i < numFiles; i++)
Expand Down
3 changes: 3 additions & 0 deletions GUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ extern ALLEGRO_BITMAP* IMGCreatureSheet;
extern ALLEGRO_BITMAP* IMGRampSheet;
extern ALLEGRO_BITMAP* IMGStatusSheet;
extern ALLEGRO_BITMAP* IMGBloodSheet;
extern ALLEGRO_BITMAP* IMGEngFloorSheet;
extern ALLEGRO_BITMAP* IMGEngLeftSheet;
extern ALLEGRO_BITMAP* IMGEngRightSheet;

extern Crd3D debugCursor;
extern vector<string*> IMGFilenames;
Expand Down
39 changes: 39 additions & 0 deletions MapLoading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,16 @@ WorldSegment* ReadMapSegment(DFHack::Context &DF, int x, int y, int z, int sizex
config.skipConstructions = true;
}
}
DFHack::Engravings *Eng;
try
{
Eng = DF.getEngravings();
}
catch (exception &e)
{
WriteErr("DFhack exeption: %s\n", e.what());
config.skipConstructions = true;
}
DFHack::World *Wold;
if(!config.skipWorld)
{
Expand Down Expand Up @@ -804,6 +814,35 @@ WorldSegment* ReadMapSegment(DFHack::Context &DF, int x, int y, int z, int sizex
//translate constructions
changeConstructionMaterials(segment, &allConstructions);

uint32_t numengravings = 0;
try
{
if (Eng->Start(numengravings))
{
dfh_engraving engraved;
t_engraving &tempeng = engraved.s;
index = 0;
Block * b = 0;
while(index < numengravings)
{
Eng->Read(index, engraved);
if(segment->CoordinateInsideSegment(tempeng.x, tempeng.y, tempeng.z))
{
b = segment->getBlock(tempeng.x, tempeng.y, tempeng.z);
b->engraving_character = tempeng.display_character;
b->engraving_flags = tempeng.flags;
b->engraving_quality = tempeng.quality;
}
index++;
}
Eng->Finish();
}
}
catch(exception &e)
{
WriteErr("DFhack exception: %s\n", e.what());
}


//Read Vegetation
//uint32_t numtrees;
Expand Down
Loading

0 comments on commit 1a3d5f6

Please sign in to comment.