Planeshift

pawsskillwindow.h

Go to the documentation of this file.
00001 /*
00002  * pawsskillwindow.h
00003  *
00004  * Copyright (C) 2003 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 
00020 #ifndef PAWS_SKILL_WINDOW_HEADER
00021 #define PAWS_SKILL_WINDOW_HEADER
00022 
00023 #include "paws/pawswidget.h"
00024 #include "net/cmdbase.h"
00025 #include "util/skillcache.h"
00026 #include "gui/pawscontrolwindow.h"
00027 #include "paws/pawsnumberpromptwindow.h"
00028 
00029 class pawsTextBox;
00030 class pawsListBox;
00031 class pawsListBoxRow;
00032 class pawsMultiLineTextBox;
00033 class pawsProgressBar;
00034 class pawsObjectView;
00035 
00038 class psSkillDescription
00039 {
00040 public:
00041     psSkillDescription()
00042     {
00043         category = 0;
00044         description.Clear();
00045     }
00046 
00047     psSkillDescription(int cat, const char *str)
00048     {
00049         category = cat;
00050         description = str;
00051     }
00052 
00053     void Update(int cat, const char *str)
00054     {
00055         category = cat;
00056         description = str;
00057     }
00058 
00059     int GetCategory() const
00060     {
00061         return category;
00062     }
00063 
00064     const char *GetDescription() const
00065     {
00066         return (const char *)description;
00067     }
00068 
00069 private:
00070     int category;
00071     csString description;
00072 };
00073 
00074 //-----------------------------------------------------------------------------
00075 
00078 class pawsSkillWindow : public pawsControlledWindow, public psClientNetSubscriber, public iOnNumberEnteredAction
00079 {
00080 public:
00081     pawsSkillWindow();
00083     pawsSkillWindow(const pawsSkillWindow& origin);
00084     virtual ~pawsSkillWindow();
00085 
00086     bool PostSetup();
00087     virtual void HandleMessage(MsgEntry *msg);
00088     bool OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget );
00089     void OnListAction( pawsListBox* listbox, int status );
00090 
00091     virtual void Draw();
00092     virtual void Show();
00093     virtual void Hide();
00094     virtual void Close();
00095 
00096     virtual void OnNumberEntered(const char *name,int param,int number);
00097 
00101     bool LoadUserSharedPrefs();
00102 
00103     void SetHPWarnLevel( float val );
00104     float GetHPWarnLevel();
00105 
00106     void SetHPDangerLevel( float val );
00107     float GetHPDangerLevel();
00108 
00109     void SetHPFlashLevel( float val );
00110     float GetHPFlashLevel();
00111 
00112     void SetManaWarnLevel( float val );
00113     float GetManaWarnLevel();
00114 
00115     void SetManaDangerLevel( float val );
00116     float GetManaDangerLevel();
00117 
00118     void SetManaFlashLevel( float val );
00119     float GetManaFlashLevel();
00120 
00121     void SetHPOn( bool val );
00122     void SetManaOn( bool val );
00123 protected:
00124 
00125     enum {
00126         CAT_STATS,
00127         CAT_COMBAT,
00128         CAT_MAGIC,
00129         CAT_JOBS,
00130         CAT_VARIOUS,
00131         CAT_FACTION
00132     };
00133 
00134     struct pawsSkill {
00135         pawsListBox *list;
00136         pawsMultiLineTextBox* description;
00137         const char* indWidget;
00138         const char* tabName;
00139         csArray<pawsListBoxRow*> unsortedSkills;
00140     };
00141 
00142     bool SetupDoll();
00143 
00144     void BuySkill();
00145     void BuyMaxSkill();
00146 
00147     void HandleSkillList(int selectedNameId, bool flush);
00148     void HandleSkillDescription( csString& description );
00149 
00156     void FlashTabButton(const char* buttonName, bool flash);
00157 
00159     void HandleSkillCategory(psSkillCacheItem* skillInfo, unsigned &idx, bool flush);
00160 
00161     pawsSkill skills[5];
00162     pawsListBox *factionList;
00163     pawsMultiLineTextBox *factionsDescription;
00164     pawsProgressBar *hpBar, *manaBar, *pysStaminaBar, *menStaminaBar, *experienceBar;
00165     pawsTextBox *hpFrac, *manaFrac, *pysStaminaFrac, *menStaminaFrac, *experiencePerc;
00166 
00167     bool filter, train;
00168     unsigned int x; 
00169 
00170     csString skillString;
00171     csString selectedSkill;
00172 
00173     int hitpointsMax, manaMax, physStaminaMax, menStaminaMax;
00174 
00175     int currentTab, previousTab; 
00176 
00177     csRef<iDocumentSystem> xml;
00178 
00179     psSkillCache skillCache; 
00180     csHash<psSkillDescription *> skillDescriptions; 
00181 
00182     void HandleFactionMsg(MsgEntry* me);
00183 
00184     struct FactionRating
00185     {
00186         csString        name;
00187         int             rating;
00188         pawsListBoxRow* row;
00189     };
00190 
00191     csPDelArray<FactionRating>   factions;      
00192 
00195     bool factRequest;
00196     psCharAppearance* charApp;
00197 
00198 };
00199 
00200 CREATE_PAWS_FACTORY( pawsSkillWindow );
00201 
00202 //-----------------------------------------------------------------------------
00203 
00206 class pawsSkillIndicator : public pawsWidget
00207 {
00208 public:
00209     pawsSkillIndicator();
00210 
00211     void Draw();
00212     void Set(unsigned int x, int rank, int y, int yCost, int z, int zCost);
00213 protected:
00215     unsigned int GetRelCoord(unsigned int pt);
00216 
00217     void DrawSkillProgressBar(int x, int y, int width, int height,
00218                               int start_r, int start_g, int start_b);
00219 
00220     unsigned int x; 
00221     int rank, y, yCost, z, zCost; 
00222 
00223     iGraphics2D * g2d;
00224 };
00225 
00226 CREATE_PAWS_FACTORY( pawsSkillIndicator );
00227 
00228 #endif