C# Класс 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.
Наследование: IDepthProvider
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
MASK_COLORS uint[]
Visible bool

Защищенные свойства (Protected)

Свойство Тип Описание
_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

Свойство Тип Описание

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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.

Описание методов

AddUpdateHook() публичный метод

Adds a callback that will be executed every update loop.
public AddUpdateHook ( UpdateHookDelegate hook ) : void
hook UpdateHookDelegate
Результат void

Async() публичный метод

Little utility to make it easier to do work outside of the UI thread
public Async ( AsyncHandler handler ) : void
handler AsyncHandler
Результат void

CalculateMatrix() защищенный метод

Calculate a matrix which represents this objects position in screen space
protected CalculateMatrix ( ) : void
Результат void

CalculateOpacity() защищенный метод

When the opacity changes this method is used to calculate the blend colour.
protected CalculateOpacity ( ) : void
Результат void

Draw() публичный абстрактный метод

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
Результат void

DrawLocalString() публичный метод

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
Результат void

DrawLocalString() публичный метод

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.
Результат void

DrawLocalString() публичный метод

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.
Результат void

DrawLocalString() публичный метод

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
Результат void

DrawLocalTexture() публичный метод

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
Результат void

DrawLocalTexture() публичный метод

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
Результат void

DrawLocalTexture() публичный метод

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
Результат void

DrawLocalTexture() публичный метод

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
Результат void

DrawTiledTexture() публичный метод

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
Результат void

FlooredLocalPoint() публичный метод

public FlooredLocalPoint ( Vector2 point ) : Vector2
point Vector2
Результат Vector2

GetBounds() публичный метод

Gets the bounding box for the component
public GetBounds ( ) : Rectangle
Результат Microsoft.Xna.Framework.Rectangle

GetMousePosition() публичный метод

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
Результат Vector2

GetTexture() публичный статический метод

public static GetTexture ( ContentID id ) : Microsoft.Xna.Framework.Graphics.Texture2D
id FSO.Common.Content.ContentID
Результат Microsoft.Xna.Framework.Graphics.Texture2D

GetTexture() публичный статический метод

public static GetTexture ( ulong id ) : Microsoft.Xna.Framework.Graphics.Texture2D
id ulong
Результат Microsoft.Xna.Framework.Graphics.Texture2D

GlobalPoint() публичный метод

Converts a point relative to the screen into a point relative to this component
public GlobalPoint ( Vector2 globalPoint ) : Vector2
globalPoint Vector2
Результат Vector2

HitTestArea() публичный метод

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
Результат bool

InvalidateMatrix() публичный метод

Utility to force the component to recalculate its matrix
public InvalidateMatrix ( ) : void
Результат void

InvalidateOpacity() публичный метод

Utility to force the component to recalculate its blend colour
public InvalidateOpacity ( ) : void
Результат void

ListenForMouse() публичный метод

public ListenForMouse ( Rectangle region, UIMouseEvent callback ) : UIMouseEventRef
region Microsoft.Xna.Framework.Rectangle
callback UIMouseEvent
Результат FSO.Common.Rendering.Framework.IO.UIMouseEventRef

LocalPoint() публичный метод

Converts a point relative to this UIElement into a point relative to the screen
public LocalPoint ( Vector2 point ) : Vector2
point Vector2
Результат Vector2

LocalPoint() публичный метод

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
Результат Vector2

LocalRect() публичный метод

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
Результат Microsoft.Xna.Framework.Rectangle

LocalRect() публичный метод

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
Результат Microsoft.Xna.Framework.Rectangle

ManualTextureMask() защищенный метод

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.
Результат void

PreDraw() публичный метод

May be removed - Called before the draw method.
public PreDraw ( FSO.Client.UI.Framework.UISpriteBatch batch ) : void
batch FSO.Client.UI.Framework.UISpriteBatch
Результат void

RemoveMouseListener() публичный метод

public RemoveMouseListener ( UIMouseEventRef item ) : void
item FSO.Common.Rendering.Framework.IO.UIMouseEventRef
Результат void

RemoveUpdateHook() публичный метод

Removes a previously added update hook.
public RemoveUpdateHook ( UpdateHookDelegate hook ) : void
hook UpdateHookDelegate
Результат void

StoreTexture() публичный статический метод

public static StoreTexture ( ulong id, ContentResource assetData ) : Microsoft.Xna.Framework.Graphics.Texture2D
id ulong
assetData FSO.Client.GameContent.ContentResource
Результат Microsoft.Xna.Framework.Graphics.Texture2D

StoreTexture() публичный статический метод

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
Результат Microsoft.Xna.Framework.Graphics.Texture2D

ToString() публичный метод

public ToString ( ) : string
Результат string

Update() публичный метод

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
Результат void

WillDraw() публичный метод

Scans through parents to determine if this element will be drawn.
public WillDraw ( ) : bool
Результат bool

Описание свойств

MASK_COLORS публичное статическое свойство

public static uint[] MASK_COLORS
Результат uint[]

Visible публичное свойство

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
Результат bool

_BlendColor защищенное свойство

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
Результат Color

_HasOpacity защищенное свойство

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
Результат bool

_Mtx защищенное свойство

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
Результат float[]

_MtxDirty защищенное свойство

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
Результат bool

_Opacity защищенное свойство

Transparency value for this UIElement. Can be between 0.0 and 1.0
protected float _Opacity
Результат float

_OpacityDirty защищенное свойство

Indicates if the opacity has changed and we have not recauclated the blend colour
protected bool _OpacityDirty
Результат bool

_Parent защищенное свойство

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
Результат UIContainer

_Scale защищенное свойство

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
Результат Vector2

_ScaleParent защищенное свойство

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
Результат Vector2

_ScaleX защищенное свойство

Scale Factor of the X Axis.
protected float _ScaleX
Результат float

_ScaleY защищенное свойство

Scale Factor of the Y Axis.
protected float _ScaleY
Результат float

_Tooltip защищенное свойство

Tooltip of this UIComponent. This is displayed when the mouse is moved over the control.
protected string _Tooltip
Результат string

_X защищенное свойство

X position of this UIComponent. This coordinate is relative to this UIElement's parent component.
protected float _X
Результат float

_Y защищенное свойство

Y position of this UIComponent. This coordinate is relative to this UIElement's parent component.
protected float _Y
Результат float

m_StringID защищенное свойство

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
Результат string