C# Class FSO.Client.UI.Framework.UIElement

Base class for all UIElements. This class has all the common stuff that user interface components have. This includes: X,Y, ScaleX, ScaleY, Visible, Parent etc. The UIElement has its own coordinate space. You can imagine that when you draw a texture inside a UIElement you are drawing it at 0,0 within the UIElement. This is then translated by the engine to screen coordinates.
Inheritance: IDepthProvider
Afficher le fichier Open project: RHY3756547/FreeSO Class Usage Examples

Méthodes publiques

Свойство Type Description
MASK_COLORS uint[]
Visible bool

Protected Properties

Свойство Type Description
_BlendColor Color
_HasOpacity bool
_Mtx float[]
_MtxDirty bool
_Opacity float
_OpacityDirty bool
_Parent UIContainer
_Scale Vector2
_ScaleParent Vector2
_ScaleX float
_ScaleY float
_Tooltip string
_X float
_Y float
m_StringID string

Private Properties

Свойство Type Description

Méthodes publiques

Méthode Description
AddUpdateHook ( UpdateHookDelegate hook ) : void

Adds a callback that will be executed every update loop.

Async ( AsyncHandler handler ) : void

Little utility to make it easier to do work outside of the UI thread

Draw ( FSO.Client.UI.Framework.UISpriteBatch batch ) : void

Basic draw method. Your component should implement this and add any drawing behavior it needs.

DrawLocalString ( SpriteBatch batch, string text, Vector2 to, TextStyle style ) : void

This utility will draw a line of text onto the UIElement.

DrawLocalString ( SpriteBatch batch, string text, Vector2 to, TextStyle style, Rectangle bounds, TextAlignment align ) : void

This utility will draw a line of text onto the UIElement.

DrawLocalString ( SpriteBatch batch, string text, Vector2 to, TextStyle style, Rectangle bounds, TextAlignment align, Rectangle margin ) : void

This utility will draw a line of text onto the UIElement.

DrawLocalString ( SpriteBatch batch, string text, Vector2 to, TextStyle style, Rectangle bounds, TextAlignment align, Rectangle margin, UIElementState state ) : void

This utility will draw a line of text onto the UIElement.

DrawLocalTexture ( SpriteBatch batch, Microsoft.Xna.Framework.Graphics.Texture2D texture, Nullable from, Vector2 to, Vector2 scale ) : void

Draws a texture to the UIElement. This method will deal with the matrix calculations

DrawLocalTexture ( SpriteBatch batch, Microsoft.Xna.Framework.Graphics.Texture2D texture, Nullable from, Vector2 to, Vector2 scale, Color blend ) : void

Draws a texture to the UIElement. This method will deal with the matrix calculations

DrawLocalTexture ( SpriteBatch batch, Microsoft.Xna.Framework.Graphics.Texture2D texture, Rectangle from, Vector2 to ) : void

Draws a texture to the UIElement. This method will deal with the matrix calculations

DrawLocalTexture ( SpriteBatch batch, Microsoft.Xna.Framework.Graphics.Texture2D texture, Vector2 to ) : void

Draws a texture to the UIElement. This method will deal with the matrix calculations

DrawTiledTexture ( SpriteBatch batch, Microsoft.Xna.Framework.Graphics.Texture2D texture, Rectangle dest, Color blend ) : void
FlooredLocalPoint ( Vector2 point ) : Vector2
GetBounds ( ) : Rectangle

Gets the bounding box for the component

GetMousePosition ( Microsoft.Xna.Framework.Input.MouseState mouse ) : Vector2

Gets the local mouse coordinates for the given mouse state

GetTexture ( ContentID id ) : Microsoft.Xna.Framework.Graphics.Texture2D
GetTexture ( ulong id ) : Microsoft.Xna.Framework.Graphics.Texture2D
GlobalPoint ( Vector2 globalPoint ) : Vector2

Converts a point relative to the screen into a point relative to this component

HitTestArea ( UpdateState state, Rectangle area, bool cache ) : bool

Returns true if the mouse is over the given area

InvalidateMatrix ( ) : void

Utility to force the component to recalculate its matrix

