ManaPlus
Public Member Functions | Private Attributes
QuestsWindow Class Reference

#include <questswindow.h>

Inheritance diagram for QuestsWindow:
Window ActionListener BasicContainer2 MouseListener WidgetListener BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 QuestsWindow ()
 
 ~QuestsWindow ()
 
void action (const ActionEvent &event)
 
void updateQuest (const int var, const int val1, const int val2, const int val3, const int time1)
 
void rebuild (const bool playSound)
 
void showQuest (const QuestItem *const quest)
 
void setMap (const Map *const map)
 
void updateEffects ()
 
void addEffect (Being *const being)
 
void selectQuest (const int varId)
 
- Public Member Functions inherited from Window
 Window (const std::string &caption, const Modal modal, Window *const parent, std::string skin)
 
 ~Window ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void setContentSize (int width, int height)
 
void setLocationRelativeTo (const Widget *const widget)
 
void setLocationHorisontallyRelativeTo (const Widget *const widget)
 
void setLocationRelativeTo (const ImagePosition::Type &position, int offsetX, int offsetY)
 
void setResizable (const bool resize)
 
void redraw ()
 
void widgetResized (const Event &event)
 
void widgetMoved (const Event &event)
 
void widgetHidden (const Event &event)
 
void setCloseButton (const bool flag)
 
bool getCloseButton () const
 
void setAllowClose (const bool b)
 
bool getAlowClose () const
 
bool isResizable () const
 
void setMinWidth (const int width)
 
int getMinWidth () const
 
void setMinHeight (const int height)
 
int getMinHeight () const
 
void setMaxWidth (const int width)
 
int getMaxWidth () const
 
void setMaxHeight (const int height)
 
int getMaxHeight () const
 
void setShowTitle (bool flag)
 
void setStickyButton (const bool flag)
 
void setSticky (const bool sticky)
 
bool isSticky () const
 
void setStickyButtonLock (const bool sticky)
 
bool isStickyButtonLock () const
 
virtual void setVisible (Visible visible)
 
void setVisible (const Visible visible, const bool forceSticky)
 
bool isDefaultVisible () const
 
void setDefaultVisible (const bool save)
 
bool willSaveVisible () const
 
void setSaveVisible (const bool save)
 
void postInit ()
 
WindowgetParentWindow () const
 
virtual void scheduleDelete ()
 
void mousePressed (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void mouseMoved (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void mouseEntered (MouseEvent &event)
 
void updateResizeHandler (MouseEvent &event)
 
void setWindowName (const std::string &name)
 
const std::string & getWindowName () const
 
void loadWindowState ()
 
void saveWindowState ()
 
void setDefaultSize (const int defaultX, const int defaultY, int defaultWidth, int defaultHeight)
 
void setDefaultSize ()
 
void setDefaultSize (const int defaultWidth, const int defaultHeight, const ImagePosition::Type &position, const int offsetx, const int offsetY)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w, int h)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w, const int h)
 
ContainerPlacer getPlacer (const int x, const int y)
 
void center ()
 
void centerHorisontally ()
 
virtual void close ()
 
void setModal (const Modal modal)
 
Rect getWindowArea () const
 
bool isResizeAllowed (const MouseEvent &event) const
 
void setCaptionFont (Font *font)
 
void enableVisibleSound (bool b)
 
bool isWindowVisible () const
 
void setPadding (int padding)
 
int getPadding () const
 
void setTitleBarHeight (unsigned int height)
 
unsigned int getTitleBarHeight () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void setAlignment (Graphics::Alignment alignment)
 
Graphics::Alignment getAlignment () const
 
void setMovable (Move movable)
 
bool isMovable () const
 
Rect getChildrenArea ()
 
virtual void resizeToContent ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
 ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget * > &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetShown (const Event &event)
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 

Private Attributes

QuestsModelmQuestsModel
 
ExtendedListBoxmQuestsListBox
 
ScrollAreamQuestScrollArea
 
ItemLinkHandlermItemLinkHandler
 
BrowserBoxmText
 
ScrollAreamTextScrollArea
 
ButtonmCloseButton
 
ImagemCompleteIcon
 
ImagemIncompleteIcon
 
