Added uri segment to the page editor.

This commit is contained in:
Relintai 2022-08-25 02:26:57 +02:00
parent 20197d93e6
commit 1e71271517
3 changed files with 53 additions and 19 deletions

View File

@ -13,4 +13,5 @@ uri_segment = "/"
data = "<a href=\"/blog\">Blog</a>" data = "<a href=\"/blog\">Blog</a>"
[node name="Asdasd" type="WebNode" parent="WebRoot"] [node name="Asdasd" type="WebNode" parent="WebRoot"]
uri_segment = "asda"
script = ExtResource( 2 ) script = ExtResource( 2 )

View File

@ -3,30 +3,43 @@ extends VBoxContainer
var _wne_tool_bar_button : Button = null var _wne_tool_bar_button : Button = null
var _post : WebPage = null var _page : WebPage = null
var undo_redo : UndoRedo = null var undo_redo : UndoRedo = null
func set_post(post : WebPage): func set_page(page : WebPage):
_post = post _page = page
get_node("HBoxContainer/PostNameLE").text = post.name get_node("Name/PostNameLE").text = page.name
name = post.name get_node("URISegment/URISegmentLE").text = page.uri_segment
# name = page.name
func _on_PostNameLE_text_entered(new_text : String): func _on_pageNameLE_text_entered(new_text : String):
var le : LineEdit = get_node("HBoxContainer/PostNameLE") var le : LineEdit = get_node("Name/PostNameLE")
undo_redo.create_action("Post name changed.") undo_redo.create_action("Page name changed.")
undo_redo.add_do_property(_post, "name", new_text) undo_redo.add_do_property(_page, "name", new_text)
undo_redo.add_undo_property(_post, "name", _post.name) undo_redo.add_undo_property(_page, "name", _page.name)
undo_redo.add_do_property(le, "text", new_text) undo_redo.add_do_property(le, "text", new_text)
undo_redo.add_undo_property(le, "text", _post.name) undo_redo.add_undo_property(le, "text", _page.name)
undo_redo.add_do_property(self, "name", new_text) undo_redo.add_do_property(self, "name", new_text)
undo_redo.add_undo_property(self, "name", _post.name) undo_redo.add_undo_property(self, "name", _page.name)
undo_redo.commit_action()
func _on_URISegmentLE_text_entered(new_text : String):
var le : LineEdit = get_node("URISegment/URISegmentLE")
undo_redo.create_action("Page uri segment changed.")
undo_redo.add_do_property(_page, "uri_segment", new_text)
undo_redo.add_undo_property(_page, "uri_segment", _page.uri_segment)
undo_redo.add_do_property(le, "text", new_text)
undo_redo.add_undo_property(le, "text", _page.uri_segment)
undo_redo.commit_action() undo_redo.commit_action()
func _notification(what): func _notification(what):
if what == NOTIFICATION_INSTANCED: if what == NOTIFICATION_INSTANCED:
var le : LineEdit = get_node("HBoxContainer/PostNameLE") var le : LineEdit = get_node("Name/PostNameLE")
le.connect("text_entered", self, "_on_PostNameLE_text_entered") le.connect("text_entered", self, "_on_pageNameLE_text_entered")
var USle : LineEdit = get_node("URISegment/URISegmentLE")
USle.connect("text_entered", self, "_on_URISegmentLE_text_entered")
elif what == NOTIFICATION_ENTER_TREE: elif what == NOTIFICATION_ENTER_TREE:
var wne : Control = Engine.get_global("WebNodeEditor") var wne : Control = Engine.get_global("WebNodeEditor")
if wne: if wne:
@ -63,13 +76,14 @@ func _edited_node_changed(web_node : WebNode):
var wne : Control = Engine.get_global("WebNodeEditor") var wne : Control = Engine.get_global("WebNodeEditor")
if wne: if wne:
if web_node is WebPage: if web_node is WebPage:
_post = web_node set_page(web_node)
#_page = web_node
_wne_tool_bar_button.show() _wne_tool_bar_button.show()
_wne_tool_bar_button.pressed = true _wne_tool_bar_button.pressed = true
#wne.switch_to_main_screen_tab(self) #wne.switch_to_main_screen_tab(self)
else: else:
_wne_tool_bar_button.hide() _wne_tool_bar_button.hide()
#_post = null #_page = null
#add method to switch off to the prev screen #add method to switch off to the prev screen
#wne.switch_to_main_screen_tab(self) #wne.switch_to_main_screen_tab(self)

View File

@ -8,20 +8,39 @@ margin_right = 1024.0
margin_bottom = 28.0 margin_bottom = 28.0
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="HBoxContainer" type="HBoxContainer" parent="."] [node name="Name" type="HBoxContainer" parent="."]
margin_right = 1024.0 margin_right = 1024.0
margin_bottom = 24.0 margin_bottom = 24.0
[node name="Label" type="Label" parent="HBoxContainer"] [node name="Label" type="Label" parent="Name"]
margin_top = 5.0 margin_top = 5.0
margin_right = 70.0 margin_right = 70.0
margin_bottom = 19.0 margin_bottom = 19.0
text = "Post Name" text = "Post Name"
[node name="PostNameLE" type="LineEdit" parent="HBoxContainer"] [node name="PostNameLE" type="LineEdit" parent="Name"]
margin_left = 74.0 margin_left = 74.0
margin_right = 1024.0 margin_right = 1024.0
margin_bottom = 24.0 margin_bottom = 24.0
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "BlogPost" text = "BlogPost"
align = 1 align = 1
[node name="URISegment" type="HBoxContainer" parent="."]
margin_top = 28.0
margin_right = 1024.0
margin_bottom = 52.0
[node name="Label" type="Label" parent="URISegment"]
margin_top = 5.0
margin_right = 87.0
margin_bottom = 19.0
text = "URI Segment:"
[node name="URISegmentLE" type="LineEdit" parent="URISegment"]
margin_left = 91.0
margin_right = 1024.0
margin_bottom = 24.0
size_flags_horizontal = 3
text = "BlogPost"
align = 1