Compare commits

..

No commits in common. "0905fb4e00141dc49d3f43248dbb9276a1da7326" and "fe0f52180b09513caa00ec39ec1995aef7cb4ce1" have entirely different histories.

75 changed files with 123 additions and 49677 deletions

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2025 Bruno Brito
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,154 +0,0 @@
en_US Hunspell Dictionary
Unknown Version
Thu Jul 16 09:31:00 UTC 2026
https://wordlist.aspell.net
README file for English Hunspell dictionaries derived from SCOWL.
These dictionaries are created using the speller/make-hunspell-dict
script in SCOWL.
The following dictionaries are available:
en_US (American)
en_CA (Canadian)
en_GB-ise (British with -ise/traditional spelling)
en_GB-ize (British with -ize/Oxford spelling)
en_AU (Australian)
en_US-large
en_CA-large
en_GB-large (with both -ise and -ize spelling)
en_AU-large
The default dictionaries correspond to SCOWL size 60 and, to encourage
consistent spelling, generally only include one spelling variant for a word.
The large dictionaries correspond to SCOWL size 70 and include common
spelling variants. The larger dictionaries, however, (1) have not been as
carefully checked for errors as the normal dictionaries and thus may contain
misspelled or invalid words; and (2) contain uncommon, yet valid, words that
might cause problems as they are likely to be misspellings of more common
words (for example, "ort" and "calender").
The American, Canadian, and Australian dictionaries are considered the
official version for Hunspell. The British ones are considered an
alternative version. The official ones are maintained by Marco A.G.Pinto at
https://proofingtoolgui.org.
For additional information, including information on how to contribute, see
https://wordlist.aspell.net/dicts/.
IMPORTANT CHANGES INTRODUCED ON 2026-02-22:
The Unicode "’" (U+2019) character was added to WORDCHARS so that Hunspell can
recognize words with the apostrophe. Based on testing, this should allow
Hunspell to recognize both "can't" and "can’t". The ASCII single quote at the
end of the word won't be considered part of the word, but the Unicode
character will. This means "'color'" is okay, but "‘color’" will get flagged
when Hunspell does the tokenization.
IMPORTANT CHANGES INTRODUCED IN 2016.11.20:
New Australian dictionaries thanks to the work of Benjamin Titze
(btitze@protonmail.ch).
IMPORTANT CHANGES INTRODUCED IN 2016.04.24:
The dictionaries are now in UTF-8 format instead of ISO-8859-1. This
was required to handle smart quotes correctly.
IMPORTANT CHANGES INTRODUCED IN 2016.01.19:
"SET UTF8" was changes to "SET UTF-8" in the affix file as some
versions of Hunspell do not recognize "UTF8".
ADDITIONAL NOTES:
The NOSUGGEST flag was added to certain taboo words. While I made an
honest attempt to flag the strongest taboo words with the NOSUGGEST
flag, I MAKE NO GUARANTEE THAT I FLAGGED EVERY POSSIBLE TABOO WORD.
The list was originally derived from Németh László, however I removed
some words which, while being considered taboo by some dictionaries,
are not really considered swear words in today's society.
COPYRIGHT, SOURCES, and CREDITS:
The English dictionaries come directly from SCOWL and is thus under
the same copyright terms as SCOWL. The affix file is a heavily
modified version of the original english.aff file, which was
released as part of Geoff Kuenning's Ispell and as such is covered by
his BSD license.
Copyright 2000-2026 by Kevin Atkinson
Permission to use, copy, modify, distribute, and sell any part of SCOWLv2, or
word lists created from it, is hereby granted without fee, provided that the
above copyright notice appears in all copies and that both the above
copyright notice and this notice appear in supporting documentation. Kevin
Atkinson makes no representations about the suitability of this database for
any purpose. It is provided "as is" without express or implied warranty.
SCOWL is derived from many sources, most of which are in the Public Domain.
Data from the Corpus of Contemporary American English (COCA) was also used.
All data from COCA comes from 3-gram data that is not freely available;
however, the usage is within the rights given by the NDA that was signed when
purchasing the data. More information on COCA is available at
https://www.english-corpora.org/coca/.
The primary source of words for SCOWL comes from 12dicts and ENABLE2K. Both
are in the Public Domain, but Alan Beale <biljir@pobox.com> deserves special
credit as he is the author of 12dicts and a major contributor to ENABLE2K. In
addition, he gave me an incredible amount of feedback and created a number of
special lists in order to help improve the overall quality of SCOWL.
The initial information for Australian English comes from Benjamin Titze:
Copyright 2016 by Benjamin Titze
Permission to use, copy, modify, distribute and sell this array, the
associated software, and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice appears
in all copies and that both that copyright notice and this permission
notice appear in supporting documentation. Benjamin Titze makes no
representations about the suitability of this array for any
purpose. It is provided "as is" without express or implied warranty.
Affix file Copyright:
Copyright 1993, Geoff Kuenning, Granada Hills, CA
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All modifications to the source code must be clearly marked as
such. Binary redistributions based on modified source code
must be clearly marked as modified versions in the documentation
and/or other materials provided with the distribution.
(clause 4 removed with permission from Geoff Kuenning)
5. The name of Geoff Kuenning may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Build Date: Thu Jul 16 09:31:00 UTC 2026
Wordlist Command: mk-list --accents=strip en_US 60

View file

@ -1,213 +0,0 @@
# Affix file for en_US Hunspell Dictionary.
#
# Unknown Version
# Thu Jul 16 09:31:00 UTC 2026
#
# https://wordlist.aspell.net
#
SET UTF-8
TRY esianrtolcdugmphbyfvkwzESIANRTOLCDUGMPHBYFVKWZ'
ICONV 1
ICONV ’ '
NOSUGGEST !
# ordinal numbers
COMPOUNDMIN 1
# only in compounds: 1th, 2th, 3th
ONLYINCOMPOUND c
# compound rules:
# 1. [0-9]*1[0-9]th (10th, 11th, 12th, 56714th, etc.)
# 2. [0-9]*[02-9](1st|2nd|3rd|[4-9]th) (21st, 22nd, 123rd, 1234th, etc.)
COMPOUNDRULE 2
COMPOUNDRULE n*1t
COMPOUNDRULE n*mp
WORDCHARS 0123456789’
PFX A Y 1
PFX A 0 re .
PFX I Y 1
PFX I 0 in .
PFX U Y 1
PFX U 0 un .
PFX C Y 1
PFX C 0 de .
PFX E Y 1
PFX E 0 dis .
PFX F Y 1
PFX F 0 con .
PFX K Y 1
PFX K 0 pro .
SFX V N 2
SFX V e ive e
SFX V 0 ive [^e]
SFX N Y 3
SFX N e ion e
SFX N y ication y
SFX N 0 en [^ey]
SFX X Y 3
SFX X e ions e
SFX X y ications y
SFX X 0 ens [^ey]
SFX H N 2
SFX H y ieth y
SFX H 0 th [^y]
SFX Y Y 1
SFX Y 0 ly .
SFX G Y 2
SFX G e ing e
SFX G 0 ing [^e]
SFX J Y 2
SFX J e ings e
SFX J 0 ings [^e]
SFX D Y 4
SFX D 0 d e
SFX D y ied [^aeiou]y
SFX D 0 ed [^ey]
SFX D 0 ed [aeiou]y
SFX T N 4
SFX T 0 st e
SFX T y iest [^aeiou]y
SFX T 0 est [aeiou]y
SFX T 0 est [^ey]
SFX R Y 4
SFX R 0 r e
SFX R y ier [^aeiou]y
SFX R 0 er [aeiou]y
SFX R 0 er [^ey]
SFX Z Y 4
SFX Z 0 rs e
SFX Z y iers [^aeiou]y
SFX Z 0 ers [aeiou]y
SFX Z 0 ers [^ey]
SFX S Y 4
SFX S y ies [^aeiou]y
SFX S 0 s [aeiou]y
SFX S 0 es [sxzh]
SFX S 0 s [^sxzhy]
SFX P Y 3
SFX P y iness [^aeiou]y
SFX P 0 ness [aeiou]y
SFX P 0 ness [^y]
SFX M Y 1
SFX M 0 's .
SFX B Y 3
SFX B 0 able [^aeiou]
SFX B 0 able ee
SFX B e able [^aeiou]e
SFX L Y 1
SFX L 0 ment .
REP 90
REP a ei
REP ei a
REP a ey
REP ey a
REP ai ie
REP ie ai
REP alot a_lot
REP are air
REP are ear
REP are eir
REP air are
REP air ere
REP ere air
REP ere ear
REP ere eir
REP ear are
REP ear air
REP ear ere
REP eir are
REP eir ere
REP ch te
REP te ch
REP ch ti
REP ti ch
REP ch tu
REP tu ch
REP ch s
REP s ch
REP ch k
REP k ch
REP f ph
REP ph f
REP gh f
REP f gh
REP i igh
REP igh i
REP i uy
REP uy i
REP i ee
REP ee i
REP j di
REP di j
REP j gg
REP gg j
REP j ge
REP ge j
REP s ti
REP ti s
REP s ci
REP ci s
REP k cc
REP cc k
REP k qu
REP qu k
REP kw qu
REP o eau
REP eau o
REP o ew
REP ew o
REP oo ew
REP ew oo
REP ew ui
REP ui ew
REP oo ui
REP ui oo
REP ew u
REP u ew
REP oo u
REP u oo
REP u oe
REP oe u
REP u ieu
REP ieu u
REP ue ew
REP ew ue
REP uff ough
REP oo ieu
REP ieu oo
REP ier ear
REP ear ier
REP ear air
REP air ear
REP w qu
REP qu w
REP z ss
REP ss z
REP shun tion
REP shun sion
REP shun cion
REP size cise

File diff suppressed because it is too large Load diff

View file

@ -1,22 +0,0 @@
[configuration]
entry_symbol = "hunspell_library_init"
compatibility_minimum = "4.2"
[libraries]
windows.debug.x86_64 = "res://addons/hunspell/bin/hunspell.windows.template_debug.x86_64.dll"
windows.release.x86_64 = "res://addons/hunspell/bin/hunspell.windows.template_release.x86_64.dll"
linux.debug.x86_64 = "res://addons/hunspell/bin/libhunspell.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://addons/hunspell/bin/libhunspell.linux.template_release.x86_64.so"
macos.debug = "res://addons/hunspell/bin/libhunspell.macos.template_debug.universal.dylib"
macos.release = "res://addons/hunspell/bin/libhunspell.macos.template_release.universal.dylib"
[dependencies]
windows.debug.x86_64 = {}
windows.release.x86_64 = {}
linux.debug.x86_64 = {}
linux.release.x86_64 = {}
macos.debug = {}
macos.release = {}

View file

@ -1 +0,0 @@
uid://dplbxl3b0l8gw

View file

@ -11,7 +11,7 @@ const TITLES := {
"pause": "Demo: pausing a roll", "pause": "Demo: pausing a roll",
"costs": "Demo: options that cost", "costs": "Demo: options that cost",
"limits": "Demo: one table adjusting another", "limits": "Demo: one table adjusting another",
"book": "Demo: the Lore Index", "book": "Demo: the Book",
"groups": "Demo: groups inside groups", "groups": "Demo: groups inside groups",
"sheet": "Demo: a sheet", "sheet": "Demo: a sheet",
} }

View file

@ -1,117 +0,0 @@
class_name RangeWeights
extends RefCounted
## How Build edits a ranged card (RollTable.range_edit):
## - Weights: each result says how many die faces it covers (TableEntry.weight);
## the ranges are laid out from it in row order (reflow). Dragging a row moves
## its share, and the ranges after it follow.
## - Ranges: each range is typed by hand, as printed books do. With auto_sort on,
## rows put themselves back in roll order after an edit or a drag.
## The ranges stay the stored truth either way, so rolling never looks at this.
const WEIGHTS := "weights"
const RANGES := "ranges"
## True when the card's ranges come from its weights.
static func uses_weights(t: RollTable) -> bool:
return t.is_ranged() and t.range_edit == WEIGHTS
## First value the weights lay out from: the dice's lowest roll, or, for a card
## whose totals clamp (a modifier or expression dice), where its first range starts.
static func start_value(t: RollTable) -> int:
if RollRange.clamps(t):
for e in t.entries:
if e.has_range:
return e.range_lo
return RollRange.natural(t).x
## Lays the ranges out from the weights, in row order. Weight 0 = no range.
static func reflow(t: RollTable) -> void:
var next := start_value(t)
for e in t.entries:
if e.weight <= 0:
e.has_range = false
continue
e.has_range = true
e.range_lo = next
e.range_hi = next + e.weight - 1
next = e.range_hi + 1
## Switches how the card is edited. Going to Weights reads each weight off its
## range and turns every gap between ranges into an empty result, so no roll
## changes. Going to Ranges keeps the ranges as they are.
static func set_mode(t: RollTable, mode: String) -> void:
if mode == t.range_edit:
return
t.range_edit = mode
if mode == WEIGHTS:
to_weights(t)
elif t.auto_sort:
sort_rows(t)
static func to_weights(t: RollTable) -> void:
sort_rows(t)
var out: Array[TableEntry] = []
var next := start_value(t)
for e in t.entries:
if not e.has_range:
e.weight = 0
out.append(e)
continue
if e.range_lo > next:
var gap := TableEntry.new(TowerBoard.new_id("e"), "")
gap.weight = e.range_lo - next
out.append(gap)
# Overlaps can't be kept as weights: the later row starts after the earlier one.
e.weight = maxi(1, e.range_hi - maxi(e.range_lo, next) + 1)
next = maxi(next, e.range_hi + 1)
out.append(e)
t.entries = out
reflow(t)
## Puts rows in roll order (by range start); rows without a range keep their
## order at the end. Returns true when anything moved.
static func sort_rows(t: RollTable) -> bool:
var before := t.entries.map(func(e: TableEntry) -> String: return e.id)
var ranged: Array[TableEntry] = []
var rest: Array[TableEntry] = []
for e in t.entries:
(ranged if e.has_range else rest).append(e)
ranged.sort_custom(func(a: TableEntry, b: TableEntry) -> bool: return a.range_lo < b.range_lo)
var sorted: Array[TableEntry] = []
sorted.append_array(ranged)
sorted.append_array(rest)
t.entries = sorted
return sorted.map(func(e: TableEntry) -> String: return e.id) != before
## After a weight, range or row-order edit: reflow (Weights) or auto-sort
## (Ranges). Returns true when auto-sort moved rows.
static func after_edit(t: RollTable) -> bool:
if not t.is_ranged():
return false
if t.range_edit == WEIGHTS:
reflow(t)
return false
return t.auto_sort and sort_rows(t)
## "Weights add up to 95 of 100: 5 short." when the weights don't cover the
## dice exactly; "" when they do, or when the card isn't edited by weight.
static func total_problem(t: RollTable) -> String:
if not uses_weights(t) or t.is_expr_dice():
return ""
var total := 0
for e in t.entries:
total += maxi(0, e.weight)
var nat := RollRange.natural(t)
var size := nat.y - nat.x + 1
if total == size or (total > size and RollRange.clamps(t)):
return ""
var off := "%d short" % (size - total) if total < size else "%d too many" % (total - size)
return "Weights add up to %d of %d: %s." % [total, size, off]

View file

@ -1 +0,0 @@
uid://c6tc7c6r4blyh

View file

@ -280,9 +280,6 @@ static func problems(t: RollTable) -> String:
var back := backwards(t) var back := backwards(t)
if back != "": if back != "":
return "The range %s runs backwards: make its start no bigger than its end. The card can't be rolled until then." % back return "The range %s runs backwards: make its start no bigger than its end. The card can't be rolled until then." % back
var weights_note := RangeWeights.total_problem(t)
if weights_note != "":
return weights_note
var lo := min_value(t) var lo := min_value(t)
var hi := max_value(t) var hi := max_value(t)
if clamps(t): if clamps(t):

View file

@ -71,14 +71,6 @@ var dice: String = DEFAULT_DICE
## Ranged tables: the modifier added to the dice, an expression ("@luck", ## Ranged tables: the modifier added to the dice, an expression ("@luck",
## "-@fatigue", "dm(@str)", "2"), or "" for none. ## "-@fatigue", "dm(@str)", "2"), or "" for none.
var dice_mod: String = "" var dice_mod: String = ""
## Ranged even while no result has a range (an empty card switched to Ranged).
## Results with ranges make a card ranged either way (is_ranged).
var ranged: bool = false
## How Build edits the ranges: RangeWeights.WEIGHTS or RangeWeights.RANGES.
## Cards made before this setting existed load as Ranges, so nothing moves.
var range_edit: String = "ranges"
## Ranges mode: rows put themselves back in roll order after edits and drags.
var auto_sort: bool = true
## Card mode: entries are drawn without replacement until the deck is empty. ## Card mode: entries are drawn without replacement until the deck is empty.
var card_mode: bool = false var card_mode: bool = false
## What happens when the deck runs out: "reshuffle" or "stop". ## What happens when the deck runs out: "reshuffle" or "stop".
@ -244,8 +236,6 @@ func is_kind(k: String) -> bool:
func is_ranged() -> bool: func is_ranged() -> bool:
if ranged:
return true
for e in entries: for e in entries:
if e.has_range: if e.has_range:
return true return true

View file

@ -31,11 +31,6 @@ static func to_dict(t: RollTable) -> Dictionary:
d["list_h"] = roundi(t.list_height) d["list_h"] = roundi(t.list_height)
if t.is_ranged(): if t.is_ranged():
d["dice"] = t.dice d["dice"] = t.dice
d["ranged"] = true
if t.range_edit == RangeWeights.WEIGHTS:
d["range_edit"] = RangeWeights.WEIGHTS
if not t.auto_sort:
d["auto_sort"] = false
if t.has_mod(): if t.has_mod():
d["dice_mod"] = t.dice_mod.strip_edges() d["dice_mod"] = t.dice_mod.strip_edges()
if t.card_mode: if t.card_mode:
@ -122,9 +117,6 @@ static func from_dict(d: Dictionary) -> RollTable:
elif int(d.get("die", 0)) > 1: elif int(d.get("die", 0)) > 1:
t.dice = "1d%d" % int(d["die"]) t.dice = "1d%d" % int(d["die"])
t.dice_mod = RollTable.expr_text(d.get("dice_mod", ""), "").strip_edges() t.dice_mod = RollTable.expr_text(d.get("dice_mod", ""), "").strip_edges()
t.ranged = bool(d.get("ranged", false))
t.range_edit = RangeWeights.WEIGHTS if str(d.get("range_edit", "")) == RangeWeights.WEIGHTS else RangeWeights.RANGES
t.auto_sort = bool(d.get("auto_sort", true))
t.card_mode = bool(d.get("card_mode", false)) t.card_mode = bool(d.get("card_mode", false))
t.deck_empty = "stop" if str(d.get("deck_empty", "reshuffle")) == "stop" else "reshuffle" t.deck_empty = "stop" if str(d.get("deck_empty", "reshuffle")) == "stop" else "reshuffle"
t.deck_empty_text = str(d.get("deck_empty_text", "")) t.deck_empty_text = str(d.get("deck_empty_text", ""))