InvalidateOpacity ( ) : void

Utility to force the component to recalculate its blend colour

ListenForMouse ( Rectangle region, UIMouseEvent callback ) : UIMouseEventRef
LocalPoint ( Vector2 point ) : Vector2

Converts a point relative to this UIElement into a point relative to the screen

LocalPoint ( float x, float y ) : Vector2

Converts a point relative to this UIElement into a point relative to the screen

LocalRect ( float x, float y, float w, float h ) : Rectangle

Converts a rectangle relative to this UIElement into a rectangle relative to the screen.

LocalRect ( float x, float y, float w, float h, float mtx ) : Rectangle

Converts a rectangle relative to this UIElement into a rectangle relative to the screen.

PreDraw ( FSO.Client.UI.Framework.UISpriteBatch batch ) : void

May be removed - Called before the draw method.

RemoveMouseListener ( UIMouseEventRef item ) : void
RemoveUpdateHook ( UpdateHookDelegate hook ) : void

Removes a previously added update hook.

StoreTexture ( ulong id, ContentResource assetData ) : Microsoft.Xna.Framework.Graphics.Texture2D
StoreTexture ( ulong id, ContentResource assetData, bool mask, bool cacheOnDisk ) : Microsoft.Xna.Framework.Graphics.Texture2D
ToString ( ) : string
Update ( UpdateState state ) : void

Standard UIElement update method. All sub-classes should call this super method. The argument is an UpdateState object, this object contains everything you may need during update including GameTime, MouseState, KeyboardState etc. This is useful because it means we dont ask for Mouse & Keyboard state in every UIElement which would be wasteful

WillDraw ( ) : bool

Scans through parents to determine if this element will be drawn.

Méthodes protégées

Méthode Description
CalculateMatrix ( ) : void

Calculate a matrix which represents this objects position in screen space

CalculateOpacity ( ) : void

When the opacity changes this method is used to calculate the blend colour.

ManualTextureMask ( Microsoft.Xna.Framework.Graphics.Texture2D &Texture, Color ColorFrom ) : void

Manually replaces a specified color in a texture with transparent black, thereby masking it.

Method Details

AddUpdateHook() public méthode

Adds a callback that will be executed every update loop.
public AddUpdateHook ( UpdateHookDelegate hook ) : void
hook UpdateHookDelegate
Résultat void

Async() public méthode

Little utility to make it easier to do work outside of the UI thread
public Async ( AsyncHandler handler ) : void
handler AsyncHandler
Résultat void

CalculateMatrix() protected méthode

Calculate a matrix which represents this objects position in screen space
protected CalculateMatrix ( ) : void
Résultat void

CalculateOpacity() protected méthode

When the opacity changes this method is used to calculate the blend colour.
protected CalculateOpacity ( ) : void
Résultat void

Draw() public abstract méthode

Basic draw method. Your component should implement this and add any drawing behavior it needs.
public abstract Draw ( FSO.Client.UI.Framework.UISpriteBatch batch ) : void
batch FSO.Client.UI.Framework.UISpriteBatch
Résultat void

DrawLocalString() public méthode

This utility will draw a line of text onto the UIElement.
public DrawLocalString ( SpriteBatch batch, string text, Vector2 to, TextStyle style ) : void
batch Microsoft.Xna.Framework.Graphics.SpriteBatch The SpriteBatch to draw the text onto
text string The content of the text
to Vector2 The position of the text. Relative to this UIElement.
style TextStyle The text style
Résultat void

DrawLocalString() public méthode

This utility will draw a line of text onto the UIElement.
public DrawLocalString ( SpriteBatch batch, string text, Vector2 to, TextStyle style, Rectangle bounds, TextAlignment align ) : void
batch Microsoft.Xna.Framework.Graphics.SpriteBatch The SpriteBatch to draw the text onto
text string The content of the text
to Vector2 The position of the text. Relative to this UIElement.
style TextStyle The text style
bounds Microsoft.Xna.Framework.Rectangle Rectangle relative to this UIElement which the text should be positioned within
align TextAlignment Alignment of the text within the bounds box.
Résultat void

