Planeshift
zonehandler.h
Go to the documentation of this file.
1 /*
2  * zonehandler.h Keith Fulton <keith@paqrat.com>
3  *
4  * Copyright (C) 2003 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 ZONEHANDLER_H
20 #define ZONEHANDLER_H
21 //=============================================================================
22 // Crystal Space Includes
23 //=============================================================================
24 #include <csutil/ref.h>
25 
26 //=============================================================================
27 // Project Includes
28 //=============================================================================
29 #include "net/cmdbase.h"
31 #include "psmovement.h"
32 
33 //=============================================================================
34 // Local Includes
35 //=============================================================================
36 
37 //-----------------------------------------------------------------------------
38 // Forward Declarations
39 //-----------------------------------------------------------------------------
40 class MsgHandler;
41 class psCelClient;
42 class pawsLoadWindow;
43 class pawsProgressBar;
44 
56 {
57 public:
58  csString inSector;
59  csString loadImage;
60  csRef<iStringArray> regions;
61 
70  ZoneLoadInfo(iDocumentNode* node);
71 
80  bool operator==(ZoneLoadInfo &other) const
81  {
82  return inSector == other.inSector;
83  }
84 
93  bool operator<(ZoneLoadInfo &other) const
94  {
95  return (strcmp(inSector,other.inSector)<0);
96  }
97 };
98 
99 
106 {
107 public:
117 
120  virtual ~ZoneHandler();
121 
129  void HandleMessage(MsgEntry* me);
130 
144  void LoadZone(csVector3 pos, float yrot, const char* sector, csVector3 vel, bool force = false);
145 
151  void OnDrawingFinished();
152 
159  void MovePlayerTo(const csVector3 &Pos, float yRot, const csString &newSector, const csVector3 &Vel);
160 
169  void HandleDelayAndAnim(int32_t loadDelay, csVector2 start, csVector2 dest, csString background, csString widgetName);
170 
175  inline bool IsLoading() const
176  {
177  return loading;
178  }
179 
184  inline bool IsValid() const
185  {
186  return valid;
187  }
188 
189 protected:
190  csHash<ZoneLoadInfo*, const char*> zonelist;
191  csRef<MsgHandler> msghandler;
193 
194  bool valid;
195  csString sectorToLoad;
196  csVector3 newPos;
197  csVector3 newVel;
198  float newyrot;
200  bool loading;
205  size_t loadCount;
206 
209 
219  bool FindLoadWindow(bool force = false, const char* widgetName = "LoadWindow");
220 
229  bool LoadZoneInfo();
230 
239  ZoneLoadInfo* FindZone(const char* sector) const;
240 
241 private:
250  void ForceLoadScreen(csString backgroundImage, uint32_t length, csString widgetName);
251 
258  bool ForceLoadWindowWidget(bool enable, csString loadWindowName);
259 };
260 
261 #endif
Ensures all regions that need to be loaded are.
Definition: zonehandler.h:105
pawsProgressBar * loadProgressBar
Used for showing users load progress.
Definition: zonehandler.h:208
csRef< MsgHandler > msghandler
Message Handler to subscribe to.
Definition: zonehandler.h:191
csVector3 newPos
The target location the player will move to after loading.
Definition: zonehandler.h:196
csRef< iStringArray > regions
Regions to load on sector load.
Definition: zonehandler.h:60
csVector3 newVel
The velocity the player will have after loading.
Definition: zonehandler.h:197
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
bool operator<(ZoneLoadInfo &other) const
Basic comparison for less than.
Definition: zonehandler.h:93
Used to save movement state to detect changes.
Definition: psmovement.h:70
csHash< ZoneLoadInfo *, const char * > zonelist
Mapping of names of zones to their load info.
Definition: zonehandler.h:190
csString loadImage
Optional loading screen image.
Definition: zonehandler.h:59
psCelClient * celclient
Pointer to cel client instance.
Definition: zonehandler.h:192
This is the window that is displayed when the game is loading the maps.
Definition: pawsloading.h:45
bool operator==(ZoneLoadInfo &other) const
Basic comparison for equality.
Definition: zonehandler.h:80
Client version of the Cel Manager Requests world loading.
Definition: pscelclient.h:108
bool loading
Whether a new zone is currently being loaded.
Definition: zonehandler.h:200
psMoveState moveState
Definition: zonehandler.h:199
csString sectorToLoad
The sector that needs to be loaded.
Definition: zonehandler.h:195
csString forcedBackgroundImg
String which holds the background of the loading screen.
Definition: zonehandler.h:201
float newyrot
The rotation the player will have after loading.
Definition: zonehandler.h:198
csString forcedWidgetName
Holds the widget name used to replace the load window.
Definition: zonehandler.h:204
csTicks forcedLoadingEndTime
Holds how long the loading shall be delayed.
Definition: zonehandler.h:202
This class is the client&#39;s and server&#39;s main interface for either sending network messages out or get...
Definition: msghandler.h:106
pawsLoadWindow * loadWindow
A load window that can be shown to users while loading.
Definition: zonehandler.h:207
Information for loading a specific zone.
Definition: zonehandler.h:55
bool valid
Whether the loading was successful.
Definition: zonehandler.h:194
csTicks forcedLoadingStartTime
Holds how long the loading shall be delayed.
Definition: zonehandler.h:203
ZoneLoadInfo(iDocumentNode *node)
Basic constructor built from a XML node.
bool IsValid() const
Returns whether the zone handler is valid.
Definition: zonehandler.h:184
bool IsLoading() const
Returns if this is loading a zone.
Definition: zonehandler.h:175
csString inSector
Which sector this zone applies to.
Definition: zonehandler.h:58
size_t loadCount
The number of items that are being loaded.
Definition: zonehandler.h:205