Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / scenario_entry_points.h
blobb9068b10c71f3612cc73b7f2104b69406c9ae50e
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
8 //
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 //-----------------------------------------------------------------------------
21 // includes
22 //-----------------------------------------------------------------------------
24 #include "nel/misc/sstring.h"
25 #include "nel/misc/vector_2f.h"
27 //-----------------------------------------------------------------------------
28 // R2 namespace
29 //-----------------------------------------------------------------------------
31 namespace R2
33 //-----------------------------------------------------------------------------
34 // class CScenarioEntryPoints
35 //-----------------------------------------------------------------------------
37 class CScenarioEntryPoints
40 friend class CScreenshotIslands;
42 public:
43 //-------------------------------------------------------------------------
44 // public data types
46 struct CEntryPoint
48 NLMISC::CSString Package;
49 NLMISC::CSString Island;
50 NLMISC::CSString Location;
51 sint32 X;
52 sint32 Y;
55 CEntryPoint()
57 X= Y =0;
60 CEntryPoint(NLMISC::CSString package, NLMISC::CSString island, NLMISC::CSString location,
61 sint32 x, sint32 y)
63 Package= package;
64 Island= island;
65 Location= location;
66 X= x;
67 Y= y;
71 typedef std::vector<CEntryPoint> TEntryPoints;
74 struct CShortEntryPoint
76 NLMISC::CSString Location;
77 sint32 X;
78 sint32 Y;
81 typedef std::vector<CShortEntryPoint> TShortEntryPoints;
84 class CCompleteIsland
86 public:
87 NLMISC::CSString Package;
88 NLMISC::CSString Island;
89 NLMISC::CSString Continent;
90 sint32 XMin;
91 sint32 YMin;
92 sint32 XMax;
93 sint32 YMax;
94 TShortEntryPoints EntryPoints;
95 std::list<std::string> Zones;
96 std::vector<uint16> ZoneIDs; // IDs of the zones of this island
97 public:
98 CCompleteIsland()
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;
113 public:
114 //-------------------------------------------------------------------------
115 // public interface
117 // get hold of the singleton instance
118 static CScenarioEntryPoints& getInstance();
120 // release memory
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();
138 private:
139 //-------------------------------------------------------------------------
140 // this is a singleton so prevent instantiation
141 CScenarioEntryPoints();
143 void init();
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
158 void loadFromFile();
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);
176 private:
177 //-------------------------------------------------------------------------
178 // private data
179 bool _IsLoaded;
180 bool _CompleteIslandsLoaded;
181 TEntryPoints _EntryPoints;
182 TCompleteIslands _CompleteIslands;
184 NLMISC::CVector2f _LastTestedCoords;
185 CCompleteIsland *_LastFoundIsland;
187 std::string _CompleteIslandsFilename;
188 std::string _EntryPointsFilename;
191 } // namespace R2
193 //-----------------------------------------------------------------------------
195 #endif