std::vector< const QuestEffect * > mMapEffects
 
NpcQuestVarMapmVars
 
std::map< int, std::vector< QuestItem * > > * mQuests
 
std::vector< QuestEffect * > * mAllEffects
 
NpcQuestEffectMap mNpcEffects
 
std::vector< QuestItem * > mQuestLinks
 
std::map< int, int > mQuestReverseLinks
 
int mNewQuestEffectId
 
int mCompleteQuestEffectId
 
const MapmMap
 

Additional Inherited Members

- Static Public Member Functions inherited from Window
static void setWindowContainer (WindowContainer *const windowContainer)
 
- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from Window
bool canMove () const
 
int getOption (const std::string &name, const int def) const
 
bool getOptionBool (const std::string &name, const bool def) const
 
void setTitlePadding (const int p)
 
int getTitlePadding () const
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Attributes inherited from Window
std::string mCaption
 
Graphics::Alignment mAlignment
 
int mPadding
 
unsigned int mTitleBarHeight
 
Move mMovable
 
int mDragOffsetX
 
int mDragOffsetY
 
bool mMoved
 
SkinmSkin
 
int mDefaultX
 
int mDefaultY
 
int mDefaultWidth
 
int mDefaultHeight
 
int mCaptionOffsetX
 
int mCaptionOffsetY
 
bool mShowTitle
 
bool mLastRedraw
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

Definition at line 50 of file questswindow.h.

Constructor & Destructor Documentation

◆ QuestsWindow()

QuestsWindow::QuestsWindow ( )

Definition at line 64 of file questswindow.cpp.

