Volume Sliders

This commit is contained in:
Marco 2025-03-17 11:43:11 +01:00
commit c75d9d226f
19 changed files with 257 additions and 49 deletions

View file

@ -0,0 +1,16 @@
[gd_resource type="StyleBoxTexture" load_steps=2 format=3 uid="uid://dnb4ogn847dyp"]
[ext_resource type="Texture2D" uid="uid://teydwmu6h04b" path="res://Sprites/UI/HealthBar.png" id="1_cbfps"]
[resource]
texture = ExtResource("1_cbfps")
texture_margin_left = 3.0
texture_margin_top = 3.0
texture_margin_right = 3.0
texture_margin_bottom = 3.0
expand_margin_left = 1.0
expand_margin_top = 1.0
expand_margin_right = 1.0
expand_margin_bottom = 1.0
axis_stretch_horizontal = 2
axis_stretch_vertical = 2

View file

@ -0,0 +1,10 @@
[gd_resource type="StyleBoxTexture" load_steps=2 format=3 uid="uid://6ydsirgc5xi5"]
[ext_resource type="Texture2D" uid="uid://b4itkpf7s61p3" path="res://Sprites/UI/HealthBar_Foreground.png" id="1_xi12v"]
[resource]
texture = ExtResource("1_xi12v")
texture_margin_left = 3.0
texture_margin_top = 3.0
texture_margin_right = 3.0
texture_margin_bottom = 3.0

View file

@ -1,9 +1,13 @@
[gd_resource type="Theme" load_steps=8 format=3 uid="uid://dnsadvmunm76k"]
[gd_resource type="Theme" load_steps=12 format=3 uid="uid://dnsadvmunm76k"]
[ext_resource type="FontFile" uid="uid://coek1e2q257pq" path="res://fonts/at01.ttf" id="1_dp7be"]
[ext_resource type="StyleBox" uid="uid://ctw2hju32l3rg" path="res://Resources/Styles/PixelStyleBoxRed.tres" id="2_wf67a"]
[ext_resource type="Texture2D" uid="uid://57jo25mrp028" path="res://Sprites/UI/Checkbox.png" id="3_xfr2l"]
[ext_resource type="StyleBox" uid="uid://6ydsirgc5xi5" path="res://Resources/Styles/HealthBarFill.tres" id="4_j5bu4"]
[ext_resource type="Texture2D" uid="uid://d2m6srimy07bq" path="res://Sprites/UI/SliderSelector.png" id="4_joeh7"]
[ext_resource type="StyleBox" uid="uid://24hh6h4juk3r" path="res://Resources/Styles/PixelStyleBoxRed_SquareBackground.tres" id="4_jpso0"]
[ext_resource type="StyleBox" uid="uid://dnb4ogn847dyp" path="res://Resources/Styles/HealthBarBackground.tres" id="5_ogh8g"]
[ext_resource type="Texture2D" uid="uid://c4bj6flx8lp68" path="res://Sprites/UI/SliderSelector_Focused.png" id="5_xp2bu"]
[sub_resource type="AtlasTexture" id="AtlasTexture_jpso0"]
atlas = ExtResource("3_xfr2l")
@ -47,6 +51,13 @@ Button/styles/pressed = ExtResource("2_wf67a")
CheckBox/icons/checked = SubResource("AtlasTexture_jpso0")
CheckBox/icons/unchecked = SubResource("AtlasTexture_0p6en")
CheckBox/icons/unchecked_disabled = SubResource("AtlasTexture_xfr2l")
HSlider/icons/grabber = ExtResource("4_joeh7")
HSlider/icons/grabber_disabled = null
HSlider/icons/grabber_highlight = ExtResource("5_xp2bu")
HSlider/icons/tick = null
HSlider/styles/grabber_area = ExtResource("4_j5bu4")
HSlider/styles/grabber_area_highlight = ExtResource("4_j5bu4")
HSlider/styles/slider = ExtResource("5_ogh8g")
TabContainer/colors/font_disabled_color = Color(0, 0.188235, 0, 1)
TabContainer/colors/font_hovered_color = Color(0, 0.698039, 0, 1)
TabContainer/colors/font_selected_color = Color(0, 0.737255, 0, 1)
@ -60,3 +71,6 @@ TabContainer/styles/tab_hovered = ExtResource("4_jpso0")
TabContainer/styles/tab_selected = ExtResource("4_jpso0")
TabContainer/styles/tab_unselected = ExtResource("4_jpso0")
TabContainer/styles/tabbar_background = null
VSlider/styles/grabber_area = null
VSlider/styles/grabber_area_highlight = null
VSlider/styles/slider = null

