Sound slider in View ▾ and ☰; built-in themes hide Delete
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
323e033d88
commit
bc2936cf15
9 changed files with 77 additions and 7 deletions
|
|
@ -208,6 +208,7 @@ Groups can hold other groups. Select a group (drag a box around it) along with a
|
||||||
[demo]groups[/demo]
|
[demo]groups[/demo]
|
||||||
|
|
||||||
# Colours and themes
|
# Colours and themes
|
||||||
|
- [b]View ▾ → Sound…[/b] (or the ☰ menu) sets how loud the theme's sounds are, with a slider from Off to Loud.
|
||||||
- [b]View ▾ → Theme…[/b] picks a theme and lets you change its colours, the background and panel gradients, the background pattern, the card border and the logo. Changes to a built-in theme are saved as a theme of your own.
|
- [b]View ▾ → Theme…[/b] picks a theme and lets you change its colours, the background and panel gradients, the background pattern, the card border and the logo. Changes to a built-in theme are saved as a theme of your own.
|
||||||
- Give a card, a thread or a group its own colour from its right-click menu ([b]Colour[/b]) or in the inspector, to sort things at a glance. [b]Any colour…[/b] at the end of the menu opens a full colour picker.
|
- Give a card, a thread or a group its own colour from its right-click menu ([b]Colour[/b]) or in the inspector, to sort things at a glance. [b]Any colour…[/b] at the end of the menu opens a full colour picker.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ func _test_dialog() -> void:
|
||||||
main.add_child(d)
|
main.add_child(d)
|
||||||
await _frames()
|
await _frames()
|
||||||
_check(d._content.find_children("*", "FillEditor", true, false).size() == 2, "background and panel fill editors")
|
_check(d._content.find_children("*", "FillEditor", true, false).size() == 2, "background and panel fill editors")
|
||||||
|
_check(bool(d._work.get("builtin", false)) and not d._delete_button.visible, "a built-in theme doesn't offer Delete")
|
||||||
var basic := d._content.find_children("*", "ColorPickerButton", true, false).size()
|
var basic := d._content.find_children("*", "ColorPickerButton", true, false).size()
|
||||||
d._more = true
|
d._more = true
|
||||||
d._rebuild()
|
d._rebuild()
|
||||||
|
|
|
||||||
|
|
@ -105,3 +105,14 @@ func _test_sounds() -> void:
|
||||||
_check(not playing, "nothing plays when the sound is off")
|
_check(not playing, "nothing plays when the sound is off")
|
||||||
main.sound.set_volume(SoundBoard.DEFAULT_VOLUME)
|
main.sound.set_volume(SoundBoard.DEFAULT_VOLUME)
|
||||||
_eq(main.sound.level_name(), "Quiet", "the default level is Quiet")
|
_eq(main.sound.level_name(), "Quiet", "the default level is Quiet")
|
||||||
|
var panel := SoundPanel.open(main, Vector2(40, 40))
|
||||||
|
var sliders := panel.find_children("*", "HSlider", true, false)
|
||||||
|
_check(sliders.size() == 1 and is_equal_approx((sliders[0] as HSlider).value, SoundBoard.DEFAULT_VOLUME * 100.0), "Sound… opens a slider at the current volume")
|
||||||
|
(sliders[0] as HSlider).value = 65
|
||||||
|
_check(is_equal_approx(main.sound.volume, 0.65), "moving the slider changes the volume")
|
||||||
|
panel.hide()
|
||||||
|
main.sound.set_volume(SoundBoard.DEFAULT_VOLUME)
|
||||||
|
var view_items: Array[String] = []
|
||||||
|
for i in main.top_bar.view_menu.get_popup().item_count:
|
||||||
|
view_items.append(main.top_bar.view_menu.get_popup().get_item_text(i))
|
||||||
|
_check(view_items.has("Sound…"), "View ▾ has Sound…")
|
||||||
|
|
|
||||||
|
|
@ -187,11 +187,8 @@ static func background(m: Main, at: Vector2) -> Array:
|
||||||
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:
|
||||||
var levels := []
|
list.append({"text": "Sound…", "do": func() -> void: SoundPanel.open(m, m.get_global_mouse_position()),
|
||||||
for level: Array in SoundBoard.LEVELS:
|
"tip": "How loud the theme's sounds are"})
|
||||||
var mark := "✓ " if m.sound.level_name() == level[0] else " "
|
|
||||||
levels.append({"text": mark + str(level[0]), "do": m.sound.set_volume.bind(float(level[1]))})
|
|
||||||
list.append({"text": "Sound", "sub": levels, "tip": "How loud the theme's sounds are"})
|
|
||||||
if m.mobile:
|
if m.mobile:
|
||||||
# The phone layout has no room for these on the bar.
|
# The phone layout has no room for these on the bar.
|
||||||
var build := m.mode == Main.Mode.BUILD
|
var build := m.mode == Main.Mode.BUILD
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ extends Node
|
||||||
## without a sound for an event stays quiet. The volume is an app setting.
|
## without a sound for an event stays quiet. The volume is an app setting.
|
||||||
|
|
||||||
const SETTING := "sound_volume"
|
const SETTING := "sound_volume"
|
||||||
## Volume levels for View ▾ → Sound: [label, linear volume].
|
## Named volume levels: [label, linear volume] (the Sound slider's default is
|
||||||
|
## Quiet).
|
||||||
const LEVELS := [["Off", 0.0], ["Quiet", 0.35], ["Medium", 0.65], ["Loud", 1.0]]
|
const LEVELS := [["Off", 0.0], ["Quiet", 0.35], ["Medium", 0.65], ["Loud", 1.0]]
|
||||||
const DEFAULT_VOLUME := 0.35
|
const DEFAULT_VOLUME := 0.35
|
||||||
const EVENTS := ["roll", "card_turn", "thread", "click", "ambient"]
|
const EVENTS := ["roll", "card_turn", "thread", "click", "ambient"]
|
||||||
|
|
@ -59,6 +60,12 @@ func play(event: String) -> void:
|
||||||
voice.play()
|
voice.play()
|
||||||
|
|
||||||
|
|
||||||
|
## Changes the volume without saving it (while a slider moves).
|
||||||
|
func preview_volume(level: float) -> void:
|
||||||
|
volume = clampf(level, 0.0, 1.0)
|
||||||
|
_start_ambient()
|
||||||
|
|
||||||
|
|
||||||
func set_volume(level: float) -> void:
|
func set_volume(level: float) -> void:
|
||||||
volume = clampf(level, 0.0, 1.0)
|
volume = clampf(level, 0.0, 1.0)
|
||||||
if m.state:
|
if m.state:
|
||||||
|
|
|
||||||
43
ui/sound_panel.gd
Normal file
43
ui/sound_panel.gd
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
class_name SoundPanel
|
||||||
|
extends RefCounted
|
||||||
|
## View ▾ → Sound… (and the ☰ menu): a small pop-up with a volume slider from
|
||||||
|
## Off to Loud. Dragging changes the volume at once; letting go saves it and
|
||||||
|
## plays the roll sound at the new level.
|
||||||
|
|
||||||
|
|
||||||
|
static func open(m: Main, at: Vector2) -> PopupPanel:
|
||||||
|
var popup := PopupPanel.new()
|
||||||
|
popup.theme = Style.card_theme()
|
||||||
|
var column := VBoxContainer.new()
|
||||||
|
column.add_theme_constant_override("separation", 6)
|
||||||
|
column.custom_minimum_size = Vector2(240, 0)
|
||||||
|
popup.add_child(column)
|
||||||
|
var heading := HBoxContainer.new()
|
||||||
|
heading.add_child(Style.make_label("Sound", Style.body_bold(), 15, Style.INK))
|
||||||
|
var shown := Style.make_label("", Style.body(), 14, Style.MUTED)
|
||||||
|
shown.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
shown.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||||
|
heading.add_child(shown)
|
||||||
|
column.add_child(heading)
|
||||||
|
var slider := HSlider.new()
|
||||||
|
slider.min_value = 0
|
||||||
|
slider.max_value = 100
|
||||||
|
slider.step = 1
|
||||||
|
slider.value = roundf(m.sound.volume * 100.0)
|
||||||
|
slider.tooltip_text = "How loud the theme's sounds are"
|
||||||
|
column.add_child(slider)
|
||||||
|
var words := func(percent: float) -> String:
|
||||||
|
return "Off" if percent <= 0.0 else "%d%%" % int(percent)
|
||||||
|
shown.text = words.call(slider.value)
|
||||||
|
slider.value_changed.connect(func(percent: float) -> void:
|
||||||
|
m.sound.preview_volume(percent / 100.0)
|
||||||
|
shown.text = words.call(percent))
|
||||||
|
slider.drag_ended.connect(func(_changed: bool) -> void:
|
||||||
|
m.sound.set_volume(slider.value / 100.0)
|
||||||
|
m.sound.play("roll"))
|
||||||
|
popup.popup_hide.connect(func() -> void:
|
||||||
|
m.sound.set_volume(slider.value / 100.0)
|
||||||
|
popup.queue_free())
|
||||||
|
m.add_child(popup)
|
||||||
|
popup.popup(Rect2i(Vector2i(at), Vector2i(260, 0)))
|
||||||
|
return popup
|
||||||
1
ui/sound_panel.gd.uid
Normal file
1
ui/sound_panel.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dklnsrugi7svi
|
||||||
|
|
@ -11,6 +11,7 @@ var _work: Dictionary = {}
|
||||||
var _dirty := false
|
var _dirty := false
|
||||||
var _picker: OptionButton
|
var _picker: OptionButton
|
||||||
var _content: VBoxContainer
|
var _content: VBoxContainer
|
||||||
|
var _delete_button: Button
|
||||||
var _more := false
|
var _more := false
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -28,7 +29,7 @@ func _init(p_main: Main) -> void:
|
||||||
_content = VBoxContainer.new()
|
_content = VBoxContainer.new()
|
||||||
_content.add_theme_constant_override("separation", 14)
|
_content.add_theme_constant_override("separation", 14)
|
||||||
body.add_child(_content)
|
body.add_child(_content)
|
||||||
add_button("Delete", "plain", _delete)
|
_delete_button = add_button("Delete", "plain", _delete)
|
||||||
add_button("Save as new…", "plain", _save_as_new)
|
add_button("Save as new…", "plain", _save_as_new)
|
||||||
add_button("Close", "plain", close)
|
add_button("Close", "plain", close)
|
||||||
add_button("Use theme", "primary", _use)
|
add_button("Use theme", "primary", _use)
|
||||||
|
|
@ -58,6 +59,9 @@ func _load(t: Dictionary) -> void:
|
||||||
func _rebuild() -> void:
|
func _rebuild() -> void:
|
||||||
for c in _content.get_children():
|
for c in _content.get_children():
|
||||||
c.queue_free()
|
c.queue_free()
|
||||||
|
# Built-in themes can't be deleted, so they don't offer it.
|
||||||
|
if _delete_button:
|
||||||
|
_delete_button.visible = not bool(_work.get("builtin", false))
|
||||||
if bool(_work.get("builtin", false)):
|
if bool(_work.get("builtin", false)):
|
||||||
_content.add_child(ModalCard.note("This theme is built in. Changes to it are saved as a new theme of your own."))
|
_content.add_child(ModalCard.note("This theme is built in. Changes to it are saved as a new theme of your own."))
|
||||||
var bg := FillEditor.new(_work.get("background", {}), _color("BG"))
|
var bg := FillEditor.new(_work.get("background", {}), _color("BG"))
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ const ID_MINIMAP := 4
|
||||||
const ID_THEME := 5
|
const ID_THEME := 5
|
||||||
const ID_LIST := 6
|
const ID_LIST := 6
|
||||||
const ID_BOOK := 7
|
const ID_BOOK := 7
|
||||||
|
const ID_SOUND := 8
|
||||||
|
|
||||||
var m: Main
|
var m: Main
|
||||||
|
|
||||||
|
|
@ -39,6 +40,8 @@ func setup(p_main: Main) -> void:
|
||||||
pm.add_separator()
|
pm.add_separator()
|
||||||
pm.add_item("Theme…", ID_THEME)
|
pm.add_item("Theme…", ID_THEME)
|
||||||
pm.set_item_tooltip(pm.get_item_index(ID_THEME), "Colours, background, fonts and logo; save your own theme")
|
pm.set_item_tooltip(pm.get_item_index(ID_THEME), "Colours, background, fonts and logo; save your own theme")
|
||||||
|
pm.add_item("Sound…", ID_SOUND)
|
||||||
|
pm.set_item_tooltip(pm.get_item_index(ID_SOUND), "How loud the theme's sounds are")
|
||||||
pm.about_to_popup.connect(sync)
|
pm.about_to_popup.connect(sync)
|
||||||
pm.id_pressed.connect(activate)
|
pm.id_pressed.connect(activate)
|
||||||
|
|
||||||
|
|
@ -77,3 +80,5 @@ func activate(id: int) -> void:
|
||||||
m.book.toggle()
|
m.book.toggle()
|
||||||
ID_THEME:
|
ID_THEME:
|
||||||
m.add_child(ThemeDialog.new(m))
|
m.add_child(ThemeDialog.new(m))
|
||||||
|
ID_SOUND:
|
||||||
|
SoundPanel.open(m, get_global_rect().position + Vector2(0, size.y + 4))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue