Skip to content

Commit

Permalink
Export template management dialog.
Browse files Browse the repository at this point in the history
Missing download (need to discuss this!)
  • Loading branch information
reduz committed Mar 21, 2017
1 parent 33a2c5d commit b5a06ce
Show file tree
Hide file tree
Showing 12 changed files with 543 additions and 105 deletions.
3 changes: 2 additions & 1 deletion editor/editor_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int _get_pad(int p_alignment, int p_n) {
};

return pad;
};
}

#define PCK_PADDING 16

Expand Down Expand Up @@ -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;
}

Expand Down
87 changes: 13 additions & 74 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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!"));
Expand Down
6 changes: 5 additions & 1 deletion editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -180,7 +181,7 @@ class EditorNode : public Node {
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,
Expand Down Expand Up @@ -300,6 +301,7 @@ class EditorNode : public Node {
RunSettingsDialog *run_settings_dialog;
ProjectSettings *project_settings;
EditorFileDialog *file;
ExportTemplateManager *export_template_manager;
FileDialog *file_templates;
FileDialog *file_export;
FileDialog *file_export_lib;
Expand Down Expand Up @@ -739,6 +741,8 @@ class EditorNode : public Node {

void update_keying();

void open_export_template_manager();

void reload_scene(const String &p_path);

bool is_exiting() const { return exiting; }
Expand Down
Loading

0 comments on commit b5a06ce

Please sign in to comment.