64  :
65  // TRANSLATORS: quests window name
66  Window(_("Quests"), Modal_false, nullptr, "quests.xml"),
70  this, mQuestsModel, "extendedlistbox.xml", 13)),
72  fromBool(getOptionBool("showlistbackground", false), Opaque),
73  "quests_list_background.xml")),
75  mText(new BrowserBox(this, Opaque_true,
76  "browserbox.xml")),
78  fromBool(getOptionBool("showtextbackground", false), Opaque),
79  "quests_text_background.xml")),
80  // TRANSLATORS: quests window button
81  mCloseButton(new Button(this, _("Close"), "close", BUTTON_SKIN, this)),
82  mCompleteIcon(Theme::getImageFromThemeXml("complete_icon.xml", "")),
83  mIncompleteIcon(Theme::getImageFromThemeXml("incomplete_icon.xml", "")),
84  mMapEffects(),
85  mVars(nullptr),
86  mQuests(nullptr),
87  mAllEffects(nullptr),
88  mNpcEffects(),
89  mQuestLinks(),
91  mNewQuestEffectId(paths.getIntValue("newQuestEffectId")),
92  mCompleteQuestEffectId(paths.getIntValue("completeQuestEffectId")),
93  mMap(nullptr)
94 {
95  setWindowName("Quests");
96  setResizable(true);
97  setCloseButton(true);
98  setStickyButtonLock(true);
99  setSaveVisible(true);
100 
101  setDefaultSize(400, 350, ImagePosition::RIGHT, 0, 0);
102  setMinWidth(310);
103  setMinHeight(220);
104 
105  if (setupWindow != nullptr)
107 
108  mQuestsListBox->setActionEventId("select");
110 
115  mQuestsListBox->setWidth(500);
116  if ((gui == nullptr) || gui->getNpcFont()->getHeight() < 20)
118  else
120 
121  ContainerPlacer placer(nullptr, nullptr);
122  placer = getPlacer(0, 0);
123 
124  placer(0, 0, mQuestScrollArea, 4, 3).setPadding(3);
125  placer(4, 0, mTextScrollArea, 4, 3).setPadding(3);
126  placer(7, 3, mCloseButton, 1, 1);
127 
128  Layout &layout = getLayout();
129  layout.setRowHeight(0, LayoutType::SET);
130 
131  loadWindowState();
132  enableVisibleSound(true);
133  QuestDb::load();
137 }
#define fromBool(val, name)
Definition: booldefines.h:49
const std::string BUTTON_SKIN
Definition: button.h:89
void setLinkHandler(LinkHandler *linkHandler)
Definition: browserbox.cpp:166
void setOpaque(Opaque opaque)
Definition: browserbox.h:75
Definition: button.h:102
int getIntValue(const std::string &key) const
int getHeight() const
Definition: font.cpp:362
Font * getNpcFont() const
Definition: gui.h:178
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:128
Definition: layout.h:45
void setRowHeight(unsigned int n)
Definition: listbox.h:159
QuestsModel * mQuestsModel
Definition: questswindow.h:81
ScrollArea * mQuestScrollArea
Definition: questswindow.h:83
std::vector< const QuestEffect * > mMapEffects
Definition: questswindow.h:90
Button * mCloseButton
Definition: questswindow.h:87
Image * mCompleteIcon
Definition: questswindow.h:88
NpcQuestEffectMap mNpcEffects
Definition: questswindow.h:96
int mCompleteQuestEffectId
Definition: questswindow.h:100
ExtendedListBox * mQuestsListBox
Definition: questswindow.h:82
ItemLinkHandler * mItemLinkHandler
Definition: questswindow.h:84
std::map< int, int > mQuestReverseLinks
Definition: questswindow.h:98
NpcQuestVarMap * mVars
Definition: questswindow.h:91
std::map< int, std::vector< QuestItem * > > * mQuests
Definition: questswindow.h:92
int mNewQuestEffectId
Definition: questswindow.h:99
std::vector< QuestItem * > mQuestLinks
Definition: questswindow.h:97
BrowserBox * mText
Definition: questswindow.h:85
ScrollArea * mTextScrollArea
Definition: questswindow.h:86
const Map * mMap
Definition: questswindow.h:101
std::vector< QuestEffect * > * mAllEffects
Definition: questswindow.h:93
Image * mIncompleteIcon
Definition: questswindow.h:89
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)
void registerWindowForReset(Window *const window)
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:926
void setWidth(const int width)
Definition: widget.cpp:133
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
void setSaveVisible(const bool save)
Definition: window.h:300
void setResizable(const bool resize)
Definition: window.cpp:627
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1391
bool getOptionBool(const std::string &name, const bool def) const
Definition: window.cpp:1466
Layout & getLayout()
Definition: window.cpp:1365
void setWindowName(const std::string &name)
Definition: window.h:355
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:109
void setMinHeight(const int height)
Definition: window.cpp:604
void setMinWidth(const int width)
Definition: window.cpp:591
void enableVisibleSound(bool b)
Definition: window.h:481
void setCloseButton(const bool flag)
Definition: window.cpp:749
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:772
void setDefaultSize()
Definition: window.cpp:1198
void loadWindowState()
Definition: window.cpp:1087
Configuration paths
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36
#define _(s)
Definition: gettext.h:35
Gui * gui
Definition: gui.cpp:111
const bool Modal_false
Definition: modal.h:30
NpcQuestVarMap * getVars()
Definition: questdb.cpp:234
void load()
Definition: questdb.cpp:47
std::map< int, std::vector< QuestItem * > > * getQuests()
Definition: questdb.cpp:239
std::vector< QuestEffect * > * getAllEffects()
Definition: questdb.cpp:244
const bool Opaque_false
Definition: opaque.h:30
const bool Opaque_true
Definition: opaque.h:30
bool Opaque
Definition: opaque.h:30
SetupWindow * setupWindow
Definition: setupwindow.cpp:64

References Widget::addActionListener(), Window::enableVisibleSound(), QuestDb::getAllEffects(), Font::getHeight(), Window::getLayout(), Gui::getNpcFont(), Window::getPlacer(), QuestDb::getQuests(), QuestDb::getVars(), gui, QuestDb::load(), Window::loadWindowState(), mAllEffects, mCloseButton, mItemLinkHandler, mQuests, mQuestScrollArea, mQuestsListBox, mText, mTextScrollArea, mVars, Opaque_false, SetupWindow::registerWindowForReset(), ImagePosition::RIGHT, LayoutType::SET, Widget::setActionEventId(), Window::setCloseButton(), Window::setDefaultSize(), ScrollArea::setHorizontalScrollPolicy(), BrowserBox::setLinkHandler(), Window::setMinHeight(), Window::setMinWidth(), BrowserBox::setOpaque(), Window::setResizable(), LayoutCell::setRowHeight(), ListBox::setRowHeight(), Window::setSaveVisible(), Window::setStickyButtonLock(), setupWindow, Widget::setWidth(), Window::setWindowName(), and ScrollArea::SHOW_NEVER.

