Merge pull request #14348 from waldson/feature-set-main-screen-plugin-icon
Add method on EditorPlugin to set main screen plugins icons
This commit is contained in:
commit
cac5aa498f
3 changed files with 25 additions and 2 deletions
|
@ -338,8 +338,14 @@ void EditorNode::_notification(int p_what) {
|
|||
|
||||
//_update_icons
|
||||
for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
|
||||
Ref<Texture> icon = singleton->main_editor_buttons[i]->get_icon();
|
||||
|
||||
if (icon.is_valid()) {
|
||||
main_editor_buttons[i]->set_icon(icon);
|
||||
} else if (singleton->gui_base->has_icon(singleton->main_editor_buttons[i]->get_name(), "EditorIcons")) {
|
||||
main_editor_buttons[i]->set_icon(gui_base->get_icon(singleton->main_editor_buttons[i]->get_name(), "EditorIcons"));
|
||||
}
|
||||
}
|
||||
play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons"));
|
||||
play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
|
||||
play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
|
||||
|
@ -2673,7 +2679,14 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
|
|||
tb->set_toggle_mode(true);
|
||||
tb->connect("pressed", singleton, "_editor_select", varray(singleton->main_editor_buttons.size()));
|
||||
tb->set_text(p_editor->get_name());
|
||||
Ref<Texture> icon = p_editor->get_icon();
|
||||
|
||||
if (icon.is_valid()) {
|
||||
tb->set_icon(icon);
|
||||
} else if (singleton->gui_base->has_icon(p_editor->get_name(), "EditorIcons")) {
|
||||
tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons"));
|
||||
}
|
||||
|
||||
tb->set_name(p_editor->get_name());
|
||||
singleton->main_editor_buttons.push_back(tb);
|
||||
singleton->main_editor_button_vb->add_child(tb);
|
||||
|
|
|
@ -466,6 +466,14 @@ String EditorPlugin::get_name() const {
|
|||
|
||||
return String();
|
||||
}
|
||||
const Ref<Texture> EditorPlugin::get_icon() const {
|
||||
|
||||
if (get_script_instance() && get_script_instance()->has_method("get_plugin_icon")) {
|
||||
return get_script_instance()->call("get_plugin_icon");
|
||||
}
|
||||
|
||||
return Ref<Texture>();
|
||||
}
|
||||
bool EditorPlugin::has_main_screen() const {
|
||||
|
||||
if (get_script_instance() && get_script_instance()->has_method("has_main_screen")) {
|
||||
|
@ -644,6 +652,7 @@ void EditorPlugin::_bind_methods() {
|
|||
gizmo.return_val.hint_string = "EditorSpatialGizmo";
|
||||
ClassDB::add_virtual_method(get_class_static(), gizmo);
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name"));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::OBJECT, "get_plugin_icon"));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "has_main_screen"));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("make_visible", PropertyInfo(Variant::BOOL, "visible")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("edit", PropertyInfo(Variant::OBJECT, "object")));
|
||||
|
|
|
@ -165,6 +165,7 @@ public:
|
|||
virtual void forward_force_draw_over_viewport(Control *p_overlay);
|
||||
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
|
||||
virtual String get_name() const;
|
||||
virtual const Ref<Texture> get_icon() const;
|
||||
virtual bool has_main_screen() const;
|
||||
virtual void make_visible(bool p_visible);
|
||||
virtual void selected_notify() {} //notify that it was raised by the user, not the editor
|
||||
|
|
Loading…
Reference in a new issue