1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef R2_SCENARIO_ENTRY_POINTS_H
18 #define R2_SCENARIO_ENTRY_POINTS_H
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 #include "nel/misc/sstring.h"
25 #include "nel/misc/vector_2f.h"
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
34 // class CScenarioEntryPoints
35 //-----------------------------------------------------------------------------
37 class CScenarioEntryPoints
40 friend class CScreenshotIslands
;
43 //-------------------------------------------------------------------------
48 NLMISC::CSString Package
;
49 NLMISC::CSString Island
;
50 NLMISC::CSString Location
;
60 CEntryPoint(NLMISC::CSString package
, NLMISC::CSString island
, NLMISC::CSString location
,
71 typedef std::vector
<CEntryPoint
> TEntryPoints
;
74 struct CShortEntryPoint
76 NLMISC::CSString Location
;
81 typedef std::vector
<CShortEntryPoint
> TShortEntryPoints
;
87 NLMISC::CSString Package
;
88 NLMISC::CSString Island
;
89 NLMISC::CSString Continent
;
94 TShortEntryPoints EntryPoints
;
95 std::list
<std::string
> Zones
;
96 std::vector
<uint16
> ZoneIDs
; // IDs of the zones of this island
100 XMin
=YMin
=XMax
=YMax
=0;
102 bool isIn(const NLMISC::CVector2f
&pos
) const
104 return (sint32
) pos
.x
>= XMin
&&
105 (sint32
) pos
.x
< XMax
&&
106 (sint32
) pos
.y
>= YMin
&&
107 (sint32
) pos
.y
< YMax
;
111 typedef std::vector
<CCompleteIsland
> TCompleteIslands
;
114 //-------------------------------------------------------------------------
117 // get hold of the singleton instance
118 static CScenarioEntryPoints
& getInstance();
121 static void releaseInstance();
123 void loadCompleteIslands();
125 // lookup the integer id for a given island
126 uint32
getIslandId(const NLMISC::CSString
& island
); //TEMP
128 CCompleteIsland
* getIslandFromId(const NLMISC::CSString
& islandId
);
130 CShortEntryPoint
* getEntryPointFromIds(const NLMISC::CSString
& islandId
, const NLMISC::CSString
& entryPointId
);
132 // get entry point from coords in world
133 CCompleteIsland
*getCompleteIslandFromCoords(const NLMISC::CVector2f
&pos
);
135 // get the vector of complete islands
136 const TCompleteIslands
& getCompleteIslands();
139 //-------------------------------------------------------------------------
140 // this is a singleton so prevent instantiation
141 CScenarioEntryPoints();
145 // the unique instance of the singleton
146 static CScenarioEntryPoints
*_Instance
;
148 void saveXMLFile(const TCompleteIslands
& entryPoints
, const std::string
& fileName
);
150 void loadFromXMLFile();
152 // load the scenario entry points from disk file
153 // Note that the file format for this routine is as follows:
154 // - empty lines are ignored
155 // - any text following a // on a line is ignored
156 // - meaningful lines have the following syntax: <package name> <island name> <entry point name> <x> <y> <orientation>
157 // eg: j1 R2UI_Goo_et_bambous R2UI_Main_entry_point 33100 -11200 NW
160 // get the entry points - calls loadFRomFile() if need be
161 const TEntryPoints
& getEntryPoints();
163 // get the vector of island names that correspond to the given package definition string
164 //void getIslands(const NLMISC::CSString& packageDefinition, NLMISC::CVectorSString& islands);
166 // get the vector of valid entry points for a given island that correspond to the given package definition string
167 //void getEntryPoints(const NLMISC::CSString& packageDefinition, const NLMISC::CSString& island, NLMISC::CVectorSString& entryPoints);
169 // lookup the integer id for an entry point for a given island and package definition
170 //uint32 getEntryPointId(const NLMISC::CSString& packageDefinition, const NLMISC::CSString& island, const NLMISC::CSString& entryPoint);
172 // lookup the coordinates of an entry point from its id and package definition
173 // sets x,y to 0,0 if the id is invalid
174 //void getEntryPointCoordsFromId(const NLMISC::CSString& packageDefinition, uint32 id, sint32& x, sint32& y);
177 //-------------------------------------------------------------------------
180 bool _CompleteIslandsLoaded
;
181 TEntryPoints _EntryPoints
;
182 TCompleteIslands _CompleteIslands
;
184 NLMISC::CVector2f _LastTestedCoords
;
185 CCompleteIsland
*_LastFoundIsland
;
187 std::string _CompleteIslandsFilename
;
188 std::string _EntryPointsFilename
;
193 //-----------------------------------------------------------------------------