summaryrefslogtreecommitdiff
path: root/editor/editor_run_native.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_run_native.cpp')
-rw-r--r--editor/editor_run_native.cpp91
1 files changed, 48 insertions, 43 deletions
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp
index 5e27598307..fa835ef76a 100644
--- a/editor/editor_run_native.cpp
+++ b/editor/editor_run_native.cpp
@@ -29,18 +29,15 @@
#include "editor_run_native.h"
#include "editor_export.h"
+#include "editor_node.h"
void EditorRunNative::_notification(int p_what) {
-#if 0
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ 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()) {
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
- Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(E->get());
+ Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(i);
if (eep.is_null())
continue;
Ref<ImageTexture> icon = eep->get_logo();
@@ -49,85 +46,93 @@ void EditorRunNative::_notification(int p_what) {
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("id_pressed",this,"_run_native",varray(E->get()));
- mb->connect("pressed",this,"_run_native",varray(-1, E->get()));
+ im.resize(16, 16);
+ 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[E->get()]=mb;
+ menus[i] = mb;
}
}
}
}
- if (p_what==NOTIFICATION_PROCESS) {
-
+ if (p_what == NOTIFICATION_PROCESS) {
- bool changed = EditorImportExport::get_singleton()->poll_export_platforms() || first;
+ bool changed = EditorExport::get_singleton()->poll_export_platforms() || first;
if (changed) {
- for(Map<StringName,MenuButton*>::Element *E=menus.front();E;E=E->next()) {
+ for (Map<int, MenuButton *>::Element *E = menus.front(); E; E = E->next()) {
- Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(E->key());
+ Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E->key());
MenuButton *mb = E->get();
int dc = eep->get_device_count();
- if (dc==0) {
+ if (dc == 0) {
mb->hide();
} else {
mb->get_popup()->clear();
mb->show();
- if (dc == 1) {
- mb->set_tooltip(eep->get_device_name(0) + "\n\n" + eep->get_device_info(0).strip_edges());
- } else {
- mb->set_tooltip("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());
- }
+ mb->set_tooltip("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;
+ first = false;
}
}
-#endif
}
-void EditorRunNative::_run_native(int p_idx, const String &p_platform) {
+void EditorRunNative::_run_native(int p_idx, int p_platform) {
-#if 0
- Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(p_platform);
+ Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(p_platform);
ERR_FAIL_COND(eep.is_null());
- if (p_idx == -1) {
+ /*if (p_idx == -1) {
if (eep->get_device_count() == 1) {
menus[p_platform]->get_popup()->hide();
p_idx = 0;
} else {
return;
}
+ }*/
+
+ Ref<EditorExportPreset> preset;
+
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
+
+ Ref<EditorExportPreset> ep = EditorExport::get_singleton()->get_export_preset(i);
+ if (ep->is_runnable() && ep->get_platform() == eep) {
+ preset = ep;
+ break;
+ }
+ }
+
+ if (preset.is_null()) {
+ EditorNode::get_singleton()->show_warning("No runnable export preset found for this platform.\nPlease add a runnable preset in the export menu.");
+ return;
}
+
emit_signal("native_run");
- int flags=0;
+ int flags = 0;
if (deploy_debug_remote)
- flags|=EditorExportPlatform::EXPORT_REMOTE_DEBUG;
+ flags |= EditorExportPlatform::DEBUG_FLAG_REMOTE_DEBUG;
if (deploy_dumb)
- flags|=EditorExportPlatform::EXPORT_DUMB_CLIENT;
+ flags |= EditorExportPlatform::DEBUG_FLAG_DUMB_CLIENT;
if (debug_collisions)
- flags|=EditorExportPlatform::EXPORT_VIEW_COLLISONS;
+ flags |= EditorExportPlatform::DEBUG_FLAG_VIEW_COLLISONS;
if (debug_navigation)
- flags|=EditorExportPlatform::EXPORT_VIEW_NAVIGATION;
-
- eep->run(p_idx,flags);
+ flags |= EditorExportPlatform::DEBUG_FLAG_VIEW_NAVIGATION;
-#endif
+ eep->run(preset, p_idx, flags);
}
void EditorRunNative::_bind_methods() {