diff --git a/game/addons/web_blog/classes/WebBlogPostEntry.gd b/game/addons/web_blog/classes/WebBlogPostEntry.gd index 238c1fe..7b54f16 100644 --- a/game/addons/web_blog/classes/WebBlogPostEntry.gd +++ b/game/addons/web_blog/classes/WebBlogPostEntry.gd @@ -1,3 +1,4 @@ extends Resource class_name WebBlogEntry, "res://addons/web_blog/icons/icon_web_blog_post_entry.svg" + diff --git a/game/addons/web_blog/editor/WebBlogEditor.gd b/game/addons/web_blog/editor/WebBlogEditor.gd new file mode 100644 index 0000000..a3bc183 --- /dev/null +++ b/game/addons/web_blog/editor/WebBlogEditor.gd @@ -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) + diff --git a/game/addons/web_blog/editor/WebBlogEditor.tscn b/game/addons/web_blog/editor/WebBlogEditor.tscn index 00a6290..4beb549 100644 --- a/game/addons/web_blog/editor/WebBlogEditor.tscn +++ b/game/addons/web_blog/editor/WebBlogEditor.tscn @@ -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 ) diff --git a/game/addons/web_blog/plugin.gd b/game/addons/web_blog/plugin.gd index 256d543..ae5d790 100644 --- a/game/addons/web_blog/plugin.gd +++ b/game/addons/web_blog/plugin.gd @@ -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"