AnimatedScreenObject Class
Definition
Section titled “Definition”A ScreenObject that displays an animated set of ICellSurface surfaces.
[DataContract][JsonObject(MemberSerialization = MemberSerialization.OptIn)]public class AnimatedScreenObject : ScreenObject, IScreenSurface, IScreenObject, IPositionable, IComponentHostInheritance object → ScreenObject
Implements IScreenSurface, IScreenObject, SadRogue.Primitives.IPositionable, IComponentHost
Constructors
Section titled “Constructors”AnimatedScreenObject(string, int, int)
Section titled “AnimatedScreenObject(string, int, int)”Creates a new animation with the specified name, width, and height.
public AnimatedScreenObject(string name, int width, int height)Parameters
Section titled “Parameters”name string
The name of the animation.
width int
The width of each frame this animation will have.
height int
The height of each frame this animation will have.
AnimatedScreenObject(string, IEnumerable<ICellSurface>)
Section titled “AnimatedScreenObject(string, IEnumerable<ICellSurface>)”Creates a new animation with the specified name and frames.
public AnimatedScreenObject(string name, IEnumerable<ICellSurface> frames)Parameters
Section titled “Parameters”name string
The name of the animation.
frames IEnumerable<ICellSurface>
The frames that make up the animation.
AnimatedScreenObject(string, int, int, IFont, Point)
Section titled “AnimatedScreenObject(string, int, int, IFont, Point)”Creates a new animation with the specified name, width, and height.
public AnimatedScreenObject(string name, int width, int height, IFont font, Point fontSize)Parameters
Section titled “Parameters”name string
The name of the animation.
width int
The width of each frame this animation will have.
height int
The height of each frame this animation will have.
font IFont
The font used with this animation.
fontSize SadRogue.Primitives.Point
The size of the font.
AnimatedScreenObject(string, IFont, Point, IEnumerable<ICellSurface>)
Section titled “AnimatedScreenObject(string, IFont, Point, IEnumerable<ICellSurface>)”[JsonConstructor]public AnimatedScreenObject(string name, IFont font, Point fontSize, IEnumerable<ICellSurface> frames)Parameters
Section titled “Parameters”name string
font IFont
fontSize SadRogue.Primitives.Point
frames IEnumerable<ICellSurface>
Fields
Section titled “Fields”AddedTime
Section titled “AddedTime”Time counter for the animation
protected TimeSpan AddedTimeCurrentFrameIndexValue
Section titled “CurrentFrameIndexValue”The current frame index being animated.
protected int CurrentFrameIndexValueTimePerFrame
Section titled “TimePerFrame”How much time per animated frame should be used.
protected TimeSpan TimePerFrameIsMouseOver
Section titled “IsMouseOver”Indicates that the mouse is currently over this console.
protected bool IsMouseOverNewFrameWidth
Section titled “NewFrameWidth”The width to assign a frame when CreateFrame() is called.
[DataMember]protected int NewFrameWidthNewFrameHeight
Section titled “NewFrameHeight”The height to assign a frame when CreateFrame() is called.
[DataMember]protected int NewFrameHeightProperties
Section titled “Properties”Center
Section titled “Center”Center of the animation used in positioning.
[DataMember]public Point Center { get; set; }Repeat
Section titled “Repeat”Indicates whether or not this animation will repeat once it has finished animating.
[DataMember]public bool Repeat { get; set; }IsPlaying
Section titled “IsPlaying”When true, Indicates the animation is currently animating. The Update(TimeSpan) method will advance the frames.
[DataMember]public bool IsPlaying { get; protected set; }AnimationDuration
Section titled “AnimationDuration”The length of the animation.
[DataMember]public TimeSpan AnimationDuration { get; set; }CurrentFrameIndex
Section titled “CurrentFrameIndex”Gets or sets the current frame index to animate.
public int CurrentFrameIndex { get; set; }IsEmpty
Section titled “IsEmpty”Indicates the animation is empty.
public bool IsEmpty { get; }Frames
Section titled “Frames”The frames of the animated surface.
[DataMember]public List<ICellSurface> Frames { get; }Gets the name of this animation.
[DataMember]public string Name { get; set; }Gets the current animation state.
public AnimatedScreenObject.AnimationState State { get; set; }MoveToFrontOnMouseClick
Section titled “MoveToFrontOnMouseClick”When true, this object will move to the front of its parent object when the mouse is clicked.
[DataMember]public bool MoveToFrontOnMouseClick { get; set; }FocusOnMouseClick
Section titled “FocusOnMouseClick”When true, this object will set IsFocused to true when the mouse is clicked.
[DataMember]public bool FocusOnMouseClick { get; set; }ForceRendererRefresh
Section titled “ForceRendererRefresh”When true, forces the Renderer to refresh the backing texture with the latest state of the object.
public bool ForceRendererRefresh { get; set; }DefaultRendererName
Section titled “DefaultRendererName”The name of the default renderer for this object.
public virtual string DefaultRendererName { get; }Renderer
Section titled “Renderer”The renderer used to draw this surface.
[DataMember][JsonConverter(typeof(RendererJsonConverter))]public IRenderer? Renderer { get; set; }IsDirty
Section titled “IsDirty”When true, indicates that the animation needs to be redrawn; otherwise false.
public bool IsDirty { get; set; }Font used with rendering.
public IFont Font { get; set; }FontSize
Section titled “FontSize”The size of the Font cells applied to the object when rendering.
public Point FontSize { get; set; }A tint used in rendering.
public Color Tint { get; set; }AbsoluteArea
Section titled “AbsoluteArea”The pixel area on the screen this surface occupies.
public Rectangle AbsoluteArea { get; }UsePixelPositioning
Section titled “UsePixelPositioning”Treats the SadRogue.Primitives.IPositionable.Position of the object as if it is pixels and not cells.
public bool UsePixelPositioning { get; set; }WidthPixels
Section titled “WidthPixels”The width of the surface in pixels.
public int WidthPixels { get; }HeightPixels
Section titled “HeightPixels”The height of the surface in pixels.
public int HeightPixels { get; }The total width of the console.
public int Width { get; }Height
Section titled “Height”The total height of the console.
public int Height { get; }ViewWidth
Section titled “ViewWidth”Gets or sets the visible width of the surface in cells.
public int ViewWidth { get; set; }ViewHeight
Section titled “ViewHeight”Gets or sets the visible height of the surface in cells.
public int ViewHeight { get; set; }ViewPosition
Section titled “ViewPosition”The position of the view within the console.
public Point ViewPosition { get; set; }CurrentFrame
Section titled “CurrentFrame”Gets the current animation frame surface. A shortcut for
Frames[CurrentFrameIndex]
public ICellSurface CurrentFrame { get; }Methods
Section titled “Methods”CreateFrame()
Section titled “CreateFrame()”Creates a new frame with the same dimensions as this entity and adds it to the Frames collection of the entity.
public ICellSurface CreateFrame()Returns
Section titled “Returns”ICellSurface
The created frame.
Stop()
Section titled “Stop()”Stops animating.
public void Stop()Start()
Section titled “Start()”Starts animating the frames.
public void Start()Restart()
Section titled “Restart()”Restarts the animation from the first frame.
public void Restart()MoveNext(bool)
Section titled “MoveNext(bool)”Changes the CurrentFrame to the next frame.
public void MoveNext(bool circular = false)Parameters
Section titled “Parameters”circular bool
If true and the current frame is the last, sets the current frame to the first frame.
MovePrevious(bool)
Section titled “MovePrevious(bool)”Changes the CurrentFrame to the previous frame.
public void MovePrevious(bool circular = false)Parameters
Section titled “Parameters”circular bool
If true and the current frame is the first, sets the current frame to the last frame.
MoveEnd()
Section titled “MoveEnd()”Changes the CurrentFrame to the last frame.
public void MoveEnd()MoveStart()
Section titled “MoveStart()”Changes the CurrentFrame to the first frame.
public void MoveStart()CreateStatic(int, int, int, double, Color?, Color?)
Section titled “CreateStatic(int, int, int, double, Color?, Color?)”Creates an animated surface that looks like static noise.
public static AnimatedScreenObject CreateStatic(int width, int height, int frames, double blankChance, Color? background = null, Color? foreground = null)Parameters
Section titled “Parameters”width int
The width of the surface.
height int
The height of the surface.
frames int
How many frames the animation should have.
blankChance double
Chance a character will be blank. Characters are between index 48-158. Chance is evaluated versus NextDouble().
background System.NullableSadRogue.Primitives.Color
The background color of the animation. Defaults to transparent.
foreground System.NullableSadRogue.Primitives.Color
The foreground color of the animation. Defaults to white.
Returns
Section titled “Returns”AnimatedScreenObject
An animation.
FromImage(string, string, Point, TimeSpan, Point?, Point?, IFont?, Action<ColoredGlyphBase>?, TextureConvertMode, TextureConvertForegroundStyle, TextureConvertBackgroundStyle, Color?)
Section titled “FromImage(string, string, Point, TimeSpan, Point?, Point?, IFont?, Action<ColoredGlyphBase>?, TextureConvertMode, TextureConvertForegroundStyle, TextureConvertBackgroundStyle, Color?)”Converts an image file containing frames to an instance of AnimatedScreenObject.
public static AnimatedScreenObject FromImage(string name, string filePath, Point frameLayout, TimeSpan frameDuration, Point? pixelPadding = null, Point? frameStartAndFinish = null, IFont? font = null, Action<ColoredGlyphBase>? action = null, TextureConvertMode convertMode = TextureConvertMode.Foreground, TextureConvertForegroundStyle convertForegroundStyle = TextureConvertForegroundStyle.Block, TextureConvertBackgroundStyle convertBackgroundStyle = TextureConvertBackgroundStyle.Pixel, Color? frameDefaultBackground = null)Parameters
Section titled “Parameters”name string
Name for the animation.
filePath string
File path to the image file.
frameLayout SadRogue.Primitives.Point
Layout of frames in the image file: X number of columns, Y number of rows.
frameDuration TimeSpan
Duration for a frame in the animation.
pixelPadding System.NullableSadRogue.Primitives.Point
Pixel padding separating frames: X between the columns, Y between the rows.
frameStartAndFinish System.NullableSadRogue.Primitives.Point
Limits the number of frames copied to the animation. X first frame index, Y last frame index.
font IFont
IFont to be used when creating the AnimatedScreenObject.
action Action<ColoredGlyphBase>
Callback that will be applied to each ColoredGlyphBase when creating a frame.
convertMode TextureConvertMode
The mode used when converting the texture to a surface.
convertForegroundStyle TextureConvertForegroundStyle
The style to use when convertMode is Foreground.
convertBackgroundStyle TextureConvertBackgroundStyle
The style to use when convertMode is Background.
frameDefaultBackground System.NullableSadRogue.Primitives.Color
The default background to use in the animation frames. Defaults to transparent.
Returns
Section titled “Returns”AnimatedScreenObject
An instance of AnimatedScreenObject with converted frames.
Remarks
Section titled “Remarks”This method assumes the image file contains only frames and optional padding between the frames, no border space. Frame count is calculated by multiplying rows and columns from the frame layout. It can by limited by specifying frame start and finish indexes. Frame size and the subsequent AnimatedScreenSurface size is calculated from the size of the image file, number of frames, padding and the font size ratio.
Save(string)
Section titled “Save(string)”Saves the AnimatedScreenObject to a file.
public void Save(string file)Parameters
Section titled “Parameters”file string
The destination file.
Load(string)
Section titled “Load(string)”Loads a AnimatedScreenObject from a file.
public static AnimatedScreenObject Load(string file)Parameters
Section titled “Parameters”file string
The source file.
Returns
Section titled “Returns”AnimatedScreenObject
The animated surface.
OnMouseEnter(MouseScreenObjectState)
Section titled “OnMouseEnter(MouseScreenObjectState)”Raises the MouseEnter event.
protected virtual void OnMouseEnter(MouseScreenObjectState state)Parameters
Section titled “Parameters”state MouseScreenObjectState
Current mouse state in relation to this console.
OnMouseExit(MouseScreenObjectState)
Section titled “OnMouseExit(MouseScreenObjectState)”Raises the MouseExit event.
protected virtual void OnMouseExit(MouseScreenObjectState state)Parameters
Section titled “Parameters”state MouseScreenObjectState
Current mouse state in relation to this console.
OnMouseMove(MouseScreenObjectState)
Section titled “OnMouseMove(MouseScreenObjectState)”Raises the MouseMove event.
protected virtual void OnMouseMove(MouseScreenObjectState state)Parameters
Section titled “Parameters”state MouseScreenObjectState
Current mouse state in relation to this console.
OnMouseLeftClicked(MouseScreenObjectState)
Section titled “OnMouseLeftClicked(MouseScreenObjectState)”Raises the MouseButtonClicked event. Possibly moves the console to the top of it’s parent’s children collection.
protected virtual void OnMouseLeftClicked(MouseScreenObjectState state)Parameters
Section titled “Parameters”state MouseScreenObjectState
Current mouse state in relation to this console.
OnRightMouseClicked(MouseScreenObjectState)
Section titled “OnRightMouseClicked(MouseScreenObjectState)”Raises the MouseButtonClicked event.
protected virtual void OnRightMouseClicked(MouseScreenObjectState state)Parameters
Section titled “Parameters”state MouseScreenObjectState
Current mouse state in relation to this console.
LostMouse(MouseScreenObjectState)
Section titled “LostMouse(MouseScreenObjectState)”Called when the mouse is being used by something else.
public override void LostMouse(MouseScreenObjectState state)Parameters
Section titled “Parameters”state MouseScreenObjectState
The current state of the mouse based on this object.
ProcessMouse(MouseScreenObjectState)
Section titled “ProcessMouse(MouseScreenObjectState)”Processes the mouse.
public override bool ProcessMouse(MouseScreenObjectState state)Parameters
Section titled “Parameters”state MouseScreenObjectState
The mouse state related to this object.
Returns
Section titled “Returns”bool
True when this object should halt further mouse processing..
UpdateAbsolutePosition()
Section titled “UpdateAbsolutePosition()”Sets a value for AbsolutePosition based on the SadRogue.Primitives.IPositionable.Position of this instance and the Parent instance.
public override void UpdateAbsolutePosition()Render(TimeSpan)
Section titled “Render(TimeSpan)”Draws the animation’s current frame and all SadComponents and Children.
public override void Render(TimeSpan delta)Parameters
Section titled “Parameters”delta TimeSpan
The time that has elapsed since the last call.
Update(TimeSpan)
Section titled “Update(TimeSpan)”Updates the AnimatedScreenObject effects and all SadComponents and Children.
public override void Update(TimeSpan delta)Parameters
Section titled “Parameters”delta TimeSpan
The time that has elapsed since this method was last called.
ToString()
Section titled “ToString()”Returns the value “ScreenSurface”.
public override string ToString()Returns
Section titled “Returns”string
The string “ScreenSurface”.
Dispose(bool)
Section titled “Dispose(bool)”protected virtual void Dispose(bool disposing)Parameters
Section titled “Parameters”disposing bool
~AnimatedScreenObject()
Section titled “~AnimatedScreenObject()”Disposes Renderer.
protected ~AnimatedScreenObject()Dispose()
Section titled “Dispose()”public void Dispose()Events
Section titled “Events”AnimationStateChanged
Section titled “AnimationStateChanged”Raised when the AnimatedScreenObject.AnimationState changes.
public event EventHandler<AnimatedScreenObject.AnimationStateChangedEventArgs>? AnimationStateChangedEvent Type
Section titled “Event Type”EventHandler<AnimatedScreenObject.AnimationStateChangedEventArgs>
MouseButtonClicked
Section titled “MouseButtonClicked”Raised when a mouse button is clicked on this object.
public event EventHandler<MouseScreenObjectState>? MouseButtonClickedEvent Type
Section titled “Event Type”EventHandler<MouseScreenObjectState>
MouseMove
Section titled “MouseMove”Raised when the mouse moves around the this object.
public event EventHandler<MouseScreenObjectState>? MouseMoveEvent Type
Section titled “Event Type”EventHandler<MouseScreenObjectState>
MouseExit
Section titled “MouseExit”Raised when the mouse exits this object.
public event EventHandler<MouseScreenObjectState>? MouseExitEvent Type
Section titled “Event Type”EventHandler<MouseScreenObjectState>
MouseEnter
Section titled “MouseEnter”Raised when the mouse enters this object.
public event EventHandler<MouseScreenObjectState>? MouseEnter