Package squidpony.squidgrid.gui.gdx
Class SquidMessageBox
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
squidpony.squidgrid.gui.gdx.SparseLayers
squidpony.squidgrid.gui.gdx.SquidMessageBox
- All Implemented Interfaces:
- IPackedColorPanel
public class SquidMessageBox extends SparseLayers
A specialized SquidPanel that is meant for displaying messages in a scrolling pane. You primarily use this class by
 calling appendMessage() or appendWrappingMessage(), but the full SquidPanel API is available as well, though it isn't
 the best idea to use that set of methods with this class in many cases. Messages can be Strings or IColoredStrings.
 Height must be at least 3 cells, because clicking/tapping the top or bottom borders (which are part of the grid's
 height, which leaves 1 row in the middle for a message) will scroll up or down.
 Created by Tommy Ettinger on 12/10/2015.
- 
Field SummaryFields Modifier and Type Field Description protected intmessageIndexprotected ArrayList<IColoredString<com.badlogic.gdx.graphics.Color>>messagesFields inherited from class squidpony.squidgrid.gui.gdx.SparseLayersanimationCount, backgrounds, defaultBackground, defaultForeground, defaultPackedBackground, defaultPackedForeground, font, glyphs, gridHeight, gridWidth, layers, mapping, scc
- 
Constructor SummaryConstructors Constructor Description SquidMessageBox(int gridWidth, int gridHeight)Creates a bare-bones panel with all default values for text rendering.SquidMessageBox(int gridWidth, int gridHeight, int cellWidth, int cellHeight)Creates a panel with the given grid and cell size.SquidMessageBox(int gridWidth, int gridHeight, TextCellFactory factory)Builds a panel with the given grid size and all other parameters determined by the factory.SquidMessageBox(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.
- 
Method SummaryModifier and Type Method Description voidappendMessage(String message)The primary way of using this class.voidappendMessage(IColoredString<com.badlogic.gdx.graphics.Color> message)A common way of using this class.voidappendWrappingMessage(String message)Appends a new line to the message listing and scrolls to the bottom.voidappendWrappingMessage(IColoredString<com.badlogic.gdx.graphics.Color> message)Appends a new line as an IColoredString to the message listing and scrolls to the bottom.voiddraw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)Draws the SparseLayers and all glyphs it tracks.voidnudgeDown()Used internally to scroll down by one line, but can also be triggered by your code.voidnudgeUp()Used internally to scroll up by one line, but can also be triggered by your code.voidsetBounds(float x, float y, float width, float height)Set the x, y position of the lower left corner, plus set the width and height.Methods inherited from class squidpony.squidgrid.gui.gdx.SparseLayersaddLayer, addLayer, blend, bump, bump, burst, burst, burst, burst, calculateConsistentLightAmount, calculateConsistentLightModifier, calculateConsistentLightModifier, cellHeight, cellWidth, clear, clear, clear, clear, fillArea, fillArea, fillBackground, fillBackground, findLayer, getBackgrounds, getColorCenter, getDefaultBackgroundColor, getDefaultForegroundColor, getFont, getGridHeight, getGridWidth, getLayer, getLayerCount, getScc, glyph, glyph, glyphFromGrid, glyphFromGrid, gridHeight, gridWidth, gridX, gridY, hasActiveAnimations, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putBorders, putBordersCaptioned, putChars, putChars, putChars, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseLight, putWithReverseLight, recallToGrid, recallToGrid, recolor, recolor, recolor, recolor, recolor, recolor, recolor, recolor, removeGlyph, setBackgrounds, setColorCenter, setDefaultBackground, setDefaultForeground, setFont, setLayer, setScc, setTextSize, slide, slide, summon, summon, summon, summon, tint, tint, tint, tint, tint, tint, tint, tint, wiggle, wiggle, worldX, worldYMethods inherited from class com.badlogic.gdx.scenes.scene2d.Actoract, addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, 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, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, toBack, toFront, toString
- 
Field Details
- 
Constructor Details- 
SquidMessageBoxCreates a bare-bones panel with all default values for text rendering.- Parameters:
- gridWidth- the number of cells horizontally
- gridHeight- the number of cells vertically, must be at least 3
 
- 
SquidMessageBoxCreates 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
 
- 
SquidMessageBoxBuilds 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
 
- 
SquidMessageBoxpublic SquidMessageBox(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- ignored.
 
 
- 
- 
Method Details- 
appendMessageThe primary way of using this class. Appends a new line to the message listing and scrolls to the bottom.- Parameters:
- message- a String that should be no longer than gridWidth - 2; will be truncated otherwise.
 
- 
appendWrappingMessageAppends a new line to the message listing and scrolls to the bottom. If the message cannot fit on one line, it will be word-wrapped and one or more messages will be appended after it.- Parameters:
- message- a String; this method has no specific length restrictions
 
- 
appendMessageA common way of using this class. Appends a new line as an IColoredString to the message listing and scrolls to the bottom.- Parameters:
- message- an IColoredString that should be no longer than gridWidth - 2; will be truncated otherwise.
 
- 
appendWrappingMessageAppends a new line as an IColoredString to the message listing and scrolls to the bottom. If the message cannot fit on one line, it will be word-wrapped and one or more messages will be appended after it.- Parameters:
- message- an IColoredString with type parameter Color; this method has no specific length restrictions
 
- 
nudgeUpUsed internally to scroll up by one line, but can also be triggered by your code.
- 
nudgeDownUsed internally to scroll down by one line, but can also be triggered by your code.
- 
drawDescription copied from class:SparseLayersDraws the SparseLayers and all glyphs it tracks.Batch.begin()must have already been called on the batch, andBatch.end()should be called after this returns and before the rendering code finishes for the frame.
 This will set the shader ofbatchif 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:
- drawin class- SparseLayers
- Parameters:
- batch- a Batch such as a- FilterBatchthat must be between a begin() and end() call; usually done by Stage
- parentAlpha- currently ignored
 
- 
setBoundsSet the x, y position of the lower left corner, plus set the width and height. ACTUALLY NEEDED to make the borders clickable. It can't know the boundaries of the clickable area until it knows its own position and bounds.- Overrides:
- setBoundsin class- com.badlogic.gdx.scenes.scene2d.Actor
- Parameters:
- x- x position in pixels or other units that libGDX is set to use
- y- y position in pixels or other units that libGDX is set to use
- width- the width in pixels (usually) of the message box; changes on resize
- height- the height in pixels (usually) of the message box; changes on resize
 
 
-