-renamed globals.h to global_config.cpp (this seems to have caused a few modified files)

-.pck and .zip exporting redone, seems to be working..
This commit is contained in:
Juan Linietsky 2017-02-21 00:05:15 -03:00
parent 6e2bf31e5a
commit de0045cf1b
121 changed files with 560 additions and 244 deletions

View File

@ -13,7 +13,7 @@ for x in env.global_defaults:
gd_inc += '#include "platform/' + x + '/globals/global_defaults.h"\n'
gd_call += "\tregister_" + x + "_global_defaults();\n"
gd_cpp = '#include "globals.h"\n'
gd_cpp = '#include "global_config.h"\n'
gd_cpp += gd_inc
gd_cpp += "void GlobalConfig::register_global_defaults() {\n" + gd_call + "\n}\n"
@ -45,7 +45,7 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
print("Invalid AES256 encryption key, not 64 bits hex: " + e)
f = open("script_encryption_key.cpp", "wb")
f.write("#include \"globals.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f.write("#include \"global_config.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f.close()

View File

@ -31,7 +31,7 @@
#include "geometry.h"
#include "io/marshalls.h"
#include "io/base64.h"
#include "core/globals.h"
#include "core/global_config.h"
#include "io/file_access_encrypted.h"
#include "os/keyboard.h"

View File

@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "globals.h"
#include "global_config.h"
#include "os/dir_access.h"
#include "os/file_access.h"
@ -247,50 +247,7 @@ bool GlobalConfig::_load_resource_pack(const String& p_pack) {
Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) {
//an absolute mess of a function, must be cleaned up and reorganized somehow at some point
//_load_settings(p_path+"/override.cfg");
if (p_main_pack!="") {
bool ok = _load_resource_pack(p_main_pack);
ERR_FAIL_COND_V(!ok,ERR_CANT_OPEN);
if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
_load_settings("res://override.cfg");
}
return OK;
}
if (OS::get_singleton()->get_executable_path()!="") {
if (_load_resource_pack(OS::get_singleton()->get_executable_path())) {
if (p_path!="") {
resource_path=p_path;
} else {
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
resource_path=d->get_current_dir();
memdelete(d);
}
if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
_load_settings("res://override.cfg");
}
return OK;
}
}
//If looking for files in network, just use network!
if (FileAccessNetworkClient::get_singleton()) {
@ -303,20 +260,58 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) {
return OK;
}
String exec_path = OS::get_singleton()->get_executable_path();
//Attempt with a passed main pack first
if (p_main_pack!="") {
bool ok = _load_resource_pack(p_main_pack);
ERR_FAIL_COND_V(!ok,ERR_CANT_OPEN);
if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
//load override from location of the main pack
_load_settings(p_main_pack.get_base_dir().plus_file("override.cfg"));
}
return OK;
}
//Attempt with execname.pck
if (exec_path!="") {
if (_load_resource_pack(exec_path.get_basename()+".pck")) {
if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
//load override from location of executable
_load_settings(exec_path.get_base_dir().plus_file("override.cfg"));
}
return OK;
}
}
//Try to use the filesystem for files, according to OS. (only Android -when reading from pck- and iOS use this)
if (OS::get_singleton()->get_resource_dir()!="") {
//OS will call Globals->get_resource_path which will be empty if not overriden!
//OS will call Globals->get_resource_path which will be empty if not overriden!
//if the OS would rather use somewhere else, then it will not be empty.
resource_path=OS::get_singleton()->get_resource_dir().replace("\\","/");
if (resource_path.length() && resource_path[ resource_path.length()-1]=='/')
resource_path=resource_path.substr(0,resource_path.length()-1); // chop end
print_line("has res dir: "+resource_path);
if (!_load_resource_pack("res://data.pck"))
_load_resource_pack("res://data.zip");
// make sure this is load from the resource path
print_line("exists engine cfg? "+itos(FileAccess::exists("/godot.cfg")));
// data.pck and data.zip are deprecated and no longer supported, apologies.
// make sure this is loaded from the resource path
if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
print_line("loaded godot.cfg");
_load_settings("res://override.cfg");
}
@ -324,67 +319,41 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) {
return OK;
}
//Nothing was found, try to find a godot.cfg somewhere!
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (!d) {
ERR_FAIL_COND_V(!d,ERR_CANT_CREATE);
resource_path = p_path;
d->change_dir(p_path);
} else {
String candidate = d->get_current_dir();
String current_dir = d->get_current_dir();
bool found = false;
d->change_dir(p_path);
while(true) {
//try to load settings in ascending through dirs shape!
String candidate = d->get_current_dir();
String current_dir = d->get_current_dir();
String exec_name = OS::get_singleton()->get_executable_path().get_file().get_basename();
bool found = false;
bool first_time=true;
if (_load_settings(current_dir+"/godot.cfg")==OK || _load_settings_binary(current_dir+"/godot.cfb")==OK) {
while(true) {
//try to load settings in ascending through dirs shape!
//tries to open pack, but only first time
if (first_time && (_load_resource_pack(current_dir+"/"+exec_name+".pck") || _load_resource_pack(current_dir+"/"+exec_name+".zip") )) {
if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
_load_settings("res://override.cfg");
found=true;
}
break;
} else if (first_time && (_load_resource_pack(current_dir+"/data.pck") || _load_resource_pack(current_dir+"/data.zip") )) {
if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
_load_settings("res://override.cfg");
found=true;
}
break;
} else if (_load_settings(current_dir+"/godot.cfg")==OK || _load_settings_binary(current_dir+"/godot.cfb")==OK) {
_load_settings(current_dir+"/override.cfg");
candidate=current_dir;
found=true;
break;
}
d->change_dir("..");
if (d->get_current_dir()==current_dir)
break; //not doing anything useful
current_dir=d->get_current_dir();
first_time=false;
_load_settings(current_dir+"/override.cfg");
candidate=current_dir;
found=true;
break;
}
d->change_dir("..");
if (d->get_current_dir()==current_dir)
break; //not doing anything useful
current_dir=d->get_current_dir();
}
resource_path=candidate;
resource_path = resource_path.replace("\\","/"); // windows path to unix path just in case
memdelete(d);
if (!found)
return ERR_FILE_NOT_FOUND;
};
resource_path=candidate;
resource_path = resource_path.replace("\\","/"); // windows path to unix path just in case
memdelete(d);
if (!found)
return ERR_FILE_NOT_FOUND;
if (resource_path.length() && resource_path[ resource_path.length()-1]=='/')
resource_path=resource_path.substr(0,resource_path.length()-1); // chop end

