1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

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

@@ -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!"));