Export template management dialog.

Missing download (need to discuss this!)
This commit is contained in:
Juan Linietsky 2017-03-20 23:31:41 -03:00
parent 33a2c5def0
commit b5a06cecff
12 changed files with 543 additions and 105 deletions

View File

@ -51,7 +51,7 @@ static int _get_pad(int p_alignment, int p_n) {
};
return pad;
};
}
#define PCK_PADDING 16
@ -870,6 +870,7 @@ bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset,
} else if (find_export_template(debug_file_64) == String()) {
r_missing_templates = true;
}
return !r_missing_templates;
}

View File

@ -1201,78 +1201,9 @@ void EditorNode::_dialog_action(String p_file) {
}
} break;
case SETTINGS_LOAD_EXPORT_TEMPLATES: {
// case SETTINGS_LOAD_EXPORT_TEMPLATES: {
FileAccess *fa = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&fa);
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
if (!pkg) {
current_option = -1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Can't open export templates zip."));
accept->popup_centered_minsize();
return;
}
int ret = unzGoToFirstFile(pkg);
int fc = 0; //count them
while (ret == UNZ_OK) {
fc++;
ret = unzGoToNextFile(pkg);
}
ret = unzGoToFirstFile(pkg);
EditorProgress p("ltask", TTR("Loading Export Templates"), fc);
fc = 0;
while (ret == UNZ_OK) {
//get filename
unz_file_info info;
char fname[16384];
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
String file = fname;
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
//read
ret = unzOpenCurrentFile(pkg);
ret = unzReadCurrentFile(pkg, data.ptr(), data.size());
unzCloseCurrentFile(pkg);
print_line(fname);
/*
for(int i=0;i<512;i++) {
print_line(itos(data[i]));
}
*/
file = file.get_file();
p.step(TTR("Importing:") + " " + file, fc);
FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_settings_path() + "/templates/" + file, FileAccess::WRITE);
ERR_CONTINUE(!f);
f->store_buffer(data.ptr(), data.size());
memdelete(f);
ret = unzGoToNextFile(pkg);
fc++;
}
unzClose(pkg);
} break;
// } break;
case RESOURCE_SAVE:
case RESOURCE_SAVE_AS: {
@ -2604,9 +2535,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
//optimized_presets->popup_centered_ratio();
} break;
case SETTINGS_LOAD_EXPORT_TEMPLATES: {
case SETTINGS_MANAGE_EXPORT_TEMPLATES: {
file_templates->popup_centered_ratio();
export_template_manager->popup_manager();
} break;
case SETTINGS_TOGGLE_FULLSCREN: {
@ -4759,6 +4690,11 @@ void EditorNode::_dim_timeout() {
}
}
void EditorNode::open_export_template_manager() {
export_template_manager->popup_manager();
}
void EditorNode::_bind_methods() {
ClassDB::bind_method("_menu_option", &EditorNode::_menu_option);
@ -5529,7 +5465,7 @@ EditorNode::EditorNode() {
p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_SHIFT | KEY_F11), SETTINGS_TOGGLE_FULLSCREN);
p->add_separator();
p->add_item(TTR("Install Export Templates"), SETTINGS_LOAD_EXPORT_TEMPLATES);
p->add_item(TTR("Manage Export Templates"), SETTINGS_MANAGE_EXPORT_TEMPLATES);
p->add_separator();
p->add_item(TTR("About"), SETTINGS_ABOUT);
@ -5855,6 +5791,9 @@ EditorNode::EditorNode() {
run_settings_dialog = memnew(RunSettingsDialog);
gui_base->add_child(run_settings_dialog);
export_template_manager = memnew(ExportTemplateManager);
gui_base->add_child(export_template_manager);
about = memnew(AcceptDialog);
about->set_title(TTR("Thanks from the Godot community!"));
about->get_ok()->set_text(TTR("Thanks!"));

View File

@ -35,6 +35,7 @@
#include "editor/editor_data.h"
#include "editor/editor_path.h"
#include "editor/editor_run.h"
#include "editor/export_template_manager.h"
#include "editor/filesystem_dock.h"
#include "editor/groups_editor.h"
#include "editor/import_dock.h"
@ -180,7 +181,7 @@ private:
SETTINGS_LAYOUT_SAVE,
SETTINGS_LAYOUT_DELETE,
SETTINGS_LAYOUT_DEFAULT,
SETTINGS_LOAD_EXPORT_TEMPLATES,
SETTINGS_MANAGE_EXPORT_TEMPLATES,
SETTINGS_PICK_MAIN_SCENE,
SETTINGS_TOGGLE_FULLSCREN,
SETTINGS_HELP,
@ -300,6 +301,7 @@ private:
RunSettingsDialog *run_settings_dialog;
ProjectSettings *project_settings;
EditorFileDialog *file;
ExportTemplateManager *export_template_manager;
FileDialog *file_templates;
FileDialog *file_export;
FileDialog *file_export_lib;
@ -739,6 +741,8 @@ public:
void update_keying();
void open_export_template_manager();
void reload_scene(const String &p_path);
bool is_exiting() const { return exiting; }

View File

@ -0,0 +1,395 @@
#include "export_template_manager.h"
#include "editor_node.h"
#include "editor_scale.h"
#include "os/dir_access.h"
#include "version.h"
#include "io/zip_io.h"
void ExportTemplateManager::_update_template_list() {
while (current_hb->get_child_count()) {
memdelete(current_hb->get_child(0));
}
while (installed_vb->get_child_count()) {
memdelete(installed_vb->get_child(0));
}
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = d->change_dir(EditorSettings::get_singleton()->get_settings_path().plus_file("templates"));
d->list_dir_begin();
Set<String> templates;
if (err == OK) {
bool isdir;
String c = d->get_next(&isdir);
while (c != String()) {
if (isdir && !c.begins_with(".")) {
templates.insert(c);
}
c = d->get_next(&isdir);
}
}
d->list_dir_end();
memdelete(d);
String current_version = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + _MKSTR(VERSION_STATUS);
Label *current = memnew(Label);
current->set_h_size_flags(SIZE_EXPAND_FILL);
current_hb->add_child(current);
if (templates.has(current_version)) {
current->add_color_override("font_color", Color(0.5, 1, 0.5));
Button *redownload = memnew(Button);
redownload->set_text(TTR("Re-Download"));
current_hb->add_child(redownload);
redownload->connect("pressed", this, "_download_template", varray(current_version));
Button *uninstall = memnew(Button);
uninstall->set_text(TTR("Uninstall"));
current_hb->add_child(uninstall);
current->set_text(current_version + " " + TTR("(Installed)"));
uninstall->connect("pressed", this, "_uninstall_template", varray(current_version));
} else {
current->add_color_override("font_color", Color(1.0, 0.5, 0.5));
Button *redownload = memnew(Button);
redownload->set_text(TTR("Download"));
redownload->connect("pressed", this, "_download_template", varray(current_version));
current_hb->add_child(redownload);
current->set_text(current_version + " " + TTR("(Missing)"));
}
for (Set<String>::Element *E = templates.back(); E; E = E->prev()) {
HBoxContainer *hbc = memnew(HBoxContainer);
Label *version = memnew(Label);
version->set_modulate(Color(1, 1, 1, 0.7));
String text = E->get();
if (text == current_version) {
text += " " + TTR("(Current)");
}
version->set_text(text);
version->set_h_size_flags(SIZE_EXPAND_FILL);
hbc->add_child(version);
Button *uninstall = memnew(Button);
uninstall->set_text(TTR("Uninstall"));
hbc->add_child(uninstall);
uninstall->connect("pressed", this, "_uninstall_template", varray(E->get()));
installed_vb->add_child(hbc);
}
}
void ExportTemplateManager::_download_template(const String &p_version) {
print_line("download " + p_version);
}
void ExportTemplateManager::_uninstall_template(const String &p_version) {
remove_confirm->set_text(vformat(TTR("Remove template version '%s'?"), p_version));
remove_confirm->popup_centered_minsize();
to_remove = p_version;
}
void ExportTemplateManager::_uninstall_template_confirm() {
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = d->change_dir(EditorSettings::get_singleton()->get_settings_path().plus_file("templates"));
ERR_FAIL_COND(err != OK);
err = d->change_dir(to_remove);
ERR_FAIL_COND(err != OK);
Vector<String> files;
d->list_dir_begin();
bool isdir;
String c = d->get_next(&isdir);
while (c != String()) {
if (!isdir) {
files.push_back(c);
}
c = d->get_next(&isdir);
}
d->list_dir_end();
for (int i = 0; i < files.size(); i++) {
d->remove(files[i]);
}
d->change_dir("..");
d->remove(to_remove);
_update_template_list();
}
void ExportTemplateManager::_install_from_file(const String &p_file) {
FileAccess *fa = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&fa);
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
if (!pkg) {
EditorNode::get_singleton()->show_warning(TTR("Can't open export templates zip."));
return;
}
int ret = unzGoToFirstFile(pkg);
int fc = 0; //count them and find version
String version;
while (ret == UNZ_OK) {
unz_file_info info;
char fname[16384];
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
String file = fname;
if (file.ends_with("version.txt")) {
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
//read
ret = unzOpenCurrentFile(pkg);
ret = unzReadCurrentFile(pkg, data.ptr(), data.size());
unzCloseCurrentFile(pkg);
String data_str;
data_str.parse_utf8((const char *)data.ptr(), data.size());
data_str = data_str.strip_edges();
if (data_str.get_slice_count("-") != 2 || data_str.get_slice_count(".") != 2) {
EditorNode::get_singleton()->show_warning(TTR("Invalid version.txt format inside templates."));
unzClose(pkg);
return;
}
String ver = data_str.get_slice("-", 0);
int major = ver.get_slice(".", 0).to_int();
int minor = ver.get_slice(".", 1).to_int();
String rev = data_str.get_slice("-", 1);
if (!rev.is_valid_identifier()) {
EditorNode::get_singleton()->show_warning(TTR("Invalid version.txt format inside templates. Revision is not a valid identifier."));
unzClose(pkg);
return;
}
version = itos(major) + "." + itos(minor) + "-" + rev;
}
fc++;
ret = unzGoToNextFile(pkg);
}
if (version == String()) {
EditorNode::get_singleton()->show_warning(TTR("No version.txt found inside templates."));
unzClose(pkg);
return;
}
String template_path = EditorSettings::get_singleton()->get_settings_path().plus_file("templates").plus_file(version);
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = d->make_dir_recursive(template_path);
if (err != OK) {
EditorNode::get_singleton()->show_warning(TTR("Error creating path for templates:\n") + template_path);
unzClose(pkg);
return;
}
memdelete(d);
ret = unzGoToFirstFile(pkg);
EditorProgress p("ltask", TTR("Extracting Export Templates"), fc);
fc = 0;
while (ret == UNZ_OK) {
//get filename
unz_file_info info;
char fname[16384];
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
String file = fname;
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
//read
ret = unzOpenCurrentFile(pkg);
ret = unzReadCurrentFile(pkg, data.ptr(), data.size());
unzCloseCurrentFile(pkg);
print_line(fname);
/*
for(int i=0;i<512;i++) {
print_line(itos(data[i]));
}
*/
file = file.get_file();
p.step(TTR("Importing:") + " " + file, fc);
FileAccess *f = FileAccess::open(template_path.plus_file(file), FileAccess::WRITE);
ERR_CONTINUE(!f);
f->store_buffer(data.ptr(), data.size());
memdelete(f);
ret = unzGoToNextFile(pkg);
fc++;
}
unzClose(pkg);
_update_template_list();
}
void ExportTemplateManager::popup_manager() {
_update_template_list();
popup_centered_minsize(Size2(400, 600) * EDSCALE);
}
void ExportTemplateManager::ok_pressed() {
template_open->popup_centered_ratio();
}
void ExportTemplateManager::_bind_methods() {
ClassDB::bind_method("_download_template", &ExportTemplateManager::_download_template);
ClassDB::bind_method("_uninstall_template", &ExportTemplateManager::_uninstall_template);
ClassDB::bind_method("_uninstall_template_confirm", &ExportTemplateManager::_uninstall_template_confirm);
ClassDB::bind_method("_install_from_file", &ExportTemplateManager::_install_from_file);
#if 0
FileAccess *fa = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&fa);
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
if (!pkg) {
current_option = -1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Can't open export templates zip."));
accept->popup_centered_minsize();
return;
}
int ret = unzGoToFirstFile(pkg);
int fc = 0; //count them
while (ret == UNZ_OK) {
fc++;
ret = unzGoToNextFile(pkg);
}
ret = unzGoToFirstFile(pkg);
EditorProgress p("ltask", TTR("Loading Export Templates"), fc);
fc = 0;
while (ret == UNZ_OK) {
//get filename
unz_file_info info;
char fname[16384];
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
String file = fname;
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
//read
ret = unzOpenCurrentFile(pkg);
ret = unzReadCurrentFile(pkg, data.ptr(), data.size());
unzCloseCurrentFile(pkg);
print_line(fname);
/*
for(int i=0;i<512;i++) {
print_line(itos(data[i]));
}
*/
file = file.get_file();
p.step(TTR("Importing:") + " " + file, fc);
FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_settings_path() + "/templates/" + file, FileAccess::WRITE);
ERR_CONTINUE(!f);
f->store_buffer(data.ptr(), data.size());
memdelete(f);
ret = unzGoToNextFile(pkg);
fc++;
}
unzClose(pkg);
#endif
}
ExportTemplateManager::ExportTemplateManager() {
VBoxContainer *main_vb = memnew(VBoxContainer);
add_child(main_vb);
current_hb = memnew(HBoxContainer);
main_vb->add_margin_child(TTR("Current Version:"), current_hb, false);
installed_scroll = memnew(ScrollContainer);
main_vb->add_margin_child(TTR("Installed Versions:"), installed_scroll, true);
installed_vb = memnew(VBoxContainer);
installed_scroll->add_child(installed_vb);
installed_scroll->set_enable_v_scroll(true);
installed_scroll->set_enable_h_scroll(false);
installed_vb->set_h_size_flags(SIZE_EXPAND_FILL);
get_cancel()->set_text(TTR("Close"));
get_ok()->set_text(TTR("Install From File"));
remove_confirm = memnew(ConfirmationDialog);
remove_confirm->set_title(TTR("Remove Template"));
add_child(remove_confirm);
remove_confirm->connect("confirmed", this, "_uninstall_template_confirm");
template_open = memnew(FileDialog);
template_open->set_title(TTR("Select template file"));
template_open->add_filter("*.tpz ; Godot Export Templates");
template_open->set_access(FileDialog::ACCESS_FILESYSTEM);
template_open->set_mode(FileDialog::MODE_OPEN_FILE);
template_open->connect("file_selected", this, "_install_from_file");
add_child(template_open);
set_title(TTR("Export Template Manager"));
set_hide_on_ok(false);
}

