Improve EditorExportPlatform interface.
Convert all get_device* methods to get_option* and normalize their usage as icon, label, tooltip.
This commit is contained in:
parent
2ae3631318
commit
53637e4b1c
|
@ -376,6 +376,12 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat
|
|||
return OK;
|
||||
}
|
||||
|
||||
Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const {
|
||||
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
|
||||
ERR_FAIL_COND_V(theme.is_null(), Ref<ImageTexture>());
|
||||
return theme->get_icon("Play", "EditorIcons");
|
||||
}
|
||||
|
||||
String EditorExportPlatform::find_export_template(String template_file_name, String *err) const {
|
||||
|
||||
String current_version = VERSION_FULL_CONFIG;
|
||||
|
@ -1403,7 +1409,7 @@ bool EditorExport::poll_export_platforms() {
|
|||
|
||||
bool changed = false;
|
||||
for (int i = 0; i < export_platforms.size(); i++) {
|
||||
if (export_platforms.write[i]->poll_devices()) {
|
||||
if (export_platforms.write[i]->poll_export()) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,10 +243,12 @@ public:
|
|||
Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files = NULL, bool p_embed = false, int64_t *r_embedded_start = NULL, int64_t *r_embedded_size = NULL);
|
||||
Error save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path);
|
||||
|
||||
virtual bool poll_devices() { return false; }
|
||||
virtual int get_device_count() const { return 0; }
|
||||
virtual String get_device_name(int p_device) const { return ""; }
|
||||
virtual String get_device_info(int p_device) const { return ""; }
|
||||
virtual bool poll_export() { return false; }
|
||||
virtual int get_options_count() const { return 0; }
|
||||
virtual String get_options_tooltip() const { return ""; }
|
||||
virtual Ref<ImageTexture> get_option_icon(int p_index) const;
|
||||
virtual String get_option_label(int p_device) const { return ""; }
|
||||
virtual String get_option_tooltip(int p_device) const { return ""; }
|
||||
|
||||
enum DebugFlags {
|
||||
DEBUG_FLAG_DUMB_CLIENT = 1,
|
||||
|
|
|
@ -75,20 +75,18 @@ void EditorRunNative::_notification(int p_what) {
|
|||
|
||||
Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E->key());
|
||||
MenuButton *mb = E->get();
|
||||
int dc = eep->get_device_count();
|
||||
int dc = eep->get_options_count();
|
||||
|
||||
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");
|
||||
mb->set_tooltip(eep->get_options_tooltip());
|
||||
if (dc > 1) {
|
||||
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->get_popup()->add_icon_item(eep->get_option_icon(i), eep->get_option_label(i));
|
||||
mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() - 1, eep->get_option_tooltip(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +109,7 @@ void EditorRunNative::_run_native(int p_idx, int p_platform) {
|
|||
ERR_FAIL_COND(eep.is_null());
|
||||
|
||||
if (p_idx == -1) {
|
||||
if (eep->get_device_count() == 1) {
|
||||
if (eep->get_options_count() == 1) {
|
||||
menus[p_platform]->get_popup()->hide();
|
||||
p_idx = 0;
|
||||
} else {
|
||||
|
|
|
@ -1345,7 +1345,7 @@ public:
|
|||
return logo;
|
||||
}
|
||||
|
||||
virtual bool poll_devices() {
|
||||
virtual bool poll_export() {
|
||||
|
||||
bool dc = devices_changed;
|
||||
if (dc) {
|
||||
|
@ -1355,7 +1355,7 @@ public:
|
|||
return dc;
|
||||
}
|
||||
|
||||
virtual int get_device_count() const {
|
||||
virtual int get_options_count() const {
|
||||
|
||||
device_lock->lock();
|
||||
int dc = devices.size();
|
||||
|
@ -1364,20 +1364,31 @@ public:
|
|||
return dc;
|
||||
}
|
||||
|
||||
virtual String get_device_name(int p_device) const {
|
||||
virtual String get_options_tooltip() const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_device, devices.size(), "");
|
||||
return TTR("Select device from the list");
|
||||
}
|
||||
|
||||
virtual String get_option_label(int p_index) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_index, devices.size(), "");
|
||||
device_lock->lock();
|
||||
String s = devices[p_device].name;
|
||||
String s = devices[p_index].name;
|
||||
device_lock->unlock();
|
||||
return s;
|
||||
}
|
||||
|
||||
virtual String get_device_info(int p_device) const {
|
||||
virtual String get_option_tooltip(int p_index) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_device, devices.size(), "");
|
||||
ERR_FAIL_INDEX_V(p_index, devices.size(), "");
|
||||
device_lock->lock();
|
||||
String s = devices[p_device].description;
|
||||
String s = devices[p_index].description;
|
||||
if (devices.size() == 1) {
|
||||
// Tooltip will be:
|
||||
// Name
|
||||
// Description
|
||||
s = devices[p_index].name + "\n\n" + s;
|
||||
}
|
||||
device_lock->unlock();
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -61,11 +61,11 @@ public:
|
|||
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const;
|
||||
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
|
||||
|
||||
virtual bool poll_devices();
|
||||
virtual int get_device_count() const;
|
||||
virtual String get_device_name(int p_device) const { return TTR("Run in Browser"); }
|
||||
virtual String get_device_info(int p_device) const { return TTR("Run exported HTML in the system's default browser."); }
|
||||
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags);
|
||||
virtual bool poll_export();
|
||||
virtual int get_options_count() const;
|
||||
virtual String get_options_name(int p_index) const { return p_index ? TTR("Stop HTTP Server") : TTR("Run in Browser"); }
|
||||
virtual String get_option_tooltip(int p_index) const { return p_index ? TTR("Stop HTTP Server") : TTR("Run exported HTML in the system's default browser."); }
|
||||
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_option, int p_debug_flags);
|
||||
virtual Ref<Texture> get_run_icon() const;
|
||||
|
||||
virtual void get_platform_features(List<String> *r_features) {
|
||||
|
@ -337,7 +337,7 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
|
|||
return OK;
|
||||
}
|
||||
|
||||
bool EditorExportPlatformJavaScript::poll_devices() {
|
||||
bool EditorExportPlatformJavaScript::poll_export() {
|
||||
|
||||
Ref<EditorExportPreset> preset;
|
||||
|
||||
|
@ -355,12 +355,12 @@ bool EditorExportPlatformJavaScript::poll_devices() {
|
|||
return runnable_when_last_polled != prev;
|
||||
}
|
||||
|
||||
int EditorExportPlatformJavaScript::get_device_count() const {
|
||||
int EditorExportPlatformJavaScript::get_options_count() const {
|
||||
|
||||
return runnable_when_last_polled;
|
||||
}
|
||||
|
||||
Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) {
|
||||
Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_preset, int p_option, int p_debug_flags) {
|
||||
|
||||
String basepath = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_js_export");
|
||||
String path = basepath + ".html";
|
||||
|
|
Loading…
Reference in New Issue