Descriptive names rule; first fix in TableCardHeader._make_go_button
DESIGN.md §5: no one- or two-letter names (loop counters and math coordinates excepted); old names are fixed when the code is touched. Rename b -> go_button and rn/rh/rp -> normal_style/hover_style/ pressed_style. Also note where Coderstanding is now installed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
baaffbdf31
commit
c009021ac3
2 changed files with 48 additions and 41 deletions
|
|
@ -120,6 +120,11 @@ a hand-testing checklist; untested-by-hand items: Deck mode fade timing and grou
|
|||
`--demo=KEY`; all in `ui/main_cli.gd`. If a run is interrupted it leaves `override.cfg` behind:
|
||||
delete it before the next run.
|
||||
- **Keep files under ~400 lines**; split by area into RefCounted helpers with one-line delegators.
|
||||
- **Descriptive names (the user is learning to code from this repo):** no one- or two-letter
|
||||
names like `b`, `rn`, `t` for variables, parameters or fields; say what the thing is
|
||||
(`go_button`, `normal_style`, `table`). Loop counters `i`/`j` and math `x`/`y` are fine. New
|
||||
code follows this; old names are fixed when we touch or read that code (Boy Scout rule), not
|
||||
in one big sweep. First fix: `TableCardHeader._make_go_button` (2026-11-11).
|
||||
- **GDScript traps hit today:** don't name methods `_set`, `_get` or `convert` (built-ins); compare
|
||||
roll-node Dictionaries with `is_same()`, not `==` (it compares contents); in Python patch
|
||||
scripts, avoid apostrophes inside single-quoted replacement strings.
|
||||
|
|
@ -131,7 +136,9 @@ a hand-testing checklist; untested-by-hand items: Deck mode fade timing and grou
|
|||
SendMessage ("don't reset"), then cherry-pick its commit and `git worktree remove -f -f`.
|
||||
- **Token savings:** read only this page at the start; read the other docs on demand; keep tool
|
||||
output short (the test runner already does); avoid viewing full-size screenshots (crop/resize).
|
||||
- **Coderstanding** (structure scanner) for audits: clone
|
||||
https://forgejo.smhub.duckdns.org/digit/coderstanding into the scratchpad, venv, `pip install`,
|
||||
`XDG_CONFIG_HOME=<scratch>/xdgconf`, `coderstanding add tabletower <repo> --data <scratch>/cs_data`.
|
||||
- **Coderstanding** (structure scanner, tours) is installed: `coderstanding` on PATH (venv
|
||||
`~/.local/share/coderstanding/venv`), app `tabletower`, data and tours in
|
||||
`~/.local/share/coderstanding/tabletower`, viewer http://127.0.0.1:8517/. Tours teach the
|
||||
user (new to coding): plain words, explain basics. Update: pull
|
||||
https://forgejo.smhub.duckdns.org/digit/coderstanding and `pip install` it into that venv.
|
||||
- **Keep this page short.** Put history in HISTORY.md and file maps in ARCHITECTURE.md.
|
||||
|
|
|
|||
|
|
@ -143,42 +143,42 @@ func _make_go_button() -> Button:
|
|||
roll_button = null
|
||||
if table.kind == RollTable.KIND_VARIABLE:
|
||||
return null
|
||||
var b := Button.new()
|
||||
b.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
b.add_theme_font_override("font", Style.display(true))
|
||||
b.add_theme_font_size_override("font_size", 17)
|
||||
var go_button := Button.new()
|
||||
go_button.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
go_button.add_theme_font_override("font", Style.display(true))
|
||||
go_button.add_theme_font_size_override("font_size", 17)
|
||||
var left := 10
|
||||
match table.kind:
|
||||
RollTable.KIND_CHOICE:
|
||||
b.text = "?"
|
||||
b.add_theme_font_size_override("font_size", 20)
|
||||
b.custom_minimum_size = Vector2(36, 0)
|
||||
b.tooltip_text = "Ask: %s" % Formatter.strip_tags(table.prompt if table.prompt != "" else table.name)
|
||||
go_button.text = "?"
|
||||
go_button.add_theme_font_size_override("font_size", 20)
|
||||
go_button.custom_minimum_size = Vector2(36, 0)
|
||||
go_button.tooltip_text = "Ask: %s" % Formatter.strip_tags(table.prompt if table.prompt != "" else table.name)
|
||||
RollTable.KIND_LOOP:
|
||||
b.custom_minimum_size = Vector2(38, 32)
|
||||
b.tooltip_text = "Run %s" % Formatter.strip_tags(table.name)
|
||||
go_button.custom_minimum_size = Vector2(38, 32)
|
||||
go_button.tooltip_text = "Run %s" % Formatter.strip_tags(table.name)
|
||||
var icon := Control.new()
|
||||
icon.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
icon.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
icon.draw.connect(func() -> void: Icons.draw_loop(icon, icon.size / 2.0 + Vector2(0, -1), 7.0, Style.ACCENT, 2.2))
|
||||
b.add_child(icon)
|
||||
go_button.add_child(icon)
|
||||
RollTable.KIND_ROUTER:
|
||||
b.custom_minimum_size = Vector2(38, 32)
|
||||
b.tooltip_text = "Route %s: the first case that's true is chosen" % Formatter.strip_tags(table.name)
|
||||
go_button.custom_minimum_size = Vector2(38, 32)
|
||||
go_button.tooltip_text = "Route %s: the first case that's true is chosen" % Formatter.strip_tags(table.name)
|
||||
var fork := Control.new()
|
||||
fork.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
fork.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
fork.draw.connect(func() -> void: draw_fork(fork, fork.size / 2.0 + Vector2(0, 0), 8.0, Style.ACCENT, 2.2))
|
||||
b.add_child(fork)
|
||||
go_button.add_child(fork)
|
||||
RollTable.KIND_SHEET:
|
||||
b.text = "Print"
|
||||
b.add_theme_font_override("font", Style.body_bold(true))
|
||||
b.add_theme_font_size_override("font_size", 14)
|
||||
b.tooltip_text = "Print this sheet in the tray"
|
||||
go_button.text = "Print"
|
||||
go_button.add_theme_font_override("font", Style.body_bold(true))
|
||||
go_button.add_theme_font_size_override("font_size", 14)
|
||||
go_button.tooltip_text = "Print this sheet in the tray"
|
||||
RollTable.KIND_CHECK:
|
||||
b.text = TableCardText.check_badge(table)
|
||||
b.custom_minimum_size = Vector2(38, 0)
|
||||
b.tooltip_text = "Roll the check: %s\nShift-click to skip the animation" % RulesView.check_line(table, card.main.data, card.plain)
|
||||
go_button.text = TableCardText.check_badge(table)
|
||||
go_button.custom_minimum_size = Vector2(38, 0)
|
||||
go_button.tooltip_text = "Roll the check: %s\nShift-click to skip the animation" % RulesView.check_line(table, card.main.data, card.plain)
|
||||
_:
|
||||
left = 34
|
||||
var label := "d%d" % table.die_size()
|
||||
|
|
@ -187,27 +187,27 @@ func _make_go_button() -> Button:
|
|||
label = table.dice_label()
|
||||
elif table.is_expr_dice():
|
||||
label = table.dice_label() if table.dice_label().length() <= 5 else "Roll"
|
||||
b.text = label
|
||||
b.tooltip_text = "Roll %s on %s\nShift-click to skip the animation" % [table.roll_text() if table.is_ranged() else table.dice_label(), table.name]
|
||||
var rn := Style.box(Style.BG, 8, [left, 6, 10, 6])
|
||||
rn.border_width_bottom = 2
|
||||
rn.border_color = Style.BG_DEEP
|
||||
var rh := rn.duplicate() as StyleBoxFlat
|
||||
rh.bg_color = Style.BG_HOVER
|
||||
var rp := rn.duplicate() as StyleBoxFlat
|
||||
rp.border_width_bottom = 1
|
||||
rp.content_margin_top = 7
|
||||
rp.content_margin_bottom = 5
|
||||
Style.skin_button(b, rn, rh, rp, Style.ACCENT)
|
||||
go_button.text = label
|
||||
go_button.tooltip_text = "Roll %s on %s\nShift-click to skip the animation" % [table.roll_text() if table.is_ranged() else table.dice_label(), table.name]
|
||||
var normal_style := Style.box(Style.BG, 8, [left, 6, 10, 6])
|
||||
normal_style.border_width_bottom = 2
|
||||
normal_style.border_color = Style.BG_DEEP
|
||||
var hover_style := normal_style.duplicate() as StyleBoxFlat
|
||||
hover_style.bg_color = Style.BG_HOVER
|
||||
var pressed_style := normal_style.duplicate() as StyleBoxFlat
|
||||
pressed_style.border_width_bottom = 1
|
||||
pressed_style.content_margin_top = 7
|
||||
pressed_style.content_margin_bottom = 5
|
||||
Style.skin_button(go_button, normal_style, hover_style, pressed_style, Style.ACCENT)
|
||||
if table.kind == RollTable.KIND_ROLL:
|
||||
var die := DieIcon.new()
|
||||
die.spinning = card._rolling
|
||||
die_icon = die
|
||||
b.add_child(die)
|
||||
b.resized.connect(func() -> void: die.position = Vector2(8, (b.size.y - 20.0) / 2.0 - 1.0))
|
||||
b.pressed.connect(func() -> void: card.main.start_roll(table.id))
|
||||
roll_button = b
|
||||
return b
|
||||
go_button.add_child(die)
|
||||
go_button.resized.connect(func() -> void: die.position = Vector2(8, (go_button.size.y - 20.0) / 2.0 - 1.0))
|
||||
go_button.pressed.connect(func() -> void: card.main.start_roll(table.id))
|
||||
roll_button = go_button
|
||||
return go_button
|
||||
|
||||
|
||||
## Kind-specific lines under the header: a choice card's question, a loop's
|
||||
|
|
|
|||
Loading…
Reference in a new issue