fix: Huge cleanup (#420)

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-10-25 08:59:07 +02:00
committed by GitHub
parent 3de06adcf9
commit 94d86d24d5
101 changed files with 1091 additions and 67952 deletions

View File

@@ -0,0 +1,64 @@
# A small utility to quickly switch to a room while developing
extends OptionButton
# The selected option
var _selected_id = 0
# The path to available rooms
var _options_paths = []
# Build up the list of rooms
func _ready():
var rooms_folder = ProjectSettings.get_setting(
"escoria/debug/room_selector_room_dir"
)
if rooms_folder == "" or \
not ProjectSettings.get_setting("escoria/debug/enable_room_selector"):
return
var dir = Directory.new()
var rooms_list: Array = []
var path = ProjectSettings.globalize_path(rooms_folder)
if not OS.has_feature("editor"):
path = OS.get_executable_path().get_base_dir().plus_file(path)
var tmp = dir.open(path)
if tmp == OK:
dir.list_dir_begin(true)
var file_name = dir.get_next()
while file_name != "":
if dir.current_is_dir():
rooms_list.push_back(file_name)
file_name = dir.get_next()
rooms_list.sort()
for room in rooms_list:
add_item(room)
_options_paths.push_back("%s/%s/%s.tscn" %[
rooms_folder,
room,
room
])
else:
escoria.logger.report_warnings("room_select.gd:_ready()",
["A problem occurred while opening rooms folder."])
# Switch to the selected room
func _on_button_pressed():
var script = escoria.esc_compiler.compile([
":debug",
"change_scene %s" % _options_paths[_selected_id]
])
escoria.event_manager.interrupt_running_event()
escoria.event_manager.queue_event(script.events['debug'])
# A room was selected, store the selection
#
# #### Parameters
# - index: The index of the selected room in the paths list
func _on_option_item_selected(index):
_selected_id = index

View File

@@ -0,0 +1,25 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/tools/room_select/room_select.gd" type="Script" id=1]
[node name="room_select" type="HBoxContainer"]
margin_right = 63.0
margin_bottom = 40.0005
__meta__ = {
"_edit_use_anchors_": false
}
[node name="option" type="OptionButton" parent="."]
margin_right = 29.0
margin_bottom = 40.0
size_flags_horizontal = 3
script = ExtResource( 1 )
[node name="button" type="Button" parent="."]
margin_left = 33.0
margin_right = 63.0
margin_bottom = 40.0
text = "Go"
[connection signal="item_selected" from="option" to="option" method="_on_option_item_selected"]
[connection signal="pressed" from="button" to="option" method="_on_button_pressed"]