View file

@ -1,47 +0,0 @@
class_name SpellWords
extends RefCounted
## Finds the words a spellchecker should look at in a field's text. Skips the
## parts that aren't prose: BBCode tags ([b], [color=#fff]), {placeholders},
## @values, [[Spread::Card]] links, numbers, dice ("2d6") and web addresses.
static var _word_re: RegEx
static var _skip_re: RegEx
static func _setup() -> void:
if _word_re != null:
return
# Letters, with inner apostrophes ("don't", "fortune-teller's" splits at -).
_word_re = RegEx.create_from_string("[\\p{L}]+(?:['’][\\p{L}]+)*")
# Spans to blank out first, so words inside them are never checked.
_skip_re = RegEx.create_from_string("\\[\\[[^\\]]*\\]\\]|\\[[^\\]\\n]*\\]|\\{[^}\\n]*\\}|@[\\w.]+|https?://\\S+|\\b\\d+d\\d+\\b|\\w*\\d\\w*")
## Vector2i(start, end) for each word to check, in text order (end exclusive).
static func ranges(text: String) -> Array[Vector2i]:
_setup()
var masked := text
for m in _skip_re.search_all(text):
var blank := " ".repeat(m.get_end() - m.get_start())
masked = masked.substr(0, m.get_start()) + blank + masked.substr(m.get_end())
var out: Array[Vector2i] = []
for m in _word_re.search_all(masked):
var word := m.get_string()
# Single letters and ALL-CAPS short forms (HP, NPC) are left alone.
if word.length() < 2 or (word.length() <= 4 and word == word.to_upper()):
continue
out.append(Vector2i(m.get_start(), m.get_end()))
return out
## The word range holding character `at`, or Vector2i(-1, -1).
static func range_at(text: String, at: int) -> Vector2i:
for r in ranges(text):
if at >= r.x and at <= r.y:
return r
return Vector2i(-1, -1)
## `text` with range `r` replaced by `word`.
static func replace(text: String, r: Vector2i, word: String) -> String:
return text.substr(0, r.x) + word + text.substr(r.y)

View file

@ -1 +0,0 @@
uid://d4ckh65ryw6rv

View file

@ -24,9 +24,6 @@ var groups: Array[TableGroup] = []
var book: Array[BookPage] = [] var book: Array[BookPage] = []
## Pictures: id -> base64 data (BoardImages). Only used ones are saved. ## Pictures: id -> base64 data (BoardImages). Only used ones are saved.
var images: Dictionary = {} var images: Dictionary = {}
## Words the spellchecker accepts in this spread ("Add to dictionary"): the
## setting's names and terms. Saved with the spread, so they travel with it.
var dictionary: Array[String] = []
static func new_id(prefix: String) -> String: static func new_id(prefix: String) -> String:
@ -216,8 +213,6 @@ func to_dict() -> Dictionary:
d["groups"] = gl d["groups"] = gl
if not book.is_empty(): if not book.is_empty():
d["book"] = book_list() d["book"] = book_list()
if not dictionary.is_empty():
d["dictionary"] = dictionary.duplicate()
var pics := BoardImages.used(self) var pics := BoardImages.used(self)
if not pics.is_empty(): if not pics.is_empty():
d["images"] = pics d["images"] = pics
@ -256,13 +251,6 @@ func load_dict(src: Dictionary) -> bool:
groups = loaded_groups groups = loaded_groups
clean_groups() clean_groups()
load_book(d.get("book", [])) load_book(d.get("book", []))
var words: Array[String] = []
var src_words: Variant = d.get("dictionary", [])
if src_words is Array:
for w: Variant in src_words:
if str(w).strip_edges() != "" and not words.has(str(w).strip_edges()):
words.append(str(w).strip_edges())
dictionary = words
# Undo snapshots carry no pictures: keep the ones already loaded. # Undo snapshots carry no pictures: keep the ones already loaded.
if d.get("images") is Dictionary: if d.get("images") is Dictionary:
images.merge(d["images"], true) images.merge(d["images"], true)

View file

