Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Settings #153

Merged
merged 4 commits into from
Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Shared/Actions/ActionManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func set_active(action: Action, character: CharacterBase, tree_position: Spatial
if action.sound and plays_sounds:
var audio_player = AudioStreamPlayer3D.new()
audio_player.stream = action.sound
audio_player.bus = "Effects"
get_tree().get_root().add_child(audio_player)
audio_player.global_transform = tree_position.global_transform
audio_player.unit_size = 20
Expand Down
4 changes: 4 additions & 0 deletions recursio-client/Characters/CharacterAudioPlayer.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ script = ExtResource( 1 )
stream = ExtResource( 2 )
unit_size = 0.1
autoplay = true
bus = "Effects"

[node name="CaptureAudio" type="AudioStreamPlayer3D" parent="."]
bus = "Effects"

[node name="SpawnAudio" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource( 4 )
unit_size = 10.0
bus = "Effects"

[node name="DieAudio" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource( 3 )
unit_size = 10.0
bus = "Effects"
4 changes: 3 additions & 1 deletion recursio-client/Characters/Player.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=26 format=2]
[gd_scene load_steps=27 format=2]

[ext_resource path="res://Shared/Characters/PlayerBase.tscn" type="PackedScene" id=1]
[ext_resource path="res://Characters/Player.gd" type="Script" id=2]
Expand All @@ -19,6 +19,7 @@
[ext_resource path="res://Characters/Visuals/Selector.gd" type="Script" id=17]
[ext_resource path="res://Characters/Visuals/Selector.obj" type="ArrayMesh" id=18]
[ext_resource path="res://Characters/CharacterAudioPlayer.tscn" type="PackedScene" id=19]
[ext_resource path="res://Characters/SettingAsciiRenderer.gd" type="Script" id=20]

[sub_resource type="SpatialMaterial" id=1]
albedo_color = Color( 1, 0, 0.866667, 1 )
Expand Down Expand Up @@ -148,6 +149,7 @@ __meta__ = {
}

[node name="AsciiRenderer" parent="KinematicBody/AsciiViewportContainer/Viewport/LerpedFollow/Camera" index="0" instance=ExtResource( 14 )]
script = ExtResource( 20 )

[node name="RemoteTransform" type="RemoteTransform" parent="KinematicBody/AsciiViewportContainer/Viewport/LerpedFollow/Camera" index="1"]
remote_path = NodePath("../../../../../NormalViewportContainer/Viewport/Camera")
Expand Down
6 changes: 6 additions & 0 deletions recursio-client/Characters/SettingAsciiRenderer.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends MeshInstance


func _ready():
var x_size = UserSettings.get_setting("video", "ascii_size")
get_surface_material(0).set_shader_param("character_size", Vector2(x_size, x_size * 2))
29 changes: 29 additions & 0 deletions recursio-client/Global/UserSettings.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
extends Node

signal setting_changed(setting_header, setting_name)

export var always_apply_defaults_at_startup := true

var settings_config = ConfigFile.new()

const SETTINGS_PATH = "user://settings.ini"


func _ready():
# Load previous settings
var err = settings_config.load(SETTINGS_PATH)

# If the file didn't load (first ever game start), save the defaults there initially
if err != OK or always_apply_defaults_at_startup:
settings_config.load("res://default-settings.ini") # this should never fail
settings_config.save(SETTINGS_PATH)


func get_setting(setting_header, setting_name, default = null):
return settings_config.get_value(setting_header, setting_name, default)


func set_setting(setting_header, setting_name, value):
settings_config.set_value(setting_header, setting_name, value)
settings_config.save(SETTINGS_PATH)
emit_signal("setting_changed", setting_header, setting_name, value)
1 change: 1 addition & 0 deletions recursio-client/Level/CapturePoint.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ fill_mode = 5
stream = ExtResource( 3 )
unit_size = 0.1
autoplay = true
bus = "Effects"
1 change: 1 addition & 0 deletions recursio-client/Rendering/OverviewLight.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func _physics_process(delta):
if omni_range > 10.0 and not _audio_played_this_pulse:
var audio_player = AudioStreamPlayer.new()
audio_player.stream = preload("res://Resources/Audio/Effects/Pulse.ogg")
audio_player.bus = "Effects"
add_child(audio_player)
audio_player.connect("finished", audio_player, "queue_free")
audio_player.play()
Expand Down
15 changes: 15 additions & 0 deletions recursio-client/UI/Menus/AsciiBackground.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extends ColorRect


func _ready():
update_ascii_size(UserSettings.get_setting("video", "ascii_size"))
UserSettings.connect("setting_changed", self, "_on_setting_changed")


func _on_setting_changed(setting_header, setting_name, value):
if setting_header == "video" and setting_name == "ascii_size":
update_ascii_size(value)


func update_ascii_size(new_x_size):
material.set_shader_param("character_size", Vector2(new_x_size, new_x_size * 2))
10 changes: 10 additions & 0 deletions recursio-client/UI/Menus/AsciiSlider.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extends HSlider


func _ready() -> void:
connect("value_changed", self, "_on_value_changed")
value = UserSettings.get_setting("video", "ascii_size")


func _on_value_changed(value: float) -> void:
UserSettings.set_setting("video", "ascii_size", value)
11 changes: 11 additions & 0 deletions recursio-client/UI/Menus/FullScreenCheckButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends CheckButton


func _ready():
connect("toggled", self, "_on_toggled")
pressed = UserSettings.get_setting("video", "fullscreen")


func _on_toggled(is_enabled):
OS.window_fullscreen = is_enabled
UserSettings.set_setting("video", "fullscreen", is_enabled)
9 changes: 9 additions & 0 deletions recursio-client/UI/Menus/SettingsContainer.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends PanelContainer


func _ready():
$SettingsList/BackButton.connect("pressed", self, "_on_back_pressed")


func _on_back_pressed():
hide()
6 changes: 6 additions & 0 deletions recursio-client/UI/Menus/StartMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ onready var _btn_play_tutorial = get_node("CenterContainer/MainMenu/PlayTutorial
onready var _btn_play_online = get_node("CenterContainer/MainMenu/PlayOnline")
onready var _btn_play_local = get_node("CenterContainer/MainMenu/HBoxContainer/Btn_PlayLocal")
onready var _lineEdit_local_ip = get_node("CenterContainer/MainMenu/HBoxContainer/LocalIPAddress")
onready var _btn_settings = get_node("CenterContainer/MainMenu/SettingsButton")
onready var _btn_exit = get_node("CenterContainer/MainMenu/Btn_Exit")

onready var _game_room_search: GameRoomSearch = get_node("CenterContainer/GameRoomSearch")
Expand All @@ -34,6 +35,7 @@ func _ready():
var _error = _btn_play_tutorial.connect("pressed", self, "_on_play_tutorial")
_error = _btn_play_online.connect("pressed", self, "_on_play_online")
_error = _btn_play_local.connect("pressed", self, "_on_play_local")
_error = _btn_settings.connect("pressed", self, "_on_open_settings")
_error = _btn_exit.connect("pressed", self, "_on_exit")

_error = _game_room_search.connect("btn_create_game_room_pressed", self, "_on_search_create_game_room_pressed")
Expand Down Expand Up @@ -128,6 +130,10 @@ func _on_play_local() -> void:
Server.connect_to_server(_lineEdit_local_ip.text)


func _on_open_settings() -> void:
$CenterContainer/SettingsContainer.show()


func _on_exit() -> void:
get_tree().quit()

Expand Down
Loading