Planeshift

pawsnpcdialog.h

Go to the documentation of this file.
00001 /*
00002  * Author: Christian Svensson
00003  *
00004  * Copyright (C) 2008 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 #ifndef PAWS_NPC_DIALOG
00020 #define PAWS_NPC_DIALOG
00021 
00022 #include "net/subscriber.h"
00023 #include "pscelclient.h"
00024 
00025 #include "paws/pawslistbox.h"
00026 #include "paws/pawswidget.h"
00027 #include "paws/pawsstringpromptwindow.h"
00028 
00029 #define CONFIG_NPCDIALOG_FILE_NAME       "/planeshift/userdata/options/npcdialog.xml"
00030 #define CONFIG_NPCDIALOG_FILE_NAME_DEF   "/planeshift/data/options/npcdialog_def.xml"
00031 
00032 
00033 class pawsListBox;
00034 
00038 class pawsNpcDialogWindow: public pawsWidget, public psClientNetSubscriber, public iOnStringEnteredAction
00039 {
00040 public:
00041     struct QuestInfo
00042     {
00043         csString    title;
00044         csString    text;
00045         csString    trig;
00046     };
00047     pawsNpcDialogWindow();
00048 
00052     bool PostSetup();
00053     
00054     void HandleMessage(MsgEntry* me);
00055 
00056     void OnListAction(pawsListBox* widget, int status);
00057 
00058     void OnStringEntered(const char *name,int param,const char *value);
00059 
00065     bool LoadSetting();
00066 
00070     void ShowIfBubbles();
00071 
00075     void CleanBubbles();
00076 
00080     void ShowOnlyFreeText();
00081 
00087     virtual void Show();
00088     virtual void Hide();
00089     bool OnKeyDown(utf32_char keyCode, utf32_char key, int modifiers);
00090     bool OnMouseDown(int button, int modifiers, int x , int y);
00094     bool OnButtonPressed(int button, int keyModifier, pawsWidget* widget);
00095 
00096     // This window should always stay on the background
00097     virtual void BringToTop(pawsWidget* widget) {};
00098 
00105     void LoadQuest(csString xmlstr);
00106 
00113     void DisplayQuestBubbles(unsigned int index);
00114 
00118     void ShowSpeechBubble();
00119     
00126     void NpcSays();//csString& inText, GEMClientActor *actor);
00127 
00131     virtual void Draw();
00132 
00137     virtual void DrawBackground();
00138 
00145     bool GetUseBubbles()
00146     {
00147         return useBubbles;
00148     }
00154     void SetUseBubbles(bool useBubblesNew)
00155     {
00156         useBubbles = useBubblesNew;
00157     }
00164     float GetNpcMsgTimeoutScale()
00165     {
00166         return npcMsgTimeoutScale;
00167     }
00175     void SetNpcMsgTimeoutScale(float timeoutScale)
00176     {
00177         if (timeoutScale < 0)
00178         {
00179             npcMsgTimeoutScale = 0.0;
00180         } else if (timeoutScale > npcMsgTimeoutScaleMax)
00181         {
00182             npcMsgTimeoutScale = npcMsgTimeoutScaleMax;
00183         } else
00184         {
00185             npcMsgTimeoutScale = timeoutScale;
00186         }
00187     }
00194     float GetNpcMsgTimeoutScaleMax()
00195     {
00196         return npcMsgTimeoutScaleMax;
00197     }
00198 
00202     void SaveSetting();
00203 
00208     void SetupWindowWidgets();
00209 
00210 
00211 private:
00212     void AdjustForPromptWindow();
00216     void DisplayTextInChat(const char *sayWhat);
00217     
00218     // values are loaded from configuration files
00219     bool useBubbles;                    
00220     float npcMsgTimeoutScale;           
00221     float npcMsgTimeoutScaleMax;        
00222 
00223     // variables used to display npc dialogs
00224     csArray<QuestInfo> questInfo;       
00225     unsigned int    displayIndex;       
00226     int             cameraMode;         
00227     int             loadOnce;           
00228     bool clickedOnResponseBubble;       
00229     int questIDFree;                    
00230     bool gotNewMenu;                    
00231     bool displaysNewMenu;               
00232     int triesNewMenu;                   
00233     csTicks timeDelay;                  
00234     csTicks ticks;                      
00235 
00236     pawsListBox* responseList;
00237     pawsWidget* speechBubble;
00238     pawsEditTextBox* textBox;
00239     pawsButton* closeBubble;
00240     pawsButton* giveBubble;
00241     
00242     EID targetEID;                      
00243     
00244     csArray<csString> npcMsgQueue;        
00245 };
00246 
00247 
00248 CREATE_PAWS_FACTORY(pawsNpcDialogWindow);
00249 #endif