From 60bc0083ac0b5bbbd2280fc4b9e23a6490a38e11 Mon Sep 17 00:00:00 2001 From: Kris Parker Date: Sat, 16 Jan 2010 22:26:45 +0000 Subject: [PATCH] Names can be configured to use nicknames and species (or not). Plain old names capitalised --- Config.cpp | 8 ++++ Creatures.cpp | 20 ++++++--- commonTypes.h | 122 +++++++++++++++++++++++++------------------------- init.txt | 4 ++ 4 files changed, 89 insertions(+), 65 deletions(-) diff --git a/Config.cpp b/Config.cpp index 24a2e2c7..ad9ce8a4 100644 --- a/Config.cpp +++ b/Config.cpp @@ -123,6 +123,14 @@ void parseConfigLine( string line ){ string result = parseStrFromLine( "SHOW_CREATURE_NAMES", line ); config.show_creature_names = (result == "YES"); } + if( line.find("NAMES_USE_NICKNAME") != -1){ + string result = parseStrFromLine( "NAMES_USE_NICKNAME", line ); + config.names_use_nick = (result == "YES"); + } + if( line.find("NAMES_USE_SPECIES") != -1){ + string result = parseStrFromLine( "NAMES_USE_SPECIES", line ); + config.names_use_species = (result == "YES"); + } if( line.find("SHOW_OSD") != -1){ string result = parseStrFromLine( "SHOW_OSD", line ); config.show_osd = (result == "YES"); diff --git a/Creatures.cpp b/Creatures.cpp index 5346e48c..b10338ec 100644 --- a/Creatures.cpp +++ b/Creatures.cpp @@ -29,13 +29,23 @@ void DrawCreature( BITMAP* target, int drawx, int drawy, t_creature* creature ){ //if(creature->x == 151 && creature->y == 145) // int j = 10; if( config.show_creature_names ) - /*if (creature->nick_name[0]) + if (creature->nick_name[0] && config.names_use_nick) + { textprintf(target, font, drawx, drawy-20, 0xFFffFF, "%s", creature->nick_name ); - else */ - if (creature->first_name[0]) - textprintf(target, font, drawx, drawy-20, 0xFFffFF, "%s", creature->first_name ); - else + } + else if (creature->first_name[0]) + { + char buffer[128]; + strncpy(buffer,creature->first_name,127); + buffer[127]=0; + if (buffer[0]>90) + buffer[0] -= 32; + textprintf(target, font, drawx, drawy-20, 0xFFffFF, "%s", buffer ); + } + else if (config.names_use_species) + { textprintf(target, font, drawx, drawy-20, 0xFFffFF, "[%s]", contentLoader.creatureNameStrings.at(creature->type).id); + } BITMAP* creatureSheet; if (sprite.fileIndex == -1) diff --git a/commonTypes.h b/commonTypes.h index 5e309480..f8f154d4 100644 --- a/commonTypes.h +++ b/commonTypes.h @@ -1,53 +1,55 @@ -#pragma once - - - -struct t_SpriteWithOffset{ - int32_t sheetIndex; - int16_t x; - int16_t y; - int32_t fileIndex; - char animFrames; -} ; - - -typedef struct Crd2D { - int32_t x,y; -}Crd2D; -typedef struct Crd3D { - int32_t x,y,z; -}Crd3D; - - - - -typedef struct { - bool show_zones; - bool show_stockpiles; - bool show_osd; - bool single_layer_view; - bool shade_hidden_blocks; - bool show_hidden_blocks; - bool show_creature_names; - bool show_all_creatures; - bool load_ground_materials; - bool hide_outer_blocks; - bool debug_mode; - bool track_center; - int lift_segment_offscreen; - bool truncate_walls; - bool follow_DFscreen; - bool verbose_logging; - int viewXoffset; - int viewYoffset; - int viewZoffset; - int automatic_reload_time; - int automatic_reload_step; - int animation_step; - - int screenWidth; - int screenHeight; - bool Fullscreen; +#pragma once + + + +struct t_SpriteWithOffset{ + int32_t sheetIndex; + int16_t x; + int16_t y; + int32_t fileIndex; + char animFrames; +} ; + + +typedef struct Crd2D { + int32_t x,y; +}Crd2D; +typedef struct Crd3D { + int32_t x,y,z; +}Crd3D; + + + + +typedef struct { + bool show_zones; + bool show_stockpiles; + bool show_osd; + bool single_layer_view; + bool shade_hidden_blocks; + bool show_hidden_blocks; + bool show_creature_names; + bool names_use_nick; + bool names_use_species; + bool show_all_creatures; + bool load_ground_materials; + bool hide_outer_blocks; + bool debug_mode; + bool track_center; + int lift_segment_offscreen; + bool truncate_walls; + bool follow_DFscreen; + bool verbose_logging; + int viewXoffset; + int viewYoffset; + int viewZoffset; + int automatic_reload_time; + int automatic_reload_step; + int animation_step; + + int screenWidth; + int screenHeight; + bool Fullscreen; bool show_intro; int fogr; int fogg; @@ -56,14 +58,14 @@ typedef struct { int backr; int backg; int backb; - - Crd3D segmentSize; - -} GameConfiguration; - - -enum enumCreatureSex{ - eCreatureSex_NA, - eCreatureSex_Male, - eCreatureSex_Female + + Crd3D segmentSize; + +} GameConfiguration; + + +enum enumCreatureSex{ + eCreatureSex_NA, + eCreatureSex_Male, + eCreatureSex_Female }; \ No newline at end of file diff --git a/init.txt b/init.txt index bb12034f..70510716 100644 --- a/init.txt +++ b/init.txt @@ -48,6 +48,10 @@ Follow DF window is on when Stonesense launches. (Toggle with 'f') Shows creatures names floating above their sprites. (Toggle with 'n') [SHOW_CREATURE_NAMES:YES] +Options to control how names are displayed (if SHOW_CREATURE_NAMES is set) +[NAMES_USE_NICKNAME:YES] +[NAMES_USE_SPECIES:YES] + Shows building graphics for zones. (Toggle with 'i') [SHOW_ZONES:NO]