Initial setup for the blog editor.

This commit is contained in:
Relintai 2022-08-23 20:44:39 +02:00
parent 59d2549d2a
commit 92d8f9c195
4 changed files with 59 additions and 4 deletions

View File

@ -1,3 +1,4 @@
extends Resource
class_name WebBlogEntry, "res://addons/web_blog/icons/icon_web_blog_post_entry.svg"

View File

@ -0,0 +1,42 @@
tool
extends Control
var _wne_tool_bar_button : Button = null
func _enter_tree():
var wne : Control = Engine.get_global("WebNodeEditor")
if wne:
_wne_tool_bar_button = Button.new()
_wne_tool_bar_button.set_text("Blog Editor")
_wne_tool_bar_button.set_tooltip("HTML preview")
_wne_tool_bar_button.set_toggle_mode(true)
_wne_tool_bar_button.set_pressed(false)
_wne_tool_bar_button.set_button_group(wne.get_main_button_group())
_wne_tool_bar_button.set_keep_pressed_outside(true)
wne.add_control_to_tool_bar(_wne_tool_bar_button)
_wne_tool_bar_button.connect("toggled", self, "_on_blog_editor_button_toggled")
wne.connect("edited_node_changed", self, "_edited_node_changed")
func _exit_tree():
if _wne_tool_bar_button:
_wne_tool_bar_button.queue_free()
func _on_blog_editor_button_toggled(on):
if on:
var wne : Control = Engine.get_global("WebNodeEditor")
if wne:
wne.switch_to_main_screen_tab(self)
_wne_tool_bar_button.set_pressed_no_signal(true)
func _edited_node_changed(web_node : WebNode):
var wne : Control = Engine.get_global("WebNodeEditor")
if wne:
if web_node is WebBlog:
_wne_tool_bar_button.show()
_wne_tool_bar_button.pressed = true
#wne.switch_to_main_screen_tab(self)
else:
_wne_tool_bar_button.hide()
#add method to switch off to the prev screen
#wne.switch_to_main_screen_tab(self)

View File

@ -1,5 +1,8 @@
[gd_scene format=2]
[gd_scene load_steps=2 format=2]
[node name="Control" type="Control"]
[ext_resource path="res://addons/web_blog/editor/WebBlogEditor.gd" type="Script" id=1]
[node name="WebBlogEditor" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )

View File

@ -1,11 +1,20 @@
tool
extends EditorPlugin
var web_blog_editor : Control = null
func _enter_tree():
pass
var wbes : PackedScene = ResourceLoader.load("res://addons/web_blog/editor/WebBlogEditor.tscn")
web_blog_editor = wbes.instance()
var wne : Control = Engine.get_global("WebNodeEditor")
if wne:
wne.add_main_screen_tab(web_blog_editor)
func _exit_tree():
pass
var wne : Control = Engine.get_global("WebNodeEditor")
if wne:
wne.remove_main_screen_tab(web_blog_editor)
func get_plugin_name() -> String:
return "WebBlogEditorPlugin"