Now the buttons in the Page editor work.

This commit is contained in:
Relintai 2022-08-25 15:28:46 +02:00
parent 1d993a21f3
commit 1527cdb480
5 changed files with 44 additions and 11 deletions

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://Main.gd" type="Script" id=1]
[ext_resource path="res://addons/web_pages/classes/WebPage.gd" type="Script" id=2]
@ -9,9 +9,9 @@ script = ExtResource( 3 )
text = "asdasdasd"
hsize = 1
[sub_resource type="Resource" id=2]
[sub_resource type="Resource" id=4]
script = ExtResource( 3 )
text = "weqweqwe"
text = "rerer"
hsize = 1
[sub_resource type="Resource" id=3]
@ -19,6 +19,11 @@ script = ExtResource( 3 )
text = "rtrtrtrttrtA"
hsize = 1
[sub_resource type="Resource" id=2]
script = ExtResource( 3 )
text = "weqweqwe"
hsize = 1
[node name="WebServer" type="WebServerSimple"]
script = ExtResource( 1 )
@ -31,4 +36,4 @@ data = "<a href=\"/blog\">Blog</a>"
[node name="Asdasd" type="WebNode" parent="WebRoot"]
uri_segment = "asda"
script = ExtResource( 2 )
entries = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ) ]
entries = [ SubResource( 1 ), SubResource( 4 ), SubResource( 3 ), SubResource( 2 ) ]

View File

@ -12,6 +12,7 @@ var _entry_name_line_edit : LineEdit = null
var _uri_segment_line_edit : LineEdit = null
var _add_entry_popup : AcceptDialog = null
var _entries_container : Control = null
var _main_add_button : Button = null
var _entry_add_after : WebPageEntry = null
@ -34,6 +35,9 @@ func recreate() -> void:
create_editors()
func create_editors() -> void:
if _page.entries.size() > 0:
_main_add_button.hide()
for i in range(_page.entries.size()):
var e : WebPageEntry = _page.entries[i]
@ -44,9 +48,17 @@ func create_editors() -> void:
func create_editor_for_entry(entry : WebPageEntry) -> Control:
var c : Control = WebPageEntryEditor.instance() as Control
c.set_entry(entry, undo_redo)
c.connect("entry_add_requested_after", self, "_on_entry_add_requested_after")
c.connect("entry_move_up_requested", self, "_on_entry_move_up_requested")
c.connect("entry_move_down_requested", self, "_on_entry_move_down_requested")
c.connect("entry_delete_requested", self, "_on_entry_delete_requested")
return c
func clear() -> void:
_main_add_button.show()
for i in range(_entries_container.get_child_count()):
_entries_container.get_child(i).queue_free()
@ -89,8 +101,8 @@ func _notification(what):
_entries_container = get_node("MC/EntriesContainer/MainVB/Entries")
var main_add_button : Button = get_node("MC/EntriesContainer/MainVB/MainAddButton")
main_add_button.connect("pressed", self, "_on_entry_add_requested")
_main_add_button = get_node("MC/EntriesContainer/MainVB/MainAddButton")
_main_add_button.connect("pressed", self, "_on_entry_add_requested")
WebPageEntryEditor = ResourceLoader.load("res://addons/web_pages/editor/WebPageEntryEditor.tscn", "PackedScene") as PackedScene
elif what == NOTIFICATION_ENTER_TREE:

View File

@ -69,7 +69,7 @@ size_flags_horizontal = 3
[node name="MainAddButton" type="Button" parent="MC/EntriesContainer/MainVB"]
margin_right = 1010.0
margin_bottom = 20.0
text = "Add (Bottom)"
text = "Add"
[node name="Entries" type="VBoxContainer" parent="MC/EntriesContainer/MainVB"]
margin_top = 24.0

View File

@ -47,7 +47,7 @@ func _notification(what):
_entry_type_label = get_node("PC/VBC/TopBar/EntryTypeLabel")
_main_container = get_node("PC/VBC/MainContainer")
get_node("AddButton").connect("pressed", self, "_on_add_button_pressed")
get_node("HBoxContainer/AddButton").connect("pressed", self, "_on_add_button_pressed")
get_node("PC/VBC/TopBar/UpButton").connect("pressed", self, "_on_up_button_pressed")
get_node("PC/VBC/TopBar/DownButton").connect("pressed", self, "_on_down_button_pressed")
get_node("PC/VBC/TopBar/Delete").connect("pressed", self, "_on_delete_button_pressed")

View File

@ -56,8 +56,24 @@ margin_top = 32.0
margin_right = 1010.0
margin_bottom = 46.0
[node name="AddButton" type="Button" parent="."]
[node name="HSeparator" type="HSeparator" parent="."]
margin_top = 64.0
margin_right = 1024.0
margin_bottom = 84.0
text = "Add Here"
margin_bottom = 68.0
[node name="HBoxContainer" type="HBoxContainer" parent="."]
margin_top = 72.0
margin_right = 1024.0
margin_bottom = 92.0
alignment = 1
[node name="AddButton" type="Button" parent="HBoxContainer"]
margin_left = 471.0
margin_right = 553.0
margin_bottom = 20.0
text = "+ Add here"
[node name="HSeparator2" type="HSeparator" parent="."]
margin_top = 96.0
margin_right = 1024.0
margin_bottom = 100.0