Help: topics for every new feature, a cheat sheet, and Try a demo spreads
Twelve new Help topics (menus, selecting and resizing, nested groups, themes, List view, the Book, rolling more than once, pausing, costs, one table adjusting another, sheets and saving, pictures, phones), and a Keyboard shortcuts topic split into keys, mouse and touch. Topics with [demo]key[/demo] get a 'Try a demo spread' link: DemoSpreads builds a small example, DemoMode shows it unsaved and unlisted with Keep a copy and Back to my spread. --demo=KEY opens one from the command line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
57041d41b3
commit
b1616373be
11 changed files with 374 additions and 7 deletions
119
core/demo_spreads.gd
Normal file
119
core/demo_spreads.gd
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
class_name DemoSpreads
|
||||
extends RefCounted
|
||||
## Small example spreads, one per feature, opened from Help ("Try a demo").
|
||||
## They're built here, opened unsaved, and never listed with the user's
|
||||
## spreads. Each is a spread dictionary (the file format) kept tiny.
|
||||
|
||||
const TITLES := {
|
||||
"threads": "Demo: threads",
|
||||
"deck": "Demo: Deck mode",
|
||||
"repeats": "Demo: rolling more than once",
|
||||
"pause": "Demo: pausing a roll",
|
||||
"costs": "Demo: options that cost",
|
||||
"limits": "Demo: one table adjusting another",
|
||||
"book": "Demo: the Book",
|
||||
"groups": "Demo: groups inside groups",
|
||||
"sheet": "Demo: a sheet",
|
||||
}
|
||||
|
||||
|
||||
static func has(key: String) -> bool:
|
||||
return TITLES.has(key)
|
||||
|
||||
|
||||
static func build(key: String) -> TowerBoard:
|
||||
var d: Dictionary = _spec(key)
|
||||
d["format_version"] = TowerBoard.FORMAT_VERSION
|
||||
d["id"] = "demo-" + key
|
||||
d["name"] = TITLES.get(key, "Demo")
|
||||
var b := TowerBoard.new()
|
||||
b.load_dict(d)
|
||||
for p in b.book:
|
||||
b.sync_page(p.id)
|
||||
return b
|
||||
|
||||
|
||||
static func _t(id: String, name: String, x: int, y: int, entries: Array, extra: Dictionary = {}) -> Dictionary:
|
||||
var list: Array = []
|
||||
for i in entries.size():
|
||||
var e: Variant = entries[i]
|
||||
list.append(e if e is Dictionary else {"id": "e%d" % i, "text": str(e)})
|
||||
var t := {"id": id, "name": name, "x": x, "y": y, "entries": list}
|
||||
t.merge(extra, true)
|
||||
return t
|
||||
|
||||
|
||||
static func _e(id: String, text: String, extra: Dictionary = {}) -> Dictionary:
|
||||
var e := {"id": id, "text": text}
|
||||
e.merge(extra, true)
|
||||
return e
|
||||
|
||||
|
||||
static func _spec(key: String) -> Dictionary:
|
||||
match key:
|
||||
"threads":
|
||||
return {"tables": [
|
||||
_t("weather", "Weather", 40, 60, [_e("w1", "Clear skies", {"pipes": ["event"]}), _e("w2", "Storm", {"pipes": ["event", "shelter"]})]),
|
||||
_t("event", "Event", 380, 40, ["A traveller waves", "Tracks in the mud", "A lost coin"]),
|
||||
_t("shelter", "Shelter", 380, 300, ["A cave", "An old barn"]),
|
||||
]}
|
||||
"deck":
|
||||
return {"tables": [_t("roles", "Party roles", 40, 60, ["Scout", "Cook", "Map keeper", "Lookout"],
|
||||
{"card_mode": true, "deck_empty": "stop", "deck_empty_text": "Everyone has a role"})]}
|
||||
"repeats":
|
||||
return {"tables": [
|
||||
_t("chest", "Open the chest", 40, 60, [
|
||||
_e("c1", "Coins (add three rolls)", {"pipes": [{"table": "coins", "count": 3, "combine": "sum"}]}),
|
||||
_e("c2", "Best of two gems", {"pipes": [{"table": "gems", "count": 2, "combine": "max"}]}),
|
||||
_e("c3", "Pick one of three trinkets", {"pipes": [{"table": "trinket", "count": 3, "combine": "choose"}]})]),
|
||||
_t("coins", "Coins", 440, 0, ["10", "20", "30", "40", "50", "60"]),
|
||||
_t("gems", "Gems", 440, 360, ["1", "2", "3", "4", "5", "6"], {"dice": "1d6"}),
|
||||
_t("trinket", "Trinket", 440, 720, ["A bent key", "A glass eye", "A tiny bell", "A pressed flower"]),
|
||||
]}
|
||||
"pause":
|
||||
return {"tables": [
|
||||
_t("door", "The old door", 40, 60, [_e("d1", "It creaks open…", {"pipes": [{"table": "inside", "pause": true}]})]),
|
||||
_t("inside", "Inside", 420, 60, ["A dusty library", "A sleeping dragon", "An empty room"]),
|
||||
]}
|
||||
"costs":
|
||||
return {"tables": [
|
||||
_t("pts", "Points", 40, 40, [_e("v", "")], {"kind": "variable", "var_name": "points", "initial": "2"}),
|
||||
_t("loot", "Find loot", 40, 260, ["A rusty sword", "A torn map", "A copper ring"], {"dice": "1d3"}),
|
||||
_t("again", "Happy with it?", 420, 260, [
|
||||
_e("k", "Keep it"),
|
||||
_e("r", "Reroll the loot", {"cost": {"value": "@points", "amount": "1"}, "pipes": ["loot"]})],
|
||||
{"kind": "choice", "choice": "pick", "prompt": "Spend a point to reroll?"}),
|
||||
]}
|
||||
"limits":
|
||||
return {"tables": [
|
||||
_t("feature", "Planet feature", 40, 60, [
|
||||
_e("f1", "Thick haze (atmosphere at least 7)", {"effects": "@atmo_min = 7", "pipes": ["atmo"]}),
|
||||
_e("f2", "Nothing special", {"effects": "@atmo_min = 2", "pipes": ["atmo"]})]),
|
||||
_t("atmo", "Atmosphere", 440, 40, [
|
||||
_e("a1", "Thin", {"range": [2, 6]}), _e("a2", "Standard", {"range": [7, 9]}), _e("a3", "Dense", {"range": [10, 12]})],
|
||||
{"dice": "2d6", "roll_floor": "@atmo_min"}),
|
||||
]}
|
||||
"book":
|
||||
return {"book": [{"id": "p_sword", "name": "Sword of Holy Light",
|
||||
"text": "[b][color=#c99a1c]The Sword of Holy Light[/color][/b]", "details": "Glows near the undead.", "tags": ["weapon"]}],
|
||||
"tables": [
|
||||
_t("goblin", "Goblin loot", 40, 60, ["A bent spoon", _e("s", "", {"page": "p_sword"})]),
|
||||
_t("dragon", "Dragon hoard", 420, 60, ["A mountain of coins", _e("s", "", {"page": "p_sword"})]),
|
||||
]}
|
||||
"groups":
|
||||
return {"groups": [
|
||||
{"id": "g_world", "name": "World", "x": 20, "y": 0, "w": 800, "h": 520, "members": ["region"]},
|
||||
{"id": "g_town", "name": "Town", "x": 60, "y": 230, "w": 700, "h": 260, "members": ["shop", "inn"], "parent": "g_world"}],
|
||||
"tables": [
|
||||
_t("region", "Region", 60, 70, ["Hills", "Coast", "Forest"]),
|
||||
_t("shop", "Shop", 100, 300, ["Bakery", "Smithy"]),
|
||||
_t("inn", "Inn", 420, 300, ["The Grey Goose", "The Lantern"]),
|
||||
]}
|
||||
"sheet":
|
||||
return {"tables": [
|
||||
_t("hero", "New hero", 40, 60, [_e("h", "Roll a hero", {"pipes": [{"table": "name", "save_as": "@name"}, {"table": "job", "save_as": "@job"}, "sheet"]})]),
|
||||
_t("name", "Name", 400, 20, ["Ash", "Briar", "Corin", "Dana"]),
|
||||
_t("job", "Job", 400, 240, ["Baker", "Guard", "Thief", "Bard"]),
|
||||
_t("sheet", "Hero sheet", 760, 60, [_e("s", "[b]Name:[/b] {@name}\n[b]Job:[/b] {@job}")], {"kind": "sheet"}),
|
||||
]}
|
||||
return {"tables": []}
|
||||
1
core/demo_spreads.gd.uid
Normal file
1
core/demo_spreads.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://vc1thcoyv2vo
|
||||
|
|
@ -66,6 +66,8 @@ A thread carries the roll from a result to another card.
|
|||
- [b]Otherwise[/b] runs the thread only when none of the result's Only if threads ran.
|
||||
- [b]Inputs[/b] pass values to a card that declares them.
|
||||
|
||||
[demo]threads[/demo]
|
||||
|
||||
# Roll modifiers
|
||||
A ranged table can add a [b]modifier[/b] to its dice, for rules like "roll 1d20 and add your Luck".
|
||||
- In Build mode, select the card and set the modifier in the inspector: [b]Add[/b] a value, [b]Subtract[/b] one, or write your own.
|
||||
|
|
@ -87,6 +89,8 @@ Deck mode decks ignore the modifier.
|
|||
|
||||
[b]Party Roles[/b] in the sample is a deck: hand one role to each player, and nobody gets the same role twice until you shuffle.
|
||||
|
||||
[demo]deck[/demo]
|
||||
|
||||
# Choice cards
|
||||
A choice card stops the roll and asks the player. Add one from [b]+ Card ▾[/b].
|
||||
- [b]Which option[/b] lists the card's options to pick from. [b]Random[/b] is always offered too. The picked option runs exactly as if it had been rolled: its changes happen and its threads follow.
|
||||
|
|
@ -148,6 +152,74 @@ A template is a saved card, group or selection that you can insert again, with b
|
|||
- Insert one from [b]+ Card ▾ → From template…[/b].
|
||||
- Built-in templates include a skill check, ask-and-repeat, a pick menu, a counter and a simple sheet.
|
||||
|
||||
# Menus: right-click and ☰
|
||||
Right-click almost anything for what you can do with it. On a phone or tablet, press and hold instead.
|
||||
- [b]A card[/b]: roll it, roll it several times, shuffle its deck, collapse it, and in Build its settings, colour, template and delete.
|
||||
- [b]A thread[/b]: go to either end, and in Build edit it, colour it or delete it.
|
||||
- [b]A group[/b]: expand or collapse it, and in Build its details, template, ungroup or delete.
|
||||
- [b]Empty space[/b]: a new card right there, group the selection, search, shuffle all decks, fit the spread, List view, the Book and the theme.
|
||||
The [b]☰[/b] button in the top bar has the same things as right-clicking empty space.
|
||||
|
||||
# Selecting, moving and resizing
|
||||
- In Build, drag a box on empty space to select cards and groups. Hold [b]Ctrl[/b] or [b]Shift[/b] to add to the selection.
|
||||
- Drag any selected card or group and everything selected moves together.
|
||||
- Drag the small lines in a card's bottom-right corner to make it wider or taller; a taller card's results scroll inside it. Double-click the corner to go back to its own size.
|
||||
- Cards can go anywhere: there's no edge to the spread.
|
||||
- Zoomed far out, cards just show their names when you hover. You can still drag them and right-click them, and in Play a click rolls them.
|
||||
|
||||
# Groups inside groups
|
||||
Groups can hold other groups. Select a group (drag a box around it) along with any cards, and press [b]Ctrl+G[/b]: the new group holds them all. Closing the outer group hides everything inside it. [b]Ungroup[/b] hands the contents to the group around it.
|
||||
[demo]groups[/demo]
|
||||
|
||||
# Colours and themes
|
||||
- [b]View ▾ → Theme…[/b] picks a theme and lets you change its colours, the background and panel gradients, the background pattern, the card border and the logo. Changes to a built-in theme are saved as a theme of your own.
|
||||
- Give a card or a thread its own colour from its right-click menu ([b]Colour[/b]) or in the inspector, to sort things at a glance.
|
||||
|
||||
# List view
|
||||
[b]List view[/b] (View ▾, ☰ or right-click the spread) shows every card as a plain list, for when you'd rather not use the spread.
|
||||
- Folders are groups. [b]+ Folder[/b] makes one; drag cards onto a folder, or a folder onto another.
|
||||
- Drag cards up and down to put them in your own order.
|
||||
- [b]←2 →3[/b] counts the threads coming in and going out; hover to see where they lead.
|
||||
- Click [b]Roll[/b] to roll a card. Double-click a card to find it on the spread.
|
||||
- The list has its own search box.
|
||||
|
||||
# The Book
|
||||
The [b]Book[/b] holds [b]Pages[/b]: results you want to use on more than one table, with their formatting, details, tags and picture.
|
||||
- Open it from View ▾, ☰ or right-click the spread. [b]+ Page[/b] adds one; in Build, a result's inspector has [b]Save to the Book[/b].
|
||||
- Drag a page onto a result to use it there, or onto a card to add it as a new result. Results using a page show a small §.
|
||||
- Edit a page and every result using it changes. Change a result's own text and it stops following the page ([b]Unlink[/b] does the same).
|
||||
[demo]book[/demo]
|
||||
|
||||
# Rolling more than once
|
||||
- A thread can roll its card several times ([b]Rolls 3 times[/b] in the thread's inspector). Then choose what happens: [b]Keep every roll[/b], [b]Add them together[/b], [b]Keep the highest[/b], [b]Keep the lowest[/b] or [b]Let me choose[/b]. Rolls that aren't kept are faded in the tray, and don't follow their own threads.
|
||||
- [b]Roll several times…[/b] on a card's menu rolls its whole chain as many times as you like (five villagers, ten treasures) and shows every result together, ready to copy.
|
||||
[demo]repeats[/demo]
|
||||
|
||||
# Pausing a roll
|
||||
Tick [b]Wait for me first[/b] on a thread and the roll stops there, with [b]Continue ▸[/b] and [b]Stop here[/b] in the tray. Use it to reveal something a piece at a time. If you roll something else meanwhile, the paused roll waits in the tray until you continue it.
|
||||
[demo]pause[/demo]
|
||||
|
||||
# Options that cost
|
||||
An option on a [b]Which option[/b] card can cost something: in its inspector, [b]Costs [1] of [Points][/b]. Picking it takes that away; when there isn't enough, the option is greyed out and says why. An option such as [b]Reroll[/b] that threads back to the loot card and costs a point gives players a spend-a-point reroll.
|
||||
[demo]costs[/demo]
|
||||
|
||||
# One table adjusting another
|
||||
A ranged card can have limits: [b]Never below[/b] and [b]Never above[/b], each a number or a value. An earlier result can set that value with a change, so it adjusts a later roll. For example "Thick haze" sets [b]Atmo min[/b] to 7, and Atmosphere is set to never go below Atmo min. To push a later roll up or down instead, give it a [topic]Roll modifiers[/topic] value that the earlier result sets. [b]Why this?[/b] says when a limit moved a roll.
|
||||
[demo]limits[/demo]
|
||||
|
||||
# Sheets and saving results
|
||||
A [b]Sheet[/b] card shows values as a finished page, such as a character. In its inspector, [b]+ Add a line for[/b] a value adds a "Name: value" line for you.
|
||||
To keep a result outside the app, use the tray's [b]Copy ▾ → Save as a file[/b]: plain text, Markdown, or a web page you can open in a browser and print as a PDF. A roll that reached a sheet saves the sheet.
|
||||
[demo]sheet[/demo]
|
||||
|
||||
# Pictures
|
||||
A result or a Book page can have a picture: [b]Picture → Choose…[/b] in its inspector or page. It shows as a small picture on the card and a bigger one when you hover. Pictures are kept inside the spread, so exports and imports bring them along.
|
||||
|
||||
# On a phone or tablet
|
||||
- The list fills the screen; [b]Spread[/b] and [b]List[/b] swap between them.
|
||||
- Press and hold for the right-click menu. Two fingers move and zoom the spread.
|
||||
- View, Help and Play/Build are in the [b]☰[/b] menu.
|
||||
|
||||
# Spreads, import and export
|
||||
A [b]spread[/b] is one layout of cards, saved under its own name. Use the switcher beside Play | Build (it shows the spread's name) to switch, or to make a new spread, rename, duplicate or delete one.
|
||||
|
||||
|
|
@ -179,14 +251,22 @@ Click any item in the report to jump to that card. A spread that can loop foreve
|
|||
- [b]Minimap[/b].
|
||||
|
||||
# Keyboard shortcuts
|
||||
## Keys
|
||||
- [b]F1[/b]: this help
|
||||
- [b]Shift-click[/b] a die: roll without the animation
|
||||
- [b]Ctrl+F[/b]: search
|
||||
- [b]M[/b]: show or hide the minimap
|
||||
- [b]Ctrl+wheel[/b]: zoom. [b]Shift+wheel[/b]: scroll sideways
|
||||
- [b]Ctrl+Z[/b]: undo
|
||||
- [b]Ctrl+Shift+Z[/b] or [b]Ctrl+Y[/b]: redo
|
||||
- [b]Ctrl+G[/b]: group the selected cards
|
||||
- [b]Ctrl-click[/b], [b]Shift-click[/b] or a drag box on empty space: select several cards and groups
|
||||
- [b]Ctrl+Z[/b]: undo. [b]Ctrl+Shift+Z[/b] or [b]Ctrl+Y[/b]: redo
|
||||
- [b]Ctrl+G[/b]: group the selected cards and groups
|
||||
- [b]Esc[/b]: clear the selection, or close a window
|
||||
- Double-click the tray's or the inspector's edge: reset its size
|
||||
- In a question pop-up: [b]1–9[/b] pick an option, [b]R[/b] Random, [b]M[/b] or [b]Tab[/b] look at the spread
|
||||
## Mouse
|
||||
- [b]Shift-click[/b] a die: roll without the animation
|
||||
- [b]Right-click[/b]: the menu for what's under the mouse
|
||||
- [b]Drag on empty space[/b] (Build): a selection box. Add [b]Ctrl[/b] or [b]Shift[/b] to add to the selection
|
||||
- [b]Middle-drag[/b], or [b]Space[/b] + drag: move around the spread
|
||||
- [b]Wheel[/b]: scroll. [b]Shift+wheel[/b]: sideways. [b]Ctrl+wheel[/b]: zoom
|
||||
- A card's bottom-right corner: drag to resize, double-click for its own size
|
||||
- Double-click the edge of the tray, inspector, list or Book: reset its size
|
||||
## Touch
|
||||
- Press and hold: the menu
|
||||
- Two fingers: move and zoom
|
||||
|
|
|
|||
63
tests/test_demos.gd
Normal file
63
tests/test_demos.gd
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
extends SceneTree
|
||||
## Help's demo spreads: every demo builds and rolls cleanly, Help links to
|
||||
## them, and opening one shows it unsaved with a way back.
|
||||
## Run: godot --headless --path . -s res://tests/test_demos.gd -- --sample
|
||||
|
||||
var _failures := 0
|
||||
var main: Main
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
if not OS.get_cmdline_user_args().has("--sample"):
|
||||
print("Run with -- --sample so the test can't touch saved data.")
|
||||
quit(2)
|
||||
return
|
||||
_test_builds()
|
||||
main = load("res://ui/main.tscn").instantiate()
|
||||
root.add_child(main)
|
||||
await _frames(5)
|
||||
await _test_open()
|
||||
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
|
||||
quit(1 if _failures else 0)
|
||||
|
||||
|
||||
func _test_builds() -> void:
|
||||
var rng := RandomNumberGenerator.new()
|
||||
for key: String in DemoSpreads.TITLES:
|
||||
var b := DemoSpreads.build(key)
|
||||
_check(not b.tables.is_empty() and b.id == "demo-" + key, "demo %s builds" % key)
|
||||
var start := b.tables[0] if b.tables[0].kind != RollTable.KIND_VARIABLE else b.tables[1]
|
||||
var tree := Roller.roll(b, start.id, rng)
|
||||
var bad := Roller.flatten(tree, []).filter(func(s: Dictionary) -> bool: return s.get("stop", false) and not s.get("deck_empty", false))
|
||||
_check(bad.is_empty(), "demo %s rolls cleanly: %s" % [key, str(bad.map(func(s: Dictionary) -> String: return str(s.get("text", ""))))])
|
||||
var book := DemoSpreads.build("book")
|
||||
_check(book.page_uses("p_sword") == 2, "the Book demo links two results to its page")
|
||||
var linked := book.get_table("goblin").entries[1]
|
||||
book.sync_page("p_sword")
|
||||
_check(linked.text.contains("Holy Light"), "and they show the page's text")
|
||||
var help := FileAccess.get_file_as_string("res://help/topics.txt")
|
||||
var re := RegEx.create_from_string("\\[demo\\]([a-z_]+)\\[/demo\\]")
|
||||
for m in re.search_all(help):
|
||||
_check(DemoSpreads.has(m.get_string(1)), "help's demo link %s exists" % m.get_string(1))
|
||||
_check(HelpDialog._inline("[demo]deck[/demo]").contains("url=demo:deck"), "a demo marker becomes a link")
|
||||
|
||||
|
||||
func _test_open() -> void:
|
||||
var before := main.data.id
|
||||
main.demo.open("deck")
|
||||
await _frames(3)
|
||||
_check(main.data.id == "demo-deck" and main.demo.active() and not main._saving_enabled, "a demo opens unsaved, with its bar")
|
||||
main.demo.back()
|
||||
await _frames(3)
|
||||
_check(not main.demo.active() and main.data.id == before, "Back to my spread returns")
|
||||
|
||||
|
||||
func _frames(n: int = 2) -> void:
|
||||
for i in n:
|
||||
await process_frame
|
||||
|
||||
|
||||
func _check(ok: bool, what: String) -> void:
|
||||
if not ok:
|
||||
_failures += 1
|
||||
print("FAIL ", what)
|
||||
1
tests/test_demos.gd.uid
Normal file
1
tests/test_demos.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b3vsrgew5p46s
|
||||
86
ui/demo_mode.gd
Normal file
86
ui/demo_mode.gd
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
class_name DemoMode
|
||||
extends RefCounted
|
||||
## A demo spread from Help (DemoSpreads): shown in place of your spread,
|
||||
## never saved and never listed. A bar above the spread offers Keep a copy
|
||||
## (saves it as a spread of your own) and Back to my spread.
|
||||
|
||||
var m: Main
|
||||
var _return_id := ""
|
||||
var _was_saving := false
|
||||
var _bar: PanelContainer
|
||||
|
||||
|
||||
func _init(p_main: Main) -> void:
|
||||
m = p_main
|
||||
|
||||
|
||||
func active() -> bool:
|
||||
return _bar != null and is_instance_valid(_bar)
|
||||
|
||||
|
||||
func open(key: String) -> void:
|
||||
if not DemoSpreads.has(key):
|
||||
return
|
||||
if not active():
|
||||
m._save_now()
|
||||
_return_id = m.data.id
|
||||
_was_saving = m._saving_enabled
|
||||
m._saving_enabled = false
|
||||
m.collections._show_collection(DemoSpreads.build(key))
|
||||
_show_bar(str(DemoSpreads.TITLES[key]))
|
||||
|
||||
|
||||
func back() -> void:
|
||||
_close_bar()
|
||||
m._saving_enabled = _was_saving
|
||||
var b: TowerBoard = null
|
||||
if m.library and _return_id != "":
|
||||
b = m.library.load_collection(_return_id)
|
||||
if b == null:
|
||||
b = SampleBoard.create()
|
||||
b.id = "fantasy-loot"
|
||||
b.name = "Fantasy Loot"
|
||||
m.collections._show_collection(b)
|
||||
|
||||
|
||||
## Saves the demo as a new spread of your own and leaves demo mode on it.
|
||||
func keep_copy() -> void:
|
||||
_close_bar()
|
||||
m._saving_enabled = _was_saving
|
||||
if m.library == null:
|
||||
m.toast("Spreads can't be saved in this session")
|
||||
return
|
||||
var copy := TowerBoard.new()
|
||||
copy.load_dict(m.data.to_dict())
|
||||
copy.name = str(m.data.name).trim_prefix("Demo: ").capitalize()
|
||||
copy.id = m.library.unique_id(LibraryStore.slugify(copy.name))
|
||||
if m.library.save(copy):
|
||||
m.collections._show_collection(copy)
|
||||
m.toast("Saved “%s” as your own spread" % copy.name)
|
||||
|
||||
|
||||
func _show_bar(title: String) -> void:
|
||||
_close_bar()
|
||||
_bar = PanelContainer.new()
|
||||
_bar.add_theme_stylebox_override("panel", Style.bordered(Style.box(Style.BG_DEEP, 10, [14, 8, 10, 8]), 1, Style.ACCENT))
|
||||
var h := HBoxContainer.new()
|
||||
h.add_theme_constant_override("separation", 10)
|
||||
_bar.add_child(h)
|
||||
var l := Style.make_label("%s · try it out; nothing here is saved" % title, Style.body_bold(), 15, Style.ON_BG)
|
||||
l.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
h.add_child(l)
|
||||
var keep := Style.bar_button("Keep a copy")
|
||||
keep.pressed.connect(keep_copy)
|
||||
h.add_child(keep)
|
||||
var back_b := Style.bar_button("Back to my spread", true)
|
||||
back_b.pressed.connect(back)
|
||||
h.add_child(back_b)
|
||||
m.board.add_child(_bar)
|
||||
# Along the bottom of the spread, clear of the cards at the top.
|
||||
_bar.set_anchors_and_offsets_preset(Control.PRESET_BOTTOM_LEFT, Control.PRESET_MODE_MINSIZE, 14)
|
||||
|
||||
|
||||
func _close_bar() -> void:
|
||||
if active():
|
||||
_bar.queue_free()
|
||||
_bar = null
|
||||
1
ui/demo_mode.gd.uid
Normal file
1
ui/demo_mode.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://wcyqau17x12i
|
||||
|
|
@ -10,6 +10,9 @@ extends ModalCard
|
|||
## [topic]Title[/topic] a link to another topic
|
||||
## Everything else is BBCode ([b], [i]) and blank lines split paragraphs.
|
||||
|
||||
## A topic's "Try a demo spread" link was clicked (key for DemoSpreads).
|
||||
signal demo_requested(key: String)
|
||||
|
||||
const PATH := "res://help/topics.txt"
|
||||
const LINK_COLOR := "#4f2b12"
|
||||
const CODE_COLOR := "#8a4a1c"
|
||||
|
|
@ -99,6 +102,8 @@ static func _inline(s: String) -> String:
|
|||
out += "[color=%s][b]%s[/b][/color]" % [CODE_COLOR, code]
|
||||
else:
|
||||
out += parts[i]
|
||||
var dre := RegEx.create_from_string("\\[demo\\]([a-z_]+)\\[/demo\\]")
|
||||
out = dre.sub(out, "[url=demo:$1][color=%s][b]▶ Try a demo spread[/b][/color][/url]" % LINK_COLOR, true)
|
||||
var re := RegEx.create_from_string("\\[topic\\](.+?)\\[/topic\\]")
|
||||
return re.sub(out, "[url=topic:$1][color=%s][u]$1[/u][/color][/url]" % LINK_COLOR, true)
|
||||
|
||||
|
|
@ -121,6 +126,9 @@ func _on_meta(meta: Variant) -> void:
|
|||
var s := str(meta)
|
||||
if s.begins_with("topic:"):
|
||||
show_topic(s.substr(6))
|
||||
elif s.begins_with("demo:"):
|
||||
close()
|
||||
demo_requested.emit(s.substr(5))
|
||||
|
||||
|
||||
## The window keeps one height while you move between topics.
|
||||
|
|
|
|||
|
|
@ -21,5 +21,6 @@ func setup(p_main: Main) -> void:
|
|||
## Opens the Help window at `topic` (the first topic when blank) and returns it.
|
||||
func open(topic: String = "") -> HelpDialog:
|
||||
var d := HelpDialog.new(topic)
|
||||
d.demo_requested.connect(func(key: String) -> void: m.demo.open(key))
|
||||
m._add_modal(d)
|
||||
return d
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ var list_view: ListView
|
|||
var mobile: MobileLayout
|
||||
## The Book panel (reusable results).
|
||||
var book: BookPanel
|
||||
## Help's demo spreads (shown unsaved).
|
||||
var demo: DemoMode
|
||||
|
||||
var _save_timer: Timer
|
||||
var _saving_enabled := true
|
||||
|
|
@ -94,6 +96,7 @@ func _init() -> void:
|
|||
inspecting = MainInspectorLink.new(self)
|
||||
cli = MainCli.new(self)
|
||||
selecting = MainSelection.new(self)
|
||||
demo = DemoMode.new(self)
|
||||
prompt_hook = rolling._ask_player
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -385,12 +385,16 @@ func _perf_frames(n: int, pan: Vector2) -> String:
|
|||
# --pack Build ▸ Arrange ▸ Pack collapsed groups
|
||||
# --perf print load and frame timings, then quit
|
||||
# --list, --book show List view, the Book
|
||||
# --demo=KEY open a Help demo spread (DemoSpreads)
|
||||
|
||||
func _run_nav_cli(args: PackedStringArray) -> void:
|
||||
if args.has("--minimap"):
|
||||
m.nav.set_minimap_visible(true)
|
||||
if args.has("--no-minimap"):
|
||||
m.nav.set_minimap_visible(false)
|
||||
var demo := _arg_value(args, "--demo")
|
||||
if demo != "":
|
||||
m.demo.open(demo)
|
||||
if args.has("--book"):
|
||||
m.book.set_shown(true)
|
||||
if args.has("--list"):
|
||||
|
|
|
|||
Loading…
Reference in a new issue