Remove duplicated code found by the coderstanding audit
- Style.menu_button / font_colors / field_colors replace five copies of the "copy a bar button's skin onto a MenuButton" block, nine single-colour font loops and four field colour blocks. - GroupCard uses TableCard.vbox/hbox instead of its own copies. - InspectorKit.focused_tag / clear / refocus / as_text_link replace the focus-keeping render frame and "Edit as text" link shared by the condition and effects builders. - InspectorCard._setting_line replaces three copies of a bound setting field. - Main.file_dialog / export_dialog replace four FileDialog setups. - JsonIO.entry_line / finish_import replace copies in canvas_io, dot_exporter and graphml_io. - Dead code: TableCard's unused inline-editor fields and the no-op --edit-details / --edit-effects flags, an unused error counter in the tray, and an unreachable "settings not available" fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
26ed4a5cbe
commit
0f3e8c278f
24 changed files with 180 additions and 285 deletions
|
|
@ -155,7 +155,7 @@ tools/test_window.sh -- --screenshot=/tmp/board.png [--build] [--expand-all] [--
|
|||
|
||||
Logic-card views: `--board=examples/logic_demo.json --roll=start "--answers=Brin|3"` answers
|
||||
the first questions and leaves the next pop-up open; `--menu=add`, `--open-settings=<id>`,
|
||||
`--edit-effects=<id>`, `--demo-long=<n>` (a chain of n steps) and `--confirm-reset` show the
|
||||
`--demo-long=<n>` (a chain of n steps) and `--confirm-reset` show the
|
||||
rest.
|
||||
|
||||
Test board: `--test-board` opens the dialog, `--test-board-run=<runs>` also starts a run.
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ static func export_canvas(collection: Dictionary) -> String:
|
|||
var entries: Array = t["entries"]
|
||||
for ei in entries.size():
|
||||
var e: Dictionary = entries[ei]
|
||||
var text := _visible_text(e, dmax)
|
||||
var text := JsonIO.entry_line(e, dmax)
|
||||
var h := _node_height(text)
|
||||
var nid := "t%de%d" % [ti, ei]
|
||||
entry_ids["%s\t%s" % [t["id"], e["id"]]] = nid
|
||||
|
|
@ -103,17 +103,6 @@ static func _entry_extra(e: Dictionary) -> Dictionary:
|
|||
return extra
|
||||
|
||||
|
||||
static func _visible_text(e: Dictionary, dmax: int) -> String:
|
||||
var plain := JsonIO.strip_bbcode(str(e["text"]))
|
||||
if e.has("range"):
|
||||
var r: Array = e["range"]
|
||||
return "%s: %s" % [JsonIO.range_text(int(r[0]), int(r[1]), dmax), plain]
|
||||
var w: Variant = e.get("weight", 1)
|
||||
if w != 1:
|
||||
return "%s × %s" % [str(w), plain]
|
||||
return plain
|
||||
|
||||
|
||||
static func _node_height(text: String) -> int:
|
||||
var lines := 0
|
||||
for part in text.split("\n"):
|
||||
|
|
@ -271,14 +260,7 @@ static func import_canvas(text: String, sanitize: Callable = Callable()) -> Dict
|
|||
}
|
||||
if doc_extra.is_empty():
|
||||
guesses.append("No collection name in the canvas; using a default.")
|
||||
var imported := JsonIO.import_dict(raw, sanitize)
|
||||
for w in imported["warnings"]:
|
||||
warnings.append(w)
|
||||
for er in imported["errors"]:
|
||||
errors.append(er)
|
||||
result["ok"] = imported["ok"]
|
||||
result["collection"] = imported["collection"]
|
||||
return result
|
||||
return JsonIO.finish_import(raw, sanitize, result)
|
||||
|
||||
|
||||
static func _containing_group(node: Dictionary, groups: Array[Dictionary]) -> Dictionary:
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ static func export_dot(collection: Dictionary) -> String:
|
|||
hidden += 1
|
||||
continue
|
||||
shown += 1
|
||||
rows.append("<TR><TD PORT=\"e%d\" ALIGN=\"LEFT\">%s</TD></TR>" % [ei, escape_html(_row_text(e, dmax))])
|
||||
rows.append("<TR><TD PORT=\"e%d\" ALIGN=\"LEFT\">%s</TD></TR>" % [ei, escape_html(JsonIO.entry_line(e, dmax))])
|
||||
if hidden > 0:
|
||||
rows.append("<TR><TD ALIGN=\"LEFT\"><I>… and %d more</I></TD></TR>" % hidden)
|
||||
out.append("\t%s [label=<<TABLE BORDER=\"1\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"4\">%s</TABLE>>];" % [node_of[t["id"]], "".join(rows)])
|
||||
|
|
@ -87,14 +87,3 @@ static func escape_string(text: String) -> String:
|
|||
## Escapes text for an HTML-like DOT label.
|
||||
static func escape_html(text: String) -> String:
|
||||
return text.replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """).replace("\n", " ")
|
||||
|
||||
|
||||
static func _row_text(e: Dictionary, dmax: int) -> String:
|
||||
var plain := JsonIO.strip_bbcode(str(e["text"]))
|
||||
if e.has("range"):
|
||||
var r: Array = e["range"]
|
||||
return "%s: %s" % [JsonIO.range_text(int(r[0]), int(r[1]), dmax), plain]
|
||||
var w: Variant = e.get("weight", 1)
|
||||
if w != 1:
|
||||
return "%s × %s" % [str(w), plain]
|
||||
return plain
|
||||
|
|
|
|||
|
|
@ -235,11 +235,4 @@ static func import_graphml(text: String, sanitize: Callable = Callable()) -> Dic
|
|||
"name": str(graph_data.get("collection_name", "")),
|
||||
"tables": tables,
|
||||
}
|
||||
var imported := JsonIO.import_dict(raw, sanitize)
|
||||
for w in imported["warnings"]:
|
||||
warnings.append(w)
|
||||
for er in imported["errors"]:
|
||||
errors.append(er)
|
||||
result["ok"] = imported["ok"]
|
||||
result["collection"] = imported["collection"]
|
||||
return result
|
||||
return JsonIO.finish_import(raw, sanitize, result)
|
||||
|
|
|
|||
|
|
@ -585,3 +585,26 @@ static func _is_power_of_ten(n: int) -> bool:
|
|||
while n >= 10 and n % 10 == 0:
|
||||
n /= 10
|
||||
return n == 1
|
||||
|
||||
|
||||
## An entry as one plain line for an export: "3-4: text", "2 × text" or "text".
|
||||
static func entry_line(e: Dictionary, dmax: int) -> String:
|
||||
var plain := strip_bbcode(str(e["text"]))
|
||||
if e.has("range"):
|
||||
var r: Array = e["range"]
|
||||
return "%s: %s" % [range_text(int(r[0]), int(r[1]), dmax), plain]
|
||||
var w: Variant = e.get("weight", 1)
|
||||
if w != 1:
|
||||
return "%s × %s" % [str(w), plain]
|
||||
return plain
|
||||
|
||||
|
||||
## Imports a converted collection (`raw`) and adds its warnings, errors and
|
||||
## result to an importer's `result` ({ok, collection, errors, warnings, ...}).
|
||||
static func finish_import(raw: Dictionary, sanitize: Callable, result: Dictionary) -> Dictionary:
|
||||
var imported := import_dict(raw, sanitize)
|
||||
(result["warnings"] as Array).append_array(imported["warnings"])
|
||||
(result["errors"] as Array).append_array(imported["errors"])
|
||||
result["ok"] = imported["ok"]
|
||||
result["collection"] = imported["collection"]
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -17,17 +17,9 @@ var _ids: Array[String] = []
|
|||
|
||||
func setup(p_main: Main) -> void:
|
||||
main = p_main
|
||||
var ref := ModalCard.bar_menu_button("")
|
||||
for n in ["normal", "hover", "pressed", "hover_pressed", "disabled", "focus"]:
|
||||
add_theme_stylebox_override(n, ref.get_theme_stylebox(n))
|
||||
for c in ["font_color", "font_hover_color", "font_focus_color", "font_pressed_color", "font_hover_pressed_color"]:
|
||||
add_theme_color_override(c, ref.get_theme_color(c))
|
||||
Style.menu_button(text, false, self)
|
||||
add_theme_color_override("font_disabled_color", Style.ON_FELT)
|
||||
add_theme_font_override("font", Style.body_bold())
|
||||
add_theme_font_size_override("font_size", 15)
|
||||
ref.free()
|
||||
mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
flat = false
|
||||
tooltip_text = "Collections"
|
||||
ModalCard.style_popup(get_popup())
|
||||
get_popup().about_to_popup.connect(_fill)
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ func _build_frame() -> void:
|
|||
bar.mouse_entered.connect(_show_details.bind(bar))
|
||||
col.add_child(bar)
|
||||
_header = bar
|
||||
var h := _hbox(8)
|
||||
var h := TableCard.hbox(8)
|
||||
h.size_flags_vertical = SIZE_SHRINK_CENTER
|
||||
bar.add_child(h)
|
||||
var chevron := ChevronButton.new()
|
||||
|
|
@ -200,7 +200,7 @@ func _build_compact() -> void:
|
|||
_card.accept_event()
|
||||
)
|
||||
add_child(_card)
|
||||
var col := _vbox(0)
|
||||
var col := TableCard.vbox(0)
|
||||
_card.add_child(col)
|
||||
|
||||
var header := PanelContainer.new()
|
||||
|
|
@ -214,7 +214,7 @@ func _build_compact() -> void:
|
|||
header.mouse_entered.connect(_show_details.bind(header))
|
||||
col.add_child(header)
|
||||
_header = header
|
||||
var row := _hbox(8)
|
||||
var row := TableCard.hbox(8)
|
||||
header.add_child(row)
|
||||
var chevron := ChevronButton.new()
|
||||
chevron.open = false
|
||||
|
|
@ -226,7 +226,7 @@ func _build_compact() -> void:
|
|||
if build:
|
||||
row.add_child(_name_edit(false))
|
||||
else:
|
||||
var titles := _vbox(3)
|
||||
var titles := TableCard.vbox(3)
|
||||
titles.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
titles.mouse_filter = MOUSE_FILTER_IGNORE
|
||||
var title := Style.make_label(Formatter.strip_tags(group.name), Style.display(true), 20, Style.INK)
|
||||
|
|
@ -249,7 +249,7 @@ func _build_compact() -> void:
|
|||
pad.add_theme_constant_override("margin_top", 6)
|
||||
pad.add_theme_constant_override("margin_bottom", 8)
|
||||
col.add_child(pad)
|
||||
var list := _vbox(2)
|
||||
var list := TableCard.vbox(2)
|
||||
pad.add_child(list)
|
||||
var shown := _lit_keys.slice(maxi(0, _lit_keys.size() - MAX_LIT))
|
||||
if _lit_keys.size() > shown.size():
|
||||
|
|
@ -310,7 +310,7 @@ func _lit_row(key: String) -> Control:
|
|||
var row := PanelContainer.new()
|
||||
row.mouse_filter = MOUSE_FILTER_PASS
|
||||
row.add_theme_stylebox_override("panel", Style.box(Style.LIT, 0, [14, 5, 22, 6]))
|
||||
var v := _vbox(1)
|
||||
var v := TableCard.vbox(1)
|
||||
row.add_child(v)
|
||||
var cap := Style.make_label(Formatter.strip_tags(t.name if t else tid).to_upper(), Style.caps(), 10, Style.COPPER_DARK)
|
||||
cap.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||
|
|
@ -340,20 +340,6 @@ func set_rolling(on: bool) -> void:
|
|||
|
||||
# ---------- Shared parts ----------
|
||||
|
||||
func _vbox(sep: int) -> VBoxContainer:
|
||||
var v := VBoxContainer.new()
|
||||
v.add_theme_constant_override("separation", sep)
|
||||
v.mouse_filter = MOUSE_FILTER_PASS
|
||||
return v
|
||||
|
||||
|
||||
func _hbox(sep: int) -> HBoxContainer:
|
||||
var h := HBoxContainer.new()
|
||||
h.add_theme_constant_override("separation", sep)
|
||||
h.mouse_filter = MOUSE_FILTER_PASS
|
||||
return h
|
||||
|
||||
|
||||
func _name_edit(on_felt: bool) -> LineEdit:
|
||||
var le := LineEdit.new()
|
||||
le.text = group.name
|
||||
|
|
@ -394,8 +380,7 @@ func _menu_button(on_felt: bool) -> MenuButton:
|
|||
for n in ["hover", "pressed", "hover_pressed"]:
|
||||
mb.add_theme_stylebox_override(n, hover)
|
||||
var fg := Style.ON_FELT if on_felt else Style.MUTED
|
||||
for c in ["font_color", "font_hover_color", "font_focus_color", "font_pressed_color", "font_hover_pressed_color"]:
|
||||
mb.add_theme_color_override(c, fg)
|
||||
Style.font_colors(mb, fg)
|
||||
mb.mouse_default_cursor_shape = CURSOR_POINTING_HAND
|
||||
menu_button = mb
|
||||
var pm := mb.get_popup()
|
||||
|
|
|
|||
|
|
@ -558,31 +558,30 @@ static func add_case(insp: Inspector) -> void:
|
|||
|
||||
# ---------- Variable ----------
|
||||
|
||||
static func _variable(insp: Inspector, box: VBoxContainer, t: RollTable) -> void:
|
||||
var err := InspectorKit.error_label()
|
||||
var vn := InspectorKit.line(t.var_name, "luck")
|
||||
InspectorKit.code(vn)
|
||||
InspectorKit.tag(vn, "card.var_name")
|
||||
insp.fields["var_name"] = vn
|
||||
vn.text_changed.connect(func(s: String) -> void:
|
||||
var msg := insp.apply_settings({"var_name": s})
|
||||
InspectorKit.mark(vn, msg == "")
|
||||
## A field for one card setting: applied as you type, marked and explained in `err` when refused.
|
||||
static func _setting_line(insp: Inspector, key: String, text: String, placeholder: String, err: Label) -> LineEdit:
|
||||
var le := InspectorKit.line(text, placeholder)
|
||||
InspectorKit.tag(le, "card." + key)
|
||||
insp.fields[key] = le
|
||||
le.text_changed.connect(func(s: String) -> void:
|
||||
var msg := insp.apply_settings({key: s})
|
||||
InspectorKit.mark(le, msg == "")
|
||||
InspectorKit.show_error(err, msg)
|
||||
)
|
||||
return le
|
||||
|
||||
|
||||
static func _variable(insp: Inspector, box: VBoxContainer, t: RollTable) -> void:
|
||||
var err := InspectorKit.error_label()
|
||||
var vn := _setting_line(insp, "var_name", t.var_name, "luck", err)
|
||||
InspectorKit.code(vn)
|
||||
box.add_child(InspectorKit.field("Name in rules (@name)", vn))
|
||||
var types := ["number", "text", "list"]
|
||||
var seg := ModalCard.segmented(["Number", "Text", "List"], maxi(0, types.find(t.var_type)), func(i: int) -> void:
|
||||
InspectorKit.show_error(err, insp.apply_settings({"var_type": types[i]}, true))
|
||||
)
|
||||
box.add_child(InspectorKit.field("Type", seg))
|
||||
var init := InspectorKit.line(t.initial, "0" if t.var_type == "number" else "nothing")
|
||||
InspectorKit.tag(init, "card.initial")
|
||||
insp.fields["initial"] = init
|
||||
init.text_changed.connect(func(s: String) -> void:
|
||||
var msg := insp.apply_settings({"initial": s})
|
||||
InspectorKit.mark(init, msg == "")
|
||||
InspectorKit.show_error(err, msg)
|
||||
)
|
||||
var init := _setting_line(insp, "initial", t.initial, "0" if t.var_type == "number" else "nothing", err)
|
||||
box.add_child(InspectorKit.field("Starting value", init))
|
||||
box.add_child(err)
|
||||
|
||||
|
|
@ -591,15 +590,8 @@ static func _variable(insp: Inspector, box: VBoxContainer, t: RollTable) -> void
|
|||
|
||||
static func _collection(insp: Inspector, box: VBoxContainer, t: RollTable) -> void:
|
||||
var err := InspectorKit.error_label()
|
||||
var vn := InspectorKit.line(t.var_name, "skill")
|
||||
var vn := _setting_line(insp, "var_name", t.var_name, "skill", err)
|
||||
InspectorKit.code(vn)
|
||||
InspectorKit.tag(vn, "card.var_name")
|
||||
insp.fields["var_name"] = vn
|
||||
vn.text_changed.connect(func(s: String) -> void:
|
||||
var msg := insp.apply_settings({"var_name": s})
|
||||
InspectorKit.mark(vn, msg == "")
|
||||
InspectorKit.show_error(err, msg)
|
||||
)
|
||||
box.add_child(InspectorKit.field("Members are named", vn))
|
||||
box.add_child(InspectorKit.note("Each member is the value @%s_<name>, e.g. @%s_pilot. Choices can offer “one of your %s”." % [t.var_name, t.var_name, Inspector._title_of(t.name, "members")], Style.MUTED, 13))
|
||||
|
||||
|
|
|
|||
|
|
@ -139,13 +139,8 @@ func set_raw(t: String) -> void:
|
|||
# ---------- UI ----------
|
||||
|
||||
func _render() -> void:
|
||||
var focus_key := ""
|
||||
var f := get_viewport().gui_get_focus_owner() if is_inside_tree() else null
|
||||
if f and is_ancestor_of(f) and f.has_meta(InspectorKit.KEY):
|
||||
focus_key = str(f.get_meta(InspectorKit.KEY))
|
||||
for c in get_children():
|
||||
remove_child(c)
|
||||
c.queue_free()
|
||||
var focus_key := InspectorKit.focused_tag(self)
|
||||
InspectorKit.clear(self)
|
||||
if text_mode:
|
||||
_render_text()
|
||||
else:
|
||||
|
|
@ -165,15 +160,9 @@ func _render() -> void:
|
|||
var add := InspectorKit.link(add_label, "Add a comparison")
|
||||
add.pressed.connect(func() -> void: add_clause())
|
||||
foot.add_child(add)
|
||||
var as_text := InspectorKit.link("Edit as text", "Edit this condition as rule text")
|
||||
as_text.add_theme_color_override("font_color", Style.MUTED)
|
||||
as_text.pressed.connect(func() -> void: set_text_mode(true))
|
||||
foot.add_child(as_text)
|
||||
foot.add_child(InspectorKit.as_text_link("Edit this condition as rule text", set_text_mode.bind(true)))
|
||||
add_child(foot)
|
||||
if focus_key != "":
|
||||
var c := InspectorKit.find_tagged(self, focus_key)
|
||||
if c:
|
||||
c.grab_focus.call_deferred()
|
||||
InspectorKit.refocus(self, focus_key)
|
||||
|
||||
|
||||
func _render_text() -> void:
|
||||
|
|
|
|||
|
|
@ -167,13 +167,8 @@ func set_raw(t: String) -> void:
|
|||
# ---------- UI ----------
|
||||
|
||||
func _render() -> void:
|
||||
var focus_key := ""
|
||||
var f := get_viewport().gui_get_focus_owner() if is_inside_tree() else null
|
||||
if f and is_ancestor_of(f) and f.has_meta(InspectorKit.KEY):
|
||||
focus_key = str(f.get_meta(InspectorKit.KEY))
|
||||
for c in get_children():
|
||||
remove_child(c)
|
||||
c.queue_free()
|
||||
var focus_key := InspectorKit.focused_tag(self)
|
||||
InspectorKit.clear(self)
|
||||
if text_mode:
|
||||
_render_text()
|
||||
else:
|
||||
|
|
@ -184,15 +179,9 @@ func _render() -> void:
|
|||
add.pressed.connect(add_row)
|
||||
InspectorKit.tag(add, _key + ".add")
|
||||
foot.add_child(add)
|
||||
var as_text := InspectorKit.link("Edit as text", "Edit these changes as rule text")
|
||||
as_text.add_theme_color_override("font_color", Style.MUTED)
|
||||
as_text.pressed.connect(func() -> void: set_text_mode(true))
|
||||
foot.add_child(as_text)
|
||||
foot.add_child(InspectorKit.as_text_link("Edit these changes as rule text", set_text_mode.bind(true)))
|
||||
add_child(foot)
|
||||
if focus_key != "":
|
||||
var c := InspectorKit.find_tagged(self, focus_key)
|
||||
if c:
|
||||
c.grab_focus.call_deferred()
|
||||
InspectorKit.refocus(self, focus_key)
|
||||
|
||||
|
||||
func _render_text() -> void:
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ static func line(text: String, placeholder: String = "", min_w: float = 0.0) ->
|
|||
le.add_theme_stylebox_override("normal", _field_box(Style.RULE))
|
||||
le.add_theme_stylebox_override("focus", _field_box(Style.COPPER))
|
||||
le.add_theme_stylebox_override("read_only", _field_box(Style.RULE))
|
||||
le.add_theme_color_override("font_color", Style.INK)
|
||||
le.add_theme_color_override("caret_color", Style.INK)
|
||||
le.add_theme_color_override("selection_color", Color(Style.BRASS, 0.55))
|
||||
le.add_theme_color_override("font_placeholder_color", Style.MUTED)
|
||||
Style.field_colors(le)
|
||||
le.add_theme_font_override("font", Style.body())
|
||||
le.add_theme_font_size_override("font_size", 15)
|
||||
le.add_theme_constant_override("minimum_character_width", 0)
|
||||
|
|
@ -59,10 +56,7 @@ static func text_box(text: String, placeholder: String = "", min_h: float = 70.0
|
|||
te.scroll_fit_content_height = true
|
||||
te.add_theme_stylebox_override("normal", Style.bordered(Style.box(FIELD_BG, 6, [8, 6, 8, 6]), 1, Style.RULE))
|
||||
te.add_theme_stylebox_override("focus", Style.bordered(Style.box(FIELD_BG, 6, [8, 6, 8, 6]), 1, Style.COPPER))
|
||||
te.add_theme_color_override("font_color", Style.INK)
|
||||
te.add_theme_color_override("caret_color", Style.INK)
|
||||
te.add_theme_color_override("selection_color", Color(Style.BRASS, 0.55))
|
||||
te.add_theme_color_override("font_placeholder_color", Style.MUTED)
|
||||
Style.field_colors(te)
|
||||
te.add_theme_color_override("background_color", Color(0, 0, 0, 0))
|
||||
te.add_theme_font_override("font", Style.body())
|
||||
te.add_theme_font_size_override("font_size", 15)
|
||||
|
|
@ -176,8 +170,7 @@ static func check_box(text: String, on: bool) -> CheckBox:
|
|||
cb.button_pressed = on
|
||||
cb.add_theme_font_override("font", Style.body_bold())
|
||||
cb.add_theme_font_size_override("font_size", 15)
|
||||
for c in ["font_color", "font_hover_color", "font_pressed_color", "font_hover_pressed_color", "font_focus_color"]:
|
||||
cb.add_theme_color_override(c, Style.INK)
|
||||
Style.font_colors(cb, Style.INK)
|
||||
cb.add_theme_color_override("font_disabled_color", Style.MUTED)
|
||||
return cb
|
||||
|
||||
|
|
@ -218,6 +211,37 @@ static func tag(c: Control, key: String) -> Control:
|
|||
return c
|
||||
|
||||
|
||||
## The tag of the focused control inside `root` ("" if none), so a rebuild
|
||||
## can give focus back with `refocus`.
|
||||
static func focused_tag(root: Control) -> String:
|
||||
var f := root.get_viewport().gui_get_focus_owner() if root.is_inside_tree() else null
|
||||
if f and root.is_ancestor_of(f) and f.has_meta(KEY):
|
||||
return str(f.get_meta(KEY))
|
||||
return ""
|
||||
|
||||
|
||||
static func refocus(root: Node, key: String) -> void:
|
||||
if key == "":
|
||||
return
|
||||
var c := find_tagged(root, key)
|
||||
if c:
|
||||
c.grab_focus.call_deferred()
|
||||
|
||||
|
||||
static func clear(box: Node) -> void:
|
||||
for c in box.get_children():
|
||||
box.remove_child(c)
|
||||
c.queue_free()
|
||||
|
||||
|
||||
## The muted "Edit as text" link at the foot of a builder.
|
||||
static func as_text_link(tip: String, on_press: Callable) -> Button:
|
||||
var b := link("Edit as text", tip)
|
||||
b.add_theme_color_override("font_color", Style.MUTED)
|
||||
b.pressed.connect(on_press)
|
||||
return b
|
||||
|
||||
|
||||
static func find_tagged(root: Node, key: String) -> Control:
|
||||
for c in root.get_children():
|
||||
if c is Control and c.has_meta(KEY) and str(c.get_meta(KEY)) == key:
|
||||
|
|
|
|||
|
|
@ -32,16 +32,7 @@ signal test_requested
|
|||
|
||||
|
||||
func setup(can_reset: bool, can_import: bool) -> void:
|
||||
var ref := ModalCard.bar_menu_button("")
|
||||
for n in ["normal", "hover", "pressed", "hover_pressed", "disabled", "focus"]:
|
||||
add_theme_stylebox_override(n, ref.get_theme_stylebox(n))
|
||||
for c in ["font_color", "font_hover_color", "font_focus_color", "font_pressed_color", "font_hover_pressed_color"]:
|
||||
add_theme_color_override(c, ref.get_theme_color(c))
|
||||
add_theme_font_size_override("font_size", 15)
|
||||
ref.free()
|
||||
mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
flat = false
|
||||
text = "Board ▾"
|
||||
Style.menu_button("Board ▾", false, self)
|
||||
tooltip_text = "Reset, import and export"
|
||||
var pm := get_popup()
|
||||
ModalCard.style_popup(pm)
|
||||
|
|
|
|||
26
ui/main.gd
26
ui/main.gd
|
|
@ -329,6 +329,32 @@ func _add_modal(d: ModalCard) -> void:
|
|||
add_child(d)
|
||||
|
||||
|
||||
## Opens the system file dialog; `on_path` gets the chosen path.
|
||||
func file_dialog(title: String, filters: Array, mode: FileDialog.FileMode, on_path: Callable, file_name: String = "") -> void:
|
||||
var dlg := FileDialog.new()
|
||||
dlg.use_native_dialog = true
|
||||
dlg.access = FileDialog.ACCESS_FILESYSTEM
|
||||
dlg.file_mode = mode
|
||||
dlg.title = title
|
||||
dlg.filters = PackedStringArray(filters)
|
||||
dlg.current_file = file_name
|
||||
dlg.file_selected.connect(on_path)
|
||||
dlg.visibility_changed.connect(func() -> void:
|
||||
if not dlg.visible:
|
||||
dlg.queue_free.call_deferred()
|
||||
)
|
||||
add_child(dlg)
|
||||
dlg.popup_centered_ratio(0.6)
|
||||
|
||||
|
||||
## A save dialog that writes `text_for.call()` to the chosen file and says how it went.
|
||||
func export_dialog(title: String, filter: String, file_name: String, text_for: Callable) -> void:
|
||||
file_dialog(title, [filter], FileDialog.FILE_MODE_SAVE_FILE, func(path: String) -> void:
|
||||
var err := TowerBoard.write_text_atomic(path, str(text_for.call()))
|
||||
toast("Exported to %s" % path.get_file() if err == OK else "Couldn't write %s" % path.get_file())
|
||||
, file_name)
|
||||
|
||||
|
||||
## The shared hover pop-up for details.
|
||||
func details() -> DetailsPopup:
|
||||
if _details_popup == null:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ func _init(p_main: Main) -> void:
|
|||
# godot --path . -- --screenshot=/tmp/shot.png [--build] [--expand-all] [--collapse-all]
|
||||
# [--roll=<table id>] [--fast] [--shot-delay=<seconds>]
|
||||
# [--board=<collection.json>] (with --sample/--screenshot only: show that board instead)
|
||||
# [--tray=variables] [--hover=<x>,<y>] [--details=<table id>] [--pipe=<pipe key>] [--edit-details=<table id>]
|
||||
# [--tray=variables] [--hover=<x>,<y>] [--details=<table id>] [--pipe=<pipe key>]
|
||||
|
||||
static func _arg_value(args: PackedStringArray, name: String) -> String:
|
||||
for a in args:
|
||||
|
|
@ -101,7 +101,6 @@ func _run_shell_cli(args: PackedStringArray) -> void:
|
|||
# later questions open the pop-up
|
||||
# --demo-long=<n> add a table that pipes into itself n times, and fast-roll it
|
||||
# --confirm-reset open the Variables tab's "Reset all…" confirmation
|
||||
# --edit-effects=<table id> open the effects editor on every row of a card (Build)
|
||||
|
||||
func _run_logic_cli(args: PackedStringArray) -> void:
|
||||
var answers := _arg_value(args, "--answers")
|
||||
|
|
@ -133,11 +132,6 @@ func _run_logic_cli(args: PackedStringArray) -> void:
|
|||
m.data.tables.append(link)
|
||||
m._rebuild_cards()
|
||||
m.start_roll("long_start", true)
|
||||
var fx := m.card_for(_arg_value(args, "--edit-effects"))
|
||||
if fx:
|
||||
for e in fx.table.entries:
|
||||
fx._open_effects[e.id] = true
|
||||
fx.rebuild()
|
||||
if args.has("--confirm-reset"):
|
||||
m.tray.set_side(ResultTray.Side.VARIABLES)
|
||||
m.tray._vars.confirm_reset_all()
|
||||
|
|
@ -271,13 +265,6 @@ func _run_cli_extras(args: PackedStringArray) -> void:
|
|||
m.tray.render()
|
||||
if _arg_value(args, "--tray") == "variables":
|
||||
m.tray.set_side(ResultTray.Side.VARIABLES)
|
||||
var edit := _arg_value(args, "--edit-details")
|
||||
var ecard := m.card_for(edit)
|
||||
if ecard:
|
||||
ecard._table_details_open = true
|
||||
if not ecard.table.entries.is_empty():
|
||||
ecard._open_details[ecard.table.entries[0].id] = true
|
||||
ecard.rebuild()
|
||||
var pipe := _arg_value(args, "--pipe")
|
||||
if pipe != "":
|
||||
m.open_pipe_options(pipe, Vector2(m.size.x * 0.45, m.size.y * 0.3))
|
||||
|
|
|
|||
|
|
@ -129,41 +129,14 @@ func delete_collection() -> void:
|
|||
# ----- Import and export -----
|
||||
|
||||
func export_collection(format: Dictionary) -> void:
|
||||
var dlg := FileDialog.new()
|
||||
dlg.use_native_dialog = true
|
||||
dlg.access = FileDialog.ACCESS_FILESYSTEM
|
||||
dlg.file_mode = FileDialog.FILE_MODE_SAVE_FILE
|
||||
dlg.title = "Export as " + str(format["label"])
|
||||
dlg.filters = PackedStringArray([format["filter"]])
|
||||
dlg.current_file = IoMenu.default_file_name(m.data, format)
|
||||
dlg.file_selected.connect(func(path: String) -> void:
|
||||
var err := TowerBoard.write_text_atomic(path, IoMenu.export_text(str(format["key"]), m.data))
|
||||
m.toast("Exported to %s" % path.get_file() if err == OK else "Couldn't write %s" % path.get_file())
|
||||
)
|
||||
dlg.visibility_changed.connect(func() -> void:
|
||||
if not dlg.visible:
|
||||
dlg.queue_free.call_deferred()
|
||||
)
|
||||
m.add_child(dlg)
|
||||
dlg.popup_centered_ratio(0.6)
|
||||
m.export_dialog("Export as " + str(format["label"]), str(format["filter"]),
|
||||
IoMenu.default_file_name(m.data, format), func() -> String: return IoMenu.export_text(str(format["key"]), m.data))
|
||||
|
||||
|
||||
func import_collection() -> void:
|
||||
if not collections_enabled():
|
||||
return
|
||||
var dlg := FileDialog.new()
|
||||
dlg.use_native_dialog = true
|
||||
dlg.access = FileDialog.ACCESS_FILESYSTEM
|
||||
dlg.file_mode = FileDialog.FILE_MODE_OPEN_FILE
|
||||
dlg.title = "Import as a new collection"
|
||||
dlg.filters = PackedStringArray(IoMenu.IMPORT_FILTERS)
|
||||
dlg.file_selected.connect(_import_file)
|
||||
dlg.visibility_changed.connect(func() -> void:
|
||||
if not dlg.visible:
|
||||
dlg.queue_free.call_deferred()
|
||||
)
|
||||
m.add_child(dlg)
|
||||
dlg.popup_centered_ratio(0.6)
|
||||
m.file_dialog("Import as a new collection", IoMenu.IMPORT_FILTERS, FileDialog.FILE_MODE_OPEN_FILE, _import_file)
|
||||
|
||||
|
||||
func _import_file(path: String) -> void:
|
||||
|
|
|
|||
|
|
@ -34,19 +34,8 @@ func _init(p_main: Main) -> void:
|
|||
|
||||
|
||||
func _make_add_menu() -> MenuButton:
|
||||
var mb := MenuButton.new()
|
||||
mb.text = "+ Card ▾"
|
||||
var mb := Style.menu_button("+ Card ▾", true)
|
||||
mb.tooltip_text = "Add a roll table or a logic card"
|
||||
mb.flat = false
|
||||
var ref := Style.bar_button("", true)
|
||||
for n in ["normal", "hover", "pressed", "hover_pressed", "disabled", "focus"]:
|
||||
mb.add_theme_stylebox_override(n, ref.get_theme_stylebox(n))
|
||||
for c in ["font_color", "font_hover_color", "font_focus_color", "font_pressed_color", "font_hover_pressed_color"]:
|
||||
mb.add_theme_color_override(c, ref.get_theme_color(c))
|
||||
mb.add_theme_font_override("font", Style.body_bold())
|
||||
mb.add_theme_font_size_override("font_size", 15)
|
||||
mb.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
ref.free()
|
||||
var pm := mb.get_popup()
|
||||
ModalCard.style_popup(pm)
|
||||
for i in ADD_KINDS.size():
|
||||
|
|
|
|||
|
|
@ -36,10 +36,7 @@ func request_table_settings(tid: String) -> void:
|
|||
if m.mode == Main.Mode.BUILD and m.inspector != null:
|
||||
select_card(tid)
|
||||
return
|
||||
if m.has_method("open_table_settings"):
|
||||
m.call("open_table_settings", tid)
|
||||
else:
|
||||
m.toast("Table settings aren't available yet")
|
||||
m.open_table_settings(tid)
|
||||
|
||||
|
||||
func select_card(table_id: String) -> void:
|
||||
|
|
|
|||
|
|
@ -205,18 +205,8 @@ func _nav_mode_changed() -> void:
|
|||
# ----- Arrange: pack collapsed groups -----
|
||||
|
||||
func _make_arrange_menu() -> MenuButton:
|
||||
var mb := MenuButton.new()
|
||||
mb.text = "Arrange ▾"
|
||||
var mb := Style.menu_button("Arrange ▾")
|
||||
mb.tooltip_text = "Tidy the layout of the board"
|
||||
mb.flat = false
|
||||
var ref := Style.bar_button("")
|
||||
for n in ["normal", "hover", "pressed", "hover_pressed", "disabled", "focus"]:
|
||||
mb.add_theme_stylebox_override(n, ref.get_theme_stylebox(n))
|
||||
for c in ["font_color", "font_hover_color", "font_focus_color", "font_pressed_color", "font_hover_pressed_color"]:
|
||||
mb.add_theme_color_override(c, ref.get_theme_color(c))
|
||||
mb.add_theme_font_size_override("font_size", 15)
|
||||
mb.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
ref.free()
|
||||
var pm := mb.get_popup()
|
||||
ModalCard.style_popup(pm)
|
||||
pm.add_item("Pack collapsed groups", ARRANGE_PACK)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ extends RefCounted
|
|||
## Saved in user://templates (TemplateLibrary), shared by every collection.
|
||||
## --sample runs keep them in memory only.
|
||||
|
||||
const TEMPLATE_FILTER := "*.json ; TableTower template"
|
||||
|
||||
var m: Main
|
||||
|
||||
var _templates: TemplateLibrary
|
||||
|
|
@ -122,33 +124,12 @@ func export_template(id: String) -> void:
|
|||
if text == "":
|
||||
m.toast("Couldn't read that template")
|
||||
return
|
||||
var dlg := FileDialog.new()
|
||||
dlg.use_native_dialog = true
|
||||
dlg.access = FileDialog.ACCESS_FILESYSTEM
|
||||
dlg.file_mode = FileDialog.FILE_MODE_SAVE_FILE
|
||||
dlg.title = "Export template"
|
||||
dlg.filters = PackedStringArray(["*.json ; TableTower template"])
|
||||
dlg.current_file = id.trim_prefix(TemplateLibrary.BUILTIN_PREFIX) + ".template.json"
|
||||
dlg.file_selected.connect(func(path: String) -> void:
|
||||
var err := TowerBoard.write_text_atomic(path, text)
|
||||
m.toast("Exported to %s" % path.get_file() if err == OK else "Couldn't write %s" % path.get_file())
|
||||
)
|
||||
dlg.visibility_changed.connect(func() -> void:
|
||||
if not dlg.visible:
|
||||
dlg.queue_free.call_deferred()
|
||||
)
|
||||
m.add_child(dlg)
|
||||
dlg.popup_centered_ratio(0.6)
|
||||
m.export_dialog("Export template", TEMPLATE_FILTER,
|
||||
id.trim_prefix(TemplateLibrary.BUILTIN_PREFIX) + ".template.json", func() -> String: return text)
|
||||
|
||||
|
||||
func import_template_file(picker: TemplatePicker = null) -> void:
|
||||
var dlg := FileDialog.new()
|
||||
dlg.use_native_dialog = true
|
||||
dlg.access = FileDialog.ACCESS_FILESYSTEM
|
||||
dlg.file_mode = FileDialog.FILE_MODE_OPEN_FILE
|
||||
dlg.title = "Import a template"
|
||||
dlg.filters = PackedStringArray(["*.json ; TableTower template"])
|
||||
dlg.file_selected.connect(func(path: String) -> void:
|
||||
m.file_dialog("Import a template", [TEMPLATE_FILTER], FileDialog.FILE_MODE_OPEN_FILE, func(path: String) -> void:
|
||||
var r := templates().import_text(FileAccess.get_file_as_string(path))
|
||||
if r["ok"]:
|
||||
m.toast("Imported template “%s”" % r["name"])
|
||||
|
|
@ -158,9 +139,3 @@ func import_template_file(picker: TemplatePicker = null) -> void:
|
|||
else:
|
||||
m._add_modal(IoMenu.report_dialog("Couldn't import %s" % path.get_file(), {"errors": r["errors"]}))
|
||||
)
|
||||
dlg.visibility_changed.connect(func() -> void:
|
||||
if not dlg.visible:
|
||||
dlg.queue_free.call_deferred()
|
||||
)
|
||||
m.add_child(dlg)
|
||||
dlg.popup_centered_ratio(0.6)
|
||||
|
|
|
|||
|
|
@ -173,10 +173,7 @@ static func segmented(options: Array, selected: int, on_change: Callable) -> Pan
|
|||
static func style_line_edit(le: LineEdit) -> void:
|
||||
le.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.DASH))
|
||||
le.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.COPPER))
|
||||
le.add_theme_color_override("font_color", Style.INK)
|
||||
le.add_theme_color_override("caret_color", Style.INK)
|
||||
le.add_theme_color_override("selection_color", Color(Style.BRASS, 0.55))
|
||||
le.add_theme_color_override("font_placeholder_color", Style.MUTED)
|
||||
Style.field_colors(le)
|
||||
le.add_theme_constant_override("minimum_character_width", 4)
|
||||
le.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
|
||||
|
|
@ -184,10 +181,7 @@ static func style_line_edit(le: LineEdit) -> void:
|
|||
static func style_text_edit(te: TextEdit) -> void:
|
||||
te.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 7, [10, 7, 10, 7]), 1, Style.DASH))
|
||||
te.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 7, [10, 7, 10, 7]), 1, Style.COPPER))
|
||||
te.add_theme_color_override("font_color", Style.INK)
|
||||
te.add_theme_color_override("caret_color", Style.INK)
|
||||
te.add_theme_color_override("selection_color", Color(Style.BRASS, 0.55))
|
||||
te.add_theme_color_override("font_placeholder_color", Style.MUTED)
|
||||
Style.field_colors(te)
|
||||
te.add_theme_color_override("background_color", Color(0, 0, 0, 0))
|
||||
|
||||
|
||||
|
|
@ -209,19 +203,9 @@ static func style_popup(pm: PopupMenu) -> void:
|
|||
|
||||
## A top-bar styled MenuButton (same look as Style.bar_button).
|
||||
static func bar_menu_button(text: String) -> MenuButton:
|
||||
var mb := MenuButton.new()
|
||||
mb.text = text
|
||||
var ref := Style.bar_button(text)
|
||||
for n in ["normal", "hover", "pressed", "hover_pressed", "disabled", "focus"]:
|
||||
mb.add_theme_stylebox_override(n, ref.get_theme_stylebox(n))
|
||||
for c in ["font_color", "font_hover_color", "font_focus_color", "font_pressed_color", "font_hover_pressed_color"]:
|
||||
mb.add_theme_color_override(c, ref.get_theme_color(c))
|
||||
var mb := Style.menu_button(text)
|
||||
mb.add_theme_color_override("font_disabled_color", Style.ON_FELT_MUTED)
|
||||
mb.add_theme_font_size_override("font_size", 15)
|
||||
mb.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
mb.flat = false
|
||||
style_popup(mb.get_popup())
|
||||
ref.free()
|
||||
return mb
|
||||
|
||||
|
||||
|
|
|
|||
37
ui/style.gd
37
ui/style.gd
|
|
@ -160,6 +160,43 @@ static func bar_button(text: String, primary: bool = false) -> Button:
|
|||
return b
|
||||
|
||||
|
||||
## A MenuButton skinned like bar_button (copies its boxes and colours onto
|
||||
## `onto`, or a new MenuButton). The caller styles the popup.
|
||||
static func menu_button(text: String, primary: bool = false, onto: MenuButton = null) -> MenuButton:
|
||||
var mb := onto if onto else MenuButton.new()
|
||||
mb.text = text
|
||||
var ref := bar_button(text, primary)
|
||||
for n in ["normal", "hover", "pressed", "hover_pressed", "disabled", "focus"]:
|
||||
mb.add_theme_stylebox_override(n, ref.get_theme_stylebox(n))
|
||||
for c in BUTTON_FONT_COLORS:
|
||||
mb.add_theme_color_override(c, ref.get_theme_color(c))
|
||||
ref.free()
|
||||
if primary:
|
||||
mb.add_theme_font_override("font", body_bold())
|
||||
mb.add_theme_font_size_override("font_size", 15)
|
||||
mb.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
mb.flat = false
|
||||
return mb
|
||||
|
||||
|
||||
const BUTTON_FONT_COLORS: Array[String] = ["font_color", "font_hover_color", "font_focus_color",
|
||||
"font_pressed_color", "font_hover_pressed_color"]
|
||||
|
||||
|
||||
## One font colour for every state of a button (normal, hover, focus, pressed).
|
||||
static func font_colors(c: Control, color: Color) -> void:
|
||||
for n in BUTTON_FONT_COLORS:
|
||||
c.add_theme_color_override(n, color)
|
||||
|
||||
|
||||
## Ink text, caret, brass selection and muted placeholder for a LineEdit or TextEdit.
|
||||
static func field_colors(c: Control) -> void:
|
||||
c.add_theme_color_override("font_color", INK)
|
||||
c.add_theme_color_override("caret_color", INK)
|
||||
c.add_theme_color_override("selection_color", Color(BRASS, 0.55))
|
||||
c.add_theme_color_override("font_placeholder_color", MUTED)
|
||||
|
||||
|
||||
## The Plain words / Text switch's look (docs/PLAIN.md §5; the switch itself
|
||||
## is Main's): two segment buttons on the felt, the chosen one card-coloured.
|
||||
## Adds them to `into` and returns [plain_button, text_button]; `on_change`
|
||||
|
|
|
|||
|
|
@ -65,12 +65,6 @@ var _style_dragging: StyleBoxFlat
|
|||
var _style_drop: StyleBoxFlat
|
||||
var _style_selected: StyleBoxFlat
|
||||
var _selected := false
|
||||
## Unused since the inspector took over the inline editors; kept because
|
||||
## Main's screenshot flags (--edit-details, --edit-effects) still set them.
|
||||
var _open_details: Dictionary = {}
|
||||
var _open_effects: Dictionary = {}
|
||||
var _open_show_if: Dictionary = {}
|
||||
var _table_details_open := false
|
||||
## The result picked in the inspector (copper bar), or "".
|
||||
var _selected_eid := ""
|
||||
|
||||
|
|
|
|||
|
|
@ -61,11 +61,10 @@ func _build() -> void:
|
|||
|
||||
start_pick = OptionButton.new()
|
||||
start_pick.add_theme_stylebox_override("normal", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.DASH))
|
||||
start_pick.add_theme_stylebox_override("hover", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.COPPER))
|
||||
start_pick.add_theme_stylebox_override("pressed", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.COPPER))
|
||||
start_pick.add_theme_stylebox_override("focus", Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.COPPER))
|
||||
for c in ["font_color", "font_hover_color", "font_pressed_color", "font_focus_color", "font_hover_pressed_color"]:
|
||||
start_pick.add_theme_color_override(c, Style.INK)
|
||||
var lit := Style.bordered(Style.box(Color.WHITE, 7, [10, 6, 10, 6]), 1, Style.COPPER)
|
||||
for n in ["hover", "pressed", "focus"]:
|
||||
start_pick.add_theme_stylebox_override(n, lit)
|
||||
Style.font_colors(start_pick, Style.INK)
|
||||
start_pick.add_theme_font_size_override("font_size", 16)
|
||||
start_pick.clip_text = true
|
||||
start_pick.fit_to_longest_item = false
|
||||
|
|
@ -301,8 +300,7 @@ func _add_section(title: String, hint: String, items: Array, open: bool) -> void
|
|||
header.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
header.add_theme_font_override("font", Style.body_bold())
|
||||
header.add_theme_font_size_override("font_size", 16)
|
||||
for c in ["font_color", "font_hover_color", "font_pressed_color", "font_focus_color", "font_hover_pressed_color"]:
|
||||
header.add_theme_color_override(c, Style.INK if not items.is_empty() else Style.MUTED)
|
||||
Style.font_colors(header, Style.INK if not items.is_empty() else Style.MUTED)
|
||||
header.add_theme_color_override("font_disabled_color", Style.MUTED)
|
||||
header.tooltip_text = hint
|
||||
var list := VBoxContainer.new()
|
||||
|
|
@ -338,8 +336,7 @@ func _item_button(item: Dictionary) -> Button:
|
|||
b.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
b.add_theme_font_override("font", Style.body())
|
||||
b.add_theme_font_size_override("font_size", 14)
|
||||
for c in ["font_color", "font_hover_color", "font_pressed_color", "font_focus_color", "font_hover_pressed_color"]:
|
||||
b.add_theme_color_override(c, Style.INK)
|
||||
Style.font_colors(b, Style.INK)
|
||||
b.add_theme_stylebox_override("hover", Style.box(Style.HOVER_ROW, 5, [8, 3, 8, 3]))
|
||||
b.add_theme_stylebox_override("pressed", Style.box(Style.HOVER_ROW, 5, [8, 3, 8, 3]))
|
||||
b.add_theme_stylebox_override("normal", Style.box(Color(0, 0, 0, 0), 5, [8, 3, 8, 3]))
|
||||
|
|
|
|||
|
|
@ -85,12 +85,9 @@ static func _effect_lines(fx: Array) -> Control:
|
|||
box.add_theme_constant_override("separation", 0)
|
||||
box.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
var shown := 0
|
||||
var errors := 0
|
||||
for l: Variant in fx:
|
||||
var d: Dictionary = l if l is Dictionary else {"text": str(l)}
|
||||
var bad: bool = d.get("error", false)
|
||||
if bad:
|
||||
errors += 1
|
||||
# Errors are always listed; ordinary lines up to EFFECT_LINES.
|
||||
if shown >= EFFECT_LINES and not bad:
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in a new issue