wip options menu

This commit is contained in:
erkkon 2023-07-22 10:08:44 +02:00
parent da0f686ea0
commit a15a1df2fd
6 changed files with 130 additions and 113 deletions

View file

@ -11,7 +11,7 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_lgjmg") script = ExtResource("1_lgjmg")
[node name="MarginContainer" type="MarginContainer" parent="."] [node name="ScrollContainer" type="ScrollContainer" parent="."]
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@ -19,72 +19,55 @@ anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"] [node name="MarginContainer" type="MarginContainer" parent="ScrollContainer"]
layout_mode = 2 layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"] [node name="HBoxContainer" type="HBoxContainer" parent="ScrollContainer/MarginContainer"]
layout_mode = 2 layout_mode = 2
[node name="Play" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
[node name="Play" type="Button" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "Play" text = "Play"
[node name="ResolutionLabel" type="Label" parent="MarginContainer/HBoxContainer/VBoxContainer"] [node name="ResolutionLabel" type="Label" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "Resolution" text = "Resolution"
[node name="QualitySlider" type="HSlider" parent="MarginContainer/HBoxContainer/VBoxContainer"] [node name="QualitySlider" type="HSlider" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
min_value = 0.25 min_value = 0.25
max_value = 2.0 max_value = 2.0
step = 0.05 step = 0.05
value = 1.0 value = 1.0
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/HBoxContainer/VBoxContainer"] [node name="HBoxContainer" type="HBoxContainer" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
[node name="Game" type="OptionButton" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer"] [node name="Game" type="OptionButton" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2 layout_mode = 2
[node name="Sensitivity" type="LineEdit" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer"] [node name="Sensitivity" type="LineEdit" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "0.215" text = "0.215"
placeholder_text = "0.215" placeholder_text = "0.215"
[node name="Options" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer"] [node name="Options" type="Button" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "Options" text = "Options"
[node name="Quit" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer"] [node name="Quit" type="Button" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "Quit" text = "Quit"
[node name="Panel" type="Panel" parent="."] [node name="VBoxContainer2" type="VBoxContainer" parent="ScrollContainer/MarginContainer/HBoxContainer"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 1924.0
offset_top = 8.0
offset_right = 4.0
offset_bottom = 8.0
grow_horizontal = 2
grow_vertical = 2
[node name="ScrollContainer" type="ScrollContainer" parent="Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer2" type="VBoxContainer" parent="Panel/ScrollContainer"]
layout_mode = 2 layout_mode = 2
[connection signal="pressed" from="MarginContainer/HBoxContainer/VBoxContainer/Play" to="." method="_on_play_pressed"] [connection signal="pressed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/Play" to="." method="_on_play_pressed"]
[connection signal="value_changed" from="MarginContainer/HBoxContainer/VBoxContainer/QualitySlider" to="." method="_on_quality_slider_value_changed"] [connection signal="value_changed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/QualitySlider" to="." method="_on_quality_slider_value_changed"]
[connection signal="item_selected" from="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/Game" to="." method="_on_game_item_selected"] [connection signal="item_selected" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/Game" to="." method="_on_game_item_selected"]
[connection signal="text_changed" from="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/Sensitivity" to="." method="_on_sensitivity_text_changed"] [connection signal="text_changed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/Sensitivity" to="." method="_on_sensitivity_text_changed"]
[connection signal="pressed" from="MarginContainer/HBoxContainer/VBoxContainer/Options" to="." method="_on_options_pressed"] [connection signal="pressed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/Options" to="." method="_on_options_pressed"]
[connection signal="pressed" from="MarginContainer/HBoxContainer/VBoxContainer/Quit" to="." method="_on_quit_pressed"] [connection signal="pressed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/Quit" to="." method="_on_quit_pressed"]

View file

@ -12,77 +12,36 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_4ilr3") script = ExtResource("1_4ilr3")
[node name="MarginContainer" type="MarginContainer" parent="."] [node name="ScrollContainer" type="ScrollContainer" parent="."]
layout_mode = 0 layout_mode = 1
offset_right = 40.0 anchors_preset = 15
offset_bottom = 40.0 anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"] [node name="MarginContainer" type="MarginContainer" parent="ScrollContainer"]
layout_mode = 2 layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"] [node name="HBoxContainer" type="HBoxContainer" parent="ScrollContainer/MarginContainer"]
layout_mode = 2 layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/HBoxContainer/VBoxContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer/MarginContainer/HBoxContainer"]
layout_mode = 2 layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
[node name="Crosshair" type="CheckButton" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"] [node name="LabelCrosshair" type="Label" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "Crosshair" text = "Crosshair"
uppercase = true
[node name="Outline" type="CheckButton" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"] [node name="Control" type="Control" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer"]
layout_mode = 2
text = "Outline"
[node name="Crosshair inner" type="CheckButton" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "Crosshair inner"
[node name="Dot" type="CheckButton" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "Dot"
[node name="DotSize" type="LineEdit" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "<null>"
placeholder_text = "6"
[node name="OutlineSize" type="LineEdit" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "1"
placeholder_text = "1"
[node name="CrosshairHeight" type="LineEdit" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "2"
placeholder_text = "2"
[node name="CrosshairWidth" type="LineEdit" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "8"
placeholder_text = "8"
[node name="CrosshairSpace" type="LineEdit" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "3"
placeholder_text = "3"
[node name="CrosshairColor" type="ColorPickerButton" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "Crosshair color"
[node name="OutlineColor" type="ColorPickerButton" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "Outline color"
[node name="Control" type="Control" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer"]
custom_minimum_size = Vector2(200, 200) custom_minimum_size = Vector2(200, 200)
layout_mode = 2 layout_mode = 2
[node name="Crosshair" type="Control" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/Control"] [node name="Crosshair" type="Control" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer/Control"]
layout_mode = 1 layout_mode = 1
anchors_preset = 8 anchors_preset = 8
anchor_left = 0.5 anchor_left = 0.5
@ -95,12 +54,69 @@ size_flags_horizontal = 4
size_flags_vertical = 4 size_flags_vertical = 4
script = ExtResource("2_iu82h") script = ExtResource("2_iu82h")
[node name="Back" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer"] [node name="Crosshair" type="CheckButton" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "Back" button_pressed = true
text = "Crosshair"
[node name="TargetColor" type="ColorPickerButton" parent="MarginContainer/HBoxContainer/VBoxContainer"] [node name="Outline" type="CheckButton" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer"]
layout_mode = 2
button_pressed = true
text = "Outline"
[node name="Crosshair inner" type="CheckButton" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer"]
layout_mode = 2
button_pressed = true
text = "Crosshair inner"
[node name="Dot" type="CheckButton" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer"]
layout_mode = 2
text = "Dot"
[node name="DotSize" type="LineEdit" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer" groups=["PutLabel"]]
layout_mode = 2
text = "6"
placeholder_text = "6"
[node name="OutlineSize" type="LineEdit" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer" groups=["PutLabel"]]
layout_mode = 2
text = "1"
placeholder_text = "1"
[node name="CrosshairHeight" type="LineEdit" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer" groups=["PutLabel"]]
layout_mode = 2
text = "2"
placeholder_text = "2"
[node name="CrosshairWidth" type="LineEdit" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer" groups=["PutLabel"]]
layout_mode = 2
text = "8"
placeholder_text = "8"
[node name="CrosshairSpace" type="LineEdit" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer" groups=["PutLabel"]]
layout_mode = 2
text = "3"
placeholder_text = "3"
[node name="CrosshairColor" type="ColorPickerButton" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer" groups=["PutLabel"]]
layout_mode = 2
text = "Crosshair color"
[node name="OutlineColor" type="ColorPickerButton" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer" groups=["PutLabel"]]
layout_mode = 2
text = "Outline color"
[node name="LabelTarget" type="Label" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "Target"
uppercase = true
[node name="TargetColor" type="ColorPickerButton" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer" groups=["PutLabel"]]
layout_mode = 2 layout_mode = 2
text = "Target color" text = "Target color"
[connection signal="pressed" from="MarginContainer/HBoxContainer/VBoxContainer/Back" to="." method="_on_back_pressed"] [node name="Back" type="Button" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = "Back"
[connection signal="pressed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/Back" to="." method="_on_back_pressed"]

View file

@ -18,16 +18,21 @@ func save_data(key, value):
file.close() file.close()
func get_data(key): func get_data(key):
return game_data.get(key) var result = null
if game_data != null:
result = game_data.get(key)
return result
func load_data(): func load_data():
var json = {} var json = JSON.new()
var result = {}
var file = FileAccess.open(file_path, FileAccess.READ) var file = FileAccess.open(file_path, FileAccess.READ)
if file: if file:
json = JSON.new()
game_data = json.parse(file.get_as_text()) game_data = json.parse(file.get_as_text())
file.close() file.close()
else: else:
print("File not found.") print("File not found.")
return json.data if json.data != null:
result = json.data
return result

View file

@ -15,6 +15,8 @@ func _ready():
for x in range(Global.game_type.number_of_initial_targets): for x in range(Global.game_type.number_of_initial_targets):
spawn_target() spawn_target()
var label = Label.new()
func target_killed(): func target_killed():
messageHit() messageHit()

View file

@ -1,10 +1,10 @@
extends Control extends Control
@onready var game = $MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/Game @onready var game = $ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/Game
@onready var resolution_label := $MarginContainer/HBoxContainer/VBoxContainer/ResolutionLabel @onready var resolution_label := $ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/ResolutionLabel
@onready var gamelist := $Panel/ScrollContainer/VBoxContainer2 @onready var gamelist := $ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer2
@onready var slider_quality := $MarginContainer/HBoxContainer/VBoxContainer/QualitySlider @onready var slider_quality := $ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/QualitySlider
@onready var sensitivity := $MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/Sensitivity @onready var sensitivity := $ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/Sensitivity
#4k #4k

View file

@ -1,14 +1,25 @@
extends Control extends Control
@onready var dot_size := $MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer/DotSize @onready var crosshair = $ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer/Crosshair
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. print(crosshair.is_pressed())
crosshair.set_pressed(true)
var all_put_labels = get_tree().get_nodes_in_group("PutLabel")
for put_label in all_put_labels:
putLabel(put_label)
func putLabel(put_label):
# Called every frame. 'delta' is the elapsed time since the previous frame. var label = Label.new()
func _process(delta): var hbox = HBoxContainer.new()
pass label.text = put_label.name + ': '
hbox.add_child(label)
var parent = put_label.get_parent()
var index = put_label.get_index()
parent.remove_child(put_label)
hbox.add_child(put_label)
parent.add_child(hbox)
parent.move_child(hbox, index)
func _on_back_pressed(): func _on_back_pressed():