21
Resources/bus_layout.tres Normal file
View file

@ -0,0 +1,21 @@
[gd_resource type="AudioBusLayout" format=3 uid="uid://clblu7fse2pjy"]
[resource]
bus/1/name = &"Music"
bus/1/solo = false
bus/1/mute = false
bus/1/bypass_fx = false
bus/1/volume_db = 0.0
bus/1/send = &"Master"
bus/2/name = &"Effects"
bus/2/solo = false
bus/2/mute = false
bus/2/bypass_fx = false
bus/2/volume_db = 0.0
bus/2/send = &"Master"
bus/3/name = &"Voice"
bus/3/solo = false
bus/3/mute = false
bus/3/bypass_fx = false
bus/3/volume_db = 0.0
bus/3/send = &"Master"

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=31 format=3 uid="uid://dkwi1hu1bixoe"]
[gd_scene load_steps=29 format=3 uid="uid://dkwi1hu1bixoe"]
[ext_resource type="Script" uid="uid://baf6pxbvhqmjk" path="res://Scripts/Hud.cs" id="1_m0hb0"]
[ext_resource type="FontFile" uid="uid://ccm3u37q1hvux" path="res://fonts/Xolonium-Regular.ttf" id="2_0xmx2"]
@ -11,10 +11,10 @@
[ext_resource type="PackedScene" uid="uid://bwlstkdibs7oc" path="res://Scenes/HUD/BossHud.tscn" id="5_vmict"]
[ext_resource type="FontFile" uid="uid://coek1e2q257pq" path="res://fonts/at01.ttf" id="6_sk1eq"]
[ext_resource type="Theme" uid="uid://dnsadvmunm76k" path="res://Resources/Styles/MainMenuButtons.tres" id="9_sx5r0"]
[ext_resource type="StyleBox" uid="uid://dnb4ogn847dyp" path="res://Resources/Styles/HealthBarBackground.tres" id="10_n0pka"]
[ext_resource type="Script" uid="uid://bobo5f4ud60qw" path="res://Scripts/UI/ItemsMenu.cs" id="10_oflr6"]
[ext_resource type="Texture2D" uid="uid://teydwmu6h04b" path="res://Sprites/UI/HealthBar.png" id="10_sjdna"]
[ext_resource type="Script" uid="uid://com5b4ffsmj7s" path="res://Scripts/UI/InventoryMenu.cs" id="11_7pulb"]
[ext_resource type="Texture2D" uid="uid://b4itkpf7s61p3" path="res://Sprites/UI/HealthBar_Foreground.png" id="11_86ddi"]
[ext_resource type="StyleBox" uid="uid://6ydsirgc5xi5" path="res://Resources/Styles/HealthBarFill.tres" id="11_j6myr"]
[ext_resource type="Texture2D" uid="uid://bhmtp6i2g2f1c" path="res://Sprites/UI/ShieldBar.png" id="12_n0pka"]
[ext_resource type="Texture2D" uid="uid://cihsd5rw8i5xm" path="res://Sprites/UI/ShieldBar_Foreground.png" id="13_j6myr"]
[ext_resource type="StyleBox" uid="uid://24hh6h4juk3r" path="res://Resources/Styles/PixelStyleBoxRed_SquareBackground.tres" id="13_sjdna"]
@ -56,26 +56,6 @@ animations = [{
"speed": 5.0
}]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_86ddi"]
texture = ExtResource("10_sjdna")
texture_margin_left = 3.0
texture_margin_top = 3.0
texture_margin_right = 3.0
texture_margin_bottom = 3.0
expand_margin_left = 1.0
expand_margin_top = 1.0
expand_margin_right = 1.0
expand_margin_bottom = 1.0
axis_stretch_horizontal = 2
axis_stretch_vertical = 2
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_qpigx"]
texture = ExtResource("11_86ddi")
texture_margin_left = 3.0
texture_margin_top = 3.0
texture_margin_right = 3.0
texture_margin_bottom = 3.0
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_h6xwv"]
texture = ExtResource("12_n0pka")
texture_margin_left = 3.0
@ -172,8 +152,8 @@ layout_mode = 2
custom_minimum_size = Vector2(34, 8)
layout_mode = 2
size_flags_vertical = 4
theme_override_styles/background = SubResource("StyleBoxTexture_86ddi")
theme_override_styles/fill = SubResource("StyleBoxTexture_qpigx")
theme_override_styles/background = ExtResource("10_n0pka")
theme_override_styles/fill = ExtResource("11_j6myr")
value = 50.0
rounded = true
show_percentage = false

