This commit is contained in:
Paul Black 2023-03-17 00:20:54 -06:00
parent 8049377263
commit 6183e16fcb
8 changed files with 58 additions and 18 deletions

View file

@ -33,7 +33,7 @@ offset_top = 213.0
offset_right = 674.0
offset_bottom = 239.0
size_flags_vertical = 0
text = "Adjust Mouse sensitivity"
text = "Adjust Mouse Sensitivity"
[node name="Button" type="Button" parent="."]
layout_mode = 0
@ -46,21 +46,39 @@ flat = true
[node name="Label2" type="Label" parent="."]
layout_mode = 0
offset_left = 512.0
offset_top = 326.0
offset_right = 596.0
offset_bottom = 352.0
offset_left = 522.0
offset_top = 501.0
offset_right = 606.0
offset_bottom = 527.0
text = "Fullscreen:"
[node name="fullscreenBox" type="CheckBox" parent="."]
layout_mode = 0
offset_left = 601.0
offset_top = 326.0
offset_right = 625.0
offset_bottom = 350.0
offset_left = 611.0
offset_top = 501.0
offset_right = 635.0
offset_bottom = 525.0
[node name="volLabel" type="Label" parent="."]
layout_mode = 0
offset_left = 517.0
offset_top = 343.0
offset_right = 635.0
offset_bottom = 369.0
text = "Master Volume"
[node name="volumeSlider" type="HSlider" parent="."]
offset_left = 487.0
offset_top = 380.0
offset_right = 671.0
offset_bottom = 396.0
max_value = 1.0
step = 0.01
[connection signal="ready" from="h_slider" to="." method="_on_h_slider_ready"]
[connection signal="value_changed" from="h_slider" to="." method="_on_h_slider_value_changed"]
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
[connection signal="button_down" from="fullscreenBox" to="." method="_on_fullscreen_box_button_down"]
[connection signal="button_up" from="fullscreenBox" to="." method="_on_fullscreen_box_button_up"]
[connection signal="ready" from="volumeSlider" to="." method="_on_volume_slider_ready"]
[connection signal="value_changed" from="volumeSlider" to="." method="_on_volume_slider_value_changed"]

View file

@ -57,7 +57,6 @@ func _process(delta):
if Global.roundInSession == false:
for i in range(Global.connectedPlayers.size()):
if Global.connectedPlayers[i]:
var objectLabel = "player" + str(i) + "Label"
var numlabel = i + 1
get_node("player" + str(numlabel) + "Label").text = Global.connectedPlayers[i] + ": " + "0"
@ -65,7 +64,6 @@ func _process(delta):
func update_scores(name):
for i in range(Global.connectedPlayers.size()):
if Global.connectedPlayers[i] == str(name):
var objectLabel = "player" + str(i) + "Label"
var numlabel = i + 1
var currentScore = scores[i] + 1
scores[i] += 1

View file

@ -40,6 +40,7 @@ var spawnCoords_x: Array[float] = [] # Used locally in spawn_locations() functio
var spawnCoords_y: Array[float] = [] # Used locally in spawn_locations() function
var spawnCoords_z: Array[float] = [] # Used locally in spawn_locations() function
var spawnCoordsInitalized = false # Used locally
var volumeModifer = 1 # Modifies volume level
func _process(delta):
#if not spawnCoordsInitalized:
@ -74,6 +75,9 @@ func reset_variables():
playerAlive = true
playerPleaseRespawn = false
func save_data():
SettingsFile.save_data(mouseSensitivity, playerName, volumeModifer)
func spawn_locations():
if mapName == "Toyland":
spawnCoords_x.resize(6)

View file

@ -71,7 +71,7 @@ func _on_join_button_pressed():
func _on_player_name_box_text_changed(new_text):
Global.playerName = $playerNameBox.text
SettingsFile.save_data(Global.mouseSensitivity, Global.playerName)
Global.save_data()
func _on_short_respawn_button_down():

View file

@ -4,7 +4,11 @@ var mainMenuScene = "res://scenes/mainmenu.tscn"
var musicName = "Fall From Grace"
var musicAuthor = "Darren Curtis"
@export var audio_bus_name := "Master"
@onready var _bus := AudioServer.get_bus_index(audio_bus_name)
func _ready():
AudioServer.set_bus_volume_db(_bus, linear_to_db(Global.volumeModifer))
if Global.playingGame == true:
$Button.text = "RESUME"
$Button3.text = "MAIN MENU"

View file

@ -60,4 +60,4 @@ func _on_join_button_pressed():
func _on_player_name_box_text_changed(new_text):
Global.playerName = new_text
SettingsFile.save_data(Global.mouseSensitivity, Global.playerName)
Global.save_data()

View file

@ -4,7 +4,8 @@ const SETTINGS_FILE = "user://settings.vars" # user:// path varies depending on
var settings_template = { # Default values if we don't already have a settings file. Assigned in save_data()
'mousesense': 0.01,
'playername' : "player"
'playername' : "player",
'volume' : 0.5
}
var settings_data = {} # This gets filled as soon as load_data() is called.
@ -28,10 +29,11 @@ func check_data(): # Makes sure the save file exists
var file2 = FileAccess.open(SETTINGS_FILE, FileAccess.WRITE)
file2.store_line(JSON.stringify(settings_template)) # Writes settings_template to our file SETTINGS_FILE
func save_data(mousesense, playername): # It's required you pass both the mouse sensitivity and the player name to save current data
func save_data(mousesense, playername, volume): # It's required you pass both the mouse sensitivity and the player name to save current data
var file = FileAccess.open(SETTINGS_FILE, FileAccess.WRITE)
settings_data['mousesense'] = Global.mouseSensitivity
settings_data['playername'] = Global.playerName
settings_data['mousesense'] = mousesense
settings_data['playername'] = playername
settings_data['volume'] = volume
file.store_line(JSON.stringify(settings_data))
func load_data():
@ -40,5 +42,7 @@ func load_data():
print(settings_data)
var mousesense = settings_data['mousesense']
var playername = settings_data['playername']
var volume = settings_data['volume']
Global.mouseSensitivity = mousesense
Global.playerName = playername
Global.volumeModifer = volume

View file

@ -1,5 +1,7 @@
extends Control
@export var audio_bus_name := "Master"
@onready var _bus := AudioServer.get_bus_index(audio_bus_name)
func _ready():
if get_window().get_mode() == Window.Mode.MODE_FULLSCREEN:
@ -15,7 +17,7 @@ func _process(delta):
func _on_h_slider_value_changed(value):
Global.mouseSensitivity = value
SettingsFile.save_data(Global.mouseSensitivity, Global.playerName)
Global.save_data()
func _on_button_pressed():
@ -28,3 +30,13 @@ func _on_fullscreen_box_button_down():
func _on_fullscreen_box_button_up():
get_window().set_mode(Window.Mode.MODE_WINDOWED)
func _on_volume_slider_value_changed(value):
Global.volumeModifer = value
AudioServer.set_bus_volume_db(_bus, linear_to_db(value))
Global.save_data()
func _on_volume_slider_ready():
var slider = $volumeSlider
slider.value = Global.volumeModifer