ManaPlus
Public Member Functions | Private Attributes
OnlinePlayer Class Reference

#include <onlineplayer.h>

Public Member Functions

 OnlinePlayer (const std::string &nick, const unsigned char status, const signed char level, const GenderT gender, const signed char version, const int group)
 
const std::string getNick () const
 
unsigned char getStaus () const
 
void setIsGM (const bool b)
 
char getVersion () const
 
char getLevel () const
 
const std::string getText () const
 
void setText (std::string str)
 
void setLevel (const char level)
 

Private Attributes

std::string mNick
 
std::string mText
 
int mGroup
 
unsigned char mStatus
 
signed char mLevel
 
signed char mVersion
 
GenderT mGender
 
bool mIsGM
 

Detailed Description

Definition at line 31 of file onlineplayer.h.

Constructor & Destructor Documentation

◆ OnlinePlayer()

OnlinePlayer::OnlinePlayer ( const std::string &  nick,
const unsigned char  status,
const signed char  level,
const GenderT  gender,
const signed char  version,
const int  group 
)
inline

Definition at line 34 of file onlineplayer.h.

39  :
40  mNick(nick),
41  mText(),
42  mGroup(group),
43  mStatus(status),
44  mLevel(level),
45  mVersion(version),
46  mGender(gender),
47  mIsGM(false)
48  {
49  }
std::string mText
Definition: onlineplayer.h:79
std::string mNick
Definition: onlineplayer.h:77
unsigned char mStatus
Definition: onlineplayer.h:83
signed char mLevel
Definition: onlineplayer.h:85
signed char mVersion
Definition: onlineplayer.h:87
GenderT mGender
Definition: onlineplayer.h:89

Member Function Documentation

◆ getLevel()

char OnlinePlayer::getLevel ( ) const
inline

Definition at line 65 of file onlineplayer.h.

66  { return mLevel; }

References mLevel.

◆ getNick()

const std::string OnlinePlayer::getNick ( ) const
inline

Definition at line 53 of file onlineplayer.h.

54  { return mNick; }

References mNick.

Referenced by WhoIsOnline::loadList(), and WhoIsOnline::setNeutralColor().

◆ getStaus()

unsigned char OnlinePlayer::getStaus ( ) const
inline

Definition at line 56 of file onlineplayer.h.

57  { return mStatus; }

References mStatus.

◆ getText()

const std::string OnlinePlayer::getText ( ) const
inline

Definition at line 68 of file onlineplayer.h.

69  { return mText; }

References mText.

◆ getVersion()

char OnlinePlayer::getVersion ( ) const
inline

Definition at line 62 of file onlineplayer.h.

63  { return mVersion; }

References mVersion.

◆ setIsGM()

void OnlinePlayer::setIsGM ( const bool  b)
inline

Definition at line 59 of file onlineplayer.h.

60  { mIsGM = b; }

References mIsGM.

Referenced by WhoIsOnline::loadWebList().

◆ setLevel()

void OnlinePlayer::setLevel ( const char  level)
inline

Definition at line 73 of file onlineplayer.h.

74  { mLevel = level; }

References mLevel.

Referenced by WhoIsOnline::loadList().

◆ setText()

void OnlinePlayer::setText ( std::string  str)

Definition at line 860 of file whoisonline.cpp.

