Skip to content

Commit

Permalink
Doc: update internal docs and TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
black-sliver committed Jan 3, 2024
1 parent b7bb773 commit 902dbf7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 148 deletions.
73 changes: 14 additions & 59 deletions doc/OUTLINE.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,34 @@
# PopTracker Overview

This is a rough overview of internals and what we (have to) provide and what dependencies we have.
This is a rough overview of internals and what we want to provide.

Check linked docs for specifics.

## Goal
- scriptable tracker and map tracker, similar to existing solutions
- open source, platform independent
- runs in browser and on desktop
- have a Makefile that builds WASM blob, Linux binaries, Windows exe
- OSX support?
- have a Makefile that builds WASM blob, Linux binaries, Windows exe and macOS app bundle
- auto-tracking support
- usb2snes interface
- see [AUTOTRACKING.md] for currently implemented things
- more TBD
- provide an interface that is compatible to existing packs
- maybe add nicer interfaces on top or in parallel

See [TODO.md](TODO.md) for current state of things.

## WASM work-arounds
- `while(true)` does not work in WASM, so we define an interface `App` that
- implements a mainloop on desktop
- hooks into AnimationFrame via `emscripten_set_main_loop` in WASM

## UI requirements
- item/status "icons" inside hbox/vbox/grid
- map display: custom widget
- map "icons" drawn in mapwidget's render()
- hover -> tooltips -> floating regular widgets/containers
- have "icons" be just widgets, state/image updated from back-end events/signals
- use one TrackerView(Tracker*) widget to link up state with ui
- we may require a "texture store" to support WebGL on mobile
- layout.json => LayoutNodes => Widgets

see [UILIB.md](UILIB.md) (outdated)

NOTE: UI needs a lot of rework.

see [UILIB.md](UILIB.md)

## Interface ideas
### Packs
```
class Pack abstracts away Filesystem
::Pack("path") loads a pack, where path can be a directory or .zip file containing a manifest.json
::ReadFile(std::string fn,std::string& buf) will read file `fn` of the package into buffer `buf` and return a result code (no exceptions)
static ::ListPacks() returns a list of packs
::ListVariants() returns a list of available variants for the pack
::getVariant() returns currently active variant (or "" if none is active)
::setVariant("variant") sets the active variant, used when resolving paths
```

Note that std::string allows easier integration with C code than a std::stream.
std::string allows easier integration with C code than a std::stream.

