Fixed "crash" when class could not be compiled

This commit is contained in:
Matthias Stöckli 2017-08-05 12:35:45 +02:00
parent f734e3233e
commit 6116da7de3
8 changed files with 57 additions and 34 deletions

View File

@ -93,15 +93,13 @@ func something_changed(item, property, value):
```
# Please Contribute!
Please feel free to contribute. Unfortunately, the code base still is not documented that well and there are a number of bugs which will need to be ironed out. I am sure that there are a number of things I have been doing wrong, e.g. performance/memory management issues.
Please feel free to contribute. Unfortunately, the code base still is not documented that well and there are a number of bugs which will need to be ironed out. I am sure that there are many things I have been doing wrong, especially in regard to memory management.
# Known Issues
* The "Rename Class" feature may not properly rename the class file if it still in use
* There are a number of reference issues
* In some cases, the controls are not properly resized - pressing "Reload" should usually do the trick though
* A number of operations will perform a complete refresh of all data, which causes unsaved changes to disappear. This was done to prevent inconsistencies
* In some cases, the controls are not correctly resized - pressing "Reload" should usually do the trick though
* There is no support for undo/redo
* Pressing Ctrl+S to save while in the data editor may temporarily hide unsaved items
* Pressing Ctrl+S will not save the data items but the current scene
* The _data_ singleton is only visible in the editor when the project is being restarted. This seems to be a limitation of the engine which does not allow reload the engine.cfg file
* The "class overview" screen is lacking any kind of useful content

View File

@ -1,6 +1,10 @@
tool
extends PanelContainer
func _ready():
pass
func set_label(text):
get_node("Panel/Body/Label").set_text(text)

View File

@ -146,4 +146,18 @@ shortcut = null
text = "Add static property"
flat = false
[node name="Label" type="Label" parent="Panel/Body"]
focus/ignore_mouse = true
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 0
margin/left = 0.0
margin/top = 19.0
margin/right = 1246.0
margin/bottom = 33.0
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1

View File

@ -79,6 +79,7 @@ func _ready():
item_manager.connect("item_insertion_failed", self, "show_warning", [])
item_manager.connect("custom_property_insertion_failed", self, "show_warning", [])
item_manager.connect("item_duplication_failed", self, "show_warning", [])
# item_manager.connect("class_is_invalid", self, "show_warning", [])
# Add types to the custom property type dropdown
var type_names = item_manager.type_names.keys()
@ -193,10 +194,13 @@ func change_item_context(selected_item, selected_class):
delete_button.set_disabled(false)
copy_id_button.set_disabled(false)
edit_class_button.set_disabled(false)
self.selected_item = null
self.selected_id = null
id_label.set_text(selected_class.capitalize())
if item_manager.invalid_classes.has(selected_class):
class_overview.set_label("There is a problem with this class, please check if there are any issues. Press 'Reload' once you are ready.")
else:
class_overview.set_label("")
class_overview.show()
instance_details.hide()
no_classes.hide()
@ -379,11 +383,7 @@ func copy_id():
OS.set_clipboard(selected_class)
func edit_class():
var script = null
if selected_item:
script = selected_item.get_script()
else:
script = item_manager.classes[selected_class].new("dummy").get_script() # If no item is selected, create a dummy item
var script = item_manager.classes[selected_class]
emit_signal("class_edit_requested", script)
#####################################################

View File

@ -75,7 +75,6 @@ margin/left = 0.0
margin/top = 0.0
margin/right = 56.0
margin/bottom = 28.0
disabled = true
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
@ -123,7 +122,6 @@ margin/left = 131.0
margin/top = 0.0
margin/right = 212.0
margin/bottom = 28.0
disabled = true
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
@ -152,7 +150,6 @@ margin/left = 223.0
margin/top = 0.0
margin/right = 306.0
margin/bottom = 28.0
disabled = true
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
@ -189,7 +186,6 @@ margin/left = 406.0
margin/top = 0.0
margin/right = 480.0
margin/bottom = 28.0
disabled = true
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
@ -418,7 +414,6 @@ margin/left = 907.0
margin/top = 0.0
margin/right = 988.0
margin/bottom = 25.0
disabled = true
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
@ -437,7 +432,6 @@ margin/left = 1003.0
margin/top = 0.0
margin/right = 1095.0
margin/bottom = 25.0
disabled = true
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
@ -460,7 +454,7 @@ custom_fonts/font = ExtResource( 14 )
custom_colors/font_color_shadow = Color( 0.300781, 0.300781, 0.300781, 1 )
custom_constants/shadow_offset_x = 1
custom_constants/shadow_offset_y = 1
text = "No Classes"
text = "Actor"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
@ -581,7 +575,6 @@ margin/bottom = 46.0
[node name="InstanceDetails" type="PanelContainer" parent="VBox/Body/Content/VBox"]
editor/display_folded = true
visibility/visible = false
focus/ignore_mouse = false
focus/stop_mouse = true
@ -590,7 +583,7 @@ size_flags/vertical = 3
margin/left = 0.0
margin/top = 50.0
margin/right = 1103.0
margin/bottom = 303.0
margin/bottom = 561.0
[node name="HBox" type="HBoxContainer" parent="VBox/Body/Content/VBox/InstanceDetails"]
@ -601,7 +594,7 @@ size_flags/vertical = 3
margin/left = 7.0
margin/top = 7.0
margin/right = 1096.0
margin/bottom = 246.0
margin/bottom = 504.0
alignment = 0
[node name="ClassProperties" parent="VBox/Body/Content/VBox/InstanceDetails/HBox" instance=ExtResource( 15 )]
@ -609,7 +602,7 @@ alignment = 0
anchor/right = 0
anchor/bottom = 0
margin/right = 542.0
margin/bottom = 239.0
margin/bottom = 497.0
[node name="CustomProperties" parent="VBox/Body/Content/VBox/InstanceDetails/HBox" instance=ExtResource( 16 )]
@ -619,11 +612,10 @@ size_flags/horizontal = 3
size_flags/vertical = 3
margin/left = 546.0
margin/right = 1089.0
margin/bottom = 239.0
margin/bottom = 497.0
[node name="ClassOverview" parent="VBox/Body/Content/VBox" instance=ExtResource( 17 )]
visibility/visible = false
anchor/right = 0
anchor/bottom = 0
margin/top = 50.0
@ -632,10 +624,11 @@ margin/bottom = 561.0
[node name="NoClasses" parent="VBox/Body/Content/VBox" instance=ExtResource( 18 )]
visibility/visible = false
anchor/right = 0
anchor/bottom = 0
margin/left = 0.0
margin/top = 50.0
margin/top = 307.0
margin/right = 1103.0
margin/bottom = 561.0
@ -657,6 +650,7 @@ script/script = ExtResource( 19 )
[node name="NewClassDialog" type="ConfirmationDialog" parent="."]
editor/display_folded = true
visibility/visible = false
focus/ignore_mouse = false
focus/stop_mouse = true

View File

@ -5,6 +5,7 @@ var items = {}
var class_names = []
var classes = {}
var invalid_classes = []
var config_class_directory = ""
var config_output_directory = ""
@ -14,6 +15,7 @@ var config_password = ""
var config_extension = ""
var config_serializer = ""
signal class_is_invalid(item_class)
signal item_duplication_failed(title, reason)
signal item_insertion_failed(title, reason)
signal class_insertion_failed(title, reason)
@ -61,7 +63,8 @@ var unsaved_items = []
func store_unsaved_changes():
for item_class in items:
for item in items[item_class].values():
if item._dirty or not item._persistent:
# Check for id to prevent invalid entries from showing up
if item and item.get("_id") and (item._dirty or not item._persistent):
unsaved_items.append(item)
# Create a duplicate of the unsaved item because this will not mess up changed properties
@ -78,6 +81,7 @@ func reload_unsaved_items():
func initialize_variables():
items = {}
class_names = []
invalid_classes = []
classes = {}
config_class_directory = ""
@ -119,7 +123,10 @@ func load_classes():
classes = {}
for item_class in class_names:
classes[item_class] = load(config_class_directory + "/" + item_class + ".gd")
#classes[item_class].reload(true)
var error = classes[item_class].reload(true)
if not error == OK or not classes[item_class]:
emit_signal("class_is_invalid", item_class)
invalid_classes.append(item_class)
pass
@ -143,6 +150,10 @@ func load_items():
var directory = Directory.new()
for item_class in class_names:
items[item_class] = {}
if invalid_classes.has(item_class):
continue
directory.open(config_output_directory + "/" + item_class )
directory.list_dir_begin()
var file_name = directory.get_next()

View File

@ -83,6 +83,8 @@ func load_tree(is_reload = false):
classes.sort()
for item_class in classes:
tree_elements[item_class] = {}
if item_manager.invalid_classes.has(item_class):
continue
var ids = item_manager.items[item_class].keys()
ids.sort()

View File

@ -40,7 +40,7 @@ size_flags/vertical = 0
margin/left = 0.0
margin/top = 0.0
margin/right = 1260.0
margin/bottom = 2.0
margin/bottom = 19.0
custom_fonts/font = ExtResource( 2 )
text = "No Classes"
uppercase = true
@ -55,9 +55,9 @@ focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 0.0
margin/top = 6.0
margin/top = 23.0
margin/right = 1260.0
margin/bottom = 9.0
margin/bottom = 26.0
[node name="Spacer" type="Control" parent="Body"]
@ -67,9 +67,9 @@ focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 0.0
margin/top = 13.0
margin/top = 30.0
margin/right = 1260.0
margin/bottom = 28.0
margin/bottom = 45.0
[node name="Scroll" type="ScrollContainer" parent="Body"]
@ -78,7 +78,7 @@ focus/stop_mouse = true
size_flags/horizontal = 3
size_flags/vertical = 3
margin/left = 0.0
margin/top = 32.0
margin/top = 49.0
margin/right = 1260.0
margin/bottom = 580.0
scroll/horizontal = true