Add infos into target window
[ryzomcore.git] / ryzom / client / src / r2 / tool_draw_prim.h
blobc1b0b43f4f264c8e543d0511adf4fb6552dcc30c
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_DRAW_PRIM_H
21 #define R2_TOOL_DRAW_PRIM_H
23 #include "tool.h"
24 #include "prim_render.h"
25 #include "../decal.h"
27 #include "nel/misc/vector.h"
30 class CEntity;
31 namespace NLGUI
33 class CLuaObject;
36 namespace R2
39 /**
40 * Tool to draw / extend a PRIMITIVE (road or zone)
42 class CToolDrawPrim : public CTool
44 public:
45 enum { PrimMaxNumPoints = 16 };
46 enum TPrimType { Road = 0, Region, PrimTypeCount };
47 NLMISC_DECLARE_CLASS(R2::CToolDrawPrim);
48 // ctor
49 CToolDrawPrim(TPrimType primType = Road, CInstance *extending = NULL);
50 virtual bool init(const CLuaObject &parameters);
51 virtual const char *getToolUIName() const;
52 virtual bool isCreationTool() const { return true; }
53 virtual void cancel();
54 virtual void updateAfterRender();
55 virtual void updateBeforeRender();
56 virtual bool onMouseLeftButtonClicked();
57 virtual bool onMouseRightButtonClicked();
58 virtual bool onMouseLeftButtonDown();
59 virtual bool onDeleteCmd();
61 // update the look of an inaccessible primitive
62 static void updateInaccessiblePrimRenderLook(CPrimRender &dest);
64 protected:
65 virtual void onActivate();
66 private:
67 CPrimRender _Prim; // the primitive being drawn
68 CPrimRender _InaccessiblePrim; // inaccessible parts for the primitive being drawn (on an invalid pos on heightmap)
69 CPrimLook _PrimLook;
70 CPrimLook _PrimLookInvalid;
71 CPrimLook _PrimLookCanClose;
72 CPrimLook _PrimLookInaccessible;
73 uint _NumPoints;
74 bool _ValidPos;
75 bool _MustClose;
76 bool _PrimInitialized;
77 bool _ValidPrim;
78 bool _InaccessibleParts;
79 bool _DistinctLastPoint;
80 TPrimType _PrimType;
81 std::vector<NLMISC::CVector> _Points;
82 std::vector<NLMISC::CVector> _InitialPoints; // for extending
83 std::vector<NLMISC::CVector> _LastPoints; // last points for validity test
84 std::string _CookieKey; // cookie to be attached if creation succeed (empty string if no cookie)
85 CLuaObject _CookieValue;
86 CLuaObject _CancelFunc;
87 bool _SelectInstance;
88 CInstance::TRefPtr _ExtendedPrimitive; // road being extended (NULL is this tool is used to create a new primitive)
89 uint _StartNumPoints; // number of points before extend
90 bool _Extending;
91 bool _Commited;
92 bool _ForceShowPrims;
93 CDecal _TestDecal;
94 private:
95 void commit();
96 void setPrimLook(bool closed, bool lastSegmentValid, bool valid);
97 void removeFromWorldMap();
98 void updateValidityFlag(bool ignoreLast);
99 bool canTerminate() const;
100 bool checkRoomLeft();
101 void displayNoMoreRoomLeftMsg();
102 // for closed polygon only : test if the current shape is valid (e.g not intersecting, with at least 3 points)
103 bool isValidPolyShape(bool ignoreLast, std::list<NLMISC::CPolygon> &splitPoly) const;
104 bool testAccessibleEdges(bool ignoreLast);
105 void doUpdateBeforeRender();
111 } // R2
113 #endif