diff options
author | BigBrotherNii <nicochr1004@gmail.com> | 2024-07-24 14:31:21 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-25 11:23:26 +0200 |
commit | e108944ffab8f69308f78a87c9c9310dff410d6e (patch) | |
tree | 4aa039752aed73a3ac9a9ddff4ed1f92923fe28a /client | |
parent | 74fb8de441c68fff92680a48352f6b9b0f6e9271 (diff) | |
download | hurrycurry-e108944ffab8f69308f78a87c9c9310dff410d6e.tar hurrycurry-e108944ffab8f69308f78a87c9c9310dff410d6e.tar.bz2 hurrycurry-e108944ffab8f69308f78a87c9c9310dff410d6e.tar.zst |
added main theme and music settings
Diffstat (limited to 'client')
-rw-r--r-- | client/audio/sound.gd | 16 | ||||
-rw-r--r-- | client/audio/sound.tscn | 4 | ||||
-rw-r--r-- | client/global.gd | 8 | ||||
-rw-r--r-- | client/map/tiles/portal.gdshader | 63 | ||||
-rw-r--r-- | client/menu/main.gd | 1 |
5 files changed, 90 insertions, 2 deletions
diff --git a/client/audio/sound.gd b/client/audio/sound.gd index ac30acf8..99bf692f 100644 --- a/client/audio/sound.gd +++ b/client/audio/sound.gd @@ -2,6 +2,7 @@ # Copyright 2024 nokoe # Copyright 2024 tpart # Copyright 2024 metamuffin +# Copyright 2024 BigBrotherNii # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -19,10 +20,25 @@ extends Node @onready var click_sound = $UI/Click @onready var hover_sound = $UI/Hover +@onready var music_node : Node = $Music var item_sounds: Dictionary = {} var item_id: int = 0 +func play_music(music : String): + for stream in music_node.get_children(): + stream.stop() + + music_node.get_node(music).play() + +func set_volume(value:float): + AudioServer.set_bus_volume_db(0, value) + + if value == -30: + AudioServer.set_bus_mute(0, true) + else: + AudioServer.set_bus_mute(0, false) + func play_click(): click_sound.play() diff --git a/client/audio/sound.tscn b/client/audio/sound.tscn index 3f2607c8..a8524e71 100644 --- a/client/audio/sound.tscn +++ b/client/audio/sound.tscn @@ -14,3 +14,7 @@ stream = ExtResource("2_mhrce") [node name="Hover" type="AudioStreamPlayer" parent="UI"] stream = ExtResource("3_qft2s") + +[node name="Music" type="Node" parent="."] + +[node name="MainMenu" type="AudioStreamPlayer" parent="Music"] diff --git a/client/global.gd b/client/global.gd index ab4c8d6a..53049823 100644 --- a/client/global.gd +++ b/client/global.gd @@ -41,6 +41,7 @@ var using_joypad := false var default_settings := { "language": DropdownSetting.new(tr("Language"), 0, languages), + "master_volume": RangeSetting.new(tr("Volume"), 0, -30, 0), "fullscreen": DropdownSetting.new(tr("Fullscreen"), 0, [tr("Keep"), tr("Always"), tr("Never")]), "touch_controls": ToggleSetting.new(tr("Enable touch screen controls"), DisplayServer.is_touchscreen_available()), "interpolate_camera_rotation": ToggleSetting.new(tr("Interpolate the camera rotation"), true), @@ -135,8 +136,6 @@ func apply_settings(): # Temporal Anti-aliasing get_viewport().use_taa = get_setting("taa") - emit_signal("settings_changed") - # UI scale match get_setting("ui_scale"): 0: @@ -149,6 +148,11 @@ func apply_settings(): for k in profile["hints"].keys(): set_hint(k, false) + # Sets Volume + Sound.set_volume(get_setting("master_volume")) + + emit_signal("settings_changed") + func update_language(): var lang_idx: int = get_setting("language") var lang = languages[lang_idx] diff --git a/client/map/tiles/portal.gdshader b/client/map/tiles/portal.gdshader new file mode 100644 index 00000000..3ffd7d07 --- /dev/null +++ b/client/map/tiles/portal.gdshader @@ -0,0 +1,63 @@ +/* + Hurry Curry! - a game about cooking + Copyright 2024 metamuffin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, version 3 of the License only. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +*/ +shader_type spatial; +render_mode unshaded; + +uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; + +varying vec3 world_camera; +varying vec3 world_position; +varying mat4 untr; + +uniform float type : hint_range(-1.0, 1.0); +uniform float size : hint_range(0.0, 2.0); + +void vertex() { + MODELVIEW_MATRIX = VIEW_MATRIX * mat4( + INV_VIEW_MATRIX[0], + INV_VIEW_MATRIX[1], + INV_VIEW_MATRIX[2], + MODEL_MATRIX[3] + ); + world_position = VERTEX; + world_camera = (inverse(MODELVIEW_MATRIX) * vec4(0, 0, 0, 1)).xyz; + untr = MODELVIEW_MATRIX; +} + +void fragment() { + vec3 ray = world_camera / size; + vec3 rv = normalize(world_position - world_camera); + vec3 em = vec3(0.); + bool hit = false; + + for (int i = 0; i < 100; i++) { + float st = length(ray) * 0.1; + ray += normalize(rv) * st; + if (length(ray) < 1.) { hit = true; break; } + rv += -normalize(ray) * -type / exp(dot(ray,ray)) * st; + em += st * smoothstep(1.5,1.2,length(ray)) * 0.2; + } + + vec4 k = PROJECTION_MATRIX * vec4(rv*1000.0, 1.0); + k /= k.z; + vec2 k2 = (k.xy + 1.) / 2.; + + vec3 col = hit ? vec3(type*0.5+0.5) : texture(screen_texture, k2).rgb; + col += vec3(0.3,0.0,1.0) * max(em - 0.1,0.); + ALBEDO = col; +} diff --git a/client/menu/main.gd b/client/menu/main.gd index 2a642e14..dbb096f1 100644 --- a/client/menu/main.gd +++ b/client/menu/main.gd @@ -35,6 +35,7 @@ func _ready(): quit_button.hide() server.hide() connect_uri.text = Global.get_profile("last_server_url") + Sound.play_music("MainMenu") func _menu_cover(state): $side.visible = not state |