Initial Android commit
This commit is contained in:
commit
1e2b80c13d
8521 changed files with 231475 additions and 0 deletions
202
addons/dialogic/Documentation/Nodes/DocsMarkdownParser.gd
Normal file
202
addons/dialogic/Documentation/Nodes/DocsMarkdownParser.gd
Normal file
|
@ -0,0 +1,202 @@
|
|||
extends Node
|
||||
|
||||
var heading1_font = "res://addons/dialogic/Documentation/Theme/DocumentationH1.tres"
|
||||
var heading2_font = "res://addons/dialogic/Documentation/Theme/DocumentationH2.tres"
|
||||
var heading3_font = "res://addons/dialogic/Documentation/Theme/DocumentationH3.tres"
|
||||
var heading4_font = "res://addons/dialogic/Documentation/Theme/DocumentationH4.tres"
|
||||
var heading5_font = "res://addons/dialogic/Documentation/Theme/DocumentationH5.tres"
|
||||
|
||||
|
||||
var heading1s = []
|
||||
var heading2s = []
|
||||
var heading3s = []
|
||||
var heading4s = []
|
||||
var heading5s = []
|
||||
var result = ""
|
||||
var bolded = []
|
||||
var italics = []
|
||||
var striked = []
|
||||
var coded = []
|
||||
var linknames = []
|
||||
var links = []
|
||||
var imagenames = []
|
||||
var imagelinks = []
|
||||
var lists = []
|
||||
var underlined = []
|
||||
|
||||
var accent_color: = Color()
|
||||
var sub_accent_color: = Color()
|
||||
|
||||
var editor_scale: = 1.0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func set_accent_colors(new_accent_color:Color, new_sub_accent_color:Color)->void :
|
||||
accent_color = new_accent_color
|
||||
sub_accent_color = new_sub_accent_color
|
||||
|
||||
|
||||
func parse(content:String, file_path:String = "", docs_path:String = ""):
|
||||
|
||||
heading1s = []
|
||||
heading2s = []
|
||||
heading3s = []
|
||||
heading4s = []
|
||||
heading5s = []
|
||||
result = ""
|
||||
bolded = []
|
||||
italics = []
|
||||
striked = []
|
||||
coded = []
|
||||
linknames = []
|
||||
links = []
|
||||
imagenames = []
|
||||
imagelinks = []
|
||||
lists = []
|
||||
underlined = []
|
||||
|
||||
var parsed_text = content
|
||||
|
||||
var regex = RegEx.new()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
regex.compile("\\*\\*(?<boldtext>(\\.|[^(\\*\\*)])*)\\*\\*")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
parsed_text = parsed_text.replace("**" + res.get_string("boldtext") + "**", "[b]" + res.get_string("boldtext") + "[/b]")
|
||||
|
||||
|
||||
regex.compile("\\_\\_(?<underlinetext>.*)\\_\\_")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
parsed_text = parsed_text.replace("__" + res.get_string("underlinetext") + "__", "[u]" + res.get_string("underlinetext") + "[/u]")
|
||||
|
||||
|
||||
regex.compile("\\*(?<italictext>[^\\*]*)\\*")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
parsed_text = parsed_text.replace("*" + res.get_string("italictext") + "*", "[i]" + res.get_string("italictext") + "[/i]")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
regex.compile("~~(?<strikedtext>.*)~~")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
parsed_text = parsed_text.replace("~~" + res.get_string("strikedtext") + "~~", "[s]" + res.get_string("strikedtext") + "[/s]")
|
||||
|
||||
|
||||
regex.compile("(([^`]`)|(```))(?<coded>[^`]+)(?(2)(`)|(```))")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
if res.get_string().begins_with("```"):
|
||||
parsed_text = parsed_text.replace("```" + res.get_string("coded") + "```", "[indent][color=#" + accent_color.lightened(0.6).to_html() + "][code]" + res.get_string("coded") + "[/code][/color][/indent]")
|
||||
else :
|
||||
parsed_text = parsed_text.replace("`" + res.get_string("coded") + "`", "[color=#" + accent_color.lightened(0.6).to_html() + "][code]" + res.get_string("coded") + "[/code][/color]")
|
||||
|
||||
|
||||
|
||||
|
||||
regex.compile("\\n\\s*(?<symbol>[-+*])(?<element>\\s.*)")
|
||||
result = regex.search_all(parsed_text)
|
||||
if result:
|
||||
for res in result:
|
||||
var symbol = res.get_string("symbol")
|
||||
var element = res.get_string("element")
|
||||
if parsed_text.find(symbol + " " + element):
|
||||
parsed_text = parsed_text.replace(symbol + " " + element, "[indent]" + symbol + " " + element + "[/indent]")
|
||||
|
||||
|
||||
regex.compile("!\\[(?<imgname>.*)\\]\\((?<imglink>.*)\\)")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
if res.get_string("imglink") != "":
|
||||
imagelinks.append(res.get_string("imglink"))
|
||||
if res.get_string("imgname") != "":
|
||||
imagenames.append(res.get_string("imgname"))
|
||||
|
||||
|
||||
regex.compile("[^!]\\[(?<linkname>[^\\[]+)\\]\\((?<link>[^\\)]*\\S*?)\\)")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
if res.get_string("link") != "":
|
||||
links.append(res.get_string("link"))
|
||||
if res.get_string("linkname") != "":
|
||||
linknames.append(res.get_string("linkname"))
|
||||
|
||||
|
||||
regex.compile("(?:\\n|^)#(?<heading>[^#\\n]+[^\\n]+)")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
var heading = res.get_string("heading")
|
||||
heading1s.append(heading)
|
||||
parsed_text = parsed_text.replace("#" + heading, "[color=#" + accent_color.lightened(0.2).to_html() + "][font=" + heading1_font + "]" + heading.strip_edges() + "[/font][/color]")
|
||||
|
||||
|
||||
regex.compile("(?:\\n|^)##(?<heading>[^#\\n]+[^\\n]+)")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
var heading = res.get_string("heading")
|
||||
heading2s.append(heading)
|
||||
parsed_text = parsed_text.replace("\n##" + heading, "\n[color=#" + accent_color.lightened(0.5).to_html() + "][font=" + heading2_font + "]" + heading.strip_edges() + "[/font][/color]")
|
||||
|
||||
|
||||
regex.compile("(?:\\n|^)###(?<heading>[^#\\n]+[^\\n]+)")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
var heading = res.get_string("heading")
|
||||
parsed_text = parsed_text.replace("\n###" + heading, "\n[color=#" + accent_color.lightened(0.7).to_html() + "][font=" + heading3_font + "]" + heading.strip_edges() + "[/font][/color]")
|
||||
|
||||
|
||||
regex.compile("(?:\\n|^)####(?<heading>[^#\\n]+[^\\n]+)")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
var heading = res.get_string("heading")
|
||||
parsed_text = parsed_text.replace("\n####" + heading, "\n[color=#" + accent_color.lightened(0.85).to_html() + "][font=" + heading4_font + "]" + heading.strip_edges() + "[/font][/color]")
|
||||
|
||||
|
||||
|
||||
regex.compile("(?:\\n|^)#####(?<heading>[^#\\n]+[^\\n]+)")
|
||||
result = regex.search_all(content)
|
||||
if result:
|
||||
for res in result:
|
||||
var heading = res.get_string("heading")
|
||||
parsed_text = parsed_text.replace("\n#####" + heading, "\n[color=#" + accent_color.lightened(0.85).to_html() + "][font=" + heading5_font + "]" + heading.strip_edges() + "[/font][/color]")
|
||||
|
||||
for i in links.size():
|
||||
parsed_text = parsed_text.replace("[" + linknames[i] + "](" + links[i] + ")", "[color=#" + accent_color.to_html() + "][url=" + links[i] + "]" + linknames[i] + "[/url][/color]")
|
||||
|
||||
for i in imagenames.size():
|
||||
var imagelink_to_use = imagelinks[i]
|
||||
if imagelink_to_use.begins_with("http"):
|
||||
var path_parts = imagelink_to_use.split("/Documentation/")
|
||||
if path_parts.size() > 1:
|
||||
imagelink_to_use = docs_path + "/" + path_parts[1]
|
||||
else :
|
||||
imagelink_to_use = "icon.png"
|
||||
if imagelink_to_use.begins_with(".") and file_path:
|
||||
imagelink_to_use = file_path.trim_suffix(file_path.get_file()).trim_suffix("/") + imagelink_to_use.trim_prefix(".")
|
||||
parsed_text = parsed_text.replace("![" + imagenames[i] + "](" + imagelinks[i] + ")", "[img=" + str(int(700 * editor_scale)) + "]" + imagelink_to_use + "[/img]")
|
||||
|
||||
parsed_text += "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
|
||||
|
||||
return parsed_text
|
205
addons/dialogic/Documentation/Nodes/DocsPageViewer.gd
Normal file
205
addons/dialogic/Documentation/Nodes/DocsPageViewer.gd
Normal file
|
@ -0,0 +1,205 @@
|
|||
tool
|
||||
extends Control
|
||||
|
||||
export (bool) var enable_editing = false
|
||||
|
||||
export (String) var documentation_path:String = "res://addons/dialogic/Documentation"
|
||||
var MarkdownParser = load("res://addons/dialogic/Documentation/Nodes/DocsMarkdownParser.gd").new()
|
||||
|
||||
var current_path:String = ""
|
||||
var current_headings = []
|
||||
|
||||
onready var Content = $Content
|
||||
|
||||
signal open_non_html_link(link, section)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func load_page(page_path:String, section:String = ""):
|
||||
Content.set("custom_styles/normal", StyleBoxEmpty.new())
|
||||
Content.get("custom_styles/normal").content_margin_left = 15
|
||||
Content.get("custom_styles/normal").content_margin_top = 15
|
||||
Content.get("custom_styles/normal").content_margin_right = 15
|
||||
Content.get("custom_styles/normal").content_margin_bottom = 15
|
||||
|
||||
var base_size = 16
|
||||
Content.set("custom_fonts/normal_font/size", int(base_size * get_constant("scale", "Editor")))
|
||||
Content.set("custom_fonts/bold_font/size", int(base_size * get_constant("scale", "Editor")))
|
||||
|
||||
Content.set("custom_fonts/mono_font/size", int(base_size * get_constant("scale", "Editor")))
|
||||
Content.set("custom_fonts/bold_italics_font/size", int(base_size * get_constant("scale", "Editor")))
|
||||
|
||||
|
||||
|
||||
Content.set("custom_fonts/mono_font", get_font("doc_source", "EditorFonts"))
|
||||
Content.set("custom_fonts/bold_font", Content.get_font("doc_bold", "EditorFonts"))
|
||||
|
||||
MarkdownParser.set_accent_colors(get_color("accent_color", "Editor"), get_color("disabled_font_color", "Editor"))
|
||||
|
||||
if page_path == "" and not section:
|
||||
return
|
||||
|
||||
show()
|
||||
_on_Content_resized()
|
||||
|
||||
|
||||
|
||||
if page_path.count("#") > 0:
|
||||
var result = page_path.split("#")
|
||||
page_path = result[0]
|
||||
section = "#" + result[1]
|
||||
|
||||
|
||||
if not page_path.begins_with("res://"):
|
||||
page_path = documentation_path + "/Content/" + page_path
|
||||
if not page_path.ends_with(".md"):
|
||||
page_path += ".md"
|
||||
|
||||
|
||||
var f = File.new()
|
||||
f.open(page_path, File.READ)
|
||||
current_path = page_path
|
||||
|
||||
|
||||
Content.bbcode_text = MarkdownParser.parse(f.get_as_text(), current_path, documentation_path)
|
||||
f.close()
|
||||
|
||||
|
||||
current_headings = MarkdownParser.heading1s + MarkdownParser.heading2s + MarkdownParser.heading3s + MarkdownParser.heading4s + MarkdownParser.heading5s
|
||||
create_content_menu(MarkdownParser.heading1s + MarkdownParser.heading2s)
|
||||
|
||||
|
||||
if not scroll_to_section(section):
|
||||
Content.scroll_to_line(0)
|
||||
|
||||
|
||||
yield (get_tree(), "idle_frame")
|
||||
_on_Up_pressed()
|
||||
|
||||
|
||||
|
||||
func scroll_to_section(title):
|
||||
if not title:
|
||||
return
|
||||
|
||||
for heading in current_headings:
|
||||
if (heading.to_lower().strip_edges().replace(" ", "-") == title.replace("#", "")) or (heading.to_lower().strip_edges() == title.to_lower().strip_edges()):
|
||||
var x = Content.bbcode_text.find(heading.replace("#", "").strip_edges() + "[/font]")
|
||||
x = Content.bbcode_text.count("\n", 0, x)
|
||||
Content.scroll_to_line(x)
|
||||
|
||||
$ContentMenu / Panel.hide()
|
||||
|
||||
return true
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func _ready():
|
||||
$Up.icon = get_icon("ArrowUp", "EditorIcons")
|
||||
|
||||
$Editing.visible = enable_editing
|
||||
|
||||
|
||||
|
||||
func create_content_menu(headings):
|
||||
for child in $ContentMenu / Panel / VBox.get_children():
|
||||
child.queue_free()
|
||||
if len(headings) < 2:
|
||||
$ContentMenu.hide()
|
||||
return
|
||||
$ContentMenu.show()
|
||||
headings.pop_front()
|
||||
for heading in headings:
|
||||
var button = Button.new()
|
||||
button.set("custom_styles/normal", get_stylebox("sub_inspector_bg0", "Editor"))
|
||||
button.text = heading
|
||||
button.align = Button.ALIGN_LEFT
|
||||
button.connect("pressed", self, "content_button_pressed", [heading])
|
||||
$ContentMenu / Panel / VBox.add_child(button)
|
||||
|
||||
|
||||
func content_button_pressed(heading):
|
||||
scroll_to_section(heading)
|
||||
$ContentMenu / ToggleContents.pressed = false
|
||||
|
||||
|
||||
|
||||
func _on_meta_clicked(meta):
|
||||
|
||||
if meta.begins_with("http"):
|
||||
|
||||
|
||||
if meta.count("Documentation/Content") > 0:
|
||||
meta = meta.split("Documentation/Content")[1]
|
||||
|
||||
|
||||
else :
|
||||
OS.shell_open(meta)
|
||||
return
|
||||
|
||||
|
||||
if meta.begins_with("#"):
|
||||
|
||||
scroll_to_section(meta)
|
||||
|
||||
|
||||
else :
|
||||
|
||||
var link = meta
|
||||
var section = null
|
||||
if meta.count("#") > 0:
|
||||
var split = meta.split("#")
|
||||
link = split[0]
|
||||
section = split[1]
|
||||
if link.begins_with("."):
|
||||
link = current_path.trim_suffix(current_path.get_file()).trim_suffix("/") + link.trim_prefix(".")
|
||||
if not link.begins_with("res://"):
|
||||
link = documentation_path.plus_file("Content").plus_file(link)
|
||||
if not link.ends_with(".md"):
|
||||
link += ".md"
|
||||
|
||||
emit_signal("open_non_html_link", link, section)
|
||||
|
||||
|
||||
func _on_EditPage_pressed():
|
||||
var x = File.new()
|
||||
x.open(current_path, File.READ)
|
||||
OS.shell_open(x.get_path_absolute())
|
||||
|
||||
|
||||
func _on_RefreshPage_pressed():
|
||||
load_page(current_path)
|
||||
|
||||
|
||||
func _on_Up_pressed():
|
||||
Content.scroll_to_line(0)
|
||||
|
||||
|
||||
func _on_ToggleContents_toggled(button_pressed):
|
||||
$ContentMenu / Panel.visible = button_pressed
|
||||
|
||||
func toggle_editing():
|
||||
enable_editing = not enable_editing
|
||||
$Editing.visible = enable_editing
|
||||
|
||||
func _on_Content_resized():
|
||||
if not Content:return
|
||||
if Content.rect_size.x < 500:
|
||||
Content.get("custom_styles/normal").content_margin_left = 15
|
||||
Content.get("custom_styles/normal").content_margin_right = 15
|
||||
else :
|
||||
Content.get("custom_styles/normal").content_margin_left = (Content.rect_size.x - 500) / 4
|
||||
Content.get("custom_styles/normal").content_margin_right = (Content.rect_size.x - 500) / 3
|
||||
Content.update()
|
178
addons/dialogic/Documentation/Nodes/DocsPageViewer.tscn
Normal file
178
addons/dialogic/Documentation/Nodes/DocsPageViewer.tscn
Normal file
|
@ -0,0 +1,178 @@
|
|||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://addons/dialogic/Documentation/Theme/Font/NotoSans-Regular.ttf" type="DynamicFontData" id=1]
|
||||
[ext_resource path="res://addons/dialogic/Documentation/Theme/Font/NotoSans-Bold.ttf" type="DynamicFontData" id=2]
|
||||
[ext_resource path="res://addons/dialogic/Documentation/Theme/Font/NotoSans-Italic.ttf" type="DynamicFontData" id=3]
|
||||
[ext_resource path="res://addons/dialogic/Documentation/Nodes/DocsPageViewer.gd" type="Script" id=6]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=1]
|
||||
content_margin_left = 89.5
|
||||
content_margin_right = 119.333
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
use_filter = true
|
||||
extra_spacing_char = 2
|
||||
extra_spacing_space = 2
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=3]
|
||||
use_filter = true
|
||||
font_data = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=4]
|
||||
font_data = ExtResource( 3 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=5]
|
||||
font_data = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=6]
|
||||
use_filter = true
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="Image" id=9]
|
||||
data = {
|
||||
"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
|
||||
"format": "LumAlpha8",
|
||||
"height": 16,
|
||||
"mipmaps": false,
|
||||
"width": 16
|
||||
}
|
||||
|
||||
[sub_resource type="ImageTexture" id=8]
|
||||
flags = 4
|
||||
flags = 4
|
||||
image = SubResource( 9 )
|
||||
size = Vector2( 16, 16 )
|
||||
|
||||
[node name="DocsPageViewer" type="Control"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
focus_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 6 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Content" type="RichTextLabel" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2( 50, 0 )
|
||||
focus_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_styles/normal = SubResource( 1 )
|
||||
custom_fonts/mono_font = SubResource( 2 )
|
||||
custom_fonts/bold_italics_font = SubResource( 3 )
|
||||
custom_fonts/italics_font = SubResource( 4 )
|
||||
custom_fonts/bold_font = SubResource( 5 )
|
||||
custom_fonts/normal_font = SubResource( 6 )
|
||||
custom_colors/selection_color = Color( 0.45098, 0.45098, 0.45098, 0.45098 )
|
||||
bbcode_enabled = true
|
||||
bbcode_text = "Can't find the specified file."
|
||||
text = "Can't find the specified file."
|
||||
scroll_following = true
|
||||
selection_enabled = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Editing" type="HBoxContainer" parent="."]
|
||||
visible = false
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
margin_left = -202.807
|
||||
margin_top = 8.09956
|
||||
margin_right = -8.80664
|
||||
margin_bottom = 33.0996
|
||||
grow_horizontal = 0
|
||||
alignment = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="RefreshPage" type="Button" parent="Editing"]
|
||||
margin_left = 94.0
|
||||
margin_right = 154.0
|
||||
margin_bottom = 25.0
|
||||
text = "Refresh"
|
||||
|
||||
[node name="EditPage" type="Button" parent="Editing"]
|
||||
margin_left = 158.0
|
||||
margin_right = 194.0
|
||||
margin_bottom = 25.0
|
||||
text = "Edit"
|
||||
|
||||
[node name="Up" type="Button" parent="."]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -40.5946
|
||||
margin_top = -41.6541
|
||||
margin_right = -10.5946
|
||||
margin_bottom = -11.6541
|
||||
rect_min_size = Vector2( 30, 30 )
|
||||
hint_tooltip = "Back to top"
|
||||
icon = SubResource( 8 )
|
||||
expand_icon = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ContentMenu" type="VBoxContainer" parent="."]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -207.0
|
||||
margin_top = -590.0
|
||||
margin_right = -49.0
|
||||
margin_bottom = -13.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
rect_min_size = Vector2( 50, 40 )
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 9
|
||||
custom_constants/separation = 20
|
||||
alignment = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Panel" type="Control" parent="ContentMenu"]
|
||||
visible = false
|
||||
margin_top = 537.0
|
||||
margin_right = 158.0
|
||||
margin_bottom = 537.0
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="ContentMenu/Panel"]
|
||||
margin_top = -88.0
|
||||
margin_right = 156.0
|
||||
margin_bottom = 4.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
size_flags_horizontal = 3
|
||||
alignment = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ToggleContents" type="Button" parent="ContentMenu"]
|
||||
margin_top = 557.0
|
||||
margin_right = 158.0
|
||||
margin_bottom = 577.0
|
||||
toggle_mode = true
|
||||
text = "Contents"
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[connection signal="meta_clicked" from="Content" to="." method="_on_meta_clicked"]
|
||||
[connection signal="resized" from="Content" to="." method="_on_Content_resized"]
|
||||
[connection signal="pressed" from="Editing/RefreshPage" to="." method="_on_RefreshPage_pressed"]
|
||||
[connection signal="pressed" from="Editing/EditPage" to="." method="_on_EditPage_pressed"]
|
||||
[connection signal="pressed" from="Up" to="." method="_on_Up_pressed"]
|
||||
[connection signal="toggled" from="ContentMenu/ToggleContents" to="." method="_on_ToggleContents_toggled"]
|
224
addons/dialogic/Documentation/Nodes/DocsTreeHelper.gd
Normal file
224
addons/dialogic/Documentation/Nodes/DocsTreeHelper.gd
Normal file
|
@ -0,0 +1,224 @@
|
|||
tool
|
||||
extends Control
|
||||
|
||||
|
||||
export (String) var documentation_path:String = "res://addons/dialogic/Documentation"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var use_folder_files = true
|
||||
|
||||
|
||||
var file_ignore_list = ["Welcome.md"]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func get_documentation_content():
|
||||
return get_dir_contents(documentation_path + "/Content")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func build_documentation_tree(tree:Tree, root_item:TreeItem = null, def_folder_info:Dictionary = {}, def_page_info:Dictionary = {}, filter_term:String = ""):
|
||||
return _build_documentation_tree(tree, root_item, def_folder_info, def_page_info, filter_term)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func get_dir_contents(rootPath:String)->Dictionary:
|
||||
var directory_structure = {}
|
||||
var dir: = Directory.new()
|
||||
|
||||
if dir.open(rootPath) == OK:
|
||||
dir.list_dir_begin(true, false)
|
||||
directory_structure = _add_dir_contents(dir)
|
||||
else :
|
||||
push_error("Docs: An error occurred when trying to access the path.")
|
||||
return directory_structure
|
||||
|
||||
func _add_dir_contents(dir:Directory)->Dictionary:
|
||||
var file_name = dir.get_next()
|
||||
|
||||
var structure = {}
|
||||
while (file_name != ""):
|
||||
var path = dir.get_current_dir() + "/" + file_name
|
||||
if dir.current_is_dir():
|
||||
|
||||
var subDir = Directory.new()
|
||||
subDir.open(path)
|
||||
subDir.list_dir_begin(true, false)
|
||||
var dir_content = _add_dir_contents(subDir)
|
||||
if dir_content.has("_files_"):
|
||||
structure[path] = dir_content
|
||||
else :
|
||||
|
||||
if not file_name.ends_with(".md"):
|
||||
file_name = dir.get_next()
|
||||
continue
|
||||
if file_name in file_ignore_list:
|
||||
file_name = dir.get_next()
|
||||
continue
|
||||
if not structure.has("_files_"):
|
||||
structure["_files_"] = []
|
||||
|
||||
structure["_files_"].append(path)
|
||||
|
||||
file_name = dir.get_next()
|
||||
dir.list_dir_end()
|
||||
return structure
|
||||
|
||||
|
||||
|
||||
|
||||
func _build_documentation_tree(tree:Tree, root_item:TreeItem = null, def_folder_info:Dictionary = {}, def_page_info:Dictionary = {}, filter_term:String = ""):
|
||||
|
||||
var documentation_tree
|
||||
if root_item == null:
|
||||
documentation_tree = tree.create_item()
|
||||
documentation_tree.set_text(0, "Documentation")
|
||||
|
||||
else :
|
||||
documentation_tree = root_item
|
||||
|
||||
|
||||
if not filter_term:
|
||||
documentation_tree.collapsed = true
|
||||
else :
|
||||
documentation_tree.collapsed = false
|
||||
|
||||
|
||||
var doc_structure = get_documentation_content()
|
||||
|
||||
create_doc_tree(tree, documentation_tree, def_folder_info, def_page_info, doc_structure, filter_term)
|
||||
return documentation_tree
|
||||
|
||||
|
||||
func create_doc_tree(tree, parent_item, def_folder_info, def_page_info, doc_structure, filter_term):
|
||||
for key in doc_structure.keys():
|
||||
|
||||
if typeof(doc_structure[key]) == TYPE_DICTIONARY:
|
||||
var folder_item = _add_documentation_folder(tree, parent_item, {"name":key.get_file(), "path":key}, def_folder_info)
|
||||
create_doc_tree(tree, folder_item, def_folder_info, def_page_info, doc_structure[key], filter_term)
|
||||
if not filter_term:
|
||||
folder_item.collapsed = true
|
||||
|
||||
elif typeof(doc_structure[key]) == TYPE_ARRAY:
|
||||
for file in doc_structure[key]:
|
||||
if use_folder_files and file.trim_suffix(".md") in doc_structure.keys():
|
||||
pass
|
||||
else :
|
||||
if not filter_term or (filter_term and filter_term.to_lower() in get_title(file, "").to_lower()):
|
||||
_add_documentation_page(tree, parent_item, {"name":file.get_file().trim_suffix(".md"), "path":file}, def_page_info)
|
||||
|
||||
func merge_dir(target:Dictionary, patch:Dictionary):
|
||||
var copy = target.duplicate()
|
||||
for key in patch:
|
||||
copy[key] = patch[key]
|
||||
return copy
|
||||
|
||||
|
||||
func _add_documentation_folder(tree, parent_item, folder_info, default_info):
|
||||
var item = tree.create_item(parent_item)
|
||||
item.set_text(0, folder_info["name"])
|
||||
item.set_icon(0, tree.get_icon("HelpSearch", "EditorIcons"))
|
||||
item.set_editable(0, false)
|
||||
if use_folder_files:
|
||||
var x = File.new()
|
||||
if x.file_exists(folder_info["path"] + ".md"):
|
||||
folder_info["path"] += ".md"
|
||||
else :
|
||||
folder_info["path"] = ""
|
||||
else :
|
||||
folder_info["path"] = ""
|
||||
item.set_metadata(0, merge_dir(default_info, folder_info))
|
||||
if not tree.get_constant("dark_theme", "Editor"):
|
||||
item.set_icon_modulate(0, get_color("property_color", "Editor"))
|
||||
return item
|
||||
|
||||
|
||||
func _add_documentation_page(tree, parent, page_info, default_info):
|
||||
var item = tree.create_item(parent)
|
||||
item.set_text(0, get_title(page_info["path"], page_info["name"]))
|
||||
item.set_tooltip(0, page_info["path"])
|
||||
item.set_editable(0, false)
|
||||
item.set_icon(0, tree.get_icon("Help", "EditorIcons"))
|
||||
var new_dir = merge_dir(default_info, page_info)
|
||||
|
||||
item.set_metadata(0, new_dir)
|
||||
if not tree.get_constant("dark_theme", "Editor"):
|
||||
item.set_icon_modulate(0, get_color("property_color", "Editor"))
|
||||
return item
|
||||
|
||||
|
||||
func get_title(path, default_name):
|
||||
|
||||
var f = File.new()
|
||||
f.open(path, File.READ)
|
||||
var arr = f.get_as_text().split("\n", false, 1)
|
||||
if not arr.empty():
|
||||
return arr[0].trim_prefix("#").strip_edges()
|
||||
else :
|
||||
return default_name
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func search_and_select_docs(docs_tree_item:TreeItem, info:String, key:String = "path"):
|
||||
if info == "":return
|
||||
if info == "/":
|
||||
docs_tree_item.select(0)
|
||||
return true
|
||||
|
||||
|
||||
var item = docs_tree_item.get_children()
|
||||
while item:
|
||||
|
||||
if not item.has_method("get_metadata"):
|
||||
item = item.get_next()
|
||||
|
||||
var meta = item.get_metadata(0)
|
||||
|
||||
if meta.has(key):
|
||||
if meta[key] == info:
|
||||
item.select(0)
|
||||
return true
|
||||
if search_and_select_docs(item, info, key):
|
||||
return true
|
||||
item = item.get_next()
|
||||
return false
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
11
addons/dialogic/Documentation/Nodes/DocsTreeHelper.tscn
Normal file
11
addons/dialogic/Documentation/Nodes/DocsTreeHelper.tscn
Normal file
|
@ -0,0 +1,11 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/dialogic/Documentation/Nodes/DocsTreeHelper.gd" type="Script" id=1]
|
||||
|
||||
[node name="DocsTreeHelper" type="Control"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
32
addons/dialogic/Documentation/Nodes/DocumentationTree.gd
Normal file
32
addons/dialogic/Documentation/Nodes/DocumentationTree.gd
Normal file
|
@ -0,0 +1,32 @@
|
|||
tool
|
||||
extends Tree
|
||||
|
||||
var documentation_tree
|
||||
|
||||
|
||||
signal _page_selected(path)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func select_item(path):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func _ready():
|
||||
connect("item_selected", self, "_on_item_selected")
|
||||
|
||||
|
||||
documentation_tree.set_icon(0, get_icon("Folder", "EditorIcons"))
|
||||
|
||||
|
||||
func _on_item_selected():
|
||||
var item = get_selected()
|
||||
var metadata = item.get_metadata(0)
|
||||
if metadata.has("path"):
|
||||
emit_signal("_page_selected", metadata["path"])
|
14
addons/dialogic/Documentation/Nodes/DocumentationTree.tscn
Normal file
14
addons/dialogic/Documentation/Nodes/DocumentationTree.tscn
Normal file
|
@ -0,0 +1,14 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/dialogic/Documentation/Nodes/DocumentationTree.gd" type="Script" id=1]
|
||||
|
||||
|
||||
[node name="DocumentationTree" type="Tree"]
|
||||
margin_right = 506.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
21
addons/dialogic/Documentation/Nodes/DocumentationViewer.gd
Normal file
21
addons/dialogic/Documentation/Nodes/DocumentationViewer.gd
Normal file
|
@ -0,0 +1,21 @@
|
|||
tool
|
||||
extends Control
|
||||
|
||||
onready var DocTree = $HSplit / VBoxContainer / DocumentationTree
|
||||
onready var DocPageViewer = $HSplit / DocsPageViewer
|
||||
|
||||
|
||||
func _on_DocsPageViewer_open_non_html_link(link, section):
|
||||
DocTree.select_item(link)
|
||||
DocPageViewer.scroll_to_section(section)
|
||||
|
||||
func _on_DocumentationTree_page_selected(path):
|
||||
DocPageViewer.load_page(path)
|
||||
|
||||
func _on_FilterEntry_text_changed(new_text):
|
||||
var child = DocTree.documentation_tree.get_children()
|
||||
while child:
|
||||
child.call_recursive("call_deferred", "free")
|
||||
child = child.get_next()
|
||||
|
||||
DocTree.call_deferred("update")
|
49
addons/dialogic/Documentation/Nodes/DocumentationViewer.tscn
Normal file
49
addons/dialogic/Documentation/Nodes/DocumentationViewer.tscn
Normal file
|
@ -0,0 +1,49 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://addons/dialogic/Documentation/Nodes/DocsPageViewer.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/dialogic/Documentation/Nodes/DocumentationTree.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/dialogic/Documentation/Nodes/DocumentationViewer.gd" type="Script" id=3]
|
||||
|
||||
[node name="DocumentationViewer" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HSplit" type="HSplitContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HSplit"]
|
||||
margin_right = 230.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 0.3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="FilterEntry" type="LineEdit" parent="HSplit/VBoxContainer"]
|
||||
margin_right = 230.0
|
||||
margin_bottom = 24.0
|
||||
placeholder_text = "Filter Documentation"
|
||||
placeholder_alpha = 0.502
|
||||
|
||||
[node name="DocumentationTree" parent="HSplit/VBoxContainer" instance=ExtResource( 2 )]
|
||||
margin_top = 28.0
|
||||
margin_right = 230.0
|
||||
|
||||
[node name="DocsPageViewer" parent="HSplit" instance=ExtResource( 1 )]
|
||||
margin_left = 242.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[connection signal="text_changed" from="HSplit/VBoxContainer/FilterEntry" to="." method="_on_FilterEntry_text_changed"]
|
||||
[connection signal="open_non_html_link" from="HSplit/DocsPageViewer" to="." method="_on_DocsPageViewer_open_non_html_link"]
|
Loading…
Add table
Add a link
Reference in a new issue