861 {
862  mText.clear();
863 
864  if (mStatus != 255 && (actorManager != nullptr))
865  {
866  Being *const being = actorManager->findBeingByName(
868  if (being != nullptr)
869  {
870  being->setState(mStatus);
871  // for now highlight versions > 3
872  if (mVersion > 3)
873  being->setAdvanced(true);
874  }
875  }
876 
877 #ifdef TMWA_SUPPORT
878  if (mGroup != -1 && GroupDb::getShowBadge(mGroup))
879  {
880  const std::string &name = GroupDb::getName(mGroup);
881  mText.append(strprintf("(%s) ", name.c_str()));
882  }
883  else
884 #endif
885  {
886  if ((mStatus != 255 && ((mStatus & BeingFlag::GM) != 0)) || mIsGM)
887  mText.append("(GM) ");
888  }
889 
890  if (mLevel > 0)
891  mText.append(strprintf("%d", mLevel));
892 
893  if (mGender == Gender::FEMALE)
894  mText.append("\u2640");
895  else if (mGender == Gender::MALE)
896  mText.append("\u2642");
897 
898 #ifdef TMWA_SUPPORT
899  if (mGroup != -1 && GroupDb::getHighlightName(mGroup) && color == "0")
900  color = "2";
901 #endif
902 
903  if (mStatus > 0 && mStatus != 255)
904  {
905  if ((mStatus & BeingFlag::SHOP) != 0)
906  mText.append("$");
907  if ((mStatus & BeingFlag::AWAY) != 0)
908  {
909  // TRANSLATORS: this away status writed in player nick
910  mText.append(_("A"));
911  }
912  if ((mStatus & BeingFlag::INACTIVE) != 0)
913  {
914  // TRANSLATORS: this inactive status writed in player nick
915  mText.append(_("I"));
916  }
917 
918  if (((mStatus & BeingFlag::GM) != 0) && color == "0")
919  color = "2";
920  }
921  else if (mIsGM && color == "0")
922  {
923  color = "2";
924  }
925 
926  if (mVersion > 0)
927  mText.append(strprintf(" - %d", mVersion));
928 
929  const std::string text = encodeLinkText(mNick);
930  mText = strprintf("@@%s|##%s%s %s@@", text.c_str(), color.c_str(),
931  text.c_str(), mText.c_str());
932 }
ActorManager * actorManager
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
Definition: being.h:96
void setState(const uint8_t state)
Definition: being.cpp:4803
void setAdvanced(const bool n)
Definition: being.h:831
#define _(s)
Definition: gettext.h:35
@ INACTIVE
Definition: beingflag.h:31
@ MALE
Definition: gender.h:31
@ FEMALE
Definition: gender.h:32
bool getShowBadge(const int id)
Definition: groupdb.cpp:366
bool getHighlightName(const int id)
Definition: groupdb.cpp:377
const std::string & getName(const int id)
Definition: groupdb.cpp:344
std::string strprintf(const char *const format,...)
std::string encodeLinkText(std::string data)

References _, actorManager, BeingFlag::AWAY, encodeLinkText(), Gender::FEMALE, ActorManager::findBeingByName(), GroupDb::getHighlightName(), GroupDb::getName(), GroupDb::getShowBadge(), BeingFlag::GM, BeingFlag::INACTIVE, Gender::MALE, mGender, mGroup, mIsGM, mLevel, mNick, mStatus, mText, mVersion, ActorType::Player, Being::setAdvanced(), Being::setState(), BeingFlag::SHOP, and strprintf().

Referenced by WhoIsOnline::handlerPlayerRelation(), and WhoIsOnline::setNeutralColor().

Field Documentation

◆ mGender

GenderT OnlinePlayer::mGender
private

Definition at line 89 of file onlineplayer.h.

Referenced by setText().

◆ mGroup

int OnlinePlayer::mGroup
private

Definition at line 81 of file onlineplayer.h.

Referenced by setText().

◆ mIsGM

bool OnlinePlayer::mIsGM
private

Definition at line 91 of file onlineplayer.h.

Referenced by setIsGM(), and setText().

◆ mLevel

signed char OnlinePlayer::mLevel
private

Definition at line 85 of file onlineplayer.h.

Referenced by getLevel(), setLevel(), and setText().

◆ mNick

std::string OnlinePlayer::mNick
private

Definition at line 77 of file onlineplayer.h.

Referenced by getNick(), and setText().

◆ mStatus

unsigned char OnlinePlayer::mStatus
private

Definition at line 83 of file onlineplayer.h.

Referenced by getStaus(), and setText().

◆ mText

std::string OnlinePlayer::mText
private

Definition at line 79 of file onlineplayer.h.

Referenced by getText(), and setText().

◆ mVersion

signed char OnlinePlayer::mVersion
private

Definition at line 87 of file onlineplayer.h.

Referenced by getVersion(), and setText().


The documentation for this class was generated from the following files: