Skip to content

Commit

Permalink
Move 2 display related functions to avatar class (#40698)
Browse files Browse the repository at this point in the history
  • Loading branch information
olanti-p authored May 20, 2020
1 parent 3dd5c44 commit 36f2c77
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 44 deletions.
41 changes: 41 additions & 0 deletions src/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,26 @@

static const activity_id ACT_READ( "ACT_READ" );

static const bionic_id bio_cloak( "bio_cloak" );
static const bionic_id bio_eye_optic( "bio_eye_optic" );
static const bionic_id bio_memory( "bio_memory" );
static const bionic_id bio_watch( "bio_watch" );

static const efftype_id effect_alarm_clock( "alarm_clock" );
static const efftype_id effect_boomered( "boomered" );
static const efftype_id effect_contacts( "contacts" );
static const efftype_id effect_depressants( "depressants" );
static const efftype_id effect_happy( "happy" );
static const efftype_id effect_irradiated( "irradiated" );
static const efftype_id effect_onfire( "onfire" );
static const efftype_id effect_pkill( "pkill" );
static const efftype_id effect_sad( "sad" );
static const efftype_id effect_sleep( "sleep" );
static const efftype_id effect_sleep_deprived( "sleep_deprived" );
static const efftype_id effect_slept_through_alarm( "slept_through_alarm" );
static const efftype_id effect_stim( "stim" );
static const efftype_id effect_stim_overdose( "stim_overdose" );
static const efftype_id effect_stunned( "stunned" );

static const itype_id itype_guidebook( "guidebook" );

Expand All @@ -97,6 +101,7 @@ static const trait_id trait_CHITIN2( "CHITIN2" );
static const trait_id trait_CHITIN3( "CHITIN3" );
static const trait_id trait_CHITIN_FUR3( "CHITIN_FUR3" );
static const trait_id trait_COMPOUND_EYES( "COMPOUND_EYES" );
static const trait_id trait_DEBUG_CLOAK( "DEBUG_CLOAK" );
static const trait_id trait_HYPEROPIC( "HYPEROPIC" );
static const trait_id trait_ILLITERATE( "ILLITERATE" );
static const trait_id trait_INSECT_ARMS( "INSECT_ARMS" );
Expand Down Expand Up @@ -978,6 +983,42 @@ void avatar::vomit()
Character::vomit();
}

nc_color avatar::basic_symbol_color() const
{
if( has_effect( effect_onfire ) ) {
return c_red;
}
if( has_effect( effect_stunned ) ) {
return c_light_blue;
}
if( has_effect( effect_boomered ) ) {
return c_pink;
}
if( has_active_mutation( trait_id( "SHELL2" ) ) ) {
return c_magenta;
}
if( underwater ) {
return c_blue;
}
if( has_active_bionic( bio_cloak ) || has_artifact_with( AEP_INVISIBLE ) ||
is_wearing_active_optcloak() || has_trait( trait_DEBUG_CLOAK ) ) {
return c_dark_gray;
}
if( move_mode == CMM_RUN ) {
return c_yellow;
}
if( move_mode == CMM_CROUCH ) {
return c_light_gray;
}
return c_white;
}

int avatar::print_info( const catacurses::window &w, int vStart, int, int column ) const
{
mvwprintw( w, point( column, vStart++ ), _( "You (%s)" ), name );
return vStart;
}

void avatar::disp_morale()
{
int equilibrium = calc_focus_equilibrium();
Expand Down
3 changes: 3 additions & 0 deletions src/avatar.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class avatar : public player
size_t max_memorized_tiles() const;
void clear_memorized_tile( const tripoint &pos );

nc_color basic_symbol_color() const override;
int print_info( const catacurses::window &w, int vStart, int vLines, int column ) const override;

/** Provides the window and detailed morale data */
void disp_morale();
/** Uses morale and other factors to return the player's focus target goto value */
Expand Down
6 changes: 0 additions & 6 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10606,12 +10606,6 @@ std::string Character::short_description() const
return join( short_description_parts(), "; " );
}

int Character::print_info( const catacurses::window &w, int vStart, int, int column ) const
{
mvwprintw( w, point( column, vStart++ ), _( "You (%s)" ), name );
return vStart;
}