◆ ~QuestsWindow()

QuestsWindow::~QuestsWindow ( )

Definition at line 139 of file questswindow.cpp.

140 {
142 
143  QuestDb::unload();
144 
146  mQuestLinks.clear();
147  mQuestReverseLinks.clear();
148  if (mCompleteIcon != nullptr)
149  {
150  mCompleteIcon->decRef();
151  mCompleteIcon = nullptr;
152  }
153  if (mIncompleteIcon != nullptr)
154  {
155  mIncompleteIcon->decRef();
156  mIncompleteIcon = nullptr;
157  }
158 }
#define delete2(var)
Definition: delete2.h:25
void unload()
Definition: questdb.cpp:216

References delete2, mCompleteIcon, mIncompleteIcon, mItemLinkHandler, mQuestLinks, mQuestReverseLinks, mQuestsModel, and QuestDb::unload().

Member Function Documentation

◆ action()

void QuestsWindow::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 160 of file questswindow.cpp.

161 {
162  const std::string &eventId = event.getId();
163  if (eventId == "select")
164  {
165  const int id = mQuestsListBox->getSelected();
166  if (id < 0)
167  return;
168  showQuest(mQuestLinks[id]);
169  }
170  else if (eventId == "close")
171  {
173  }
174 }
int getSelected() const
Definition: listbox.h:168
void showQuest(const QuestItem *const quest)
virtual void setVisible(Visible visible)
Definition: window.cpp:778
const bool Visible_false
Definition: visible.h:30

References ListBox::getSelected(), mQuestLinks, mQuestsListBox, Window::setVisible(), showQuest(), and Visible_false.

◆ addEffect()

void QuestsWindow::addEffect ( Being *const  being)

Definition at line 464 of file questswindow.cpp.

465 {
466  if (being == nullptr)
467  return;
468  const BeingTypeId id = being->getSubType();
469  const std::map<BeingTypeId, const QuestEffect*>::const_iterator
470  it = mNpcEffects.find(id);
471  if (it != mNpcEffects.end())
472  {
473  const QuestEffect *const effect = (*it).second;
474  if (effect != nullptr)
475  being->addSpecialEffect(effect->effectId);
476  }
477 }
int BeingTypeId
Definition: beingtypeid.h:30
BeingTypeId getSubType() const
Definition: being.h:400
void addSpecialEffect(const int effect)
Definition: being.cpp:4928

References Being::addSpecialEffect(), QuestEffect::effectId, Being::getSubType(), and mNpcEffects.

Referenced by ActorManager::createBeing().

◆ rebuild()

void QuestsWindow::rebuild ( const bool  playSound)

Definition at line 185 of file questswindow.cpp.

