Planeshift
|
00001 /* 00002 * zonehandler.h Keith Fulton <[email protected]> 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 #ifndef ZONEHANDLER_H 00020 #define ZONEHANDLER_H 00021 //============================================================================= 00022 // Crystal Space Includes 00023 //============================================================================= 00024 #include <csutil/ref.h> 00025 00026 //============================================================================= 00027 // Project Includes 00028 //============================================================================= 00029 #include "net/cmdbase.h" 00030 #include "paws/pawstexturemanager.h" 00031 #include "psmovement.h" 00032 00033 //============================================================================= 00034 // Local Includes 00035 //============================================================================= 00036 00037 //----------------------------------------------------------------------------- 00038 // Forward Declarations 00039 //----------------------------------------------------------------------------- 00040 class MsgHandler; 00041 class psCelClient; 00042 class pawsLoadWindow; 00043 class pawsProgressBar; 00044 00055 class ZoneLoadInfo 00056 { 00057 public: 00058 csString inSector; 00059 csString loadImage; 00060 csRef<iStringArray> regions; 00061 00070 ZoneLoadInfo(iDocumentNode* node); 00071 00080 bool operator==(ZoneLoadInfo &other) const 00081 { 00082 return inSector == other.inSector; 00083 } 00084 00093 bool operator<(ZoneLoadInfo &other) const 00094 { 00095 return (strcmp(inSector,other.inSector)<0); 00096 } 00097 }; 00098 00099 00105 class ZoneHandler : public psClientNetSubscriber 00106 { 00107 public: 00116 ZoneHandler(MsgHandler* mh, psCelClient* cc); 00117 00120 virtual ~ZoneHandler(); 00121 00129 void HandleMessage(MsgEntry* me); 00130 00144 void LoadZone(csVector3 pos, float yrot, const char* sector, csVector3 vel, bool force = false); 00145 00151 void OnDrawingFinished(); 00152 00159 void MovePlayerTo(const csVector3 &Pos, float yRot, const csString &newSector, const csVector3 &Vel); 00160 00169 void HandleDelayAndAnim(int32_t loadDelay, csVector2 start, csVector2 dest, csString background, csString widgetName); 00170 00175 inline bool IsLoading() const 00176 { 00177 return loading; 00178 } 00179 00184 inline bool IsValid() const 00185 { 00186 return valid; 00187 } 00188 00189 protected: 00190 csHash<ZoneLoadInfo*, const char*> zonelist; 00191 csRef<MsgHandler> msghandler; 00192 psCelClient* celclient; 00193 00194 bool valid; 00195 csString sectorToLoad; 00196 csVector3 newPos; 00197 csVector3 newVel; 00198 float newyrot; 00199 psMoveState moveState; 00200 bool loading; 00201 csString forcedBackgroundImg; 00202 csTicks forcedLoadingEndTime; 00203 csTicks forcedLoadingStartTime; 00204 csString forcedWidgetName; 00205 size_t loadCount; 00206 00207 pawsLoadWindow* loadWindow; 00208 pawsProgressBar* loadProgressBar; 00209 00219 bool FindLoadWindow(bool force = false, const char* widgetName = "LoadWindow"); 00220 00229 bool LoadZoneInfo(); 00230 00239 ZoneLoadInfo* FindZone(const char* sector) const; 00240 00241 private: 00250 void ForceLoadScreen(csString backgroundImage, uint32_t length, csString widgetName); 00251 00258 bool ForceLoadWindowWidget(bool enable, csString loadWindowName); 00259 }; 00260 00261 #endif