This commit is contained in:
James 2023-12-28 17:21:25 +00:00
parent 87542751e4
commit 3943a1eff2
10 changed files with 244 additions and 306 deletions

44
HUD.gd
View File

@ -1,44 +0,0 @@
extends PanelContainer
var elapsed_time = 0.0 # Initialize a variable to keep track of elapsed time
# Called when the node enters the scene tree for the first time.
func _ready():
var popup_menu = $HBoxContainer/Right/File.get_popup()
popup_menu.connect("id_pressed", self._on_PopupMenu_id_pressed)
func _on_PopupMenu_id_pressed(id):
match id:
0:
$"../NewDialog".popup_centered()
1:
$"../LoadDialog".popup_centered()
2:
$"../SaveDialog".popup_centered()
4:
$"../SettingsWindow".popup()
5:
$"../StatsWindow".popup()
func _process(delta):
elapsed_time += delta # Increment the elapsed time by the frame's delta time
var hours = int(elapsed_time / 3600)
var minutes = int(elapsed_time / 60) % 60
var seconds = int(elapsed_time) % 60
var time_string = "%02d:%02d:%02d" % [hours, minutes, seconds] # Format time as H:M:S
var fps = Engine.get_frames_per_second() # Get the current FPS
$HBoxContainer/Debug.text = time_string+" "+str(fps) + " fps" # Combine FPS and runtime into one string
if %Map.controlling and is_instance_valid(%Map.controlling):
$HBoxContainer/Debug.text += " [H:"+str(%Map.controlling.health)+"]"
func _on_settings_window_close_requested():
print("close")
$"../SettingsWindow".hide()
func _on_control_stop_button_pressed():
%Map.controlling=null
func _on_kill_all_pressed():
for node in %Map.get_children():
if node is Player:
node.queue_free()

View File

@ -14,7 +14,7 @@ func _integrate_forces(state: PhysicsDirectBodyState2D):
handle_pool_collision(collider_object)
func handle_player_collision(player: Player):
if not get_tree().root.get_node("Sim/ScreenOverlay/SettingsWindow/VBoxContainer/DropOnColl").is_pressed():
if not get_tree().root.get_node("Sim/ScreenOverlay/Settings/VBoxContainer/DropOnColl").is_pressed():
return
if is_carrying() and player.is_carrying():
doubledrop(player)
@ -148,7 +148,7 @@ func load_data(data):
update()
func _on_health_timer_timeout():
if not get_tree().root.get_node("Sim/ScreenOverlay/SettingsWindow/VBoxContainer/Health").is_pressed():
if not get_tree().root.get_node("Sim/ScreenOverlay/Settings/VBoxContainer/Health").is_pressed():
return
if is_carrying():

View File

@ -123,7 +123,7 @@ func load_data(data):
mana_b=data["b"]
func _on_decay_timer_timeout():
if not get_tree().root.get_node("Sim/ScreenOverlay/SettingsWindow/VBoxContainer/Decay").is_pressed():
if not get_tree().root.get_node("Sim/ScreenOverlay/Settings/VBoxContainer/Decay").is_pressed():
return
if (mana_r+mana_g+mana_b)>randf_range(0,99999):
decay()

View File

@ -14,8 +14,8 @@ func _ready():
if not DirAccess.dir_exists_absolute(session_path):
DirAccess.make_dir_recursive_absolute(session_path)
$"../ScreenOverlay/SettingsWindow/VBoxContainer/HBoxContainer/Interval".text=str(wait_time)
$"../ScreenOverlay/SettingsWindow/VBoxContainer/HBoxContainer/Screenshots".set_pressed(is_stopped() == false)
$"../ScreenOverlay/Settings/VBoxContainer/HBoxContainer/Interval".text=str(wait_time)
$"../ScreenOverlay/Settings/VBoxContainer/HBoxContainer/Screenshots".set_pressed(is_stopped() == false)
func _on_timeout():
var image = get_viewport().get_texture().get_image()

