Planeshift
pawsnpcdialog.h
Go to the documentation of this file.
1 /*
2  * Author: Christian Svensson
3  *
4  * Copyright (C) 2008 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 #ifndef PAWS_NPC_DIALOG
20 #define PAWS_NPC_DIALOG
21 
22 #include "net/subscriber.h"
23 #include "pscelclient.h"
24 
25 #include "paws/pawslistbox.h"
26 #include "paws/pawswidget.h"
28 
29 #define CONFIG_NPCDIALOG_FILE_NAME "/planeshift/userdata/options/npcdialog.xml"
30 #define CONFIG_NPCDIALOG_FILE_NAME_DEF "/planeshift/data/options/npcdialog_def.xml"
31 
32 
33 class pawsListBox;
34 
39 {
40 public:
41  struct QuestInfo
42  {
43  csString title;
44  csString text;
45  csString trig;
46  };
48 
52  bool PostSetup();
53 
54  void HandleMessage(MsgEntry* me);
55 
56  void OnListAction(pawsListBox* widget, int status);
57 
58  void OnStringEntered(const char *name,int param,const char *value);
59 
65  bool LoadSetting();
66 
70  void ShowIfBubbles();
71 
75  void CleanBubbles();
76 
80  void ShowOnlyFreeText();
81 
87  virtual void Show();
88  virtual void Hide();
89  bool OnKeyDown(utf32_char keyCode, utf32_char key, int modifiers);
90  bool OnMouseDown(int button, int modifiers, int x , int y);
94  bool OnButtonPressed(int button, int keyModifier, pawsWidget* widget);
95 
96  // This window should always stay on the background
97  virtual void BringToTop(pawsWidget* widget) {};
98 
105  void LoadQuest(csString xmlstr);
106 
113  void DisplayQuestBubbles(unsigned int index);
114 
118  void ShowSpeechBubble();
119 
126  void NpcSays();//csString& inText, GEMClientActor *actor);
127 
131  virtual void Draw();
132 
137  virtual void DrawBackground();
138 
146  {
147  return useBubbles;
148  }
154  void SetUseBubbles(bool useBubblesNew)
155  {
156  useBubbles = useBubblesNew;
157  }
165  {
166  return npcMsgTimeoutScale;
167  }
175  void SetNpcMsgTimeoutScale(float timeoutScale)
176  {
177  if (timeoutScale < 0)
178  {
179  npcMsgTimeoutScale = 0.0;
180  } else if (timeoutScale > npcMsgTimeoutScaleMax)
181  {
182  npcMsgTimeoutScale = npcMsgTimeoutScaleMax;
183  } else
184  {
185  npcMsgTimeoutScale = timeoutScale;
186  }
187  }
195  {
196  return npcMsgTimeoutScaleMax;
197  }
198 
202  void SaveSetting();
203 
208  void SetupWindowWidgets();
209 
210 
211 private:
212  void AdjustForPromptWindow();
216  void DisplayTextInChat(const char *sayWhat);
217 
218  // values are loaded from configuration files
219  bool useBubbles;
220  float npcMsgTimeoutScale;
221  float npcMsgTimeoutScaleMax;
222 
223  // variables used to display npc dialogs
224  csArray<QuestInfo> questInfo;
225  unsigned int displayIndex;
226  int cameraMode;
227  int loadOnce;
228  bool clickedOnResponseBubble;
229  int questIDFree;
230  bool gotNewMenu;
231  bool displaysNewMenu;
232  int triesNewMenu;
233  csTicks timeDelay;
234  csTicks ticks;
235 
236  pawsListBox* responseList;
237  pawsWidget* speechBubble;
238  pawsEditTextBox* textBox;
239  pawsButton* closeBubble;
240  pawsButton* giveBubble;
241 
242  EID targetEID;
243 
244  csArray<csString> npcMsgQueue;
245 };
246 
247 
249 #endif
bool OnKeyDown(utf32_char keyCode, utf32_char key, int modifiers)
Process keydown messages.
void DisplayQuestBubbles(unsigned int index)
Display quests in bubbles.
bool OnMouseDown(int button, int modifiers, int x, int y)
Manage mouse down event to test for and apply window changes.
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
This window shows the popup menu of available responses when talking to an NPC.
Definition: pawsnpcdialog.h:38
void ShowIfBubbles()
Shows the window only if it&#39;s in bubbles mode, else does nothing.
void OnListAction(pawsListBox *widget, int status)
Called whenever an item in a child list box is selected.
virtual void DrawBackground()
Has a real functionality only when using the bubbles npc dialog.
CREATE_PAWS_FACTORY(pawsNpcDialogWindow)
csString name
The name of this widget.
Definition: pawswidget.h:217
void ShowSpeechBubble()
Shows the npc chat window and hides the menu bubbles.
virtual void BringToTop(pawsWidget *widget)
Move this widget up the z order to the top.
Definition: pawsnpcdialog.h:97
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
void SaveSetting()
Saves the setting of the menu used for later use.
void OnStringEntered(const char *name, int param, const char *value)
When the pawsStringPromptWindow is created, a ptr to a class which implements this function is provid...
An edit box widget/.
Definition: pawstextbox.h:409
void SetNpcMsgTimeoutScale(float timeoutScale)
Setter for npc messsage timeout.
bool OnButtonPressed(int button, int keyModifier, pawsWidget *widget)
callback function called when a pawsButton (bubble) is clicked
virtual void Draw()
Handles timing to make bubbles disappear in the bubbles npc dialog mode.
float GetNpcMsgTimeoutScaleMax()
Getter for npc messsage timeout.
A simple list box widget.
Definition: pawslistbox.h:202
float GetNpcMsgTimeoutScale()
Getter for npc messsage timeout.
void LoadQuest(csString xmlstr)
Load quest info from xmlbinding message.
void SetupWindowWidgets()
Sets the widget appropriate for display depending on the type of npc dialog menu used.
bool LoadSetting()
Loads the settings from the config files and sets the window appropriately.
bool GetUseBubbles()
Getter for useBubbles, which states if we use the bubbles based npcdialog interface.
virtual void Hide()
Makes widget invisible and removes focus if widget has current focus.
void HandleMessage(MsgEntry *me)
A simple button widget.
Definition: pawsbutton.h:43
bool PostSetup()
Aquire pointers to widgets and load settings for the npc dialog.
void SetUseBubbles(bool useBubblesNew)
Sets if we have to use the bubbles based npc dialog interface (true) or the classic menu based one (f...
This interface defines the callback used by pawsStringPromptWindow to notify another window of a supp...
void CleanBubbles()
empties all bubbles structures and hides them.
void NpcSays()
Display NPC&#39;s chat text.
virtual void Show()
Shows the window and applies some special handling to fix up the window Behaviour and graphics correc...
void ShowOnlyFreeText()
Hides all bubbles except freetext and bye.