This commit is contained in:
Paul Black 2023-09-10 02:39:31 -06:00
parent 830b715d35
commit feef3a74f6
4 changed files with 25 additions and 1 deletions

View file

@ -106,5 +106,7 @@ offset_bottom = 369.0
[connection signal="text_changed" from="playerNameBox" to="." method="_on_player_name_box_text_changed"] [connection signal="text_changed" from="playerNameBox" to="." method="_on_player_name_box_text_changed"]
[connection signal="pressed" from="backButton" to="." method="_on_button_pressed"] [connection signal="pressed" from="backButton" to="." method="_on_button_pressed"]
[connection signal="text_changed" from="ipBox" to="." method="_on_ip_box_text_changed"]
[connection signal="text_changed" from="portBox" to="." method="_on_port_box_text_changed"]
[connection signal="pressed" from="hostButton" to="." method="_on_host_button_pressed"] [connection signal="pressed" from="hostButton" to="." method="_on_host_button_pressed"]
[connection signal="pressed" from="joinButton" to="." method="_on_join_button_pressed"] [connection signal="pressed" from="joinButton" to="." method="_on_join_button_pressed"]

View file

@ -55,6 +55,8 @@ var playerDisable = false # Can be used to disable the player
var playerDeathHealth = 100 # Can be changed by death.gd var playerDeathHealth = 100 # Can be changed by death.gd
var kickAllPlayers = false # Can be set to true to kick all players in-game var kickAllPlayers = false # Can be set to true to kick all players in-game
var respawnLocationChosen = false # When set to false, the game will be allowed to select a spawnpoint for the player var respawnLocationChosen = false # When set to false, the game will be allowed to select a spawnpoint for the player
var lastEnteredIP = "" # For keeping track of the last IP Address that was used
var lastEnteredPort = "28000" # For keeping track of the last port that was used
func _process(delta): func _process(delta):
spawn_locations() spawn_locations()

View file

@ -5,6 +5,8 @@ var SCENE = "res://scenes/toyland.tscn"
func _ready(): func _ready():
$playerNameBox.text = Global.playerName $playerNameBox.text = Global.playerName
$ipBox.text = Global.lastEnteredIP
$portBox.text = Global.lastEnteredPort
func _process(delta): func _process(delta):
pass pass
@ -64,3 +66,13 @@ func _on_join_button_pressed():
func _on_player_name_box_text_changed(new_text): func _on_player_name_box_text_changed(new_text):
Global.playerName = new_text Global.playerName = new_text
Global.save_data() Global.save_data()
func _on_ip_box_text_changed(new_text):
Global.lastEnteredIP = new_text
Global.save_data()
func _on_port_box_text_changed(new_text):
Global.lastEnteredPort = new_text
Global.save_data()

View file

@ -6,7 +6,9 @@ var settings_template = { # Default values if we don't already have a settings f
'mousesense': 0.01, 'mousesense': 0.01,
'playername' : "player", 'playername' : "player",
'volume' : 0.5, 'volume' : 0.5,
'tutorialCompleted' : false 'tutorialCompleted' : false,
'lastEnteredIP' : "",
'lastEnteredPort' : "28000"
} }
var settings_data = {} # This gets filled as soon as load_data() is called. var settings_data = {} # This gets filled as soon as load_data() is called.
@ -36,6 +38,8 @@ func save_data():
settings_data['playername'] = Global.playerName settings_data['playername'] = Global.playerName
settings_data['volume'] = Global.volumeModifer settings_data['volume'] = Global.volumeModifer
settings_data['tutorialCompleted'] = Global.tutorialCompleted settings_data['tutorialCompleted'] = Global.tutorialCompleted
settings_data['lastEnteredIP'] = Global.lastEnteredIP
settings_data['lastEnteredPort'] = Global.lastEnteredPort
file.store_line(JSON.stringify(settings_data)) file.store_line(JSON.stringify(settings_data))
func load_data(): func load_data():
@ -46,7 +50,11 @@ func load_data():
var playername = settings_data['playername'] var playername = settings_data['playername']
var volume = settings_data['volume'] var volume = settings_data['volume']
var tutorialCompleted = settings_data['tutorialCompleted'] var tutorialCompleted = settings_data['tutorialCompleted']
var lastEnteredIP = settings_data['lastEnteredIP']
var lastEnteredPort = settings_data['lastEnteredPort']
Global.mouseSensitivity = mousesense Global.mouseSensitivity = mousesense
Global.playerName = playername Global.playerName = playername
Global.volumeModifer = volume Global.volumeModifer = volume
Global.tutorialCompleted = tutorialCompleted Global.tutorialCompleted = tutorialCompleted
Global.lastEnteredIP = lastEnteredIP
Global.lastEnteredPort = lastEnteredPort