void Character::shift_destination( const point &shift )
{
if( next_expected_position ) {
Expand Down
5 changes: 2 additions & 3 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ class Character : public Creature, public visitable<Character>
bool in_species( const species_id &spec ) const override;
// Turned to false for simulating NPCs on distant missions so they don't drop all their gear in sight
bool death_drops;
const std::string &symbol() const override;

enum class comfort_level {
impossible = -999,
Expand Down Expand Up @@ -1566,8 +1565,9 @@ class Character : public Creature, public visitable<Character>
*/
social_modifiers get_mutation_social_mods() const;

/** Color's character's tile's background */
// Display
nc_color symbol_color() const override;
const std::string &symbol() const override;

std::string extended_description() const override;

Expand Down Expand Up @@ -2103,7 +2103,6 @@ class Character : public Creature, public visitable<Character>
int heartrate_bpm() const;
std::vector<std::string> short_description_parts() const;
std::string short_description() const;
int print_info( const catacurses::window &w, int vStart, int vLines, int column ) const override;
// Checks whether a player can hear a sound at a given volume and location.
bool can_hear( const tripoint &source, int volume ) const;
// Returns a multiplier indicating the keenness of a player's hearing.
Expand Down
3 changes: 3 additions & 0 deletions src/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,11 @@ class Creature

virtual std::string extended_description() const = 0;

/** Creature symbol background color */
virtual nc_color symbol_color() const = 0;
/** Creature symbol color */
virtual nc_color basic_symbol_color() const = 0;
/** Creature symbol */
virtual const std::string &symbol() const = 0;
virtual bool is_symbol_highlighted() const;

Expand Down
32 changes: 0 additions & 32 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ static const trait_id trait_CHLOROMORPH( "CHLOROMORPH" );
static const trait_id trait_CLUMSY( "CLUMSY" );
static const trait_id trait_COLDBLOOD4( "COLDBLOOD4" );
static const trait_id trait_DEBUG_BIONIC_POWER( "DEBUG_BIONIC_POWER" );
static const trait_id trait_DEBUG_CLOAK( "DEBUG_CLOAK" );
static const trait_id trait_DEBUG_HS( "DEBUG_HS" );
static const trait_id trait_DEFT( "DEFT" );
static const trait_id trait_EASYSLEEPER( "EASYSLEEPER" );
Expand Down Expand Up @@ -215,7 +214,6 @@ static const skill_id skill_dodge( "dodge" );
static const skill_id skill_gun( "gun" );
static const skill_id skill_swimming( "swimming" );

static const bionic_id bio_cloak( "bio_cloak" );
static const bionic_id bio_cqb( "bio_cqb" );
static const bionic_id bio_earplugs( "bio_earplugs" );
static const bionic_id bio_ears( "bio_ears" );
Expand Down Expand Up @@ -610,36 +608,6 @@ void player::set_underwater( bool u )
}
}

nc_color player::basic_symbol_color() const
{
if( has_effect( effect_onfire ) ) {
return c_red;
}
if( has_effect( effect_stunned ) ) {
return c_light_blue;
}
if( has_effect( effect_boomered ) ) {
return c_pink;
}
if( has_active_mutation( trait_id( "SHELL2" ) ) ) {
return c_magenta;
}
if( underwater ) {
return c_blue;
}
if( has_active_bionic( bio_cloak ) || has_artifact_with( AEP_INVISIBLE ) ||
is_wearing_active_optcloak() || has_trait( trait_DEBUG_CLOAK ) ) {
return c_dark_gray;
}
if( move_mode == CMM_RUN ) {
return c_yellow;
}
if( move_mode == CMM_CROUCH ) {
return c_light_gray;
}
return c_white;
}

void player::mod_stat( const std::string &stat, float modifier )
{
if( stat == "thirst" ) {
Expand Down
3 changes: 0 additions & 3 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ class player : public Character
return false; // Overloaded for NPCs in npc.h
}

/** Returns what color the player should be drawn as */
nc_color basic_symbol_color() const override;

// populate variables, inventory items, and misc from json object
virtual void deserialize( JsonIn &jsin ) = 0;

Expand Down

0 comments on commit 36f2c77

Please sign in to comment.