void EditorRunNative::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(i); if (eep.is_null()) continue; Ref<ImageTexture> icon = eep->get_run_icon(); if (!icon.is_null()) { Ref<Image> im = icon->get_data(); im = im->duplicate(); im->clear_mipmaps(); if (!im->empty()) { im->resize(16 * EDSCALE, 16 * EDSCALE); Ref<ImageTexture> small_icon; small_icon.instance(); small_icon->create_from_image(im, 0); MenuButton *mb = memnew(MenuButton); mb->get_popup()->connect("id_pressed", this, "_run_native", varray(i)); //mb->connect("pressed", this, "_run_native", varray(-1, i)); mb->set_icon(small_icon); add_child(mb); menus[i] = mb; } } } } if (p_what == NOTIFICATION_PROCESS) { bool changed = EditorExport::get_singleton()->poll_export_platforms() || first; if (changed) { for (Map<int, MenuButton *>::Element *E = menus.front(); E; E = E->next()) { Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E->key()); MenuButton *mb = E->get(); int dc = eep->get_device_count(); if (dc == 0) { mb->hide(); } else { mb->get_popup()->clear(); mb->show(); mb->set_tooltip(TTR("Select device from the list")); for (int i = 0; i < dc; i++) { mb->get_popup()->add_icon_item(get_icon("Play", "EditorIcons"), eep->get_device_name(i)); mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() - 1, eep->get_device_info(i).strip_edges()); } } } first = false; } } }
void EditorRunNative::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { List<StringName> ep; EditorImportExport::get_singleton()->get_export_platforms(&ep); ep.sort_custom<StringName::AlphCompare>(); for(List<StringName>::Element *E=ep.front();E;E=E->next()) { Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(E->get()); if (eep.is_null()) continue; Ref<ImageTexture> icon = eep->get_logo(); if (!icon.is_null()) { Image im = icon->get_data(); im.clear_mipmaps(); if (!im.empty()) { im.resize(16,16); Ref<ImageTexture> small_icon = memnew( ImageTexture); small_icon->create_from_image(im); MenuButton *mb = memnew( MenuButton ); mb->get_popup()->connect("item_pressed",this,"_run_native",varray(E->get())); mb->set_icon(small_icon); add_child(mb); menus[E->get()]=mb; } } } } if (p_what==NOTIFICATION_PROCESS) { bool changed = EditorImportExport::get_singleton()->poll_export_platforms() || first; if (changed) { for(Map<StringName,MenuButton*>::Element *E=menus.front();E;E=E->next()) { Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(E->key()); MenuButton *mb = E->get(); int dc = eep->get_device_count(); if (dc==0) { mb->hide(); } else { mb->get_popup()->clear(); mb->show(); for(int i=0;i<dc;i++) { mb->get_popup()->add_icon_item(get_icon("Play","EditorIcons"),eep->get_device_name(i)); mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() -1,eep->get_device_info(i)); } } } first=false; } } }