Fix css style order when using external css files
[ryzomcore.git] / ryzom / client / src / r2 / tool_choose_pos.h
blob913dad3c11f693638aa3a84098f9b70c0f4c3b8b
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef R2_TOOL_CHOOSE_POS_H
21 #define R2_TOOL_CHOOSE_POS_H
23 #include "tool.h"
24 #include "../decal.h"
25 #include "prim_render.h"
26 #include "nel/misc/vector.h"
27 #include "nel/misc/polygon.h"
29 class CEntity;
30 class CEntityCL;
31 namespace NLGUI
33 class CLuaObject;
36 namespace R2
39 /**
40 * Tool to choose a position on landscape, with transparent entity drawn under the mouse
41 * A transparent version of the entity to be created is drawn under the mouse
42 * at the chosen position.
43 * Additionnally, a set of zone can be created to choose the pos. These zone must be at a valid
44 * position on the map to allow validation
47 class CToolChoosePos : public CTool
49 public:
51 CToolChoosePos() { nlassert(0); }
53 enum TAction { NoAction, SelectPos, Cancel };
55 CToolChoosePos(sint ghostSlot,
56 const std::string &cursValid = "curs_create.tga",
57 const std::string &cursInvalid = "curs_stop.tga",
58 const std::vector<NLMISC::CPolygon2D> &polyList = std::vector<NLMISC::CPolygon2D>(),
59 const CPrimLook &polyValidLook = CPrimLook(),
60 const CPrimLook &polyInvalidLook = CPrimLook()
63 /** Init for multiple pos selection (for the creation tool)
64 * Multiple position can be chosen by holding 'shift' down
66 void enableMultiPos(const std::string &cursValidMulti = "curs_create_multi.tga");
67 bool isMultiPos() const { return _MultiPos; }
69 // force multi-creation to be used by default (no need for the shift key down)
70 void lockMultiPos() { _MultiPosLocked = true; }
73 // {}
74 ~CToolChoosePos();
75 // from CTool
76 virtual const char *getToolUIName() const { return ""; }
77 virtual bool isCreationTool() const { return true; }
78 virtual void updateAfterRender();
79 virtual void updateBeforeRender();
80 virtual bool onMouseLeftButtonClicked();
81 virtual bool onMouseRightButtonClicked();
82 virtual void cancel();
83 /** Update the cursor on the ui. Depending on the context the cursor
84 * may take different shapes (for example, it wouldn't show a 'stop' cursor when
85 * the palette is under and one has just selected an object to drop)
87 virtual void updateInvalidCursorOnUI();
88 protected:
89 std::string _CursValid;
90 std::string _CursValidMulti;
91 std::string _CursInvalid;
92 bool _Valid;
93 NLMISC::CVector _CreatePosition;
94 private:
95 CDecal _BadPlaceDecal;
96 CDecal _TestDecal;
97 bool _MultiPos;
98 bool _MultiPosLocked;
99 float _CreateAngle;
100 TAction _WantedAction;
101 bool _WarningNoMeshOrSkeletonShown;
102 NLMISC::CVector _DefaultScale;
103 float _LocalSelectBoxSize;
104 std::vector<NLMISC::CPolygon2D> _PolyList;
105 std::vector<CPrimRender> _PolyRender;
106 CPrimLook _PolyValidLook;
107 CPrimLook _PolyInvalidLook;
108 protected:
109 sint _GhostSlot;
110 protected:
111 CEntityCL *getGhost();
112 // for derivers
113 virtual void commit(const NLMISC::CVector &createPosition, float createAngle) = 0;
114 virtual bool stopAfterCommit() const { return true; }
115 /** For derivers : additionnal checking can be done on the pos to choose
116 * Pos must at least be a valid pacs pos
118 virtual bool isValidChoosePos(const NLMISC::CVector2f &pos) const { return isValid2DPos(pos); }
119 void removeGhostSlot();
120 private:
121 void hideMapSelectionAxis();
122 void showPolys(bool visible);
128 } // R2
130 #endif