guiRoadEditorCtrl.h
Engine/source/environment/editors/guiRoadEditorCtrl.h
Classes:
class
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _GUIROADEDITORCTRL_H_ 25#define _GUIROADEDITORCTRL_H_ 26 27#ifndef _EDITTSCTRL_H_ 28#include "gui/worldEditor/editTSCtrl.h" 29#endif 30#ifndef _UNDO_H_ 31#include "util/undo.h" 32#endif 33#ifndef _DECALROAD_H_ 34#include "environment/decalRoad.h" 35#endif 36 37class GameBase; 38class DecalRoad; 39 40 41class GuiRoadEditorCtrl : public EditTSCtrl 42{ 43 typedef EditTSCtrl Parent; 44 45 public: 46 47 friend class GuiRoadEditorUndoAction; 48 49 String mSelectRoadMode; 50 String mAddRoadMode; 51 String mAddNodeMode; 52 String mInsertPointMode; 53 String mRemovePointMode; 54 String mMovePointMode; 55 String mScalePointMode; 56 57 GuiRoadEditorCtrl(); 58 ~GuiRoadEditorCtrl(); 59 60 DECLARE_CONOBJECT(GuiRoadEditorCtrl); 61 62 // SimObject 63 bool onAdd(); 64 static void initPersistFields(); 65 66 // GuiControl 67 virtual void onSleep(); 68 virtual void onRender(Point2I offset, const RectI &updateRect); 69 70 // EditTSCtrl 71 bool onKeyDown(const GuiEvent& event); 72 void get3DCursor( GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_ ); 73 void on3DMouseDown(const Gui3DMouseEvent & event); 74 void on3DMouseUp(const Gui3DMouseEvent & event); 75 void on3DMouseMove(const Gui3DMouseEvent & event); 76 void on3DMouseDragged(const Gui3DMouseEvent & event); 77 void on3DMouseEnter(const Gui3DMouseEvent & event); 78 void on3DMouseLeave(const Gui3DMouseEvent & event); 79 void on3DRightMouseDown(const Gui3DMouseEvent & event); 80 void on3DRightMouseUp(const Gui3DMouseEvent & event); 81 void updateGuiInfo(); 82 void renderScene(const RectI & updateRect); 83 void renderGui(Point2I offset, const RectI &updateRect); 84 85 bool getTerrainPos( const Gui3DMouseEvent & event, Point3F &tpos ); 86 void deleteSelectedNode(); 87 void deleteSelectedRoad( bool undoAble = true ); 88 89 void setMode( String mode, bool sourceShortcut ); 90 String getMode() { return mMode; } 91 92 void setSelectedRoad( DecalRoad *road ); 93 DecalRoad* getSelectedRoad() { return mSelRoad; }; 94 void setSelectedNode( S32 node ); 95 S32 getSelectedNode() { return mSelNode; }; 96 97 F32 getNodeWidth(); 98 void setNodeWidth( F32 width ); 99 100 Point3F getNodePosition(); 101 void setNodePosition(const Point3F& pos); 102 103 void setTextureFile( StringTableEntry file ); 104 105 public: 106 107 StringTableEntry mMaterialName; 108 protected: 109 110 void _drawRoadSpline( DecalRoad *road, const ColorI &color ); 111 void _drawRoadControlNodes( DecalRoad *road, const ColorI &color ); 112 113 void submitUndo( const UTF8 *name ); 114 115 bool mSavedDrag; 116 bool mIsDirty; 117 118 SimSet *mRoadSet; 119 S32 mSelNode; 120 S32 mHoverNode; 121 U32 mAddNodeIdx; 122 SimObjectPtr<DecalRoad> mSelRoad; 123 SimObjectPtr<DecalRoad> mHoverRoad; 124 125 ColorI mHoverSplineColor; 126 ColorI mSelectedSplineColor; 127 ColorI mHoverNodeColor; 128 129 String mMode; 130 131 F32 mDefaultWidth; 132 S32 mInsertIdx; 133 134 F32 mStartWidth; 135 S32 mStartX; 136 Point3F mStartWorld; 137 138 Point2I mNodeHalfSize; 139 140 // StateBlock for rendering road splines. 141 GFXStateBlockRef mZDisableSB; 142}; 143 144class GuiRoadEditorUndoAction : public UndoAction 145{ 146 public: 147 148 GuiRoadEditorUndoAction( const UTF8* actionName ) : UndoAction( actionName ) 149 { 150 } 151 152 GuiRoadEditorCtrl *mRoadEditor; 153 154 Vector<RoadNode> mNodes; 155 156 SimObjectId mObjId; 157 String mMaterialName; 158 F32 mBreakAngle; 159 U32 mSegmentsPerBatch; 160 F32 mTextureLength; 161 162 virtual void undo(); 163 virtual void redo() { undo(); } 164}; 165 166#endif 167 168 169 170
