Added a new PageTextEntry with small ui improvements.

This commit is contained in:
Relintai 2022-08-25 16:05:45 +02:00
parent f6da7c1f12
commit 42b65e21f1
11 changed files with 116 additions and 29 deletions

View File

@ -1,14 +1,27 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=9 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]
[ext_resource path="res://addons/web_pages/classes/post_entries/WebPageEntryTitleText.gd" type="Script" id=3]
[ext_resource path="res://addons/web_pages/classes/post_entries/WebPageEntryText.gd" type="Script" id=4]
[sub_resource type="Resource" id=1]
script = ExtResource( 3 )
text = "asdasdasd"
hsize = 1
[sub_resource type="Resource" id=4]
script = ExtResource( 4 )
text = "asdasd
asda
TEST
A"
[sub_resource type="Resource" id=3]
script = ExtResource( 3 )
text = "rtrtrtrttrtA"
@ -31,4 +44,4 @@ data = "<a href=\"/page\">Page</a>"
[node name="page" type="WebNode" parent="WebRoot"]
uri_segment = "page"
script = ExtResource( 2 )
entries = [ SubResource( 1 ), SubResource( 3 ), SubResource( 2 ) ]
entries = [ SubResource( 1 ), SubResource( 4 ), SubResource( 3 ), SubResource( 2 ) ]

View File

@ -0,0 +1,20 @@
tool
extends "res://addons/web_pages/classes/WebPageEntry.gd"
class_name WebPageEntryText, "res://addons/web_pages/icons/icon_web_page_entry_text.svg"
export(String) var text : String setget set_text, get_text
var compiled_text : String
func get_text() -> String:
return text
func set_text(t : String) -> void:
text = t
compiled_text = text.replace("\n", "<br>")
func _render(request : WebServerRequest):
request.body += compiled_text
func get_page_entry_class_name() -> String:
return "WebPageEntryText"

View File

@ -10,4 +10,4 @@ func _render(request : WebServerRequest):
func get_page_entry_class_name() -> String:
return "WebPageEntryTitleText"

View File

@ -12,7 +12,12 @@ func _notification(what):
get_ok().set_text("Close")
get_node("VBC/AddTitleTextButton").connect("pressed", self, "_add_title_text_button_pressed")
get_node("VBC/AddTextButton").connect("pressed", self, "_add_text_button_pressed")
func _add_title_text_button_pressed() -> void:
emit_signal("on_entry_class_selected" , "WebPageEntryTitleText")
hide()
func _add_text_button_pressed() -> void:
emit_signal("on_entry_class_selected" , "WebPageEntryText")
hide()

View File

@ -177,7 +177,9 @@ func _on_add_entry_class_selected(cls_name : String) -> void:
if cls_name == "WebPageEntryTitleText":
entry = WebPageEntryTitleText.new()
elif cls_name == "WebPageEntryText":
entry = WebPageEntryText.new()
if !entry:
PLogger.log_error("PageEditor: Couldn't create entry for: " + cls_name)
return

View File

@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://addons/web_pages/editor/PageEditor.gd" type="Script" id=1]
[ext_resource path="res://addons/web_pages/icons/icon_web_page_entry_title_text.svg" type="Texture" id=2]
[ext_resource path="res://addons/web_pages/editor/AddEntryPopup.gd" type="Script" id=3]
[ext_resource path="res://addons/web_pages/icons/icon_web_page_entry_text.svg" type="Texture" id=4]
[node name="PostEditor" type="PanelContainer"]
anchor_right = 1.0
@ -99,7 +100,7 @@ script = ExtResource( 3 )
margin_left = 8.0
margin_top = 8.0
margin_right = 192.0
margin_bottom = 30.0
margin_bottom = 56.0
size_flags_horizontal = 3
size_flags_vertical = 3
@ -108,3 +109,10 @@ margin_right = 184.0
margin_bottom = 22.0
text = "Title Text"
icon = ExtResource( 2 )
[node name="AddTextButton" type="Button" parent="Popups/AddEntryPopup/VBC"]
margin_top = 26.0
margin_right = 184.0
margin_bottom = 48.0
text = "Text"
icon = ExtResource( 4 )

View File

@ -9,6 +9,7 @@ var _main_container : Control = null
var _editor : Control = null
var WebPageEntryTitleTextEditor : PackedScene = null
var WebPageEntryTextEditor : PackedScene = null
signal entry_add_requested_after(entry)
signal entry_move_up_requested(entry)
@ -23,6 +24,8 @@ func set_entry(entry : WebPageEntry, undo_redo : UndoRedo) -> void:
if cls == "WebPageEntryTitleText":
_editor = WebPageEntryTitleTextEditor.instance()
elif cls == "WebPageEntryText":
_editor = WebPageEntryTextEditor.instance()
if _editor:
_editor.set_entry(entry, undo_redo)
@ -43,6 +46,7 @@ func _on_delete_button_pressed():
func _notification(what):
if what == NOTIFICATION_INSTANCED:
WebPageEntryTitleTextEditor = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryTitleTextEditor.tscn", "PackedScene")
WebPageEntryTextEditor = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryTextEditor.tscn", "PackedScene")
_entry_type_label = get_node("PC/VBC/TopBar/EntryTypeLabel")
_main_container = get_node("PC/VBC/MainContainer")

