Planeshift

entitylabels.h

Go to the documentation of this file.
00001 /*
00002  * entitylabels.h - Author: Ondrej Hurt
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 
00021 
00022 #ifndef ENTITYLABEL_HEADER
00023 #define ENTITYLABEL_HEADER
00024 
00025 // CS INCLUDES
00026 #include <cstypes.h>
00027 #include <csutil/ref.h>
00028 #include <imesh/sprite2d.h>
00029 #include <ivideo/fontserv.h>
00030 #include <csutil/leakguard.h>
00031 
00032 // PS INCLUDES
00033 #include "pscelclient.h"
00034 #include "util/genericevent.h"
00035 
00036 struct iPluginManager;
00037 struct iFont;
00038 struct iEventQueue;
00039 struct iEvent;
00040 
00042 enum psEntityLabelVisib 
00043      { 
00044         LABEL_ALWAYS = 0,         
00045         LABEL_ONMOUSE,            
00046         LABEL_ONTARGET,           
00047         LABEL_NEVER               
00048      };
00050 enum psEntityLabelType
00051     {
00052         ENTITY_DEFAULT=0,       
00053         ENTITY_PLAYER,          
00054         ENTITY_NPC,             
00055         ENTITY_DEAD,            
00056         ENTITY_GM1,             
00057         ENTITY_GM25,            
00058         ENTITY_TESTER,          
00059         ENTITY_DEV,             
00060         ENTITY_GROUP,           
00061         ENTITY_GUILD,           
00062         ENTITY_TYPES_AMOUNT     
00063     };
00064 
00069 class psEntityLabels
00070 {
00071 public:
00072     psEntityLabels();
00073     virtual ~psEntityLabels();
00074     
00078     virtual void RemoveObject( GEMClientObject* object );
00079     
00080     // from iEventHandle:
00081     
00085     bool HandleEvent (iEvent &Event);
00086     
00087 
00088     bool Initialize(iObjectRegistry * object_reg, psCelClient * celClient);
00089     
00093     void Configure(psEntityLabelVisib visCreatures, psEntityLabelVisib visItems, bool showGuild, int* colors);
00094     
00098     void GetConfiguration(psEntityLabelVisib & visCreatures, psEntityLabelVisib & visItems, bool & showGuild, int* colors);
00099     
00103     bool LoadFromFile();
00104     
00108     bool SaveToFile();
00109     
00113     void OnObjectArrived( GEMClientObject* object );
00114     
00118     void RepaintAllLabels();
00119     void RepaintObjectLabel(GEMClientObject* object);
00120     
00122     void LoadAllEntityLabels();
00123 
00124 protected:
00125     
00127     void UpdateVisibility();
00128     
00130     void UpdateMouseover();
00131 
00133     void UpdateTarget();
00134     
00138     typedef struct
00139     {
00140         csString text;
00141         int x, y;
00142         int width, height;
00143         int r,g,b; //addes by jacob to complete task
00144     } labelRow;
00145     
00149     void SetObjectText( GEMClientObject* object);
00150 
00154     void CreateLabelOfObject( GEMClientObject* object );
00155 
00161     void ShowLabelOfObject( GEMClientObject* object, bool show );
00162     
00164     void HideAllLabels();
00165     
00167     void RefreshGuildLabels();
00168     
00172     void DeleteLabelOfObject( GEMClientObject* object );
00173      
00174     
00175     bool MatchVisibility(GEMOBJECT_TYPE type, psEntityLabelVisib vis);
00179     psEntityLabelVisib visCreatures;
00180     psEntityLabelVisib visItems;
00181     bool showGuild;                    // should the label contain name of character's guild ?
00182 
00184     int entityColors[ENTITY_TYPES_AMOUNT];
00185 
00189     GEMClientObject * underMouse;
00190 
00194     GEMClientObject * underTarget;
00195 
00199     csRef<iEventQueue> eventQueue;
00200     iVFS* vfs;
00201     psCelClient* celClient;
00202 
00204     DeclareGenericEventHandler(EventHandler,psEntityLabels,"planeshift.entityevent");
00205     csRef<EventHandler> eventhandler;
00206 };
00207 
00208 #endif