Adds the `doodad` binary which will be a command line tool to work with
Doodads and Levels and assist with development.
The `doodad` binary has subcommands like git and the first command is
`convert` which converts between image files (PNG or BMP) and Doodle
drawing files (Level or Doodad). You can "screenshot" a level into a PNG
or you can initialize a new drawing from a PNG.
* Add a tab bar to the top of the Palette window that has two
radiobuttons for "Palette" and "Doodads"
* UI: add the concept of a Hidden() widget and the corresponding Hide()
and Show() methods. Hidden widgets are skipped over when evaluating
Frame packing, rendering, and event supervision.
* The Palette Window in editor mode now displays one of two tabs:
* Palette: the old color swatch palette now lives here.
* Doodads: the new Doodad palette.
* The Doodad Palette shows a grid of buttons (2 per row) showing the
available Doodad drawings in the user's config folder.
* The Doodad buttons act as radiobuttons for now and have no other
effect. TODO will be making them react to drag-drop events.
* UI: added a `Children()` method as the inverse of `Parent()` for
container widgets (like Frame, Window and Button) to expose their
children. The BaseWidget just returns an empty []Widget.
* Console: added a `repl` command that keeps the dev console open and
prefixes every command with `$` filled out -- for rapid JavaScript
console evaluation.
* Increase the default window size from 800x600 to 1024x768.
* Move the drawing canvas in EditorMode to inside the EditorUI where it can
be better managed with the other widgets it shares the screen with.
* Slightly fix Frame packing bug (with East orientation) that was causing
right-aligned statusbar items to be partially cropped off-screen. Moved a
couple statusbar labels in EditorMode to the right.
* Add `Parent()` and `Adopt()` methods to widgets for when they're managed
by containers like the Frame.
* Add utility functions to UI toolkit for computing a widget's Absolute
Position and Absolute Rect, by crawling all parent widgets and summing
them up.
* Add `lib/debugging` package with useful stack tracing utilities.
* Add `make guitest` to launch the program into the GUI Test.
The command line flag is: `doodle -guitest`
* Console: add a `close` command which returns to the MainScene.
* Initialize the font cache directory (~/.cache/doodle/fonts) but don't
extract the fonts there yet.
* Create a configuration directory to store the user's local levels
and doodads. On Linux this is at ~/.config/doodle
* Unify the file loading and saving functions: you can type into the
console "edit example" and it will open `example.level` from your
levels folder or else `example.doodad` from the doodads folder, in the
appropriate mode.
* You can further specify the file extension: `edit example.doodad` and
it will load it from the doodads folder only.
* Any slash characters in a file name are taken literally as a relative
or absolute path.
* The UI Save/Load buttons now share the same code path as the console
commands, so the `save` command always saves as a Doodad when the
EditorScene is in Doodad Mode.
Adds the first features to Edit Mode to support creation of Doodad
files! The "New Doodad" button pops up a prompt for a Doodad size
(default 100px) and configures the Canvas widget and makes a Doodad
struct instead of a Level to manage.
* Move the custom Canvas widget from `level.Canvas` to `uix.Canvas`
(the uix package is for our custom UI widgets now)
* Rename the `doodads.Doodad` interface (for runtime instances of
Doodads) to `doodads.Actor` and make `doodads.Doodad` describe the
file format and JSON schema instead.
* Rename the `EditLevel()` method to `EditDrawing()` and it inspects the
file extension to know whether to launch the Edit Mode for a Level or
for a Doodad drawing.
* Doodads can be edited by using the `-edit` CLI flag or using the
in-game file open features (including `edit` command of dev console).
* Add a `Scrollable` boolean to uix.Canvas to restrict the keyboard
being able to scroll the level, for editing Doodads which have a fixed
size.
* Edit Mode now uses the Level object itself to keep the drawing data
rather than pull its Palette and Chunks out, so it can hang on to more
information. The Canvas widget is given references to the
Level.Palette and Level.Chunker via Canvas.LoadLevel()
* Fix the handoff between Edit Mode and Play Mode. They pass the Level
object back and forth and the Filename, because it's not part of the
Level. You can save the map with its original settings after returning
from Play Mode.
* Fix the collision detection in Play Mode. It broke previously when
palettes were added because of the difference between a render.Point
and a level.Pixel and it couldn't easily look up coordinates. The new
Chunker system provides a render.Point lookup API.
* All pixels are solid for collision right now, TODO is to return Swatch
information from the pixels touching the player character and react
accordingly (non-solid, fire flag, etc.)
* Remove the level.Grid type as it has been replaced by the Chunker.
* Clean up some unused variables and functions.
Starts the implementation of the chunk-based pixel storage system for
levels and drawings.
Previously the levels had a Pixels structure which was just an array of
X,Y and palette index triplets. The new chunk system divides the map up
into square chunks, and lets each chunk manage its own memory layout.
The "MapAccessor" layout is implemented first which is a map of X,Y
coordinates to their Swatches (pointer to an index of the palette). When
serialized the MapAccessor maps the "X,Y": "index" similarly to the old
Pixels array.
The object hierarchy for the chunk system is like:
* Chunker: the manager of the chunks who keeps track of the ChunkSize
and a map of "chunk coordinates" to the chunk in charge of it.
* Chunk: a part of the drawing ChunkSize length square. A chunk has a
Type (of how it stores its data, 0 being a map[Point]Swatch and 1
being a [][]Swatch 2D array), and the chunk has an Accessor which
implements the underlying type.
* Accessor: an interface for a Chunk to provide access to its
pixels.
* MapAccessor: a "sparse map" of coordinates to their Swatches.
* GridAccessor: TBD, will be a "dense" 2D grid of Swatches.
The JSON files are loaded in two passes:
1. The chunks only load their swatch indexes from disk.
2. With the palette also loaded, the chunks are "inflated" and linked
to their swatch pointers.
Misc changes:
* The `level.Canvas` UI widget switches from the old Grid data type to
being able to directly use a `level.Chunker`
* The Chunker is a shared data type between the on-disk level format and
the actual renderer (level.Canvas), so saving the level is easy
because you can just pull the Chunker out from the canvas.
* ChunkSize is stored inside the level file and the default value is at
balance/numbers.go: 1000
The `level.Canvas` is a widget that holds onto its Palette and Grid and
has interactions to allow scrolling and editing the grid using the
swatches available on the palette.
Thus all of the logic in the Editor Mode for drawing directly onto the
root SDL surface are now handled inside a level.Canvas instance.
The `level.Canvas` widget has the following properties:
* Like any widget it has an X,Y position and a width/height.
* It has a Scroll position to control which slice of its drawing will be
visible inside its bounding box.
* It supports levels having negative coordinates for their pixels. It
doesn't care. The default Scroll position is (0,0) at the top left
corner of the widget but you can scroll into the negatives and see the
negative pixels.
* Keyboard keys will scroll the viewport inside the canvas.
* The canvas draws only the pixels that are visible inside its bounding
box.
This feature will eventually pave the way toward:
* Doodads being dropped on top of your map, each Doodad being its own
Canvas widget.
* Using drawings as button icons for the user interface, as the Canvas
is a normal widget.
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
* Add ui.Window to easily create reusable windows with titles.
* Add a palette window (panel) to the right edge of the Edit Mode.
* Has Radio Buttons listing the colors available in the palette.
* Add palette support to Edit Mode so when you draw pixels, they take
on the color and attributes of the currently selected Swatch in your
palette.
* Revise the on-disk format to better serialize the Palette object to
JSON.
* Break Play Mode: collision detection fails because the Grid key
elements are now full Pixel objects (which retain their Palette and
Swatch properties).
* The Grid will need to be re-worked to separate X,Y coordinates from
the Pixel metadata to just test "is something there, and what is
it?"
* Added `BoxSize()` to Widget that reports the full box size including
borders and margin.
* The Frame uses the `BoxSize()` of widgets to position them.
Reintroduces some padding issues (boxes on the GUI Test stick out of
bounds a bit) but is on the right track.
* Renamed `Padding` to `Margin` on the Widget object, since the Margin
is taken into consideration along with Outline and Border in computing
the widget's BoxSize.
* Restructured the Label widget to take a Text or TextVariable property
and the font settings (render.Text) are in a new `Font` property.
CheckButton is a generic component based on Button that additionally
takes a *bool variable to manage. When the CheckButton is clicked or
unclicked, it will toggle the bool var and its border style will "stick"
in or out depending on the state.
Checkbox is a Frame widget that wraps a CheckButton and another child
widget, such as a Label. Interacting with the child widget will forward
all of its mouse events to the CheckButton, so that the Label could be
clicked instead of just the box itself.
* Frame.Pack() now supports Fill and Expand and works like Tk.
* The GUITest Scene now draws a large window with two fixed side panels,
an expanding body panel, and a fixed footer with buttons. The panels
are filled with other buttons and widgets showing off the Frame
packing.
These properties will be globally useful to all sorts of Widgets and
have been moved from the Button up into the Common widget, and its
interface extended to configure these:
* Padding int32
* Background color
* Foreground color
* Border size, color and style (default solid; raised; sunken)
* Outline size and color
The button adjusts its border style from "raised" to "sunken" for
MouseDown events and its Background color for MouseOver events. Other
widgets such as Labels and Frames will be able to have borders, paddings
and outlines too, but they will be off by default.
The Buttons can now be managed by a ui.Supervisor and be notified when
the mouse enters or leaves their bounding box and handle click events.
Current event handlers supported:
* MouseOver
* MouseOut
* MouseDown
* MouseUp
* Click
Each of those events are only fired when the state of the event has
changed, i.e. the first time the mouse enters the widget MouseOver is
called and then when the mouse leaves later, MouseOut is called.
A completed click event (mouse was released while pressed and hovering
the button) triggers both MouseOut and Click, so the button can pop
itself out and also run the click handler.
* The shell now supports an "eval" command, or "$" for short.
* Runs it in an Otto JavaScript VM.
* Some global variables are available, like `d` is the Doodle object
itself, `log`, `RGBA()` and `Point()`
* The shell supports paging through input history using the arrow keys.
* Added an initial Main Scene
With Labels and Buttons so far.
* Labels are pretty much complete, they wrap a render.Text and have a
Compute() method that returns their Width and Height when rendered
onto an SDL Surface.
* Buttons wrap a Label widget and Compute() its size and takes that into
consideration when rendering itself. Buttons render themselves from
scratch in a "Windows 95" themed way, with configurable colors, border
widths and outline.
* Add a debug view that draws the player bounding boxes.
* Improve the collision detection to add support for:
* Doodads being "Grounded" so gravity need not apply.
* Walking up hills, albeit a bit "bouncily"
* Harder to clip out of bounds
Known bugs:
* The Pixel format in the Grid has DX and DY attributes and
it wreaks havoc on collision detection in Play Mode when you
come straight from the editor. Reloading the map from disk to
play is OK cuz it lacks these attrs.
Implements the dev console in-game with various commands to start out
with.
Press the Enter key to show or hide the console. Commands supported:
new
Start a new map in Edit Mode.
save [filename.json]
Save the current map to disk. Filename is required unless you
have saved recently.
edit filename.json
Open a map from disk in Edit Mode.
play filename.json
Play a map from disk in Play Mode.
First pass at a level storage format to save and restore maps.
To save a map: press F12. It takes a screenshot PNG into the
screenshots/ folder and outputs a map JSON in the working directory.
To restore a map: "go run cmd/doodle/main.go map.json"