ManaPlus
Public Member Functions | Private Attributes
RenameListener Class Reference

#include <renamelistener.h>

Inheritance diagram for RenameListener:
ActionListener

Public Member Functions

 RenameListener ()
 
void action (const ActionEvent &event)
 
void setMapItem (const MapItem *const mapItem)
 
void setDialog (TextDialog *dialog)
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 

Private Attributes

int mMapItemX
 
int mMapItemY
 
TextDialogmDialog
 

Additional Inherited Members

- Protected Member Functions inherited from ActionListener
 ActionListener ()
 

Detailed Description

Definition at line 32 of file renamelistener.h.

Constructor & Destructor Documentation

◆ RenameListener()

RenameListener::RenameListener ( )

Definition at line 35 of file renamelistener.cpp.

35  :
37  mMapItemX(0),
38  mMapItemY(0),
39  mDialog(nullptr)
40 {
41 }
TextDialog * mDialog

Member Function Documentation

◆ action()

void RenameListener::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 57 of file renamelistener.cpp.

58 {
59  if (event.getId() == "ok" && (viewport != nullptr) && (mDialog != nullptr))
60  {
61  const Map *const map = viewport->getMap();
62  if (map == nullptr)
63  return;
64 
65  const SpecialLayer *const sl = map->getSpecialLayer();
66  MapItem *item = nullptr;
67  if (sl != nullptr)
68  {
69  item = sl->getTile(mMapItemX, mMapItemY);
70  if (item != nullptr)
71  item->setComment(mDialog->getText());
72  }
73  item = map->findPortalXY(mMapItemX, mMapItemY);
74  if (item != nullptr)
75  item->setComment(mDialog->getText());
76 
77  if (socialWindow != nullptr)
79  }
80  mDialog = nullptr;
81 }
void setComment(const std::string &comment)
Definition: mapitem.h:71
Definition: map.h:75
SpecialLayer * getSpecialLayer() const
Definition: map.h:241
MapItem * findPortalXY(const int x, const int y) const
Definition: map.cpp:1338
void updatePortalNames()
MapItem * getTile(const int x, const int y) const
const std::string & getText() const
Definition: textdialog.cpp:124
Map * getMap() const
Definition: viewport.h:135
Viewport * viewport
Definition: viewport.cpp:36
SocialWindow * socialWindow

References Map::findPortalXY(), ActionEvent::getId(), Viewport::getMap(), Map::getSpecialLayer(), TextDialog::getText(), SpecialLayer::getTile(), mDialog, mMapItemX, mMapItemY, MapItem::setComment(), socialWindow, SocialWindow::updatePortalNames(), and viewport.

◆ setDialog()

void RenameListener::setDialog ( TextDialog dialog)
inline

Definition at line 43 of file renamelistener.h.

44  { mDialog = dialog; }

References mDialog.

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

◆ setMapItem()

void RenameListener::setMapItem ( const MapItem *const  mapItem)

Definition at line 43 of file renamelistener.cpp.

44 {
45  if (mapItem != nullptr)
46  {
47  mMapItemX = mapItem->getX();
48  mMapItemY = mapItem->getY();
49  }
50  else
51  {
52  mMapItemX = 0;
53  mMapItemY = 0;
54  }
55 }
int getY() const
Definition: mapitem.h:65
int getX() const
Definition: mapitem.h:62

References MapItem::getX(), MapItem::getY(), mMapItemX, and mMapItemY.

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

Field Documentation

◆ mDialog

TextDialog* RenameListener::mDialog
private

Definition at line 49 of file renamelistener.h.

Referenced by action(), and setDialog().

◆ mMapItemX

int RenameListener::mMapItemX
private

Definition at line 47 of file renamelistener.h.

Referenced by action(), and setMapItem().

◆ mMapItemY

int RenameListener::mMapItemY
private

Definition at line 48 of file renamelistener.h.

Referenced by action(), and setMapItem().


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