View File

@ -10,13 +10,13 @@ script = ExtResource( 1 )
[node name="PC" type="PanelContainer" parent="."]
margin_right = 1024.0
margin_bottom = 60.0
margin_bottom = 52.0
[node name="VBC" type="VBoxContainer" parent="PC"]
margin_left = 7.0
margin_top = 7.0
margin_right = 1017.0
margin_bottom = 53.0
margin_bottom = 45.0
[node name="TopBar" type="HBoxContainer" parent="PC/VBC"]
margin_right = 1010.0
@ -46,25 +46,15 @@ margin_right = 1010.0
margin_bottom = 20.0
text = "Delete"
[node name="HSeparator" type="HSeparator" parent="PC/VBC"]
[node name="MainContainer" type="PanelContainer" parent="PC/VBC"]
margin_top = 24.0
margin_right = 1010.0
margin_bottom = 28.0
[node name="MainContainer" type="PanelContainer" parent="PC/VBC"]
margin_top = 32.0
margin_right = 1010.0
margin_bottom = 46.0
[node name="HSeparator" type="HSeparator" parent="."]
margin_top = 64.0
margin_right = 1024.0
margin_bottom = 68.0
margin_bottom = 38.0
[node name="HBoxContainer" type="HBoxContainer" parent="."]
margin_top = 72.0
margin_top = 56.0
margin_right = 1024.0
margin_bottom = 92.0
margin_bottom = 76.0
alignment = 1
[node name="AddButton" type="Button" parent="HBoxContainer"]
@ -72,8 +62,3 @@ 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

View File

@ -0,0 +1,25 @@
tool
extends MarginContainer
var _entry : WebPageEntryText = null
var undo_redo : UndoRedo = null
var _text_edit : TextEdit = null
func set_entry(entry : WebPageEntryText, pundo_redo : UndoRedo) -> void:
undo_redo = pundo_redo
_entry = entry
_text_edit.text = _entry.text
func _notification(what):
if what == NOTIFICATION_INSTANCED:
_text_edit = get_node("TextEdit")
_text_edit.connect("text_changed", self, "_on_text_changed")
func _on_text_changed() -> void:
var new_text : String = _text_edit.text
undo_redo.create_action("Page text changed")
undo_redo.add_do_property(_entry, "text", new_text)
undo_redo.add_undo_property(_entry, "text", _entry.text)
undo_redo.commit_action()

View File

@ -0,0 +1,19 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/web_pages/editor/post_entries/WebPageEntryTextEditor.gd" type="Script" id=1]
[node name="WebPageEntryTitleTextEditor" type="MarginContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
[node name="TextEdit" type="TextEdit" parent="."]
margin_right = 1024.0
margin_bottom = 600.0
rect_min_size = Vector2( 0, 300 )
highlight_current_line = true
syntax_highlighting = true
show_line_numbers = true
fold_gutter = true
highlight_all_occurrences = true
minimap_draw = true

View File

@ -20,6 +20,11 @@ _global_script_classes=[ {
"path": "res://addons/web_pages/classes/WebPageEntry.gd"
}, {
"base": "Resource",
"class": @"WebPageEntryText",
"language": @"GDScript",
"path": "res://addons/web_pages/classes/post_entries/WebPageEntryText.gd"
}, {
"base": "Resource",
"class": @"WebPageEntryTitleText",
"language": @"GDScript",
"path": "res://addons/web_pages/classes/post_entries/WebPageEntryTitleText.gd"
@ -31,9 +36,10 @@ _global_script_classes=[ {
} ]
_global_script_class_icons={
@"WebPage": "res://addons/web_pages/icons/icon_web_page.svg",
@"WebPageEntryTitleText": "res://addons/web_pages/icons/icon_web_page_entry_title_text.svg",
@"WebPageEntryTitleText": "",
@"WebPageEntry": "res://addons/web_pages/icons/icon_web_page_entry.svg",
@"WebPageList": "res://addons/web_page_list/icons/icon_web_page_list.svg"
@"WebPageList": "res://addons/web_page_list/icons/icon_web_page_list.svg",
@"WebPageEntryText": "res://addons/web_pages/icons/icon_web_page_entry_text.svg"
}
[application]