Class ImageSquidPanel

java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.Group
squidpony.squidgrid.gui.gdx.SquidPanel
squidpony.squidgrid.gui.gdx.ImageSquidPanel
All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Cullable, IPackedColorPanel

public class ImageSquidPanel
extends SquidPanel
Displays text and images in a grid pattern, like SquidPanel, but will automatically render certain chars as images. Supports basic animations, such as sliding, wiggling, or fading the contents of a cell.
Grid width and height settings are in terms of number of cells. Cell width and height are in terms of number of pixels (when there is no stretching taking place due to viewport or window size).
Author:
Eben Howard - http://squidpony.com - howard@squidpony.com, Tommy Ettinger
  • Field Summary

    Fields 
    Modifier and Type Field Description
    com.badlogic.gdx.utils.IntMap<com.badlogic.gdx.graphics.g2d.TextureRegion> imageMap  
  • Constructor Summary

    Constructors 
    Constructor Description
    ImageSquidPanel​(int gridWidth, int gridHeight)
    Creates a bare-bones panel with all default values for text rendering.
    ImageSquidPanel​(int gridWidth, int gridHeight, int cellWidth, int cellHeight)
    Creates a panel with the given grid and cell size.
    ImageSquidPanel​(int gridWidth, int gridHeight, TextCellFactory factory)
    Builds a panel with the given grid size and all other parameters determined by the factory.
    ImageSquidPanel​(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center)
    Builds a panel with the given grid size and all other parameters determined by the factory.
    ImageSquidPanel​(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center, float xOffset, float yOffset)
    Builds a panel with the given grid size and all other parameters determined by the factory.
    ImageSquidPanel​(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center, float xOffset, float yOffset, char[][] actualMap)
    Builds a panel with the given grid size and all other parameters determined by the factory.
  • Method Summary

    Modifier and Type Method Description
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, boolean stretch, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
    Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which, if and only if stretch is true, will be stretched to fit one cell, or two cells if doubleWidth is true.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, boolean stretch, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)
    Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which, if and only if stretch is true, will be stretched to fit one cell, or two cells if doubleWidth is true.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, char c, com.badlogic.gdx.graphics.Color color)
    Create an AnimatedEntity at position x, y, using the char c in the given color.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, char c, Collection<com.badlogic.gdx.graphics.Color> colors)
    Create an AnimatedEntity at position x, y, using the char c in the given colors to cycle through.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, char c, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
    Create an AnimatedEntity at position x, y, using the char c in the given colors to cycle through.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
    Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which will be stretched to fit one cell, or two cells if doubleWidth is true.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)
    Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color, String name)
    Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, Collection<com.badlogic.gdx.graphics.Color> colors)
    Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
    Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime, String name)
    Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, String s, com.badlogic.gdx.graphics.Color color)
    Create an AnimatedEntity at position x, y, using the String s in the given color.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, String s, Collection<com.badlogic.gdx.graphics.Color> colors)
    Create an AnimatedEntity at position x, y, using the String s in the given color.
    AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, String s, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
    Create an AnimatedEntity at position x, y, using the String s in the given color.
    AnimatedEntity animateActor​(int x, int y, char c, int index, ArrayList<com.badlogic.gdx.graphics.Color> palette)
    Create an AnimatedEntity at position x, y, using the char c with a color looked up by index in palette.
    AnimatedEntity animateActor​(int x, int y, char c, com.badlogic.gdx.graphics.Color color)
    Create an AnimatedEntity at position x, y, using the char c in the given color.
    AnimatedEntity animateActor​(int x, int y, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
    Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which will be stretched to fit one cell.
    AnimatedEntity animateActor​(int x, int y, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)
    Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell.
    AnimatedEntity animateActor​(int x, int y, String s, int index, ArrayList<com.badlogic.gdx.graphics.Color> palette)
    Create an AnimatedEntity at position x, y, using the String s with a color looked up by index in palette.
    AnimatedEntity animateActor​(int x, int y, String s, com.badlogic.gdx.graphics.Color color)
    Create an AnimatedEntity at position x, y, using the String s in the given color.
    AnimatedEntity directionMarker​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.Color color)  
    AnimatedEntity directionMarker​(int x, int y, boolean doubleWidth, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
    Create an AnimatedEntity at position x, y, using '^' as its contents, but as an image so it can be rotated.
    void draw​(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
    Draws this ImageSquidPanel and any SquidPanel.autoActors it has, and calls Actor.act(float) for each AnimatedEntity this contains in SquidPanel.animatedEntities or SquidPanel.autoActors.
    void drawActor​(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha, com.badlogic.gdx.scenes.scene2d.Actor ac)
    Draws one AnimatedEntity, specifically the Actor it contains.
    void drawActor​(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha, AnimatedEntity ae)
    Draws one AnimatedEntity, specifically the Actor it contains.
    AnimatedEntity getAnimatedEntityByCell​(int x, int y)  
    com.badlogic.gdx.graphics.Color getDefaultForegroundColor()  
    com.badlogic.gdx.graphics.g2d.TextureRegion getImageSwap​(char toFind)
    If there is a TextureRegion that would replace the char toFind when drawn, this will return that TextureRegion, otherwise it returns null.
    StringBuilder getSnapshot()
    Gets a "snapshot" of the data represented by this ImageSquidPanel; stores the dimensions, the char data, and the color data in a way that can be set back to a SquidPanel or ImageSquidPanel using setFromSnapshot(String, int, int, int, int) or its overload that takes a StringBuilder.
    StringBuilder getSnapshot​(int startX, int startY, int width, int height)
    Gets a "snapshot" of the data represented by this ImageSquidPanel; stores the dimensions, the char data, and the color data in a way that can be set back to a SquidPanel or ImageSquidPanel using setFromSnapshot(String, int, int, int, int) or its overload that takes a StringBuilder.
    static char getUnusedChar​(char initial)
    Meant for taking easy-to-write chars and generating chars that can map to images, while still allowing the original easy-to-write char to be used as its own non-image char.
    void removeImageSwap​(char toRemove)
    Removes the char toRemove from the mapping of chars to replace with images, or does nothing if this did not already replace toRemove with an image.
    void setColorCenter​(IColorCenter<com.badlogic.gdx.graphics.Color> scc)
    Use this method if you use your own IColorCenter and want this panel not to allocate its own colors (or fill DefaultResources.getSCC() but instead to the provided center.
    void setDefaultForeground​(com.badlogic.gdx.graphics.Color defaultForeground)
    Sets the default foreground color.
    ImageSquidPanel setFromSnapshot​(String snapshot)
    Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from 0,0 (inclusive) up to the dimensions stored in the snapshot to match the snapshot's data.
    ImageSquidPanel setFromSnapshot​(StringBuilder snapshot)
    Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from 0,0 (inclusive) up to the dimensions stored in the snapshot to match the snapshot's data.
    ImageSquidPanel setFromSnapshot​(StringBuilder snapshot, int putX, int putY)
    Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from the position given by putX,putY (inclusive) up to the dimensions stored in the snapshot (considering putX and putY as offsets) so they have the values stored in the snapshot.
    ImageSquidPanel setFromSnapshot​(StringBuilder snapshot, int putX, int putY, int limitWidth, int limitHeight)
    Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from the position given by putX,putY (inclusive) to putX+limitWidth,putY+limitHeight (exclusive) so they have the values stored in the snapshot.
    ImageSquidPanel setFromSnapshot​(String snapshot, int putX, int putY)
    Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from the position given by putX,putY (inclusive) up to the dimensions stored in the snapshot (considering putX and putY as offsets) so they have the values stored in the snapshot.
    ImageSquidPanel setFromSnapshot​(String snapshot, int putX, int putY, int limitWidth, int limitHeight)
    Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from the position given by putX,putY (inclusive) to putX+limitWidth,putY+limitHeight (exclusive) so they have the values stored in the snapshot.
    void setImageSwap​(char swapOut, com.badlogic.gdx.graphics.g2d.TextureRegion swapIn)
    Makes it so when the char swapOut would be drawn, the TextureRegion swapIn is drawn instead.

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group

    act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, applyTransform, childrenChanged, clear, clearChildren, computeTransform, debugAll, drawChildren, drawDebug, drawDebugChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, hit, isTransform, localToDescendantCoordinates, removeActor, removeActor, removeActorAt, resetTransform, resetTransform, setCullingArea, setDebug, setStage, setTransform, swapActor, swapActor, toString

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor

    addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, toBack, toFront

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • imageMap

      public com.badlogic.gdx.utils.IntMap<com.badlogic.gdx.graphics.g2d.TextureRegion> imageMap
  • Constructor Details

    • ImageSquidPanel

      public ImageSquidPanel​(int gridWidth, int gridHeight)
      Creates a bare-bones panel with all default values for text rendering.
      Parameters:
      gridWidth - the number of cells horizontally
      gridHeight - the number of cells vertically
    • ImageSquidPanel

      public ImageSquidPanel​(int gridWidth, int gridHeight, int cellWidth, int cellHeight)
      Creates a panel with the given grid and cell size. Uses a default square font.
      Parameters:
      gridWidth - the number of cells horizontally
      gridHeight - the number of cells vertically
      cellWidth - the number of horizontal pixels in each cell
      cellHeight - the number of vertical pixels in each cell
    • ImageSquidPanel

      public ImageSquidPanel​(int gridWidth, int gridHeight, TextCellFactory factory)
      Builds a panel with the given grid size and all other parameters determined by the factory. Even if sprite images are being used, a TextCellFactory is still needed to perform sizing and other utility functions. If the TextCellFactory has not yet been initialized, then it will be sized at 12x12 px per cell. If it is null then a default one will be created and initialized.
      Parameters:
      gridWidth - the number of cells horizontally
      gridHeight - the number of cells vertically
      factory - the factory to use for cell rendering
    • ImageSquidPanel

      public ImageSquidPanel​(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center)
      Builds a panel with the given grid size and all other parameters determined by the factory. Even if sprite images are being used, a TextCellFactory is still needed to perform sizing and other utility functions. If the TextCellFactory has not yet been initialized, then it will be sized at 12x12 px per cell. If it is null then a default one will be created and initialized.
      Parameters:
      gridWidth - the number of cells horizontally
      gridHeight - the number of cells vertically
      factory - the factory to use for cell rendering
      center - The color center to use. Can be null, but then must be set later on with SquidPanel.setColorCenter(IColorCenter).
    • ImageSquidPanel

      public ImageSquidPanel​(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center, float xOffset, float yOffset)
      Builds a panel with the given grid size and all other parameters determined by the factory. Even if sprite images are being used, a TextCellFactory is still needed to perform sizing and other utility functions. If the TextCellFactory has not yet been initialized, then it will be sized at 12x12 px per cell. If it is null then a default one will be created and initialized.
      Parameters:
      gridWidth - the number of cells horizontally
      gridHeight - the number of cells vertically
      factory - the factory to use for cell rendering
      center - The color center to use. Can be null, but then must be set later on with SquidPanel.setColorCenter(IColorCenter).
    • ImageSquidPanel

      public ImageSquidPanel​(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center, float xOffset, float yOffset, char[][] actualMap)
      Builds a panel with the given grid size and all other parameters determined by the factory. Even if sprite images are being used, a TextCellFactory is still needed to perform sizing and other utility functions. Importantly, this constructor takes a 2D char array argument that can be sized differently than the displayed area. The displayed area is gridWidth by gridHeight in cells, but the actualMap argument can be much larger, and only a portion will be displayed at a time. This requires some special work with the Camera and Viewports to get working correctly; in the squidlib module's examples, EverythingDemo may be a good place to see how this can be done. You can pass null for actualMap, which will simply create a char array to use internally that is exactly gridWidth by gridHeight, in cells.
      If the TextCellFactory has not yet been initialized, then it will be sized at 12x12 px per cell. If it is null then a default one will be created and initialized. The xOffset and yOffset arguments are measured in pixels or whatever sub-cell unit of measure your game uses (world coordinates, in libGDX parlance), and change where the SquidPanel starts drawing by simply adding to the initial x and y coordinates. 0 and 0 are usually fine.
      Parameters:
      gridWidth - the number of cells horizontally
      gridHeight - the number of cells vertically
      factory - the factory to use for cell rendering
      center - The color center to use. Can be null, but then must be set later on with SquidPanel.setColorCenter(IColorCenter).
      xOffset - the x offset to start rendering at, in pixels (or some other sub-cell measurement your game uses)
      yOffset - the y offset to start rendering at, in pixels (or some other sub-cell measurement your game uses)
      actualMap - will often be a different size than gridWidth by gridHeight, which enables camera scrolling
  • Method Details

    • draw

      public void draw​(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
      Draws this ImageSquidPanel and any SquidPanel.autoActors it has, and calls Actor.act(float) for each AnimatedEntity this contains in SquidPanel.animatedEntities or SquidPanel.autoActors.
      This will set the shader of batch if using a distance field or MSDF font and the shader is currently not configured for such a font; it does not reset the shader to the default so that multiple Actors can all use the same shader and so specific extra glyphs or other items can be rendered after calling draw(). If you need to draw both a distance field font and full-color art, you should set the shader on the Batch to null when you want to draw full-color art, and end the Batch between drawing this object and the other art.
      Overrides:
      draw in class SquidPanel
      Parameters:
      batch - a Batch such as a FilterBatch that must be between a begin() and end() call; usually done by Stage
      parentAlpha - only used when drawing children of this ImageSquidPanel
    • drawActor

      public void drawActor​(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha, AnimatedEntity ae)
      Draws one AnimatedEntity, specifically the Actor it contains. Batch must be between start() and end()
      Overrides:
      drawActor in class SquidPanel
      Parameters:
      batch - Must have start() called already but not stop() yet during this frame.
      parentAlpha - This can be assumed to be 1.0f if you don't know it
      ae - The AnimatedEntity to draw; the position to draw ae is stored inside it.
    • drawActor

      public void drawActor​(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha, com.badlogic.gdx.scenes.scene2d.Actor ac)
      Draws one AnimatedEntity, specifically the Actor it contains. Batch must be between start() and end()
      Overrides:
      drawActor in class SquidPanel
      Parameters:
      batch - Must have start() called already but not stop() yet during this frame.
      parentAlpha - This can be assumed to be 1.0f if you don't know it
      ac - The Actor to draw; the position to draw ac is modified and reset based on some fields of this object
    • setDefaultForeground

      public void setDefaultForeground​(com.badlogic.gdx.graphics.Color defaultForeground)
      Description copied from interface: IPackedColorPanel
      Sets the default foreground color.
      Specified by:
      setDefaultForeground in interface IPackedColorPanel
      Overrides:
      setDefaultForeground in class SquidPanel
    • getDefaultForegroundColor

      public com.badlogic.gdx.graphics.Color getDefaultForegroundColor()
      Specified by:
      getDefaultForegroundColor in interface IPackedColorPanel
      Overrides:
      getDefaultForegroundColor in class SquidPanel
      Returns:
      The default foreground color (if none was set with IPackedColorPanel.setDefaultForeground(Color)), or the last color set with IPackedColorPanel.setDefaultForeground(Color). Cannot be null.
    • getAnimatedEntityByCell

      public AnimatedEntity getAnimatedEntityByCell​(int x, int y)
      Overrides:
      getAnimatedEntityByCell in class SquidPanel
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, char c, com.badlogic.gdx.graphics.Color color)
      Create an AnimatedEntity at position x, y, using the char c in the given color.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      c -
      color -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, char c, com.badlogic.gdx.graphics.Color color)
      Create an AnimatedEntity at position x, y, using the char c in the given color. If doubleWidth is true, treats the char c as the left char to be placed in a grid of 2-char cells.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      c -
      color -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, String s, com.badlogic.gdx.graphics.Color color)
      Create an AnimatedEntity at position x, y, using the String s in the given color.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      s -
      color -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, String s, com.badlogic.gdx.graphics.Color color)
      Create an AnimatedEntity at position x, y, using the String s in the given color. If doubleWidth is true, treats the String s as starting in the left cell of a pair to be placed in a grid of 2-char cells.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      s -
      color -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, String s, Collection<com.badlogic.gdx.graphics.Color> colors)
      Create an AnimatedEntity at position x, y, using the String s in the given color. If doubleWidth is true, treats the String s as starting in the left cell of a pair to be placed in a grid of 2-char cells.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      s -
      colors -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, String s, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
      Create an AnimatedEntity at position x, y, using the String s in the given color. If doubleWidth is true, treats the String s as starting in the left cell of a pair to be placed in a grid of 2-char cells.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      s -
      colors -
      loopTime -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, char c, Collection<com.badlogic.gdx.graphics.Color> colors)
      Create an AnimatedEntity at position x, y, using the char c in the given colors to cycle through. If doubleWidth is true, treats the String s as starting in the left cell of a pair to be placed in a grid of 2-char cells.
      Parameters:
      x -
      y -
      doubleWidth -
      c -
      colors -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, char c, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
      Create an AnimatedEntity at position x, y, using the char c in the given colors to cycle through. If doubleWidth is true, treats the String s as starting in the left cell of a pair to be placed in a grid of 2-char cells.
      Parameters:
      x -
      y -
      doubleWidth -
      c -
      colors -
      loopTime -
      Returns:
    • directionMarker

      public AnimatedEntity directionMarker​(int x, int y, boolean doubleWidth, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
      Create an AnimatedEntity at position x, y, using '^' as its contents, but as an image so it can be rotated. Uses the given colors in a looping pattern, that doesn't count as an animation. If doubleWidth is true, treats the '^' as starting in the middle of a 2-char cell.
      Overrides:
      directionMarker in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      colors -
      loopTime -
      Returns:
    • directionMarker

      public AnimatedEntity directionMarker​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.Color color)
      Overrides:
      directionMarker in class SquidPanel
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, char c, int index, ArrayList<com.badlogic.gdx.graphics.Color> palette)
      Create an AnimatedEntity at position x, y, using the char c with a color looked up by index in palette.
      Parameters:
      x -
      y -
      c -
      index -
      palette -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, String s, int index, ArrayList<com.badlogic.gdx.graphics.Color> palette)
      Create an AnimatedEntity at position x, y, using the String s with a color looked up by index in palette.
      Parameters:
      x -
      y -
      s -
      index -
      palette -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
      Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which will be stretched to fit one cell.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      texture -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)
      Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      texture -
      color -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
      Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which will be stretched to fit one cell, or two cells if doubleWidth is true.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      texture -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)
      Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      texture -
      color -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color, String name)
      Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.
      Parameters:
      x -
      y -
      doubleWidth -
      texture -
      color -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, Collection<com.badlogic.gdx.graphics.Color> colors)
      Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      texture -
      colors -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
      Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      texture -
      colors -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime, String name)
      Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.
      Parameters:
      x -
      y -
      doubleWidth -
      texture -
      colors -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, boolean stretch, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
      Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which, if and only if stretch is true, will be stretched to fit one cell, or two cells if doubleWidth is true. If stretch is false, this will preserve the existing size of texture.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      stretch -
      texture -
      Returns:
    • animateActor

      public AnimatedEntity animateActor​(int x, int y, boolean doubleWidth, boolean stretch, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)
      Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which, if and only if stretch is true, will be stretched to fit one cell, or two cells if doubleWidth is true. If stretch is false, this will preserve the existing size of texture.
      Overrides:
      animateActor in class SquidPanel
      Parameters:
      x -
      y -
      doubleWidth -
      stretch -
      texture -
      color -
      Returns:
    • setColorCenter

      public void setColorCenter​(IColorCenter<com.badlogic.gdx.graphics.Color> scc)
      Use this method if you use your own IColorCenter and want this panel not to allocate its own colors (or fill DefaultResources.getSCC() but instead to the provided center.
      Overrides:
      setColorCenter in class SquidPanel
      Parameters:
      scc - The color center to use. Should not be null.
      Throws:
      NullPointerException - If scc is null.
    • getSnapshot

      Gets a "snapshot" of the data represented by this ImageSquidPanel; stores the dimensions, the char data, and the color data in a way that can be set back to a SquidPanel or ImageSquidPanel using setFromSnapshot(String, int, int, int, int) or its overload that takes a StringBuilder. The actual contents of the returned StringBuilder are unlikely to be legible in any way if read as text, and are meant to be concise and stable across versions.
      NOTE: For this version, the mapping of chars to images is not stored in the snapshot, allowing alternate mappings to be used, such as while graphics are being updated frequently. This also allows the snapshot to be read in from both normal SquidPanels and ImageSquidPanels.
      Overrides:
      getSnapshot in class SquidPanel
      Returns:
      a StringBuilder representation of this SquidPanel's data that can be passed later to setFromSnapshot(StringBuilder, int, int, int, int) or converted to String and passed to its overload
    • getSnapshot

      public StringBuilder getSnapshot​(int startX, int startY, int width, int height)
      Gets a "snapshot" of the data represented by this ImageSquidPanel; stores the dimensions, the char data, and the color data in a way that can be set back to a SquidPanel or ImageSquidPanel using setFromSnapshot(String, int, int, int, int) or its overload that takes a StringBuilder. The actual contents of the returned StringBuilder are unlikely to be legible in any way if read as text, and are meant to be concise and stable across versions. This overload allows the first x and y position used to be specified, as well as the width and height to use (the actual width and height stored may be different if this SquidPanel's gridWidth and/or gridHeight are smaller than the width and/or height given).
      NOTE: For this version, the mapping of chars to images is not stored in the snapshot, allowing alternate mappings to be used, such as while graphics are being updated frequently. This also allows the snapshot to be read in from both normal SquidPanels and ImageSquidPanels.
      Overrides:
      getSnapshot in class SquidPanel
      Parameters:
      startX - the first x position to use in the snapshot, inclusive
      startY - the first y position to use in the snapshot, inclusive
      width - how wide the snapshot area should be; x positions from startX to startX + width - 1 will be used
      height - how tall the snapshot area should be; y positions from startY to startY + height - 1 will be used
      Returns:
      a StringBuilder representation of this SquidPanel's data that can be passed later to setFromSnapshot(StringBuilder, int, int, int, int) or converted to String and passed to its overload
    • setFromSnapshot

      Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from 0,0 (inclusive) up to the dimensions stored in the snapshot to match the snapshot's data.
      Overrides:
      setFromSnapshot in class SquidPanel
      Parameters:
      snapshot - a StringBuilder in a special format as produced by getSnapshot(int, int, int, int)
      Returns:
      this after setting, for chaining
    • setFromSnapshot

      public ImageSquidPanel setFromSnapshot​(StringBuilder snapshot, int putX, int putY)
      Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from the position given by putX,putY (inclusive) up to the dimensions stored in the snapshot (considering putX and putY as offsets) so they have the values stored in the snapshot.
      Overrides:
      setFromSnapshot in class SquidPanel
      Parameters:
      snapshot - a StringBuilder in a special format as produced by getSnapshot(int, int, int, int)
      putX - where to start placing the data from the snapshot, x position
      putY - where to start placing the data from the snapshot, y position
      Returns:
      this after setting, for chaining
    • setFromSnapshot

      public ImageSquidPanel setFromSnapshot​(StringBuilder snapshot, int putX, int putY, int limitWidth, int limitHeight)
      Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from the position given by putX,putY (inclusive) to putX+limitWidth,putY+limitHeight (exclusive) so they have the values stored in the snapshot. If limitWidth or limitHeight is negative, this uses the full width and height of the snapshot (stopping early if it would extend past the gridWidth or gridHeight of this ImageSquidPanel).
      Overrides:
      setFromSnapshot in class SquidPanel
      Parameters:
      snapshot - a StringBuilder in a special format as produced by getSnapshot(int, int, int, int)
      putX - where to start placing the data from the snapshot, x position
      putY - where to start placing the data from the snapshot, y position
      limitWidth - if negative, uses all of snapshot's width as possible, otherwise restricts the width allowed
      limitHeight - if negative, uses all of snapshot's height as possible, otherwise restricts the height allowed
      Returns:
      this after setting, for chaining
    • setFromSnapshot

      public ImageSquidPanel setFromSnapshot​(String snapshot)
      Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from 0,0 (inclusive) up to the dimensions stored in the snapshot to match the snapshot's data.
      This overload takes a String instead of a StringBuilder for potentially-easier loading from files.
      Overrides:
      setFromSnapshot in class SquidPanel
      Parameters:
      snapshot - a String in a special format as produced by getSnapshot(int, int, int, int)
      Returns:
      this after setting, for chaining
    • setFromSnapshot

      public ImageSquidPanel setFromSnapshot​(String snapshot, int putX, int putY)
      Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from the position given by putX,putY (inclusive) up to the dimensions stored in the snapshot (considering putX and putY as offsets) so they have the values stored in the snapshot.
      This overload takes a String instead of a StringBuilder for potentially-easier loading from files.
      Overrides:
      setFromSnapshot in class SquidPanel
      Parameters:
      snapshot - a String in a special format as produced by getSnapshot(int, int, int, int)
      putX - where to start placing the data from the snapshot, x position
      putY - where to start placing the data from the snapshot, y position
      Returns:
      this after setting, for chaining
    • setFromSnapshot

      public ImageSquidPanel setFromSnapshot​(String snapshot, int putX, int putY, int limitWidth, int limitHeight)
      Given a "snapshot" from getSnapshot(int, int, int, int), this assigns the chars and colors in this ImageSquidPanel from the position given by putX,putY (inclusive) to putX+limitWidth,putY+limitHeight (exclusive) so they have the values stored in the snapshot. If limitWidth or limitHeight is negative, this uses the full width and height of the snapshot (stopping early if it would extend past the gridWidth or gridHeight of this ImageSquidPanel).
      This overload takes a String instead of a StringBuilder for potentially-easier loading from files.
      Overrides:
      setFromSnapshot in class SquidPanel
      Parameters:
      snapshot - a String in a special format as produced by getSnapshot(int, int, int, int)
      putX - where to start placing the data from the snapshot, x position
      putY - where to start placing the data from the snapshot, y position
      limitWidth - if negative, uses all of snapshot's width as possible, otherwise restricts the width allowed
      limitHeight - if negative, uses all of snapshot's height as possible, otherwise restricts the height allowed
      Returns:
      this after setting, for chaining
    • setImageSwap

      public void setImageSwap​(char swapOut, com.badlogic.gdx.graphics.g2d.TextureRegion swapIn)
      Makes it so when the char swapOut would be drawn, the TextureRegion swapIn is drawn instead. This will apply for as long as this ImageSquidPanel is in use unless swapIn is removed with removeImageSwap(char) or directly changing this object's imageMap.
      Parameters:
      swapOut - the char to avoid rendering and replace with an image
      swapIn - the image to replace the character with
    • removeImageSwap

      public void removeImageSwap​(char toRemove)
      Removes the char toRemove from the mapping of chars to replace with images, or does nothing if this did not already replace toRemove with an image. This means toRemove will render as itself, if present in the font.
      Parameters:
      toRemove - the char to render as a glyph instead of a texture
    • getImageSwap

      public com.badlogic.gdx.graphics.g2d.TextureRegion getImageSwap​(char toFind)
      If there is a TextureRegion that would replace the char toFind when drawn, this will return that TextureRegion, otherwise it returns null.
      Parameters:
      toFind - the char to find the corresponding TextureRegion that it could be mapped to
      Returns:
      the corresponding TextureRegion if it exists, or null otherwise
    • getUnusedChar

      public static char getUnusedChar​(char initial)
      Meant for taking easy-to-write chars and generating chars that can map to images, while still allowing the original easy-to-write char to be used as its own non-image char. Given a char that should be from the "relatively common" parts of Unicode (essentially, anything with a codepoint before 0x1000, or with a small risk of collision, anything before 0x8000), this returns a character from the "Private Use Area" of Unicode that will probably be unique for most kinds of input. 4096 possible chars can be returned by this method. As an example, you may want to map the char 'g' to an image of a goblin, but still sometimes show the actual 'g' for some other monster or a variant on goblins you don't have an image for. You could call char goblinChar = ImageSquidPanel.getUnusedChar('g'); and then register goblinChar in the image mapping with myImageSquidPanel.setImageSwap(goblinChar, goblinImage);, which would allow you to draw 'g' directly by placing a 'g' with put(), or draw goblinImage by placing either goblinChar or ImageSquidPanel.getUnusedChar('g') with put().
      Parameters:
      initial - a char that ideally should be from the earlier parts of Unicode (before 0x1000 is ideal)
      Returns:
      a char from Unicode's private use area that is unlikely to be found otherwise or accidentally