DrawLocalString() public méthode

This utility will draw a line of text onto the UIElement.
public DrawLocalString ( SpriteBatch batch, string text, Vector2 to, TextStyle style, Rectangle bounds, TextAlignment align, Rectangle margin ) : void
batch Microsoft.Xna.Framework.Graphics.SpriteBatch The SpriteBatch to draw the text onto
text string The content of the text
to Vector2 The position of the text. Relative to this UIElement.
style TextStyle The text style
bounds Microsoft.Xna.Framework.Rectangle Rectangle relative to this UIElement which the text should be positioned within
align TextAlignment Alignment of the text within the bounds box.
margin Microsoft.Xna.Framework.Rectangle Margin offset from the bounding box.
Résultat void

DrawLocalString() public méthode

This utility will draw a line of text onto the UIElement.
public DrawLocalString ( SpriteBatch batch, string text, Vector2 to, TextStyle style, Rectangle bounds, TextAlignment align, Rectangle margin, UIElementState state ) : void
batch Microsoft.Xna.Framework.Graphics.SpriteBatch The SpriteBatch to draw the text onto
text string The content of the text
to Vector2 The position of the text. Relative to this UIElement.
style TextStyle The text style
bounds Microsoft.Xna.Framework.Rectangle Rectangle relative to this UIElement which the text should be positioned within
align TextAlignment Alignment of the text within the bounds box.
margin Microsoft.Xna.Framework.Rectangle Margin offset from the bounding box.
state UIElementState State of the text, e.g. hover, down, normal
Résultat void

DrawLocalTexture() public méthode

Draws a texture to the UIElement. This method will deal with the matrix calculations
public DrawLocalTexture ( SpriteBatch batch, Microsoft.Xna.Framework.Graphics.Texture2D texture, Nullable from, Vector2 to, Vector2 scale ) : void
batch Microsoft.Xna.Framework.Graphics.SpriteBatch
texture Microsoft.Xna.Framework.Graphics.Texture2D
from Nullable
to Vector2
scale Vector2
Résultat void

DrawLocalTexture() public méthode

Draws a texture to the UIElement. This method will deal with the matrix calculations
public DrawLocalTexture ( SpriteBatch batch, Microsoft.Xna.Framework.Graphics.Texture2D texture, Nullable from, Vector2 to, Vector2 scale, Color blend ) : void
batch Microsoft.Xna.Framework.Graphics.SpriteBatch
texture Microsoft.Xna.Framework.Graphics.Texture2D
from Nullable
to Vector2
scale Vector2
blend Color
Résultat void

DrawLocalTexture() public méthode

Draws a texture to the UIElement. This method will deal with the matrix calculations
public DrawLocalTexture ( SpriteBatch batch, Microsoft.Xna.Framework.Graphics.Texture2D texture, Rectangle from, Vector2 to ) : void
batch Microsoft.Xna.Framework.Graphics.SpriteBatch
texture Microsoft.Xna.Framework.Graphics.Texture2D
from Microsoft.Xna.Framework.Rectangle
to Vector2
Résultat void

DrawLocalTexture() public méthode

Draws a texture to the UIElement. This method will deal with the matrix calculations
public DrawLocalTexture ( SpriteBatch batch, Microsoft.Xna.Framework.Graphics.Texture2D texture, Vector2 to ) : void
batch Microsoft.Xna.Framework.Graphics.SpriteBatch
texture Microsoft.Xna.Framework.Graphics.Texture2D
to Vector2
Résultat void

DrawTiledTexture() public méthode

public DrawTiledTexture ( SpriteBatch batch, Microsoft.Xna.Framework.Graphics.Texture2D texture, Rectangle dest, Color blend ) : void
batch Microsoft.Xna.Framework.Graphics.SpriteBatch
texture Microsoft.Xna.Framework.Graphics.Texture2D
dest Microsoft.Xna.Framework.Rectangle
blend Color
Résultat void

FlooredLocalPoint() public méthode

public FlooredLocalPoint ( Vector2 point ) : Vector2
point Vector2
Résultat Vector2

GetBounds() public méthode