@ -234,23 +234,6 @@ Each original file keeps one-line delegators, so callers are unchanged.
switcher's menu items run Callables (`CollectionSwitcher._calls`, id = index). switcher's menu items run Callables (`CollectionSwitcher._calls`, id = index).
- **Timing:** `tests/perf_roll.gd` (not in the suite). - **Timing:** `tests/perf_roll.gd` (not in the suite).
## 3g. Modules added 2026-11-15 (Build UX round)
- **Ranged cards:** `core/range_weights.gd` (Weights vs Ranges editing: `reflow`, `to_weights` turns
gaps into empty results, `sort_rows` = auto-sort, `total_problem`). `RollTable.ranged` keeps an
empty card ranged; `range_edit` ("ranges" for older files) and `auto_sort` are saved.
- **Inspector as one list:** `ui/inspector_list.gd` (sections for the card and each result; only
open ones build; `activate` points `selection`/`fields`/`effects` at the section clicked in),
`ui/inspector_range.gd` (a result's weight, range and position).
- **Dock tabs:** `ui/side_tabs.gd` (Build: Inspector | Lore Index; `BookPanel` is the Lore Index).
- **Rolling:** `ui/skip_animations.gd` (View ▾ setting); `ModalCard.animate_in` (pop-up entrance).
- **Look:** `ui/card_move_handle.gd` (Build grip on the header; `CardGrip` is the resize corner);
theme tokens `SELECTED` and `CARD_HEAD` (derived from CARD/CARD_SHADE when a theme omits it).
- **Build hint:** `ui/build_mode_hint.gd` (Play's greyed + Card, ☰ New card; `MainTopBar.toast_action`).
- **Spellcheck:** `core/spell_words.gd` (which words to check), `ui/spellcheck.gd` (Hunspell via the
Godot-Hunspell `SpellChecker` class if present; off on Android), `ui/spell_underline.gd` (wavy lines
and the right-click menu). Spread words: `TowerBoard.dictionary` ("dictionary" in the file).
`addons/hunspell/` holds the add-on's prebuilt libraries (Windows, Linux, macOS) and the en_US dictionary.
## 4. Data and storage ## 4. Data and storage
- **Collections:** `user://collections/<id>.json`, format_version 2 (`{format_version, id, - **Collections:** `user://collections/<id>.json`, format_version 2 (`{format_version, id,
name, tables, groups?}`). On Linux that's `~/.local/share/godot/app_userdata/TableTower/`. name, tables, groups?}`). On Linux that's `~/.local/share/godot/app_userdata/TableTower/`.

View file

@ -1,7 +1,7 @@
# Table Tarot (repo: TableTower) — Status and Plan # Table Tarot (repo: TableTower) — Status and Plan
**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-15 (Build UX round merged to **Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-14 (spread folders round 2
`main` and pushed) pushed to `main`)
The short page to read at the start of every session. Everything else is read only when needed: The short page to read at the start of every session. Everything else is read only when needed:
- `docs/ARCHITECTURE.md`: feature summary, file map (§3b lists the 2026-11-10 modules), storage, known gaps. - `docs/ARCHITECTURE.md`: feature summary, file map (§3b lists the 2026-11-10 modules), storage, known gaps.
@ -28,7 +28,7 @@ mascot, **Morgan Fortuna** ("Morgan"; they/them in any UI text, kept gender-neut
| Spread (a saved set of cards) | `TowerBoard`, `LibraryStore`, `collections/` | | Spread (a saved set of cards) | `TowerBoard`, `LibraryStore`, `collections/` |
| Thread | `pipes`, `PipeLayer` | | Thread | `pipes`, `PipeLayer` |
| Deck mode | `card_mode` | | Deck mode | `card_mode` |
| Lore Index / Lore Entry (reusable results; was Book / Page) | `book`, `BookPanel`, `BookPage`, `TableEntry.page` | | Book / Page (reusable results) | `book`, `BookPage`, `TableEntry.page` |
| Branch / Repeat (card kinds) | `router` / `loop` | | Branch / Repeat (card kinds) | `router` / `loop` |
| Ledger (card kind; "for the time being", user 2026-11-11) | variable card, `var_type: "collection"` | | Ledger (card kind; "for the time being", user 2026-11-11) | variable card, `var_type: "collection"` |
Card, Result, Change, Reset, Dice wording rules: `docs/HISTORY.md` §6 "Terminology". Card, Result, Change, Reset, Dice wording rules: `docs/HISTORY.md` §6 "Terminology".
@ -95,25 +95,7 @@ templates) is on the Theme Art Guide checklist.
**Spread folders round 2 (2026-11-14, pushed):** see §4 item 8. Hand-tested by the user: works. **Spread folders round 2 (2026-11-14, pushed):** see §4 item 8. Hand-tested by the user: works.
**Build UX round (2026-11-15, merged to `main` and pushed; all 50 suites pass).** From **Next, likely:** the user tries spread links; new playtest reports. Older open items in §4.
the user's list and an approved mockup ("Workday Job Mockup" artifact,
https://claude.ai/code/artifact/2ba0bb3e-d6d1-46db-8b39-efd7e3665918). Built: View ▾ Skip
animations (+ Shift); questions animate like pauses; pop-ups fade in; ranged cards edit by
**Weights** (default for cards made ranged; gaps become empty results; total warning) or
**Ranges** (auto-sort on by default); whole rows drag; empty cards can switch Plain/Ranged;
Inspector is one list (card + each result, collapsible; spread clicks open one, hand-opened stay);
result weight/range/position in the Inspector; thicker coloured header (`CARD_HEAD`), Build move
handle, green selection glow (`SELECTED`, also on the inspected card); Play's greyed + Card and ☰
New card point to Build; Book → Lore Index / Lore Entries, a tab beside the Inspector in Build;
spellcheck (Hunspell; per-spread dictionary; off on Android). Modules: ARCHITECTURE §3g.
**Spellcheck:** the Godot-Hunspell prebuilt libraries (MIT, github.com/brunogbrito/Godot-Hunspell)
are in `addons/hunspell/bin` with the user's OK (2026-11-15); Hunspell loads in Godot 4.7.2 and the
underlines were checked in a screenshot. Hunspell prints "Wrote dictionary file…" lines on load
(normal). **Open:** exports need `addons/hunspell/dictionaries/*` in each preset's `include_filter`
(export_presets.cfg holds uncommitted user edits: ask first); not tried in an exported build yet.
**Not hand-tested by the user yet** (only tests and screenshots): the whole round.
**Next, likely:** the user hand-tests the Build UX round; spread links; new playtest reports.
## 3b. Theme slots plan (2026-11-11, user-approved order) ## 3b. Theme slots plan (2026-11-11, user-approved order)
Mockups: "Morgan's Wardrobe" artifact (https://claude.ai/code/artifact/136b4ce8-1ef7-47ca-a39a-a75eb34d64b7): Mockups: "Morgan's Wardrobe" artifact (https://claude.ai/code/artifact/136b4ce8-1ef7-47ca-a39a-a75eb34d64b7):

View file

@ -196,7 +196,7 @@ Right-click almost anything for what you can do with it. On a phone or tablet, p
- [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 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 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]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 Lore Index and the theme. - [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. The [b]☰[/b] button in the top bar has the same things as right-clicking empty space.
# Selecting, moving and resizing # Selecting, moving and resizing
@ -223,11 +223,11 @@ Groups can hold other groups. Select a group (drag a box around it) along with a
- Click [b]Roll[/b] to roll a card. Double-click a card to find it on the spread. - 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 list has its own search box.
# The Lore Index # The Book
The [b]Lore Index[/b] holds [b]Lore Entries[/b]: results you want to use on more than one table, with their formatting, details, tags and picture. 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. In Build it is a tab beside the inspector. [b]+ Lore Entry[/b] adds one; in Build, a result's inspector has [b]Save to the Lore Index[/b]. - 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 Lore Entry onto a result to use it there, or onto a card to add it as a new result. Results using a Lore Entry show a small §. - 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 Lore Entry and every result using it changes. Change a result's own text and it stops following the Lore Entry ([b]Unlink[/b] does the same). - 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] [demo]book[/demo]
# Rolling more than once # Rolling more than once
@ -255,7 +255,7 @@ To keep a result outside the app, use the tray's [b]Copy ▾ → Save as a file[
[demo]sheet[/demo] [demo]sheet[/demo]
# Pictures # Pictures
A result or a Lore Entry can have a picture: [b]Picture → Choose…[/b] in its inspector or Lore Entry. 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. 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 # On a phone or tablet
- The list fills the screen; [b]Spread[/b] and [b]List[/b] swap between them. - The list fills the screen; [b]Spread[/b] and [b]List[/b] swap between them.
@ -314,7 +314,7 @@ Click any item in the report to jump to that card. A spread that can loop foreve
- [b]Middle-drag[/b], or [b]Space[/b] + drag: move around the spread - [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 - [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 - 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 Lore Index: reset its size - Double-click the edge of the tray, inspector, list or Book: reset its size
## Touch ## Touch
- Press and hold: the menu - Press and hold: the menu
- Two fingers: move and zoom - Two fingers: move and zoom

View file

@ -27,9 +27,7 @@ func _test_lists() -> void:
var play := _texts(Actions.card(main, t)) var play := _texts(Actions.card(main, t))
_check(play.has("Roll") and not play.has("Delete table"), "Play: a card can be rolled, not deleted: %s" % str(play)) _check(play.has("Roll") and not play.has("Delete table"), "Play: a card can be rolled, not deleted: %s" % str(play))
var bg := _texts(Actions.background(main, Vector2.ZERO)) var bg := _texts(Actions.background(main, Vector2.ZERO))
_check(bg.has("Search… Ctrl+F") and bg.has("Shuffle all decks") and not bg.has("New card from template…"), "Play spread menu: %s" % str(bg)) _check(bg.has("Search… Ctrl+F") and bg.has("Shuffle all decks") and not bg.has("New card"), "Play spread menu: %s" % str(bg))
var new_card: Dictionary = Actions.background(main, Vector2.ZERO)[bg.find("New card")]
_check(new_card.get("disabled", false), "Play: New card shows greyed, pointing to Build mode")
main.set_mode(Main.Mode.BUILD) main.set_mode(Main.Mode.BUILD)
await _frames() await _frames()
var build := _texts(Actions.card(main, t)) var build := _texts(Actions.card(main, t))

View file

@ -42,42 +42,17 @@ func _test_plain() -> void:
_eq(_ids(main.data.get_table("monsters")), before, "undo puts the order back") _eq(_ids(main.data.get_table("monsters")), before, "undo puts the order back")
## Drags a ranged card's first row to the third row's place. func _test_ranged() -> void:
func _drag_first_down_two(t: RollTable) -> String: var t := main.data.get_table("wilderness")
var card := main.card_for(t.id) var card := main.card_for(t.id)
var ranges := t.entries.map(func(e: TableEntry) -> Vector2i: return Vector2i(e.range_lo, e.range_hi))
var moved: String = t.entries[0].id var moved: String = t.entries[0].id
var h := _handle(card, moved) var h := _handle(card, moved)
var second := (card.rows[t.entries[2].id] as Control).get_global_rect() var second := (card.rows[t.entries[2].id] as Control).get_global_rect()
h.track(second.get_center() + Vector2(0, 2)) h.track(second.get_center() + Vector2(0, 2))
h.finish() h.finish()
return moved
func _test_ranged() -> void:
var t := main.data.get_table("wilderness")
_eq(t.range_edit, RangeWeights.RANGES, "a loaded card keeps typed ranges")
var first_range := Vector2i(t.entries[0].range_lo, t.entries[0].range_hi)
# Auto-sort (on by default) puts a Ranges card back in roll order.
var moved := _drag_first_down_two(t)
await _frames() await _frames()
_eq(t.entries.find(t.find_entry(moved)), 0, "auto-sort puts the row back in roll order") _eq(t.entries.find(t.find_entry(moved)), 2, "the result moved down two places")
# Without auto-sort the whole row moves, range and all. _eq(t.entries.map(func(e: TableEntry) -> Vector2i: return Vector2i(e.range_lo, e.range_hi)), ranges,
t.auto_sort = false "the ranges stay in place")
moved = _drag_first_down_two(t)
await _frames()
var e := t.find_entry(moved)
_eq(t.entries.find(e), 2, "the result moved down two places")
_eq(Vector2i(e.range_lo, e.range_hi), first_range, "its range moved with it")
_eq(t.range_problems(), "", "the ranges still cover the dice") _eq(t.range_problems(), "", "the ranges still cover the dice")
# Weights: the moved row's share follows it and the ranges are laid out again.
t.auto_sort = true
RangeWeights.set_mode(t, RangeWeights.WEIGHTS)
main.card_for(t.id).rebuild()
await _frames()
_eq(t.entries[0].range_lo, RollRange.natural(t).x, "Weights: the first row starts at the dice's lowest roll")
var size := e.weight
moved = _drag_first_down_two(t)
await _frames()
_eq(t.find_entry(moved).range_hi - t.find_entry(moved).range_lo + 1, t.find_entry(moved).weight, "Weights: the moved row keeps its share")
_eq(t.range_problems(), "", "Weights: the ranges still cover the dice")
_check(size > 0, "weights were read off the ranges")

View file

@ -184,7 +184,7 @@ func _test_lit_and_choice() -> void:
var node := main.group_node(g.id) var node := main.group_node(g.id)
# A real roll through the hidden choice card: the pop-up opens and answers. # A real roll through the hidden choice card: the pop-up opens and answers.
main.prompt_hook = main.rolling._ask_player main.prompt_hook = main.rolling._ask_player
main.start_roll("start", true) main.start_roll("start")
var d: ChoiceDialog = null var d: ChoiceDialog = null
for i in 60: for i in 60:
await process_frame await process_frame

View file

@ -1,106 +0,0 @@
extends TestBase
## The inspector's card page as one list (InspectorList): a section for the
## card and one per result; selecting on the spread opens only that section;
## sections opened by hand stay open and edits go to the section clicked in;
## a result's weight, range and position (InspectorRange).
## Run: godot --headless --path . -s res://tests/test_inspector_list.gd -- --sample
var insp: Inspector
func _init() -> void:
if not await start_main():
return
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
main.size = Vector2(1440, 900)
main.set_mode(Main.Mode.BUILD)
insp = main.inspector
main.data.load_dict({"format_version": 2, "id": "list-test", "name": "List test", "tables": [
{"id": "work", "name": "Workday Job", "x": 40, "y": 40, "dice": "1d100", "ranged": true,
"range_edit": "weights", "entries": [
{"id": "a", "text": "Result 1", "range": [1, 5], "weight": 5},
{"id": "b", "text": "Bob", "range": [6, 80], "weight": 75},
{"id": "c", "text": "Joe", "range": [81, 87], "weight": 7},
{"id": "d", "text": "Kevin", "range": [88, 100], "weight": 13}]}]})
main._rebuild_cards()
main.clear_inspector()
await _frames(4)
await _test_sections()
await _test_open_by_hand()
await _test_position_and_weight()
await _test_lore_tab()
finish()
func _t() -> RollTable:
return main.data.get_table("work")
func _open_keys() -> Array:
var out: Array = []
for k: String in insp.section_parts:
if insp.section_parts[k].get("built", false):
out.append(k)
return out
func _test_sections() -> void:
main.select_result("work", "b")
await _frames()
_eq(insp.section_parts.keys(), ["card", "a", "b", "c", "d"], "a section for the card and each result")
_eq(_open_keys(), ["b"], "selecting a result opens only its section")
_eq((insp.fields["text"] as LineEdit).text, "Bob", "the open section edits that result")
main.select_card("work")
await _frames()
_eq(_open_keys(), ["card"], "selecting the card opens only the card section")
_check(insp.fields.has("name"), "the card's fields are active")
var card := main.card_for("work")
var panel := card.get_theme_stylebox("panel") as StyleBoxFlat
_check(card._inspected and panel.border_color == Style.SELECTED, "the inspected card glows in the Selected colour")
_check(card.find_children("*", "CardMoveHandle", true, false).size() == 1, "Build shows a move handle on the header")
func _test_open_by_hand() -> void:
main.select_result("work", "a")
await _frames()
InspectorList.toggle(insp, "c")
await _frames()
_eq(_open_keys(), ["a", "c"], "a section opened by hand joins the open one")
_eq(str(insp.selection.get("eid")), "c", "the section just opened is active")
InspectorList.activate(insp, "a")
insp.set_entry_text("First")
_eq(_t().find_entry("a").text, "First", "edits go to the section made active")
_eq(_t().find_entry("c").text, "Joe", "the other open section is untouched")
await _frames()
_eq(_open_keys(), ["a", "c"], "an edit keeps both sections open")
main.select_result("work", "d")
await _frames()
_eq(_open_keys(), ["d"], "a click on the spread closes the rest again")
func _test_position_and_weight() -> void:
var t := _t()
InspectorRange.set_weight(insp, t, t.find_entry("a"), 10)
_eq(Vector2i(t.find_entry("b").range_lo, t.find_entry("b").range_hi), Vector2i(11, 85), "a weight edit moves the ranges after it")
InspectorRange.move_to(insp, t, t.find_entry("d"), 0)
_eq(t.entries[0].id, "d", "Position moves the result")
_eq(t.entries[0].range_lo, 1, "Weights lay the ranges out again after a move")
RangeWeights.set_mode(t, RangeWeights.RANGES)
InspectorRange.set_range(insp, t, t.find_entry("d"), 120, 125)
_eq(t.entries.back().id, "d", "auto-sort puts an edited range in roll order")
## In Build the Lore Index is a tab beside the inspector; in Play it opens alone.
func _test_lore_tab() -> void:
SideTabs.show_tab(main, SideTabs.LORE)
_check(main.book.visible and not insp.visible, "Build: the Lore Index tab replaces the inspector")
_check(main.book._tabs.visible, "Build: the Lore Index shows the tab row")
main.select_result("work", "a")
await _frames()
_check(insp.visible and not main.book.visible, "selecting on the spread goes back to the Inspector tab")
main.set_mode(Main.Mode.PLAY)
main.book.toggle()
_check(main.book.visible and not insp.visible and not main.book._tabs.visible, "Play: the Lore Index opens alone, with no tabs")
main.book.toggle()
main.set_mode(Main.Mode.BUILD)
_check(insp.visible, "back in Build the inspector shows")

View file

@ -1 +0,0 @@
uid://7enpfdhcgrqj

View file

@ -17,7 +17,6 @@ func _init() -> void:
await _load_demo() await _load_demo()
_test_cards() _test_cards()
await _test_scripted() await _test_scripted()
await _test_question_animates()
await _test_dialog_answers() await _test_dialog_answers()
await _test_cancel() await _test_cancel()
await _test_replace() await _test_replace()
@ -111,13 +110,13 @@ func _test_cards() -> void:
func _test_scripted() -> void: func _test_scripted() -> void:
var log: Array = [] var log: Array = []
main.prompt_hook = _scripted({"text": "Brin", "number": 3, "pick": 1}, log) main.prompt_hook = _scripted({"text": "Brin", "number": 3, "pick": 1}, log)
main.start_roll("start", true) main.start_roll("start")
_eq(log.size(), 3, "three questions: name, rooms, way out") _eq(log.size(), 3, "three questions: name, rooms, way out")
var kinds: Array = [] var kinds: Array = []
for r: Dictionary in log: for r: Dictionary in log:
kinds.append(r["kind"]) kinds.append(r["kind"])
_eq(kinds, ["text", "number", "pick"], "asked in chain order") _eq(kinds, ["text", "number", "pick"], "asked in chain order")
_check(main.current.get("done", false), "a fast roll with questions shows at once after the last answer") _check(main.current.get("done", false), "a roll with questions shows at once after the last answer")
_eq(_var("name"), "Brin", "text answer saved") _eq(_var("name"), "Brin", "text answer saved")
_eq(_var("rooms"), 3, "number answer saved") _eq(_var("rooms"), 3, "number answer saved")
var passes := 0 var passes := 0
@ -144,29 +143,6 @@ func _test_scripted() -> void:
main.prompt_hook = main.rolling._ask_player main.prompt_hook = main.rolling._ask_player
## A normal (not fast) roll animates up to a question and on after it, as a
## pause does, and its pop-up fades in; Skip animations makes it all instant.
func _test_question_animates() -> void:
var log: Array = []
main.prompt_hook = _scripted({"text": "Brin", "number": 1, "pick": 1}, log)
main.start_roll("start")
_eq(log.size(), 0, "a normal roll animates before its first question")
for i in 1200:
await process_frame
if main.current.get("done", false):
break
_check(main.current.get("done", false) and not main.current.get("fast", false), "the roll animates on after the answers")
SkipAnimations.set_on(main, true)
log.clear()
main.start_roll("start")
_check(log.size() >= 3, "Skip animations: the questions come at once")
SkipAnimations.set_on(main, false)
main.prompt_hook = main.rolling._ask_player
var dialog := ModalCard.new("Plain")
_check(not dialog.animate_in, "pop-ups don't animate unless a roll asks for it")
dialog.free()
func _test_dialog_answers() -> void: func _test_dialog_answers() -> void:
main.start_roll("start", true) main.start_roll("start", true)
await process_frame await process_frame
@ -210,7 +186,7 @@ func _test_dialog_answers() -> void:
func _test_cancel() -> void: func _test_cancel() -> void:
main.start_roll("start", true) main.start_roll("start")
await process_frame await process_frame
var d := main.rolling.pending_choice() var d := main.rolling.pending_choice()
_check(d != null, "a pop-up is open") _check(d != null, "a pop-up is open")
@ -226,7 +202,7 @@ func _test_cancel() -> void:
_check(main.tray._halt.visible and main.tray._halt_label.text.contains("Cancelled"), "the tray says Cancelled") _check(main.tray._halt.visible and main.tray._halt_label.text.contains("Cancelled"), "the tray says Cancelled")
_check(main.rolling_ctx == null, "no roll is left running") _check(main.rolling_ctx == null, "no roll is left running")
# Freeing the dialog some other way also answers Cancel. # Freeing the dialog some other way also answers Cancel.
main.start_roll("start", true) main.start_roll("start")
await process_frame await process_frame
d = main.rolling.pending_choice() d = main.rolling.pending_choice()
if d: if d:
@ -236,13 +212,13 @@ func _test_cancel() -> void:
func _test_replace() -> void: func _test_replace() -> void:
main.start_roll("start", true) main.start_roll("start")
await process_frame await process_frame
var first := main.rolling.pending_choice() var first := main.rolling.pending_choice()
_check(first != null, "first roll asks") _check(first != null, "first roll asks")
var first_reply := first.reply if first else null var first_reply := first.reply if first else null
var history := main.history.size() var history := main.history.size()
main.start_roll("start", true) main.start_roll("start")
_check(first_reply != null and first_reply.finished, "a new roll answers the old question with Cancel") _check(first_reply != null and first_reply.finished, "a new roll answers the old question with Cancel")
await process_frame await process_frame
var second := main.rolling.pending_choice() var second := main.rolling.pending_choice()
@ -268,7 +244,7 @@ func _test_replace() -> void:
func _test_keys() -> void: func _test_keys() -> void:
main.start_roll("start", true) main.start_roll("start")
await process_frame await process_frame
var d := main.rolling.pending_choice() var d := main.rolling.pending_choice()
if d: if d:

View file

@ -1,98 +0,0 @@
extends TestBase
## Headless checks for ranged cards edited by weight or by range (RangeWeights):
## turning gaps into empty results, laying ranges out from weights, the total
## warning, auto-sort, the file format, and an empty card switching to Ranged.
## Run: godot --headless --path . -s res://tests/test_range_weights.gd
func _init() -> void:
_test_to_weights()
_test_total_warning()
_test_auto_sort()
_test_file_format()
_test_empty_card_ranged()
finish()
## The user's example: d100 with 1–5, 10–80, 81–87, 88–100 (a gap at 6–9).
func _workday() -> RollTable:
var t := RollTable.new("work", "Workday Job")
t.dice = "1d100"
for r: Array in [["Result 1", 1, 5], ["Bob", 10, 80], ["Joe", 81, 87], ["Kevin", 88, 100]]:
var e := TableEntry.new("e%d" % t.entries.size(), r[0])
e.has_range = true
e.range_lo = r[1]
e.range_hi = r[2]
t.entries.append(e)
return t
func _texts(t: RollTable) -> Array:
return t.entries.map(func(e: TableEntry) -> String: return e.text)
func _spans(t: RollTable) -> Array:
return t.entries.map(func(e: TableEntry) -> Vector2i: return Vector2i(e.range_lo, e.range_hi))
func _test_to_weights() -> void:
var t := _workday()
RangeWeights.set_mode(t, RangeWeights.WEIGHTS)
_eq(_texts(t), ["Result 1", "", "Bob", "Joe", "Kevin"], "the 6–9 gap becomes an empty result")
_eq(t.entries.map(func(e: TableEntry) -> int: return e.weight), [5, 4, 71, 7, 13], "weights are read off the ranges")
_eq(_spans(t)[1], Vector2i(6, 9), "no roll changes: the empty result covers 6–9")
_eq(t.range_problems(), "", "the weights cover the d100")
t.entries[2].weight = 70
RangeWeights.reflow(t)
_eq(_spans(t)[3], Vector2i(80, 86), "editing a weight moves the ranges after it")
func _test_total_warning() -> void:
var t := _workday()
RangeWeights.set_mode(t, RangeWeights.WEIGHTS)
t.entries[1].weight = 0
RangeWeights.reflow(t)
_eq(t.range_problems(), "Weights add up to 96 of 100: 4 short.", "a short total says so")
_check(not t.entries[1].has_range, "weight 0 gives no range")
t.entries[0].weight = 10
RangeWeights.reflow(t)
_eq(t.range_problems(), "Weights add up to 101 of 100: 1 too many.", "a long total says so")
func _test_auto_sort() -> void:
var t := _workday()
var bob := t.entries[1]
t.entries.remove_at(1)
t.entries.append(bob)
_check(RangeWeights.after_edit(t), "auto-sort reports that it moved rows")
_eq(_texts(t), ["Result 1", "Bob", "Joe", "Kevin"], "auto-sort puts the rows in roll order")
t.auto_sort = false
t.entries.remove_at(1)
t.entries.append(bob)
_check(not RangeWeights.after_edit(t), "with auto-sort off nothing moves")
_eq(_texts(t), ["Result 1", "Joe", "Kevin", "Bob"], "the dragged order stays")
func _test_file_format() -> void:
var t := _workday()
var d := t.to_dict()
_check(not d.has("range_edit"), "Ranges is the default in files, so old cards load unchanged")
RangeWeights.set_mode(t, RangeWeights.WEIGHTS)
t.auto_sort = false
d = t.to_dict()
var back := RollTable.from_dict(d)
_eq(back.range_edit, RangeWeights.WEIGHTS, "Weights is saved")
_check(not back.auto_sort, "auto-sort off is saved")
var empty := RollTable.new("empty", "Empty")
empty.ranged = true
_check(RollTable.from_dict(empty.to_dict()).is_ranged(), "an empty ranged card stays ranged after saving")
func _test_empty_card_ranged() -> void:
var t := RollTable.new("new", "New card")
var res := TableSettingsRules.apply_settings(t, {"ranged": true, "dice": "1d20"})
_check(res["ok"], "the switch is accepted")
_check(t.is_ranged(), "an empty card can switch to Ranged")
_eq(t.range_edit, RangeWeights.WEIGHTS, "a card made ranged is edited by weight")
TableSettingsRules.apply_settings(t, {"ranged": false})
_check(not t.is_ranged(), "and back to Plain")

View file

@ -1 +0,0 @@
uid://c5v8kve34t5gy

View file

@ -1,97 +0,0 @@
extends TestBase
## Spellchecking in Build (Spellcheck, SpellWords, SpellUnderline), with a
## stand-in checker so the test needs no native add-on: which words are
## checked, underlines on card and inspector fields, suggestions replacing a
## word, the spread's own dictionary (saved with it) and Ignore.
## Run: godot --headless --path . -s res://tests/test_spellcheck.gd -- --sample
## Knows a few words; suggests from a fixed table.
class FakeChecker:
extends RefCounted
const KNOWN := ["the", "result", "work", "joe", "tinker", "bob", "workday", "job", "fixes", "press", "after", "hard", "day's", "new"]
func spell(word: String) -> bool:
return KNOWN.has(word.to_lower())
func suggest(word: String) -> PackedStringArray:
return PackedStringArray({"tinkerr": ["tinker", "tinkers"], "wrok": ["work"]}.get(word.to_lower(), []))
func _init() -> void:
_test_words()
Spellcheck.use_backend(FakeChecker.new())
_test_checking()
if not await start_main():
return
main.set_mode(Main.Mode.BUILD)
main.data.load_dict({"format_version": 2, "id": "spell-test", "name": "Spell test", "tables": [
{"id": "work", "name": "Workday Job", "x": 40, "y": 40, "entries": [
{"id": "a", "text": "Joe the tinkerr", "details": "Fixes the press after a hard day's wrok"},
{"id": "b", "text": "Vargr"}]}]})
main._rebuild_cards()
await _frames(4)
await _test_card_fields()
await _test_dictionary()
Spellcheck.use_backend(null)
finish()
func _words(text: String) -> Array:
return SpellWords.ranges(text).map(func(r: Vector2i) -> String: return text.substr(r.x, r.y - r.x))
func _test_words() -> void:
_eq(_words("[b]Joe[/b] the {option} tinker @hp [[Spread::Card]]"), ["Joe", "the", "tinker"], "tags, placeholders, values and links are skipped")
_eq(_words("Roll 2d6 for 3 HP, don't"), ["Roll", "for", "don't"], "numbers, dice and short capitals are skipped")
func _test_checking() -> void:
var board := TowerBoard.new()
var text := "Joe the tinkerr"
_eq(Spellcheck.misspelled(text, board), [Vector2i(8, 15)] as Array[Vector2i], "a misspelled word is found")
board.dictionary.append("Tinkerr")
_check(Spellcheck.misspelled(text, board).is_empty(), "the spread's dictionary accepts it, in any case")
var back := TowerBoard.new()
back.load_dict(board.to_dict())
_eq(back.dictionary, ["Tinkerr"] as Array[String], "the dictionary is saved with the spread")
func _underline(c: Control) -> SpellUnderline:
return c.get_meta("spell") if c.has_meta("spell") else null
func _test_card_fields() -> void:
var card := main.card_for("work")
var row: Control = card.rows["a"]
var edits := row.find_children("*", "LineEdit", true, false)
var u: SpellUnderline = _underline(edits[0]) if not edits.is_empty() else null
_check(u != null, "a result's text field on the card is checked")
if u == null:
return
_eq(u.bad, [Vector2i(8, 15)] as Array[Vector2i], "the misspelled word is underlined")
u.open_menu(u.bad[0], Vector2(100, 100))
_eq(u._menu.get_item_text(0), "tinker", "the menu starts with suggestions")
u._on_menu(0)
await _frames()
_eq(main.data.get_table("work").find_entry("a").text, "Joe the tinker", "picking a suggestion fixes the result")
main.select_result("work", "a")
await _frames()
var det: Control = main.inspector.fields.get("details")
_check(det != null and _underline(det) != null and _underline(det).bad.size() == 1, "the inspector's Details are checked too")
func _test_dictionary() -> void:
var card := main.card_for("work")
var edits := (card.rows["b"] as Control).find_children("*", "LineEdit", true, false)
var u: SpellUnderline = _underline(edits[0])
_eq(u.bad.size(), 1, "a setting's name is flagged at first")
u.open_menu(u.bad[0], Vector2(100, 100))
u._on_menu(SpellUnderline.ID_ADD)
_check(main.data.dictionary.has("Vargr"), "Add to dictionary saves the word in the spread")
_check(u.bad.is_empty(), "the underline goes away")
Spellcheck.ignore(main, "wrok")
_check(Spellcheck.is_ok("Wrok", main.data), "Ignore accepts the word for this session")
main.set_mode(Main.Mode.PLAY)
await _frames()
main.set_mode(Main.Mode.BUILD)

View file

@ -1 +0,0 @@
uid://bsbhdy6i2m786

View file

@ -16,7 +16,6 @@ func _init() -> void:
await _test_stripes() await _test_stripes()
await _test_card_menu() await _test_card_menu()
await _test_help() await _test_help()
await _test_build_hint()
finish() finish()
@ -137,23 +136,3 @@ func _test_help() -> void:
_check(d.text.get_parsed_text().contains("Luck"), "and shows its text") _check(d.text.get_parsed_text().contains("Luck"), "and shows its text")
d.close() d.close()
await _frames() await _frames()
## Play shows that Build mode exists: a greyed "+ Card" that explains and
## offers to switch, and a greyed "New card" in the ☰ menu.
func _test_build_hint() -> void:
main.set_mode(Main.Mode.PLAY)
var bar := main.top_bar
_check(bar.play_add_button.visible and not bar._build_tools.visible, "Play shows the greyed + Card, not the Build tools")
var names := Actions.background(main, Vector2.ZERO).map(func(a: Dictionary) -> String: return str(a.get("text", "")))
var item: Dictionary = Actions.background(main, Vector2.ZERO)[names.find("New card")] if names.has("New card") else {}
_check(item.get("disabled", false), "the ☰ menu shows New card greyed in Play")
bar.play_add_button.pressed.emit()
_eq(bar._toast_label.text, BuildModeHint.MESSAGE, "clicking it explains Build mode")
_check(bar._toast_undo.visible and bar._toast_undo.text == "Switch to Build", "the toast offers Switch to Build")
bar._toast_undo.pressed.emit()
await _frames()
_eq(main.mode, Main.Mode.BUILD, "Switch to Build switches")
_check(not bar.play_add_button.visible, "Build hides the greyed button")
main.toast("Saved")
_eq(bar._toast_undo.text, "Undo", "a later toast's button is Undo again")

View file

@ -176,17 +176,14 @@ static func background(m: Main, at: Vector2) -> Array:
list.append({"text": "Group the selection Ctrl+G", "do": m.grouping.group_selection, "disabled": picked == 0 and m.selecting.groups.is_empty(), list.append({"text": "Group the selection Ctrl+G", "do": m.grouping.group_selection, "disabled": picked == 0 and m.selecting.groups.is_empty(),
"tip": "Select cards first: drag a box around them"}) "tip": "Select cards first: drag a box around them"})
list.append({"sep": ""}) list.append({"sep": ""})
else:
list.append(BuildModeHint.menu_item())
list.append({"sep": ""})
list.append({"text": "Search… Ctrl+F", "do": m.nav.open_search}) list.append({"text": "Search… Ctrl+F", "do": m.nav.open_search})
list.append({"text": "Shuffle all decks", "do": m.local_state.reshuffle_all, "disabled": not has_decks(m), list.append({"text": "Shuffle all decks", "do": m.local_state.reshuffle_all, "disabled": not has_decks(m),
"tip": "Put every Deck-mode card's results back"}) "tip": "Put every Deck-mode card's results back"})
list.append({"text": "Fit spread", "do": m.board.fit}) list.append({"text": "Fit spread", "do": m.board.fit})
list.append({"text": "Hide the list" if m.list_view.visible else "List view", "do": m.list_view.toggle, list.append({"text": "Hide the list" if m.list_view.visible else "List view", "do": m.list_view.toggle,
"tip": "The cards as a list with their groups"}) "tip": "The cards as a list with their groups"})
list.append({"text": "Close the Lore Index" if m.book.visible else "Lore Index", "do": m.book.toggle, list.append({"text": "Close the Book" if m.book.visible else "Book", "do": m.book.toggle,
"tip": "Reusable results (Lore Entries) to drag onto tables"}) "tip": "Reusable results (Pages) to drag onto tables"})
list.append({"sep": ""}) list.append({"sep": ""})
list.append({"text": "Theme…", "do": func() -> void: m.add_child(ThemeDialog.new(m))}) list.append({"text": "Theme…", "do": func() -> void: m.add_child(ThemeDialog.new(m))})
if m.sound: if m.sound:

View file

@ -1,8 +1,6 @@
class_name BookPanel class_name BookPanel
extends PanelContainer extends PanelContainer
## The Lore Index (Book in code): the spread's reusable results, its Lore ## The Book: the spread's reusable results (Pages), docked beside the spread.
## Entries (BookPage), docked beside the spread; in Build it is a tab beside
## the inspector (SideTabs).
## A searchable list (name, text and tags) above the page editor. Drag a page ## A searchable list (name, text and tags) above the page editor. Drag a page
## onto a result to link it there, or onto a card to add it as a new result. ## onto a result to link it there, or onto a card to add it as a new result.
## Open from View ▾, ☰ or right-clicking the spread; × closes it. ## Open from View ▾, ☰ or right-clicking the spread; × closes it.
@ -18,8 +16,6 @@ var _search: LineEdit
var _ids: Array[String] = [] var _ids: Array[String] = []
var _rev := -1 var _rev := -1
var _dragging := "" var _dragging := ""
var _tabs: Control
var _title: Label
func setup(p_main: Main) -> void: func setup(p_main: Main) -> void:
@ -28,24 +24,22 @@ func setup(p_main: Main) -> void:
var col := VBoxContainer.new() var col := VBoxContainer.new()
col.add_theme_constant_override("separation", 8) col.add_theme_constant_override("separation", 8)
add_child(col) add_child(col)
_tabs = SideTabs.make_row(m, SideTabs.LORE)
col.add_child(_tabs)
var head := HBoxContainer.new() var head := HBoxContainer.new()
head.add_theme_constant_override("separation", 6) head.add_theme_constant_override("separation", 6)
col.add_child(head) col.add_child(head)
_title = Style.make_label("Lore Index", Style.display(), 20, Style.ON_BG) var title := Style.make_label("Book", Style.display(), 20, Style.ON_BG)
_title.size_flags_horizontal = SIZE_EXPAND_FILL title.size_flags_horizontal = SIZE_EXPAND_FILL
head.add_child(_title) head.add_child(title)
var add := Style.bar_button("+ Lore Entry") var add := Style.bar_button("+ Page")
add.tooltip_text = "A new Lore Entry: a result you can reuse on any table" add.tooltip_text = "A new page: a result you can reuse on any table"
add.pressed.connect(new_page) add.pressed.connect(new_page)
head.add_child(add) head.add_child(add)
var close := Style.bar_button("×") var close := Style.bar_button("×")
close.tooltip_text = "Close the Lore Index" close.tooltip_text = "Close the Book"
close.pressed.connect(func() -> void: set_shown(false)) close.pressed.connect(func() -> void: set_shown(false))
head.add_child(close) head.add_child(close)
_search = LineEdit.new() _search = LineEdit.new()
_search.placeholder_text = "Search Lore Entries and tags" _search.placeholder_text = "Search pages and tags"
_search.clear_button_enabled = true _search.clear_button_enabled = true
ModalCard.style_line_edit(_search) ModalCard.style_line_edit(_search)
_search.text_changed.connect(func(_s: String) -> void: refresh()) _search.text_changed.connect(func(_s: String) -> void: refresh())
@ -116,22 +110,15 @@ func set_shown(on: bool) -> void:
if m.state: if m.state:
m.state.set_setting(SETTING, on) m.state.set_setting(SETTING, on)
m.state.save() m.state.save()
SideTabs.sync(m)
func toggle() -> void: func toggle() -> void:
SideTabs.show_tab(m, SideTabs.INSPECTOR if visible else SideTabs.LORE) set_shown(not visible)
## Build shows the Inspector | Lore Index tabs in place of the title.
func show_tabs(on: bool) -> void:
_tabs.visible = on
_title.visible = not on
func new_page() -> BookPage: func new_page() -> BookPage:
m.undo_redo._begin_edit() m.undo_redo._begin_edit()
var p := m.data.add_page("New Lore Entry") var p := m.data.add_page("New page")
m.mark_dirty() m.mark_dirty()
m.undo_redo._end_edit() m.undo_redo._end_edit()
if not visible: if not visible:
@ -153,7 +140,7 @@ func save_result(t: RollTable, e: TableEntry) -> BookPage:
set_shown(true) set_shown(true)
refresh() refresh()
select_page(p.id) select_page(p.id)
m.toast("Saved “%s” to the Lore Index" % p.label()) m.toast("Saved “%s” to the Book" % p.label())
return p return p

View file

@ -1,38 +0,0 @@
class_name BuildModeHint
extends RefCounted
## Play mode tells new players that Build mode exists: a greyed "+ Card"
## button in the top bar and a greyed "New card" in the ☰ menu. Clicking the
## button explains, offers "Switch to Build" and makes the Build switch pulse.
const MESSAGE := "Cards are added and edited in Build mode."
const TIP := "Switch to Build mode (top left) to add and edit cards"
## The greyed "+ Card" shown in Play in place of the real one.
static func make_button(m: Main) -> Button:
var b := Style.bar_button("+ Card")
b.modulate.a = 0.5
b.tooltip_text = TIP
b.focus_mode = Control.FOCUS_NONE
b.pressed.connect(func() -> void: explain(m))
return b
## The ☰ menu's greyed "New card" in Play (Actions.background).
static func menu_item() -> Dictionary:
return {"text": "New card", "disabled": true, "tip": TIP}
static func explain(m: Main) -> void:
m.top_bar.toast_action(MESSAGE, "Switch to Build", func() -> void: m.set_mode(Main.Mode.BUILD))
pulse(m.top_bar._build_button)
## Flashes a button three times to draw the eye.
static func pulse(b: Control) -> void:
if b == null or not b.is_inside_tree():
return
var tween := b.create_tween()
for i in 3:
tween.tween_property(b, "modulate", Color(1.6, 1.4, 0.8), 0.18)
tween.tween_property(b, "modulate", Color.WHITE, 0.22)

View file

@ -1 +0,0 @@
uid://cqbsjhxxuyjys

View file

@ -1,27 +0,0 @@
class_name CardMoveHandle
extends Control
## The dotted handle at the left of a card's header in Build: shows where to
## grab the card to move it. It only draws; the header under it does the
## dragging. (The resize corner is CardGrip.)
const DOT := 1.8
const STEP := 6.0
func _init() -> void:
custom_minimum_size = Vector2(14, 30)
size_flags_vertical = Control.SIZE_SHRINK_CENTER
mouse_filter = Control.MOUSE_FILTER_PASS
mouse_default_cursor_shape = Control.CURSOR_MOVE
tooltip_text = "Drag to move the card"
mouse_entered.connect(queue_redraw)
mouse_exited.connect(queue_redraw)
func _draw() -> void:
var hot := get_global_rect().has_point(get_global_mouse_position())
var color := Style.INK if hot else Style.MUTED
for col in 2:
for row in 4:
var at := Vector2(size.x / 2.0 + (col - 0.5) * STEP, size.y / 2.0 + (row - 1.5) * STEP)
draw_circle(at, DOT, color)

View file

@ -1 +0,0 @@
uid://b8et3sky3yjby

View file

@ -83,7 +83,7 @@ static func label_for(a: Dictionary, b: Dictionary, d: Dictionary = {}) -> Strin
if d.is_empty(): if d.is_empty():
d = diff(a, b) d = diff(a, b)
if d.get("book", false) and (d["changed"] as Array).is_empty() and (d["added"] as Array).is_empty(): if d.get("book", false) and (d["changed"] as Array).is_empty() and (d["added"] as Array).is_empty():
return "Edit the Lore Index" return "Edit the Book"
var added: Array = d["added"] var added: Array = d["added"]
var removed: Array = d["removed"] var removed: Array = d["removed"]
var gadded: Array = d["gadded"] var gadded: Array = d["gadded"]

View file

@ -40,13 +40,8 @@ var show_if_builder: ConditionBuilder
var case_builder: ConditionBuilder var case_builder: ConditionBuilder
## target id -> {box, when (ConditionBuilder), otherwise (CheckBox), count, save, inputs: {name: LineEdit}, taken} ## target id -> {box, when (ConditionBuilder), otherwise (CheckBox), count, save, inputs: {name: LineEdit}, taken}
var pipe_parts: Dictionary = {} var pipe_parts: Dictionary = {}
## Named fields of the active section ("name", "dice", "text", ...). ## Named fields of the card section ("name", "dice", "check_mod", ...).
var fields: Dictionary = {} var fields: Dictionary = {}
## The card page's sections (InspectorList): which are open ("card" or a
## result id -> true), each one's parts, and each one's box.
var open_sections: Dictionary = {}
var section_parts: Dictionary = {}
var section_boxes: Dictionary = {}
func setup(p_main: Main) -> void: func setup(p_main: Main) -> void:
@ -61,39 +56,12 @@ func setup(p_main: Main) -> void:
# ---------- Selection ---------- # ---------- Selection ----------
## Selecting a card or result on the spread opens its section and closes the rest.
func select(sel: Dictionary) -> void: func select(sel: Dictionary) -> void:
if collapsed: if collapsed:
set_collapsed(false) set_collapsed(false)
if main and main.book and main.book.visible:
SideTabs.show_tab(main, SideTabs.INSPECTOR)
selection = sel selection = sel
var kind := str(sel.get("kind", ""))
if kind == "card" or kind == "result":
open_sections = {InspectorList.key_of(sel): true}
rebuild() rebuild()
_mark_cards() _mark_cards()
if kind == "card" or kind == "result":
InspectorList.scroll_to(self, InspectorList.key_of(sel))
func _ready() -> void:
get_viewport().gui_focus_changed.connect(_on_focus_changed)
## A click or focus inside a section makes it the one edits go to.
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton and (event as InputEventMouseButton).pressed and is_visible_in_tree() and not section_boxes.is_empty():
var key := InspectorList.key_at(self, (event as InputEventMouseButton).global_position)
if key != "":
InspectorList.activate(self, key)
func _on_focus_changed(c: Control) -> void:
if c and is_ancestor_of(c) and not section_boxes.is_empty():
var key := InspectorList.key_holding(self, c)
if key != "":
InspectorList.activate(self, key)
func clear() -> void: func clear() -> void:
@ -113,7 +81,6 @@ func _mark_cards() -> void:
var card := c as TableCard var card := c as TableCard
if card and card.has_method("set_selected_entry"): if card and card.has_method("set_selected_entry"):
card.set_selected_entry(eid if card.table.id == tid else "") card.set_selected_entry(eid if card.table.id == tid else "")
card.set_inspected(card.table.id == tid)
func set_collapsed(on: bool) -> void: func set_collapsed(on: bool) -> void:
@ -311,10 +278,8 @@ func rebuild() -> void:
effects = null effects = null
show_if_builder = null show_if_builder = null
case_builder = null case_builder = null
pipe_parts = {} pipe_parts.clear()
fields = {} fields.clear()
section_parts.clear()
section_boxes.clear()
var t := selected_table() var t := selected_table()
var e := selected_entry() var e := selected_entry()
if selection.has("eid") and e == null: if selection.has("eid") and e == null:
@ -324,10 +289,12 @@ func rebuild() -> void:
InspectorFrame.show_empty(self) InspectorFrame.show_empty(self)
else: else:
match str(selection.get("kind", "card")): match str(selection.get("kind", "card")):
"result":
InspectorResult.section(self, t, e)
"pipe": "pipe":
InspectorThread.section(self, t, e, str(selection.get("to", ""))) InspectorThread.section(self, t, e, str(selection.get("to", "")))
_: _:
InspectorList.build(self, t) InspectorCard.build(self, _content, t)
_sig = _signature() _sig = _signature()
if main and main.board and main.board.pipes: if main and main.board and main.board.pipes:
main.board.pipes.select_key = Roller.pipe_key(t.id, e.id, str(selection["to"])) if t and str(selection.get("kind", "")) == "pipe" else "" main.board.pipes.select_key = Roller.pipe_key(t.id, e.id, str(selection["to"])) if t and str(selection.get("kind", "")) == "pipe" else ""

View file

@ -9,10 +9,8 @@ extends RefCounted
## InspectorCollection. ## InspectorCollection.
## `with_head`: false inside the inspector's list, which has its own headers. static func build(insp: Inspector, box: VBoxContainer, t: RollTable) -> void:
static func build(insp: Inspector, box: VBoxContainer, t: RollTable, with_head: bool = true) -> void: box.add_child(insp._head("Selected card · " + Describe.kind_label(t), Inspector._title_of(t.name, "(no name)")))
if with_head:
box.add_child(insp._head("Selected card · " + Describe.kind_label(t), Inspector._title_of(t.name, "(no name)")))
var plain := insp.main.rules_plain() var plain := insp.main.rules_plain()
var name := InspectorKit.line(t.name, "Name") var name := InspectorKit.line(t.name, "Name")
@ -22,7 +20,6 @@ static func build(insp: Inspector, box: VBoxContainer, t: RollTable, with_head:
insp.apply_settings({"name": s}) insp.apply_settings({"name": s})
) )
insp.fields["name"] = name insp.fields["name"] = name
SpellUnderline.attach(name, insp.main)
box.add_child(InspectorKit.field("Label" if t.kind == RollTable.KIND_VARIABLE else "Name", name)) box.add_child(InspectorKit.field("Label" if t.kind == RollTable.KIND_VARIABLE else "Name", name))
match t.kind: match t.kind:
@ -50,7 +47,6 @@ static func build(insp: Inspector, box: VBoxContainer, t: RollTable, with_head:
InspectorKit.tag(det, "card.details") InspectorKit.tag(det, "card.details")
det.text_changed.connect(func() -> void: insp.apply_settings({"details": det.text})) det.text_changed.connect(func() -> void: insp.apply_settings({"details": det.text}))
insp.fields["details"] = det insp.fields["details"] = det
SpellUnderline.attach(det, insp.main)
box.add_child(InspectorKit.field("Details", det)) box.add_child(InspectorKit.field("Details", det))
var tags := InspectorKit.line(", ".join(t.tags), "e.g. loot, town") var tags := InspectorKit.line(", ".join(t.tags), "e.g. loot, town")

View file

@ -20,11 +20,6 @@ static func build(insp: Inspector) -> void:
insp._body.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) insp._body.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
insp._body.add_theme_constant_override("separation", 0) insp._body.add_theme_constant_override("separation", 0)
stack.add_child(insp._body) stack.add_child(insp._body)
var tabs_pad := MarginContainer.new()
for side: String in ["margin_left", "margin_right", "margin_top"]:
tabs_pad.add_theme_constant_override(side, 10)
tabs_pad.add_child(SideTabs.make_row(insp.main, SideTabs.INSPECTOR))
insp._body.add_child(tabs_pad)
insp._scroll = ScrollContainer.new() insp._scroll = ScrollContainer.new()
insp._scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED insp._scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
insp._scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL insp._scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
@ -93,7 +88,7 @@ static func refresh_title(insp: Inspector) -> void:
"result": "result":
var entry := insp.selected_entry() var entry := insp.selected_entry()
if entry: if entry:
InspectorList.refresh_title(insp, entry) insp._title_label.text = Inspector._title_of(entry.text, "(no text)")
## The page shown when nothing is selected. ## The page shown when nothing is selected.

View file

@ -1,183 +0,0 @@
class_name InspectorList
extends RefCounted
## The inspector's page for a card, as one list: the card's own section, then
## one section per result, each with a header that opens and closes it.
##
## Clicking the card or a result on the spread opens that section and closes the
## rest (Inspector.select). Sections opened by hand stay open until then.
## Only open sections build their fields, so long cards stay quick.
##
## The older section code edits "the selected result" (Inspector.selection,
## fields, effects, ...). So each open section keeps its own parts, and a click
## or focus inside a section makes it the active one (activate): selection and
## those parts then point at it, and its header is outlined.
const CARD := "card"
## Builds the whole page for card `t` into the inspector's content box.
static func build(insp: Inspector, t: RollTable) -> void:
insp.section_parts.clear()
insp.section_boxes.clear()
var keep_selection := insp.selection.duplicate()
insp._content.add_child(insp._head("Card · " + Describe.kind_label(t), Inspector._title_of(t.name, "(no name)")))
var list := InspectorKit.vbox(6)
insp._content.add_child(list)
_section(insp, list, CARD, "Card", "Settings", "", func(body: VBoxContainer) -> void:
insp.selection = {"kind": "card", "tid": t.id}
InspectorCard.build(insp, body, t, false))
if t.kind != RollTable.KIND_VARIABLE:
for i in t.entries.size():
var e := t.entries[i]
var span := t.num_label(e, i) if t.is_ranged() and e.has_range else ""
_section(insp, list, e.id, _kind_word(t), Inspector._title_of(e.text, "(nothing)"), span, func(body: VBoxContainer) -> void:
insp.selection = {"kind": "result", "tid": t.id, "eid": e.id}
InspectorRange.build(insp, body, t, e)
var outer := insp._content
insp._content = body
InspectorResult.section(insp, t, e, false)
insp._content = outer)
insp.selection = keep_selection
activate(insp, key_of(insp.selection))
## "card" for a card selection, the result's id for a result.
static func key_of(sel: Dictionary) -> String:
return str(sel.get("eid", "")) if str(sel.get("kind", "")) == "result" else CARD
static func _kind_word(t: RollTable) -> String:
match t.kind:
RollTable.KIND_CHOICE:
return "Option"
RollTable.KIND_ROUTER:
return "Case"
return "Result"
## One section: a header (▸/▾, kind, title, range) and, when open, its body.
static func _section(insp: Inspector, list: VBoxContainer, key: String, kind: String, title: String, span: String, fill: Callable) -> void:
var open: bool = insp.open_sections.get(key, false)
var box := InspectorKit.vbox(0)
list.add_child(box)
insp.section_boxes[key] = box
var head := PanelContainer.new()
head.mouse_filter = Control.MOUSE_FILTER_STOP
head.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
head.tooltip_text = "Close this section" if open else "Open this section"
var row := InspectorKit.hbox(8)
head.add_child(row)
row.add_child(InspectorKit.word("▾" if open else "▸", Style.MUTED))
var kind_label := InspectorKit.flabel(kind)
kind_label.size_flags_vertical = Control.SIZE_SHRINK_CENTER
row.add_child(kind_label)
var title_label := InspectorKit.word(title, Style.INK, true)
title_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
title_label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
title_label.clip_text = true
row.add_child(title_label)
if span != "":
row.add_child(InspectorKit.word(span, Style.TRIM))
head.gui_input.connect(func(ev: InputEvent) -> void:
if ev is InputEventMouseButton and (ev as InputEventMouseButton).pressed and (ev as InputEventMouseButton).button_index == MOUSE_BUTTON_LEFT:
toggle(insp, key))
box.add_child(head)
var parts := {"head": head, "title": title_label, "fields": {}, "pipe_parts": {}, "built": open}
insp.section_parts[key] = parts
if not open:
_style_head(head, false, false)
return
var pad := MarginContainer.new()
for side: String in ["margin_left", "margin_right"]:
pad.add_theme_constant_override(side, 8)
pad.add_theme_constant_override("margin_top", 10)
pad.add_theme_constant_override("margin_bottom", 14)
box.add_child(pad)
var body := InspectorKit.vbox(14)
pad.add_child(body)
insp.fields = parts["fields"]
insp.pipe_parts = parts["pipe_parts"]
insp.effects = null
insp.show_if_builder = null
insp.case_builder = null
fill.call(body)
parts["effects"] = insp.effects
parts["show_if_builder"] = insp.show_if_builder
parts["case_builder"] = insp.case_builder
_style_head(head, true, false)
static func _style_head(head: PanelContainer, open: bool, active: bool) -> void:
var fill := Style.HOVER_ROW if open else Color(0, 0, 0, 0.04)
var sb := Style.bordered(Style.box(fill, 7, [10, 7, 10, 7]), 2 if active else 1, Style.TRIM if active else Style.RULE)
head.add_theme_stylebox_override("panel", sb)
## Opens or closes a section by its header. Opening one makes it active.
static func toggle(insp: Inspector, key: String) -> void:
var t := insp.selected_table()
if t == null:
return
var open: bool = not insp.open_sections.get(key, false)
insp.open_sections[key] = open
if open:
insp.selection = {"kind": "card", "tid": t.id} if key == CARD else {"kind": "result", "tid": t.id, "eid": key}
insp.rebuild()
insp._mark_cards()
## Makes section `key` the one edits go to: the selection and the shared parts
## (fields, effects, ...) point at it, and its header is outlined.
static func activate(insp: Inspector, key: String) -> void:
var t := insp.selected_table()
if t == null or not insp.section_parts.has(key):
return
var parts: Dictionary = insp.section_parts[key]
if parts.get("built", false):
insp.fields = parts["fields"]
insp.pipe_parts = parts["pipe_parts"]
insp.effects = parts.get("effects")
insp.show_if_builder = parts.get("show_if_builder")
insp.case_builder = parts.get("case_builder")
var was := key_of(insp.selection)
insp.selection = {"kind": "card", "tid": t.id} if key == CARD else {"kind": "result", "tid": t.id, "eid": key}
for k: String in insp.section_parts:
var p: Dictionary = insp.section_parts[k]
_style_head(p["head"], p.get("built", false), k == key)
if was != key:
insp._mark_cards()
## The open section under a point or holding a control, or "".
static func key_at(insp: Inspector, global_point: Vector2) -> String:
for key: String in insp.section_boxes:
var box: Control = insp.section_boxes[key]
if is_instance_valid(box) and box.get_global_rect().has_point(global_point):
return key
return ""
static func key_holding(insp: Inspector, c: Control) -> String:
for key: String in insp.section_boxes:
var box: Control = insp.section_boxes[key]
if is_instance_valid(box) and box.is_ancestor_of(c):
return key
return ""
## Scrolls so the section's header shows (after the page is laid out).
static func scroll_to(insp: Inspector, key: String) -> void:
await insp.get_tree().process_frame
var head: Control = (insp.section_parts.get(key, {}) as Dictionary).get("head")
if is_instance_valid(head) and is_instance_valid(insp._scroll):
# The header near the top, so the open section's fields show below it.
var offset := head.get_global_rect().position.y - insp._scroll.get_global_rect().position.y
insp._scroll.scroll_vertical = maxi(0, insp._scroll.scroll_vertical + int(offset) - 8)
## Keeps a result's header title in step with its text as it is typed.
static func refresh_title(insp: Inspector, e: TableEntry) -> void:
var parts: Dictionary = insp.section_parts.get(e.id, {})
var label: Label = parts.get("title")
if is_instance_valid(label):
label.text = Inspector._title_of(e.text, "(nothing)")

View file

@ -1 +0,0 @@
uid://bhb60l4tafo4c

View file

@ -1,121 +0,0 @@
class_name InspectorRange
extends RefCounted
## A result's place on its card, in the inspector's result section: its weight
## (die faces on a Weights card, chance on a plain card) or its range (From–To
## on a Ranges card), and its position (▲ ▼ or a typed number). Edits go
## through RangeWeights.after_edit, so Weights reflow and auto-sort apply, as
## they do on the card.
static func build(insp: Inspector, box: VBoxContainer, t: RollTable, e: TableEntry) -> void:
var fixed := t.kind == RollTable.KIND_LOOP or (t.kind == RollTable.KIND_CHOICE and t.choice != "pick")
if fixed or t.kind == RollTable.KIND_SHEET:
return
if t.kind == RollTable.KIND_ROLL or t.kind == RollTable.KIND_CHOICE:
if RangeWeights.uses_weights(t) or not t.is_ranged():
box.add_child(InspectorKit.field("Weight (die faces)" if t.is_ranged() else "Weight", _weight_row(insp, t, e)))
else:
box.add_child(InspectorKit.field("Range", _range_row(insp, t, e)))
if t.entries.size() > 1:
box.add_child(InspectorKit.field("Position", _position_row(insp, t, e)))
static func _weight_row(insp: Inspector, t: RollTable, e: TableEntry) -> Control:
var row := InspectorKit.hbox(8)
var amount := InspectorKit.line(str(e.weight), "1", 64.0)
InspectorKit.tag(amount, "res.weight")
insp.fields["weight"] = amount
amount.text_submitted.connect(func(_s: String) -> void: amount.release_focus())
amount.focus_exited.connect(func() -> void:
var typed := amount.text.strip_edges()
if typed.is_valid_int():
set_weight(insp, t, e, typed.to_int()))
row.add_child(amount)
if t.is_ranged():
row.add_child(InspectorKit.note("rolls %s" % (t.num_label(e, t.entries.find(e)) if e.has_range else "never"), Style.MUTED, 13))
else:
row.add_child(InspectorKit.note("0 = never comes up", Style.MUTED, 13))
return row
static func _range_row(insp: Inspector, t: RollTable, e: TableEntry) -> Control:
var row := InspectorKit.hbox(6)
var from := InspectorKit.line(str(e.range_lo), "1", 64.0)
var to := InspectorKit.line(str(e.range_hi), "1", 64.0)
InspectorKit.tag(from, "res.range_lo")
InspectorKit.tag(to, "res.range_hi")
insp.fields["range_lo"] = from
insp.fields["range_hi"] = to
var commit := func() -> void:
var lo := from.text.strip_edges()
var hi := to.text.strip_edges()
if lo.is_valid_int() and hi.is_valid_int():
set_range(insp, t, e, lo.to_int(), hi.to_int())
for edit: LineEdit in [from, to]:
edit.text_submitted.connect(func(_s: String) -> void: edit.release_focus())
edit.focus_exited.connect(commit)
row.add_child(from)
row.add_child(InspectorKit.word("–"))
row.add_child(to)
return row
static func _position_row(insp: Inspector, t: RollTable, e: TableEntry) -> Control:
var row := InspectorKit.hbox(6)
var at := t.entries.find(e)
var up := ModalCard.make_button("▲")
up.tooltip_text = "Move up one row"
up.disabled = at <= 0
up.pressed.connect(func() -> void: move_to(insp, t, e, at - 1))
var down := ModalCard.make_button("▼")
down.tooltip_text = "Move down one row"
down.disabled = at >= t.entries.size() - 1
down.pressed.connect(func() -> void: move_to(insp, t, e, at + 1))
var number := InspectorKit.line(str(at + 1), "", 52.0)
InspectorKit.tag(number, "res.position")
insp.fields["position"] = number
number.text_submitted.connect(func(_s: String) -> void: number.release_focus())
number.focus_exited.connect(func() -> void:
var typed := number.text.strip_edges()
if typed.is_valid_int() and typed.to_int() - 1 != t.entries.find(e):
move_to(insp, t, e, typed.to_int() - 1))
for c: Control in [up, down, number]:
row.add_child(c)
row.add_child(InspectorKit.note("of %d" % t.entries.size(), Style.MUTED, 13))
return row
static func set_weight(insp: Inspector, t: RollTable, e: TableEntry, w: int) -> void:
w = clampi(w, 0, 9999)
if w == e.weight:
return
e.weight = w
RangeWeights.after_edit(t)
insp.wrote(t, false, true)
static func set_range(insp: Inspector, t: RollTable, e: TableEntry, lo: int, hi: int) -> void:
var limit := TableCardEditing.RANGE_LIMIT
lo = clampi(lo, -limit, limit)
hi = clampi(hi, -limit, limit)
if lo == e.range_lo and hi == e.range_hi:
return
e.range_lo = lo
e.range_hi = hi
e.has_range = true
RangeWeights.after_edit(t)
insp.wrote(t, false, true)
## Moves the result to row `to` (0-based, clamped). On a Ranges card with
## auto-sort the row may go back to its place in roll order; a toast says so.
static func move_to(insp: Inspector, t: RollTable, e: TableEntry, to: int) -> void:
var from := t.entries.find(e)
to = clampi(to, 0, t.entries.size() - 1)
if from < 0 or from == to:
return
t.entries.remove_at(from)
t.entries.insert(to, e)
if RangeWeights.after_edit(t):
insp.main.toast("Auto-sort put the rows back in roll order (turn it off in the card's section)")
insp.wrote(t, false, true)

View file

@ -1 +0,0 @@
uid://exp3vts6sv6n

View file

@ -9,17 +9,17 @@ extends RefCounted
static func book_line(insp: Inspector, t: RollTable, e: TableEntry) -> Control: static func book_line(insp: Inspector, t: RollTable, e: TableEntry) -> Control:
var p := insp.main.data.get_page(e.page) var p := insp.main.data.get_page(e.page)
if p == null: if p == null:
var save := InspectorKit.link("Save to the Lore Index", "Keep this result as a Lore Entry to reuse on other tables") var save := InspectorKit.link("Save to the Book", "Keep this result as a Page to reuse on other tables")
save.pressed.connect(func() -> void: insp.main.book.save_result(t, e)) save.pressed.connect(func() -> void: insp.main.book.save_result(t, e))
return save return save
var row := InspectorKit.hbox(8) var row := InspectorKit.hbox(8)
var open := InspectorKit.link("§ Lore Entry: %s" % p.label(), "Edit the Lore Entry; every result using it changes") var open := InspectorKit.link("§ From the Book: %s" % p.label(), "Edit the page; every result using it changes")
open.pressed.connect(func() -> void: open.pressed.connect(func() -> void:
insp.main.book.set_shown(true) insp.main.book.set_shown(true)
insp.main.book.refresh() insp.main.book.refresh()
insp.main.book.select_page(p.id)) insp.main.book.select_page(p.id))
row.add_child(open) row.add_child(open)
var unlink := InspectorKit.link("Unlink", "Keep the text here but stop following the Lore Entry") var unlink := InspectorKit.link("Unlink", "Keep the text here but stop following the page")
unlink.pressed.connect(func() -> void: unlink.pressed.connect(func() -> void:
e.page = "" e.page = ""
insp.wrote(t, false, true)) insp.wrote(t, false, true))
@ -61,11 +61,9 @@ static func card_link(insp: Inspector, t: RollTable) -> Button:
return b return b
## `with_head`: false inside the inspector's list, which has its own headers. static func section(insp: Inspector, t: RollTable, e: TableEntry) -> void:
static func section(insp: Inspector, t: RollTable, e: TableEntry, with_head: bool = true) -> void: insp._content.add_child(insp._head("Selected result", Inspector._title_of(e.text, "(no text)")))
if with_head: insp._content.add_child(card_link(insp, t))
insp._content.add_child(insp._head("Selected result", Inspector._title_of(e.text, "(no text)")))
insp._content.add_child(card_link(insp, t))
var plain := insp.main.rules_plain() var plain := insp.main.rules_plain()
if t.kind != RollTable.KIND_SHEET: if t.kind != RollTable.KIND_SHEET:
@ -78,7 +76,6 @@ static func section(insp: Inspector, t: RollTable, e: TableEntry, with_head: boo
le.text = (le.text.strip_edges() + " " + ref).strip_edges() le.text = (le.text.strip_edges() + " " + ref).strip_edges()
insp.set_entry_text(le.text))) insp.set_entry_text(le.text)))
insp.fields["text"] = le insp.fields["text"] = le
SpellUnderline.attach(le, insp.main)
insp._content.add_child(InspectorKit.field(Inspector._title_of(str(t.columns[0].get("name", "")), "Text") if t.has_columns() else "Text", le)) insp._content.add_child(InspectorKit.field(Inspector._title_of(str(t.columns[0].get("name", "")), "Text") if t.has_columns() else "Text", le))
insp._content.add_child(link) insp._content.add_child(link)
InspectorColumns.result_cells(insp, t, e) InspectorColumns.result_cells(insp, t, e)
@ -87,7 +84,6 @@ static func section(insp: Inspector, t: RollTable, e: TableEntry, with_head: boo
InspectorKit.tag(det, "res.details") InspectorKit.tag(det, "res.details")
det.text_changed.connect(func() -> void: insp.set_entry_details(det.text)) det.text_changed.connect(func() -> void: insp.set_entry_details(det.text))
insp.fields["details"] = det insp.fields["details"] = det
SpellUnderline.attach(det, insp.main)
insp._content.add_child(InspectorKit.field("Details", det)) insp._content.add_child(InspectorKit.field("Details", det))
insp._content.add_child(InspectorKit.field("Picture", ImageField.new(insp.main, e.image, func(id: String) -> void: insp._content.add_child(InspectorKit.field("Picture", ImageField.new(insp.main, e.image, func(id: String) -> void:
e.image = id e.image = id

View file

@ -52,7 +52,6 @@ static func build(insp: Inspector, box: VBoxContainer, t: RollTable, plain: bool
) )
v.add_child(err) v.add_child(err)
box.add_child(InspectorKit.field("Rolls", v)) box.add_child(InspectorKit.field("Rolls", v))
box.add_child(InspectorKit.field("Edit ranges as", edit_mode(insp, t)))
_modifier_field(insp, box, t, plain) _modifier_field(insp, box, t, plain)
box.add_child(InspectorKit.field("Limits", limits(insp, t))) box.add_child(InspectorKit.field("Limits", limits(insp, t)))
@ -77,27 +76,6 @@ static func build(insp: Inspector, box: VBoxContainer, t: RollTable, plain: bool
refresh.call() refresh.call()
## Weights or Ranges (RangeWeights), with Auto-sort for Ranges.
static func edit_mode(insp: Inspector, t: RollTable) -> Control:
var v := InspectorKit.vbox(6)
var weights := t.range_edit == RangeWeights.WEIGHTS
var seg := ModalCard.segmented(["Weights", "Ranges"], 0 if weights else 1, func(i: int) -> void:
insp.apply_settings({"range_edit": RangeWeights.WEIGHTS if i == 0 else RangeWeights.RANGES}, true)
)
InspectorKit.tag(seg, "card.range_edit")
v.add_child(seg)
if weights:
v.add_child(InspectorKit.note("Type how many die faces each result covers; the ranges follow the row order.", Style.MUTED, 13))
else:
v.add_child(InspectorKit.note("Type each range by hand, as a printed table does.", Style.MUTED, 13))
var sort := InspectorKit.check_box("Auto-sort rows by range", t.auto_sort)
sort.tooltip_text = "After an edit or a drag, rows put themselves back in roll order"
InspectorKit.tag(sort, "card.auto_sort")
sort.toggled.connect(func(on: bool) -> void: insp.apply_settings({"auto_sort": on}, true))
v.add_child(sort)
return v
## "Never below [ ]" and "Never above [ ]": a number, or a value an earlier ## "Never below [ ]" and "Never above [ ]": a number, or a value an earlier
## result sets (so one table can adjust a later one), via RollTable.roll_floor ## result sets (so one table can adjust a later one), via RollTable.roll_floor
## and roll_ceiling. ## and roll_ceiling.

View file

@ -156,13 +156,7 @@ func add_entry(tid: String) -> void:
m.undo_redo._begin_edit() m.undo_redo._begin_edit()
var t := m.data.get_table(tid) var t := m.data.get_table(tid)
var e := TableEntry.new(TowerBoard.new_id("e"), "Result %d" % (t.entries.size() + 1)) var e := TableEntry.new(TowerBoard.new_id("e"), "Result %d" % (t.entries.size() + 1))
if RangeWeights.uses_weights(t): if t.is_ranged():
e.has_range = true
e.weight = 1
e.text = "New result"
t.entries.append(e)
RangeWeights.reflow(t)
elif t.is_ranged():
var hi := 0 var hi := 0
for x in t.entries: for x in t.entries:
hi = maxi(hi, x.range_hi) hi = maxi(hi, x.range_hi)
@ -171,8 +165,7 @@ func add_entry(tid: String) -> void:
e.range_lo = hi + 1 if t.has_mod() else clampi(hi + 1, t.min_value(), t.die_size()) e.range_lo = hi + 1 if t.has_mod() else clampi(hi + 1, t.min_value(), t.die_size())
e.range_hi = e.range_lo e.range_hi = e.range_lo
e.text = "New range" e.text = "New range"
if not t.entries.has(e): t.entries.append(e)
t.entries.append(e)
t.collapsed = false t.collapsed = false
m.card_for(tid).rebuild() m.card_for(tid).rebuild()
m.undo_redo._end_edit() m.undo_redo._end_edit()

View file

@ -90,7 +90,7 @@ func _build_ui() -> void:
if m.state and bool(m.state.get_setting("inspector_collapsed", false)): if m.state and bool(m.state.get_setting("inspector_collapsed", false)):
m.inspector.set_collapsed(true) m.inspector.set_collapsed(true)
middle.add_child(m.inspector) middle.add_child(m.inspector)
SideTabs.sync(m) m.inspector._sync_splitter()
m.editing._build_selection_bar() m.editing._build_selection_bar()
m.tray = ResultTray.new() m.tray = ResultTray.new()
m.tray.setup(m) m.tray.setup(m)
@ -157,10 +157,9 @@ func set_mode(new_mode: Main.Mode) -> void:
m.top_bar._hint.tooltip_text = Main.HINTS[new_mode] m.top_bar._hint.tooltip_text = Main.HINTS[new_mode]
m.top_bar._hint.custom_minimum_size.x = 60.0 if new_mode == Main.Mode.PLAY else 0.0 m.top_bar._hint.custom_minimum_size.x = 60.0 if new_mode == Main.Mode.PLAY else 0.0
m.top_bar._build_tools.visible = new_mode == Main.Mode.BUILD m.top_bar._build_tools.visible = new_mode == Main.Mode.BUILD
m.top_bar.play_add_button.visible = new_mode == Main.Mode.PLAY
m.board.pipes.hover_key = "" m.board.pipes.hover_key = ""
m.clear_selection() m.clear_selection()
SideTabs.sync(m) m.inspector.visible = new_mode == Main.Mode.BUILD
if new_mode != Main.Mode.BUILD: if new_mode != Main.Mode.BUILD:
m.inspector.clear() m.inspector.clear()
for card in m.cards.values(): for card in m.cards.values():

View file

@ -13,8 +13,6 @@ var _pulse_tween: Tween
## True when _play_one lit nodes again (after a pause) without redrawing yet. ## True when _play_one lit nodes again (after a pause) without redrawing yet.
var _relit := false var _relit := false
var _choice: ChoiceDialog var _choice: ChoiceDialog
## True while the roll asking a question skips animations (its pop-up appears at once).
var _ask_fast := false
## Rolls waiting at a paused thread. ## Rolls waiting at a paused thread.
var pauses: RollPauses var pauses: RollPauses
## Deck-mode draws not shown yet in an animated roll. ## Deck-mode draws not shown yet in an animated roll.
@ -35,10 +33,10 @@ func _init(p_main: Main) -> void:
## Rolls a table and plays the result down its pipes. A fast roll (Shift held ## Rolls a table and plays the result down its pipes. A fast roll (Shift held
## while clicking, or `fast`) skips the flicker and the beads and shows the ## while clicking, or `fast`) skips the flicker and the beads and shows the
## whole result at once; so does the "Skip animations" setting. Choice cards ## whole result at once. Choice cards still ask (docs/LOGIC.md §8): before a
## still ask (docs/LOGIC.md §8): the roll animates up to the question, waits, ## question opens, the steps so far light up; after the last answer the rest
## then animates the rest, as a pause does. Starting a roll while a question ## of the roll shows at once. Starting a roll while a question is open cancels
## is open cancels the old roll. ## the old roll.
func start_roll(tid: String, fast: bool = false) -> void: func start_roll(tid: String, fast: bool = false) -> void:
var t := m.data.get_table(tid) var t := m.data.get_table(tid)
if t == null or t.kind == RollTable.KIND_VARIABLE: if t == null or t.kind == RollTable.KIND_VARIABLE:
@ -50,7 +48,7 @@ func start_roll(tid: String, fast: bool = false) -> void:
# A minimized question keeps waiting; a new roll must not cancel it. # A minimized question keeps waiting; a new roll must not cancel it.
if _choice_waiting("Answer the waiting question first"): if _choice_waiting("Answer the waiting question first"):
return return
fast = fast or Input.is_key_pressed(KEY_SHIFT) or SkipAnimations.on(m) fast = fast or Input.is_key_pressed(KEY_SHIFT)
_archive_current() _archive_current()
_token += 1 _token += 1
if m.sound: if m.sound:
@ -82,7 +80,9 @@ func start_roll(tid: String, fast: bool = false) -> void:
if ctx.persistent_changed: if ctx.persistent_changed:
m.local_state._store_variables() m.local_state._store_variables()
return return
# A question, pause or cost animates up to itself; the rest animates after. # Questions light the roll so far at once, so the rest shows at once too;
# a pause (or a cost) animates up to itself and the rest animates after.
var prompted: bool = run.get("other_prompt", false)
m.lit_entries.clear() m.lit_entries.clear()
m.lit_pipes.clear() m.lit_pipes.clear()
m.lit_texts.clear() m.lit_texts.clear()
@ -92,7 +92,7 @@ func start_roll(tid: String, fast: bool = false) -> void:
if ctx.halted != "": if ctx.halted != "":
m.current["halted"] = ctx.halted m.current["halted"] = ctx.halted
m.local_state._store_roll(ctx) m.local_state._store_roll(ctx)
if fast or (m.current["all"] as Array).size() > LONG_CHAIN: if fast or prompted or (m.current["all"] as Array).size() > LONG_CHAIN:
_finish_fast_roll() _finish_fast_roll()
return return
deck_reveal.hold(m.current["all"], my) deck_reveal.hold(m.current["all"], my)
@ -118,25 +118,26 @@ func _prompt_for(req: Dictionary, run: Dictionary) -> Variant:
m.current["prompted"] = true m.current["prompted"] = true
m.current["asking"] = Formatter.strip_tags(str(req.get("title", ""))) m.current["asking"] = Formatter.strip_tags(str(req.get("title", "")))
var reply: Variant var reply: Variant
if run.get("fast", false) or m.rolling_ctx == null:
show_progress()
else:
# The roll so far animates (dice, lights, threads), then it waits.
# Steps shown before an earlier pause are listed again as they replay,
# and the previous roll's lights go out first.
m.current["steps"] = []
m.lit_entries.clear()
m.lit_pipes.clear()
m.lit_texts.clear()
m.lit_columns.clear()
m._refresh_lit()
await _play_node(m.rolling_ctx.root, int(run["token"]))
if int(run["token"]) != _token:
return null
_ask_fast = run.get("fast", false)
if str(req.get("kind", "")) == "pause": if str(req.get("kind", "")) == "pause":
if run.get("fast", false) or m.rolling_ctx == null:
show_progress()
else:
# The roll so far animates (dice, lights, threads), then it waits.
# Steps shown before an earlier pause are listed again as they replay,
# and the previous roll's lights go out first.
m.current["steps"] = []
m.lit_entries.clear()
m.lit_pipes.clear()
m.lit_texts.clear()
m.lit_columns.clear()
m._refresh_lit()
await _play_node(m.rolling_ctx.root, int(run["token"]))
if int(run["token"]) != _token:
return null
reply = await pauses.wait(req, run) reply = await pauses.wait(req, run)
else: else:
run["other_prompt"] = true
show_progress()
reply = await m.prompt_hook.call(req) reply = await m.prompt_hook.call(req)
if int(run["token"]) != _token: if int(run["token"]) != _token:
return null return null
@ -149,7 +150,6 @@ func _prompt_for(req: Dictionary, run: Dictionary) -> Variant:
func _ask_player(req: Dictionary) -> Variant: func _ask_player(req: Dictionary) -> Variant:
cancel_choice() cancel_choice()
var d := ChoiceDialog.new(req) var d := ChoiceDialog.new(req)
d.animate_in = not _ask_fast
_choice = d _choice = d
var waiter := d.reply var waiter := d.reply
m._add_modal(d) m._add_modal(d)

View file

@ -22,10 +22,6 @@ var zoom: ZoomControl
var _toast: PanelContainer var _toast: PanelContainer
var _toast_label: Label var _toast_label: Label
var _toast_undo: Button var _toast_undo: Button
## The toast button's own action (toast_action), or empty for Undo.
var _toast_do := Callable()
## Play mode's greyed "+ Card" (BuildModeHint).
var play_add_button: Button
var _toast_timer: Timer var _toast_timer: Timer
## The undo step the toast's Undo button undoes (EditHistory serial), or -1. ## The undo step the toast's Undo button undoes (EditHistory serial), or -1.
var _toast_serial := -1 var _toast_serial := -1
@ -122,8 +118,6 @@ func _build_top_bar() -> Control:
tools.add_child(_board_menu) tools.add_child(_board_menu)
tools.visible = false tools.visible = false
h.add_child(tools) h.add_child(tools)
play_add_button = BuildModeHint.make_button(m)
h.add_child(play_add_button)
_endless_chip = _make_endless_chip() _endless_chip = _make_endless_chip()
h.add_child(_endless_chip) h.add_child(_endless_chip)
@ -218,12 +212,7 @@ func _build_toast() -> void:
var un := Style.box(Style.BG, 7, [12, 5, 12, 5]) var un := Style.box(Style.BG, 7, [12, 5, 12, 5])
var uh := Style.box(Style.BG_HOVER, 7, [12, 5, 12, 5]) var uh := Style.box(Style.BG_HOVER, 7, [12, 5, 12, 5])
Style.skin_button(_toast_undo, un, uh, uh, Style.ACCENT) Style.skin_button(_toast_undo, un, uh, uh, Style.ACCENT)
_toast_undo.pressed.connect(func() -> void: _toast_undo.pressed.connect(_undo)
if _toast_do.is_valid():
_toast.hide()
_toast_do.call()
else:
_undo())
_toast_undo.focus_mode = Control.FOCUS_NONE _toast_undo.focus_mode = Control.FOCUS_NONE
h.add_child(_toast_undo) h.add_child(_toast_undo)
_toast.hide() _toast.hide()
@ -242,8 +231,6 @@ func _build_toast() -> void:
## the edit just committed (it goes through the edit history, like Ctrl+Z). ## the edit just committed (it goes through the edit history, like Ctrl+Z).
func toast(message: String, undoable: bool = false) -> void: func toast(message: String, undoable: bool = false) -> void:
_toast_serial = m.undo_redo.edits.top_serial() if undoable and m.undo_redo.edits else -1 _toast_serial = m.undo_redo.edits.top_serial() if undoable and m.undo_redo.edits else -1
_toast_do = Callable()
_toast_undo.text = "Undo"
_toast_label.text = message _toast_label.text = message
_toast_undo.visible = _toast_serial >= 0 _toast_undo.visible = _toast_serial >= 0
_toast.show() _toast.show()
@ -252,16 +239,6 @@ func toast(message: String, undoable: bool = false) -> void:
_toast_timer.start() _toast_timer.start()
## A toast whose button runs `on_press` (labelled `label`) instead of Undo.
func toast_action(message: String, label: String, on_press: Callable) -> void:
toast(message)
_toast_do = on_press
_toast_undo.text = label
_toast_undo.show()
_toast.reset_size()
_place_toast()
func _place_toast() -> void: func _place_toast() -> void:
if _toast and _toast.visible: if _toast and _toast.visible:
_toast.reset_size() _toast.reset_size()

View file

@ -11,8 +11,6 @@ var body: VBoxContainer
var footer: HBoxContainer var footer: HBoxContainer
var title_label: Label var title_label: Label
var close_on_backdrop := true var close_on_backdrop := true
## Fade and rise in when shown (roll pop-ups, unless animations are skipped).
var animate_in := false
var _scroll: ScrollContainer var _scroll: ScrollContainer
var _width := 520.0 var _width := 520.0
@ -72,22 +70,8 @@ func _init(title: String = "", width: float = 520.0) -> void:
func _ready() -> void: func _ready() -> void:
resized.connect(_fit) resized.connect(_fit)
_fit() _fit()
if animate_in:
modulate.a = 0.0
await get_tree().process_frame await get_tree().process_frame
_fit() _fit()
if animate_in and is_inside_tree():
_play_entrance()
## The backdrop fades in while the card grows into place with a small overshoot.
## (Scale only: the card sits in a CenterContainer, which owns its position.)
func _play_entrance() -> void:
card.pivot_offset = card.size / 2.0
card.scale = Vector2(0.94, 0.94)
var tween := create_tween().set_parallel(true)
tween.tween_property(self, "modulate:a", 1.0, 0.2).set_ease(Tween.EASE_OUT)
tween.tween_property(card, "scale", Vector2.ONE, 0.3).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
func _fit() -> void: func _fit() -> void:

View file

@ -20,10 +20,10 @@ func show_page(p: BookPage) -> void:
for c in get_children(): for c in get_children():
c.queue_free() c.queue_free()
if p == null: if p == null:
add_child(_note("Pick a Lore Entry to edit it, or press + Lore Entry.")) add_child(_note("Pick a page to edit it, or press + Page."))
return return
var name_edit := _line(p.name, p.label(), func(s: String) -> void: p.name = s.strip_edges()) var name_edit := _line(p.name, p.label(), func(s: String) -> void: p.name = s.strip_edges())
add_child(_field("Name in the Lore Index", name_edit)) add_child(_field("Name in the Book", name_edit))
var text := TextEdit.new() var text := TextEdit.new()
text.text = p.text text.text = p.text
text.placeholder_text = "The result, e.g. [b][color=gold]The Sword of Holy Light[/color][/b]" text.placeholder_text = "The result, e.g. [b][color=gold]The Sword of Holy Light[/color][/b]"
@ -35,7 +35,6 @@ func show_page(p: BookPage) -> void:
_preview.text = RichText.decorate(p.text) _preview.text = RichText.decorate(p.text)
_changed()) _changed())
add_child(_field("Result text", text)) add_child(_field("Result text", text))
SpellUnderline.attach(text, m)
_preview = RichText.label(RichText.decorate(p.text), 16, Style.INK, false, true) _preview = RichText.label(RichText.decorate(p.text), 16, Style.INK, false, true)
var pv := PanelContainer.new() var pv := PanelContainer.new()
pv.add_theme_stylebox_override("panel", Style.box(Style.CARD, 6, [10, 6, 10, 6])) pv.add_theme_stylebox_override("panel", Style.box(Style.CARD, 6, [10, 6, 10, 6]))
@ -47,7 +46,6 @@ func show_page(p: BookPage) -> void:
det.wrap_mode = TextEdit.LINE_WRAPPING_BOUNDARY det.wrap_mode = TextEdit.LINE_WRAPPING_BOUNDARY
det.custom_minimum_size = Vector2(0, 60) det.custom_minimum_size = Vector2(0, 60)
ModalCard.style_text_edit(det) ModalCard.style_text_edit(det)
SpellUnderline.attach(det, m)
det.text_changed.connect(func() -> void: det.text_changed.connect(func() -> void:
p.details = det.text p.details = det.text
_changed()) _changed())
@ -65,8 +63,8 @@ func show_page(p: BookPage) -> void:
_uses = _note("") _uses = _note("")
add_child(_uses) add_child(_uses)
_refresh_uses() _refresh_uses()
var del := Style.bar_button("Delete Lore Entry") var del := Style.bar_button("Delete page")
del.tooltip_text = "Results using it keep their text and stop following the Lore Entry" del.tooltip_text = "Results using it keep their text and stop following the page"
del.size_flags_horizontal = SIZE_SHRINK_BEGIN del.size_flags_horizontal = SIZE_SHRINK_BEGIN
del.pressed.connect(func() -> void: del.pressed.connect(func() -> void:
m.undo_redo._begin_edit() m.undo_redo._begin_edit()
@ -87,7 +85,7 @@ func _changed() -> void:
func _refresh_uses() -> void: func _refresh_uses() -> void:
var n := m.data.page_uses(page.id) var n := m.data.page_uses(page.id)
_uses.text = "Used by %d %s. Drag the Lore Entry from the list onto a result to use it there." % [n, "result" if n == 1 else "results"] _uses.text = "Used by %d %s. Drag the page from the list onto a result to use it there." % [n, "result" if n == 1 else "results"]
func _line(text: String, placeholder: String, on_change: Callable) -> LineEdit: func _line(text: String, placeholder: String, on_change: Callable) -> LineEdit:

View file

@ -45,7 +45,6 @@ func _popup(item: Dictionary) -> ModalCard:
dialog.add_button("Later", "plain", dialog.close) dialog.add_button("Later", "plain", dialog.close)
dialog.add_button("Don't pay" if item["cost"] else "Stop here", "plain", reply.bind(false)) dialog.add_button("Don't pay" if item["cost"] else "Stop here", "plain", reply.bind(false))
dialog.add_button("Pay ▸" if item["cost"] else "Continue ▸", "primary", reply.bind(true)) dialog.add_button("Pay ▸" if item["cost"] else "Continue ▸", "primary", reply.bind(true))
dialog.animate_in = not (item["run"] as Dictionary).get("fast", false)
m._add_modal(dialog) m._add_modal(dialog)
return dialog return dialog

View file

@ -1,49 +0,0 @@
class_name SideTabs
extends RefCounted
## In Build, the Inspector and the Lore Index share the right-hand dock as two
## tabs ("Inspector | Lore Index"); only one shows at a time. In Play there is
## no inspector, so the Lore Index opens on its own (no tab row).
## The Lore Index is BookPanel in code (TowerBoard.book, BookPage).
const INSPECTOR := "inspector"
const LORE := "lore"
## The tab row put at the top of both panels. `active` is the panel it sits on.
static func make_row(m: Main, active: String) -> HBoxContainer:
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 4)
for tab: Array in [[INSPECTOR, "Inspector"], [LORE, "Lore Index"]]:
var b := Button.new()
b.text = tab[1]
b.toggle_mode = true
b.button_pressed = tab[0] == active
b.focus_mode = Control.FOCUS_NONE
b.size_flags_horizontal = Control.SIZE_EXPAND_FILL
b.add_theme_font_override("font", Style.body_bold())
b.add_theme_font_size_override("font_size", 14)
var normal := Style.box(Color(0, 0, 0, 0.06), 6, [10, 5, 10, 5])
var hover := Style.box(Color(0, 0, 0, 0.12), 6, [10, 5, 10, 5])
var on := Style.bordered(Style.box(Style.CARD, 6, [10, 5, 10, 5]), 2, Style.TRIM)
Style.skin_button(b, normal, hover, on, Style.MUTED, Style.INK, Style.INK)
var which: String = tab[0]
b.pressed.connect(func() -> void: show_tab(m, which))
row.add_child(b)
return row
## Shows one tab. The Lore Index tab opens the Lore Index; the Inspector tab closes it.
static func show_tab(m: Main, which: String) -> void:
if m.book:
m.book.set_shown(which == LORE)
## Brings the dock in line with the mode: in Build an open Lore Index hides the
## inspector; in Play the inspector is always hidden.
static func sync(m: Main) -> void:
if m.inspector == null or m.book == null:
return
var build := m.mode == Main.Mode.BUILD
m.inspector.visible = build and not m.book.visible
m.inspector._sync_splitter()
m.book.show_tabs(build)

View file

@ -1 +0,0 @@
uid://bjqt8hiravlht

View file

@ -1,20 +0,0 @@
class_name SkipAnimations
extends RefCounted
## The "Skip animations" setting (View ▾): every roll shows its result at once,
## with no flicker, beads or pop-up motion. Shift-click does the same for one roll.
const SETTING := "skip_animations"
## Used when there is no state store (tests that build a bare Main).
static var _skip_mem := false
static func on(m: Main) -> bool:
return bool(m.state.get_setting(SETTING, false)) if m and m.state else _skip_mem
static func set_on(m: Main, value: bool) -> void:
_skip_mem = value
if m and m.state:
m.state.set_setting(SETTING, value)
m.state.save()

View file

@ -1 +0,0 @@
uid://c7430sis573db

View file

@ -1,223 +0,0 @@
class_name SpellUnderline
extends Control
## Red wavy lines under misspelled words in one LineEdit or TextEdit (Build
## only), laid over the field. Right-clicking such a word opens a menu of
## suggestions, "Add to dictionary" (the spread's own words) and "Ignore",
## then the usual Cut, Copy and Paste. Spellcheck does the checking.
const GROUP := "spell_underline"
const WAVE := 2.0
const ID_ADD := 100
const ID_IGNORE := 101
const ID_CUT := 102
const ID_COPY := 103
const ID_PASTE := 104
var field: Control
var m: Main
## Misspelled word ranges in the field's text, from the last check.
var bad: Array[Vector2i] = []
var _menu: PopupMenu
var _menu_range := Vector2i(-1, -1)
## Adds underlines to `field`, if spellchecking is available.
static func attach(field: Control, p_main: Main) -> void:
if p_main == null or field.has_meta("spell") or not Spellcheck.available():
return
var u := SpellUnderline.new()
u.field = field
u.m = p_main
field.set_meta("spell", u)
field.add_child(u)
func _ready() -> void:
set_anchors_and_offsets_preset(PRESET_FULL_RECT)
mouse_filter = MOUSE_FILTER_IGNORE
# Text scrolled out of a narrow field must not be underlined outside it.
clip_contents = true
add_to_group(GROUP)
if field is LineEdit:
(field as LineEdit).text_changed.connect(func(_s: String) -> void: recheck())
else:
(field as TextEdit).text_changed.connect(recheck)
(field as TextEdit).get_v_scroll_bar().value_changed.connect(func(_v: float) -> void: queue_redraw())
field.resized.connect(queue_redraw)
field.gui_input.connect(_on_field_input)
recheck()
## The field's text scrolls as the caret moves, so a focused field redraws.
func _process(_delta: float) -> void:
if field.has_focus():
queue_redraw()
func text() -> String:
return (field as LineEdit).text if field is LineEdit else (field as TextEdit).text
func recheck() -> void:
bad = Spellcheck.misspelled(text(), m.data) if m.mode == Main.Mode.BUILD else ([] as Array[Vector2i])
queue_redraw()
func _draw() -> void:
for r in bad:
for seg in _segments(r):
_wave(seg[0], seg[1], seg[2])
## Wavy line from x0 to x1 at height y.
func _wave(x0: float, x1: float, y: float) -> void:
var pts := PackedVector2Array()
var x := x0
var up := true
while x <= x1:
pts.append(Vector2(x, y + (-WAVE if up else WAVE) * 0.5))
x += WAVE
up = not up
if pts.size() >= 2:
draw_polyline(pts, Style.DANGER, 1.2, true)
## [x0, x1, y] pieces under range `r` (one per line it covers).
func _segments(r: Vector2i) -> Array:
if field is LineEdit:
var y := size.y - _line_margin_bottom()
var sb := field.get_theme_stylebox("normal")
var left := sb.get_margin(SIDE_LEFT) if sb else 0.0
var right := size.x - (sb.get_margin(SIDE_RIGHT) if sb else 0.0)
var x0 := maxf(left, _line_x(r.x))
var x1 := minf(right, _line_x(r.y))
return [[x0, x1, y]] if x1 > x0 else []
var edit := field as TextEdit
var out: Array = []
for i in range(r.x, r.y):
var lc := _line_col(i)
var rect := edit.get_rect_at_line_column(lc.x, lc.y)
if rect.size.x <= 0:
continue
var y := float(rect.position.y + rect.size.y) - 1.0
if not out.is_empty() and is_equal_approx(out[-1][2], y):
out[-1][1] = float(rect.position.x + rect.size.x)
else:
out.append([float(rect.position.x), float(rect.position.x + rect.size.x), y])
return out
func _line_margin_bottom() -> float:
var sb := field.get_theme_stylebox("normal")
return maxf(3.0, sb.get_margin(SIDE_BOTTOM) * 0.6) if sb else 4.0
## LineEdit: the x of the gap before character `column`.
func _line_x(column: int) -> float:
var line := field as LineEdit
var font := line.get_theme_font("font")
var font_size := line.get_theme_font_size("font_size")
var sb := line.get_theme_stylebox("normal")
var left := sb.get_margin(SIDE_LEFT) if sb else 0.0
var scroll: float = line.call("get_scroll_offset") if line.has_method("get_scroll_offset") else 0.0
return left - scroll + font.get_string_size(line.text.substr(0, column), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x
## TextEdit: Vector2i(line, column) of character offset `at`.
func _line_col(at: int) -> Vector2i:
var edit := field as TextEdit
var rest := at
for i in edit.get_line_count():
var n := edit.get_line(i).length()
if rest <= n:
return Vector2i(i, rest)
rest -= n + 1
return Vector2i(edit.get_line_count() - 1, 0)
## The character offset under a point in the field.
func offset_at(p: Vector2) -> int:
if field is LineEdit:
var best := 0
for column in (field as LineEdit).text.length() + 1:
if _line_x(column) <= p.x:
best = column
return best
var edit := field as TextEdit
var lc := edit.get_line_column_at_pos(Vector2i(p), false)
var offset := 0
for i in lc.y:
offset += edit.get_line(i).length() + 1
return offset + lc.x
func _on_field_input(ev: InputEvent) -> void:
var mb := ev as InputEventMouseButton
if mb == null or not mb.pressed or mb.button_index != MOUSE_BUTTON_RIGHT:
return
var at := offset_at(mb.position)
for r in bad:
if at >= r.x and at <= r.y:
field.accept_event()
open_menu(r, field.get_screen_position() + mb.position)
return
## The spelling menu for word range `r`, at a screen position.
func open_menu(r: Vector2i, at: Vector2) -> void:
if _menu == null:
_menu = PopupMenu.new()
ModalCard.style_popup(_menu)
_menu.id_pressed.connect(_on_menu)
add_child(_menu)
_menu.clear()
_menu_range = r
var word := text().substr(r.x, r.y - r.x)
var sugs := Spellcheck.suggestions(word)
for i in sugs.size():
_menu.add_item(sugs[i], i)
if sugs.is_empty():
_menu.add_item("No suggestions", 99)
_menu.set_item_disabled(_menu.get_item_index(99), true)
_menu.add_separator()
_menu.add_item("Add “%s” to dictionary" % word, ID_ADD)
_menu.set_item_tooltip(_menu.get_item_index(ID_ADD), "This spread accepts the word from now on (it travels with the spread)")
_menu.add_item("Ignore", ID_IGNORE)
_menu.set_item_tooltip(_menu.get_item_index(ID_IGNORE), "Accept it until the app closes")
_menu.add_separator()
_menu.add_item("Cut", ID_CUT)
_menu.add_item("Copy", ID_COPY)
_menu.add_item("Paste", ID_PASTE)
_menu.popup(Rect2i(Vector2i(at), Vector2i.ZERO))
func _on_menu(id: int) -> void:
var word := text().substr(_menu_range.x, _menu_range.y - _menu_range.x)
match id:
ID_ADD:
Spellcheck.add_to_dictionary(m, word)
ID_IGNORE:
Spellcheck.ignore(m, word)
ID_CUT:
field.call("menu_option", LineEdit.MENU_CUT if field is LineEdit else TextEdit.MENU_CUT)
ID_COPY:
field.call("menu_option", LineEdit.MENU_COPY if field is LineEdit else TextEdit.MENU_COPY)
ID_PASTE:
field.call("menu_option", LineEdit.MENU_PASTE if field is LineEdit else TextEdit.MENU_PASTE)
_:
if id >= 0 and id < Spellcheck.MAX_SUGGESTIONS:
replace(_menu_range, _menu.get_item_text(_menu.get_item_index(id)))
## Puts `word` in place of range `r` and tells the field's listeners.
func replace(r: Vector2i, word: String) -> void:
var new_text := SpellWords.replace(text(), r, word)
if field is LineEdit:
var line := field as LineEdit
line.text = new_text
line.caret_column = r.x + word.length()
line.text_changed.emit(line.text)
else:
var edit := field as TextEdit
edit.text = new_text
edit.text_changed.emit()

View file

@ -1 +0,0 @@
uid://2w17lsg5qyby

View file

@ -1,104 +0,0 @@
class_name Spellcheck
extends RefCounted
## English spellchecking for Build's prose fields (titles, result text,
## details), through Hunspell (the Godot-Hunspell add-on's SpellChecker class
## in addons/hunspell). Words the spread accepts live in TowerBoard.dictionary;
## Ignore lasts for this session. Off on Android (its keyboards check spelling)
## and whenever the add-on isn't there; then fields simply get no underlines.
const AFF := "res://addons/hunspell/dictionaries/en_US.aff"
const DIC := "res://addons/hunspell/dictionaries/en_US.dic"
const MAX_SUGGESTIONS := 5
## The checker (spell(word) -> bool, suggest(word) -> PackedStringArray), or
## null. Tests set a stand-in with use_backend().
static var backend: Object = null
static var _tried := false
static var _cache: Dictionary = {}
## Lower-case words ignored until the app closes.
static var ignored: Dictionary = {}
static func available() -> bool:
if OS.get_name() == "Android":
return false
_load()
return backend != null
static func _load() -> void:
if _tried:
return
_tried = true
if not ClassDB.class_exists("SpellChecker"):
return
var checker: Object = ClassDB.instantiate("SpellChecker")
if checker and checker.call("load_dictionary", AFF, DIC):
backend = checker
## Uses `checker` instead of Hunspell (tests); null turns spellchecking off.
static func use_backend(checker: Object) -> void:
backend = checker
_tried = true
_cache.clear()
ignored.clear()
## True when `word` is spelled right, ignored, or in the spread's dictionary.
static func is_ok(word: String, board: TowerBoard) -> bool:
if backend == null or ignored.has(word.to_lower()) or in_dictionary(board, word):
return true
if not _cache.has(word):
_cache[word] = bool(backend.call("spell", word))
return _cache[word]
## The word ranges in `text` that are spelled wrong.
static func misspelled(text: String, board: TowerBoard) -> Array[Vector2i]:
var out: Array[Vector2i] = []
if backend == null:
return out
for r in SpellWords.ranges(text):
if not is_ok(text.substr(r.x, r.y - r.x), board):
out.append(r)
return out
static func suggestions(word: String) -> PackedStringArray:
if backend == null:
return PackedStringArray()
var all: PackedStringArray = backend.call("suggest", word)
return all.slice(0, MAX_SUGGESTIONS)
static func in_dictionary(board: TowerBoard, word: String) -> bool:
if board == null:
return false
var low := word.to_lower()
for w in board.dictionary:
if w.to_lower() == low:
return true
return false
## "Add to dictionary": the spread accepts the word from now on (an undo step).
static func add_to_dictionary(m: Main, word: String) -> void:
if in_dictionary(m.data, word):
return
m.undo_redo._begin_edit()
m.data.dictionary.append(word)
m.mark_dirty()
m.undo_redo._end_edit()
recheck_all(m)
## "Ignore": accepted until the app closes, in every spread.
static func ignore(m: Main, word: String) -> void:
ignored[word.to_lower()] = true
recheck_all(m)
static func recheck_all(m: Main) -> void:
if m.is_inside_tree():
m.get_tree().call_group(SpellUnderline.GROUP, "recheck")

View file

@ -1 +0,0 @@
uid://cfwlxsb3mnyxm

View file

@ -40,11 +40,6 @@ static var FLICK := Color(0.953, 0.769, 0.314, 0.35)
static var PULSE := Color("#fff6d2") static var PULSE := Color("#fff6d2")
## Magic sparkle colour for glows and particles. ## Magic sparkle colour for glows and particles.
static var GLOW := Color("#f3c450") static var GLOW := Color("#f3c450")
## The glowing outline of a selected card in Build (Morgan's eye glint).
static var SELECTED := Color("#0fd077")
## The band behind a card's title. Themes that don't set it get a shade
## between the card face and Card shading (ThemeStore.apply).
static var CARD_HEAD := Color("#e6d8bd")
static var DANGER := Color("#e0574a") static var DANGER := Color("#e0574a")
static var DANGER_INK := Color("#a33a2c") static var DANGER_INK := Color("#a33a2c")
static var BAD_INK_ON_BG := Color("#ffb1a3") static var BAD_INK_ON_BG := Color("#ffb1a3")

View file

@ -77,8 +77,6 @@ var _style_dragging: StyleBoxFlat
var _style_drop: StyleBoxFlat var _style_drop: StyleBoxFlat
var _style_selected: StyleBoxFlat var _style_selected: StyleBoxFlat
var _selected := false var _selected := false
## True while the inspector shows this card (Build): it glows like a selected card.
var _inspected := false
## The result picked in the inspector (copper bar), or "". ## The result picked in the inspector (copper bar), or "".
var _selected_eid := "" var _selected_eid := ""
@ -159,7 +157,7 @@ static func hbox(sep: int) -> HBoxContainer:
func _num_width(build: bool, ranged: bool) -> float: func _num_width(build: bool, ranged: bool) -> float:
var wide := table.die_size() >= 100 var wide := table.die_size() >= 100
if build and ranged: if build and ranged:
return 100.0 if RangeWeights.uses_weights(table) else 90.0 return 90.0
if ranged: if ranged:
return 52.0 if wide else 40.0 return 52.0 if wide else 40.0
return 24.0 if wide else 22.0 return 24.0 if wide else 22.0
@ -229,14 +227,7 @@ func refresh_live() -> void:
header_ui.refresh_live() header_ui.refresh_live()
## The card the inspector shows: glows like a selected card in Build. ## Build-mode selection (Main.selection): a copper ring around the card.
func set_inspected(on: bool) -> void:
if _inspected != on:
_inspected = on
skin.apply_style()
## Build-mode selection (Main.selection): a glowing ring around the card.
func set_selected(on: bool) -> void: func set_selected(on: bool) -> void:
if _selected != on: if _selected != on:
_selected = on _selected = on

View file

@ -21,8 +21,6 @@ func text_edit(e: TableEntry, index: int, chosen: bool) -> LineEdit:
var edit := LineEdit.new() var edit := LineEdit.new()
edit.text = e.text edit.text = e.text
FormatMenu.attach(edit) FormatMenu.attach(edit)
if table.kind != RollTable.KIND_LOOP:
SpellUnderline.attach(edit, card.main)
if chosen: if chosen:
edit.placeholder_text = "(the option's name)" edit.placeholder_text = "(the option's name)"
edit.tooltip_text = "The result text. Leave it as Chosen (or empty) to show the picked option's name; {option_label}, {option_value} and {@[option]} work" edit.tooltip_text = "The result text. Leave it as Chosen (or empty) to show the picked option's name; {option_label}, {option_value} and {@[option]} work"
@ -36,8 +34,6 @@ func text_edit(e: TableEntry, index: int, chosen: bool) -> LineEdit:
edit.tooltip_text = "%s: shown each pass ({i} is the pass number)" % loop_rows[0] if index == 0 else "%s: runs once when the repeat ends" % loop_rows[1] edit.tooltip_text = "%s: shown each pass ({i} is the pass number)" % loop_rows[0] if index == 0 else "%s: runs once when the repeat ends" % loop_rows[1]
elif table.kind == RollTable.KIND_ROUTER: elif table.kind == RollTable.KIND_ROUTER:
edit.placeholder_text = "Result text" edit.placeholder_text = "Result text"
elif not chosen:
edit.placeholder_text = "(nothing)"
edit.text_changed.connect(func(s: String) -> void: edit.text_changed.connect(func(s: String) -> void:
e.text = s e.text = s
e.page = "" e.page = ""
@ -129,13 +125,17 @@ func move_entry(from: int, to: int) -> void:
var entries := card.table.entries var entries := card.table.entries
if from == to or from < 0 or from >= entries.size() or to < 0 or to >= entries.size(): if from == to or from < 0 or from >= entries.size() or to < 0 or to >= entries.size():
return return
# A row moves whole, with its range or weight; Weights then lay the ranges var ranges: Array = []
# out again, and auto-sort may put a Ranges card back in roll order. for e in entries:
ranges.append([e.has_range, e.range_lo, e.range_hi])
var moved := entries[from] var moved := entries[from]
entries.remove_at(from) entries.remove_at(from)
entries.insert(to, moved) entries.insert(to, moved)
if RangeWeights.after_edit(card.table): if card.table.is_ranged():
card.main.toast("Auto-sort put the rows back in roll order (turn it off in the card's settings)") for i in entries.size():
entries[i].has_range = ranges[i][0]
entries[i].range_lo = ranges[i][1]
entries[i].range_hi = ranges[i][2]
card.rebuild() card.rebuild()
card.main.mark_dirty() card.main.mark_dirty()
@ -156,39 +156,28 @@ func add_case() -> void:
## Weight on a plain table, shown as ×N. Also the number of copies in card mode. ## Weight on a plain table, shown as ×N. Also the number of copies in card mode.
## The weight box. `faces`: a Weights-mode ranged card, where the weight is func weight_edit(e: TableEntry) -> LineEdit:
## how many die faces the result covers (shown plain, in a range-style box).
func weight_edit(e: TableEntry, faces: bool = false) -> LineEdit:
var edit := LineEdit.new() var edit := LineEdit.new()
var shown := func(w: int) -> String: return str(w) if faces else "×%d" % w edit.text = "×%d" % e.weight
edit.text = shown.call(e.weight) edit.custom_minimum_size = Vector2(34, 0)
edit.custom_minimum_size = Vector2(40 if faces else 34, 0)
edit.alignment = HORIZONTAL_ALIGNMENT_CENTER edit.alignment = HORIZONTAL_ALIGNMENT_CENTER
edit.max_length = 4 edit.max_length = 4
edit.tooltip_text = "Weight: how many die faces this result covers (0 = never). The ranges follow the row order." if faces \ edit.tooltip_text = "Weight: how likely this result is, relative to the others (0 = never)"
else "Weight: how likely this result is, relative to the others (0 = never)"
edit.size_flags_vertical = Control.SIZE_SHRINK_CENTER edit.size_flags_vertical = Control.SIZE_SHRINK_CENTER
edit.add_theme_font_override("font", Style.display(true)) edit.add_theme_font_override("font", Style.display(true))
edit.add_theme_font_size_override("font_size", 15 if faces else 14) edit.add_theme_font_size_override("font_size", 14)
if faces: edit.add_theme_color_override("font_color", Style.MUTED)
edit.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 4, [2, 2, 2, 2]), 1, Style.RULE))
edit.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 4, [2, 2, 2, 2]), 1, Style.TRIM))
else:
edit.add_theme_color_override("font_color", Style.MUTED)
var commit := func() -> void: var commit := func() -> void:
var digits := "" var digits := ""
for ch in edit.text: for ch in edit.text:
if ch >= "0" and ch <= "9": if ch >= "0" and ch <= "9":
digits += ch digits += ch
var w := clampi(digits.to_int(), 0, 9999 if faces else 999) if digits != "" else e.weight var w := clampi(digits.to_int(), 0, 999) if digits != "" else e.weight
edit.text = shown.call(w) edit.text = "×%d" % w
if w != e.weight: if w != e.weight:
e.weight = w e.weight = w
card.update_deck() card.update_deck()
card.main.mark_dirty() card.main.mark_dirty()
if RangeWeights.uses_weights(card.table):
RangeWeights.reflow(card.table)
card.rebuild.call_deferred()
edit.text_submitted.connect(func(_t: String) -> void: commit.call()) edit.text_submitted.connect(func(_t: String) -> void: commit.call())
edit.focus_exited.connect(commit) edit.focus_exited.connect(commit)
return edit return edit
@ -219,11 +208,8 @@ func range_edit(e: TableEntry, is_lo: bool) -> LineEdit:
else: else:
e.range_hi = v e.range_hi = v
edit.text = str(e.range_lo if is_lo else e.range_hi) edit.text = str(e.range_lo if is_lo else e.range_hi)
card.update_warning()
card.main.mark_dirty() card.main.mark_dirty()
if RangeWeights.after_edit(table):
card.rebuild.call_deferred()
else:
card.update_warning()
edit.text_submitted.connect(func(_t: String) -> void: commit.call()) edit.text_submitted.connect(func(_t: String) -> void: commit.call())
edit.focus_exited.connect(commit) edit.focus_exited.connect(commit)
return edit return edit
@ -241,7 +227,7 @@ func make_footer(ranged: bool) -> Control:
wrap.add_child(h) wrap.add_child(h)
# Loops, sheets, variables and number/text choices have fixed rows. # Loops, sheets, variables and number/text choices have fixed rows.
if table.kind == RollTable.KIND_ROLL or (table.kind == RollTable.KIND_CHOICE and table.choice == "pick"): if table.kind == RollTable.KIND_ROLL or (table.kind == RollTable.KIND_CHOICE and table.choice == "pick"):
var label := "+ Add range" if ranged and not RangeWeights.uses_weights(table) else ("+ Add option" if table.kind == RollTable.KIND_CHOICE else "+ Add result") var label := "+ Add range" if ranged else ("+ Add option" if table.kind == RollTable.KIND_CHOICE else "+ Add result")
var add := footer_button(label, Style.INK) var add := footer_button(label, Style.INK)
add.pressed.connect(func() -> void: main.add_entry(table.id)) add.pressed.connect(func() -> void: main.add_entry(table.id))
h.add_child(add) h.add_child(add)

View file

@ -30,14 +30,10 @@ func make(build: bool, ranged: bool) -> Control:
var table := card.table var table := card.table
var main := card.main var main := card.main
var header := PanelContainer.new() var header := PanelContainer.new()
# A thicker band in its own colour: the place to grab the card. var hs := Style.box(Color(0, 0, 0, 0), 0, [12, 10, 10, 9])
var hs := Style.box(Style.CARD_HEAD, 8, [12, 13, 10, 12])
hs.corner_radius_bottom_left = 0
hs.corner_radius_bottom_right = 0
hs.border_width_bottom = 1 hs.border_width_bottom = 1
hs.border_color = Style.RULE hs.border_color = Style.RULE
header.add_theme_stylebox_override("panel", hs) header.add_theme_stylebox_override("panel", hs)
header.custom_minimum_size.y = 56
header.mouse_filter = Control.MOUSE_FILTER_PASS header.mouse_filter = Control.MOUSE_FILTER_PASS
header.mouse_default_cursor_shape = Control.CURSOR_MOVE header.mouse_default_cursor_shape = Control.CURSOR_MOVE
header.gui_input.connect(card._on_header_input.bind(header)) header.gui_input.connect(card._on_header_input.bind(header))
@ -47,8 +43,6 @@ func make(build: bool, ranged: bool) -> Control:
header.add_child(head_box) header.add_child(head_box)
head_box.add_child(row) head_box.add_child(row)
if build:
row.add_child(CardMoveHandle.new())
if card.can_collapse(): if card.can_collapse():
var chevron := ChevronButton.new() var chevron := ChevronButton.new()
chevron.open = not table.collapsed chevron.open = not table.collapsed
@ -76,7 +70,6 @@ func make(build: bool, ranged: bool) -> Control:
main.mark_dirty() main.mark_dirty()
) )
row.add_child(name_edit) row.add_child(name_edit)
SpellUnderline.attach(name_edit, main)
row.add_child(card.edit_ui.make_card_menu()) row.add_child(card.edit_ui.make_card_menu())
else: else:
var titles := TableCard.vbox(3) var titles := TableCard.vbox(3)

View file

@ -90,19 +90,7 @@ func make_row(e: TableEntry, index: int, build: bool, ranged: bool, numw: float)
if build and not fixed and not chosen and table.entries.size() > 1: if build and not fixed and not chosen and table.entries.size() > 1:
h.add_child(EntryHandle.new(card, e.id)) h.add_child(EntryHandle.new(card, e.id))
var num: Label = null var num: Label = null
if build and RangeWeights.uses_weights(table): if build and ranged:
# Weights: the box sets the share; the range it gives is shown beside it.
var r := TableCard.hbox(6)
r.custom_minimum_size = Vector2(numw, 0)
r.size_flags_vertical = Control.SIZE_SHRINK_CENTER
r.add_child(edit.weight_edit(e, true))
var span := Style.make_label(table.num_label(e, index) if e.has_range else "—", Style.display(true), 14, Style.MUTED)
span.custom_minimum_size = Vector2(52, 0)
span.mouse_filter = Control.MOUSE_FILTER_PASS
span.tooltip_text = "The range this weight gives, from the row order"
r.add_child(span)
h.add_child(r)
elif build and ranged:
var r := TableCard.hbox(2) var r := TableCard.hbox(2)
r.custom_minimum_size = Vector2(numw, 0) r.custom_minimum_size = Vector2(numw, 0)
r.size_flags_vertical = Control.SIZE_SHRINK_CENTER r.size_flags_vertical = Control.SIZE_SHRINK_CENTER
@ -193,7 +181,7 @@ func make_row(e: TableEntry, index: int, build: bool, ranged: bool, numw: float)
var mark := Style.make_label("§", Style.body_bold(true), 13, Style.TRIM) var mark := Style.make_label("§", Style.body_bold(true), 13, Style.TRIM)
mark.size_flags_vertical = Control.SIZE_SHRINK_CENTER mark.size_flags_vertical = Control.SIZE_SHRINK_CENTER
mark.mouse_filter = Control.MOUSE_FILTER_PASS mark.mouse_filter = Control.MOUSE_FILTER_PASS
mark.tooltip_text = "Lore Entry: %s" % (pg.label() if pg else "a deleted Lore Entry") mark.tooltip_text = "From the Book: %s" % (pg.label() if pg else "a deleted page")
h.add_child(mark) h.add_child(mark)
h.move_child(mark, mini(1, h.get_child_count() - 1)) h.move_child(mark, mini(1, h.get_child_count() - 1))
register(e, row, num, text, index) register(e, row, num, text, index)

View file

@ -33,7 +33,7 @@ func apply_style() -> void:
s = card._style_drop s = card._style_drop
elif card._rolling: elif card._rolling:
s = card._style_rolling s = card._style_rolling
elif card._selected or (card._inspected and card.main.mode == Main.Mode.BUILD): elif card._selected:
s = card._style_selected s = card._style_selected
elif card._dragging: elif card._dragging:
s = card._style_dragging s = card._style_dragging
@ -115,10 +115,10 @@ func build_styles() -> void:
card._style_drop.shadow_size = 16 card._style_drop.shadow_size = 16
card._style_drop.shadow_offset = Vector2(0, 8) card._style_drop.shadow_offset = Vector2(0, 8)
card._style_selected = card._style_normal.duplicate() as StyleBoxFlat card._style_selected = card._style_normal.duplicate() as StyleBoxFlat
Style.bordered(card._style_selected, 4, Style.SELECTED) Style.bordered(card._style_selected, 3, Style.TRIM)
card._style_selected.set_expand_margin_all(6) card._style_selected.set_expand_margin_all(4)
card._style_selected.shadow_color = Color(Style.SELECTED, 0.65) card._style_selected.shadow_color = Color(Style.TRIM, 0.5)
card._style_selected.shadow_size = 24 card._style_selected.shadow_size = 14
card._style_selected.shadow_offset = Vector2.ZERO card._style_selected.shadow_offset = Vector2.ZERO
card._style_dragging = card._style_normal.duplicate() as StyleBoxFlat card._style_dragging = card._style_normal.duplicate() as StyleBoxFlat
card._style_dragging.shadow_color = Color(0, 0, 0, 0.4) card._style_dragging.shadow_color = Color(0, 0, 0, 0.4)

View file

@ -137,7 +137,6 @@ static func _apply_kind(t: RollTable, s: Dictionary) -> void:
t.entries.append(TableEntry.new(TowerBoard.new_id("e"), "Answer")) t.entries.append(TableEntry.new(TowerBoard.new_id("e"), "Answer"))
t.entries[0].text = "Answer" t.entries[0].text = "Answer"
t.entries[0].has_range = false t.entries[0].has_range = false
t.ranged = false
t.card_mode = false t.card_mode = false
t.choice = c t.choice = c
t.prompt = str(s.get("prompt", t.prompt)) t.prompt = str(s.get("prompt", t.prompt))
@ -294,19 +293,8 @@ static func apply_settings(t: RollTable, s: Dictionary) -> Dictionary:
t.dice = dice t.dice = dice
if not was_ranged: if not was_ranged:
assign_ranges(t) assign_ranges(t)
# A card made ranged now is edited by weight (RangeWeights).
t.range_edit = RangeWeights.RANGES
RangeWeights.set_mode(t, RangeWeights.WEIGHTS)
elif was_ranged: elif was_ranged:
drop_ranges(t) drop_ranges(t)
if ranged:
if s.has("auto_sort"):
t.auto_sort = bool(s["auto_sort"])
RangeWeights.after_edit(t)
if s.has("range_edit"):
RangeWeights.set_mode(t, str(s["range_edit"]))
if was_ranged and old_dice != t.dice:
RangeWeights.after_edit(t)
_apply_kind(t, s) _apply_kind(t, s)
var deck_reset := was_ranged != ranged or old_card != t.card_mode or (ranged and old_dice != t.dice) var deck_reset := was_ranged != ranged or old_card != t.card_mode or (ranged and old_dice != t.dice)
return {"ok": true, "error": "", "deck_reset": deck_reset} return {"ok": true, "error": "", "deck_reset": deck_reset}
@ -316,7 +304,6 @@ static func apply_settings(t: RollTable, s: Dictionary) -> Dictionary:
## value each while there is room). Entries of weight 0 get no range. Each ## value each while there is room). Entries of weight 0 get no range. Each
## entry keeps only its first pipe, since a range takes one pipe. ## entry keeps only its first pipe, since a range takes one pipe.
static func assign_ranges(t: RollTable) -> void: static func assign_ranges(t: RollTable) -> void:
t.ranged = true
var d := t.dice_obj() var d := t.dice_obj()
var lo := d.min_value() var lo := d.min_value()
var hi := d.max_value() var hi := d.max_value()
@ -349,7 +336,6 @@ static func assign_ranges(t: RollTable) -> void:
static func drop_ranges(t: RollTable) -> void: static func drop_ranges(t: RollTable) -> void:
t.ranged = false
for e in t.entries: for e in t.entries:
e.has_range = false e.has_range = false
e.range_lo = 1 e.range_lo = 1

View file

@ -21,8 +21,6 @@ const TOKENS := [
["ACCENT", "Highlight (lit and selected)", true], ["ACCENT", "Highlight (lit and selected)", true],
["TRIM", "Trim and headings", true], ["TRIM", "Trim and headings", true],
["GLOW", "Magic sparkles", true], ["GLOW", "Magic sparkles", true],
["SELECTED", "Selected card outline", true],
["CARD_HEAD", "Card header", true],
["BG", "Background (flat)", false], ["BG", "Background (flat)", false],
["BG_DEEP", "Background shadow", false], ["BG_DEEP", "Background shadow", false],
["BG_HOVER", "Background buttons, hover", false], ["BG_HOVER", "Background buttons, hover", false],
@ -127,9 +125,6 @@ static func apply(t: Dictionary) -> void:
for row: Array in TOKENS: for row: Array in TOKENS:
var tok: String = row[0] var tok: String = row[0]
sc.set(tok, Color.from_string(str(colors[tok]), _fallback[tok]) if colors.has(tok) else _fallback[tok]) sc.set(tok, Color.from_string(str(colors[tok]), _fallback[tok]) if colors.has(tok) else _fallback[tok])
if not colors.has("CARD_HEAD"):
# Darker than the card face, so card text stays readable in every theme.
Style.CARD_HEAD = Style.CARD.lerp(Style.CARD_SHADE, 0.85)
Style.BG_FILL = t.get("background", {}) Style.BG_FILL = t.get("background", {})
Style.PANEL_FILL = t.get("panel", {}) Style.PANEL_FILL = t.get("panel", {})
Style.PATTERN = str(t.get("pattern", "dots")) Style.PATTERN = str(t.get("pattern", "dots"))

View file

@ -14,7 +14,6 @@ const ID_LIST := 6
const ID_BOOK := 7 const ID_BOOK := 7
const ID_SOUND := 8 const ID_SOUND := 8
const ID_CONFIRM_DELETE := 9 const ID_CONFIRM_DELETE := 9
const ID_SKIP_ANIM := 10
var m: Main var m: Main
@ -36,12 +35,10 @@ func setup(p_main: Main) -> void:
pm.add_check_item("Striped rows", ID_STRIPES) pm.add_check_item("Striped rows", ID_STRIPES)
pm.add_check_item("Minimap (M)", ID_MINIMAP) pm.add_check_item("Minimap (M)", ID_MINIMAP)
pm.add_check_item("List view", ID_LIST) pm.add_check_item("List view", ID_LIST)
pm.add_check_item("Lore Index", ID_BOOK) pm.add_check_item("Book", ID_BOOK)
pm.add_check_item("Ask before deleting", ID_CONFIRM_DELETE) pm.add_check_item("Ask before deleting", ID_CONFIRM_DELETE)
pm.set_item_tooltip(pm.get_item_index(ID_CONFIRM_DELETE), "The Delete key asks “Are you sure?” first") pm.set_item_tooltip(pm.get_item_index(ID_CONFIRM_DELETE), "The Delete key asks “Are you sure?” first")
pm.add_check_item("Skip animations", ID_SKIP_ANIM) pm.set_item_tooltip(pm.get_item_index(ID_BOOK), "Reusable results (Pages) to drag onto tables")
pm.set_item_tooltip(pm.get_item_index(ID_SKIP_ANIM), "Rolls show their result at once, with no flicker, beads or pop-up motion.\nShift-click a die to skip them for one roll.")
pm.set_item_tooltip(pm.get_item_index(ID_BOOK), "Reusable results (Lore Entries) to drag onto tables")
pm.set_item_tooltip(pm.get_item_index(ID_LIST), "The cards as a list with their groups, beside the spread") pm.set_item_tooltip(pm.get_item_index(ID_LIST), "The cards as a list with their groups, beside the spread")
pm.add_separator() pm.add_separator()
pm.add_item("Theme…", ID_THEME) pm.add_item("Theme…", ID_THEME)
@ -63,7 +60,6 @@ func sync() -> void:
pm.set_item_checked(pm.get_item_index(ID_LIST), m.list_view.visible) pm.set_item_checked(pm.get_item_index(ID_LIST), m.list_view.visible)
pm.set_item_checked(pm.get_item_index(ID_BOOK), m.book.visible) pm.set_item_checked(pm.get_item_index(ID_BOOK), m.book.visible)
pm.set_item_checked(pm.get_item_index(ID_CONFIRM_DELETE), DeleteKey.asks(m)) pm.set_item_checked(pm.get_item_index(ID_CONFIRM_DELETE), DeleteKey.asks(m))
pm.set_item_checked(pm.get_item_index(ID_SKIP_ANIM), SkipAnimations.on(m))
func collapse_label() -> String: func collapse_label() -> String:
@ -90,7 +86,5 @@ func activate(id: int) -> void:
m.add_child(ThemeDialog.new(m)) m.add_child(ThemeDialog.new(m))
ID_CONFIRM_DELETE: ID_CONFIRM_DELETE:
DeleteKey.set_asks(m, not DeleteKey.asks(m)) DeleteKey.set_asks(m, not DeleteKey.asks(m))
ID_SKIP_ANIM:
SkipAnimations.set_on(m, not SkipAnimations.on(m))
ID_SOUND: ID_SOUND:
SoundPanel.open(m, get_global_rect().position + Vector2(0, size.y + 4)) SoundPanel.open(m, get_global_rect().position + Vector2(0, size.y + 4))