ability to export scene to zip
This commit is contained in:
parent
11eaf019b3
commit
709de124c1
@ -77,9 +77,14 @@ void OptionButton::_selected(int p_which) {
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(selid==-1);
|
||||
if (selid==-1 && p_which>=0 && p_which<popup->get_item_count()) {
|
||||
_select(p_which,true);
|
||||
} else {
|
||||
|
||||
_select(selid,true);
|
||||
ERR_FAIL_COND(selid==-1);
|
||||
|
||||
_select(selid,true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -370,7 +370,7 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
|
||||
}
|
||||
|
||||
int over=_get_mouse_over(Point2(m.x,m.y));
|
||||
int id = (over<0 || items[over].separator || items[over].disabled)?-1:items[over].ID;
|
||||
int id = (over<0 || items[over].separator || items[over].disabled)?-1:(items[over].ID>=0?items[over].ID:over);
|
||||
|
||||
if (id<0) {
|
||||
mouse_over=-1;
|
||||
@ -753,6 +753,7 @@ int PopupMenu::find_item_by_accelerator(uint32_t p_accel) const {
|
||||
|
||||
void PopupMenu::activate_item(int p_item) {
|
||||
|
||||
|
||||
ERR_FAIL_INDEX(p_item,items.size());
|
||||
ERR_FAIL_COND(items[p_item].separator);
|
||||
int id = items[p_item].ID>=0?items[p_item].ID:p_item;
|
||||
|
@ -163,7 +163,7 @@ void TextureButton::_bind_methods() {
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture"));
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture"));
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ;
|
||||
ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("set_texture_scale"));
|
||||
ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
|
||||
ADD_PROPERTYNO(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
|
||||
|
||||
}
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "io/md5.h"
|
||||
#include "io_plugins/editor_texture_import_plugin.h"
|
||||
#include "tools/editor/plugins/script_editor_plugin.h"
|
||||
#include "io/zip_io.h"
|
||||
|
||||
String EditorImportPlugin::validate_source_path(const String& p_path) {
|
||||
|
||||
@ -1077,6 +1078,59 @@ Error EditorExportPlatform::save_pack_file(void *p_userdata,const String& p_path
|
||||
|
||||
}
|
||||
|
||||
Error EditorExportPlatform::save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) {
|
||||
|
||||
|
||||
ZipData *zd = (ZipData*)p_userdata;
|
||||
|
||||
zipFile zip=(zipFile)zd->zip;
|
||||
|
||||
zipOpenNewFileInZip(zip,
|
||||
p_path.utf8().get_data(),
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
Z_DEFLATED,
|
||||
Z_DEFAULT_COMPRESSION);
|
||||
|
||||
zipWriteInFileInZip(zip,p_data.ptr(),p_data.size());
|
||||
zipCloseFileInZip(zip);
|
||||
|
||||
zd->ep->step("Storing File: "+p_path,2+p_file*100/p_total);
|
||||
zd->count++;
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
Error EditorExportPlatform::save_zip(const String& p_path, bool p_make_bundles) {
|
||||
|
||||
EditorProgress ep("savezip","Packing",102);
|
||||
|
||||
//FileAccess *tmp = FileAccess::open(tmppath,FileAccess::WRITE);
|
||||
|
||||
FileAccess *src_f;
|
||||
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
|
||||
zipFile zip=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io);
|
||||
|
||||
ZipData zd;
|
||||
zd.count=0;
|
||||
zd.ep=&ep;
|
||||
zd.zip=zip;
|
||||
|
||||
|
||||
Error err = export_project_files(save_zip_file,&zd,p_make_bundles);
|
||||
|
||||
zipClose(zip,NULL);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Error EditorExportPlatform::save_pack(FileAccess *dst,bool p_make_bundles, int p_alignment) {
|
||||
|
||||
EditorProgress ep("savepack","Packing",102);
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
|
||||
class EditorExportPlatform;
|
||||
class FileAccess;
|
||||
class EditorProgress;
|
||||
@ -107,8 +108,17 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
struct ZipData {
|
||||
|
||||
void* zip;
|
||||
EditorProgress *ep;
|
||||
int count;
|
||||
|
||||
};
|
||||
|
||||
void gen_export_flags(Vector<String> &r_flags, int p_flags);
|
||||
static Error save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
|
||||
static Error save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
|
||||
|
||||
public:
|
||||
|
||||
@ -134,6 +144,8 @@ public:
|
||||
Error export_project_files(EditorExportSaveFunction p_func, void* p_udata,bool p_make_bundles);
|
||||
|
||||
Error save_pack(FileAccess *p_where, bool p_make_bundles=false, int p_alignment = 1);
|
||||
Error save_zip(const String& p_path, bool p_make_bundles=false);
|
||||
|
||||
virtual String get_name() const =0;
|
||||
virtual ImageCompression get_image_compression() const=0;
|
||||
virtual Ref<Texture> get_logo() const =0;
|
||||
|
@ -471,20 +471,32 @@ void ProjectExportDialog::_export_action_pck(const String& p_file) {
|
||||
ERR_PRINT("Invalid platform for export of PCK");
|
||||
return;
|
||||
}
|
||||
FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE);
|
||||
if (!f) {
|
||||
error->set_text("Error exporting project PCK! Can't write");
|
||||
error->popup_centered_minsize();
|
||||
}
|
||||
ERR_FAIL_COND(!f);
|
||||
|
||||
Error err = exporter->save_pack(f,false);
|
||||
memdelete(f);
|
||||
if (p_file.ends_with(".pck")) {
|
||||
FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE);
|
||||
if (!f) {
|
||||
error->set_text("Error exporting project PCK! Can't write");
|
||||
error->popup_centered_minsize();
|
||||
}
|
||||
ERR_FAIL_COND(!f);
|
||||
|
||||
if (err!=OK) {
|
||||
error->set_text("Error exporting project!");
|
||||
error->popup_centered_minsize();
|
||||
return;
|
||||
Error err = exporter->save_pack(f,false);
|
||||
memdelete(f);
|
||||
|
||||
if (err!=OK) {
|
||||
error->set_text("Error exporting project!");
|
||||
error->popup_centered_minsize();
|
||||
return;
|
||||
}
|
||||
} else if (p_file.ends_with(".zip")) {
|
||||
|
||||
Error err = exporter->save_zip(p_file,false);
|
||||
|
||||
if (err!=OK) {
|
||||
error->set_text("Error exporting project!");
|
||||
error->popup_centered_minsize();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1425,6 +1437,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) {
|
||||
pck_export->set_title("Export Project PCK");
|
||||
pck_export->connect("file_selected", this,"_export_action_pck");
|
||||
pck_export->add_filter("*.pck ; Data Pack");
|
||||
pck_export->add_filter("*.zip ; Zip");
|
||||
add_child(pck_export);
|
||||
|
||||
button_export = add_button("Export..",!OS::get_singleton()->get_swap_ok_cancel(),"export_pck");
|
||||
|
Loading…
Reference in New Issue
Block a user