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
capiICoreClientAPIThe Client API
boundsElementBoundsThe 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
ctxStaticContextThe context of the components.
surfaceImageSurfaceThe surface of the GUI.
DialogRoundRectangle(Context, ElementBounds)
Creates a rounded rectangle.
public void DialogRoundRectangle(Context ctx, ElementBounds bounds)
Parameters
ctxContextThe GUI context
boundsElementBoundsThe bounds of the rectangle.
DiscardPattern(AssetLocation)
Discards a pattern based off the the filename.
public static void DiscardPattern(AssetLocation textureLoc)
Parameters
textureLocAssetLocationThe 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
ctxContextThe context for the rectangle.
boundsElementBoundsThe bounds of the rectangle.
isBackgroundboolIs the rectangle part of a background GUI object (Default: false)
radiusdoubleThe 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
ctxContextThe context of the rectangle.
xdoubleThe X position of the rectangle
ydoubleThe Y position of the rectangle
widthdoubleThe width of the rectangle
heightdoubleThe height of the rectangle.
radiusdoubleThe radius of the corner of the rectangle.
depthintThe thickness of the emboss. (Default: 3)
intensityfloatThe intensity of the emboss. (Default: 0.4f)
lightDarkBalancefloatHow skewed is the light/dark balance (Default: 1)
inverseboolWhether or not it goes in or out. (Default: false)
alphaOffsetfloatThe 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
ctxContextThe context of the rectangle.
xdoubleThe X position of the rectangle
ydoubleThe Y position of the rectangle
widthdoubleThe width of the rectangle
heightdoubleThe height of the rectangle.
inverseboolWhether 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
ctxContextThe context of the rectangle.
xdoubleThe X position of the rectangle
ydoubleThe Y position of the rectangle
widthdoubleThe width of the rectangle
heightdoubleThe height of the rectangle.
inverseboolWhether or not it goes in or out.
depthintThe depth of the emboss.
radiusintThe 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
ctxContextThe context of the rectangle.
boundsElementBoundsThe position and size of the rectangle.
inverseboolWhether or not it goes in or out. (Default: false)
depthintThe depth of the emboss. (Default: 2)
radiusintThe radius of the corner of the rectangle. (default: -1)
GenContext(ImageSurface)
Generates context based off the image surface. (A static version of genContext(), identical behavior)
public static Context GenContext(ImageSurface surface)
Parameters
surfaceImageSurfaceThe surface where the context is based.
Returns
- Context
The context based off the provided surface.
GenerateTexture(ICoreClientAPI, ImageSurface, ref int, bool)
Generates a texture with an ID. (A static version of generateTexture())
public static void GenerateTexture(ICoreClientAPI api, ImageSurface surface, ref int textureId, bool linearMag = true)
Parameters
apiICoreClientAPIsurfaceImageSurfaceThe image surface supplied.
textureIdintThe previous texture id.
linearMagboolWhether or not the texture will have linear magnification.
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
apiICoreClientAPIThe client API
argsKeyEventThe key event arguments.
OnKeyPress(ICoreClientAPI, KeyEvent)
The event fired the moment a key is pressed.
public virtual void OnKeyPress(ICoreClientAPI api, KeyEvent args)
Parameters
apiICoreClientAPIThe Client API.
argsKeyEventThe 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
apiICoreClientAPIThe client API
argsKeyEventThe 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
apiICoreClientAPIThe Client API
mouseMouseEventThe 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
apiICoreClientAPIThe Client API
argsMouseEventThe mouse event args.
OnMouseEnterSlot(ICoreClientAPI, ItemSlot)
public virtual bool OnMouseEnterSlot(ICoreClientAPI api, ItemSlot slot)
Parameters
apiICoreClientAPIslotItemSlot
Returns
OnMouseLeaveSlot(ICoreClientAPI, ItemSlot)
public virtual bool OnMouseLeaveSlot(ICoreClientAPI api, ItemSlot slot)
Parameters
apiICoreClientAPIslotItemSlot
Returns
OnMouseMove(ICoreClientAPI, MouseEvent)
The event fired when the mouse is moved.
public virtual void OnMouseMove(ICoreClientAPI api, MouseEvent args)
Parameters
apiICoreClientAPIThe Client API.
argsMouseEventThe mouse event arguments.
OnMouseUp(ICoreClientAPI, MouseEvent)
The event fired when the mouse is released.
public virtual void OnMouseUp(ICoreClientAPI api, MouseEvent args)
Parameters
apiICoreClientAPIThe Client API.
argsMouseEventThe 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
apiICoreClientAPIThe Client API
argsMouseEventThe mouse event args.
OnMouseWheel(ICoreClientAPI, MouseWheelEventArgs)
The event fired when the mouse wheel is scrolled.
public virtual void OnMouseWheel(ICoreClientAPI api, MouseWheelEventArgs args)
Parameters
apiICoreClientAPIThe Client API
argsMouseWheelEventArgsThe 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
deltaTimefloatThe 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
ctxContextContext of the rectangle
xdoubleThe X position of the rectangle
ydoubleThe Y position of the rectangle
widthdoubleThe width of the rectangle
heightdoubleThe 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
ctxContextThe context for the rectangle.
boundsElementBoundsThe 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
textureidintboundsElementBoundszfloatcolorVec4f
RenderBoundsDebug()
public virtual void RenderBoundsDebug()
RenderFocusOverlay(float)
Renders the focus overlay.
public void RenderFocusOverlay(float deltaTime)
Parameters
deltaTimefloatThe change in time.
RenderInteractiveElements(float)
Renders the element as an interactive element.
public virtual void RenderInteractiveElements(float deltaTime)
Parameters
deltaTimefloatThe 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
ctxContextThe context for the rectangle.
xdoubleThe X position of the rectangle
ydoubleThe Y position of the rectangle
widthdoubleThe width of the rectangle
heightdoubleThe height of the rectangle.
radiusdoubleThe 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
ctxContextThe context of the shading.
thicknessdoubleThe 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
capiICoreClientAPIThe Client API
ctxContextThe context of the fill.
textureLocAssetLocationThe name of the texture file.
nearestScalingFilerboolpreserveboolWhether or not to preserve the aspect ratio of the texture.
mulAlphaintscalefloat
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
surfaceImageSurfaceThe 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
surfaceImageSurfaceThe image surface supplied.
textureIdintThe previous texture id.
linearMagboolWhether 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
surfaceImageSurfaceThe surface provided.
intoTextureLoadedTextureThe texture to be loaded into.
linearMagboolWhether 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
bitmapSKBitmapThe 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
bitmapSKBitmapThe provided bitmap.
widthintThe width requested.
heightintThe 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
capiICoreClientAPIThe Client API
textureLocAssetLocationThe name of the text file.
mulAlphaint
Returns
- ImageSurface
getImageSurfaceFromAsset(BitmapExternal)
Gets an image surface based off the bitmap.
public static ImageSurface getImageSurfaceFromAsset(BitmapExternal bitmap)
Parameters
bitmapBitmapExternalThe 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
bitmapBitmapExternalThe provided bitmap.
widthintThe width requested.
heightintThe 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
bitmapSKBitmapThe 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
capiICoreClientAPIThe Client API
textureLocAssetLocationThe name of the file.
doCacheboolDo we cache the file?
mulAlphaintscalefloat
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
bitmapBitmapExternalThe 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
valuedouble
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
valuedouble
Returns
- int
Scaled value type cast to int