186 {
187  mQuestsModel->clear();
188  mQuestLinks.clear();
189  mQuestReverseLinks.clear();
190  StringVect &names = mQuestsModel->getNames();
191  STD_VECTOR<Image*> &images = mQuestsModel->getImages();
192  STD_VECTOR<QuestItem*> complete;
193  STD_VECTOR<QuestItem*> incomplete;
194  STD_VECTOR<QuestItem*> hidden;
195  int updatedQuest = -1;
196  int newCompleteStatus = -1;
197 
199  {
200  const int var = (*it).first;
201  const QuestVar &val = (*it).second;
202  const STD_VECTOR<QuestItem*> &quests = (*mQuests)[var];
203  FOR_EACH (STD_VECTOR<QuestItem*>::const_iterator, it2, quests)
204  {
205  if (*it2 == nullptr)
206  continue;
207  QuestItem *const quest = *it2;
208  // complete quest
209  if (quest->complete.find(val.var1) != quest->complete.end())
210  {
211  complete.push_back(quest);
212  }
213  // incomplete quest
214  else if (quest->incomplete.find(val.var1) !=
215  quest->incomplete.end())
216  {
217  incomplete.push_back(quest);
218  }
219  // hidden quest
220  else
221  {
222  hidden.push_back(quest);
223  }
224  }
225  }
226 
227  int k = 0;
228 
229  for (STD_VECTOR<QuestItem*>::const_iterator it = complete.begin(),
230  it_end = complete.end(); it != it_end; ++ it, k ++)
231  {
232  QuestItem *const quest = *it;
233  if (quest->completeFlag == 0 || (quest->broken
234  && quest->completeFlag == -1))
235  {
236  updatedQuest = k;
237  newCompleteStatus = 1;
238  }
239  quest->completeFlag = 1;
240  mQuestLinks.push_back(quest);
241  mQuestReverseLinks[quest->var] = k;
242  names.push_back(quest->name);
243  if (mCompleteIcon != nullptr)
244  {
245  mCompleteIcon->incRef();
246  images.push_back(mCompleteIcon);
247  }
248  else
249  {
250  images.push_back(nullptr);
251  }
252  }
253 
254  for (STD_VECTOR<QuestItem*>::const_iterator it = incomplete.begin(),
255  it_end = incomplete.end(); it != it_end; ++ it, k ++)
256  {
257  QuestItem *const quest = *it;
258  if (quest->completeFlag == -1)
259  {
260  updatedQuest = k;
261  newCompleteStatus = 0;
262  }
263  quest->completeFlag = 0;
264  mQuestLinks.push_back(quest);
265  mQuestReverseLinks[quest->var] = k;
266  names.push_back(quest->name);
267  if (mIncompleteIcon != nullptr)
268  {
269  mIncompleteIcon->incRef();
270  images.push_back(mIncompleteIcon);
271  }
272  else
273  {
274  images.push_back(nullptr);
275  }
276  }
277 
278  FOR_EACH (STD_VECTOR<QuestItem*>::const_iterator, it, hidden)
279  (*it)->completeFlag = -1;
280 
281  if (updatedQuest == -1 || updatedQuest >= CAST_S32(
282  mQuestLinks.size()))
283  {
284  updatedQuest = CAST_S32(mQuestLinks.size() - 1);
285  }
286  if (updatedQuest >= 0)
287  {
288  mQuestsListBox->setSelected(updatedQuest);
289  showQuest(mQuestLinks[updatedQuest]);
290  if (playSound && (effectManager != nullptr))
291  {
292  switch (newCompleteStatus)
293  {
294  case 0:
296  break;
297  case 1:
299  localPlayer,
300  0);
301  break;
302  default:
303  break;
304  }
305  }
306  }
307  updateEffects();
308 }
#define CAST_S32
Definition: cast.h:30
bool trigger(const int id, Being *const being, const int rotation)
StringVect & getNames()
std::vector< Image * > & getImages()
void setSelected(const int selected)
Definition: listbox.cpp:399
void updateEffects()
EffectManager * effectManager
#define FOR_EACHP(type, iter, array)
Definition: foreach.h:31
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
LocalPlayer * localPlayer
NpcQuestVarMap::const_iterator NpcQuestVarMapCIter
Definition: questvar.h:59
std::vector< std::string > StringVect
Definition: stringvector.h:29
int var
Definition: questitem.h:49
bool broken
Definition: questitem.h:56
std::set< int > complete
Definition: questitem.h:53
std::string name
Definition: questitem.h:50
int completeFlag
Definition: questitem.h:55
std::set< int > incomplete
Definition: questitem.h:52
int var1
Definition: questvar.h:52

References QuestItem::broken, CAST_S32, ExtendedNamesModel::clear(), QuestItem::complete, QuestItem::completeFlag, effectManager, FOR_EACH, FOR_EACHP, ExtendedNamesModel::getImages(), ExtendedNamesModel::getNames(), QuestItem::incomplete, localPlayer, mCompleteIcon, mCompleteQuestEffectId, mIncompleteIcon, mNewQuestEffectId, mQuestLinks, mQuestReverseLinks, mQuestsListBox, mQuestsModel, mVars, QuestItem::name, ListBox::setSelected(), showQuest(), EffectManager::trigger(), updateEffects(), QuestItem::var, and QuestVar::var1.

