4 ## A Main page in the dialogic editor.
10 func _get_icon() -> Texture:
11 return load("res://addons/dialogic/Editor/Images/plugin-icon.svg")
14 func _ready() -> void:
15 self_modulate = get_theme_color("font_color", "Editor")
18 var edit_scale := DialogicUtil.get_editor_scale()
19 %HomePageBox.custom_minimum_size = Vector2(600, 350)*edit_scale
20 %TopPanel.custom_minimum_size.y = 100*edit_scale
21 %VersionLabel.set('theme_override_font_sizes/font_size', 10 * edit_scale)
22 var plugin_cfg := ConfigFile.new()
23 plugin_cfg.load("res://addons/dialogic/plugin.cfg")
24 %VersionLabel.text = plugin_cfg.get_value('plugin', 'version', 'unknown version')
26 %BottomPanel.self_modulate = get_theme_color("dark_color_3", "Editor")
28 %RandomTipLabel.add_theme_color_override("font_color", get_theme_color("property_color_z", "Editor"))
29 %RandomTipMoreButton.icon = get_theme_icon("ExternalLink", "EditorIcons")
33 func _register() -> void:
34 editors_manager.register_simple_editor(self)
36 self.alternative_text = "Welcome to dialogic!"
40 func _open(extra_info:Variant="") -> void:
42 var file := FileAccess.open('res://addons/dialogic/Editor/HomePage/tips.txt', FileAccess.READ)
43 tips = file.get_as_text().split('\n')
44 tips = tips.filter(func(item): return !item.is_empty())
47 var tip: String = tips[randi()%len(tips)]
48 var text := tip.get_slice(';',0).strip_edges()
49 var action := tip.get_slice(';',1).strip_edges()
52 show_tip(text, action)
55 func show_tip(text:String='', action:String='') -> void:
58 %RandomTipLabel.hide()
62 %RandomTipLabel.show()
63 %RandomTip.text = '[i]'+text
66 %RandomTipMoreButton.hide()
69 %RandomTipMoreButton.show()
71 if %RandomTipMoreButton.pressed.is_connected(_on_tip_action):
72 %RandomTipMoreButton.pressed.disconnect(_on_tip_action)
73 %RandomTipMoreButton.pressed.connect(_on_tip_action.bind(action))
76 func _on_tip_action(action:String) -> void:
77 if action.begins_with('https://'):
80 elif action.begins_with('editor://'):
81 var editor_name := action.trim_prefix('editor://').get_slice('->',0)
82 var extra_info := action.trim_prefix('editor://').get_slice('->',1)
83 if editor_name in editors_manager.editors:
84 editors_manager.open_editor(editors_manager.editors[editor_name].node, false, extra_info)
86 print("Tip button doesn't do anything (", action, ")")