View File

@ -0,0 +1,40 @@
#ifndef EXPORT_TEMPLATE_MANAGER_H
#define EXPORT_TEMPLATE_MANAGER_H
#include "editor/editor_settings.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/scroll_container.h"
class ExportTemplateVersion;
class ExportTemplateManager : public ConfirmationDialog {
GDCLASS(ExportTemplateManager, ConfirmationDialog)
ScrollContainer *installed_scroll;
VBoxContainer *installed_vb;
HBoxContainer *current_hb;
FileDialog *template_open;
ConfirmationDialog *remove_confirm;
String to_remove;
void _update_template_list();
void _download_template(const String &p_version);
void _uninstall_template(const String &p_version);
void _uninstall_template_confirm();
virtual void ok_pressed();
void _install_from_file(const String &p_file);
protected:
static void _bind_methods();
public:
void popup_manager();
ExportTemplateManager();
};
#endif // EXPORT_TEMPLATE_MANAGER_H

View File

@ -155,6 +155,8 @@ void ProjectExportDialog::_edit_preset(int p_index) {
delete_preset->set_disabled(true);
sections->hide();
patches->clear();
export_error->hide();
export_templates_error->hide();
return;
}
@ -205,6 +207,33 @@ void ProjectExportDialog::_edit_preset(int p_index) {
_fill_resource_tree();
bool needs_templates;
String error;
if (!current->get_platform()->can_export(current, error, needs_templates)) {
if (error != String()) {
Vector<String> items = error.split("\n");
error = "";
for (int i = 0; i < items.size(); i++) {
if (i > 0)
error += "\n";
error += " - " + items[i];
}
export_error->set_text(error);
export_error->show();
} else {
export_error->hide();
}
if (needs_templates)
export_templates_error->show();
} else {
export_error->show();
export_templates_error->hide();
}
updating = false;
}
@ -607,6 +636,12 @@ void ProjectExportDialog::_export_pck_zip_selected(const String &p_path) {
}
}
void ProjectExportDialog::_open_export_template_manager() {
EditorNode::get_singleton()->open_export_template_manager();
hide();
}
void ProjectExportDialog::_bind_methods() {
ClassDB::bind_method("_add_preset", &ProjectExportDialog::_add_preset);
@ -627,14 +662,18 @@ void ProjectExportDialog::_bind_methods() {
ClassDB::bind_method("_patch_edited", &ProjectExportDialog::_patch_edited);
ClassDB::bind_method("_export_pck_zip", &ProjectExportDialog::_export_pck_zip);
ClassDB::bind_method("_export_pck_zip_selected", &ProjectExportDialog::_export_pck_zip_selected);
ClassDB::bind_method("_open_export_template_manager", &ProjectExportDialog::_open_export_template_manager);
}
ProjectExportDialog::ProjectExportDialog() {
set_title(TTR("Export"));
set_resizable(true);
VBoxContainer *main_vb = memnew(VBoxContainer);
add_child(main_vb);
HBoxContainer *hbox = memnew(HBoxContainer);
add_child(hbox);
main_vb->add_child(hbox);
hbox->set_v_size_flags(SIZE_EXPAND_FILL);
VBoxContainer *preset_vb = memnew(VBoxContainer);
preset_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@ -770,6 +809,25 @@ ProjectExportDialog::ProjectExportDialog() {
add_child(export_pck_zip);
export_pck_zip->connect("file_selected", this, "_export_pck_zip_selected");
export_error = memnew(Label);
main_vb->add_child(export_error);
export_error->hide();
export_error->add_color_override("font_color", Color(1, 0.5, 0.5));
export_templates_error = memnew(HBoxContainer);
main_vb->add_child(export_templates_error);
export_templates_error->hide();
Label *export_error2 = memnew(Label);
export_templates_error->add_child(export_error2);
export_error2->add_color_override("font_color", Color(1, 0.5, 0.5));
export_error2->set_text(" - " + TTR("Export templates for this platform are missing:") + " ");
LinkButton *download_templates = memnew(LinkButton);
download_templates->set_text(TTR("Manage Export Templates"));
export_templates_error->add_child(download_templates);
download_templates->connect("pressed", this, "_open_export_template_manager");
set_hide_on_ok(false);
editor_icons = "EditorIcons";

View File

@ -37,6 +37,7 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/label.h"
#include "scene/gui/link_button.h"
#include "scene/gui/option_button.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/tree.h"
@ -89,6 +90,9 @@ private:
Button *export_button;
Label *export_error;
HBoxContainer *export_templates_error;
void _patch_selected(const String &p_path);
void _patch_deleted();
@ -116,6 +120,8 @@ private:
FileDialog *export_pck_zip;
void _open_export_template_manager();
void _export_pck_zip();
void _export_pck_zip_selected(const String &p_path);

View File

@ -19,8 +19,8 @@ android_files = [
'android_native_app_glue.c',
'java_glue.cpp',
'cpu-features.c',
'java_class_wrapper.cpp'
'power_android.cpp'
'java_class_wrapper.cpp',
# 'power_android.cpp'
]
# env.Depends('#core/math/vector3.h', 'vector3_psp.h')

View File

@ -26,7 +26,7 @@ def get_opts():
return [
('ANDROID_NDK_ROOT', 'the path to Android NDK',
os.environ.get("ANDROID_NDK_ROOT", 0)),
('ndk_platform', 'compile for platform: (android-<api> , example: android-14)', "android-14"),
('ndk_platform', 'compile for platform: (android-<api> , example: android-18)', "android-18"),
('android_arch', 'select compiler architecture: (armv7/armv6/x86)', "armv7"),
('android_neon', 'enable neon (armv7 only)', "yes"),
('android_stl', 'enable STL support in android port (for modules)', "no")
@ -198,7 +198,7 @@ def configure(env):
env.Append(LIBS=['OpenSLES'])
env.Append(LIBS=['EGL', 'OpenSLES', 'android'])
env.Append(LIBS=['log', 'GLESv1_CM', 'GLESv2', 'z'])
env.Append(LIBS=['log', 'GLESv1_CM', 'GLESv2', 'GLESv3','z'])
if (sys.platform.startswith("darwin")):
env['SHLIBSUFFIX'] = '.so'

View File

@ -350,7 +350,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
jobjectArray arr = (jobjectArray)obj;
int objCount = env->GetArrayLength(arr);
Array varr(true);
Array varr;
for (int i = 0; i < objCount; i++) {
jobject jobj = env->GetObjectArrayElement(arr, i);
@ -364,7 +364,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
if (name == "java.util.HashMap" || name == "org.godotengine.godot.Dictionary") {
Dictionary ret(true);
Dictionary ret;
jclass oclass = c;
jmethodID get_keys = env->GetMethodID(oclass, "get_keys", "()[Ljava/lang/String;");
jobjectArray arr = (jobjectArray)env->CallObjectMethod(obj, get_keys);

View File

@ -30,13 +30,13 @@
#include "core/global_config.h"
#include "core/io/file_access_buffered_fa.h"
#include "drivers/gles2/rasterizer_gles2.h"
#include "drivers/gles3/rasterizer_gles3.h"
#include "drivers/unix/dir_access_unix.h"
#include "drivers/unix/file_access_unix.h"
#include "file_access_android.h"
#include "main/main.h"
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
//#include "servers/visual/visual_server_wrap_mt.h"
#ifdef ANDROID_NATIVE_ACTIVITY
#include "dir_access_android.h"
@ -125,18 +125,14 @@ void OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int
AudioDriverManager::add_driver(&audio_driver_android);
RasterizerGLES2 *rasterizer_gles22 = memnew(RasterizerGLES2(false, use_reload_hooks, false, use_reload_hooks));
if (gl_extensions)
rasterizer_gles22->set_extensions(gl_extensions);
rasterizer = rasterizer_gles22;
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
rasterizer->set_force_16_bits_fbo(use_16bits_fbo);
visual_server = memnew(VisualServerRaster(rasterizer));
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
visual_server = memnew(VisualServerRaster);
/* if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
visual_server = memnew(VisualServerWrapMT(visual_server, false));
};
};*/
visual_server->init();
visual_server->cursor_set_visible(false, 0);
@ -156,7 +152,7 @@ void OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int
input = memnew(InputDefault);
input->set_fallback_mapping("Default Android Gamepad");
power_manager = memnew(power_android);
//power_manager = memnew(power_android);
}
void OS_Android::set_main_loop(MainLoop *p_main_loop) {
@ -227,7 +223,7 @@ void OS_Android::print(const char *p_format, ...) {
void OS_Android::alert(const String &p_alert, const String &p_title) {
print("ALERT: %s\n", p_alert.utf8().get_data());
//print("ALERT: %s\n", p_alert.utf8().get_data());
if (alert_func)
alert_func(p_alert, p_title);
}
@ -631,8 +627,8 @@ void OS_Android::reload_gfx() {
if (gfx_init_func)
gfx_init_func(gfx_init_ud, use_gl2);
if (rasterizer)
rasterizer->reload_vram();
// if (rasterizer)
// rasterizer->reload_vram();
}
Error OS_Android::shell_open(String p_uri) {
@ -750,9 +746,9 @@ void OS_Android::native_video_stop() {
void OS_Android::set_context_is_16_bits(bool p_is_16) {
use_16bits_fbo = p_is_16;
if (rasterizer)
rasterizer->set_force_16_bits_fbo(p_is_16);
// use_16bits_fbo = p_is_16;
// if (rasterizer)
// rasterizer->set_force_16_bits_fbo(p_is_16);
}
void OS_Android::joy_connection_changed(int p_device, bool p_connected, String p_name) {
@ -780,7 +776,7 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURI
main_loop = NULL;
last_id = 1;
gl_extensions = NULL;
rasterizer = NULL;
// rasterizer = NULL;
use_gl2 = false;
open_uri_func = p_open_uri_func;

View File

@ -35,7 +35,7 @@
#include "main/input_default.h"
#include "os/input.h"
#include "os/main_loop.h"
#include "power_android.h"
//#include "power_android.h"
#include "servers/audio_server.h"
#include "servers/physics/physics_server_sw.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
@ -104,7 +104,6 @@ private:
bool use_16bits_fbo;
Rasterizer *rasterizer;
VisualServer *visual_server;
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
@ -141,7 +140,7 @@ private:
SetKeepScreenOnFunc set_keep_screen_on_func;
AlertFunc alert_func;
power_android *power_manager;
//power_android *power_manager;
public:
// functions used by main to initialize/deintialize the OS