Gets the bounding box for the component
public GetBounds ( ) : Rectangle
Résultat Microsoft.Xna.Framework.Rectangle

GetMousePosition() public méthode

Gets the local mouse coordinates for the given mouse state
public GetMousePosition ( Microsoft.Xna.Framework.Input.MouseState mouse ) : Vector2
mouse Microsoft.Xna.Framework.Input.MouseState
Résultat Vector2

GetTexture() public static méthode

public static GetTexture ( ContentID id ) : Microsoft.Xna.Framework.Graphics.Texture2D
id FSO.Common.Content.ContentID
Résultat Microsoft.Xna.Framework.Graphics.Texture2D

GetTexture() public static méthode

public static GetTexture ( ulong id ) : Microsoft.Xna.Framework.Graphics.Texture2D
id ulong
Résultat Microsoft.Xna.Framework.Graphics.Texture2D

GlobalPoint() public méthode

Converts a point relative to the screen into a point relative to this component
public GlobalPoint ( Vector2 globalPoint ) : Vector2
globalPoint Vector2
Résultat Vector2

HitTestArea() public méthode

Returns true if the mouse is over the given area
public HitTestArea ( UpdateState state, Rectangle area, bool cache ) : bool
state FSO.Common.Rendering.Framework.Model.UpdateState
area Microsoft.Xna.Framework.Rectangle
cache bool
Résultat bool

InvalidateMatrix() public méthode

Utility to force the component to recalculate its matrix
public InvalidateMatrix ( ) : void
Résultat void

InvalidateOpacity() public méthode

Utility to force the component to recalculate its blend colour
public InvalidateOpacity ( ) : void
Résultat void

ListenForMouse() public méthode

public ListenForMouse ( Rectangle region, UIMouseEvent callback ) : UIMouseEventRef
region Microsoft.Xna.Framework.Rectangle
callback UIMouseEvent
Résultat FSO.Common.Rendering.Framework.IO.UIMouseEventRef

LocalPoint() public méthode

Converts a point relative to this UIElement into a point relative to the screen
public LocalPoint ( Vector2 point ) : Vector2
point Vector2
Résultat Vector2

LocalPoint() public méthode

Converts a point relative to this UIElement into a point relative to the screen
public LocalPoint ( float x, float y ) : Vector2
x float
y float
Résultat Vector2

LocalRect() public méthode

Converts a rectangle relative to this UIElement into a rectangle relative to the screen.
public LocalRect ( float x, float y, float w, float h ) : Rectangle
x float
y float
w float
h float
Résultat Microsoft.Xna.Framework.Rectangle

LocalRect() public méthode

Converts a rectangle relative to this UIElement into a rectangle relative to the screen.
public LocalRect ( float x, float y, float w, float h, float mtx ) : Rectangle
x float
y float
w float
h float
mtx float
Résultat Microsoft.Xna.Framework.Rectangle

ManualTextureMask() protected méthode

Manually replaces a specified color in a texture with transparent black, thereby masking it.
protected ManualTextureMask ( Microsoft.Xna.Framework.Graphics.Texture2D &Texture, Color ColorFrom ) : void
Texture Microsoft.Xna.Framework.Graphics.Texture2D The texture on which to apply the mask.
ColorFrom Color The color to mask away.
Résultat void

PreDraw() public méthode

May be removed - Called before the draw method.
public PreDraw ( FSO.Client.UI.Framework.UISpriteBatch batch ) : void
batch FSO.Client.UI.Framework.UISpriteBatch
Résultat void

RemoveMouseListener() public méthode

public RemoveMouseListener ( UIMouseEventRef item ) : void
item FSO.Common.Rendering.Framework.IO.UIMouseEventRef
Résultat void

RemoveUpdateHook() public méthode

Removes a previously added update hook.
public RemoveUpdateHook ( UpdateHookDelegate hook ) : void
hook UpdateHookDelegate
Résultat void

StoreTexture() public static méthode

public static StoreTexture ( ulong id, ContentResource assetData ) : Microsoft.Xna.Framework.Graphics.Texture2D
id ulong
assetData FSO.Client.GameContent.ContentResource
Résultat Microsoft.Xna.Framework.Graphics.Texture2D

