Package squidpony.squidgrid.gui.gdx
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).
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
Fields inherited from class squidpony.squidgrid.gui.gdx.SquidPanel
animatedEntities, animationCount, autoActors, cellHeight, cellWidth, colors, contents, DEFAULT_ANIMATION_DURATION, defaultForeground, gridHeight, gridOffsetX, gridOffsetY, gridWidth, lightingColor, lightingFloat, onlyRenderEven, scc, textFactory, tmpColor, xOffset, yOffset
-
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 anySquidPanel.autoActors
it has, and callsActor.act(float)
for each AnimatedEntity this contains inSquidPanel.animatedEntities
orSquidPanel.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 usingsetFromSnapshot(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 usingsetFromSnapshot(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 ownIColorCenter
and want this panel not to allocate its own colors (or fillDefaultResources.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" fromgetSnapshot(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" fromgetSnapshot(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" fromgetSnapshot(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" fromgetSnapshot(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" fromgetSnapshot(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" fromgetSnapshot(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 squidpony.squidgrid.gui.gdx.SquidPanel
adjustX, adjustY, blend, bump, bump, bump, bump, burst, burst, burst, burst, burst, burst, burst, cellHeight, cellToActor, cellToActor, cellWidth, clampDuration, clear, createActor, createActor, erase, fade, fixPosition, fixPositions, getAnimatedEntities, getAt, getColorAt, getColorCenter, getGridHeight, getGridOffsetX, getGridOffsetY, getGridWidth, getLightingColor, getOnlyRenderEven, getTextCellFactory, getTotalHeight, getTotalWidth, getxOffset, getyOffset, gridHeight, gridWidth, hasActiveAnimations, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putBorders, putBorders, putBorders, putBorders, putBorders, putBordersCaptioned, putBordersCaptioned, recallActor, recallActor, recallActor, recallActor, recallActor, removeAnimatedEntity, setGridHeight, setGridOffsetX, setGridOffsetY, setGridWidth, setLightingColor, setOffsets, setOffsetX, setOffsetY, setOnlyRenderEven, setPosition, setTextSize, slide, slide, slide, slide, slide, slide, slide, summon, summon, summon, summon, summon, summon, tint, tint, tint, tint, wiggle, wiggle, worldX, worldY
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
-
Field Details
-
Constructor Details
-
ImageSquidPanel
Creates a bare-bones panel with all default values for text rendering.- Parameters:
gridWidth
- the number of cells horizontallygridHeight
- the number of cells vertically
-
ImageSquidPanel
Creates a panel with the given grid and cell size. Uses a default square font.- Parameters:
gridWidth
- the number of cells horizontallygridHeight
- the number of cells verticallycellWidth
- the number of horizontal pixels in each cellcellHeight
- the number of vertical pixels in each cell
-
ImageSquidPanel
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 horizontallygridHeight
- the number of cells verticallyfactory
- 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 horizontallygridHeight
- the number of cells verticallyfactory
- the factory to use for cell renderingcenter
- The color center to use. Can benull
, but then must be set later on withSquidPanel.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 horizontallygridHeight
- the number of cells verticallyfactory
- the factory to use for cell renderingcenter
- The color center to use. Can benull
, but then must be set later on withSquidPanel.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 horizontallygridHeight
- the number of cells verticallyfactory
- the factory to use for cell renderingcenter
- The color center to use. Can benull
, but then must be set later on withSquidPanel.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
Draws this ImageSquidPanel and anySquidPanel.autoActors
it has, and callsActor.act(float)
for each AnimatedEntity this contains inSquidPanel.animatedEntities
orSquidPanel.autoActors
.
This will set the shader ofbatch
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 classSquidPanel
- Parameters:
batch
- a Batch such as aFilterBatch
that must be between a begin() and end() call; usually done by StageparentAlpha
- 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 classSquidPanel
- 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 itae
- 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 classSquidPanel
- 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 itac
- The Actor to draw; the position to draw ac is modified and reset based on some fields of this object
-
setDefaultForeground
Description copied from interface:IPackedColorPanel
Sets the default foreground color.- Specified by:
setDefaultForeground
in interfaceIPackedColorPanel
- Overrides:
setDefaultForeground
in classSquidPanel
-
getDefaultForegroundColor
- Specified by:
getDefaultForegroundColor
in interfaceIPackedColorPanel
- Overrides:
getDefaultForegroundColor
in classSquidPanel
- Returns:
- The default foreground color (if none was set with
IPackedColorPanel.setDefaultForeground(Color)
), or the last color set withIPackedColorPanel.setDefaultForeground(Color)
. Cannot benull
.
-
getAnimatedEntityByCell
- Overrides:
getAnimatedEntityByCell
in classSquidPanel
-
animateActor
Create an AnimatedEntity at position x, y, using the char c in the given color.- Overrides:
animateActor
in classSquidPanel
- 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 classSquidPanel
- Parameters:
x
-y
-doubleWidth
-c
-color
-- Returns:
-
animateActor
Create an AnimatedEntity at position x, y, using the String s in the given color.- Overrides:
animateActor
in classSquidPanel
- 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 classSquidPanel
- 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 classSquidPanel
- 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 classSquidPanel
- 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 classSquidPanel
- 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 classSquidPanel
-
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 classSquidPanel
- 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 classSquidPanel
- 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 classSquidPanel
- 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 classSquidPanel
- 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 classSquidPanel
- 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 classSquidPanel
- 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 classSquidPanel
- 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 classSquidPanel
- Parameters:
x
-y
-doubleWidth
-stretch
-texture
-color
-- Returns:
-
setColorCenter
Use this method if you use your ownIColorCenter
and want this panel not to allocate its own colors (or fillDefaultResources.getSCC()
but instead to the provided center.- Overrides:
setColorCenter
in classSquidPanel
- Parameters:
scc
- The color center to use. Should not benull
.- Throws:
NullPointerException
- Ifscc
isnull
.
-
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 usingsetFromSnapshot(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 classSquidPanel
- 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
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 usingsetFromSnapshot(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 classSquidPanel
- Parameters:
startX
- the first x position to use in the snapshot, inclusivestartY
- the first y position to use in the snapshot, inclusivewidth
- how wide the snapshot area should be; x positions from startX to startX + width - 1 will be usedheight
- 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" fromgetSnapshot(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 classSquidPanel
- Parameters:
snapshot
- a StringBuilder in a special format as produced bygetSnapshot(int, int, int, int)
- Returns:
- this after setting, for chaining
-
setFromSnapshot
Given a "snapshot" fromgetSnapshot(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 classSquidPanel
- Parameters:
snapshot
- a StringBuilder in a special format as produced bygetSnapshot(int, int, int, int)
putX
- where to start placing the data from the snapshot, x positionputY
- 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" fromgetSnapshot(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 classSquidPanel
- Parameters:
snapshot
- a StringBuilder in a special format as produced bygetSnapshot(int, int, int, int)
putX
- where to start placing the data from the snapshot, x positionputY
- where to start placing the data from the snapshot, y positionlimitWidth
- if negative, uses all of snapshot's width as possible, otherwise restricts the width allowedlimitHeight
- if negative, uses all of snapshot's height as possible, otherwise restricts the height allowed- Returns:
- this after setting, for chaining
-
setFromSnapshot
Given a "snapshot" fromgetSnapshot(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 classSquidPanel
- Parameters:
snapshot
- a String in a special format as produced bygetSnapshot(int, int, int, int)
- Returns:
- this after setting, for chaining
-
setFromSnapshot
Given a "snapshot" fromgetSnapshot(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 classSquidPanel
- Parameters:
snapshot
- a String in a special format as produced bygetSnapshot(int, int, int, int)
putX
- where to start placing the data from the snapshot, x positionputY
- 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" fromgetSnapshot(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 classSquidPanel
- Parameters:
snapshot
- a String in a special format as produced bygetSnapshot(int, int, int, int)
putX
- where to start placing the data from the snapshot, x positionputY
- where to start placing the data from the snapshot, y positionlimitWidth
- if negative, uses all of snapshot's width as possible, otherwise restricts the width allowedlimitHeight
- if negative, uses all of snapshot's height as possible, otherwise restricts the height allowed- Returns:
- this after setting, for chaining
-
setImageSwap
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 withremoveImageSwap(char)
or directly changing this object'simageMap
.- Parameters:
swapOut
- the char to avoid rendering and replace with an imageswapIn
- the image to replace the character with
-
removeImageSwap
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
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
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 callchar goblinChar = ImageSquidPanel.getUnusedChar('g');
and then register goblinChar in the image mapping withmyImageSquidPanel.setImageSwap(goblinChar, goblinImage);
, which would allow you to draw 'g' directly by placing a 'g' with put(), or draw goblinImage by placing either goblinChar orImageSquidPanel.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
-