215
hud.tscn
View File

@ -1,215 +0,0 @@
[gd_scene load_steps=3 format=3 uid="uid://i5hw0qow332a"]
[ext_resource type="Script" path="res://HUD.gd" id="1_4qotk"]
[ext_resource type="Script" path="res://ToolSelect.gd" id="2_m1iu2"]
[node name="HUD" type="PanelContainer"]
anchors_preset = 10
anchor_right = 1.0
grow_horizontal = 2
script = ExtResource("1_4qotk")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="ToolSelect" type="HBoxContainer" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 2
script = ExtResource("2_m1iu2")
[node name="VBoxContainer" type="HBoxContainer" parent="HBoxContainer/ToolSelect"]
layout_mode = 2
[node name="OptionButton" type="OptionButton" parent="HBoxContainer/ToolSelect/VBoxContainer"]
layout_mode = 2
[node name="Create Player" type="VBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
layout_mode = 2
[node name="Create Pool" type="HBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool"]
layout_mode = 2
text = "R:"
[node name="Red" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool"]
layout_mode = 2
text = "100"
placeholder_text = "0"
[node name="Label5" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool"]
layout_mode = 2
text = "G:"
[node name="Green" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool"]
layout_mode = 2
text = "100"
placeholder_text = "0"
max_length = 5
[node name="Label4" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool"]
layout_mode = 2
text = "B:"
[node name="Blue" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool"]
layout_mode = 2
text = "100"
placeholder_text = "0"
max_length = 5
[node name="Create Player Circle" type="HBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
layout_mode = 2
[node name="Label2" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
layout_mode = 2
text = "Radius:"
[node name="Radius" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
layout_mode = 2
text = "50"
placeholder_text = "0"
max_length = 5
[node name="Label3" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
layout_mode = 2
text = "Count:"
[node name="Count" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
layout_mode = 2
text = "16"
placeholder_text = "0"
max_length = 5
[node name="Create Pool Circle" type="HBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "R:"
[node name="Red" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "100"
placeholder_text = "0"
max_length = 5
[node name="Label5" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "G:"
[node name="Green" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "100"
placeholder_text = "0"
max_length = 5
[node name="Label4" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "B:"
[node name="Blue" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "100"
placeholder_text = "0"
max_length = 5
[node name="Label2" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "Radius:"
[node name="Radius" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "200"
placeholder_text = "0"
max_length = 5
[node name="Label3" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "Count:"
[node name="Count" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "16"
placeholder_text = "0"
max_length = 5
[node name="Paste" type="OptionButton" parent="HBoxContainer/ToolSelect/VBoxContainer"]
layout_mode = 2
[node name="Delete" type="VBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
layout_mode = 2
[node name="Impulse" type="HBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
layout_mode = 2
[node name="Type" type="OptionButton" parent="HBoxContainer/ToolSelect/VBoxContainer/Impulse"]
layout_mode = 2
item_count = 2
selected = 0
popup/item_0/text = "Linear"
popup/item_0/id = 0
popup/item_1/text = "Radial"
popup/item_1/id = 1
[node name="Label2" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Impulse"]
layout_mode = 2
text = "Power
"
[node name="Power" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Impulse"]
layout_mode = 2
text = "1"
[node name="Label" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Impulse"]
layout_mode = 2
text = "Dampening"
[node name="DropOff" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Impulse"]
layout_mode = 2
text = "1"
[node name="Control Player" type="VBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
layout_mode = 2
[node name="Button" type="Button" parent="HBoxContainer/ToolSelect/VBoxContainer/Control Player"]
layout_mode = 2
text = "Stop"
[node name="GOD" type="VBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
layout_mode = 2
[node name="kill all" type="Button" parent="HBoxContainer/ToolSelect/VBoxContainer/GOD"]
layout_mode = 2
text = "Kill All"
[node name="Debug" type="Label" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 6
text = "debug"
[node name="Right" type="HBoxContainer" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 10
[node name="File" type="MenuButton" parent="HBoxContainer/Right"]
layout_mode = 2
text = "File..."
item_count = 6
popup/item_0/text = "New..."
popup/item_0/id = 0
popup/item_1/text = "Load..."
popup/item_1/id = 1
popup/item_2/text = "Save..."
popup/item_2/id = 2
popup/item_3/text = ""
popup/item_3/id = 3
popup/item_3/separator = true
popup/item_4/text = "Settings..."
popup/item_4/id = 4
popup/item_5/text = "Stats..."
popup/item_5/id = 5
[connection signal="item_selected" from="HBoxContainer/ToolSelect/VBoxContainer/OptionButton" to="HBoxContainer/ToolSelect" method="_on_option_button_item_selected"]
[connection signal="pressed" from="HBoxContainer/ToolSelect/VBoxContainer/Control Player/Button" to="." method="_on_control_stop_button_pressed"]
[connection signal="pressed" from="HBoxContainer/ToolSelect/VBoxContainer/GOD/kill all" to="." method="_on_kill_all_pressed"]

View File

@ -1,13 +1,14 @@
[gd_scene load_steps=9 format=3 uid="uid://bpy475nyq5ea1"]
[gd_scene load_steps=10 format=3 uid="uid://bpy475nyq5ea1"]
[ext_resource type="Script" path="res://Map.gd" id="2_rolej"]
[ext_resource type="Script" path="res://ScreenShots.gd" id="3_7b3mn"]
[ext_resource type="Texture2D" uid="uid://1g54esg7yd35" path="res://images/crosshair.png" id="3_i24br"]
[ext_resource type="Script" path="res://Camera2D.gd" id="4_g4kw0"]
[ext_resource type="PackedScene" uid="uid://i5hw0qow332a" path="res://hud.tscn" id="4_u63sk"]
[ext_resource type="Script" path="res://LoadDialog.gd" id="6_0mayr"]
[ext_resource type="Script" path="res://SaveDialog.gd" id="6_v2wl8"]
[ext_resource type="Script" path="res://StatsWindow.gd" id="7_8peal"]
[ext_resource type="PackedScene" uid="uid://bfjdgwkowj6rr" path="res://src/Windows/tool_select.tscn" id="8_wgtoc"]
[ext_resource type="PackedScene" uid="uid://0i5mf5rafi45" path="res://src/Windows/settings.tscn" id="8_yj6l1"]
[node name="Sim" type="Node2D"]
@ -24,8 +25,6 @@ texture = ExtResource("3_i24br")
[node name="ScreenOverlay" type="CanvasLayer" parent="."]
[node name="HUD" parent="ScreenOverlay" instance=ExtResource("4_u63sk")]
[node name="LoadDialog" type="ConfirmationDialog" parent="ScreenOverlay"]
title = "Load"
position = Vector2i(0, 36)
@ -57,7 +56,7 @@ dialog_text = "Clear current map?"
[node name="StatsWindow" type="Window" parent="ScreenOverlay"]
title = "Stats"
position = Vector2i(15, 320)
position = Vector2i(15, 197)
size = Vector2i(200, 200)
script = ExtResource("7_8peal")
@ -68,40 +67,10 @@ autostart = true
offset_right = 40.0
offset_bottom = 23.0
[node name="SettingsWindow" type="Window" parent="ScreenOverlay"]
title = "Settings"
position = Vector2i(18, 75)
size = Vector2i(250, 200)
[node name="Settings" parent="ScreenOverlay" instance=ExtResource("8_yj6l1")]
[node name="VBoxContainer" type="VBoxContainer" parent="ScreenOverlay/SettingsWindow"]
offset_right = 123.0
offset_bottom = 101.0
[node name="Decay" type="CheckBox" parent="ScreenOverlay/SettingsWindow/VBoxContainer"]
layout_mode = 2
text = "Decay"
[node name="Health" type="CheckBox" parent="ScreenOverlay/SettingsWindow/VBoxContainer"]
layout_mode = 2
text = "Health"
[node name="DropOnColl" type="CheckBox" parent="ScreenOverlay/SettingsWindow/VBoxContainer"]
layout_mode = 2
text = "Drop on Coll"
[node name="HBoxContainer" type="HBoxContainer" parent="ScreenOverlay/SettingsWindow/VBoxContainer"]
layout_mode = 2
[node name="Screenshots" type="CheckBox" parent="ScreenOverlay/SettingsWindow/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Screenshots @"
[node name="Interval" type="LineEdit" parent="ScreenOverlay/SettingsWindow/VBoxContainer/HBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="ScreenOverlay/SettingsWindow/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "sec"
[node name="ToolSelect" parent="ScreenOverlay" instance=ExtResource("8_wgtoc")]
position = Vector2i(20, 50)
[node name="ScreenShots" type="Timer" parent="."]
wait_time = 60.0
@ -115,7 +84,4 @@ script = ExtResource("3_7b3mn")
[connection signal="confirmed" from="ScreenOverlay/NewDialog" to="Map" method="_on_new_dialog_confirmed"]
[connection signal="close_requested" from="ScreenOverlay/StatsWindow" to="ScreenOverlay/StatsWindow" method="_on_close_requested"]
[connection signal="timeout" from="ScreenOverlay/StatsWindow/Timer" to="ScreenOverlay/StatsWindow" method="_on_timer_timeout"]
[connection signal="close_requested" from="ScreenOverlay/SettingsWindow" to="ScreenOverlay/HUD" method="_on_settings_window_close_requested"]
[connection signal="toggled" from="ScreenOverlay/SettingsWindow/VBoxContainer/HBoxContainer/Screenshots" to="ScreenShots" method="_on_screenshots_toggled"]
[connection signal="text_changed" from="ScreenOverlay/SettingsWindow/VBoxContainer/HBoxContainer/Interval" to="ScreenShots" method="_on_interval_text_changed"]
[connection signal="timeout" from="ScreenShots" to="ScreenShots" method="_on_timeout"]

View File

@ -1,4 +1,4 @@
extends Control
extends Window
# Called when the node enters the scene tree for the first time.
func _ready():

11
src/Windows/settings.gd Normal file
View File

@ -0,0 +1,11 @@
extends Window
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

39
src/Windows/settings.tscn Normal file
View File

@ -0,0 +1,39 @@
[gd_scene load_steps=2 format=3 uid="uid://0i5mf5rafi45"]
[ext_resource type="Script" path="res://src/Windows/settings.gd" id="1_i80kr"]
[node name="SettingsWindow" type="Window"]
title = "Settings"
position = Vector2i(0, 36)
size = Vector2i(250, 200)
script = ExtResource("1_i80kr")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
offset_right = 123.0
offset_bottom = 101.0
[node name="Decay" type="CheckBox" parent="VBoxContainer"]
layout_mode = 2
text = "Decay"
[node name="Health" type="CheckBox" parent="VBoxContainer"]
layout_mode = 2
text = "Health"
[node name="DropOnColl" type="CheckBox" parent="VBoxContainer"]
layout_mode = 2
text = "Drop on Coll"
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="Screenshots" type="CheckBox" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Screenshots @"
[node name="Interval" type="LineEdit" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "sec"

View File

@ -0,0 +1,181 @@
[gd_scene load_steps=2 format=3 uid="uid://bfjdgwkowj6rr"]
[ext_resource type="Script" path="res://src/Windows/ToolSelect.gd" id="1_suvl4"]
[node name="ToolSelect" type="Window"]
title = "Tool"
size = Vector2i(200, 200)
script = ExtResource("1_suvl4")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
offset_right = 1656.0
offset_bottom = 31.0
[node name="OptionButton" type="OptionButton" parent="VBoxContainer"]
layout_mode = 2
item_count = 1
selected = 0
popup/item_0/text = "Select Tool..."
popup/item_0/id = 0
[node name="Create Player" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="Create Pool" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/Create Pool"]
layout_mode = 2
text = "R:"
[node name="Red" type="LineEdit" parent="VBoxContainer/Create Pool"]
layout_mode = 2
text = "100"
placeholder_text = "0"
[node name="Label5" type="Label" parent="VBoxContainer/Create Pool"]
layout_mode = 2
text = "G:"
[node name="Green" type="LineEdit" parent="VBoxContainer/Create Pool"]
layout_mode = 2
text = "100"
placeholder_text = "0"
max_length = 5
[node name="Label4" type="Label" parent="VBoxContainer/Create Pool"]
layout_mode = 2
text = "B:"
[node name="Blue" type="LineEdit" parent="VBoxContainer/Create Pool"]
layout_mode = 2
text = "100"
placeholder_text = "0"
max_length = 5
[node name="Create Player Circle" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="Label2" type="Label" parent="VBoxContainer/Create Player Circle"]
layout_mode = 2
text = "Radius:"
[node name="Radius" type="LineEdit" parent="VBoxContainer/Create Player Circle"]
layout_mode = 2
text = "50"
placeholder_text = "0"
max_length = 5
[node name="Label3" type="Label" parent="VBoxContainer/Create Player Circle"]
layout_mode = 2
text = "Count:"
[node name="Count" type="LineEdit" parent="VBoxContainer/Create Player Circle"]
layout_mode = 2
text = "16"
placeholder_text = "0"
max_length = 5
[node name="Create Pool Circle" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "R:"
[node name="Red" type="LineEdit" parent="VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "100"
placeholder_text = "0"
max_length = 5
[node name="Label5" type="Label" parent="VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "G:"
[node name="Green" type="LineEdit" parent="VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "100"
placeholder_text = "0"
max_length = 5
[node name="Label4" type="Label" parent="VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "B:"
[node name="Blue" type="LineEdit" parent="VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "100"
placeholder_text = "0"
max_length = 5
[node name="Label2" type="Label" parent="VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "Radius:"
[node name="Radius" type="LineEdit" parent="VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "200"
placeholder_text = "0"
max_length = 5
[node name="Label3" type="Label" parent="VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "Count:"
[node name="Count" type="LineEdit" parent="VBoxContainer/Create Pool Circle"]
layout_mode = 2
text = "16"
placeholder_text = "0"
max_length = 5
[node name="Paste" type="OptionButton" parent="VBoxContainer"]
layout_mode = 2
[node name="Delete" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="Impulse" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="Type" type="OptionButton" parent="VBoxContainer/Impulse"]
layout_mode = 2
item_count = 2
selected = 0
popup/item_0/text = "Linear"
popup/item_0/id = 0
popup/item_1/text = "Radial"
popup/item_1/id = 1
[node name="Label2" type="Label" parent="VBoxContainer/Impulse"]
layout_mode = 2
text = "Power
"
[node name="Power" type="LineEdit" parent="VBoxContainer/Impulse"]
layout_mode = 2
text = "1"
[node name="Label" type="Label" parent="VBoxContainer/Impulse"]
layout_mode = 2
text = "Dampening"
[node name="DropOff" type="LineEdit" parent="VBoxContainer/Impulse"]
layout_mode = 2
text = "1"
[node name="Control Player" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="Button" type="Button" parent="VBoxContainer/Control Player"]
layout_mode = 2
text = "Stop"
[node name="GOD" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="kill all" type="Button" parent="VBoxContainer/GOD"]
layout_mode = 2
text = "Kill All"
[connection signal="item_selected" from="VBoxContainer/OptionButton" to="." method="_on_option_button_item_selected"]