Skip to content

WorldUI

Extends: Node2D

Description

WorldUI is a singleton for Dungeondraft to display many of the UI elements for drawing like the cursor, line segments, and object previews.

Accessed by Global.WorldUI.

Properties

Color cursorPrimaryColor
Color cursorSecondaryColor
Color cursorTertiaryColor
Color cursorQuaternaryColor
Color selectionBoxColor
Color selectionHighlightColor
Color selectionSelectColor
StyleBox transformStyleBox
StyleBox transformCornerStyleBox
Vector2 CellSize
Vector2 MousePosition
bool IsMouseMoving
bool IsInsideBounds
Vector2 CursorTilePosition
Vector2 CursorHalfTilePosition
Vector2 SnappedPosition
Vector2 HalfSnappedPosition
bool UseHalfSnap
bool IsSelectionEllipse
Vector2[] Vertices
bool VerticesLoop
ArcVector2[] Polyline
bool IsDrawingPolyline
bool IsMeasuring
Vector2 RulerStart
Vector2 RulerEnd
bool CanPolylineLoop
bool EditArcPoint
int IndicateEditArcPoint
int ArcSegments
UISegment Segment
UITexture Texture
Color CursorColor
float CursorRadius
int CursorMode
bool IsActionInverted
bool IsCursorPositionFirstPoint
bool IsCursorPositionLastPoint
bool ArePolyEndPointsTouching

Methods

void MarkPolyPoint ( )
void UpdateLastArcPoint ( )
void UndoPolyPoint ( )
void AddPolyPoint ( Vector2 position )
void ClearPolyline ( )
Vector2[] GetArcPolyline ( )
void DrawVertex ( Vector2 position, float radius, Color color )
void DrawCursorCircle ( Vector2 position, float radius, int sides, Color color )
void DrawEllipse ( Rect2 bounds, int sides, Color color )
void DrawLineEx ( Vector2[] line, Color color )
Vector2 GetSnappedPosition ( Vector2 position )
void SetSelectionBox ( Rect2 box )
Rect2 GetSelectionBox ( )
void ClearSelectionBox ( )
void SetVertex ( Vector2 vertex )
Vector2 GetVertex ( )
void ClearVertex ( )
void SetGuidePosition ( Vector2 position )
Vector2 GetGuidePosition ( )
void ClearGuidePosition ( )

Property Descriptions

  • Color cursorPrimaryColor:
    Get or set the primary cursor color.

  • Color cursorSecondaryColor:
    Get or set the secondary cursor color.

  • Color cursorTertiaryColor:
    Get or set the tertiary cursor color.

  • Color cursorQuaternaryColor:
    Get or set the quarternary cursor color.

  • Color selectionBoxColor:
    Get or set the selection box normal color.

  • Color selectionHighlightColor:
    Get or set the selection box highlight color.

  • Color selectionSelectColor:
    Get or set the selection box select color.

  • StyleBox transformStyleBox:
    Gets or sets the StyleBox used to draw the transform selection box for the SelectTool.

  • StyleBox transformCornerStyleBox:
    Gets or sets the StyleBox used to draw the transform selection corner circles for the SelectTool.

  • Vector2 CellSize:
    Gets the world unit size of each grid square.

  • Vector2 MousePosition:
    Gets the mouse position in world space.

  • bool IsMouseMoving:
    Get if the mouse is moving.

  • bool IsInsideBounds:
    Get if the mouse is inside the canvas (Has a 512 unit padding because some tools can draw outside of bounds).

  • Vector2 CursorTilePosition:
    Gets the mouse grid snapped grid position. Read only.

  • Vector2 CursorHalfTilePosition:
    Gets the mouse half grid snapped grid position. Read only.

  • Vector2 SnappedPosition:
    Gets the mouse snapped position. Will return half snapped position if half snapping is enabled. If snapping is disabled by the user, will return the mouse position as normal. Read only.

  • Vector2 HalfSnappedPosition:
    Gets the mouse half snapped position or just the mouse position if snapping is disabled. Read only.

  • bool UseHalfSnap:
    Get or set if half grid snapping is used. Normally set by the user preferences.

  • bool IsSelectionEllipse:
    Get or set if selection box should be drawn as an ellipse.

  • Vector2[] Vertices:
    Get or set if vertices drawn as a series of points.

  • bool VerticesLoop:
    Get or set if vertices should have a line closing the first and last points.

  • bool IsDrawingPolyline:
    Get or set if polyline should be drawn on screen.

  • bool IsMeasuring:
    Get or set if the ruler is enabled.

  • Vector2 RulerStart:
    Get or set the start position of the ruler.

  • Vector2 RulerEnd:
    Get or set the end position of the ruler.

  • bool CanPolylineLoop:
    Get or set if the polyline is allowed to loop.

  • bool EditArcPoint:
    Get or set if the user is editing the arc point instead of adding a new point.

  • int IndicateEditArcPoint:
    Gets if the UI is showing to the user that Arc Points are being shown. Set automatically, not advised to set manually.

  • int ArcSegments:
    Gets the number of segments generated in the last arc. Set automatically, not advised to set manually.

  • UISegment Segment:
    Get or set the segment used to show edits of walls, paths, etc.

  • UITexture Texture:
    Get or set the instance used to preview Portals.

  • Color CursorColor:
    Gets the color of the cusor. Read only.

  • float CursorRadius:
    Gets or sets the radius of the cursor.

  • int CursorMode:
    Get or set the cursor mode. 0 = Off, 1 = Point, 2 = Tile, 3 = Vertex, 4 = Segment, 5 = Circle, 6 = Texture

  • bool IsActionInverted:
    Gets or set if cursor or line should be drawn with the inverted color. Used by tools to inform the player they are erasing instead of adding an asset.

  • bool IsCursorPositionFirstPoint:
    Gets if the cursor is snapped to the same position as the first point of the polyline (closing the loop). Read only.

  • bool IsCursorPositionLastPoint:
    Gets if the cursor is snapped to the same position as the last point of the polyline (mouse has not moved). Read only.

  • bool ArePolyEndPointsTouching:
    Gets if the last point of the polyine is very close or exactly the same as the first point. Read only.

Method Descriptions

  • void MarkPolyPoint ( ):
    Adds the mouse snapped position as a new point to the polyline.

  • void UpdateLastArcPoint ( ):
    Adds the mouse snapped position as an arc point to the polyline. Arc points are used to curve the last segment added.

  • void UndoPolyPoint ( ):
    Removes the last point of the polyline.



  • Vector2[] GetArcPolyline ( ):
    Return the polyline as an array of Vector2 points, including any creating any curves created by arc points.