Referenced by EAthena::QuestRecv::processAddQuest(), EAthena::QuestRecv::processAddQuest2(), EAthena::QuestRecv::processAddQuests(), EAthena::QuestRecv::processAddQuests2(), TmwAthena::QuestRecv::processPlayerQuests(), EAthena::QuestRecv::processRemoveQuest(), and TmwAthena::QuestRecv::processSetQuestVar().

◆ selectQuest()

void QuestsWindow::selectQuest ( const int  varId)

Definition at line 479 of file questswindow.cpp.

480 {
481  std::map<int, int>::const_iterator it = mQuestReverseLinks.find(varId);
482  if (it == mQuestReverseLinks.end())
483  return;
484  if (mVisible == Visible_false)
486  const int listPos = (*it).second;
487  if (listPos < 0)
488  return;
489  showQuest(mQuestLinks[listPos]);
490  mQuestsListBox->setSelected(listPos);
492 }
virtual void requestMoveToTop()
Definition: widget.cpp:213
Visible mVisible
Definition: widget.h:963
const bool Visible_true
Definition: visible.h:30

References mQuestLinks, mQuestReverseLinks, mQuestsListBox, Widget::mVisible, Widget::requestMoveToTop(), ListBox::setSelected(), Window::setVisible(), showQuest(), Visible_false, and Visible_true.

Referenced by ItemLinkHandler::handleLink().

◆ setMap()

void QuestsWindow::setMap ( const Map *const  map)

Definition at line 380 of file questswindow.cpp.

381 {
382  if (mMap != map)
383  {
384  mMap = map;
385  mMapEffects.clear();
386  if (mMap == nullptr)
387  return;
388 
389  const std::string name = mMap->getProperty("shortName",
390  std::string());
391  FOR_EACHP (STD_VECTOR<QuestEffect*>::const_iterator, it, mAllEffects)
392  {
393  const QuestEffect *const effect = *it;
394  if ((effect != nullptr) && name == effect->map)
395  mMapEffects.push_back(effect);
396  }
397  updateEffects();
398  }
399 }
const std::string getProperty(const std::string &name, const std::string &def) const
Definition: properties.h:59
std::string map
Definition: questeffect.h:45

References FOR_EACHP, Properties::getProperty(), mAllEffects, QuestEffect::map, mMap, mMapEffects, and updateEffects().

Referenced by Game::changeMap().

◆ showQuest()

void QuestsWindow::showQuest ( const QuestItem *const  quest)

Definition at line 310 of file questswindow.cpp.

311 {
312  if (quest == nullptr)
313  return;
314 
315  const STD_VECTOR<QuestItemText> &texts = quest->texts;
316  const QuestVar &var = (*mVars)[quest->var];
317  const std::string var1 = toString(var.var1);
318  const std::string var2 = toString(var.var2);
319  const std::string var3 = toString(var.var3);
320  const std::string timeStr = timeDiffToString(var.time1);
321  mText->clearRows();
322  FOR_EACH (STD_VECTOR<QuestItemText>::const_iterator, it, texts)
323  {
324  const QuestItemText &data = *it;
325  std::string text = data.text;
326  replaceAll(text, "{@@var1}", var1);
327  replaceAll(text, "{@@var2}", var2);
328  replaceAll(text, "{@@var3}", var3);
329  replaceAll(text, "{@@time}", timeStr);
330  switch (data.type)
331  {
332  case QuestType::TEXT:
333  default:
334  mText->addRow(text,
335  false);
336  break;
337  case QuestType::NAME:
338  mText->addRow(std::string("[").append(text).append("]"),
339  false);
340  break;
341  case QuestType::REWARD:
342  mText->addRow(std::string(
343  // TRANSLATORS: quest reward
344  _("Reward:")).append(
345  " ").append(
346  text),
347  false);
348  break;
349  case QuestType::GIVER:
350  mText->addRow(std::string(
351  // TRANSLATORS: quest giver name
352  _("Quest Giver:")).append(
353  " ").append(
354  text),
355  false);
356  break;
357  case QuestType::NPC:
358  mText->addRow(std::string(
359  // TRANSLATORS: quest npc name
360  _("Npc:")).append(
361  " ").append(
362  text),
363  false);
364  break;
366  mText->addRow(std::string(
367  strprintf("%s [@@=navigate %s %s|%s@@]",
368  // TRANSLATORS: quest coordinates
369  _("Coordinates:"),
370  data.data1.c_str(),
371  data.data2.c_str(),
372  text.c_str())),
373  false);
374  break;
375  }
376  }
377  mText->updateHeight();
378 }
void updateHeight()
Definition: browserbox.cpp:851
void addRow(const std::string &row, const bool atTop)
Definition: browserbox.cpp:171
void clearRows()
Definition: browserbox.cpp:359
uint32_t data
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
@ COORDINATES
Definition: questtype.h:33
std::string & replaceAll(std::string &context, const std::string &from, const std::string &to)
std::string strprintf(const char *const format,...)
std::string timeDiffToString(int timeDiff)
std::vector< QuestItemText > texts
Definition: questitem.h:54
int var2
Definition: questvar.h:53
int var3
Definition: questvar.h:54
int time1
Definition: questvar.h:55

