mirror of
https://github.com/Relintai/pandemonium_cms.git
synced 2024-11-10 09:32:08 +01:00
Initial blog post editor setup and small changes.
This commit is contained in:
parent
92d8f9c195
commit
73f70bebc3
@ -1,7 +1,13 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Main.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/web_blog/classes/WebBlog.gd" type="Script" id=2]
|
||||
[ext_resource path="res://addons/web_blog/classes/WebBlogPost.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="Resource" id=1]
|
||||
script = ExtResource( 3 )
|
||||
post_name = "BlogTest"
|
||||
entries = [ ]
|
||||
|
||||
[node name="WebServer" type="WebServerSimple"]
|
||||
script = ExtResource( 1 )
|
||||
@ -15,3 +21,4 @@ data = "<a href=\"/blog\">Blog</a>"
|
||||
[node name="WebBlog" type="WebNode" parent="WebRoot"]
|
||||
uri_segment = "blog"
|
||||
script = ExtResource( 2 )
|
||||
posts = [ SubResource( 1 ) ]
|
||||
|
@ -1,4 +1,15 @@
|
||||
tool
|
||||
extends WebNode
|
||||
class_name WebBlog, "res://addons/web_blog/icons/icon_web_blog.svg"
|
||||
|
||||
export(Array, Resource) var posts : Array
|
||||
|
||||
func add_post(post : WebBlogPost) -> void:
|
||||
posts.push_back(post)
|
||||
|
||||
func remove_post(post : WebBlogPost) -> void:
|
||||
posts.erase(post)
|
||||
|
||||
# Temp hack for undoredo
|
||||
func null_method() -> void:
|
||||
pass
|
||||
|
@ -1,4 +1,6 @@
|
||||
tool
|
||||
extends Resource
|
||||
class_name WebBlogPost, "res://addons/web_blog/icons/icon_web_blog_post.svg"
|
||||
|
||||
export(String) var post_name : String = "BlogPost"
|
||||
export(Array, Resource) var entries : Array
|
||||
|
@ -1,4 +1,5 @@
|
||||
tool
|
||||
extends Resource
|
||||
class_name WebBlogEntry, "res://addons/web_blog/icons/icon_web_blog_post_entry.svg"
|
||||
class_name WebBlogPostEntry, "res://addons/web_blog/icons/icon_web_blog_post_entry.svg"
|
||||
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
tool
|
||||
extends "res://addons/web_blog/classes/WebBlogPostEntry.gd"
|
||||
class_name WebBlogPostEntryTitleText, "res://addons/web_blog/icons/icon_web_blog_post_entry_title_text.svg"
|
||||
|
||||
export(String) var title_text : String
|
||||
export(int) var hsize : int = 1
|
22
game/addons/web_blog/editor/PostEditor.gd
Normal file
22
game/addons/web_blog/editor/PostEditor.gd
Normal file
@ -0,0 +1,22 @@
|
||||
tool
|
||||
extends VBoxContainer
|
||||
|
||||
var _post : WebBlogPost = null
|
||||
var undo_redo : UndoRedo = null
|
||||
|
||||
func set_post(post : WebBlogPost):
|
||||
_post = post
|
||||
get_node("HBoxContainer/PostNameLE").text = post.post_name
|
||||
name = post.post_name
|
||||
|
||||
func _on_PostNameLE_text_entered(new_text : String):
|
||||
var le : LineEdit = get_node("HBoxContainer/PostNameLE")
|
||||
|
||||
undo_redo.create_action("Post name changed.")
|
||||
undo_redo.add_do_property(_post, "post_name", new_text)
|
||||
undo_redo.add_undo_property(_post, "post_name", _post.post_name)
|
||||
undo_redo.add_do_property(le, "text", new_text)
|
||||
undo_redo.add_undo_property(le, "text", _post.post_name)
|
||||
undo_redo.add_do_property(self, "name", new_text)
|
||||
undo_redo.add_undo_property(self, "name", _post.post_name)
|
||||
undo_redo.commit_action()
|
29
game/addons/web_blog/editor/PostEditor.tscn
Normal file
29
game/addons/web_blog/editor/PostEditor.tscn
Normal file
@ -0,0 +1,29 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/web_blog/editor/PostEditor.gd" type="Script" id=1]
|
||||
|
||||
[node name="PostEditor" type="VBoxContainer"]
|
||||
margin_top = 28.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 28.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxContainer"]
|
||||
margin_top = 5.0
|
||||
margin_right = 70.0
|
||||
margin_bottom = 19.0
|
||||
text = "Post Name"
|
||||
|
||||
[node name="PostNameLE" type="LineEdit" parent="HBoxContainer"]
|
||||
margin_left = 74.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
text = "BlogPost"
|
||||
align = 1
|
||||
|
||||
[connection signal="text_entered" from="HBoxContainer/PostNameLE" to="." method="_on_PostNameLE_text_entered"]
|
7
game/addons/web_blog/editor/Posts.gd
Normal file
7
game/addons/web_blog/editor/Posts.gd
Normal file
@ -0,0 +1,7 @@
|
||||
tool
|
||||
extends VBoxContainer
|
||||
|
||||
signal new_post_request
|
||||
|
||||
func _on_NewPostButton_pressed():
|
||||
emit_signal("new_post_request")
|
40
game/addons/web_blog/editor/Posts.tscn
Normal file
40
game/addons/web_blog/editor/Posts.tscn
Normal file
@ -0,0 +1,40 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/web_blog/editor/Posts.gd" type="Script" id=1]
|
||||
|
||||
[node name="Posts" type="VBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 4.0
|
||||
margin_top = 32.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = -4.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="NewPostButton" type="Button" parent="."]
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 20.0
|
||||
text = "New post"
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
margin_top = 24.0
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 564.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="OutsideVBC" type="VBoxContainer" parent="ScrollContainer"]
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 4.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Entries" type="VBoxContainer" parent="ScrollContainer/OutsideVBC"]
|
||||
margin_right = 1016.0
|
||||
|
||||
[node name="Pagination" type="HBoxContainer" parent="ScrollContainer/OutsideVBC"]
|
||||
margin_top = 4.0
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 4.0
|
||||
alignment = 1
|
||||
|
||||
[connection signal="pressed" from="NewPostButton" to="." method="_on_NewPostButton_pressed"]
|
@ -1,7 +1,9 @@
|
||||
tool
|
||||
extends Control
|
||||
extends PanelContainer
|
||||
|
||||
var _wne_tool_bar_button : Button = null
|
||||
var _edited_blog : WebBlog = null
|
||||
var undo_redo : UndoRedo = null
|
||||
|
||||
func _enter_tree():
|
||||
var wne : Control = Engine.get_global("WebNodeEditor")
|
||||
@ -20,6 +22,11 @@ func _enter_tree():
|
||||
func _exit_tree():
|
||||
if _wne_tool_bar_button:
|
||||
_wne_tool_bar_button.queue_free()
|
||||
_wne_tool_bar_button = null
|
||||
|
||||
var wne : Control = Engine.get_global("WebNodeEditor")
|
||||
if wne:
|
||||
wne.disconnect("edited_node_changed", self, "_edited_node_changed")
|
||||
|
||||
func _on_blog_editor_button_toggled(on):
|
||||
if on:
|
||||
@ -29,6 +36,11 @@ func _on_blog_editor_button_toggled(on):
|
||||
_wne_tool_bar_button.set_pressed_no_signal(true)
|
||||
|
||||
func _edited_node_changed(web_node : WebNode):
|
||||
_edited_blog = web_node
|
||||
|
||||
if !_wne_tool_bar_button:
|
||||
return
|
||||
|
||||
var wne : Control = Engine.get_global("WebNodeEditor")
|
||||
if wne:
|
||||
if web_node is WebBlog:
|
||||
@ -40,3 +52,22 @@ func _edited_node_changed(web_node : WebNode):
|
||||
#add method to switch off to the prev screen
|
||||
#wne.switch_to_main_screen_tab(self)
|
||||
|
||||
func _on_new_post_requested():
|
||||
if !_edited_blog:
|
||||
return
|
||||
|
||||
var post : WebBlogPost = WebBlogPost.new()
|
||||
_edited_blog.add_post(post)
|
||||
|
||||
var post_editor_scene : PackedScene = ResourceLoader.load("res://addons/web_blog/editor/PostEditor.tscn", "PackedScene")
|
||||
var nps : Control = post_editor_scene.instance()
|
||||
nps.undo_redo = undo_redo
|
||||
nps.set_post(post)
|
||||
get_node("./Tabs").add_child(nps)
|
||||
|
||||
# Hack for now. Todo add support for this into UndoRedo without hacks
|
||||
undo_redo.create_action("Created WebBlog Post")
|
||||
undo_redo.add_do_method(_edited_blog, "null_method")
|
||||
undo_redo.add_undo_method(_edited_blog, "null_method")
|
||||
undo_redo.commit_action()
|
||||
|
||||
|
@ -1,8 +1,23 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/web_blog/editor/WebBlogEditor.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/web_blog/editor/Posts.tscn" type="PackedScene" id=3]
|
||||
|
||||
[node name="WebBlogEditor" type="Control"]
|
||||
[node name="WebBlogEditor" type="PanelContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Tabs" type="TabContainer" parent="."]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 1017.0
|
||||
margin_bottom = 593.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Posts" parent="Tabs" instance=ExtResource( 3 )]
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[connection signal="new_post_request" from="Tabs/Posts" to="." method="_on_new_post_requested"]
|
||||
|
@ -6,6 +6,7 @@ var web_blog_editor : Control = null
|
||||
func _enter_tree():
|
||||
var wbes : PackedScene = ResourceLoader.load("res://addons/web_blog/editor/WebBlogEditor.tscn")
|
||||
web_blog_editor = wbes.instance()
|
||||
web_blog_editor.undo_redo = get_undo_redo()
|
||||
|
||||
var wne : Control = Engine.get_global("WebNodeEditor")
|
||||
if wne:
|
||||
|
@ -15,18 +15,24 @@ _global_script_classes=[ {
|
||||
"path": "res://addons/web_blog/classes/WebBlog.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": @"WebBlogEntry",
|
||||
"class": @"WebBlogPost",
|
||||
"language": @"GDScript",
|
||||
"path": "res://addons/web_blog/classes/WebBlogPost.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": @"WebBlogPostEntry",
|
||||
"language": @"GDScript",
|
||||
"path": "res://addons/web_blog/classes/WebBlogPostEntry.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": @"WebBlogPost",
|
||||
"class": @"WebBlogPostEntryTitleText",
|
||||
"language": @"GDScript",
|
||||
"path": "res://addons/web_blog/classes/WebBlogPost.gd"
|
||||
"path": "res://addons/web_blog/classes/post_entries/WebBlogPostEntryTitleText.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
@"WebBlogEntry": "res://addons/web_blog/icons/icon_web_blog_post_entry.svg",
|
||||
@"WebBlogPost": "res://addons/web_blog/icons/icon_web_blog_post.svg",
|
||||
@"WebBlogPostEntryTitleText": "res://addons/web_blog/icons/icon_web_blog_post_entry_title_text.svg",
|
||||
@"WebBlogPostEntry": "res://addons/web_blog/icons/icon_web_blog_post_entry.svg",
|
||||
@"WebBlog": "res://addons/web_blog/icons/icon_web_blog.svg"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user