From 384d9954aedefcee6f132d2bdadca11fca682bd7 Mon Sep 17 00:00:00 2001 From: msg-programs Date: Sun, 23 Jul 2023 12:29:32 +0200 Subject: Massive refactor, see details Instead of creating a new widget instance every frame, instantiate once and update content. This means that every widget had to be updated to work like that. This also necessitated some ugly hackery for the dwarven HUD. Many other minor things like moving and renaming classes --- .../assets/skyblocker/tabhud/assignment.json | 6 +- .../skyblocker/tabhud/garden_info_screen.json | 88 --------------- .../skyblocker/tabhud/generic_info_screen.json | 69 ------------ .../skyblocker/tabhud/info/garden_info_screen.json | 70 ++++++++++++ .../tabhud/info/generic_info_screen.json | 70 ++++++++++++ .../skyblocker/tabhud/info/rift_info_screen.json | 48 ++++++++ .../resources/assets/skyblocker/tabhud/readme.md | 100 +++++++++++++++++ .../assets/skyblocker/tabhud/test_screen.json | 122 +++++++++++++++++++++ 8 files changed, 413 insertions(+), 160 deletions(-) delete mode 100644 src/main/resources/assets/skyblocker/tabhud/garden_info_screen.json delete mode 100644 src/main/resources/assets/skyblocker/tabhud/generic_info_screen.json create mode 100644 src/main/resources/assets/skyblocker/tabhud/info/garden_info_screen.json create mode 100644 src/main/resources/assets/skyblocker/tabhud/info/generic_info_screen.json create mode 100644 src/main/resources/assets/skyblocker/tabhud/info/rift_info_screen.json create mode 100644 src/main/resources/assets/skyblocker/tabhud/readme.md create mode 100644 src/main/resources/assets/skyblocker/tabhud/test_screen.json (limited to 'src/main/resources') diff --git a/src/main/resources/assets/skyblocker/tabhud/assignment.json b/src/main/resources/assets/skyblocker/tabhud/assignment.json index a7b8dd80..85c8f938 100644 --- a/src/main/resources/assets/skyblocker/tabhud/assignment.json +++ b/src/main/resources/assets/skyblocker/tabhud/assignment.json @@ -1,11 +1,11 @@ { - "screenA": { + "standard" : { "default": "generic_info_screen" }, - "screenB": { + "screenA": { "default": "empty_screen" }, - "screenC": { + "screenB": { "default": "empty_screen" } } \ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/tabhud/garden_info_screen.json b/src/main/resources/assets/skyblocker/tabhud/garden_info_screen.json deleted file mode 100644 index 3ddfdfc3..00000000 --- a/src/main/resources/assets/skyblocker/tabhud/garden_info_screen.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "widgets":[ - { - "name": "GardenSkillsWidget", - "alias": "gsw", - "args": null - }, - { - "name": "EventWidget", - "alias": "evw", - "args": true - }, - { - "name": "UpgradeWidget", - "alias": "uw", - "args": null - }, - { - "name": "ProfileWidget", - "alias": "pw", - "args": null - }, - { - "name": "EffectWidget", - "alias": "efw", - "args": null - }, - { - "name": "JacobsContestWidget", - "alias": "jcw", - "args": null - }, - { - "name": "CookieWidget", - "alias": "cw", - "args": null - } - ], - "layout": [ - { - "op": "stack", - "direction": "vertical", - "align": "center", - "apply_to": ["gsw", "evw", "uw"] - }, - { - "op": "stack", - "direction": "vertical", - "align": "center", - "apply_to": ["pw", "efw"] - }, - { - "op": "stack", - "direction": "vertical", - "align": "center", - "apply_to": ["jcw", "cw"] - }, - { - "op": "align", - "align": "center", - "apply_to": ["gsw", "evw", "uw"] - }, - { - "op": "collideAgainst", - "direction": "left", - "widget": "pw", - "colliders": ["gsw", "evw", "uw"] - }, - { - "op": "collideAgainst", - "direction": "left", - "widget": "efw", - "colliders": ["gsw", "evw", "uw"] - }, - { - "op": "collideAgainst", - "direction": "right", - "widget": "jcw", - "colliders": ["gsw", "evw", "uw"] - }, - { - "op": "collideAgainst", - "direction": "right", - "widget": "cw", - "colliders": ["gsw", "evw", "uw"] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/tabhud/generic_info_screen.json b/src/main/resources/assets/skyblocker/tabhud/generic_info_screen.json deleted file mode 100644 index 27a28008..00000000 --- a/src/main/resources/assets/skyblocker/tabhud/generic_info_screen.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "widgets":[ - { - "name": "SkillsWidget", - "alias": "sw" - }, - { - "name": "EventWidget", - "alias": "evw" - }, - { - "name": "UpgradeWidget", - "alias": "uw" - }, - { - "name": "ProfileWidget", - "alias": "pw" - }, - { - "name": "EffectWidget", - "alias": "efw" - }, - { - "name": "ElectionWidget", - "alias": "elw" - }, - { - "name": "CookieWidget", - "alias": "cw" - } - ], - "layout": [ - { - "op": "stack", - "direction": "vertical", - "align": "center", - "apply_to": ["sw", "evw", "uw"] - }, - { - "op": "stack", - "direction": "vertical", - "align": "center", - "apply_to": ["pw", "efw"] - }, - { - "op": "stack", - "direction": "vertical", - "align": "center", - "apply_to": ["elw", "cw"] - }, - { - "op": "align", - "reference": "horizontalCenter", - "apply_to": ["sw", "evw", "uw"] - }, - { - "op": "collideAgainst", - "direction": "left", - "widgets": ["pw", "efw"], - "colliders": ["sw", "evw", "uw"] - }, - { - "op": "collideAgainst", - "direction": "right", - "widgets": ["elw", "cw"], - "colliders": ["sw", "evw", "uw"] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/tabhud/info/garden_info_screen.json b/src/main/resources/assets/skyblocker/tabhud/info/garden_info_screen.json new file mode 100644 index 00000000..3e1556ef --- /dev/null +++ b/src/main/resources/assets/skyblocker/tabhud/info/garden_info_screen.json @@ -0,0 +1,70 @@ +{ + "widgets":[ + { + "name": "GardenSkillsWidget", + "alias": "gsw" + }, + { + "name": "EventWidget", + "alias": "evw", + "inGarden": true + }, + { + "name": "UpgradeWidget", + "alias": "uw" + }, + { + "name": "ProfileWidget", + "alias": "pw" + }, + { + "name": "EffectWidget", + "alias": "efw" + }, + { + "name": "JacobsContestWidget", + "alias": "jcw" + }, + { + "name": "CookieWidget", + "alias": "cw" + } + ], + "layout": [ + { + "op": "stack", + "direction": "vertical", + "align": "center", + "apply_to": ["gsw", "evw", "uw"] + }, + { + "op": "stack", + "direction": "vertical", + "align": "center", + "apply_to": ["pw", "efw"] + }, + { + "op": "stack", + "direction": "vertical", + "align": "center", + "apply_to": ["jcw", "cw"] + }, + { + "op": "align", + "reference": "horizontalCenter", + "apply_to": ["gsw", "evw", "uw"] + }, + { + "op": "collideAgainst", + "direction": "left", + "widgets": ["pw", "efw"], + "colliders": ["gsw", "evw", "uw"] + }, + { + "op": "collideAgainst", + "direction": "right", + "widgets": ["jcw", "cw"], + "colliders": ["gsw", "evw", "uw"] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/tabhud/info/generic_info_screen.json b/src/main/resources/assets/skyblocker/tabhud/info/generic_info_screen.json new file mode 100644 index 00000000..dcfa5138 --- /dev/null +++ b/src/main/resources/assets/skyblocker/tabhud/info/generic_info_screen.json @@ -0,0 +1,70 @@ +{ + "widgets":[ + { + "name": "SkillsWidget", + "alias": "sw" + }, + { + "name": "EventWidget", + "alias": "evw", + "inGarden": false + }, + { + "name": "UpgradeWidget", + "alias": "uw" + }, + { + "name": "ProfileWidget", + "alias": "pw" + }, + { + "name": "EffectWidget", + "alias": "efw" + }, + { + "name": "ElectionWidget", + "alias": "elw" + }, + { + "name": "CookieWidget", + "alias": "cw" + } + ], + "layout": [ + { + "op": "stack", + "direction": "vertical", + "align": "center", + "apply_to": ["sw", "evw", "uw"] + }, + { + "op": "stack", + "direction": "vertical", + "align": "center", + "apply_to": ["pw", "efw"] + }, + { + "op": "stack", + "direction": "vertical", + "align": "center", + "apply_to": ["elw", "cw"] + }, + { + "op": "align", + "reference": "horizontalCenter", + "apply_to": ["sw", "evw", "uw"] + }, + { + "op": "collideAgainst", + "direction": "left", + "widgets": ["pw", "efw"], + "colliders": ["sw", "evw", "uw"] + }, + { + "op": "collideAgainst", + "direction": "right", + "widgets": ["elw", "cw"], + "colliders": ["sw", "evw", "uw"] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/tabhud/info/rift_info_screen.json b/src/main/resources/assets/skyblocker/tabhud/info/rift_info_screen.json new file mode 100644 index 00000000..3eda517d --- /dev/null +++ b/src/main/resources/assets/skyblocker/tabhud/info/rift_info_screen.json @@ -0,0 +1,48 @@ +{ + "widgets":[ + { + "name": "RiftProfileWidget", + "alias": "profile" + }, + { + "name": "RiftStatsWidget", + "alias": "stats" + }, + { + "name": "ShenWidget", + "alias": "shen" + }, + { + "name": "CookieWidget", + "alias": "cookie" + }, + { + "name": "AdvertisementWidget", + "alias": "ad" + } + ], + "layout": [ + { + "op": "stack", + "direction": "vertical", + "align": "center", + "apply_to": ["stats", "ad"] + }, + { + "op": "stack", + "direction": "vertical", + "align": "center", + "apply_to": ["profile", "shen", "cookie"] + }, + { + "op": "align", + "reference": "leftOfCenter", + "apply_to": ["stats", "ad"] + }, + { + "op": "align", + "direction": "rightOfCenter", + "apply_to": ["profile", "shen", "cookie"] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/tabhud/readme.md b/src/main/resources/assets/skyblocker/tabhud/readme.md new file mode 100644 index 00000000..7167f561 --- /dev/null +++ b/src/main/resources/assets/skyblocker/tabhud/readme.md @@ -0,0 +1,100 @@ +# assignment.json +Assigns the screens to a type (standard, screenA, screenB). standard is shown when just pressing tab, A and B are shown when using other keys/the modifiers. +For every type, the concrete screens are mapped to the areas they are supposed to be shown in. See Appendix A for a list of valid areas. +To find the screen definition, ".json" is appended to the screen key, so specifying `"foo": "generic_info_screen"` will try to find `generic_info_screen.json` and assign this definition to the "foo" area. + +# Screen definition JSON +This file consists of one widgets section and one layout section. + +## Widget section +The widget section defines all of the widgets that a screen uses. It also defines an alias that is used in the layout section and possibly a widget's argument if its behaviour can be changed by one. +For a full list of widgets, their names and their arguments see Appendix B + +## Layout section +The layout section defines how the widgets are arranged on the screen. This is done using a pipeline; an ordered list of stages where each stage moves the widgets in some way. The initial position of the widgets is undefined. As a rule of thumb, every stage (except "Place", see below) only moves the widget in one direction, so at least two operations need to be done executed on each widget for it to be in a well defined position. A full list of operations and their arguments is found in Appendix C. + +# Appendices + +## Appendix A: Area identifiers +- default: Any area not explicitly listed in the type. + +## Appendix B: Widget identifiers and arguments + +- EmptyWidget: Generic "No data available" +- SkillsWidget: The player's skill levels and stats +- EventWidget: Info about current events. Arg `inGarden: true|false`: Is this widget displayed in the garden area? +- UpgradeWidget: Currently running upgrades +- ProfileWidget: Data about the player's profile +- EffectWidget: Currently active effects +- ElectionWidget: Info about the current mayor election +- CookieWidget: Info about your super cookie + +## Appendix C: Pipeline stages + +#### Align +- op: `align` +- reference: One of `horizontalCenter`, `verticalCenter`, `leftOfCenter`, `rightOfCenter`, `topOfCenter`, `botOfCenter` +- apply_to: List of widgets to individually apply this operation to. +- Moves a widget in *one* direction (up/down OR left/right) until it's positioned in the way described by `reference`. This reference may be thought of as a straight line, with some describing the screen's borders and others referring to it's two center axis. + +Example: align A and B with "horizontalCenter" +``` ++-----------+ +-----------+ +| | | | +| A | | -> A | +| | --> | | +| | | | +| B| | B <- | ++-----------+ +-----------+ +``` + +#### Collide +- op: `collideAgainst` +- direction: One of `left`, `right` +- widgets: List of widgets to individually move. +- colliders: List static reference widgets to "collide against". +- Moves a widget in the `direction` until it would overlap with any one of the colliders. Doesn't move the widget in the other direction, doesn't move the widget if it wouldn't collide with anything. + +Example: Collide A and B from the right with X, Y and Z +``` ++-----------+ +-----------+ +| A | | A | +| A XX | | -> AXX | +| XX | --> | XX | +| Y | | Y | +| Y BB| | -> BBY | ++-----------+ +-----------+ +``` + +#### Stack +- op: `stack` +- direction: One of `vertical`, `horizontal` +- align: One of `center`, `top`, `bot`, `left`, `right` +- apply_to: List of widgets to stack, order of the list is important (top -> bot or left -> right) +- Move the widgets vertically or horizontally as indicated by the `direction`. `align` indicates if the list is touching a screen border or is centered on the screen. This only works with borders in the direction of the stacking; combinations such as `vertical`/`left` are considered invalid and act like `align` was set to `center`. This only moves the widget in one direction so in order to get a clean list, an Align operation must be executed as well. + +Example: Stack A, B, C vertically/center-aligned, then align with leftOfCenter +``` ++-----------+ +-----------+ +-----------+ +| A | | v | | | +| | stack | A | align | -> A | +| C | --> | v B | --> | B <- | +| | | C ^ | | C <- | +| B | | | | | ++-----------+ +-----------+ +-----------+ +``` + +#### Place +- op: `place` +- where: One of `center` +- apply_to: Widget to place an the indicated position. +- Places a widget at some position, moving it in any direction as needed. Only makes sense to use on one widget at a time, as applying the same Place op to multiple widgtes causes them to be on top of each other. + +Example: Place A at "center" ++-----------+ +-----------+ +| | | | +| A | | -> v | +| | --> | A | +| | | | +| | | | ++-----------+ +-----------+ \ No newline at end of file diff --git a/src/main/resources/assets/skyblocker/tabhud/test_screen.json b/src/main/resources/assets/skyblocker/tabhud/test_screen.json new file mode 100644 index 00000000..2ffa802d --- /dev/null +++ b/src/main/resources/assets/skyblocker/tabhud/test_screen.json @@ -0,0 +1,122 @@ +{ + "widgets": [ + { + "name": "EmptyWidget", + "alias": "ew1" + }, + { + "name": "EmptyWidget", + "alias": "ew2" + }, + { + "name": "EffectWidget", + "alias": "ew3" + }, + { + "name": "EffectWidget", + "alias": "ew4" + }, + { + "name": "CookieWidget", + "alias": "ew5" + }, + { + "name": "CookieWidget", + "alias": "ew6" + }, + { + "name": "UpgradeWidget", + "alias": "ew7" + }, + { + "name": "UpgradeWidget", + "alias": "ew8" + }, + { + "name": "FireSaleWidget", + "alias": "ew9" + }, + { + "name": "FireSaleWidget", + "alias": "ew10" + }, + { + "name": "EventWidget", + "alias": "ew11", + "inGarden": true + }, + { + "name": "EventWidget", + "alias": "ew12", + "inGarden": true + } + ], + "layout": [ + { + "op": "stack", + "direction": "vertical", + "align": "top", + "apply_to": ["ew1", "ew2"] + }, + { + "op": "align", + "reference": "leftOfCenter", + "apply_to": ["ew1", "ew2"] + }, + { + "op": "stack", + "direction": "vertical", + "align": "center", + "apply_to": ["ew3", "ew4"] + }, + { + "op": "align", + "reference": "horizontalCenter", + "apply_to": ["ew3", "ew4"] + }, + { + "op": "stack", + "direction": "vertical", + "align": "bot", + "apply_to": ["ew5", "ew6"] + }, + { + "op": "align", + "reference": "rightOfCenter", + "apply_to": ["ew5", "ew6"] + }, + { + "op": "stack", + "direction": "horizontal", + "align": "left", + "apply_to": ["ew7", "ew8"] + }, + { + "op": "align", + "reference": "topOfCenter", + "apply_to": ["ew7", "ew8"] + }, + { + "op": "stack", + "direction": "horizontal", + "align": "center", + "apply_to": ["ew9", "ew10"] + }, + { + "op": "align", + "reference": "verticalCenter", + "apply_to": ["ew9", "ew10"] + }, + { + "op": "stack", + "direction": "horizontal", + "align": "right", + "apply_to": ["ew11", "ew12"] + }, + { + "op": "align", + "reference": "botOfCenter", + "apply_to": ["ew11", "ew12"] + } + ] +} \ No newline at end of file -- cgit