References _, BrowserBox::addRow(), BrowserBox::clearRows(), QuestType::COORDINATES, data, FOR_EACH, QuestType::GIVER, mText, QuestType::NAME, QuestType::NPC, replaceAll(), QuestType::REWARD, strprintf(), QuestType::TEXT, QuestItem::texts, QuestVar::time1, timeDiffToString(), Catch::toString(), BrowserBox::updateHeight(), QuestItem::var, QuestVar::var1, QuestVar::var2, and QuestVar::var3.

Referenced by action(), rebuild(), and selectQuest().

◆ updateEffects()

void QuestsWindow::updateEffects ( )

Definition at line 401 of file questswindow.cpp.

402 {
404  mNpcEffects.clear();
405 
406  FOR_EACH (STD_VECTOR<const QuestEffect*>::const_iterator,
407  it, mMapEffects)
408  {
409  const QuestEffect *const effect = *it;
410  if (effect != nullptr)
411  {
412  const NpcQuestVarMapCIter varIt = mVars->find(effect->var);
413  if (varIt != mVars->end())
414  {
415  const std::set<int> &vals = effect->values;
416  if (vals.find((*mVars)[effect->var].var1) != vals.end())
417  mNpcEffects[effect->id] = effect;
418  }
419  }
420  }
421  if (actorManager == nullptr)
422  return;
423 
424  std::set<BeingTypeId> removeEffects;
425  std::map<BeingTypeId, int> addEffects;
426 
427  // for old effects
428  FOR_EACH (NpcQuestEffectMapCIter, it, oldNpc)
429  {
430  const BeingTypeId id = (*it).first;
431  const QuestEffect *const effect = (*it).second;
432 
433  const NpcQuestEffectMapCIter itNew = mNpcEffects.find(id);
434  if (itNew == mNpcEffects.end())
435  { // in new list no effect for this npc
436  removeEffects.insert(id);
437  }
438  else
439  { // in new list exists effect for this npc
440  const QuestEffect *const newEffect = (*itNew).second;
441  if (effect != newEffect)
442  { // new effects is not equal to old effect
443  addEffects[id] = newEffect->effectId;
444  removeEffects.insert(id);
445  }
446  }
447  }
448 
449  // for new effects
451  {
452  const BeingTypeId id = (*it).first;
453  const QuestEffect *const effect = (*it).second;
454 
455  const NpcQuestEffectMapCIter itNew = oldNpc.find(id);
456  // check if old effect was not present
457  if (itNew == oldNpc.end())
458  addEffects[id] = effect->effectId;
459  }
460  if (!removeEffects.empty() || !addEffects.empty())
461  actorManager->updateEffects(addEffects, removeEffects);
462 }
ActorManager * actorManager
void updateEffects(const std::map< BeingTypeId, int > &addEffects, const std::set< BeingTypeId > &removeEffects) const
std::map< BeingTypeId, const QuestEffect * > NpcQuestEffectMap
Definition: questswindow.h:45
NpcQuestEffectMap::const_iterator NpcQuestEffectMapCIter
Definition: questswindow.h:48
BeingTypeId id
Definition: questeffect.h:47
std::set< int > values
Definition: questeffect.h:49

