ManaPlus
Public Member Functions | Private Attributes
PlayerListener Class Reference

#include <playerlistener.h>

Inheritance diagram for PlayerListener:
ActionListener

Public Member Functions

 PlayerListener ()
 
void action (const ActionEvent &event)
 
void setNick (const std::string &name)
 
void setDialog (TextDialog *const dialog)
 
void setType (const ActorTypeT type)
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 

Private Attributes

std::string mNick
 
TextDialogmDialog
 
ActorTypeT mType
 

Additional Inherited Members

- Protected Member Functions inherited from ActionListener
 ActionListener ()
 

Detailed Description

Definition at line 33 of file playerlistener.h.

Constructor & Destructor Documentation

◆ PlayerListener()

PlayerListener::PlayerListener ( )

Definition at line 32 of file playerlistener.cpp.

32  :
34  mNick(),
35  mDialog(nullptr),
37 {
38 }
std::string mNick
ActorTypeT mType
TextDialog * mDialog

Member Function Documentation

◆ action()

void PlayerListener::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Implements ActionListener.

Definition at line 40 of file playerlistener.cpp.

41 {
42  if (event.getId() == "ok" && !mNick.empty() && (mDialog != nullptr))
43  {
44  std::string comment = mDialog->getText();
45  Being *const being = actorManager->findBeingByName(
46  mNick, static_cast<ActorTypeT>(mType));
47  if (being != nullptr)
48  being->setComment(comment);
49  Being::saveComment(mNick, comment, mType);
50  }
51  mDialog = nullptr;
52 }
ActorManager * actorManager
ActorType ::T ActorTypeT
Definition: actortype.h:43
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
Definition: being.h:96
void setComment(const std::string &n)
Definition: being.h:815
static void saveComment(const std::string &name, const std::string &comment, const ActorTypeT &type)
Definition: being.cpp:4771
const std::string & getText() const
Definition: textdialog.cpp:124

References actorManager, ActorManager::findBeingByName(), ActionEvent::getId(), TextDialog::getText(), mDialog, mNick, mType, Being::saveComment(), and Being::setComment().

◆ setDialog()

void PlayerListener::setDialog ( TextDialog *const  dialog)
inline

Definition at line 45 of file playerlistener.h.

46  { mDialog = dialog; }

References mDialog.

Referenced by PopupMenu::handleLink(), and PopupMenu::PopupMenu().

◆ setNick()

void PlayerListener::setNick ( const std::string &  name)
inline

Definition at line 42 of file playerlistener.h.

43  { mNick = name; }

References mNick.

Referenced by PopupMenu::handleLink(), and PopupMenu::PopupMenu().

◆ setType()

void PlayerListener::setType ( const ActorTypeT  type)
inline

Definition at line 48 of file playerlistener.h.

49  { mType = type; }

References mType.

Referenced by PopupMenu::handleLink(), and PopupMenu::PopupMenu().

Field Documentation

◆ mDialog

TextDialog* PlayerListener::mDialog
private

Definition at line 53 of file playerlistener.h.

Referenced by action(), and setDialog().

◆ mNick

std::string PlayerListener::mNick
private

Definition at line 52 of file playerlistener.h.

Referenced by action(), and setNick().

◆ mType

ActorTypeT PlayerListener::mType
private

Definition at line 54 of file playerlistener.h.

Referenced by action(), and setType().


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