View File

@ -26,8 +26,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GLOBALS_H
#define GLOBALS_H
#ifndef GLOBAL_CONFIG_H
#define GLOBAL_CONFIG_H
#include "object.h"
#include "set.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "input_map.h"
#include "globals.h"
#include "global_config.h"
#include "os/keyboard.h"
InputMap *InputMap::singleton=NULL;

View File

@ -30,7 +30,7 @@
#include "os/dir_access.h"
#include "os/copymem.h"
#include "globals.h"
#include "global_config.h"
#include "map.h"
static Map<String, Vector<uint8_t> >* files = NULL;

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "file_access_network.h"
#include "marshalls.h"
#include "globals.h"
#include "global_config.h"
#include "os/os.h"
#include "io/ip.h"

View File

@ -31,7 +31,7 @@
#include <stdio.h>
#define PACK_VERSION 0
#define PACK_VERSION 1
Error PackedData::add_pack(const String& p_path) {
@ -167,8 +167,8 @@ bool PackedSourcePCK::try_open_pack(const String& p_path) {
uint32_t ver_minor = f->get_32();
uint32_t ver_rev = f->get_32();
ERR_EXPLAIN("Pack version newer than supported by engine: "+itos(version));
ERR_FAIL_COND_V( version > PACK_VERSION, ERR_INVALID_DATA);
ERR_EXPLAIN("Pack version unsupported: "+itos(version));
ERR_FAIL_COND_V( version != PACK_VERSION, ERR_INVALID_DATA);
ERR_EXPLAIN("Pack created with a newer version of the engine: "+itos(ver_major)+"."+itos(ver_minor)+"."+itos(ver_rev));
ERR_FAIL_COND_V( ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), ERR_INVALID_DATA);

View File

@ -29,7 +29,7 @@
#include "packet_peer.h"
#include "io/marshalls.h"
#include "globals.h"
#include "global_config.h"
/* helpers / binders */

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "version.h"
#include "resource_format_binary.h"
#include "globals.h"
#include "global_config.h"
#include "io/file_access_compressed.h"
#include "io/marshalls.h"
#include "os/dir_access.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "resource_loader.h"
#include "print_string.h"
#include "globals.h"
#include "global_config.h"
#include "path_remap.h"
#include "os/file_access.h"
#include "os/os.h"

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_saver.h"
#include "globals.h"
#include "global_config.h"
#include "os/file_access.h"
#include "script_language.h"
#include "resource_loader.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "message_queue.h"
#include "globals.h"
#include "global_config.h"
#include "script_language.h"
MessageQueue *MessageQueue::singleton=NULL;

View File

@ -30,7 +30,7 @@
#include "os/file_access.h"
#include "os/memory.h"
#include "os/os.h"
#include "globals.h"
#include "global_config.h"
String DirAccess::_get_root_path() const {

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "file_access.h"
#include "globals.h"
#include "global_config.h"
#include "os/os.h"
#include "core/io/marshalls.h"
#include "io/md5.h"

View File

@ -29,7 +29,7 @@
#include "input.h"
#include "input_map.h"
#include "os/os.h"
#include "globals.h"
#include "global_config.h"
Input *Input::singleton=NULL;
Input *Input::get_singleton() {

View File

@ -29,7 +29,7 @@
#include "os.h"
#include "dir_access.h"
#include "globals.h"
#include "global_config.h"
#include "input.h"
#include "os/file_access.h"

View File

@ -35,7 +35,7 @@
#include "io/packet_peer.h"
#include "math/a_star.h"
#include "math/triangle_mesh.h"
#include "globals.h"
#include "global_config.h"
#include "class_db.h"
#include "geometry.h"
#include "bind/core_bind.h"

View File

@ -30,7 +30,7 @@
#include "os/os.h"
#include "io/ip.h"
#include "globals.h"
#include "global_config.h"
#include "os/input.h"
void ScriptDebuggerRemote::_send_video_memory() {

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "translation.h"
#include "globals.h"
#include "global_config.h"
#include "io/resource_loader.h"
#include "os/os.h"

View File

@ -52,8 +52,40 @@
#define UPPERCASE(m_c) (((m_c)>='a' && (m_c)<='z')?((m_c)-('a'-'A')):(m_c))
#define LOWERCASE(m_c) (((m_c)>='A' && (m_c)<='Z')?((m_c)+('a'-'A')):(m_c))
/** STRING **/
bool CharString::operator<(const CharString& p_right) const {
if (length()==0) {
return p_right.length()!=0;
}
const char *this_str=get_data();
const char *that_str=get_data();
while (true) {
if (*that_str==0 && *this_str==0)
return false; //this can't be equal, sadly
else if (*this_str==0)
return true; //if this is empty, and the other one is not, then we're less.. I think?
else if (*that_str==0)
return false; //otherwise the other one is smaller..
else if (*this_str < *that_str ) //more than
return true;
else if (*this_str > *that_str ) //less than
return false;
this_str++;
that_str++;
}
return false; //should never reach here anyway
}
const char *CharString::get_data() const {
if (size())

View File

@ -41,6 +41,8 @@
class CharString : public Vector<char> {
public:
bool operator<(const CharString& p_right) const;
int length() const { return size() ? size()-1 : 0; }
const char *get_data() const;
operator const char*() {return get_data();};

View File

@ -30,7 +30,7 @@
#ifdef ALSA_ENABLED
#include "globals.h"
#include "global_config.h"
#include <errno.h>

View File

@ -30,7 +30,7 @@
#include "rasterizer_gles2.h"
#include "os/os.h"
#include "globals.h"
#include "global_config.h"
#include <stdio.h>
#include "servers/visual/shader_language.h"
#include "servers/visual/particle_system_sw.h"

View File

@ -1,6 +1,6 @@
#include "rasterizer_gles3.h"
#include "os/os.h"
#include "globals.h"
#include "global_config.h"
#include "gl_context/context_gl.h"
#include <string.h>
RasterizerStorage *RasterizerGLES3::get_storage() {

View File

@ -1,5 +1,5 @@
#include "rasterizer_scene_gles3.h"
#include "globals.h"
#include "global_config.h"
#include "os/os.h"
#include "rasterizer_canvas_gles3.h"

View File

@ -1,7 +1,7 @@
#include "rasterizer_storage_gles3.h"
#include "rasterizer_canvas_gles3.h"
#include "rasterizer_scene_gles3.h"
#include "globals.h"
#include "global_config.h"
/* TEXTURE API */

View File

@ -29,7 +29,7 @@
#include "resource_saver_png.h"
#include "core/image.h"
#include "globals.h"
#include "global_config.h"
#include "os/file_access.h"
#include "scene/resources/texture.h"

View File

@ -32,7 +32,7 @@
#include <pulse/error.h>
#include "globals.h"
#include "global_config.h"
Error AudioDriverPulseAudio::init() {

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "audio_driver_rtaudio.h"
#include "globals.h"
#include "global_config.h"
#include "os/os.h"
#ifdef RTAUDIO_ENABLED

View File

@ -61,7 +61,7 @@
#include <poll.h>
#include <errno.h>
#include <assert.h>
#include "globals.h"
#include "global_config.h"
extern bool _print_error_enabled;

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "audio_driver_xaudio2.h"
#include "globals.h"
#include "global_config.h"
#include "os/os.h"
const char * AudioDriverXAudio2::get_name() const

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "main.h"
#include "os/os.h"
#include "globals.h"
#include "global_config.h"
#include "splash.h"
#include "core/register_core_types.h"
#include "scene/register_scene_types.h"

View File

@ -39,7 +39,7 @@
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/dir_access.h"
#include "core/globals.h"
#include "core/global_config.h"
#include "io/file_access_memory.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "gd_script.h"
#include "gd_compiler.h"
#include "globals.h"
#include "global_config.h"
#include "os/file_access.h"
void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gd_script.h"
#include "globals.h"
#include "global_config.h"
#include "global_constants.h"
#include "gd_compiler.h"
#include "os/file_access.h"

View File

@ -31,7 +31,7 @@
#include <stdio.h> // If you don't know what this is for stop reading now.
#include "io/stream_peer_ssl.h"
#include "globals.h"
#include "global_config.h"
#include "os/file_access.h"
#include "curl_hostcheck.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "video_stream_theora.h"
#include "globals.h"
#include "global_config.h"
#include "os/os.h"
#include "yuv2rgb.h"

View File

@ -2,7 +2,7 @@
#include "visual_script_nodes.h"
#include "scene/main/node.h"
#include "os/os.h"
#include "globals.h"
#include "global_config.h"

View File

@ -1,6 +1,6 @@
#include "visual_script_flow_control.h"
#include "os/keyboard.h"
#include "globals.h"
#include "global_config.h"
//////////////////////////////////////////

View File

@ -4,7 +4,7 @@
#include "scene/main/node.h"
#include "visual_script_nodes.h"
#include "io/resource_loader.h"
#include "globals.h"
#include "global_config.h"
//////////////////////////////////////////
////////////////CALL//////////////////////

View File

@ -1,6 +1,6 @@
#include "visual_script_nodes.h"
#include "global_constants.h"
#include "globals.h"
#include "global_config.h"
#include "scene/main/scene_main_loop.h"
#include "os/os.h"
#include "scene/main/node.h"

View File

@ -35,7 +35,7 @@
#include "../theora/yuv2rgb.h"
#include "os/file_access.h"
#include "globals.h"
#include "global_config.h"
#include <string.h>

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "audio_driver_jandroid.h"
#include "globals.h"
#include "global_config.h"
#include "os/os.h"
#include "thread_jandroid.h"

View File

@ -33,7 +33,7 @@
#include "tools/editor/editor_node.h"
#include "io/zip_io.h"
#include "io/marshalls.h"
#include "globals.h"
#include "global_config.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/android/logo.h"

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "global_defaults.h"
#include "globals.h"
#include "global_config.h"
void register_android_global_defaults() {

View File

@ -36,7 +36,7 @@
#include "file_access_android.h"
#include "dir_access_jandroid.h"
#include "audio_driver_jandroid.h"
#include "globals.h"
#include "global_config.h"
#include "thread_jandroid.h"
#include "core/os/keyboard.h"
#include "java_class_wrapper.h"

View File

@ -36,7 +36,7 @@
#include "servers/visual/visual_server_wrap_mt.h"
#include "main/main.h"
#include "file_access_android.h"
#include "core/globals.h"
#include "core/global_config.h"
#ifdef ANDROID_NATIVE_ACTIVITY
#include "file_access_android.h"

View File

@ -33,7 +33,7 @@
#include "tools/editor/editor_node.h"
#include "io/zip_io.h"
#include "io/marshalls.h"
#include "globals.h"
#include "global_config.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/bb10/logo.h"

View File

@ -31,7 +31,7 @@
#include "drivers/gles2/rasterizer_gles2.h"
#include "servers/visual/visual_server_raster.h"
#include "core/os/dir_access.h"
#include "core/globals.h"
#include "core/global_config.h"
#include "main/main.h"
#include "bbutil.h"
#include "core/os/keyboard.h"

View File

@ -30,7 +30,7 @@
#import "gl_view.h"
#include "os_iphone.h"
#include "core/globals.h"
#include "core/global_config.h"
#include "main/main.h"
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED

View File

@ -31,7 +31,7 @@
#import <OpenGLES/EAGLDrawable.h>
#include "os_iphone.h"
#include "core/os/keyboard.h"
#include "core/globals.h"
#include "core/global_config.h"
#include "servers/audio_server.h"
#import "gl_view.h"

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "global_defaults.h"
#include "globals.h"
#include "global_config.h"
void register_iphone_global_defaults() {

View File

@ -33,7 +33,7 @@
#include "tools/editor/editor_node.h"
#include "io/zip_io.h"
#include "io/marshalls.h"
#include "globals.h"
#include "global_config.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/javascript/logo.h"

View File

@ -158,9 +158,8 @@ int main(int argc, char *argv[]) {
char *args[]={"-test","gui","-v",NULL};
Error err = Main::setup("apk",3,args);
#else
//char *args[]={"-v",NULL};//
//Error err = Main::setup("",1,args);
Error err = Main::setup("",0,NULL);
char *args[]={"-main_pack","data.pck",NULL}; //pass location of main pack manually, because it wont get an executable name
Error err = Main::setup("",2,args);
#endif
ResourceLoader::set_abort_on_missing_resources(false); //ease up compatibility

View File

@ -34,7 +34,7 @@
#include "drivers/unix/dir_access_unix.h"
#include "servers/visual/visual_server_raster.h"
#include "main/main.h"
#include "core/globals.h"
#include "core/global_config.h"
#include "dom_keys.h"
#include <stdlib.h>

View File

@ -34,7 +34,7 @@
#include "io/zip_io.h"
#include "io/marshalls.h"
#include "io/resource_saver.h"
#include "globals.h"
#include "global_config.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/osx/logo.h"

View File

@ -40,7 +40,7 @@
#include "servers/audio_server.h"
//#include "servers/visual/visual_server_wrap_mt.h"
#include "os/memory_pool_dynamic_prealloc.h"
#include "globals.h"
#include "global_config.h"
#include "io/marshalls.h"
#include "platform/windows/packet_peer_udp_winsock.h"
#include "platform/windows/stream_peer_winsock.h"

View File

@ -44,7 +44,7 @@
#include "packet_peer_udp_winsock.h"
#include "stream_peer_winsock.h"
#include "lang_table.h"
#include "globals.h"
#include "global_config.h"
#include "io/marshalls.h"
#include "joypad.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "light.h"
#include "globals.h"
#include "global_config.h"
#include "scene/resources/surface_tool.h"
#include "baked_light_instance.h"

View File

@ -29,7 +29,7 @@
#include "portal.h"
#include "servers/visual_server.h"
#include "scene/resources/surface_tool.h"
#include "globals.h"
#include "global_config.h"
bool Portal::_set(const StringName& p_name, const Variant& p_value) {

View File

@ -31,7 +31,7 @@
#include "servers/visual_server.h"
#include "geometry.h"
#include "globals.h"
#include "global_config.h"
#include "scene/resources/surface_tool.h"

View File

@ -31,7 +31,7 @@
#include "message_queue.h"
#include "scene/resources/surface_tool.h"
#include "core/globals.h"
#include "core/global_config.h"
bool Skeleton::_set(const StringName& p_path, const Variant& p_value) {

View File

@ -30,7 +30,7 @@
#include "servers/visual_server.h"
#include "scene/main/viewport.h"
#include "scene/main/canvas_layer.h"
#include "globals.h"
#include "global_config.h"
#include "print_string.h"
#include "os/keyboard.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "item_list.h"
#include "os/os.h"
#include "globals.h"
#include "global_config.h"
void ItemList::add_item(const String& p_item,const Ref<Texture>& p_texture,bool p_selectable) {

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "label.h"
#include "print_string.h"
#include "globals.h"
#include "global_config.h"
#include "translation.h"

View File

@ -32,7 +32,7 @@
#include "os/input.h"
#include "os/os.h"
#include "globals.h"
#include "global_config.h"
#include "message_queue.h"
#include "scene/main/viewport.h"

View File

@ -30,7 +30,7 @@
#include "print_string.h"
#include "os/os.h"
#include "os/keyboard.h"
#include "globals.h"
#include "global_config.h"
#include "os/input.h"
#include "scene/main/viewport.h"

View File

@ -29,7 +29,7 @@
#ifndef NODE_H
#define NODE_H
#include "globals.h"
#include "global_config.h"
#include "object.h"
#include "path_db.h"
#include "map.h"

View File

@ -32,7 +32,7 @@
#include "os/os.h"
#include "message_queue.h"
#include "node.h"
#include "globals.h"
#include "global_config.h"
#include <stdio.h>
#include "os/keyboard.h"
//#include "servers/spatial_sound_2d_server.h"

View File

@ -48,7 +48,7 @@
#include "scene/main/timer.h"
#include "scene/scene_string_names.h"
#include "globals.h"
#include "global_config.h"
void ViewportTexture::setup_local_to_scene() {

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "register_scene_types.h"
#include "os/os.h"
#include "globals.h"
#include "global_config.h"
#include "scene/io/resource_format_image.h"
#include "scene/io/resource_format_wav.h"

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_stream_resampled.h"
#include "globals.h"
#include "global_config.h"
#if 0

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "environment.h"
#include "texture.h"
#include "globals.h"
#include "global_config.h"
#include "servers/visual_server.h"
RID Environment::get_rid() const {

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "packed_scene.h"
#include "globals.h"
#include "global_config.h"
#include "io/resource_loader.h"
#include "scene/3d/spatial.h"
#include "scene/gui/control.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "scene_format_text.h"
#include "globals.h"
#include "global_config.h"
#include "version.h"
#include "os/dir_access.h"

View File

@ -30,11 +30,11 @@
#include "servers/visual_server.h"
#include "servers/physics_2d_server.h"
//#include "servers/spatial_sound_2d_server.h"
#include "globals.h"
#include "global_config.h"
#include "scene/2d/visibility_notifier_2d.h"
#include "scene/main/viewport.h"
#include "scene/2d/camera_2d.h"
#include "globals.h"
#include "global_config.h"
struct SpatialIndexer2D {

View File

@ -31,7 +31,7 @@
#include "resource.h"
#include "servers/physics_2d_server.h"
#include "globals.h"
#include "global_config.h"
class SpatialIndexer2D;
class VisibilityNotifier2D;

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "audio_driver_dummy.h"
#include "globals.h"
#include "global_config.h"
#include "os/os.h"

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_server.h"
#include "globals.h"
#include "global_config.h"
#include "os/os.h"
#include "servers/audio/effects/audio_effect_compressor.h"
#include "io/resource_loader.h"

View File

@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "globals.h"
#include "global_config.h"
#include "space_sw.h"
#include "collision_solver_sw.h"
#include "physics_server_sw.h"

View File

@ -37,7 +37,7 @@
#include "area_pair_sw.h"
#include "broad_phase_sw.h"
#include "collision_object_sw.h"
#include "globals.h"
#include "global_config.h"
class PhysicsDirectSpaceStateSW : public PhysicsDirectSpaceState {

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "broad_phase_2d_hash_grid.h"
#include "globals.h"
#include "global_config.h"
#define LARGE_ELEMENT_FI 1.01239812

View File

@ -30,7 +30,7 @@
#include "broad_phase_2d_basic.h"
#include "broad_phase_2d_hash_grid.h"
#include "collision_solver_2d_sw.h"
#include "globals.h"
#include "global_config.h"
#include "script_language.h"
#include "os/os.h"

View File

@ -33,7 +33,7 @@
#include "servers/physics_2d_server.h"
#include "command_queue_mt.h"
#include "os/thread.h"
#include "globals.h"
#include "global_config.h"
#ifdef DEBUG_SYNC
#define SYNC_DEBUG print_line("sync on: "+String(__FUNCTION__));

View File

@ -37,7 +37,7 @@
#include "area_pair_2d_sw.h"
#include "broad_phase_2d_sw.h"
#include "collision_object_2d_sw.h"
#include "globals.h"
#include "global_config.h"
class Physics2DDirectSpaceStateSW : public Physics2DDirectSpaceState {

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_server_types.h"
#include "globals.h"
#include "global_config.h"
#include "visual_server.h"
#include "audio_server.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "visual_server_raster.h"
#include "os/os.h"
#include "globals.h"
#include "global_config.h"
#include "default_mouse_cursor.xpm"
#include "sort.h"
#include "io/marshalls.h"

View File

@ -2,7 +2,7 @@
#include "visual_server_global.h"
#include "visual_server_canvas.h"
#include "visual_server_scene.h"
#include "globals.h"
#include "global_config.h"

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visual_server.h"
#include "globals.h"
#include "global_config.h"
#include "method_bind_ext.inc"
VisualServer *VisualServer::singleton=NULL;

View File

@ -33,7 +33,7 @@
#include "scene/resources/material.h"
#include "globals.h"
#include "global_config.h"
#include "io/xml_parser.h"
#include "map.h"

View File

@ -30,7 +30,7 @@
#include "version.h"
#include "global_constants.h"
#include "globals.h"
#include "global_config.h"
#include "script_language.h"
#include "io/marshalls.h"
#include "io/compression.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "editor_autoload_settings.h"
#include "globals.h"
#include "global_config.h"
#include "global_constants.h"
#include "editor_node.h"

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "editor_data.h"
#include "globals.h"
#include "global_config.h"
#include "editor_settings.h"
#include "os/dir_access.h"
#include "io/resource_loader.h"

View File

@ -29,7 +29,7 @@
#include "editor_export.h"
#include "version.h"
#include "script_language.h"
#include "globals.h"
#include "global_config.h"
#include "os/file_access.h"
#include "os/dir_access.h"
#include "tools/editor/editor_file_system.h"
@ -42,8 +42,18 @@
#include "tools/editor/plugins/script_editor_plugin.h"
#include "io/zip_io.h"
static int _get_pad(int p_alignment, int p_n) {
int rest = p_n % p_alignment;
int pad = 0;
if (rest > 0) {
pad = p_alignment - rest;
};
return pad;
};
#define PCK_PADDING 16
bool EditorExportPreset::_set(const StringName& p_name, const Variant& p_value) {
@ -73,7 +83,7 @@ void EditorExportPreset::_get_property_list( List<PropertyInfo> *p_list) const{
}
}
Ref<EditorExportPlatform> EditorExportPreset::get_platform() {
Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
return platform;
}
@ -254,6 +264,34 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags)
Error EditorExportPlatform::_save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) {
PackData *pd = (PackData*)p_userdata;
SavedData sd;
sd.path_utf8=p_path.utf8();
sd.ofs = pd->f->get_pos();
sd.size = p_data.size();
pd->f->store_buffer(p_data.ptr(),p_data.size());
int pad = _get_pad(PCK_PADDING,sd.size);
for(int i=0;i<pad;i++) {
pd->f->store_8(0);
}
{
MD5_CTX ctx;
MD5Init(&ctx);
MD5Update(&ctx,(unsigned char*)p_data.ptr(),p_data.size());
MD5Final(&ctx);
sd.md5.resize(16);
for(int i=0;i<16;i++) {
sd.md5[i]=ctx.digest[i];
}
}
pd->file_ofs.push_back(sd);
pd->ep->step(TTR("Storing File:")+" "+p_path,2+p_file*100/p_total,false);
return OK;
}
@ -281,7 +319,7 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata,const String& p_path
zipCloseFileInZip(zip);
zd->ep->step(TTR("Storing File:")+" "+p_path,2+p_file*100/p_total,false);
zd->count++;
return OK;
}
@ -335,18 +373,250 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() {
}
void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir,Set<String>& p_paths) {
for(int i=0;i<p_dir->get_subdir_count();i++) {
_export_find_resources(p_dir->get_subdir(i),p_paths);
}
for(int i=0;i<p_dir->get_file_count();i++) {
p_paths.insert(p_dir->get_file_path(i));
}
}
void EditorExportPlatform::_export_find_dependencies(const String& p_path,Set<String>& p_paths) {
if (p_paths.has(p_path))
return;
p_paths.insert(p_path);
EditorFileSystemDirectory *dir;
int file_idx;
dir = EditorFileSystem::get_singleton()->find_file(p_path,&file_idx);
if (!dir)
return;
Vector<String> deps = dir->get_file_deps(file_idx);
for(int i=0;i<deps.size();i++) {
_export_find_dependencies(deps[i],p_paths);
}
}
Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset>& p_preset,EditorExportSaveFunction p_func, void* p_udata) {
Ref<EditorExportPlatform> platform = p_preset->get_platform();
List<String> feature_list;
platform->get_preset_features(p_preset,&feature_list);
//figure out features
Set<String> features;
for (List<String>::Element *E=feature_list.front();E;E=E->next()) {
features.insert(E->get());
}
//figure out paths of files that will be exported
Set<String> paths;
if (p_preset->get_export_filter()==EditorExportPreset::EXPORT_ALL_RESOURCES) {
//find stuff
_export_find_resources(EditorFileSystem::get_singleton()->get_filesystem(),paths);
} else {
bool scenes_only = p_preset->get_export_filter()==EditorExportPreset::EXPORT_SELECTED_SCENES;
Vector<String> files = p_preset->get_files_to_export();
for(int i=0;i<files.size();i++) {
if (scenes_only && ResourceLoader::get_resource_type(files[i])!="PackedScene")
continue;
_export_find_dependencies(files[i],paths);
}
}
//store everything in the export medium
int idx = 0;
int total=paths.size();
for(Set<String>::Element *E=paths.front();E;E=E->next()) {
String path = E->get();
if (FileAccess::exists(path+".import")) {
//file is imported, replace by what it imports
Ref<ConfigFile> config;
config.instance();
Error err = config->load(path+".import");
if (err!=OK) {
ERR_PRINTS("Could not parse: '"+path+"', not exported.");
continue;
}
List<String> remaps;
config->get_section_keys("remap",&remaps);
for(List<String>::Element *F=remaps.front();F;F=F->next()) {
String remap=F->get();
if (remap=="path") {
String remapped_path=config->get_value("remap",remap);
Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
p_func(p_udata,remapped_path,array,idx,total);
} else if (remap.begins_with("path.")) {
String feature = remap.get_slice(".",1);
if (features.has(feature)) {
String remapped_path=config->get_value("remap",remap);
Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
p_func(p_udata,remapped_path,array,idx,total);
}
}
}
//also save the .import file
Vector<uint8_t> array = FileAccess::get_file_as_array(path+".import");
p_func(p_udata,path+".import",array,idx,total);
} else {
//just store it as it comes
Vector<uint8_t> array = FileAccess::get_file_as_array(path);
p_func(p_udata,path,array,idx,total);
}
idx++;
}
//save config!
String config_file="godot.cfb";
String engine_cfb =EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmp"+config_file;
GlobalConfig::get_singleton()->save_custom(engine_cfb);
Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb);
p_func(p_udata,"res://"+config_file,data,idx,total);
return OK;
}
Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset>& p_preset,FileAccess *p_where) {
Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset>& p_preset,const String& p_path) {
EditorProgress ep("savepack",TTR("Packing"),102);
String tmppath = EditorSettings::get_singleton()->get_settings_path()+"/tmp/packtmp";
FileAccess *ftmp = FileAccess::open(tmppath,FileAccess::WRITE);
ERR_FAIL_COND_V(!ftmp,ERR_CANT_CREATE)
PackData pd;
pd.ep=&ep;
pd.f=ftmp;
Error err = export_project_files(p_preset,_save_pack_file,&pd);
memdelete(ftmp); //close tmp file
if (err)
return err;
pd.file_ofs.sort(); //do sort, so we can do binary search later
FileAccess *f = FileAccess::open(p_path,FileAccess::WRITE);
ERR_FAIL_COND_V(!f,ERR_CANT_CREATE)
f->store_32(0x43504447); //GDPK
f->store_32(1); //pack version
f->store_32(VERSION_MAJOR);
f->store_32(VERSION_MINOR);
f->store_32(0); //hmph
for(int i=0;i<16;i++) {
//reserved
f->store_32(0);
}
f->store_32(pd.file_ofs.size()); //amount of files
size_t header_size = f->get_pos();
//precalculate header size
for(int i=0;i<pd.file_ofs.size();i++) {
header_size += 4; // size of path string (32 bits is enough)
uint32_t string_len = pd.file_ofs[i].path_utf8.length();
header_size += string_len + _get_pad(4,string_len); ///size of path string
header_size += 8; // offset to file _with_ header size included
header_size += 8; // size of file
header_size +=16; // md5
}
size_t header_padding = _get_pad(PCK_PADDING,header_size);
for(int i=0;i<pd.file_ofs.size();i++) {
uint32_t string_len = pd.file_ofs[i].path_utf8.length();
uint32_t pad = _get_pad(4,string_len);;
f->store_32(string_len+pad);
f->store_buffer((const uint8_t*)pd.file_ofs[i].path_utf8.get_data(),string_len);
for(uint32_t j=0;j<pad;j++) {
f->store_8(0);
}
f->store_64(pd.file_ofs[i].ofs + header_padding + header_size);
f->store_64(pd.file_ofs[i].size); // pay attention here, this is where file is
f->store_buffer(pd.file_ofs[i].md5.ptr(),16); //also save md5 for file
}
for(uint32_t j=0;j<header_padding;j++) {
f->store_8(0);
}
//save the rest of the data
ftmp = FileAccess::open(tmppath,FileAccess::READ);
if (!ftmp) {
memdelete(f);
ERR_FAIL_COND_V(!ftmp,ERR_CANT_CREATE)
}
const int bufsize=16384;
uint8_t buf[bufsize];
while(true) {
int got = ftmp->get_buffer(buf,bufsize);
if (got<=0)
break;
f->store_buffer(buf,got);
}
memdelete(ftmp);
f->store_32(0x43504447); //GDPK
memdelete(f);
return OK;
}
Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset>& p_preset,const String& p_path) {
EditorProgress ep("savezip",TTR("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.ep=&ep;
zd.zip=zip;
Error err = export_project_files(p_preset,_save_zip_file,&zd);
zipClose(zip,NULL);
return OK;
}
@ -387,9 +657,7 @@ void EditorExport::_save() {
config->set_value(section,"export_filter","resources");
save_files=true;
} break;
case EditorExportPreset::EXPORT_ALL_FILES: {
config->set_value(section,"export_filter","all_files");
} break;
}
@ -527,8 +795,6 @@ void EditorExport::load_config() {
} else if (export_filter=="resources") {
preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_RESOURCES);
get_files=true;
} else if (export_filter=="all_files") {
preset->set_export_filter(EditorExportPreset::EXPORT_ALL_FILES);
}
if (get_files) {

View File

@ -39,6 +39,7 @@
class EditorProgress;
class FileAccess;
class EditorExportPlatform;
class EditorFileSystemDirectory;
class EditorExportPreset : public Reference {
@ -48,7 +49,6 @@ public:
EXPORT_ALL_RESOURCES,
EXPORT_SELECTED_SCENES,
EXPORT_SELECTED_RESOURCES,
EXPORT_ALL_FILES,
};
private:
@ -64,6 +64,7 @@ private:
Vector<String> patches;
friend class EditorExport;
friend class EditorExportPlatform;
@ -78,7 +79,7 @@ protected:
public:
Ref<EditorExportPlatform> get_platform();
Ref<EditorExportPlatform> get_platform() const;
bool has(const StringName& p_property) const { return values.has(p_property); }
Vector<String> get_files_to_export() const;
@ -126,9 +127,14 @@ private:
struct SavedData {
String path;
uint64_t ofs;
uint64_t size;
Vector<uint8_t> md5;
CharString path_utf8;
bool operator<(const SavedData& p_data) const {
return path_utf8 < p_data.path_utf8;
}
};
struct PackData {
@ -142,10 +148,12 @@ private:
void* zip;
EditorProgress *ep;
int count;
};
void _export_find_resources(EditorFileSystemDirectory *p_dir,Set<String>& p_paths);
void _export_find_dependencies(const String& p_path,Set<String>& p_paths);
void gen_debug_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);
@ -176,7 +184,7 @@ public:
Error export_project_files(const Ref<EditorExportPreset>& p_preset,EditorExportSaveFunction p_func, void* p_udata);
Error save_pack(const Ref<EditorExportPreset>& p_preset,FileAccess *p_where);
Error save_pack(const Ref<EditorExportPreset>& p_preset,const String& p_path);
Error save_zip(const Ref<EditorExportPreset>& p_preset,const String& p_path);

View File

@ -28,7 +28,7 @@
/*************************************************************************/
#include "editor_file_system.h"
#include "globals.h"
#include "global_config.h"
#include "io/resource_loader.h"
#include "os/os.h"
#include "os/file_access.h"

View File

@ -37,7 +37,7 @@
#include "servers/physics_2d_server.h"
#include "scene/resources/packed_scene.h"
#include "editor_settings.h"
#include "globals.h"
#include "global_config.h"
#include <stdio.h>
#include "class_db.h"
#include "os/keyboard.h"

View File

@ -32,7 +32,7 @@
#include "io/config_file.h"
#include "os/file_access.h"
#include "os/main_loop.h"
#include "globals.h"
#include "global_config.h"
#include "editor_node.h"
void EditorPluginSettings::_notification(int p_what) {

View File

@ -32,7 +32,7 @@
#include "os/file_access.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "globals.h"
#include "global_config.h"
#include "editor_scale.h"
#include "message_queue.h"

Some files were not shown because too many files have changed in this diff Show More