References actorManager, QuestEffect::effectId, FOR_EACH, QuestEffect::id, mMapEffects, mNpcEffects, mVars, ActorManager::updateEffects(), QuestEffect::values, and QuestEffect::var.

Referenced by rebuild(), and setMap().

◆ updateQuest()

void QuestsWindow::updateQuest ( const int  var,
const int  val1,
const int  val2,
const int  val3,
const int  time1 
)

Field Documentation

◆ mAllEffects

std::vector<QuestEffect*>* QuestsWindow::mAllEffects
private

Definition at line 93 of file questswindow.h.

Referenced by QuestsWindow(), and setMap().

◆ mCloseButton

Button* QuestsWindow::mCloseButton
private

Definition at line 87 of file questswindow.h.

Referenced by QuestsWindow().

◆ mCompleteIcon

Image* QuestsWindow::mCompleteIcon
private

Definition at line 88 of file questswindow.h.

Referenced by rebuild(), and ~QuestsWindow().

◆ mCompleteQuestEffectId

int QuestsWindow::mCompleteQuestEffectId
private

Definition at line 100 of file questswindow.h.

Referenced by rebuild().

◆ mIncompleteIcon

Image* QuestsWindow::mIncompleteIcon
private

Definition at line 89 of file questswindow.h.

Referenced by rebuild(), and ~QuestsWindow().

◆ mItemLinkHandler

ItemLinkHandler* QuestsWindow::mItemLinkHandler
private

Definition at line 84 of file questswindow.h.

Referenced by QuestsWindow(), and ~QuestsWindow().

◆ mMap

const Map* QuestsWindow::mMap
private

Definition at line 101 of file questswindow.h.

Referenced by setMap().

◆ mMapEffects

std::vector<const QuestEffect*> QuestsWindow::mMapEffects
private

Definition at line 90 of file questswindow.h.

Referenced by setMap(), and updateEffects().

◆ mNewQuestEffectId

int QuestsWindow::mNewQuestEffectId
private

Definition at line 99 of file questswindow.h.

Referenced by rebuild().

◆ mNpcEffects

NpcQuestEffectMap QuestsWindow::mNpcEffects
private

Definition at line 96 of file questswindow.h.

Referenced by addEffect(), and updateEffects().

◆ mQuestLinks

std::vector<QuestItem*> QuestsWindow::mQuestLinks
private

Definition at line 97 of file questswindow.h.

Referenced by action(), rebuild(), selectQuest(), and ~QuestsWindow().

◆ mQuestReverseLinks

std::map<int, int> QuestsWindow::mQuestReverseLinks
private

Definition at line 98 of file questswindow.h.

Referenced by rebuild(), selectQuest(), and ~QuestsWindow().

◆ mQuests

std::map<int, std::vector <QuestItem*> >* QuestsWindow::mQuests
private

Definition at line 92 of file questswindow.h.

Referenced by QuestsWindow().

◆ mQuestScrollArea

ScrollArea* QuestsWindow::mQuestScrollArea
private

Definition at line 83 of file questswindow.h.

Referenced by QuestsWindow().

◆ mQuestsListBox

ExtendedListBox* QuestsWindow::mQuestsListBox
private

Definition at line 82 of file questswindow.h.

Referenced by action(), QuestsWindow(), rebuild(), and selectQuest().

◆ mQuestsModel

QuestsModel* QuestsWindow::mQuestsModel
private

Definition at line 81 of file questswindow.h.

Referenced by rebuild(), and ~QuestsWindow().

◆ mText

BrowserBox* QuestsWindow::mText
private

Definition at line 85 of file questswindow.h.

Referenced by QuestsWindow(), and showQuest().

◆ mTextScrollArea

ScrollArea* QuestsWindow::mTextScrollArea
private

Definition at line 86 of file questswindow.h.

Referenced by QuestsWindow().

◆ mVars

NpcQuestVarMap* QuestsWindow::mVars
private

Definition at line 91 of file questswindow.h.

Referenced by QuestsWindow(), rebuild(), and updateEffects().


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