StoreTexture() public static méthode

public static StoreTexture ( ulong id, ContentResource assetData, bool mask, bool cacheOnDisk ) : Microsoft.Xna.Framework.Graphics.Texture2D
id ulong
assetData FSO.Client.GameContent.ContentResource
mask bool
cacheOnDisk bool
Résultat Microsoft.Xna.Framework.Graphics.Texture2D

ToString() public méthode

public ToString ( ) : string
Résultat string

Update() public méthode

Standard UIElement update method. All sub-classes should call this super method. The argument is an UpdateState object, this object contains everything you may need during update including GameTime, MouseState, KeyboardState etc. This is useful because it means we dont ask for Mouse & Keyboard state in every UIElement which would be wasteful
public Update ( UpdateState state ) : void
state FSO.Common.Rendering.Framework.Model.UpdateState
Résultat void

WillDraw() public méthode

Scans through parents to determine if this element will be drawn.
public WillDraw ( ) : bool
Résultat bool

Property Details

MASK_COLORS public_oe static_oe property

public static uint[] MASK_COLORS
Résultat uint[]

Visible public_oe property

Indicates if the component is visible or not. If false the UIElement should not draw. This must be implemented in the super class. UIElement does nothing with this variable.
public bool Visible
Résultat bool

_BlendColor protected_oe property

When the opacity changes this color will be changed into a representation of the opacity that can be used when calling the draw texture methods.
protected Color _BlendColor
Résultat Color

_HasOpacity protected_oe property

Boolean which indicates if the opacity is not 1.0. This is here as a utility because its faster to compare a boolean than to compare a float (_Opacity != 1.0f)
protected bool _HasOpacity
Résultat bool

_Mtx protected_oe property

Matrix object which represents the position & scale of this UIElement. Whenever X, Y, ScaleX, ScaleY, Parent (or any of these values on my parent) change We recalculate this matrix. It is used to convert local coordinates into absolute screen coordinates for drawing.
protected float[] _Mtx
Résultat float[]

_MtxDirty protected_oe property

Indicates if something has changed to make the Matrix invalid, e.g. X,Y has changed or the component is now inside a different parent object. Also called when the parent decides its dirty.
protected bool _MtxDirty
Résultat bool

_Opacity protected_oe property

Transparency value for this UIElement. Can be between 0.0 and 1.0
protected float _Opacity
Résultat float

_OpacityDirty protected_oe property

Indicates if the opacity has changed and we have not recauclated the blend colour
protected bool _OpacityDirty
Résultat bool

_Parent protected_oe property

The container which this element is a child of. Can be null if top level UI object. UIContainer sets this in its Add method. Helps describe the UI Tree.
protected UIContainer,FSO.Client.UI.Framework _Parent
Résultat UIContainer

_Scale protected_oe property

This is the absolute scale of this UIElement, Aka it is all the parent scales multiplied together finally multiplied by this UIElement's scale. Essentially, this is the scale value you would pass into a texture draw method. It is relative to the screen
protected Vector2 _Scale
Résultat Vector2

_ScaleParent protected_oe property

This is the absolute scale of this UIElement, Aka it is all the parent scales multiplied together. This is used for some specific calculations.
protected Vector2 _ScaleParent
Résultat Vector2

_ScaleX protected_oe property

Scale Factor of the X Axis.
protected float _ScaleX
Résultat float

_ScaleY protected_oe property

Scale Factor of the Y Axis.
protected float _ScaleY
Résultat float

_Tooltip protected_oe property

Tooltip of this UIComponent. This is displayed when the mouse is moved over the control.
protected string _Tooltip
Résultat string

_X protected_oe property

X position of this UIComponent. This coordinate is relative to this UIElement's parent component.
protected float _X
Résultat float

_Y protected_oe property

Y position of this UIComponent. This coordinate is relative to this UIElement's parent component.
protected float _Y
Résultat float

m_StringID protected_oe property

ID of the element, this is not used by any functional code. It is only used in the debug UI Inspector to help you identify which component you are looking at.
protected string m_StringID
Résultat string