Interface IMyTextSurface
Describes one of block LCDs where you can write text or draw things (PB scripting interface)
Namespace: Sandbox.ModAPI.Ingame
Assembly: Sandbox.Common.dll
Syntax
public interface IMyTextSurface
Properties
Alignment
How should the text be aligned
Declaration
TextAlignment Alignment { get; set; }
Property Value
| Type | Description |
|---|---|
| TextAlignment |
BackgroundAlpha
Value for offscreen texture alpha channel
- for PBR material it is metalness (should be 0)
- for transparent texture it is opacity
Declaration
byte BackgroundAlpha { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
BackgroundColor
Gets or sets background color
Declaration
Color BackgroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color |
ChangeInterval
Gets or sets the change interval for selected textures
Declaration
float ChangeInterval { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
ContentType
Type of content to be displayed on the screen.
Declaration
ContentType ContentType { get; set; }
Property Value
| Type | Description |
|---|---|
| ContentType |
CurrentlyShownImage
Gets image that is currently shown on the screen.
Returns NULL if there are no images selected OR the screen is in text mode.
Declaration
string CurrentlyShownImage { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
DisplayName
Get localized name of this surface.
Declaration
string DisplayName { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Font
Gets or sets the font
Declaration
string Font { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
FontColor
Gets or sets font color
Declaration
Color FontColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color |
FontSize
Gets or sets font size
Declaration
float FontSize { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Name
Gets identifier name of this surface.
Declaration
string Name { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
PreserveAspectRatio
Gets or sets preserve aspect ratio of images.
Declaration
bool PreserveAspectRatio { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Script
Currently running script
Declaration
string Script { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ScriptBackgroundColor
Gets or sets background color used for scripts.
Declaration
Color ScriptBackgroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color |
ScriptForegroundColor
Gets or sets foreground color used for scripts.
Declaration
Color ScriptForegroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color |
SurfaceSize
Gets size of the drawing surface.
Declaration
Vector2 SurfaceSize { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
TextPadding
Gets or sets text padding from all sides of the panel.
Declaration
float TextPadding { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
TextureSize
Gets size of the texture the drawing surface is rendered to.
Declaration
Vector2 TextureSize { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Methods
AddImagesToSelection(List<String>, Boolean)
Adds image to list of shown images. You can get image ids by GetSelectedImages(List<String>)
Declaration
void AddImagesToSelection(List<string> ids, bool checkExistence = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.List<System.String> | ids | Ids of image |
| System.Boolean | checkExistence | If true, image can't be added twice |
AddImageToSelection(String, Boolean)
Adds image to list of shown images. You can get image ids by GetSelectedImages(List<String>)
Declaration
void AddImageToSelection(string id, bool checkExistence = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | Id of image |
| System.Boolean | checkExistence | If true, image can't be added twice |
ClearImagesFromSelection()
Removes images from shown images.
Declaration
void ClearImagesFromSelection()
DrawFrame()
Creates a new draw frame where you can add sprites to be rendered.
Declaration
MySpriteDrawFrame DrawFrame()
Returns
| Type | Description |
|---|---|
| MySpriteDrawFrame |
GetFonts(List<String>)
Gets a list of available fonts
Declaration
void GetFonts(List<string> fonts)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.List<System.String> | fonts |
GetScripts(List<String>)
Gets a list of available scripts
Declaration
void GetScripts(List<string> scripts)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.List<System.String> | scripts |
GetSelectedImages(List<String>)
Outputs the selected image ids to the specified list.
NOTE: List is not cleared internally.
Declaration
void GetSelectedImages(List<string> output)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.List<System.String> | output | Image id's would be written into this array |
GetSprites(List<String>)
Gets a list of available sprites
Declaration
void GetSprites(List<string> sprites)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.List<System.String> | sprites | Buffer array that would be filled with available sprites |
GetText()
Gets current text that is written on surface. Allocates memory (StringBuilder.ToString())! This method doesn't allocate memory ReadText(StringBuilder, Boolean)
Declaration
string GetText()
Returns
| Type | Description |
|---|---|
| System.String | Current text |
MeasureStringInPixels(StringBuilder, String, Single)
Calculates how many pixels a string of a given font and scale will take up.
Declaration
Vector2 MeasureStringInPixels(StringBuilder text, string font, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Text.StringBuilder | text | Text to measure |
| System.String | font | Text font to measure |
| System.Single | scale | Text scale to measure |
Returns
| Type | Description |
|---|---|
| Vector2 | Width and Height of text with specified text, font and scale |
ReadText(StringBuilder, Boolean)
Gets current text that is written on surface.
Declaration
void ReadText(StringBuilder buffer, bool append = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Text.StringBuilder | buffer | Where to write text |
| System.Boolean | append | If true, text would be appended, else buffer would be cleared before text append |
RemoveImageFromSelection(String, Boolean)
Removes image from shown images.
Declaration
void RemoveImageFromSelection(string id, bool removeDuplicates = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | Id of image |
| System.Boolean | removeDuplicates |
RemoveImagesFromSelection(List<String>, Boolean)
Removes images from shown images.
Declaration
void RemoveImagesFromSelection(List<string> ids, bool removeDuplicates = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.List<System.String> | ids | Images ids |
| System.Boolean | removeDuplicates | If true, would remove all images with provided ids |
WriteText(String, Boolean)
Writes text to surface. If somebody opened LCD text in popup dialog, text can no longer be added to the surface. Resulting text must is capped with 100000 symbols
Declaration
bool WriteText(string value, bool append = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | Text to append |
| System.Boolean | append | If true, appends, else replaces text with |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if text was added, or replaced. False if somebody was looking at lcd |
WriteText(StringBuilder, Boolean)
Writes text to surface. If somebody opened LCD text in popup dialog, text can no longer be added to the surface. Resulting text must is capped with 100000 symbols
Declaration
bool WriteText(StringBuilder value, bool append = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Text.StringBuilder | value | Text to append |
| System.Boolean | append | If true, appends, else replaces text with |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if text was added, or replaced. False if somebody was looking at lcd |