View file

@ -1,10 +1,11 @@
[gd_scene load_steps=7 format=3 uid="uid://bnhcgsyh6wfo3"]
[gd_scene load_steps=8 format=3 uid="uid://bnhcgsyh6wfo3"]
[ext_resource type="Theme" uid="uid://dnsadvmunm76k" path="res://Resources/Styles/MainMenuButtons.tres" id="1_il8fq"]
[ext_resource type="Script" uid="uid://c1874e6ryvd1g" path="res://Scripts/UI/OptionsMenu.cs" id="1_mpohc"]
[ext_resource type="Texture2D" uid="uid://b4fhb0wyc5vw" path="res://Sprites/UI/BackIcon.png" id="2_4kao5"]
[ext_resource type="FontFile" uid="uid://ccm3u37q1hvux" path="res://fonts/Xolonium-Regular.ttf" id="2_l5i2j"]
[ext_resource type="StyleBox" uid="uid://ctw2hju32l3rg" path="res://Resources/Styles/PixelStyleBoxRed.tres" id="3_l5i2j"]
[ext_resource type="PackedScene" uid="uid://cwhm3802fhdax" path="res://Scenes/HUD/Volume_Slider.tscn" id="6_x23el"]
[sub_resource type="LabelSettings" id="LabelSettings_4kao5"]
font = ExtResource("2_l5i2j")
@ -12,13 +13,14 @@ font_size = 20
outline_size = 4
outline_color = Color(0, 0, 0, 1)
[node name="OptionsMenu" type="VBoxContainer"]
[node name="OptionsMenu" type="VBoxContainer" node_paths=PackedStringArray("ResolutionsList")]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_mpohc")
ResolutionsList = NodePath("ScrollContainer/HBoxContainer/HFlowContainer/Resolution/ResolutionsList")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
@ -58,19 +60,15 @@ layout_mode = 2
text = "Note: The options currently do nothing"
[node name="Resolution" type="VBoxContainer" parent="ScrollContainer/HBoxContainer/HFlowContainer"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="ScrollContainer/HBoxContainer/HFlowContainer/Resolution"]
layout_mode = 2
text = "Resolution"
[node name="OptionButton" type="OptionButton" parent="ScrollContainer/HBoxContainer/HFlowContainer/Resolution"]
[node name="ResolutionsList" type="OptionButton" parent="ScrollContainer/HBoxContainer/HFlowContainer/Resolution"]
layout_mode = 2
item_count = 2
popup/item_0/text = "1920x1080"
popup/item_0/id = 0
popup/item_1/text = "Test 1"
popup/item_1/id = 1
[node name="CheckBox" type="CheckBox" parent="ScrollContainer/HBoxContainer/HFlowContainer"]
layout_mode = 2
@ -80,7 +78,7 @@ text = "VSync"
[node name="CheckBox2" type="CheckBox" parent="ScrollContainer/HBoxContainer/HFlowContainer"]
layout_mode = 2
size_flags_vertical = 0
text = "Whatever"
text = "Full Screen"
[node name="CheckBox3" type="CheckBox" parent="ScrollContainer/HBoxContainer/HFlowContainer"]
layout_mode = 2
@ -95,16 +93,28 @@ text = "adsfdsaf"
[node name="VBoxContainer3" type="VBoxContainer" parent="ScrollContainer/HBoxContainer"]
layout_mode = 2
[node name="VBoxContainer3" type="VBoxContainer" parent="ScrollContainer/HBoxContainer/VBoxContainer3"]
layout_mode = 2
theme = ExtResource("1_il8fq")
[node name="Label" type="Label" parent="ScrollContainer/HBoxContainer/VBoxContainer3/VBoxContainer3"]
layout_mode = 2
text = "Master Volume"
[node name="MusicSlider" parent="ScrollContainer/HBoxContainer/VBoxContainer3/VBoxContainer3" instance=ExtResource("6_x23el")]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer/HBoxContainer/VBoxContainer3"]
layout_mode = 2
theme = ExtResource("1_il8fq")
[node name="Label" type="Label" parent="ScrollContainer/HBoxContainer/VBoxContainer3/VBoxContainer"]
layout_mode = 2
text = "Music Volume"
[node name="HSlider" type="HSlider" parent="ScrollContainer/HBoxContainer/VBoxContainer3/VBoxContainer"]
[node name="MusicSlider" parent="ScrollContainer/HBoxContainer/VBoxContainer3/VBoxContainer" instance=ExtResource("6_x23el")]
layout_mode = 2
value = 50.0
AudioBusName = &"Music"
[node name="VBoxContainer2" type="VBoxContainer" parent="ScrollContainer/HBoxContainer/VBoxContainer3"]
layout_mode = 2
@ -113,8 +123,8 @@ layout_mode = 2
layout_mode = 2
text = "Sound Effects Volume"
[node name="HSlider" type="HSlider" parent="ScrollContainer/HBoxContainer/VBoxContainer3/VBoxContainer2"]
[node name="SoundSlider" parent="ScrollContainer/HBoxContainer/VBoxContainer3/VBoxContainer2" instance=ExtResource("6_x23el")]
layout_mode = 2
value = 50.0
AudioBusName = &"Effects"
[connection signal="pressed" from="HBoxContainer/BackButton" to="." method="_on_back_button_pressed"]