We may want to use mmap or raw pointer in the future, see [Ideal ZIP](#ideal-zip).

### Lua Glue
since packs use Lua to do actual stuff, we map C++ classes into Lua.
Since packs use Lua to do actual stuff, we map C++ classes into Lua.
See [luaglue/README.md](https://github.com/black-sliver/luaglue/blob/main/README.md) for the lua interface code.

### Game pack interface
Expand All @@ -63,33 +37,14 @@ see [PACKS.md](PACKS.md)
We do not use the data directly, but instead load it into objects via
Class::FromJSON, which are then used for to the actual (UI) implementation.

## WASM support
At some point PopTracker should be able to run inside a webbrowser using
[WASM](https://en.wikipedia.org/wiki/WebAssembly).
Most or all dependencies should work with emcc, but UI/window handling is not done yet nor is a virtual file system.

## Back-end requirements
- Lua VM
- JSON parser
- UI/Layout abstraction (JSON -> Widgets -> Pixels)

## Base System / Dependencies
- libsdl
- libsdl_ttf
- libfreetype as dependency of sdl_ttf
- libsdl_image
- libpng as dependency of sdl_image
- zlib
- liblua
- json.hpp - https://github.com/nlohmann/json + patch to allow trailing commas

## Linking
emcc for web/wasm deployment provides some (specialized) versions of some libs:
- SDL2
- SDL2_image
- SDL2_ttf
- libpng
- zlib
- and their dependencies

for now we link the libraries dynamically on Linux and use prebuilt SDL-devel (mingw) libs on Windows,
but a more comlpex source tree + Makefile could integrate them as well
- `while(true)` does not work in WASM, so we define an interface `App` that
- implements a mainloop on desktop
- hooks into AnimationFrame via `emscripten_set_main_loop` in WASM

## UI-Data-Bindings
- signal Tracker::onLayoutChanged -> Ui::TrackerView::relayout
Expand Down
4 changes: 2 additions & 2 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

## Misc

* [Project Overview](OUTLINE.md) (outdated)
* [TODO](TODO.md) (outdated)
* [Project Overview](OUTLINE.md)
* [TODO](TODO.md)
18 changes: 3 additions & 15 deletions doc/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,26 @@

Check [OUTLINE.md](OUTLINE.md) to get an overview of everything.

## Current Plans
see [github projects](https://github.com/black-sliver/PopTracker/projects) (outdated)

## Help wanted
- OSX .dmg
- Custom application icon
- Fancier GUI
- Better widgets ("real" buttons)
- Nicer icons (I'm not an artist)

## General Stuff
- isReachable optimizations:
- do not call into Lua from updateLocationState(): prebuild cache
- invalidate only parts of _reachableCache when toggling items?
- update location state on next frame instead of immediately (start of auto-tracking)
- try to determine if location state needs update?
- show version somewhere in the app
- MemoryWatch: only run callback if all bytes of a watch have been read to avoid potential races (this has to add race-free bool to SNES::readBlock)
- auto-tracking for N64?
- pins
- notes
- background color of groups/titles
- alignment of widgets inside widgets
- Makefile: 32bit exe (static linking is currently somewhat broken)
- Show error (+reason) when loading a pack fails
- Log/console/error window as part of the UI
- Log/console/error window as part of the UI (currently --console and stdout in shell/prompt exists)
- Remove toolbar and put everything inside a context menu on desktop?
- Update websocketpp, update asio (or use a different websocket implementation)
- included websocketpp is patched to allow std::thread on mingw
- included asio is the latest one that works with websocketpp 0.8.1
- Update websocketpp, update asio
- Item: `swap_actions: <bool>` (swaps left and right mouse button, alttpr)
- Map/Locations:
- number overlay on map (X unreachable red, Y reachable white)
Expand Down Expand Up @@ -75,17 +65,15 @@ see [github projects](https://github.com/black-sliver/PopTracker/projects) (outd
- a uniform logic for relayout has to be found
- a lot of hacks to make the current model somewhat work (see `// FIXME:`s and `// TODO:`s in source)
- Responsive UI
- Toolbar hover/pressed
- Pack-loading button-widget

## Random Notes
### Data additions
- Item::ID in json? Auto-generated at the moment
- Location::ID in json? Concat of names at the moment
- Unique ID for actual drops (locations' sections' checks) so we can have the same drop on two maps (detailed and overview)
- Location/section help/info (requirements to reach it)
- Location/section help/info/hover text (requirements to reach it)
### Other stuff
- enum class Ui::MouseButton in Mouse Events (instead of int and C-style enum)
- enum flags Ui::Map::LocationState with operator|
- (Evermizer: `settings_popup`) Layout: `header_background`
- (Evermizer) Layout: header_content: adds a button to the header
76 changes: 4 additions & 72 deletions doc/UILIB.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,7 @@
# UI system

This document is a collection of ideas and may not always be accurate/up to date.
*current implementation undocumented*

Current state of things is very messy, because I tried to just make it compatible to packs.

## Concepts
- Each window has its own drawing context (`Renderer`)
- Widgets may be bound to the drawing context they first drew to
- Widgets are implemented by overriding common methods
- Widgets should not have to know what their parents are
- we have one problem with tooltips and a dirty work-around
- `addChild` transfers ownership to container
- `removeChild` transfers ownership to caller
- `setSize()` should auto-size all children. Value given may be modified if too small.
- a layout step should generate all `MinSize`s, update actual size and emit `Signal`s when modifing any portion of the tree - this is incomplete

## UI main class
- `createWindow`: creates a window and adds it to the list of event receivers
- `render`: receives/handles/propagates events and calls `render` on all windows

## Widgets
- `Window` inherits `Container`
- `HBox` inherits `Container`: Horizontally oriented children
- `VBox` inherits `Container`: Vertically oriented children
- `Table` or `Grid` inherits `Container`: X x Y (equally sized) children
- `SimpleContainer` inherits `Container`: 1 full-size child (or managed by parent)
- `Tooltip` inherits `SimpleContanier`: styled background and border
- `Group` inherits `VBox`: 1 child + title
- `Dock` inserhits `Container`: children can be docked left, right, top bottom or be floating in the remaining space
- `Container` inherits `Widget`
- `Label` inherits `Widget`
- `LineEdit` inherits `Widget` or `TextEdit`?
- `TextEdit` inherits `Widget`
- `StagedImageButton` ? inherits `Widget`: scrolls through states with left/right mous, e.g. value or enable/disable
- `DoubleStagedImageButton` ? inherits `Widget`: scrolls through one state with left, other with right mouse, e.g. value + enable/disable
- `CountImageButton` ?

## Layout system
This needs a lot of work still.

- Original: not really clear, we try to implement widgets in a compatible manner
- Future: auto-size in both directions, see Concepts and TODO.md
- Hints/Values:
- `size`: always, actual size that was decided on
- manual `minSize`: future
- autom. `minSize`: always (required for docks/hboxes)
- manual `maxSize`: always (selectively implemented with hacks at the moment)
- autom. `maxSize`: future (required to transfer manual maxSize to parents)
- `autoSize`: always, what size (or aspect ratio) the actual content has
- `preferredSize`: future (lets child tell the size it wants)
- `hGrow`: future; original has `"h_alignment": "stretch"` though
- `vGrow`: future; original has `"v_alignment": "stretch"` though
- `hGravity`: future; original has `"h_alignment"` though
- `vGravity`: future; original has `"v_alignment"` though

## Common widget stuff
- tooltip: any widget/container
- background: image or color (or none/transparent)
- keepAspect: in relation to autoSize; TODO: in relation to preferredSize?

## Events
Using `class Signal`, we can "subscribe" lambdas to:
- `onMouseEnter (sender, position, Button, Modifiers)`
- `onMouseLeave (sender, position, Button, Modifiers)`
- `onClick (sender, position, Button, Modifiers)`
- `onBeforeChange (sender)`
- `onAfterChange (sender)`

Fixed member functions, only propagating from window to widgets:
- `ParentResized` (for future layout system)

## Checks to Widget mapping
Currently we have a generic UI::Item, which requires conversion of eveything to
stages (individual images).
## TODO
reiterate on how things are done. Auto-streching is under defined the way it is currently implemented.
See [TODO.md](TODO.md#ui-stuff-for-later).

0 comments on commit 902dbf7

Please sign in to comment.