Class GuiElement
- Namespace
- Vintagestory.API.Client
- Assembly
- VintagestoryAPI.dll
public abstract class GuiElement : IDisposable
- Inheritance
-
GuiElement
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
GuiElement(ICoreClientAPI, ElementBounds)
Adds a new GUIElement to the GUI.
public GuiElement(ICoreClientAPI capi, ElementBounds bounds)
Parameters
capi
ICoreClientAPIThe Client API
bounds
ElementBoundsThe bounds of the element.
Fields
Bounds
The bounds of the element.
public ElementBounds Bounds
Field Value
TabIndex
The tab index of the element.
public int TabIndex
Field Value
api
The Client API.
protected ICoreClientAPI api
Field Value
dirtTextureName
public static AssetLocation dirtTextureName
Field Value
hasFocus
Whether or not the element has focus.
protected bool hasFocus
Field Value
noisyMetalTextureName
public static AssetLocation noisyMetalTextureName
Field Value
paperTextureName
public static AssetLocation paperTextureName
Field Value
stoneTextureName
public static AssetLocation stoneTextureName
Field Value
waterTextureName
public static AssetLocation waterTextureName
Field Value
woodTextureName
public static AssetLocation woodTextureName
Field Value
Properties
DrawOrder
0 = draw first, 1 = draw last. Only for interactive elements.
public virtual double DrawOrder { get; }
Property Value
Focusable
Whether or not the element can be focused.
public virtual bool Focusable { get; }
Property Value
HasFocus
Whether or not the element has focus or not.
public bool HasFocus { get; }
Property Value
InsideClipBounds
If the element is inside a clip or not.
public virtual ElementBounds InsideClipBounds { get; set; }
Property Value
MouseOverCursor
public virtual string MouseOverCursor { get; protected set; }
Property Value
RenderAsPremultipliedAlpha
public bool RenderAsPremultipliedAlpha { get; set; }
Property Value
Scale
The scale of the element.
public virtual double Scale { get; set; }
Property Value
Methods
BeforeCalcBounds()
public virtual void BeforeCalcBounds()
ComposeElements(Context, ImageSurface)
Composes the elements.
public virtual void ComposeElements(Context ctxStatic, ImageSurface surface)
Parameters
ctxStatic
ContextThe context of the components.
surface
ImageSurfaceThe surface of the GUI.
DialogRoundRectangle(Context, ElementBounds)
Creates a rounded rectangle.
public void DialogRoundRectangle(Context ctx, ElementBounds bounds)
Parameters
ctx
ContextThe GUI context
bounds
ElementBoundsThe bounds of the rectangle.
DiscardPattern(AssetLocation)
Discards a pattern based off the the filename.
public static void DiscardPattern(AssetLocation textureLoc)
Parameters
textureLoc
AssetLocationThe pattern to discard.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public virtual void Dispose()
ElementRoundRectangle(Context, ElementBounds, bool, double)
Creates a rounded rectangle element.
public void ElementRoundRectangle(Context ctx, ElementBounds bounds, bool isBackground = false, double radius = -1)
Parameters
ctx
ContextThe context for the rectangle.
bounds
ElementBoundsThe bounds of the rectangle.
isBackground
boolIs the rectangle part of a background GUI object (Default: false)
radius
doubleThe radius of the corner of the rectangle (default: -1)
EmbossRoundRectangle(Context, double, double, double, double, double, int, float, float, bool, float)
Adds an embossed rounded rectangle to the dialog.
protected void EmbossRoundRectangle(Context ctx, double x, double y, double width, double height, double radius, int depth = 3, float intensity = 0.4, float lightDarkBalance = 1, bool inverse = false, float alphaOffset = 0)
Parameters
ctx
ContextThe context of the rectangle.
x
doubleThe X position of the rectangle
y
doubleThe Y position of the rectangle
width
doubleThe width of the rectangle
height
doubleThe height of the rectangle.
radius
doubleThe radius of the corner of the rectangle.
depth
intThe thickness of the emboss. (Default: 3)
intensity
floatThe intensity of the emboss. (Default: 0.4f)
lightDarkBalance
floatHow skewed is the light/dark balance (Default: 1)
inverse
boolWhether or not it goes in or out. (Default: false)
alphaOffset
floatThe offset for the alpha part of the emboss. (Default: 0)
EmbossRoundRectangleDialog(Context, double, double, double, double, bool)
Adds an embossed rounded rectangle to the dialog.
public void EmbossRoundRectangleDialog(Context ctx, double x, double y, double width, double height, bool inverse = false)
Parameters
ctx
ContextThe context of the rectangle.
x
doubleThe X position of the rectangle
y
doubleThe Y position of the rectangle
width
doubleThe width of the rectangle
height
doubleThe height of the rectangle.
inverse
boolWhether or not it goes in or out.
EmbossRoundRectangleElement(Context, double, double, double, double, bool, int, int)
Adds an embossed rounded rectangle to the dialog.
public void EmbossRoundRectangleElement(Context ctx, double x, double y, double width, double height, bool inverse = false, int depth = 2, int radius = -1)
Parameters
ctx
ContextThe context of the rectangle.
x
doubleThe X position of the rectangle
y
doubleThe Y position of the rectangle
width
doubleThe width of the rectangle
height
doubleThe height of the rectangle.
inverse
boolWhether or not it goes in or out.
depth
intThe depth of the emboss.
radius
intThe radius of the corner of the rectangle.
EmbossRoundRectangleElement(Context, ElementBounds, bool, int, int)
Adds an embossed rounded rectangle to the dialog.
public void EmbossRoundRectangleElement(Context ctx, ElementBounds bounds, bool inverse = false, int depth = 2, int radius = -1)
Parameters
ctx
ContextThe context of the rectangle.
bounds
ElementBoundsThe position and size of the rectangle.
inverse
boolWhether or not it goes in or out. (Default: false)
depth
intThe depth of the emboss. (Default: 2)
radius
intThe radius of the corner of the rectangle. (default: -1)
IsPositionInside(int, int)
Whether or not the point on screen is inside the Element's area.
public virtual bool IsPositionInside(int posX, int posY)
Parameters
Returns
Lamp(Context, double, double, float[])
protected void Lamp(Context ctx, double x, double y, float[] color)
Parameters
OnFocusGained()
The event fired when the element gains focus.
public virtual void OnFocusGained()
OnFocusLost()
The event fired when the element looses focus.
public virtual void OnFocusLost()
OnKeyDown(ICoreClientAPI, KeyEvent)
The event fired when a key is held down.
public virtual void OnKeyDown(ICoreClientAPI api, KeyEvent args)
Parameters
api
ICoreClientAPIThe client API
args
KeyEventThe key event arguments.
OnKeyPress(ICoreClientAPI, KeyEvent)
The event fired the moment a key is pressed.
public virtual void OnKeyPress(ICoreClientAPI api, KeyEvent args)
Parameters
api
ICoreClientAPIThe Client API.
args
KeyEventThe keyboard state when the key was pressed.
OnKeyUp(ICoreClientAPI, KeyEvent)
The event fired when a key is held down.
public virtual void OnKeyUp(ICoreClientAPI api, KeyEvent args)
Parameters
api
ICoreClientAPIThe client API
args
KeyEventThe key event arguments.
OnMouseDown(ICoreClientAPI, MouseEvent)
The event fired when the mouse is down the element is around. Fires before OnMouseDownOnElement, however OnMouseDownOnElement is called within the base function.
public virtual void OnMouseDown(ICoreClientAPI api, MouseEvent mouse)
Parameters
api
ICoreClientAPIThe Client API
mouse
MouseEventThe mouse event args.
OnMouseDownOnElement(ICoreClientAPI, MouseEvent)
The event fired when the mouse is pressed while on the element. Called after OnMouseDown and tells the engine that the event is handled.
public virtual void OnMouseDownOnElement(ICoreClientAPI api, MouseEvent args)
Parameters
api
ICoreClientAPIThe Client API
args
MouseEventThe mouse event args.
OnMouseEnterSlot(ICoreClientAPI, ItemSlot)
public virtual bool OnMouseEnterSlot(ICoreClientAPI api, ItemSlot slot)
Parameters
api
ICoreClientAPIslot
ItemSlot
Returns
OnMouseLeaveSlot(ICoreClientAPI, ItemSlot)
public virtual bool OnMouseLeaveSlot(ICoreClientAPI api, ItemSlot slot)
Parameters
api
ICoreClientAPIslot
ItemSlot
Returns
OnMouseMove(ICoreClientAPI, MouseEvent)
The event fired when the mouse is moved.
public virtual void OnMouseMove(ICoreClientAPI api, MouseEvent args)
Parameters
api
ICoreClientAPIThe Client API.
args
MouseEventThe mouse event arguments.
OnMouseUp(ICoreClientAPI, MouseEvent)
The event fired when the mouse is released.
public virtual void OnMouseUp(ICoreClientAPI api, MouseEvent args)
Parameters
api
ICoreClientAPIThe Client API.
args
MouseEventThe arguments for the mouse event.
OnMouseUpOnElement(ICoreClientAPI, MouseEvent)
The event fired when the mouse is released on the element. Called after OnMouseUp.
public virtual void OnMouseUpOnElement(ICoreClientAPI api, MouseEvent args)
Parameters
api
ICoreClientAPIThe Client API
args
MouseEventThe mouse event args.
OnMouseWheel(ICoreClientAPI, MouseWheelEventArgs)
The event fired when the mouse wheel is scrolled.
public virtual void OnMouseWheel(ICoreClientAPI api, MouseWheelEventArgs args)
Parameters
api
ICoreClientAPIThe Client API
args
MouseWheelEventArgsThe mouse wheel arguments.
OutlineColor()
The compressed version of the debug outline color as a single int value.
public virtual int OutlineColor()
Returns
PostRenderInteractiveElements(float)
The post render of the interactive element.
public virtual void PostRenderInteractiveElements(float deltaTime)
Parameters
deltaTime
floatThe change in time.
Rectangle(Context, double, double, double, double)
Makes a rectangle with specified parameters.
public static void Rectangle(Context ctx, double x, double y, double width, double height)
Parameters
ctx
ContextContext of the rectangle
x
doubleThe X position of the rectangle
y
doubleThe Y position of the rectangle
width
doubleThe width of the rectangle
height
doubleThe height of the rectangle.
Rectangle(Context, ElementBounds)
Makes a rectangle with the provided context and bounds.
public static void Rectangle(Context ctx, ElementBounds bounds)
Parameters
ctx
ContextThe context for the rectangle.
bounds
ElementBoundsThe bounds of the rectangle.
Render2DTexture(int, double, double, double, double, float, Vec4f)
protected void Render2DTexture(int textureid, double posX, double posY, double width, double height, float z = 50, Vec4f color = null)
Parameters
Render2DTexture(int, float, float, float, float, float, Vec4f)
protected void Render2DTexture(int textureid, float posX, float posY, float width, float height, float z = 50, Vec4f color = null)
Parameters
Render2DTexture(int, ElementBounds, float, Vec4f)
protected void Render2DTexture(int textureid, ElementBounds bounds, float z = 50, Vec4f color = null)
Parameters
textureid
intbounds
ElementBoundsz
floatcolor
Vec4f
RenderBoundsDebug()
public virtual void RenderBoundsDebug()
RenderFocusOverlay(float)
Renders the focus overlay.
public void RenderFocusOverlay(float deltaTime)
Parameters
deltaTime
floatThe change in time.
RenderInteractiveElements(float)
Renders the element as an interactive element.
public virtual void RenderInteractiveElements(float deltaTime)
Parameters
deltaTime
floatThe change in time.
RoundRectangle(Context, double, double, double, double, double)
Creates a rounded rectangle
public static void RoundRectangle(Context ctx, double x, double y, double width, double height, double radius)
Parameters
ctx
ContextThe context for the rectangle.
x
doubleThe X position of the rectangle
y
doubleThe Y position of the rectangle
width
doubleThe width of the rectangle
height
doubleThe height of the rectangle.
radius
doubleThe radius of the corner of the rectangle.
ShadePath(Context, double)
Shades a path with the given context.
public void ShadePath(Context ctx, double thickness = 2)
Parameters
ctx
ContextThe context of the shading.
thickness
doubleThe thickness of the line to shade.
fillWithPattern(ICoreClientAPI, Context, AssetLocation, bool, bool, int, float)
Fills an area with a pattern.
public static SurfacePattern fillWithPattern(ICoreClientAPI capi, Context ctx, AssetLocation textureLoc, bool nearestScalingFiler = false, bool preserve = false, int mulAlpha = 255, float scale = 1)
Parameters
capi
ICoreClientAPIThe Client API
ctx
ContextThe context of the fill.
textureLoc
AssetLocationThe name of the texture file.
nearestScalingFiler
boolpreserve
boolWhether or not to preserve the aspect ratio of the texture.
mulAlpha
intscale
float
Returns
- SurfacePattern
The surface pattern filled with the given texture.
genContext(ImageSurface)
Generates context based off the image surface.
protected Context genContext(ImageSurface surface)
Parameters
surface
ImageSurfaceThe surface where the context is based.
Returns
- Context
The context based off the provided surface.
generateTexture(ImageSurface, ref int, bool)
Generates a texture with an ID.
protected void generateTexture(ImageSurface surface, ref int textureId, bool linearMag = true)
Parameters
surface
ImageSurfaceThe image surface supplied.
textureId
intThe previous texture id.
linearMag
boolWhether or not the texture will have linear magnification.
generateTexture(ImageSurface, ref LoadedTexture, bool)
Generates a new texture.
protected void generateTexture(ImageSurface surface, ref LoadedTexture intoTexture, bool linearMag = true)
Parameters
surface
ImageSurfaceThe surface provided.
intoTexture
LoadedTextureThe texture to be loaded into.
linearMag
boolWhether or not the texture will have linear magnification.
getImageSurfaceFromAsset(SKBitmap)
Gets an image surface based off the bitmap.
[Obsolete("Use getImageSurfaceFromAsset(BitmapExternal bitmap) for easier update to .NET7.0")]
public static ImageSurface getImageSurfaceFromAsset(SKBitmap bitmap)
Parameters
bitmap
SKBitmapThe provided bitmap.
Returns
- ImageSurface
The image surface built from the bitmap.
getImageSurfaceFromAsset(SKBitmap, int, int)
Gets an image surface based off the bitmap.
[Obsolete("Use getImageSurfaceFromAsset(BitmapExternal bitmap, int width, int height) for easier update to .NET7.0")]
public static ImageSurface getImageSurfaceFromAsset(SKBitmap bitmap, int width, int height)
Parameters
bitmap
SKBitmapThe provided bitmap.
width
intThe width requested.
height
intThe height requested.
Returns
- ImageSurface
The image surface built from the bitmap and data.
getImageSurfaceFromAsset(ICoreClientAPI, AssetLocation, int)
Fetches an image surface from a named file.
public static ImageSurface getImageSurfaceFromAsset(ICoreClientAPI capi, AssetLocation textureLoc, int mulAlpha = 255)
Parameters
capi
ICoreClientAPIThe Client API
textureLoc
AssetLocationThe name of the text file.
mulAlpha
int
Returns
- ImageSurface
getImageSurfaceFromAsset(BitmapExternal)
Gets an image surface based off the bitmap.
public static ImageSurface getImageSurfaceFromAsset(BitmapExternal bitmap)
Parameters
bitmap
BitmapExternalThe provided bitmap.
Returns
- ImageSurface
The image surface built from the bitmap.
getImageSurfaceFromAsset(BitmapExternal, int, int)
Gets an image surface based off the bitmap.
public static ImageSurface getImageSurfaceFromAsset(BitmapExternal bitmap, int width, int height)
Parameters
bitmap
BitmapExternalThe provided bitmap.
width
intThe width requested.
height
intThe height requested.
Returns
- ImageSurface
The image surface built from the bitmap and data.
getPattern(SKBitmap)
Gets a surface pattern based off the bitmap.
[Obsolete("Use getPattern(BitmapExternal bitmap) for easier update to .NET7.0")]
public static SurfacePattern getPattern(SKBitmap bitmap)
Parameters
bitmap
SKBitmapThe provided bitmap.
Returns
- SurfacePattern
The resulting surface pattern.
getPattern(ICoreClientAPI, AssetLocation, bool, int, float)
Gets a surface pattern from a named file.
public static SurfacePattern getPattern(ICoreClientAPI capi, AssetLocation textureLoc, bool doCache = true, int mulAlpha = 255, float scale = 1)
Parameters
capi
ICoreClientAPIThe Client API
textureLoc
AssetLocationThe name of the file.
doCache
boolDo we cache the file?
mulAlpha
intscale
float
Returns
- SurfacePattern
The resulting surface pattern.
getPattern(BitmapExternal)
Gets a surface pattern based off the bitmap.
[Obsolete("Use getPattern(BitmapExternal bitmap) for easier update to .NET7.0")]
public static SurfacePattern getPattern(BitmapExternal bitmap)
Parameters
bitmap
BitmapExternalThe provided bitmap.
Returns
- SurfacePattern
The resulting surface pattern.
scaled(double)
Changes the scale of given value by the GUIScale factor.
public static double scaled(double value)
Parameters
value
double
Returns
- double
The scaled value based
scaledi(double)
Changes the scale of given value by the GUIScale factor
public static int scaledi(double value)
Parameters
value
double
Returns
- int
Scaled value type cast to int