From ff0c2f362c8cd9bef6d160e09fc6ef0a7739c59e Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 25 Dec 2019 01:36:34 +0100 Subject: [PATCH] Implemented different row scenes for the options menu, and exposed/implemented a few video-related options. --- game/autoload/SettingsManager.gd | 41 +++++- game/data/models/armature_model_orig_v2.tscn | 134 +++++++++--------- game/project.godot | 3 + .../settings/DirectionalLightSettings.gd | 10 +- .../{OptionRow.gd => OptionButtonRow.gd} | 10 ++ game/ui/options/OptionButtonRow.tscn | 25 ++++ game/ui/options/OptionCheckboxRow.tscn | 27 ++++ game/ui/options/OptionEnumRow.gd | 47 ++++++ game/ui/options/OptionEnumRow.tscn | 27 ++++ game/ui/options/OptionToggleRow.gd | 44 ++++++ game/ui/options/Options.tscn | 112 +++++++++------ game/ui/options/OptionsSliderRow.gd | 44 ++++++ game/ui/options/OptionsSliderRow.tscn | 29 ++++ game/ui/options/OptionsSpinboxRow.gd | 63 ++++++++ game/ui/options/OptionsSpinboxRow.tscn | 29 ++++ game/ui/options/OptionsViewportLabel.gd | 37 +++++ game/ui/options/OptionsViewportLabel.tscn | 27 ++++ 17 files changed, 587 insertions(+), 122 deletions(-) rename game/ui/options/{OptionRow.gd => OptionButtonRow.gd} (82%) create mode 100644 game/ui/options/OptionButtonRow.tscn create mode 100644 game/ui/options/OptionCheckboxRow.tscn create mode 100644 game/ui/options/OptionEnumRow.gd create mode 100644 game/ui/options/OptionEnumRow.tscn create mode 100644 game/ui/options/OptionToggleRow.gd create mode 100644 game/ui/options/OptionsSliderRow.gd create mode 100644 game/ui/options/OptionsSliderRow.tscn create mode 100644 game/ui/options/OptionsSpinboxRow.gd create mode 100644 game/ui/options/OptionsSpinboxRow.tscn create mode 100644 game/ui/options/OptionsViewportLabel.gd create mode 100644 game/ui/options/OptionsViewportLabel.tscn diff --git a/game/autoload/SettingsManager.gd b/game/autoload/SettingsManager.gd index 4ecb0d03..0ddd6736 100644 --- a/game/autoload/SettingsManager.gd +++ b/game/autoload/SettingsManager.gd @@ -27,7 +27,14 @@ const SAVE_PATH : String = "user://settings.cfg" var _config_file : ConfigFile = ConfigFile.new() var _settings : Dictionary = { "rendering" : { - "thread_model" : ProjectSettings.get("rendering/threads/thread_model") + "viewport_scale" : ProjectSettings.get("display/window/size/viewport_scale"), + "thread_model" : ProjectSettings.get("rendering/threads/thread_model"), + "borderless" : ProjectSettings.get("display/window/size/borderless"), + "fullscreen" : ProjectSettings.get("display/window/size/fullscreen"), + "always_on_top" : ProjectSettings.get("display/window/size/always_on_top"), + "shadows_enabled" : ProjectSettings.get("rendering/quality/shadows/enabled"), + "use_vsync" : ProjectSettings.get("display/window/vsync/use_vsync"), + "vsync_via_compositor" : ProjectSettings.get("display/window/vsync/vsync_via_compositor"), }, "debug" : { "debug_info" : false @@ -77,3 +84,35 @@ func load_settings() -> void: func set_rendering_thread_model(value : int) -> void: ProjectSettings.set("rendering/threads/thread_model", value) + +func set_rendering_borderless(value : bool) -> void: + ProjectSettings.set("display/window/size/borderless", value) + OS.window_borderless = value + +func set_rendering_fullscreen(value : bool) -> void: + ProjectSettings.set("display/window/size/fullscreen", value) + OS.window_fullscreen = value + +func set_rendering_always_on_top(value : bool) -> void: + ProjectSettings.set("display/window/size/always_on_top", value) + OS.set_window_always_on_top(value) + +func set_rendering_viewport_scale(value : int) -> void: + ProjectSettings.set("rendering/window/size/viewport_scale", value) + var v: Vector2 = OS.get_window_size() + v *= value * 0.01 + + get_tree().get_root().size = v + +func set_rendering_shadows_enabled(value : bool) -> void: + ProjectSettings.set("rendering/quality/shadows/enabled", value) + +func set_rendering_use_vsync(value : bool) -> void: + ProjectSettings.set("display/window/vsync/use_vsync", value) + + OS.vsync_enabled = value + +func set_rendering_vsync_via_compositor(value : bool) -> void: + ProjectSettings.set("display/window/vsync/vsync_via_compositor", value) + + OS.vsync_via_compositor = value diff --git a/game/data/models/armature_model_orig_v2.tscn b/game/data/models/armature_model_orig_v2.tscn index 739f4955..ced127fa 100644 --- a/game/data/models/armature_model_orig_v2.tscn +++ b/game/data/models/armature_model_orig_v2.tscn @@ -6,7 +6,7 @@ [ext_resource path="res://player/CharacterSkeletonAttachPoint.gd" type="Script" id=4] [ext_resource path="res://data/item_visuals/test_base_v3.tres" type="ItemVisual" id=6] -[sub_resource type="Skin" id=41] +[sub_resource type="Skin" id=1] bind_count = 31 bind/0/bone = 0 bind/0/pose = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0010334, -1.32424, 0.004403 ) @@ -71,111 +71,111 @@ bind/29/pose = Transform( 0.997795, 0.00782497, 0.066146, 0.0235858, -0.970258, bind/30/bone = 30 bind/30/pose = Transform( 1, 0, 0, 0, 1, -2.84217e-14, 0, -4.98108e-09, 1, 0, -0.832461, 2.76188e-08 ) -[sub_resource type="AnimationNodeAnimation" id=12] +[sub_resource type="AnimationNodeAnimation" id=2] animation = "cast-end" -[sub_resource type="AnimationNodeAnimation" id=13] +[sub_resource type="AnimationNodeAnimation" id=3] animation = "cast-end" -[sub_resource type="AnimationNodeAnimation" id=14] +[sub_resource type="AnimationNodeAnimation" id=4] animation = "casting-loop" -[sub_resource type="AnimationNodeAnimation" id=15] +[sub_resource type="AnimationNodeAnimation" id=5] animation = "dead" -[sub_resource type="AnimationNodeAnimation" id=16] +[sub_resource type="AnimationNodeAnimation" id=6] animation = "idle-loop" -[sub_resource type="AnimationNodeAnimation" id=17] +[sub_resource type="AnimationNodeAnimation" id=7] animation = "run-left-loop" -[sub_resource type="AnimationNodeAnimation" id=18] +[sub_resource type="AnimationNodeAnimation" id=8] animation = "run-loop" -[sub_resource type="AnimationNodeAnimation" id=19] +[sub_resource type="AnimationNodeAnimation" id=9] animation = "run-loop" -[sub_resource type="AnimationNodeAnimation" id=20] +[sub_resource type="AnimationNodeAnimation" id=10] animation = "run-right-loop" -[sub_resource type="AnimationNodeBlendSpace2D" id=21] -blend_point_0/node = SubResource( 17 ) +[sub_resource type="AnimationNodeBlendSpace2D" id=11] +blend_point_0/node = SubResource( 7 ) blend_point_0/pos = Vector2( -1, 0 ) -blend_point_1/node = SubResource( 18 ) +blend_point_1/node = SubResource( 8 ) blend_point_1/pos = Vector2( 0, 1 ) -blend_point_2/node = SubResource( 19 ) +blend_point_2/node = SubResource( 9 ) blend_point_2/pos = Vector2( 0, -1 ) -blend_point_3/node = SubResource( 20 ) +blend_point_3/node = SubResource( 10 ) blend_point_3/pos = Vector2( 1, 0 ) blend_mode = 1 -[sub_resource type="AnimationNodeStateMachineTransition" id=22] +[sub_resource type="AnimationNodeStateMachineTransition" id=12] xfade_time = 0.09 -[sub_resource type="AnimationNodeStateMachineTransition" id=23] +[sub_resource type="AnimationNodeStateMachineTransition" id=13] xfade_time = 0.09 -[sub_resource type="AnimationNodeStateMachineTransition" id=24] +[sub_resource type="AnimationNodeStateMachineTransition" id=14] xfade_time = 0.05 -[sub_resource type="AnimationNodeStateMachineTransition" id=25] +[sub_resource type="AnimationNodeStateMachineTransition" id=15] auto_advance = true xfade_time = 0.15 -[sub_resource type="AnimationNodeStateMachineTransition" id=26] +[sub_resource type="AnimationNodeStateMachineTransition" id=16] auto_advance = true xfade_time = 0.14 +[sub_resource type="AnimationNodeStateMachineTransition" id=17] +xfade_time = 0.09 + +[sub_resource type="AnimationNodeStateMachineTransition" id=18] +xfade_time = 0.1 + +[sub_resource type="AnimationNodeStateMachineTransition" id=19] +xfade_time = 0.1 + +[sub_resource type="AnimationNodeStateMachineTransition" id=20] +xfade_time = 0.09 + +[sub_resource type="AnimationNodeStateMachineTransition" id=21] +xfade_time = 0.09 + +[sub_resource type="AnimationNodeStateMachineTransition" id=22] + +[sub_resource type="AnimationNodeStateMachineTransition" id=23] +xfade_time = 0.12 + +[sub_resource type="AnimationNodeStateMachineTransition" id=24] +xfade_time = 0.12 + +[sub_resource type="AnimationNodeStateMachineTransition" id=25] +xfade_time = 0.12 + +[sub_resource type="AnimationNodeStateMachineTransition" id=26] +xfade_time = 0.12 + [sub_resource type="AnimationNodeStateMachineTransition" id=27] -xfade_time = 0.09 - -[sub_resource type="AnimationNodeStateMachineTransition" id=28] -xfade_time = 0.1 - -[sub_resource type="AnimationNodeStateMachineTransition" id=29] -xfade_time = 0.1 - -[sub_resource type="AnimationNodeStateMachineTransition" id=30] -xfade_time = 0.09 - -[sub_resource type="AnimationNodeStateMachineTransition" id=31] -xfade_time = 0.09 - -[sub_resource type="AnimationNodeStateMachineTransition" id=32] - -[sub_resource type="AnimationNodeStateMachineTransition" id=33] xfade_time = 0.12 -[sub_resource type="AnimationNodeStateMachineTransition" id=34] -xfade_time = 0.12 - -[sub_resource type="AnimationNodeStateMachineTransition" id=35] -xfade_time = 0.12 - -[sub_resource type="AnimationNodeStateMachineTransition" id=36] -xfade_time = 0.12 - -[sub_resource type="AnimationNodeStateMachineTransition" id=37] -xfade_time = 0.12 - -[sub_resource type="AnimationNodeStateMachine" id=38] -states/cast-end/node = SubResource( 13 ) +[sub_resource type="AnimationNodeStateMachine" id=28] +states/cast-end/node = SubResource( 3 ) states/cast-end/position = Vector2( 117.871, -197.811 ) -"states/cast-end 2/node" = SubResource( 12 ) +"states/cast-end 2/node" = SubResource( 2 ) "states/cast-end 2/position" = Vector2( 317.871, -197.811 ) -states/casting-loop/node = SubResource( 14 ) +states/casting-loop/node = SubResource( 4 ) states/casting-loop/position = Vector2( -76.129, -197.811 ) -states/dead/node = SubResource( 15 ) +states/dead/node = SubResource( 5 ) states/dead/position = Vector2( -129.129, 73.189 ) -states/idle-loop/node = SubResource( 16 ) +states/idle-loop/node = SubResource( 6 ) states/idle-loop/position = Vector2( -255.566, -317.817 ) -states/run-loop/node = SubResource( 21 ) +states/run-loop/node = SubResource( 11 ) states/run-loop/position = Vector2( 31.871, -340.817 ) -transitions = [ "idle-loop", "casting-loop", SubResource( 22 ), "casting-loop", "idle-loop", SubResource( 23 ), "casting-loop", "cast-end", SubResource( 24 ), "cast-end", "cast-end 2", SubResource( 25 ), "cast-end 2", "idle-loop", SubResource( 26 ), "idle-loop", "cast-end", SubResource( 27 ), "idle-loop", "run-loop", SubResource( 28 ), "run-loop", "idle-loop", SubResource( 29 ), "casting-loop", "run-loop", SubResource( 30 ), "run-loop", "casting-loop", SubResource( 31 ), "run-loop", "cast-end", SubResource( 32 ), "idle-loop", "dead", SubResource( 33 ), "casting-loop", "dead", SubResource( 34 ), "cast-end 2", "dead", SubResource( 35 ), "run-loop", "dead", SubResource( 36 ), "dead", "idle-loop", SubResource( 37 ) ] +transitions = [ "idle-loop", "casting-loop", SubResource( 12 ), "casting-loop", "idle-loop", SubResource( 13 ), "casting-loop", "cast-end", SubResource( 14 ), "cast-end", "cast-end 2", SubResource( 15 ), "cast-end 2", "idle-loop", SubResource( 16 ), "idle-loop", "cast-end", SubResource( 17 ), "idle-loop", "run-loop", SubResource( 18 ), "run-loop", "idle-loop", SubResource( 19 ), "casting-loop", "run-loop", SubResource( 20 ), "run-loop", "casting-loop", SubResource( 21 ), "run-loop", "cast-end", SubResource( 22 ), "idle-loop", "dead", SubResource( 23 ), "casting-loop", "dead", SubResource( 24 ), "cast-end 2", "dead", SubResource( 25 ), "run-loop", "dead", SubResource( 26 ), "dead", "idle-loop", SubResource( 27 ) ] start_node = "idle-loop" graph_offset = Vector2( -567.129, -449.811 ) -[sub_resource type="AnimationNodeStateMachinePlayback" id=39] +[sub_resource type="AnimationNodeStateMachinePlayback" id=29] [node name="character" type="CharacterSkeleton3D"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00126277, 0, -0.000325084 ) @@ -196,17 +196,11 @@ viss = [ ExtResource( 6 ) ] [node name="armature" parent="." instance=ExtResource( 1 )] -[node name="Skeleton" parent="armature/Armature" index="0"] -bones/0/bound_children = [ NodePath("RootAttachment") ] -bones/5/bound_children = [ NodePath("NeckAttachment") ] -bones/10/bound_children = [ NodePath("LeftHandAttachment") ] -bones/18/bound_children = [ NodePath("RightHandAttachment") ] - [node name="MeshInstance" type="MeshInstance" parent="armature/Armature/Skeleton" index="0"] -skin = SubResource( 41 ) +skin = SubResource( 1 ) [node name="LeftHandAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="1"] -transform = Transform( 0.103562, -0.988419, -0.110691, 0.056439, -0.105232, 0.992798, -0.993015, -0.109066, 0.04489, 0.268651, 0.761138, -0.0112995 ) +transform = Transform( 0.103542, -0.988288, -0.111817, 0.0564193, -0.106355, 0.99265, -0.993017, -0.109094, 0.04475, 0.270236, 0.760211, -0.0102059 ) bone_name = "left_hand" [node name="LeftHandAP" type="Spatial" parent="armature/Armature/Skeleton/LeftHandAttachment"] @@ -214,7 +208,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.04, -0.09 ) script = ExtResource( 4 ) [node name="RightHandAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="2"] -transform = Transform( -0.0425602, -0.998135, 0.0431318, -0.127954, 0.0482458, 0.990539, -0.990882, 0.036651, -0.129773, -0.274643, 0.765119, -0.00467242 ) +transform = Transform( -0.0424658, -0.998156, 0.0426038, -0.127127, 0.047675, 0.990638, -0.990996, 0.0366682, -0.128925, -0.275232, 0.765703, -0.0060403 ) bone_name = "right_hand" [node name="RightHandAP" type="Spatial" parent="armature/Armature/Skeleton/RightHandAttachment"] @@ -230,7 +224,7 @@ transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0 script = ExtResource( 4 ) [node name="NeckAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="4"] -transform = Transform( 0.999951, -0.00131182, 0.00983482, 0.00989661, 0.073096, -0.997197, 0.000589293, 0.997323, 0.0731102, 0.0012516, 1.31281, 9.62426e-05 ) +transform = Transform( 0.999941, -0.00154955, 0.0108087, 0.0108837, 0.073068, -0.997152, 0.000755443, 0.997325, 0.0730877, 0.00121255, 1.31159, 0.000111008 ) bone_name = "neck" [node name="TorsoAP" type="Spatial" parent="armature/Armature/Skeleton/NeckAttachment"] @@ -238,10 +232,10 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.04, -0.09 ) script = ExtResource( 4 ) [node name="AnimationTree" type="AnimationTree" parent="."] -tree_root = SubResource( 38 ) +tree_root = SubResource( 28 ) anim_player = NodePath("../armature/AnimationPlayer") active = true -parameters/playback = SubResource( 39 ) +parameters/playback = SubResource( 29 ) parameters/run-loop/blend_position = Vector2( 0, -0.0172414 ) [editable path="armature"] diff --git a/game/project.godot b/game/project.godot index d2fc1cb7..a49395ee 100644 --- a/game/project.godot +++ b/game/project.godot @@ -220,6 +220,7 @@ Node="input/actionbar_5_11" [application] config/name="Broken Seals" +config/description="An open source third person RPG " run/main_scene="res://scenes/Main.tscn" config/icon="res://icon.png" config/version="0.2" @@ -250,6 +251,7 @@ window/handheld/orientation="sensor_landscape" window/stretch/mode="2d" window/stretch/aspect="expand" mouse_cursor/sensitivity=0.9 +window/size/viewport_scale=100 [editor_plugins] @@ -360,3 +362,4 @@ quality/driver/fallback_to_gles2=true vram_compression/import_etc=true quality/directional_shadow/size.mobile=1024 quality/shading/force_vertex_shading=true +quality/shadows/enabled=false diff --git a/game/scripts/settings/DirectionalLightSettings.gd b/game/scripts/settings/DirectionalLightSettings.gd index ad460f82..70b3945d 100644 --- a/game/scripts/settings/DirectionalLightSettings.gd +++ b/game/scripts/settings/DirectionalLightSettings.gd @@ -20,14 +20,6 @@ extends DirectionalLight # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" - -# Called when the node enters the scene tree for the first time. func _ready(): - pass # Replace with function body. + shadow_enabled = ProjectSettings.get("rendering/quality/shadows/enabled") -# Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass diff --git a/game/ui/options/OptionRow.gd b/game/ui/options/OptionButtonRow.gd similarity index 82% rename from game/ui/options/OptionRow.gd rename to game/ui/options/OptionButtonRow.gd index 998ad606..d2a4b449 100644 --- a/game/ui/options/OptionRow.gd +++ b/game/ui/options/OptionButtonRow.gd @@ -23,3 +23,13 @@ extends HBoxContainer export(String) var property_category : String export(String) var property_name : String +export(String) var property_label : String + +func _ready(): + var ob : Button = $Button as Button + $Label.text = property_label + +# ob.connect("pressed", self, "pressed") +# +#func pressed() -> void: +# Settings.set_value(property_category, property_name, val) diff --git a/game/ui/options/OptionButtonRow.tscn b/game/ui/options/OptionButtonRow.tscn new file mode 100644 index 00000000..c86e5323 --- /dev/null +++ b/game/ui/options/OptionButtonRow.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://ui/options/OptionButtonRow.gd" type="Script" id=1] + +[node name="OptionButtonRow" type="HBoxContainer"] +margin_right = 527.0 +margin_bottom = 15.0 +size_flags_horizontal = 3 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="."] +margin_top = 3.0 +margin_right = 261.0 +margin_bottom = 17.0 +size_flags_horizontal = 3 + +[node name="Button" type="Button" parent="."] +margin_left = 265.0 +margin_right = 527.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 diff --git a/game/ui/options/OptionCheckboxRow.tscn b/game/ui/options/OptionCheckboxRow.tscn new file mode 100644 index 00000000..92ab19a3 --- /dev/null +++ b/game/ui/options/OptionCheckboxRow.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://ui/options/OptionToggleRow.gd" type="Script" id=1] + +[node name="OptionToggleRow" type="HBoxContainer"] +margin_top = 34.0 +margin_right = 527.0 +margin_bottom = 60.0 +size_flags_horizontal = 3 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="."] +margin_top = 6.0 +margin_right = 261.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 + +[node name="CheckBox" type="CheckBox" parent="."] +margin_left = 265.0 +margin_right = 527.0 +margin_bottom = 26.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +text = "On" diff --git a/game/ui/options/OptionEnumRow.gd b/game/ui/options/OptionEnumRow.gd new file mode 100644 index 00000000..1d9a44a1 --- /dev/null +++ b/game/ui/options/OptionEnumRow.gd @@ -0,0 +1,47 @@ +tool +extends HBoxContainer + +# Copyright (c) 2019 Péter Magyar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +export(String) var property_category : String +export(String) var property_name : String + +export(String) var property_label : String + +export(Array, String) var options : Array + +func _ready(): + $Label.text = property_label + + if Engine.editor_hint: + return + + var ob : OptionButton = $OptionButton as OptionButton + + for i in range(options.size()): + ob.add_item(options[i], i) + + ob.selected = Settings.get_value(property_category, property_name) + + ob.connect("item_selected", self, "item_selected") + +func item_selected(id : int) -> void: + Settings.set_value(property_category, property_name, id) diff --git a/game/ui/options/OptionEnumRow.tscn b/game/ui/options/OptionEnumRow.tscn new file mode 100644 index 00000000..6f900d97 --- /dev/null +++ b/game/ui/options/OptionEnumRow.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://ui/options/OptionEnumRow.gd" type="Script" id=1] + +[node name="OptionEnumRow" type="HBoxContainer"] +margin_top = 34.0 +margin_right = 527.0 +margin_bottom = 60.0 +size_flags_horizontal = 3 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="."] +margin_top = 6.0 +margin_right = 261.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 + +[node name="OptionButton" type="OptionButton" parent="."] +margin_left = 265.0 +margin_right = 527.0 +margin_bottom = 26.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +align = 1 diff --git a/game/ui/options/OptionToggleRow.gd b/game/ui/options/OptionToggleRow.gd new file mode 100644 index 00000000..3314c2d5 --- /dev/null +++ b/game/ui/options/OptionToggleRow.gd @@ -0,0 +1,44 @@ +tool +extends HBoxContainer + +# Copyright (c) 2019 Péter Magyar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +export(String) var property_category : String +export(String) var property_name : String + +export(String) var property_label : String + +var _cb : CheckBox = null + +func _ready(): + $Label.text = property_label + + if Engine.editor_hint: + return + + _cb = $CheckBox as CheckBox + + _cb.pressed = Settings.get_value(property_category, property_name) + + _cb.connect("pressed", self, "pressed") + +func pressed() -> void: + Settings.set_value(property_category, property_name, _cb.pressed) diff --git a/game/ui/options/Options.tscn b/game/ui/options/Options.tscn index e3f910fc..6f54cf20 100644 --- a/game/ui/options/Options.tscn +++ b/game/ui/options/Options.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=1] [ext_resource path="res://ui/player_ui/RemoveProfile.gd" type="Script" id=2] -[ext_resource path="res://ui/options/OptionRow.gd" type="Script" id=3] -[ext_resource path="res://ui/options/Threads.gd" type="Script" id=4] +[ext_resource path="res://ui/options/OptionsViewportLabel.tscn" type="PackedScene" id=3] +[ext_resource path="res://ui/options/OptionCheckboxRow.tscn" type="PackedScene" id=4] [ext_resource path="res://ui/options/OptionCheckBox.gd" type="Script" id=5] +[ext_resource path="res://ui/options/OptionEnumRow.tscn" type="PackedScene" id=6] +[ext_resource path="res://ui/options/OptionsSpinboxRow.tscn" type="PackedScene" id=8] [node name="Options" type="Control"] anchor_right = 1.0 @@ -50,49 +52,75 @@ margin_right = -4.0 margin_bottom = -4.0 size_flags_horizontal = 3 -[node name="Threads2" type="HBoxContainer" parent="PanelContainer/VBoxContainer/TabContainer/Video"] -visible = false -margin_right = 519.0 -margin_bottom = 26.0 -size_flags_horizontal = 3 -script = ExtResource( 3 ) -property_category = "rendering/threads" +[node name="ViewportWidth" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 3 )] +margin_bottom = 15.0 +property_label = "Viewport Width" + +[node name="ViewportHeight" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 3 )] +margin_top = 23.0 +margin_bottom = 38.0 +property_label = "Viewport Height" +width = false + +[node name="ViewportScale" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 8 )] +margin_top = 46.0 +margin_bottom = 70.0 +property_category = "rendering" +property_name = "viewport_scale" +property_label = "Viewport Scale" +min_value = 20 +step = 5 +suffix = "%" + +[node name="Borderless" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 4 )] +margin_top = 78.0 +margin_bottom = 104.0 +property_category = "rendering" +property_name = "borderless" +property_label = "Borderless Window" + +[node name="FullScreen" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 4 )] +margin_top = 112.0 +margin_bottom = 138.0 +property_category = "rendering" +property_name = "fullscreen" +property_label = "Fullscreen" + +[node name="AlwaysOnTop" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 4 )] +margin_top = 146.0 +margin_bottom = 172.0 +property_category = "rendering" +property_name = "always_on_top" +property_label = "Always On Top" + +[node name="ThreadModel" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 6 )] +margin_top = 180.0 +margin_bottom = 206.0 +property_category = "rendering" property_name = "thread_model" +property_label = "Thread Model" +options = [ "Single-Unsafe", "Single-Safe", "Multi Threaded" ] -[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/TabContainer/Video/Threads2"] -margin_top = 5.0 -margin_right = 255.0 -margin_bottom = 20.0 -size_flags_horizontal = 3 -text = "asd" +[node name="Shadows" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 4 )] +margin_top = 214.0 +margin_bottom = 240.0 +property_category = "rendering" +property_name = "shadows_enabled" +property_label = "Shadows Enabled" -[node name="Button" type="Button" parent="PanelContainer/VBoxContainer/TabContainer/Video/Threads2"] -margin_left = 263.0 -margin_right = 519.0 -margin_bottom = 26.269 -size_flags_horizontal = 3 -text = "tb" +[node name="VSync" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 4 )] +margin_top = 248.0 +margin_bottom = 274.0 +property_category = "rendering" +property_name = "use_vsync" +property_label = "VSync" -[node name="Threads" type="HBoxContainer" parent="PanelContainer/VBoxContainer/TabContainer/Video"] -margin_right = 527.0 -margin_bottom = 26.0 -size_flags_horizontal = 3 -script = ExtResource( 4 ) - -[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/TabContainer/Video/Threads"] -margin_top = 5.0 -margin_right = 259.0 -margin_bottom = 20.0 -size_flags_horizontal = 3 -text = "Thread Model" - -[node name="OptionButton" type="OptionButton" parent="PanelContainer/VBoxContainer/TabContainer/Video/Threads"] -margin_left = 267.0 -margin_right = 527.0 -margin_bottom = 26.269 -size_flags_horizontal = 3 -align = 1 -expand_icon = true +[node name="VSyncViaCompositor" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 4 )] +margin_top = 282.0 +margin_bottom = 308.0 +property_category = "rendering" +property_name = "vsync_via_compositor" +property_label = "VSync Via Compositor" [node name="Debug" type="VBoxContainer" parent="PanelContainer/VBoxContainer/TabContainer"] visible = false diff --git a/game/ui/options/OptionsSliderRow.gd b/game/ui/options/OptionsSliderRow.gd new file mode 100644 index 00000000..3bead5cd --- /dev/null +++ b/game/ui/options/OptionsSliderRow.gd @@ -0,0 +1,44 @@ +tool +extends HBoxContainer + +# Copyright (c) 2019 Péter Magyar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +export(String) var property_category : String +export(String) var property_name : String + +export(String) var property_label : String + +var _slider : HSlider = null + +func _ready(): + $Label.text = property_label + + if Engine.editor_hint: + return + + _slider = $HSlider as Slider + + _slider.value = Settings.get_value(property_category, property_name) + + _slider.connect("value_changed", self, "value_changed") + +func value_changed(val: float) -> void: + Settings.set_value(property_category, property_name, val) diff --git a/game/ui/options/OptionsSliderRow.tscn b/game/ui/options/OptionsSliderRow.tscn new file mode 100644 index 00000000..70171785 --- /dev/null +++ b/game/ui/options/OptionsSliderRow.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://ui/options/OptionsSliderRow.gd" type="Script" id=1] + +[node name="OptionsSliderRow" type="HBoxContainer"] +margin_top = 46.0 +margin_right = 527.0 +margin_bottom = 72.0 +size_flags_horizontal = 3 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="."] +margin_top = 6.0 +margin_right = 261.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 + +[node name="HSlider" type="HSlider" parent="."] +margin_left = 265.0 +margin_right = 527.0 +margin_bottom = 26.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +min_value = 5.0 +step = 5.0 +value = 100.0 diff --git a/game/ui/options/OptionsSpinboxRow.gd b/game/ui/options/OptionsSpinboxRow.gd new file mode 100644 index 00000000..731a9f65 --- /dev/null +++ b/game/ui/options/OptionsSpinboxRow.gd @@ -0,0 +1,63 @@ +tool +extends HBoxContainer + +# Copyright (c) 2019 Péter Magyar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +export(String) var property_category : String +export(String) var property_name : String + +export(String) var property_label : String + +export(int) var min_value : int = 0 +export(int) var max_value : int = 100 +export(int) var step : int = 1 + +export(String) var prefix : String = "" +export(String) var suffix : String = "" + +var _sb : SpinBox = null + +func _ready(): + $Label.text = property_label + + _sb = $SpinBox as SpinBox + + _sb.min_value = min_value + _sb.max_value = max_value + _sb.step = step + + _sb.prefix = prefix + _sb.suffix = suffix + + if Engine.editor_hint: + return + + _sb = $SpinBox as SpinBox + + _sb.min_value = min_value + _sb.max_value = max_value + _sb.step = step + _sb.value = Settings.get_value(property_category, property_name) + + _sb.connect("value_changed", self, "value_changed") + +func value_changed(val: float) -> void: + Settings.set_value(property_category, property_name, val) diff --git a/game/ui/options/OptionsSpinboxRow.tscn b/game/ui/options/OptionsSpinboxRow.tscn new file mode 100644 index 00000000..6767464e --- /dev/null +++ b/game/ui/options/OptionsSpinboxRow.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://ui/options/OptionsSpinboxRow.gd" type="Script" id=1] + +[node name="OptionsSpinboxRow" type="HBoxContainer"] +margin_top = 70.0 +margin_right = 527.0 +margin_bottom = 86.0 +size_flags_horizontal = 3 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} +step = 0 + +[node name="Label" type="Label" parent="."] +margin_top = 5.0 +margin_right = 261.0 +margin_bottom = 19.0 +size_flags_horizontal = 3 + +[node name="SpinBox" type="SpinBox" parent="."] +margin_left = 265.0 +margin_right = 527.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +rounded = true +align = 1 diff --git a/game/ui/options/OptionsViewportLabel.gd b/game/ui/options/OptionsViewportLabel.gd new file mode 100644 index 00000000..e3517589 --- /dev/null +++ b/game/ui/options/OptionsViewportLabel.gd @@ -0,0 +1,37 @@ +extends HBoxContainer + +# Copyright (c) 2019 Péter Magyar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +export(String) var property_label : String +export(bool) var width : bool = true + +var _label : Label = null + +func _ready(): + $Label.text = property_label + _label = $Label2 as Label + + +func _process(delta: float) -> void: + if width: + _label.text = str(int(get_tree().root.size.x)) + else: + _label.text = str(int(get_tree().root.size.y)) diff --git a/game/ui/options/OptionsViewportLabel.tscn b/game/ui/options/OptionsViewportLabel.tscn new file mode 100644 index 00000000..f4cd861b --- /dev/null +++ b/game/ui/options/OptionsViewportLabel.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://ui/options/OptionsViewportLabel.gd" type="Script" id=1] + +[node name="OptionsViewportLabel" type="HBoxContainer"] +margin_right = 527.0 +margin_bottom = 26.0 +size_flags_horizontal = 3 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="."] +margin_top = 6.0 +margin_right = 261.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 + +[node name="Label2" type="Label" parent="."] +margin_left = 265.0 +margin_right = 527.0 +margin_bottom = 26.0 +size_flags_horizontal = 3 +size_flags_vertical = 7 +align = 1 +valign = 1