View file

@ -0,0 +1,18 @@
[gd_scene load_steps=3 format=3 uid="uid://cwhm3802fhdax"]
[ext_resource type="Theme" uid="uid://dnsadvmunm76k" path="res://Resources/Styles/MainMenuButtons.tres" id="1_guyi5"]
[ext_resource type="Script" uid="uid://du6nu7qvqvd8w" path="res://Scripts/UI/AudioSlider.cs" id="2_i14ck"]
[node name="VolumeSlider" type="HSlider"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_guyi5")
max_value = 1.0
step = 0.05
value = 0.6
script = ExtResource("2_i14ck")
[connection signal="mouse_exited" from="." to="." method="release_focus"]

View file

@ -20,9 +20,9 @@
[ext_resource type="Resource" uid="uid://byo74ews118nl" path="res://Resources/Music/No_Reason.tres" id="13_fh7cp"]
[ext_resource type="FontFile" uid="uid://cyk27h5aox1n7" path="res://fonts/sector_034.ttf" id="14_yxkem"]
[sub_resource type="AtlasTexture" id="AtlasTexture_ljnfb"]
[sub_resource type="AtlasTexture" id="AtlasTexture_hbsma"]
atlas = ExtResource("9_riqfo")
region = Rect2(128, 0, 32, 16)
region = Rect2(192, 0, 32, 16)
[sub_resource type="Theme" id="Theme_c7h4d"]
@ -67,7 +67,7 @@ offset_top = 40.995
offset_right = 186.42
offset_bottom = 56.995
rotation = 3.14159
texture = SubResource("AtlasTexture_ljnfb")
texture = SubResource("AtlasTexture_hbsma")
[node name="MarginContainer" type="MarginContainer" parent="."]
anchors_preset = 15
@ -203,14 +203,16 @@ text = "Credits"
[node name="AudioStreamPlayer2D" parent="." instance=ExtResource("8_koqhg")]
stream = ExtResource("4_i6ku4")
autoplay = true
bus = &"Music"
MusicData = ExtResource("13_fh7cp")
[node name="SubMenuContainer" type="PanelContainer" parent="."]
visible = false
offset_left = 13.0
offset_top = 23.0
offset_right = 312.0
offset_bottom = 156.0
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = ExtResource("7_rrcx7")
[connection signal="pressed" from="MarginContainer/GridContainer/GameButtons/StartButton" to="." method="_on_start_button_pressed"]

View file

@ -61,7 +61,7 @@
[sub_resource type="Resource" id="Resource_6wo78"]
script = ExtResource("4_u1i8n")
EggIndex = 0
StartingEquipment = Array[ExtResource("5_u1i8n")]([])
StartingEquipment = []
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rff8l"]
size = Vector2(30, 52.5)

23
Scripts/UI/AudioSlider.cs Normal file
View file

@ -0,0 +1,23 @@
using Godot;
namespace Cirno.Scripts.UI;
public partial class AudioSlider : HSlider
{
[Export] public StringName AudioBusName { get; private set; } = "Master";
private int _audioBusIndex;
public override void _Ready()
{
_audioBusIndex = AudioServer.GetBusIndex(AudioBusName);
this.Value = AudioServer.GetBusVolumeLinear(_audioBusIndex);
this.ValueChanged += MusicVolumeSliderOnValueChanged;
}
private void MusicVolumeSliderOnValueChanged(double value)
{
AudioServer.SetBusVolumeLinear(_audioBusIndex, (float)value);
}
}

View file

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

View file

@ -1,9 +1,38 @@
namespace Cirno.Scripts.UI;
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.UI;
public partial class OptionsMenu : MenuBase
{
[Export] public Array<Vector2I> Resolutions =
[
new(320, 160),
new(512, 256),
new(640, 320),
new(1024, 512),
new(1280, 640),
new(1920, 1080),
];
[Export] public OptionButton ResolutionsList { get; private set; }
//[Export] public HSlider MusicVolumeSlider { get; private set; }
public override void _Ready()
{
foreach (var resolution in Resolutions)
{
ResolutionsList.AddItem($"{resolution.X}x{resolution.Y}");
}
ResolutionsList.ItemSelected += ResolutionsListOnItemSelected;
}
private void ResolutionsListOnItemSelected(long index)
{
GD.Print($"Selected index: {index} {Resolutions[(int)index]}");
DisplayServer.WindowSetSize(Resolutions[(int)index]);
}
}

BIN
Sprites/UI/SliderSelector.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/UI/SliderSelector.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d2m6srimy07bq"
path="res://.godot/imported/SliderSelector.png-7f9e1c15068fb5b4a5ee9b337faf3167.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/UI/SliderSelector.png"
dest_files=["res://.godot/imported/SliderSelector.png-7f9e1c15068fb5b4a5ee9b337faf3167.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Sprites/UI/SliderSelector_Focused.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/UI/SliderSelector_Focused.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c4bj6flx8lp68"
path="res://.godot/imported/SliderSelector_Focused.png-e8de4c793060d915d1bd4f1b45318ccb.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/UI/SliderSelector_Focused.png"
dest_files=["res://.godot/imported/SliderSelector_Focused.png-e8de4c793060d915d1bd4f1b45318ccb.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -38,6 +38,10 @@ run/main_scene="uid://dew6axbejrusj"
config/features=PackedStringArray("4.4", "C#", "GL Compatibility")
config/icon="res://icon.svg"
[audio]
buses/default_bus_layout="uid://clblu7fse2pjy"
[autoload]
DebugStats="res://Scenes/debug_stats.tscn"