Skip to main content

FlixelDebugWatchManager

View source

class

org.flixelgdx.debug.FlixelDebugWatchManager

public class FlixelDebugWatchManager

Manages the variable watch list for the debug overlay. Watch entries are getter-based (no reflection). Each entry is a display name mapped to a Supplier whose value is polled every frame.

Access via Flixel.watch. The API mirrors HaxeFlixel's FlxG.watch front-end as closely as possible while staying idiomatic in Java.

Constructors

FlixelDebugWatchManager()

public FlixelDebugWatchManager()

Methods

add(String, Supplier<?>)

public void add(String displayName, Supplier<?> valueGetter)

Registers a watch entry. If an entry with the same name already exists it is replaced. Equivalent to HaxeFlixel's FlxG.watch.addFunction.

Parameters:

NameDescription
displayNameThe label shown in the watch panel.
valueGetterA supplier that returns the current value each frame.

add(String, ByteSupplier)

public void add(String displayName, ByteSupplier valueGetter)

Registers a byte-valued watch entry without boxing.

Parameters:

NameDescription
displayNameThe label shown in the watch panel.
valueGetterA supplier that returns a primitive byte each frame.

add(String, ShortSupplier)

public void add(String displayName, ShortSupplier valueGetter)

Registers a short-valued watch entry without boxing.

Parameters:

NameDescription
displayNameThe label shown in the watch panel.
valueGetterA supplier that returns a primitive short each frame.

add(String, IntSupplier)

public void add(String displayName, IntSupplier valueGetter)

Registers an int-valued watch entry without boxing.

Parameters:

NameDescription
displayNameThe label shown in the watch panel.
valueGetterA supplier that returns a primitive int each frame.

add(String, LongSupplier)

public void add(String displayName, LongSupplier valueGetter)

Registers a long-valued watch entry without boxing.

Parameters:

NameDescription
displayNameThe label shown in the watch panel.
valueGetterA supplier that returns a primitive long each frame.

add(String, FloatSupplier)

public void add(String displayName, FloatSupplier valueGetter)

Registers a float-valued watch entry without boxing.

Parameters:

NameDescription
displayNameThe label shown in the watch panel.
valueGetterA supplier that returns a primitive float each frame.

add(String, DoubleSupplier)

public void add(String displayName, DoubleSupplier valueGetter)

Registers a double-valued watch entry without boxing.

Parameters:

NameDescription
displayNameThe label shown in the watch panel.
valueGetterA supplier that returns a primitive double each frame.

add(String, BooleanSupplier)

public void add(String displayName, BooleanSupplier valueGetter)

Registers a boolean-valued watch entry without boxing.

Parameters:

NameDescription
displayNameThe label shown in the watch panel.
valueGetterA supplier that returns a primitive boolean each frame.

add(String, CharSupplier)

public void add(String displayName, CharSupplier valueGetter)

Registers a char-valued watch entry without boxing.

Parameters:

NameDescription
displayNameThe label shown in the watch panel.
valueGetterA supplier that returns a primitive char each frame.

remove(String)

public void remove(String displayName)

Removes a previously registered watch entry by name.

Parameters:

NameDescription
displayNameThe label of the entry to remove.

addMouse()

public void addMouse()

Adds a convenience watch entry that shows the current mouse screen position.


removeMouse()

public void removeMouse()

Removes the convenience mouse position watch entry.


forEach(BiConsumer<String,String>)

public void forEach(BiConsumer<String,String> callback)

Iterates every watch entry, invoking the callback with each display name and its current resolved value string. The value string is materialized for the callback; prefer FlixelDebugWatchManager.fillWatchLines(Array<FlixelString>) when drawing to avoid per-entry String churn in tight loops.

Parameters:

NameDescription
callbackReceives (displayName, currentValueString) for every entry.

fillWatchLines(Array<FlixelString>)

public void fillWatchLines(Array<FlixelString> output)

Formats all watch lines into output, reusing existing FlixelString slots and shrinking the array when fewer watches are registered. Each line includes markup for the debug overlay.

Prefer FlixelDebugWatchManager.fillWatchEntries(Array<FlixelString>, Array<FlixelString>) when the renderer (for example a Dear ImGui based overlay) is responsible for coloring keys and values separately, since that path avoids appending markup tokens that the renderer has to ignore anyway.

Parameters:

NameDescription
outputCleared and filled with one FlixelString per watch entry (order follows Map.entrySet()).

fillWatchEntries(Array<FlixelString>, Array<FlixelString>)

public void fillWatchEntries(Array<FlixelString> keys, Array<FlixelString> values)

Fills two parallel arrays with each watch entry's name and its current value, reusing existing FlixelString slots so that no allocations happen on the steady-state path.

This is the preferred path when the debug renderer can color keys and values on its own (for example Dear ImGui's TextColored), since neither array contains color markup. Both arrays are guaranteed to have the same size on return.

Parameters:

NameDescription
keysCleared and filled with one entry per watch's display name.
valuesCleared and filled with one entry per watch's current value (no formatting prefix).

isEmpty()

public boolean isEmpty()

Returns true when there are no watch entries registered.


clear()

public void clear()

Clears all watch entries.


WatchEntry

interface

org.flixelgdx.debug.FlixelDebugWatchManager.WatchEntry

protected static interface WatchEntry

Internal hook for formatting a watch value into a FlixelString without returning an intermediate String.

Methods

appendValue(FlixelString)

public void appendValue(FlixelString out)

Appends the current watch value to out. Implementations must not clear out; callers own the prefix and lifecycle.

Parameters:

NameDescription
outDestination buffer.