diff options
120 files changed, 1325 insertions, 811 deletions
diff --git a/core/SCsub b/core/SCsub index 77c8288846..fd3f57dd7c 100644 --- a/core/SCsub +++ b/core/SCsub @@ -5,6 +5,7 @@ Import('env') env.core_sources = [] +# Generate global defaults gd_call = "" gd_inc = "" @@ -21,6 +22,8 @@ f = open("global_defaults.cpp", "wb") f.write(gd_cpp) f.close() + +# Generate AES256 script encryption key import os txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0" if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ): @@ -49,20 +52,57 @@ f.write("#include \"global_config.h\"\nuint8_t script_encryption_key[32]={" + tx f.close() +# Add required thirdparty code. Header paths are hardcoded, we don't need to append +# to the include path (saves a few chars on the compiler invocation for touchy MSVC...) +thirdparty_dir = "#thirdparty/misc/" +thirdparty_sources = [ + # C sources + "base64.c", + "fastlz.c", + "sha256.c", + "smaz.c", + + # C++ sources + "aes256.cpp", + "hq2x.cpp", + "md5.cpp", + "pcg.cpp", + "triangulator.cpp", +] +thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] +env.add_source_files(env.core_sources, thirdparty_sources) + +# Minizip library, can be unbundled in theory +# However, our version has some custom modifications, so it won't compile with the system one +thirdparty_minizip_dir = "#thirdparty/minizip/" +thirdparty_minizip_sources = [ + "ioapi.c", + "unzip.c", + "zip.c", +] +thirdparty_minizip_sources = [thirdparty_minizip_dir + file for file in thirdparty_minizip_sources] +env.add_source_files(env.core_sources, thirdparty_minizip_sources) + + +# Godot's own sources env.add_source_files(env.core_sources, "*.cpp") -Export('env') - +# Make binders import make_binders env.Command(['method_bind.inc', 'method_bind_ext.inc'], 'make_binders.py', make_binders.run) + +# Chain load SCsubs SConscript('os/SCsub') SConscript('math/SCsub') SConscript('io/SCsub') SConscript('bind/SCsub') SConscript('helper/SCsub') -lib = env.Library("core", env.core_sources) +# Build it all as a library +lib = env.Library("core", env.core_sources) env.Prepend(LIBS=[lib]) + +Export('env') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index bd41e48a30..7a03ceb64c 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -28,14 +28,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "core_bind.h" + #include "core/global_config.h" #include "geometry.h" -#include "io/base64.h" #include "io/file_access_encrypted.h" #include "io/marshalls.h" #include "os/keyboard.h" #include "os/os.h" +#include "thirdparty/misc/base64.h" + /** * Time constants borrowed from loc_time.h */ diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index d41534703c..9bdd960424 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -30,218 +30,11 @@ #include "compressed_translation.h" #include "pair.h" -#include <string.h> - -/////////// SMAZ ///////////// - -/* -Copyright (c) 2006-2009, Salvatore Sanfilippo -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Smaz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* Our compression codebook, used for compression */ -static const char *Smaz_cb[241] = { - "\002s,\266", "\003had\232\002leW", "\003on \216", "", "\001yS", - "\002ma\255\002li\227", "\003or \260", "", "\002ll\230\003s t\277", - "\004fromg\002mel", "", "\003its\332", "\001z\333", "\003ingF", "\001>\336", - "\001 \000\003 (\002nc\344", "\002nd=\003 on\312", - "\002ne\213\003hat\276\003re q", "", "\002ngT\003herz\004have\306\003s o\225", - "", "\003ionk\003s a\254\002ly\352", "\003hisL\003 inN\003 be\252", "", - "\003 fo\325\003 of \003 ha\311", "", "\002of\005", - "\003 co\241\002no\267\003 ma\370", "", "", "\003 cl\356\003enta\003 an7", - "\002ns\300\001\"e", "\003n t\217\002ntP\003s, \205", - "\002pe\320\003 we\351\002om\223", "\002on\037", "", "\002y G", "\003 wa\271", - "\003 re\321\002or*", "", "\002=\"\251\002ot\337", "\003forD\002ou[", - "\003 toR", "\003 th\r", "\003 it\366", - "\003but\261\002ra\202\003 wi\363\002</\361", "\003 wh\237", "\002 4", - "\003nd ?", "\002re!", "", "\003ng c", "", - "\003ly \307\003ass\323\001a\004\002rir", "", "", "", "\002se_", "\003of \"", - "\003div\364\002ros\003ere\240", "", "\002ta\310\001bZ\002si\324", "", - "\003and\a\002rs\335", "\002rt\362", "\002teE", "\003ati\316", "\002so\263", - "\002th\021", "\002tiJ\001c\034\003allp", "\003ate\345", "\002ss\246", - "\002stM", "", "\002><\346", "\002to\024", "\003arew", "\001d\030", - "\002tr\303", "", "\001\n1\003 a \222", "\003f tv\002veo", "\002un\340", "", - "\003e o\242", "\002a \243\002wa\326\001e\002", "\002ur\226\003e a\274", - "\002us\244\003\n\r\n\247", "\002ut\304\003e c\373", "\002we\221", "", "", - "\002wh\302", "\001f,", "", "", "", "\003d t\206", "", "", "\003th \343", - "\001g;", "", "", "\001\r9\003e s\265", "\003e t\234", "", "\003to Y", - "\003e\r\n\236", "\002d \036\001h\022", "", "\001,Q", "\002 a\031", "\002 b^", - "\002\r\n\025\002 cI", "\002 d\245", "\002 e\253", "\002 fh\001i\b\002e \v", - "", "\002 hU\001-\314", "\002 i8", "", "", "\002 l\315", "\002 m{", - "\002f :\002 n\354", "\002 o\035", "\002 p}\001.n\003\r\n\r\250", "", - "\002 r\275", "\002 s>", "\002 t\016", "", "\002g \235\005which+\003whi\367", - "\002 w5", "\001/\305", "\003as \214", "\003at \207", "", "\003who\331", "", - "\001l\026\002h \212", "", "\002, $", "", "\004withV", "", "", "", "\001m-", "", - "", "\002ac\357", "\002ad\350", "\003TheH", "", "", "\004this\233\001n\t", - "", "\002. y", "", "\002alX\003e, \365", "\003tio\215\002be\\", - "\002an\032\003ver\347", "", "\004that0\003tha\313\001o\006", "\003was2", - "\002arO", "\002as.", "\002at'\003the\001\004they\200\005there\322\005theird", - "\002ce\210", "\004were]", "", "\002ch\231\002l \264\001p<", "", "", - "\003one\256", "", "\003he \023\002dej", "\003ter\270", "\002cou", "", - "\002by\177\002di\201\002eax", "", "\002ec\327", "\002edB", "\002ee\353", "", - "", "\001r\f\002n )", "", "", "", "\002el\262", "", "\003in i\002en3", "", - "\002o `\001s\n", "", "\002er\033", "\003is t\002es6", "", "\002ge\371", - "\004.com\375", "\002fo\334\003our\330", "\003ch \301\001t\003", "\002hab", "", - "\003men\374", "", "\002he\020", "", "", "\001u&", "\002hif", "", - "\003not\204\002ic\203", "\003ed @\002id\355", "", "", "\002ho\273", - "\002r K\001vm", "", "", "", "\003t t\257\002il\360", "\002im\342", - "\003en \317\002in\017", "\002io\220", "\002s \027\001wA", "", "\003er |", - "\003es ~\002is%", "\002it/", "", "\002iv\272", "", - "\002t #\ahttp://C\001x\372", "\002la\211", "\001<\341", "\003, a\224" -}; - -/* Reverse compression codebook, used for decompression */ -static const char *Smaz_rcb[254] = { - " ", "the", "e", "t", "a", "of", "o", "and", "i", "n", "s", "e ", "r", " th", - " t", "in", "he", "th", "h", "he ", "to", "\r\n", "l", "s ", "d", " a", "an", - "er", "c", " o", "d ", "on", " of", "re", "of ", "t ", ", ", "is", "u", "at", - " ", "n ", "or", "which", "f", "m", "as", "it", "that", "\n", "was", "en", - " ", " w", "es", " an", " i", "\r", "f ", "g", "p", "nd", " s", "nd ", "ed ", - "w", "ed", "http://", "for", "te", "ing", "y ", "The", " c", "ti", "r ", "his", - "st", " in", "ar", "nt", ",", " to", "y", "ng", " h", "with", "le", "al", "to ", - "b", "ou", "be", "were", " b", "se", "o ", "ent", "ha", "ng ", "their", "\"", - "hi", "from", " f", "in ", "de", "ion", "me", "v", ".", "ve", "all", "re ", - "ri", "ro", "is ", "co", "f t", "are", "ea", ". ", "her", " m", "er ", " p", - "es ", "by", "they", "di", "ra", "ic", "not", "s, ", "d t", "at ", "ce", "la", - "h ", "ne", "as ", "tio", "on ", "n t", "io", "we", " a ", "om", ", a", "s o", - "ur", "li", "ll", "ch", "had", "this", "e t", "g ", "e\r\n", " wh", "ere", - " co", "e o", "a ", "us", " d", "ss", "\n\r\n", "\r\n\r", "=\"", " be", " e", - "s a", "ma", "one", "t t", "or ", "but", "el", "so", "l ", "e s", "s,", "no", - "ter", " wa", "iv", "ho", "e a", " r", "hat", "s t", "ns", "ch ", "wh", "tr", - "ut", "/", "have", "ly ", "ta", " ha", " on", "tha", "-", " l", "ati", "en ", - "pe", " re", "there", "ass", "si", " fo", "wa", "ec", "our", "who", "its", "z", - "fo", "rs", ">", "ot", "un", "<", "im", "th ", "nc", "ate", "><", "ver", "ad", - " we", "ly", "ee", " n", "id", " cl", "ac", "il", "</", "rt", " wi", "div", - "e, ", " it", "whi", " ma", "ge", "x", "e c", "men", ".com" -}; -static int smaz_compress(const char *in, int inlen, char *out, int outlen) { - unsigned int h1, h2, h3 = 0; - int verblen = 0, _outlen = outlen; - char verb[256], *_out = out; - - while (inlen) { - int j = 7, needed; - char *flush = NULL; - const char *slot; - - h1 = h2 = in[0] << 3; - if (inlen > 1) h2 += in[1]; - if (inlen > 2) h3 = h2 ^ in[2]; - if (j > inlen) j = inlen; - - /* Try to lookup substrings into the hash table, starting from the -* longer to the shorter substrings */ - for (; j > 0; j--) { - switch (j) { - case 1: slot = Smaz_cb[h1 % 241]; break; - case 2: slot = Smaz_cb[h2 % 241]; break; - default: slot = Smaz_cb[h3 % 241]; break; - } - while (slot[0]) { - if (slot[0] == j && memcmp(slot + 1, in, j) == 0) { - /* Match found in the hash table, -* prepare a verbatim bytes flush if needed */ - if (verblen) { - needed = (verblen == 1) ? 2 : 2 + verblen; - flush = out; - out += needed; - outlen -= needed; - } - /* Emit the byte */ - if (outlen <= 0) return _outlen + 1; - out[0] = slot[slot[0] + 1]; - out++; - outlen--; - inlen -= j; - in += j; - goto out; - } else { - slot += slot[0] + 2; - } - } - } - /* Match not found - add the byte to the verbatim buffer */ - verb[verblen] = in[0]; - verblen++; - inlen--; - in++; - out: - /* Prepare a flush if we reached the flush length limit, and there -* is not already a pending flush operation. */ - if (!flush && (verblen == 256 || (verblen > 0 && inlen == 0))) { - needed = (verblen == 1) ? 2 : 2 + verblen; - flush = out; - out += needed; - outlen -= needed; - if (outlen < 0) return _outlen + 1; - } - /* Perform a verbatim flush if needed */ - if (flush) { - if (verblen == 1) { - flush[0] = (signed char)254; - flush[1] = verb[0]; - } else { - flush[0] = (signed char)255; - flush[1] = (signed char)(verblen - 1); - memcpy(flush + 2, verb, verblen); - } - flush = NULL; - verblen = 0; - } - } - return out - _out; -} - -static int smaz_decompress(const char *in, int inlen, char *out, int outlen) { - unsigned char *c = (unsigned char *)in; - char *_out = out; - int _outlen = outlen; - - while (inlen) { - if (*c == 254) { - /* Verbatim byte */ - if (outlen < 1) return _outlen + 1; - *out = *(c + 1); - out++; - outlen--; - c += 2; - inlen -= 2; - } else if (*c == 255) { - /* Verbatim string */ - int len = (*(c + 1)) + 1; - if (outlen < len) return _outlen + 1; - memcpy(out, c + 2, len); - out += len; - outlen -= len; - c += 2 + len; - inlen -= 2 + len; - } else { - /* Codebook entry */ - const char *s = Smaz_rcb[*c]; - int len = strlen(s); - - if (outlen < len) return _outlen + 1; - memcpy(out, s, len); - out += len; - outlen -= len; - c++; - inlen--; - } - } - return out - _out; +extern "C" { +#include "thirdparty/misc/smaz.h" } -/////////// END OF SMAZ ///////////// - struct _PHashTranslationCmp { int orig_len; diff --git a/core/global_config.cpp b/core/global_config.cpp index f9a0877c23..81b923f01e 100644 --- a/core/global_config.cpp +++ b/core/global_config.cpp @@ -53,11 +53,6 @@ String GlobalConfig::get_resource_path() const { return resource_path; }; -String GlobalConfig::get_project_file_name() const { - - return project_file_name; -} - String GlobalConfig::localize_path(const String &p_path) const { if (resource_path == "") @@ -241,43 +236,13 @@ bool GlobalConfig::_load_resource_pack(const String &p_pack) { return true; } -static String _find_project_file(DirAccess *p_diraccess, bool p_res = false) { - p_diraccess->list_dir_begin(); - String ret = ""; - while (true) { - bool isdir; - String file = p_diraccess->get_next(&isdir); - if (file == "") - break; - - if (!isdir) { - if (file.get_extension() == "godot") { - - if (p_res) { - ret = "res://" + file; - } else { - ret = p_diraccess->get_current_dir() + "/" + file; - } - } - } - } - p_diraccess->list_dir_end(); - return ret; -} - -static String _find_project_file() { - DirAccess *dir = DirAccess::create(DirAccess::ACCESS_RESOURCES); - String ret = _find_project_file(dir, true); - memdelete(dir); - return ret; -} - Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { //If looking for files in network, just use network! + if (FileAccessNetworkClient::get_singleton()) { - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + + if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) { _load_settings("res://override.cfg"); } @@ -293,8 +258,8 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { bool ok = _load_resource_pack(p_main_pack); ERR_FAIL_COND_V(!ok, ERR_CANT_OPEN); - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + + if (_load_settings("res://project.godot") == 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")); } @@ -307,8 +272,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { if (_load_resource_pack(exec_path.get_basename() + ".pck")) { - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + if (_load_settings("res://project.godot") == 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")); } @@ -328,15 +292,15 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { // data.pck and data.zip are deprecated and no longer supported, apologies. // make sure this is loaded from the resource path - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + + if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) { _load_settings("res://override.cfg"); } return OK; } - //Nothing was found, try to find a *.godot somewhere! + //Nothing was found, try to find a project.godot somewhere! DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); ERR_FAIL_COND_V(!d, ERR_CANT_CREATE); @@ -349,8 +313,8 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { while (true) { //try to load settings in ascending through dirs shape! - String gdproj = _find_project_file(d); - if (_load_settings(gdproj) == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) { + + if (_load_settings(current_dir + "/project.godot") == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) { _load_settings(current_dir + "/override.cfg"); candidate = current_dir; @@ -464,7 +428,6 @@ Error GlobalConfig::_load_settings(const String p_path) { err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); if (err == ERR_FILE_EOF) { memdelete(f); - project_file_name = p_path.get_file(); return OK; } else if (err != OK) { ERR_PRINTS("GlobalConfig::load - " + p_path + ":" + itos(lines) + " error: " + error_text); @@ -486,7 +449,6 @@ Error GlobalConfig::_load_settings(const String p_path) { } } - project_file_name = p_path.get_file(); memdelete(f); return OK; @@ -512,12 +474,7 @@ void GlobalConfig::clear(const String &p_name) { Error GlobalConfig::save() { - if (project_file_name.empty()) { - String name = ((String)get("application/name")).replace(" ", "_"); - return save_custom(get_resource_path() + "/" + name + ".godot"); - } else { - return save_custom(get_resource_path() + "/" + project_file_name); - } + return save_custom(get_resource_path() + "/project.godot"); } Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom) { @@ -591,7 +548,7 @@ Error GlobalConfig::_save_settings_text(const String &p_file, const Map<String, FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); if (err) { - ERR_EXPLAIN("Couldn't save project file - " + p_file); + ERR_EXPLAIN("Couldn't save project.godot - " + p_file); ERR_FAIL_COND_V(err, err) } @@ -717,7 +674,7 @@ Error GlobalConfig::save_custom(const String &p_path, const CustomMap &p_custom, Error err = file->open(dst_file,FileAccess::WRITE); if (err) { memdelete(file); - ERR_EXPLAIN("Coudln't save godot.cfg"); + ERR_EXPLAIN("Couldn't save project.godot"); ERR_FAIL_COND_V(err,err) } @@ -871,7 +828,6 @@ void GlobalConfig::_bind_methods() { ClassDB::bind_method(D_METHOD("clear", "name"), &GlobalConfig::clear); ClassDB::bind_method(D_METHOD("localize_path", "path"), &GlobalConfig::localize_path); ClassDB::bind_method(D_METHOD("globalize_path", "path"), &GlobalConfig::globalize_path); - ClassDB::bind_method(D_METHOD("get_project_file_name"), &GlobalConfig::get_project_file_name); ClassDB::bind_method(D_METHOD("save"), &GlobalConfig::save); ClassDB::bind_method(D_METHOD("has_singleton", "name"), &GlobalConfig::has_singleton); ClassDB::bind_method(D_METHOD("get_singleton", "name"), &GlobalConfig::get_singleton_object); diff --git a/core/global_config.h b/core/global_config.h index 5148c4377e..d0f64dc23c 100644 --- a/core/global_config.h +++ b/core/global_config.h @@ -111,8 +111,6 @@ protected: void _add_property_info_bind(const Dictionary &p_info); - String project_file_name; - protected: static void _bind_methods(); @@ -126,7 +124,6 @@ public: Variant property_get_revert(const String &p_name); String get_resource_path() const; - String get_project_file_name() const; static GlobalConfig *get_singleton(); diff --git a/core/image.cpp b/core/image.cpp index 8a09dc1a8c..b81d92fa33 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -32,9 +32,10 @@ #include "core/io/image_loader.h" #include "core/os/copymem.h" #include "hash_map.h" -#include "hq2x.h" #include "print_string.h" +#include "thirdparty/misc/hq2x.h" + #include <stdio.h> const char *Image::format_names[Image::FORMAT_MAX] = { diff --git a/core/io/SCsub b/core/io/SCsub index 6789aa8bc6..4efc902717 100644 --- a/core/io/SCsub +++ b/core/io/SCsub @@ -3,7 +3,5 @@ Import('env') env.add_source_files(env.core_sources, "*.cpp") -env.add_source_files(env.core_sources, "*.c") -# env.core_sources.append("io/fastlz.c") Export('env') diff --git a/core/io/compression.cpp b/core/io/compression.cpp index c26bd7cdcd..662411a62e 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -28,12 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "compression.h" -#include "os/copymem.h" -#include "zlib.h" -#include "fastlz.h" +#include "os/copymem.h" #include "zip_io.h" +#include "thirdparty/misc/fastlz.h" + +#include <zlib.h> + int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, Mode p_mode) { switch (p_mode) { diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 2625e5fe34..f2b33a01bb 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -28,15 +28,18 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "file_access_encrypted.h" -#include "aes256.h" -#include "md5.h" + +#include "core/variant.h" #include "os/copymem.h" #include "print_string.h" -#define COMP_MAGIC 0x43454447 -#include "core/variant.h" +#include "thirdparty/misc/aes256.h" +#include "thirdparty/misc/md5.h" + #include <stdio.h> +#define COMP_MAGIC 0x43454447 + Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode) { //print_line("open and parse!"); diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index 8c3cd3ae67..c9cc2dac79 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -34,7 +34,9 @@ #include "core/io/file_access_pack.h" #include "map.h" -#include "unzip.h" + +#include "thirdparty/minizip/unzip.h" + #include <stdlib.h> class ZipArchive : public PackSource { diff --git a/core/io/sha-README.md b/core/io/sha-README.md deleted file mode 100644 index 27a73cffe7..0000000000 --- a/core/io/sha-README.md +++ /dev/null @@ -1,5 +0,0 @@ -SHA256 -====== - -SHA-256 implementation to compliment a portable byte-oriented AES-256 -implementation in C at http://www.literatecode.com/aes256 diff --git a/core/io/zip_io.h b/core/io/zip_io.h index d5af042499..88e680c0e0 100644 --- a/core/io/zip_io.h +++ b/core/io/zip_io.h @@ -30,11 +30,12 @@ #ifndef ZIP_IO_H #define ZIP_IO_H -#include "io/unzip.h" -#include "io/zip.h" #include "os/copymem.h" #include "os/file_access.h" +#include "thirdparty/minizip/unzip.h" +#include "thirdparty/minizip/zip.h" + static void *zipio_open(void *data, const char *p_fname, int mode) { FileAccess *&f = *(FileAccess **)data; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 5bfbc1005f..06ec77daae 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -31,9 +31,10 @@ #define MATH_FUNCS_H #include "math_defs.h" -#include "pcg.h" #include "typedefs.h" +#include "thirdparty/misc/pcg.h" + #include <float.h> #include <math.h> diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index f344525d1e..375121c0cc 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -28,13 +28,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "file_access.h" + #include "core/io/file_access_pack.h" #include "core/io/marshalls.h" #include "global_config.h" -#include "io/md5.h" -#include "io/sha256.h" #include "os/os.h" +#include "thirdparty/misc/md5.h" +#include "thirdparty/misc/sha256.h" + FileAccess::CreateFunc FileAccess::create_func[ACCESS_MAX] = { 0, 0 }; FileAccess::FileCloseFailNotify FileAccess::close_fail_notify = NULL; diff --git a/core/ustring.cpp b/core/ustring.cpp index b01f680dd6..dcb6545bd1 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -30,14 +30,15 @@ #include "ustring.h" #include "color.h" -#include "io/md5.h" -#include "io/sha256.h" #include "math_funcs.h" #include "os/memory.h" #include "print_string.h" #include "ucaps.h" #include "variant.h" +#include "thirdparty/misc/md5.h" +#include "thirdparty/misc/sha256.h" + #include <wchar.h> #ifndef NO_USE_STDLIB diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 5e12b230be..234156d39f 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -409,7 +409,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings, Token token; get_token(p_stream, token, line, r_err_str); if (token.type != TK_PARENTHESIS_OPEN) { - r_err_str = "Expected '(' in old-style godot.cfg construct"; + r_err_str = "Expected '(' in old-style project.godot construct"; return ERR_PARSE_ERROR; } @@ -420,7 +420,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings, CharType c = p_stream->get_char(); if (p_stream->is_eof()) { - r_err_str = "Unexpected EOF while parsing old-style godot.cfg construct"; + r_err_str = "Unexpected EOF while parsing old-style project.godot construct"; return ERR_PARSE_ERROR; } @@ -1273,7 +1273,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = arr; return OK; - } else if (id == "key") { // compatibility with godot.cfg + } else if (id == "key") { // compatibility with project.godot Vector<String> params; Error err = _parse_enginecfg(p_stream, params, line, r_err_str); @@ -1309,7 +1309,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = ie; return OK; - } else if (id == "mbutton") { // compatibility with godot.cfg + } else if (id == "mbutton") { // compatibility with project.godot Vector<String> params; Error err = _parse_enginecfg(p_stream, params, line, r_err_str); @@ -1324,7 +1324,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = ie; return OK; - } else if (id == "jbutton") { // compatibility with godot.cfg + } else if (id == "jbutton") { // compatibility with project.godot Vector<String> params; Error err = _parse_enginecfg(p_stream, params, line, r_err_str); @@ -1339,7 +1339,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = ie; return OK; - } else if (id == "jaxis") { // compatibility with godot.cfg + } else if (id == "jaxis") { // compatibility with project.godot Vector<String> params; Error err = _parse_enginecfg(p_stream, params, line, r_err_str); @@ -1357,19 +1357,19 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = ie; return OK; - } else if (id == "img") { // compatibility with godot.cfg + } else if (id == "img") { // compatibility with project.godot Token token; // FIXME: no need for this declaration? the first argument in line 509 is a Token& token. get_token(p_stream, token, line, r_err_str); if (token.type != TK_PARENTHESIS_OPEN) { - r_err_str = "Expected '(' in old-style godot.cfg construct"; + r_err_str = "Expected '(' in old-style project.godot construct"; return ERR_PARSE_ERROR; } while (true) { CharType c = p_stream->get_char(); if (p_stream->is_eof()) { - r_err_str = "Unexpected EOF in old style godot.cfg img()"; + r_err_str = "Unexpected EOF in old style project.godot img()"; return ERR_PARSE_ERROR; } if (c == ')') diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 6f6a094927..03dd151eb2 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -16455,7 +16455,7 @@ Contains global variables accessible from everywhere. </brief_description> <description> - Contains global variables accessible from everywhere. Use the normal [Object] API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in the project file (*.godot) are also loaded into globals, making this object very useful for reading custom game configuration options. + Contains global variables accessible from everywhere. Use the normal [Object] API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in project.godot are also loaded into globals, making this object very useful for reading custom game configuration options. </description> <methods> <method name="add_property_info"> diff --git a/drivers/convex_decomp/SCsub b/drivers/convex_decomp/SCsub index ee39fd2631..f017e55120 100644 --- a/drivers/convex_decomp/SCsub +++ b/drivers/convex_decomp/SCsub @@ -4,4 +4,13 @@ Import('env') env.add_source_files(env.drivers_sources, "*.cpp") +# Thirdparty dependencies +thirdparty_dir = "#thirdparty/b2d_convexdecomp/" +thirdparty_sources = [ + "b2Polygon.cpp", + "b2Triangle.cpp", +] +thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] +env.add_source_files(env.drivers_sources, thirdparty_sources) + Export('env') diff --git a/drivers/convex_decomp/b2d_decompose.cpp b/drivers/convex_decomp/b2d_decompose.cpp index f918b66c31..d9011b8eab 100644 --- a/drivers/convex_decomp/b2d_decompose.cpp +++ b/drivers/convex_decomp/b2d_decompose.cpp @@ -28,7 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "b2d_decompose.h" -#include "b2Polygon.h" + +#include "thirdparty/b2d_convexdecomp/b2Polygon.h" namespace b2ConvexDecomp { diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 4214ee5a6d..db814ec721 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -72,7 +72,7 @@ RasterizerScene *RasterizerGLES3::get_scene() { #define _EXT_DEBUG_SEVERITY_LOW_ARB 0x9148 #define _EXT_DEBUG_OUTPUT 0x92E0 -#ifdef WINDOWS_ENABLED +#if (defined WINDOWS_ENABLED) && !(defined UWP_ENABLED) #define GLAPIENTRY APIENTRY #else #define GLAPIENTRY diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 73547b5a16..1025acceb4 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -245,7 +245,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image &p_image, Ima if (config.s3tc_supported) { - r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_S3TC_DXT1_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT; + r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h index 8d240de02e..7c1d31b57c 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.h +++ b/drivers/xaudio2/audio_driver_xaudio2.h @@ -34,7 +34,6 @@ #include "core/os/thread.h" #include "servers/audio_server.h" -#include <mmreg.h> #include <mmsystem.h> #include <windows.h> #include <wrl/client.h> diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 7dc5db4c7d..3774c8d4c3 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -28,13 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_export.h" + #include "editor/editor_file_system.h" #include "editor/plugins/script_editor_plugin.h" #include "editor_node.h" #include "editor_settings.h" #include "global_config.h" #include "io/config_file.h" -#include "io/md5.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "io/zip_io.h" @@ -43,6 +43,8 @@ #include "script_language.h" #include "version.h" +#include "thirdparty/misc/md5.h" + static int _get_pad(int p_alignment, int p_n) { int rest = p_n % p_alignment; @@ -319,7 +321,7 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat return OK; } -String EditorExportPlatform::find_export_template(String template_file_name) const { +String EditorExportPlatform::find_export_template(String template_file_name, String *err) const { String base_name = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + _MKSTR(VERSION_STATUS) + "/" + template_file_name; String user_file = EditorSettings::get_singleton()->get_settings_path() + "/templates/" + base_name; @@ -340,9 +342,20 @@ String EditorExportPlatform::find_export_template(String template_file_name) con return system_file; } } - print_line("none,sorry"); - return String(); //not found + // Not found + if (err) { + *err += "No export template found at \"" + user_file + "\""; + if (has_system_path) + *err += "\n or \"" + system_file + "\"."; + else + *err += "."; + } + return String(); // not found +} + +bool EditorExportPlatform::exists_export_template(String template_file_name, String *err) const { + return find_export_template(template_file_name, err) != ""; } Ref<EditorExportPreset> EditorExportPlatform::create_preset() { @@ -923,19 +936,47 @@ Ref<Texture> EditorExportPlatformPC::get_logo() const { bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { - r_missing_templates = false; + String err; + bool valid = true; + + if (use64 && (!exists_export_template(debug_file_64, &err) || !exists_export_template(release_file_64, &err))) { + valid = false; + } - if (find_export_template(release_file_32) == String()) { - r_missing_templates = true; - } else if (find_export_template(debug_file_32) == String()) { - r_missing_templates = true; - } else if (find_export_template(release_file_64) == String()) { - r_missing_templates = true; - } else if (find_export_template(debug_file_64) == String()) { - r_missing_templates = true; + if (!use64 && (!exists_export_template(debug_file_32, &err) || !exists_export_template(release_file_32, &err))) { + valid = false; } - return !r_missing_templates; + String custom_debug_binary = p_preset->get("custom_template/debug"); + String custom_release_binary = p_preset->get("custom_template/release"); + + if (custom_debug_binary == "" && custom_release_binary == "") { + if (!err.empty()) + r_error = err; + return valid; + } + + bool dvalid = true; + bool rvalid = true; + + if (!FileAccess::exists(custom_debug_binary)) { + dvalid = false; + err = "Custom debug binary not found.\n"; + } + + if (!FileAccess::exists(custom_release_binary)) { + rvalid = false; + err += "Custom release binary not found.\n"; + } + + if (dvalid || rvalid) + valid = true; + else + valid = false; + + if (!err.empty()) + r_error = err; + return valid; } String EditorExportPlatformPC::get_binary_extension() const { @@ -1379,8 +1420,8 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const Set<StringName> exported; - if (FileAccess::exists("res://godot.cfg")) - exported.insert("res://godot.cfg"); + if (FileAccess::exists("res://project.godot")) + exported.insert("res://project.godot"); if (EditorImportExport::get_singleton()->get_export_filter()!=EditorImportExport::EXPORT_SELECTED) { @@ -1495,40 +1536,6 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const } -String EditorExportPlatform::find_export_template(String template_file_name, String *err) const { - String user_file = EditorSettings::get_singleton()->get_settings_path() - +"/templates/"+template_file_name; - String system_file=OS::get_singleton()->get_installed_templates_path(); - bool has_system_path=(system_file!=""); - system_file+=template_file_name; - - // Prefer user file - if (FileAccess::exists(user_file)) { - return user_file; - } - - // Now check system file - if (has_system_path) { - if (FileAccess::exists(system_file)) { - return system_file; - } - } - - // Not found - if (err) { - *err+="No export template found at \""+user_file+"\""; - if (has_system_path) - *err+="\n or \""+system_file+"\"."; - else - *err+="."; - } - return ""; -} - -bool EditorExportPlatform::exists_export_template(String template_file_name, String *err) const { - return find_export_template(template_file_name,err)!=""; -} - /////////////////////////////////////// @@ -1976,7 +1983,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func } - StringName engine_cfg="res://godot.cfg"; + StringName engine_cfg="res://project.godot"; StringName boot_splash; { String splash=GlobalConfig::get_singleton()->get("application/boot_splash"); //avoid splash from being converted @@ -2030,7 +2037,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func { - //make binary godot.cfg config + //make binary project.godot config Map<String,Variant> custom; @@ -2428,50 +2435,6 @@ void EditorExportPlatformPC::set_binary_extension(const String& p_extension) { binary_extension=p_extension; } -bool EditorExportPlatformPC::can_export(String *r_error) const { - - String err; - bool valid=true; - - if (use64 && (!exists_export_template(debug_binary64) || !exists_export_template(release_binary64))) { - valid=false; - err="No 64 bits export templates found.\nDownload and install export templates.\n"; - } - - if (!use64 && (!exists_export_template(debug_binary32) || !exists_export_template(release_binary32))) { - valid=false; - err="No 32 bits export templates found.\nDownload and install export templates.\n"; - } - - if(custom_debug_binary=="" && custom_release_binary=="") { - if (r_error) *r_error=err; - return valid; - } - - bool dvalid = true; - bool rvalid = true; - - if(!FileAccess::exists(custom_debug_binary)) { - dvalid = false; - err = "Custom debug binary not found.\n"; - } - - if(!FileAccess::exists(custom_release_binary)) { - rvalid = false; - err = "Custom release binary not found.\n"; - } - - if (dvalid || rvalid) - valid = true; - else - valid = false; - - if (r_error) - *r_error=err; - return valid; -} - - EditorExportPlatformPC::EditorExportPlatformPC() { export_mode=EXPORT_PACK; diff --git a/editor/editor_export.h b/editor/editor_export.h index a78762ad80..740f05174b 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -154,7 +154,8 @@ private: protected: virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0; - String find_export_template(String template_file_name) const; + bool exists_export_template(String template_file_name, String *err) const; + String find_export_template(String template_file_name, String *err = NULL) const; void gen_export_flags(Vector<String> &r_flags, int p_flags); public: @@ -258,6 +259,8 @@ class EditorExportPlatformPC : public EditorExportPlatform { String debug_file_32; String debug_file_64; + bool use64; + public: virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 3fb2923696..b7070ab5f6 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -487,22 +487,6 @@ bool EditorFileSystem::_check_missing_imported_files(const String &p_path) { return true; } -static bool _find_project(const String &p_path) { - DirAccess *dir_access = DirAccess::create_for_path(p_path); - bool ret = false; - while (true) { - bool is_dir; - String file = dir_access->get_next(&is_dir); - if (file == "") - break; - if (file.ends_with(".godot")) { - ret = true; - } - } - memdelete(dir_access); - return ret; -} - void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress) { List<String> dirs; @@ -525,9 +509,8 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (f.begins_with(".")) //ignore hidden and . / .. continue; - if (_find_project(cd.plus_file(f))) { + if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this continue; - } dirs.push_back(f); @@ -693,35 +676,34 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const while (true) { bool isdir; - String file = da->get_next(&isdir); - if (file == "") + String f = da->get_next(&isdir); + if (f == "") break; if (isdir) { - if (file.begins_with(".")) //ignore hidden and . / .. + if (f.begins_with(".")) //ignore hidden and . / .. continue; - int idx = p_dir->find_dir_index(file); + int idx = p_dir->find_dir_index(f); if (idx == -1) { - if (_find_project(cd.plus_file(file))) { + if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this continue; - } EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory); efd->parent = p_dir; - efd->name = file; + efd->name = f; DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); - d->change_dir(cd.plus_file(file)); + d->change_dir(cd.plus_file(f)); _scan_new_dir(efd, d, p_progress.get_sub(1, 1)); memdelete(d); ItemAction ia; ia.action = ItemAction::ACTION_DIR_ADD; ia.dir = p_dir; - ia.file = file; + ia.file = f; ia.new_dir = efd; scan_actions.push_back(ia); } else { @@ -729,16 +711,16 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const } } else { - String ext = file.get_extension().to_lower(); + String ext = f.get_extension().to_lower(); if (!valid_extensions.has(ext)) continue; //invalid - int idx = p_dir->find_file_index(file); + int idx = p_dir->find_file_index(f); if (idx == -1) { //never seen this file, add actition to add it EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo); - fi->file = file; + fi->file = f; String path = cd.plus_file(fi->file); fi->modified_time = FileAccess::get_modified_time(path); @@ -749,7 +731,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const ItemAction ia; ia.action = ItemAction::ACTION_FILE_ADD; ia.dir = p_dir; - ia.file = file; + ia.file = f; ia.new_file = fi; scan_actions.push_back(ia); } @@ -757,14 +739,14 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const if (import_extensions.has(ext)) { //if it can be imported, and it was added, it needs to be reimported print_line("REIMPORT: file was not found before, reimport"); - print_line("at dir: " + p_dir->get_path() + " file: " + file); + print_line("at dir: " + p_dir->get_path() + " file: " + f); for (int i = 0; i < p_dir->files.size(); i++) { print_line(itos(i) + ": " + p_dir->files[i]->file); } ItemAction ia; ia.action = ItemAction::ACTION_FILE_REIMPORT; ia.dir = p_dir; - ia.file = file; + ia.file = f; scan_actions.push_back(ia); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index bff22655ff..5f88a928ca 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -360,6 +360,7 @@ void EditorNode::_notification(int p_what) { if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); + property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/capitalize_properties", true))); } } @@ -2688,6 +2689,14 @@ void EditorNode::_editor_select(int p_which) { editor_plugin_screen = new_editor; editor_plugin_screen->make_visible(true); editor_plugin_screen->selected_notify(); + + if (EditorSettings::get_singleton()->get("interface/separate_distraction_mode")) { + if (p_which == EDITOR_SCRIPT) { + set_distraction_free_mode(script_distraction); + } else { + set_distraction_free_mode(scene_distraction); + } + } } void EditorNode::add_editor_plugin(EditorPlugin *p_editor) { @@ -4381,7 +4390,25 @@ bool EditorNode::get_docks_visible() const { void EditorNode::_toggle_distraction_free_mode() { - set_distraction_free_mode(distraction_free->is_pressed()); + if (EditorSettings::get_singleton()->get("interface/separate_distraction_mode")) { + int screen = -1; + for (int i = 0; i < editor_table.size(); i++) { + if (editor_plugin_screen == editor_table[i]) { + screen = i; + break; + } + } + + if (screen == EDITOR_SCRIPT) { + script_distraction = not script_distraction; + set_distraction_free_mode(script_distraction); + } else { + scene_distraction = not scene_distraction; + set_distraction_free_mode(scene_distraction); + } + } else { + set_distraction_free_mode(distraction_free->is_pressed()); + } } void EditorNode::set_distraction_free_mode(bool p_enter) { @@ -4805,6 +4832,9 @@ EditorNode::EditorNode() { _initializing_addons = false; docks_visible = true; + scene_distraction = false; + script_distraction = false; + FileAccess::set_backup_save(true); TranslationServer::get_singleton()->set_enabled(false); @@ -4942,13 +4972,11 @@ EditorNode::EditorNode() { //top_dark_vb->add_child(scene_tabs); //left left_l_hsplit = memnew(HSplitContainer); - left_l_hsplit->add_constant_override("separation", 8 * EDSCALE); main_vbox->add_child(left_l_hsplit); left_l_hsplit->set_v_size_flags(Control::SIZE_EXPAND_FILL); left_l_vsplit = memnew(VSplitContainer); - left_l_vsplit->add_constant_override("separation", 8 * EDSCALE); left_l_hsplit->add_child(left_l_vsplit); dock_slot[DOCK_SLOT_LEFT_UL] = memnew(TabContainer); left_l_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_UL]); @@ -4959,10 +4987,8 @@ EditorNode::EditorNode() { dock_slot[DOCK_SLOT_LEFT_BL]->hide(); left_r_hsplit = memnew(HSplitContainer); - left_r_hsplit->add_constant_override("separation", 8 * EDSCALE); left_l_hsplit->add_child(left_r_hsplit); left_r_vsplit = memnew(VSplitContainer); - left_r_hsplit->add_constant_override("separation", 8 * EDSCALE); left_r_hsplit->add_child(left_r_vsplit); dock_slot[DOCK_SLOT_LEFT_UR] = memnew(TabContainer); left_r_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_UR]); @@ -4973,7 +4999,6 @@ EditorNode::EditorNode() { //dock_slot[DOCK_SLOT_LEFT_BR]->hide(); main_hsplit = memnew(HSplitContainer); - main_hsplit->add_constant_override("separation", 8 * EDSCALE); left_r_hsplit->add_child(main_hsplit); //main_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); VBoxContainer *center_vb = memnew(VBoxContainer); @@ -4981,18 +5006,15 @@ EditorNode::EditorNode() { center_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); center_split = memnew(VSplitContainer); - center_split->add_constant_override("separation", 8 * EDSCALE); //main_hsplit->add_child(center_split); center_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); center_split->set_collapsed(false); center_vb->add_child(center_split); right_hsplit = memnew(HSplitContainer); - right_hsplit->add_constant_override("separation", 8 * EDSCALE); main_hsplit->add_child(right_hsplit); right_l_vsplit = memnew(VSplitContainer); - right_l_vsplit->add_constant_override("separation", 8 * EDSCALE); right_hsplit->add_child(right_l_vsplit); dock_slot[DOCK_SLOT_RIGHT_UL] = memnew(TabContainer); right_l_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_UL]); @@ -5003,7 +5025,6 @@ EditorNode::EditorNode() { //dock_slot[DOCK_SLOT_RIGHT_BL]->hide(); right_r_vsplit = memnew(VSplitContainer); - right_r_vsplit->add_constant_override("separation", 8 * EDSCALE); right_hsplit->add_child(right_r_vsplit); dock_slot[DOCK_SLOT_RIGHT_UR] = memnew(TabContainer); right_r_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_UR]); @@ -5062,7 +5083,6 @@ EditorNode::EditorNode() { dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL); dock_slot[i]->set_popup(dock_select_popoup); dock_slot[i]->connect("pre_popup_pressed", this, "_dock_pre_popup", varray(i)); - dock_slot[i]->add_constant_override("side_margin", 0); //dock_slot[i]->set_tab_align(TabContainer::ALIGN_LEFT); } @@ -5073,7 +5093,6 @@ EditorNode::EditorNode() { dock_drag_timer->connect("timeout", this, "_save_docks"); top_split = memnew(VSplitContainer); - top_split->add_constant_override("separation", 8 * EDSCALE); center_split->add_child(top_split); top_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); top_split->set_collapsed(true); @@ -5638,6 +5657,7 @@ EditorNode::EditorNode() { property_editor->set_show_categories(true); property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); property_editor->set_use_doc_hints(true); + property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/capitalize_properties", true))); property_editor->hide_top_label(); property_editor->register_text_enter(search_box); diff --git a/editor/editor_node.h b/editor/editor_node.h index 7de713eae9..fc107bb505 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -357,6 +357,9 @@ private: bool docks_visible; ToolButton *distraction_free; + bool scene_distraction; + bool script_distraction; + String _tmp_import_path; EditorExport *editor_export; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 5f2a4d2269..7d7db5ac75 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -509,6 +509,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("interface/dim_transition_time", 0.08f); hints["interface/dim_transition_time"] = PropertyInfo(Variant::REAL, "interface/dim_transition_time", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_DEFAULT); + set("interface/separate_distraction_mode", false); + set("filesystem/directories/autoscan_project_path", ""); hints["filesystem/directories/autoscan_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/autoscan_project_path", PROPERTY_HINT_GLOBAL_DIR); set("filesystem/directories/default_project_path", ""); @@ -558,6 +560,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("text_editor/completion/auto_brace_complete", false); set("text_editor/files/restore_scripts_on_load", true); set("text_editor/completion/complete_file_paths", true); + set("text_editor/files/maximum_recent_files", 20); + hints["text_editor/files/maximum_recent_files"] = PropertyInfo(Variant::INT, "text_editor/files/maximum_recent_files", PROPERTY_HINT_RANGE, "1, 200, 0"); //set("docks/scene_tree/display_old_action_buttons",false); set("docks/scene_tree/start_create_dialog_fully_expanded", false); @@ -587,6 +591,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("editors/3d/emulate_3_button_mouse", false); set("editors/3d/warped_mouse_panning", true); + set("editors/3d/freelook_base_speed", 5); + set("editors/3d/freelook_acceleration", 10); + set("editors/3d/freelook_max_speed", 100); + set("editors/3d/freelook_modifier_speed_factor", 1.0 / 5.0); + set("editors/2d/bone_width", 5); set("editors/2d/bone_color1", Color(1.0, 1.0, 1.0, 0.9)); set("editors/2d/bone_color2", Color(0.75, 0.75, 0.75, 0.9)); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index dee83c6bc3..1457f6b421 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -69,6 +69,11 @@ Ref<Theme> create_editor_theme() { theme->set_stylebox("bg", "ItemList", style_bg); theme->set_stylebox("EditorBG", "EditorStyles", style_bg); + Ref<StyleBox> style_tree_btn = theme->get_stylebox("button_pressed", "Tree"); + style_tree_btn->set_default_margin(MARGIN_LEFT, 3 * EDSCALE); + style_tree_btn->set_default_margin(MARGIN_RIGHT, 3 * EDSCALE); + theme->set_stylebox("button_pressed", "Tree", style_tree_btn); + Ref<StyleBoxFlat> style_tab(memnew(StyleBoxFlat)); style_tab->set_default_margin(MARGIN_LEFT, 15 * EDSCALE); style_tab->set_default_margin(MARGIN_RIGHT, 15 * EDSCALE); @@ -114,6 +119,10 @@ Ref<Theme> create_editor_theme() { style_textedit_normal->set_default_margin(MARGIN_TOP, 0); theme->set_stylebox("normal", "TextEdit", style_textedit_normal); + theme->set_constant("separation", "HSplitContainer", 8 * EDSCALE); + theme->set_constant("separation", "VSplitContainer", 8 * EDSCALE); + theme->set_constant("side_margin", "TabContainer", 0); + // theme->set_color("prop_category","Editor",Color::hex(0x3f3a44ff)); // theme->set_color("prop_section","Editor",Color::hex(0x35313aff)); // theme->set_color("prop_subsection","Editor",Color::hex(0x312e37ff)); diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 83ada90144..e6f15d1712 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -1,11 +1,40 @@ +/*************************************************************************/ +/* export_template_manager.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "export_template_manager.h" + #include "editor_node.h" #include "editor_scale.h" +#include "io/zip_io.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()) { diff --git a/editor/export_template_manager.h b/editor/export_template_manager.h index c3834ec643..480c73e123 100644 --- a/editor/export_template_manager.h +++ b/editor/export_template_manager.h @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* export_template_manager.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef EXPORT_TEMPLATE_MANAGER_H #define EXPORT_TEMPLATE_MANAGER_H diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index dcbc509865..2cefcdbc4a 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -1863,7 +1863,7 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im node = node_name_map[at.target]; } else { - print_line("Coudlnt find node: " + at.target); + print_line("Couldnt find node: " + at.target); continue; } } else { diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 19fd1208b9..21c2ae6eb3 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -168,18 +168,23 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s if (face[idx].size() == 3) { int norm = face[idx][2].to_int() - 1; + if (norm < 0) + norm += normals.size() + 1; ERR_FAIL_INDEX_V(norm, normals.size(), ERR_PARSE_ERROR); surf_tool->add_normal(normals[norm]); } if (face[idx].size() >= 2 && face[idx][1] != String()) { - int uv = face[idx][1].to_int() - 1; + if (uv < 0) + uv += uvs.size() + 1; ERR_FAIL_INDEX_V(uv, uvs.size(), ERR_PARSE_ERROR); surf_tool->add_uv(uvs[uv]); } int vtx = face[idx][0].to_int() - 1; + if (vtx < 0) + vtx += vertices.size() + 1; ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_PARSE_ERROR); Vector3 vertex = vertices[vtx]; diff --git a/editor/io_plugins/editor_scene_import_plugin.cpp b/editor/io_plugins/editor_scene_import_plugin.cpp index cd6acbb374..fed02b0e72 100644 --- a/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/editor/io_plugins/editor_scene_import_plugin.cpp @@ -1093,7 +1093,7 @@ const EditorSceneImportDialog::FlagInfo EditorSceneImportDialog::scene_flag_name {EditorSceneImportPlugin::SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,("Merge"),"Keep user-added Animation tracks.",true}, {EditorSceneImportPlugin::SCENE_FLAG_DETECT_ALPHA,("Materials"),"Set Alpha in Materials (-alpha)",true}, {EditorSceneImportPlugin::SCENE_FLAG_DETECT_VCOLOR,("Materials"),"Set Vert. Color in Materials (-vcol)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_COLLISIONS,("Create"),"Create Collisions and/or Rigid Bodies (-col,-colonly,-rigid)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_COLLISIONS,("Create"),"Create Collisions and/or Rigid Bodies (-col,-colonly,-rigid,-rigidonly)",true}, {EditorSceneImportPlugin::SCENE_FLAG_CREATE_PORTALS,("Create"),"Create Portals (-portal)",true}, {EditorSceneImportPlugin::SCENE_FLAG_CREATE_ROOMS,("Create"),"Create Rooms (-room)",true}, {EditorSceneImportPlugin::SCENE_FLAG_SIMPLIFY_ROOMS,("Create"),"Simplify Rooms",false}, @@ -1714,12 +1714,14 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> //mi->set_baked_light_texture_id(layer); } - if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(name,"colonly")) { + bool is_rigid = _teststr(name, "rigidonly"); + + if (p_flags & SCENE_FLAG_CREATE_COLLISIONS && (_teststr(name, "colonly") || is_rigid)) { if (isroot) return p_node; - - if (p_node->cast_to<MeshInstance>()) { + + if (p_node->cast_to<MeshInstance>() && !is_rigid) { MeshInstance *mi = p_node->cast_to<MeshInstance>(); Node * col = mi->create_trimesh_collision_node(); ERR_FAIL_COND_V(!col,NULL); @@ -1739,10 +1741,16 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> } else if (p_node->has_meta("empty_draw_type")) { String empty_draw_type = String(p_node->get_meta("empty_draw_type")); print_line(empty_draw_type); - StaticBody *sb = memnew( StaticBody); - sb->set_name(_fixstr(name,"colonly")); - sb->cast_to<Spatial>()->set_transform(p_node->cast_to<Spatial>()->get_transform()); - p_node->replace_by(sb); + PhysicsBody *pb; + if (is_rigid) { + pb = memnew(RigidBody); + pb->set_name(_fixstr(name, "rigidonly")); + } else { + pb = memnew(StaticBody); + pb->set_name(_fixstr(name, "colonly")); + } + pb->cast_to<Spatial>()->set_transform(p_node->cast_to<Spatial>()->get_transform()); + p_node->replace_by(pb); memdelete(p_node); CollisionShape *colshape = memnew( CollisionShape); if (empty_draw_type == "CUBE") { @@ -1755,7 +1763,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> rayShape->set_length(1); colshape->set_shape(rayShape); colshape->set_name("RayShape"); - sb->cast_to<Spatial>()->rotate_x(Math_PI / 2); + pb->cast_to<Spatial>()->rotate_x(Math_PI / 2); } else if (empty_draw_type == "IMAGE") { PlaneShape *planeShape = memnew( PlaneShape); colshape->set_shape(planeShape); @@ -1766,8 +1774,8 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> colshape->set_shape(sphereShape); colshape->set_name("SphereShape"); } - sb->add_child(colshape); - colshape->set_owner(sb->get_owner()); + pb->add_child(colshape); + colshape->set_owner(pb->get_owner()); } } else if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(name,"rigid") && p_node->cast_to<MeshInstance>()) { diff --git a/editor/io_plugins/editor_texture_import_plugin.cpp b/editor/io_plugins/editor_texture_import_plugin.cpp index ba380f0334..d9b4a95045 100644 --- a/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/editor/io_plugins/editor_texture_import_plugin.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_texture_import_plugin.h" + #if 0 #include "editor/editor_node.h" #include "editor/editor_settings.h" @@ -35,13 +36,14 @@ #include "global_config.h" #include "io/image_loader.h" #include "io/marshalls.h" -#include "io/md5.h" #include "io/resource_saver.h" #include "scene/gui/button_group.h" #include "scene/gui/check_button.h" #include "scene/gui/margin_container.h" #include "scene/io/resource_format_image.h" +#include "thirdparty/misc/md5.h" + static const char *flag_names[]={ ("Streaming Format"), ("Fix Border Alpha"), diff --git a/editor/io_plugins/editor_translation_import_plugin.cpp b/editor/io_plugins/editor_translation_import_plugin.cpp index 8fba33f787..caa0659046 100644 --- a/editor/io_plugins/editor_translation_import_plugin.cpp +++ b/editor/io_plugins/editor_translation_import_plugin.cpp @@ -347,7 +347,7 @@ public: add_to_project = memnew( CheckButton); add_to_project->set_pressed(true); - add_to_project->set_text(TTR("Add to Project (godot.cfg)")); + add_to_project->set_text(TTR("Add to Project (project.godot)")); tcomp->add_child(add_to_project); file_select = memnew(EditorFileDialog); diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 52edc75bc0..f3ad5c0fd1 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -1,8 +1,38 @@ +/*************************************************************************/ +/* curve_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "curve_editor_plugin.h" #include "canvas_item_editor_plugin.h" #include "os/keyboard.h" #include "spatial_editor_plugin.h" + void CurveTextureEdit::_gui_input(const InputEvent &p_event) { if (p_event.type == InputEvent::KEY && p_event.key.pressed && p_event.key.scancode == KEY_DELETE && grabbed != -1) { diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h index e98cec2727..ebe05539aa 100644 --- a/editor/plugins/curve_editor_plugin.h +++ b/editor/plugins/curve_editor_plugin.h @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* curve_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef CURVE_EDITOR_PLUGIN_H #define CURVE_EDITOR_PLUGIN_H diff --git a/editor/plugins/gradient_texture_editor_plugin.cpp b/editor/plugins/gradient_texture_editor_plugin.cpp index 9551fe19fa..41dd64d931 100644 --- a/editor/plugins/gradient_texture_editor_plugin.cpp +++ b/editor/plugins/gradient_texture_editor_plugin.cpp @@ -1,10 +1,39 @@ +/*************************************************************************/ +/* gradient_texture_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "gradient_texture_editor_plugin.h" #include "canvas_item_editor_plugin.h" -#include "spatial_editor_plugin.h" - #include "os/keyboard.h" #include "scene/resources/default_theme/theme_data.h" +#include "spatial_editor_plugin.h" + #define POINT_WIDTH 8 GradientTextureEdit::GradientTextureEdit() { diff --git a/editor/plugins/gradient_texture_editor_plugin.h b/editor/plugins/gradient_texture_editor_plugin.h index 5af828f17c..cb2f6b4061 100644 --- a/editor/plugins/gradient_texture_editor_plugin.h +++ b/editor/plugins/gradient_texture_editor_plugin.h @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* gradient_texture_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef GRADIENT_TEXTURE_EDITOR_PLUGIN_H #define GRADIENT_TEXTURE_EDITOR_PLUGIN_H diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index b029f8a3fe..a5414325d0 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -411,6 +411,80 @@ void ScriptEditor::_go_to_tab(int p_idx) { _update_selected_editor_menu(); } +void ScriptEditor::_add_recent_script(String p_path) { + + if (p_path.empty()) { + return; + } + + // remove if already stored + int already_recent = previous_scripts.find(p_path); + if (already_recent >= 0) { + previous_scripts.remove(already_recent); + } + + // add to list + previous_scripts.insert(0, p_path); + + _update_recent_scripts(); +} + +void ScriptEditor::_update_recent_scripts() { + + // make sure we don't exceed max size + const int max_history = EDITOR_DEF("text_editor/files/maximum_recent_files", 20); + if (previous_scripts.size() > max_history) { + previous_scripts.resize(max_history); + } + + recent_scripts->clear(); + + recent_scripts->add_shortcut(ED_SHORTCUT("script_editor/open_recent", TTR("Open Recent"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_T)); + recent_scripts->add_separator(); + + const int max_shown = 8; + for (int i = 0; i < previous_scripts.size() && i <= max_shown; i++) { + String path = previous_scripts.get(i); + // just show script name and last dir + recent_scripts->add_item(path.get_slice("/", path.get_slice_count("/") - 2) + "/" + path.get_file()); + } + + recent_scripts->add_separator(); + recent_scripts->add_shortcut(ED_SHORTCUT("script_editor/clear_recent", TTR("Clear Recent Files"))); +} + +void ScriptEditor::_open_recent_script(int p_idx) { + + // clear button + if (p_idx == recent_scripts->get_item_count() - 1) { + previous_scripts.clear(); + _update_recent_scripts(); + return; + } + + // take two for the open recent button + if (p_idx > 0) { + p_idx -= 2; + } + + if (p_idx < previous_scripts.size() && p_idx >= 0) { + + String path = previous_scripts.get(p_idx); + // if its not on disk its a help file or deleted + if (FileAccess::exists(path)) { + Ref<Script> script = ResourceLoader::load(path); + if (script.is_valid()) { + edit(script, true); + } + // if it's a path then its most likely a delted file not help + } else if (!path.is_resource_file()) { + _help_class_open(path); + } + previous_scripts.remove(p_idx); + _update_recent_scripts(); + } +} + void ScriptEditor::_close_tab(int p_idx, bool p_save) { int selected = p_idx; @@ -420,12 +494,16 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { Node *tselected = tab_container->get_child(selected); ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>(); if (current) { + _add_recent_script(current->get_edited_script()->get_path()); if (p_save) { apply_scripts(); } if (current->get_edit_menu()) { memdelete(current->get_edit_menu()); } + } else { + EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>(); + _add_recent_script(help->get_class()); } //remove from history @@ -1978,6 +2056,7 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_close_discard_current_tab", &ScriptEditor::_close_discard_current_tab); ClassDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab); ClassDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs); + ClassDB::bind_method("_open_recent_script", &ScriptEditor::_open_recent_script); ClassDB::bind_method("_editor_play", &ScriptEditor::_editor_play); ClassDB::bind_method("_editor_pause", &ScriptEditor::_editor_pause); ClassDB::bind_method("_editor_stop", &ScriptEditor::_editor_stop); @@ -2024,7 +2103,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { add_child(menu_hb); script_split = memnew(HSplitContainer); - script_split->add_constant_override("separation", 8 * EDSCALE); add_child(script_split); script_split->set_v_size_flags(SIZE_EXPAND_FILL); @@ -2049,6 +2127,14 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->set_text(TTR("File")); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new", TTR("New")), FILE_NEW); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/open", TTR("Open")), FILE_OPEN); + file_menu->get_popup()->add_submenu_item(TTR("Open Recent"), "RecentScripts", FILE_OPEN_RECENT); + + recent_scripts = memnew(PopupMenu); + recent_scripts->set_name("RecentScripts"); + file_menu->get_popup()->add_child(recent_scripts); + recent_scripts->connect("id_pressed", this, "_open_recent_script"); + _update_recent_scripts(); + file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save", TTR("Save"), KEY_MASK_ALT | KEY_MASK_CMD | KEY_S), FILE_SAVE); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_as", TTR("Save As..")), FILE_SAVE_AS); @@ -2355,6 +2441,9 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { EDITOR_DEF("text_editor/open_scripts/list_script_names_as", 0); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "text_editor/external/exec_path", PROPERTY_HINT_GLOBAL_FILE)); EDITOR_DEF("text_editor/external/exec_flags", ""); + + ED_SHORTCUT("script_editor/open_recent", TTR("Open Recent"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_T); + ED_SHORTCUT("script_editor/clear_recent", TTR("Clear Recent Files")); } ScriptEditorPlugin::~ScriptEditorPlugin() { diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 6a54609167..983847ddaf 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -120,6 +120,7 @@ class ScriptEditor : public VBoxContainer { enum { FILE_NEW, FILE_OPEN, + FILE_OPEN_RECENT, FILE_SAVE, FILE_SAVE_AS, FILE_SAVE_ALL, @@ -169,6 +170,8 @@ class ScriptEditor : public VBoxContainer { Timer *autosave_timer; uint64_t idle; + PopupMenu *recent_scripts; + Button *help_search; Button *site_search; Button *class_search; @@ -207,6 +210,8 @@ class ScriptEditor : public VBoxContainer { Vector<ScriptHistory> history; int history_pos; + Vector<String> previous_scripts; + EditorHelpIndex *help_index; void _tab_changed(int p_which); @@ -224,6 +229,10 @@ class ScriptEditor : public VBoxContainer { bool _test_script_times_on_disk(Ref<Script> p_for_script = Ref<Script>()); + void _add_recent_script(String p_path); + void _update_recent_scripts(); + void _open_recent_script(int p_idx); + void _close_tab(int p_idx, bool p_save = true); void _close_current_tab(); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index d73349f773..8a8add5611 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -58,20 +58,26 @@ void SpatialEditorViewport::_update_camera() { } else camera->set_perspective(get_fov(), get_znear(), get_zfar()); + Transform camera_transform = to_camera_transform(cursor); + + if (camera->get_global_transform() != camera_transform) { + camera->set_global_transform(camera_transform); + update_transform_gizmo_view(); + } +} + +Transform SpatialEditorViewport::to_camera_transform(const Cursor &p_cursor) const { Transform camera_transform; - camera_transform.translate(cursor.pos); - camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot); - camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot); + camera_transform.translate(p_cursor.pos); + camera_transform.basis.rotate(Vector3(1, 0, 0), -p_cursor.x_rot); + camera_transform.basis.rotate(Vector3(0, 1, 0), -p_cursor.y_rot); if (orthogonal) camera_transform.translate(0, 0, 4096); else - camera_transform.translate(0, 0, cursor.distance); + camera_transform.translate(0, 0, p_cursor.distance); - if (camera->get_global_transform() != camera_transform) { - camera->set_global_transform(camera_transform); - update_transform_gizmo_view(); - } + return camera_transform; } String SpatialEditorGizmo::get_handle_name(int p_idx) const { @@ -669,8 +675,7 @@ void SpatialEditorViewport::_list_select(InputEventMouseButton b) { selection_menu->add_item(spat->get_name()); selection_menu->set_item_icon(i, icon); selection_menu->set_item_metadata(i, node_path); - selection_menu->set_item_tooltip(i, String(spat->get_name()) + - "\nType: " + spat->get_class() + "\nPath: " + node_path); + selection_menu->set_item_tooltip(i, String(spat->get_name()) + "\nType: " + spat->get_class() + "\nPath: " + node_path); } selection_menu->set_global_position(Vector2(b.global_x, b.global_y)); @@ -729,76 +734,6 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (_edit.mode == TRANSFORM_NONE && b.pressed) { - Plane cursor_plane(cursor.cursor_pos, _get_camera_normal()); - - Vector3 ray_origin = _get_ray_pos(Vector2(b.x, b.y)); - Vector3 ray_dir = _get_ray(Vector2(b.x, b.y)); - - //gizmo modify - - if (b.mod.control) { - - Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(ray_origin, ray_dir, get_tree()->get_root()->get_world()->get_scenario()); - - Plane p(ray_origin, _get_camera_normal()); - - float min_d = 1e10; - bool found = false; - - for (int i = 0; i < instances.size(); i++) { - - Object *obj = ObjectDB::get_instance(instances[i]); - - if (!obj) - continue; - - VisualInstance *vi = obj->cast_to<VisualInstance>(); - if (!vi) - continue; - - //optimize by checking AABB (although should pre sort by distance) - Rect3 aabb = vi->get_global_transform().xform(vi->get_aabb()); - if (p.distance_to(aabb.get_support(-ray_dir)) > min_d) - continue; - - PoolVector<Face3> faces = vi->get_faces(VisualInstance::FACES_SOLID); - int c = faces.size(); - if (c > 0) { - PoolVector<Face3>::Read r = faces.read(); - - for (int j = 0; j < c; j++) { - - Vector3 inters; - if (r[j].intersects_ray(ray_origin, ray_dir, &inters)) { - - float d = p.distance_to(inters); - if (d < 0) - continue; - - if (d < min_d) { - min_d = d; - found = true; - } - } - } - } - } - - if (found) { - - //cursor.cursor_pos=ray_origin+ray_dir*min_d; - //VisualServer::get_singleton()->instance_set_transform(cursor_instance,Transform(Matrix3(),cursor.cursor_pos)); - } - - } else { - Vector3 new_pos; - if (cursor_plane.intersects_ray(ray_origin, ray_dir, &new_pos)) { - - //cursor.cursor_pos=new_pos; - //VisualServer::get_singleton()->instance_set_transform(cursor_instance,Transform(Matrix3(),cursor.cursor_pos)); - } - } - if (b.mod.alt) { if (nav_scheme == NAVIGATION_MAYA) @@ -1344,6 +1279,8 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (nav_scheme == NAVIGATION_MAYA && m.mod.alt) { nav_mode = NAVIGATION_ZOOM; + } else { + nav_mode = NAVIGATION_LOOK; } } else if (m.button_mask & 4) { @@ -1453,6 +1390,29 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { _update_name(); } break; + case NAVIGATION_LOOK: { + // Freelook only works properly in perspective. + // It technically works too in ortho, but it's awful for a user due to fov being near zero + if (!orthogonal) { + cursor.x_rot += m.relative_y / 120.0; + cursor.y_rot += m.relative_x / 120.0; + if (cursor.x_rot > Math_PI / 2.0) + cursor.x_rot = Math_PI / 2.0; + if (cursor.x_rot < -Math_PI / 2.0) + cursor.x_rot = -Math_PI / 2.0; + + // Look is like Orbit, except the cursor translates, not the camera + Transform camera_transform = to_camera_transform(cursor); + Vector3 pos = camera_transform.xform(Vector3(0, 0, 0)); + Vector3 diff = camera->get_translation() - pos; + cursor.pos += diff; + + name = ""; + _update_name(); + } + + } break; + default: {} } } break; @@ -1543,6 +1503,75 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } } +void SpatialEditorViewport::_update_freelook(real_t delta) { + + const Input &input = *Input::get_singleton(); + + if (!input.is_mouse_button_pressed(BUTTON_RIGHT)) + return; + + Vector3 forward = camera->get_transform().basis.xform(Vector3(0, 0, -1)); + Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0)); + Vector3 up = Vector3(0, 1, 0); + + int key_left = ED_SHORTCUT("spatial_editor/freelook_left", TTR("Freelook Left"), KEY_A)->get_shortcut().key.scancode; + int key_right = ED_SHORTCUT("spatial_editor/freelook_right", TTR("Freelook Right"), KEY_D)->get_shortcut().key.scancode; + int key_forward = ED_SHORTCUT("spatial_editor/freelook_forward", TTR("Freelook Forward"), KEY_W)->get_shortcut().key.scancode; + int key_backwards = ED_SHORTCUT("spatial_editor/freelook_backwards", TTR("Freelook Backwards"), KEY_S)->get_shortcut().key.scancode; + int key_up = ED_SHORTCUT("spatial_editor/freelook_up", TTR("Freelook Up"), KEY_Q)->get_shortcut().key.scancode; + int key_down = ED_SHORTCUT("spatial_editor/freelook_down", TTR("Freelook Down"), KEY_E)->get_shortcut().key.scancode; + int key_speed_modifier = ED_SHORTCUT("spatial_editor/freelook_speed_modifier", TTR("Freelook Speed Modifier"), KEY_SHIFT)->get_shortcut().key.scancode; + + Vector3 velocity; + bool pressed = false; + bool speed_modifier = false; + + if (input.is_key_pressed(key_left)) { + velocity -= right; + pressed = true; + } + if (input.is_key_pressed(key_right)) { + velocity += right; + pressed = true; + } + if (input.is_key_pressed(key_forward)) { + velocity += forward; + pressed = true; + } + if (input.is_key_pressed(key_backwards)) { + velocity -= forward; + pressed = true; + } + if (input.is_key_pressed(key_up)) { + velocity += up; + pressed = true; + } + if (input.is_key_pressed(key_down)) { + velocity -= up; + pressed = true; + } + if (input.is_key_pressed(key_speed_modifier)) { + speed_modifier = true; + } + + const EditorSettings &s = *EditorSettings::get_singleton(); + + real_t base_speed = s.get("editors/3d/freelook_base_speed"); + real_t acceleration = s.get("editors/3d/freelook_acceleration"); + real_t max_speed = s.get("editors/3d/freelook_max_speed"); + real_t modifier_speed_factor = s.get("editors/3d/freelook_modifier_speed_factor"); + + if (pressed) { + velocity.normalize(); + freelook_speed += acceleration * delta; + if (freelook_speed > max_speed) + freelook_speed = max_speed; + cursor.pos += velocity * ((freelook_speed * (speed_modifier ? modifier_speed_factor : 1.0) * delta)); + } else { + freelook_speed = base_speed; + } +} + void SpatialEditorViewport::set_message(String p_message, float p_time) { message = p_message; @@ -1579,6 +1608,8 @@ void SpatialEditorViewport::_notification(int p_what) { } */ + _update_freelook(get_tree()->get_idle_process_time()); + _update_camera(); Map<Node *, Object *> &selection = editor_selection->get_selection(); @@ -2204,6 +2235,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed previewing = NULL; preview = NULL; gizmo_scale = 1.0; + freelook_speed = 0; selection_menu = memnew(PopupMenu); add_child(selection_menu); @@ -3149,36 +3181,6 @@ void SpatialEditor::_finish_indicators() { VisualServer::get_singleton()->free(cursor_mesh); } -void SpatialEditor::_instance_scene() { -#if 0 - EditorNode *en = get_scene()->get_root_node()->cast_to<EditorNode>(); - ERR_FAIL_COND(!en); - String path = en->get_filesystem_dock()->get_selected_path(); - if (path=="") { - set_message(TTR("No scene selected to instance!")); - return; - } - - undo_redo->create_action(TTR("Instance at Cursor")); - - Node* scene = en->request_instance_scene(path); - - if (!scene) { - set_message(TTR("Could not instance scene!")); - undo_redo->commit_action(); //bleh - return; - } - - Spatial *s = scene->cast_to<Spatial>(); - if (s) { - - undo_redo->add_do_method(s,"set_global_transform",Transform(Matrix3(),cursor.cursor_pos)); - } - - undo_redo->commit_action(); -#endif -} - void SpatialEditor::_unhandled_key_input(InputEvent p_event) { if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack()) @@ -3242,8 +3244,6 @@ void SpatialEditor::_notification(int p_what) { tool_button[SpatialEditor::TOOL_MODE_ROTATE]->set_icon(get_icon("ToolRotate", "EditorIcons")); tool_button[SpatialEditor::TOOL_MODE_SCALE]->set_icon(get_icon("ToolScale", "EditorIcons")); tool_button[SpatialEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_icon("ListSelect", "EditorIcons")); - instance_button->set_icon(get_icon("SpatialAdd", "EditorIcons")); - instance_button->hide(); view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_icon("Panels1", "EditorIcons")); view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_icon("Panels2", "EditorIcons")); @@ -3383,7 +3383,6 @@ void SpatialEditor::_bind_methods() { ClassDB::bind_method("_node_removed", &SpatialEditor::_node_removed); ClassDB::bind_method("_menu_item_pressed", &SpatialEditor::_menu_item_pressed); ClassDB::bind_method("_xform_dialog_action", &SpatialEditor::_xform_dialog_action); - ClassDB::bind_method("_instance_scene", &SpatialEditor::_instance_scene); ClassDB::bind_method("_get_editor_data", &SpatialEditor::_get_editor_data); ClassDB::bind_method("_request_gizmo", &SpatialEditor::_request_gizmo); ClassDB::bind_method("_default_light_angle_input", &SpatialEditor::_default_light_angle_input); @@ -3520,12 +3519,6 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_SCALE]->connect("pressed", this, "_menu_item_pressed", button_binds); tool_button[TOOL_MODE_SCALE]->set_tooltip(TTR("Scale Mode (R)")); - instance_button = memnew(Button); - hbc_menu->add_child(instance_button); - instance_button->set_flat(true); - instance_button->connect("pressed", this, "_instance_scene"); - instance_button->hide(); - VSeparator *vs = memnew(VSeparator); hbc_menu->add_child(vs); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 4302927426..c7336cef86 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -113,6 +113,7 @@ private: bool transforming; bool orthogonal; float gizmo_scale; + real_t freelook_speed; struct _RayResult { @@ -168,7 +169,8 @@ private: NAVIGATION_NONE, NAVIGATION_PAN, NAVIGATION_ZOOM, - NAVIGATION_ORBIT + NAVIGATION_ORBIT, + NAVIGATION_LOOK }; enum TransformMode { TRANSFORM_NONE, @@ -203,8 +205,6 @@ private: struct Cursor { - Vector3 cursor_pos; - Vector3 pos; float x_rot, y_rot, distance; bool region_select; @@ -227,10 +227,12 @@ private: // void _update_camera(); + Transform to_camera_transform(const Cursor &p_cursor) const; void _draw(); void _smouseenter(); void _sinput(const InputEvent &p_ie); + void _update_freelook(real_t delta); SpatialEditor *spatial_editor; Camera *previewing; @@ -385,7 +387,6 @@ private: }; Button *tool_button[TOOL_MAX]; - Button *instance_button; MenuButton *transform_menu; MenuButton *view_menu; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 90db23d236..40ffb8e246 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -229,6 +229,8 @@ void ProjectExportDialog::_edit_preset(int p_index) { } if (needs_templates) export_templates_error->show(); + else + export_templates_error->hide(); export_button->set_disabled(true); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 1a4a36fa18..289655e9da 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -50,19 +50,6 @@ #include "scene/gui/tool_button.h" #include "version.h" -static String _find_project_file(DirAccess *p_da) { - p_da->list_dir_begin(); - while (true) { - String f = p_da->get_next(); - if (f == "") - break; - if (f.get_extension() == "godot") - return p_da->get_current_dir() + "/" + f; - } - p_da->list_dir_end(); - return ""; -} - class NewProjectDialog : public ConfirmationDialog { GDCLASS(NewProjectDialog, ConfirmationDialog); @@ -105,18 +92,18 @@ private: if (mode != MODE_IMPORT) { - if (_find_project_file(d) != "") { + if (d->file_exists("project.godot")) { - error->set_text(TTR("Invalid project path, *.godot must not exist.")); + error->set_text(TTR("Invalid project path, project.godot must not exist.")); memdelete(d); return ""; } } else { - if (valid_path != "" && _find_project_file(d) == "") { + if (valid_path != "" && !d->file_exists("project.godot")) { - error->set_text(TTR("Invalid project path, *.godot must exist.")); + error->set_text(TTR("Invalid project path, project.godot must exist.")); memdelete(d); return ""; } @@ -149,7 +136,7 @@ private: String p = p_path; if (mode == MODE_IMPORT) { - if (p.get_extension() == "godot") { + if (p.ends_with("project.godot")) { p = p.get_base_dir(); } @@ -175,7 +162,7 @@ private: fdialog->set_mode(FileDialog::MODE_OPEN_FILE); fdialog->clear_filters(); - fdialog->add_filter("*.godot ; " _MKSTR(VERSION_NAME) " Project"); + fdialog->add_filter("project.godot ; " _MKSTR(VERSION_NAME) " Project"); } else { fdialog->set_mode(FileDialog::MODE_OPEN_DIR); } @@ -199,9 +186,9 @@ private: } else { if (mode == MODE_NEW) { - FileAccess *f = FileAccess::open(dir.plus_file("/" + project_name->get_text().replace(" ", "_") + ".godot"), FileAccess::WRITE); + FileAccess *f = FileAccess::open(dir.plus_file("/project.godot"), FileAccess::WRITE); if (!f) { - error->set_text(TTR("Couldn't create *.godot project file in project path.")); + error->set_text(TTR("Couldn't create project.godot in project path.")); } else { f->store_line("; Engine configuration file."); @@ -754,17 +741,10 @@ void ProjectManager::_load_recent_projects() { continue; String project = _name.get_slice("/", 1); - DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - if (dir_access->change_dir(path) != OK) { - EditorSettings::get_singleton()->erase(_name); - continue; - } - String conf = _find_project_file(dir_access); - memdelete(dir_access); + String conf = path.plus_file("project.godot"); bool favorite = (_name.begins_with("favorite_projects/")) ? true : false; uint64_t last_modified = 0; - if (FileAccess::exists(conf)) { last_modified = FileAccess::get_modified_time(conf); @@ -1026,7 +1006,7 @@ void ProjectManager::_scan_dir(DirAccess *da, float pos, float total, List<Strin while (n != String()) { if (da->current_is_dir() && !n.begins_with(".")) { subdirs.push_front(n); - } else if (n.get_extension() == "godot") { + } else if (n == "project.godot") { r_projects->push_back(da->get_current_dir()); } n = da->get_next(); @@ -1137,7 +1117,7 @@ void ProjectManager::_files_dropped(PoolStringArray p_files, int p_screen) { dir->list_dir_begin(); String file = dir->get_next(); while (confirm && file != String()) { - if (!dir->current_is_dir() && file.get_extension() == "godot") { + if (!dir->current_is_dir() && file.ends_with("project.godot")) { confirm = false; } file = dir->get_next(); diff --git a/editor/project_settings.cpp b/editor/project_settings.cpp index 7d9ee91f35..5795e41b92 100644 --- a/editor/project_settings.cpp +++ b/editor/project_settings.cpp @@ -1168,14 +1168,12 @@ void ProjectSettings::_bind_methods() { ProjectSettings::ProjectSettings(EditorData *p_data) { singleton = this; - String project_file = "(" + GlobalConfig::get_singleton()->get_project_file_name() + ")"; - set_title(TTR("Project Settings " + project_file)); + set_title(TTR("Project Settings (project.godot)")); set_resizable(true); undo_redo = &p_data->get_undo_redo(); data = p_data; tab_container = memnew(TabContainer); - tab_container->add_constant_override("side_margin", 0); add_child(tab_container); //set_child_rect(tab_container); @@ -1266,7 +1264,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { //globals_editor->hide_top_label(); globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); globals_editor->get_property_editor()->register_text_enter(search_box); - globals_editor->get_property_editor()->set_capitalize_paths(false); + globals_editor->get_property_editor()->set_enable_capitalize_paths(false); globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected", this, "_item_selected"); globals_editor->get_property_editor()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED); globals_editor->get_property_editor()->connect("property_edited", this, "_settings_prop_edited"); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index f0717f1e6b..5ff5e680f6 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -2769,10 +2769,7 @@ TreeItem *PropertyEditor::get_parent_node(String p_path, HashMap<String, TreeIte item = tree->create_item(parent); String name = (p_path.find("/") != -1) ? p_path.right(p_path.find_last("/") + 1) : p_path; - if (capitalize_paths) - item->set_text(0, name.capitalize()); - else - item->set_text(0, name); + item->set_text(0, capitalize_paths ? name.capitalize() : name); item->set_tooltip(0, p_path); if (item->get_parent() != root) { item->set_icon(0, get_icon("Folder", "EditorIcons")); @@ -3405,6 +3402,13 @@ void PropertyEditor::update_tree() { item->set_icon(0, get_icon("ArrayData", "EditorIcons")); } break; + case Variant::DICTIONARY: { + + item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); + item->set_editable(1, false); + item->set_text(1, obj->get(p.name).operator String()); + + } break; case Variant::POOL_INT_ARRAY: { @@ -4298,9 +4302,15 @@ String PropertyEditor::get_selected_path() const { return ""; } -void PropertyEditor::set_capitalize_paths(bool p_capitalize) { +bool PropertyEditor::is_capitalize_paths_enabled() const { + + return capitalize_paths; +} + +void PropertyEditor::set_enable_capitalize_paths(bool p_capitalize) { capitalize_paths = p_capitalize; + update_tree_pending = true; } void PropertyEditor::set_autoclear(bool p_enable) { diff --git a/editor/property_editor.h b/editor/property_editor.h index 3b68e80ac3..b88ba38e19 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -272,7 +272,8 @@ public: custom_editor->set_read_only(p_read_only); } - void set_capitalize_paths(bool p_capitalize); + bool is_capitalize_paths_enabled() const; + void set_enable_capitalize_paths(bool p_capitalize); void set_autoclear(bool p_enable); void set_show_categories(bool p_show); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index a5cee0c907..ebf4b1cf3a 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -90,11 +90,13 @@ public: return ""; } - void add_property(const String &p_name, const Variant &p_value) { + void add_property(const String &p_name, const Variant &p_value, const PropertyHint &p_hint, const String p_hint_string) { PropertyInfo pinfo; pinfo.name = p_name; pinfo.type = p_value.get_type(); + pinfo.hint = p_hint; + pinfo.hint_string = p_hint_string; props.push_back(pinfo); values[p_name] = p_value; } @@ -437,7 +439,11 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da inspected_object->last_edited_id = id; - inspect_properties->edit(inspected_object); + if (tabs->get_current_tab() == 2) { + inspect_properties->edit(inspected_object); + } else { + editor->push_item(inspected_object); + } } else if (p_msg == "message:video_mem") { @@ -499,13 +505,20 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String n = p_data[ofs + i * 2 + 0]; Variant v = p_data[ofs + i * 2 + 1]; + PropertyHint h = PROPERTY_HINT_NONE; + String hs = String(); if (n.begins_with("*")) { n = n.substr(1, n.length()); + h = PROPERTY_HINT_OBJECT_ID; + String s = v; + s = s.replace("[", ""); + hs = s.get_slice(":", 0); + v = s.get_slice(":", 1).to_int(); } - variables->add_property("members/" + n, v); + variables->add_property("members/" + n, v, h, hs); } ofs += mcount * 2; @@ -516,13 +529,20 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String n = p_data[ofs + i * 2 + 0]; Variant v = p_data[ofs + i * 2 + 1]; + PropertyHint h = PROPERTY_HINT_NONE; + String hs = String(); if (n.begins_with("*")) { n = n.substr(1, n.length()); + h = PROPERTY_HINT_OBJECT_ID; + String s = v; + s = s.replace("[", ""); + hs = s.get_slice(":", 0); + v = s.get_slice(":", 1).to_int(); } - variables->add_property("locals/" + n, v); + variables->add_property("locals/" + n, v, h, hs); } variables->update(); @@ -1056,6 +1076,9 @@ void ScriptEditorDebugger::stop() { EditorNode::get_singleton()->get_pause_button()->set_pressed(false); EditorNode::get_singleton()->get_pause_button()->set_disabled(true); + //avoid confusion when stopped debugging but an object is still edited + EditorNode::get_singleton()->push_item(NULL); + if (hide_on_stop) { if (is_visible_in_tree()) EditorNode::get_singleton()->hide_bottom_panel(); @@ -1634,8 +1657,9 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { inspector->set_h_size_flags(SIZE_EXPAND_FILL); inspector->hide_top_label(); inspector->get_scene_tree()->set_column_title(0, TTR("Variable")); - inspector->set_capitalize_paths(false); + inspector->set_enable_capitalize_paths(false); inspector->set_read_only(true); + inspector->connect("object_id_selected", this, "_scene_tree_property_select_object"); sc->add_child(inspector); server = TCP_Server::create_ref(); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 70acb8a052..8c87857944 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -300,7 +300,6 @@ EditorSettingsDialog::EditorSettingsDialog() { set_resizable(true); tabs = memnew(TabContainer); - tabs->add_constant_override("side_margin", 0); add_child(tabs); //set_child_rect(tabs); diff --git a/main/main.cpp b/main/main.cpp index 377d15f5f4..33095e8599 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -129,7 +129,7 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(VERSION_FULL_NAME " (c) 2008-2017 Juan Linietsky, Ariel Manzur.\n"); OS::get_singleton()->print("Usage: %s [options] [scene]\n", p_binary); OS::get_singleton()->print("Options:\n"); - OS::get_singleton()->print("\t-path [dir] : Path to a game, containing *.godot\n"); + OS::get_singleton()->print("\t-path [dir] : Path to a game, containing project.godot\n"); #ifdef TOOLS_ENABLED OS::get_singleton()->print("\t-e,-editor : Bring up the editor instead of running the scene.\n"); #endif @@ -447,7 +447,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } else { goto error; } - } else if (I->get().ends_with(".godot")) { + } else if (I->get().ends_with("project.godot")) { String path; String file = I->get(); int sep = MAX(file.find_last("/"), file.find_last("\\")); @@ -457,7 +457,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph path = file.substr(0, sep); } if (OS::get_singleton()->set_cwd(path) == OK) { - + // path already specified, don't override } else { game_path = path; } @@ -690,7 +690,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph else input_map->load_from_globals(); //keys for game - if (video_driver == "") // specified in *.godot + if (video_driver == "") // specified in project.godot video_driver = GLOBAL_DEF("display/driver/name", Variant((const char *)OS::get_singleton()->get_video_driver_name(0))); if (!force_res && use_custom_res && globals->has("display/window/width")) @@ -742,7 +742,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph /* Determine Video Driver */ - if (audio_driver == "") { // specified in *.godot + if (audio_driver == "") { // specified in project.godot audio_driver = GLOBAL_DEF("audio/driver", OS::get_singleton()->get_audio_driver_name(0)); } diff --git a/misc/scripts/sort-demos.sh b/misc/scripts/sort-demos.sh index 2121d78c15..5e01b86b46 100644 --- a/misc/scripts/sort-demos.sh +++ b/misc/scripts/sort-demos.sh @@ -1,7 +1,7 @@ #!/bin/bash # When scanning for demos, the project manager sorts them based on their # timestamp, i.e. last modification date. This can make for a pretty -# messy output, so this script 'touches' each godot.cfg file in reverse +# messy output, so this script 'touches' each project.godot file in reverse # alphabetical order to ensure a nice listing. # # It's good practice to run it once before packaging demos on the build @@ -17,7 +17,7 @@ if [ -e demos.list ]; then fi for dir in 2d 3d gui misc viewport; do - find "demos/$dir" -name "godot.cfg" |sort >> demos.list + find "demos/$dir" -name "project.godot" |sort >> demos.list done cat demos.list |sort -r > demos_r.list diff --git a/modules/openssl/SCsub b/modules/openssl/SCsub index 0e811ce8c9..add7d4dcfc 100644 --- a/modules/openssl/SCsub +++ b/modules/openssl/SCsub @@ -677,7 +677,16 @@ if (env['builtin_openssl'] != 'no'): # Module sources env_openssl.add_source_files(env.modules_sources, "*.cpp") -env_openssl.add_source_files(env.modules_sources, "*.c") + + +# Other thirdparty dependencies +thirdparty_misc_dir = "#thirdparty/misc/" +thirdparty_misc_sources = [ + "curl_hostcheck.c", +] +thirdparty_misc_sources = [thirdparty_misc_dir + file for file in thirdparty_misc_sources] +env_openssl.add_source_files(env.modules_sources, thirdparty_misc_sources) + # platform/uwp need to know openssl is available, pass to main env if "platform" in env and env["platform"] == "uwp": diff --git a/modules/openssl/stream_peer_openssl.h b/modules/openssl/stream_peer_openssl.h index 12262da94a..5c830ebf37 100644 --- a/modules/openssl/stream_peer_openssl.h +++ b/modules/openssl/stream_peer_openssl.h @@ -30,17 +30,19 @@ #ifndef STREAM_PEER_OPEN_SSL_H #define STREAM_PEER_OPEN_SSL_H -#include "curl_hostcheck.h" #include "global_config.h" #include "io/stream_peer_ssl.h" #include "os/file_access.h" -#include <stdio.h> // If you don't know what this is for stop reading now. + +#include "thirdparty/misc/curl_hostcheck.h" #include <openssl/bio.h> // BIO objects for I/O #include <openssl/err.h> // Error reporting #include <openssl/ssl.h> // SSL and SSL_CTX for SSL connections #include <openssl/x509v3.h> +#include <stdio.h> + class StreamPeerOpenSSL : public StreamPeerSSL { private: static int _bio_create(BIO *b); diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp index c6835d4b62..3f7ad8b2c2 100644 --- a/modules/squish/image_compress_squish.cpp +++ b/modules/squish/image_compress_squish.cpp @@ -31,6 +31,12 @@ #include "print_string.h" +#if defined(__SSE2__) +#define SQUISH_USE_SSE 2 +#elif defined(__SSE__) +#define SQUISH_USE_SSE 1 +#endif + #include <squish.h> void image_compress_squish(Image *p_image) { diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index b0870c9dc2..c645a55703 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -30,7 +30,8 @@ #include "audio_stream_ogg_vorbis.h" #include "os/file_access.h" -#include "thirdparty/stb_vorbis/stb_vorbis.c" + +#include "thirdparty/misc/stb_vorbis.c" void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_frames) { diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h index bb895c4dfa..287aa4ca47 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h @@ -34,7 +34,7 @@ #include "servers/audio/audio_stream.h" #define STB_VORBIS_HEADER_ONLY -#include "thirdparty/stb_vorbis/stb_vorbis.c" +#include "thirdparty/misc/stb_vorbis.c" #undef STB_VORBIS_HEADER_ONLY class AudioStreamOGGVorbis; diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 28463e2cba..61112f20b4 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -31,7 +31,8 @@ #include "global_config.h" #include "os/os.h" -#include "yuv2rgb.h" + +#include "thirdparty/misc/yuv2rgb.h" int VideoStreamPlaybackTheora::buffer_data() { diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 9d8062d283..eaf4215302 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -32,12 +32,13 @@ #include "OpusVorbisDecoder.hpp" #include "VPXDecoder.hpp" -#include "../theora/yuv2rgb.h" #include "mkvparser/mkvparser.h" #include "global_config.h" #include "os/file_access.h" +#include "thirdparty/misc/yuv2rgb.h" + #include <string.h> class MkvReader : public mkvparser::IMkvReader { diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index e122bb2e4d..6b1d574496 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -31,94 +31,50 @@ #include "io/resource_loader.h" #include "main/main.h" #include "os_javascript.h" -#include <GL/glut.h> -#include <string.h> OS_JavaScript *os = NULL; -static void _gfx_init(void *ud, bool gl2, int w, int h, bool fs) { +static void main_loop() { - glutInitWindowSize(w, h); - glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutCreateWindow("godot"); + os->main_loop_iterate(); } -static void _gfx_idle() { +extern "C" void main_after_fs_sync() { - glutPostRedisplay(); -} - -int start_step = 0; - -static void _godot_draw(void) { - - if (start_step == 1) { - start_step = 2; - Main::start(); - os->main_loop_begin(); - } - - if (start_step == 2) { - os->main_loop_iterate(); - } - - glutSwapBuffers(); -} - -extern "C" { - -void main_after_fs_sync() { - - start_step = 1; -} + // Ease up compatibility + ResourceLoader::set_abort_on_missing_resources(false); + Main::start(); + os->main_loop_begin(); + emscripten_set_main_loop(main_loop, 0, false); } int main(int argc, char *argv[]) { - /* Initialize the window */ printf("let it go dude!\n"); - glutInit(&argc, argv); - os = new OS_JavaScript(argv[0], _gfx_init, NULL, NULL); - - Error err = Main::setup(argv[0], argc - 1, &argv[1]); - - ResourceLoader::set_abort_on_missing_resources(false); //ease up compatibility - - /* Set up glut callback functions */ - glutIdleFunc(_gfx_idle); - // glutReshapeFunc(gears_reshape); - glutDisplayFunc(_godot_draw); - //glutSpecialFunc(gears_special); - //mount persistent file system + // sync from persistent state into memory and then + // run the 'main_after_fs_sync' function /* clang-format off */ EM_ASM( + Module.noExitRuntime = true; FS.mkdir('/userfs'); FS.mount(IDBFS, {}, '/userfs'); - - // sync from persistent state into memory and then - // run the 'main_after_fs_sync' function FS.syncfs(true, function(err) { - if (err) { Module.setStatus('Failed to load persistent data\nPlease allow (third-party) cookies'); Module.printErr('Failed to populate IDB file system: ' + err.message); - Module.exit(); + Module.noExitRuntime = false; } else { Module.print('Successfully populated IDB file system'); - ccall('main_after_fs_sync', 'void', []); + ccall('main_after_fs_sync', null); } }); ); /* clang-format on */ - glutMainLoop(); + os = new OS_JavaScript(argv[0], NULL); + Error err = Main::setup(argv[0], argc - 1, &argv[1]); return 0; + // continued async in main_after_fs_sync() from syncfs() callback } - -/* - * - *09] <azakai|2__> reduz: yes, define TOTAL_MEMORY on Module. for example var Module = { TOTAL_MEMORY: 12345.. }; before the main - * - */ diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index e99a6e87f6..dda619a54d 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -390,14 +390,18 @@ void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, i print_line("Init OS"); - if (gfx_init_func) - gfx_init_func(gfx_init_ud, use_gl2, p_desired.width, p_desired.height, p_desired.fullscreen); + EmscriptenWebGLContextAttributes attributes; + emscripten_webgl_init_context_attributes(&attributes); + attributes.alpha = false; + attributes.antialias = false; + attributes.majorVersion = 2; + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context(NULL, &attributes); + ERR_FAIL_COND(emscripten_webgl_make_context_current(ctx) != EMSCRIPTEN_RESULT_SUCCESS); - // nothing to do here, can't fulfil fullscreen request due to - // browser security, window size is already set from HTML video_mode = p_desired; + // can't fulfil fullscreen request due to browser security video_mode.fullscreen = false; - _windowed_size = get_window_size(); + set_window_size(Size2(p_desired.width, p_desired.height)); // find locale, emscripten only sets "C" char locale_ptr[16]; @@ -906,10 +910,8 @@ int OS_JavaScript::get_power_percent_left() { return power_manager->get_power_percent_left(); } -OS_JavaScript::OS_JavaScript(const char *p_execpath, GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, GetDataDirFunc p_get_data_dir_func) { +OS_JavaScript::OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_dir_func) { set_cmdline(p_execpath, get_cmdline_args()); - gfx_init_func = p_gfx_init_func; - gfx_init_ud = p_gfx_init_ud; main_loop = NULL; gl_extensions = NULL; window_maximized = false; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 80df03e307..2bc603d8d9 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -45,16 +45,10 @@ #include <emscripten/html5.h> -typedef void (*GFXInitFunc)(void *ud, bool gl2, int w, int h, bool fs); typedef String (*GetDataDirFunc)(); class OS_JavaScript : public OS_Unix { - GFXInitFunc gfx_init_func; - void *gfx_init_ud; - - bool use_gl2; - int64_t time_to_save_sync; int64_t last_sync_time; @@ -170,7 +164,7 @@ public: virtual int get_power_seconds_left(); virtual int get_power_percent_left(); - OS_JavaScript(const char *p_execpath, GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, GetDataDirFunc p_get_data_dir_func); + OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_dir_func); ~OS_JavaScript(); }; diff --git a/platform/uwp/SCsub b/platform/uwp/SCsub index 0167ea9e02..7ee5aa2ac3 100644 --- a/platform/uwp/SCsub +++ b/platform/uwp/SCsub @@ -9,6 +9,7 @@ files = [ '#platform/windows/stream_peer_winsock.cpp', '#platform/windows/key_mapping_win.cpp', 'joypad_uwp.cpp', + 'power_uwp.cpp', 'gl_context_egl.cpp', 'app.cpp', 'os_uwp.cpp', diff --git a/platform/uwp/app.h b/platform/uwp/app.h index 647ef0261b..9cbe7669c9 100644 --- a/platform/uwp/app.h +++ b/platform/uwp/app.h @@ -107,7 +107,7 @@ namespace GodotUWP int last_touch_y[32]; int number_of_contacts; Windows::Foundation::Point last_mouse_pos; - } + }; } /* clang-format on */ diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 4a164e5ba1..976e6208ee 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -72,17 +72,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "editor/editor_import_export.h" #include "editor/editor_node.h" #include "global_config.h" -#include "io/base64.h" #include "io/marshalls.h" -#include "io/sha256.h" -#include "io/unzip.h" -#include "io/zip.h" #include "io/zip_io.h" #include "object.h" #include "os/file_access.h" #include "platform/uwp/logo.h" #include "version.h" +#include "thirdparty/minizip/unzip.h" +#include "thirdparty/minizip/zip.h" +#include "thirdparty/misc/base64.h" +#include "thirdparty/misc/sha256.h" + #include <zlib.h> // Capabilities diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 8b7e821ab3..818b827e83 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -28,24 +28,22 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "os_uwp.h" -#include "drivers/gles2/rasterizer_gles2.h" +#include "drivers/gles3/rasterizer_gles3.h" +#include "drivers/unix/ip_unix.h" #include "drivers/windows/dir_access_windows.h" #include "drivers/windows/file_access_windows.h" #include "drivers/windows/mutex_windows.h" +#include "drivers/windows/rw_lock_windows.h" #include "drivers/windows/semaphore_windows.h" -#include "main/main.h" -#include "os/memory_pool_dynamic_static.h" -#include "servers/audio_server.h" -#include "servers/visual/visual_server_raster.h" -#include "thread_uwp.h" -//#include "servers/visual/visual_server_wrap_mt.h" -#include "drivers/unix/ip_unix.h" #include "global_config.h" #include "io/marshalls.h" -#include "os/memory_pool_dynamic_prealloc.h" +#include "main/main.h" #include "platform/windows/packet_peer_udp_winsock.h" #include "platform/windows/stream_peer_winsock.h" #include "platform/windows/tcp_server_winsock.h" +#include "servers/audio_server.h" +#include "servers/visual/visual_server_raster.h" +#include "thread_uwp.h" #include <ppltasks.h> #include <wrl.h> @@ -149,9 +147,6 @@ const char *OSUWP::get_audio_driver_name(int p_driver) const { return AudioDriverManager::get_driver(p_driver)->get_name(); } -static MemoryPoolStatic *mempool_static = NULL; -static MemoryPoolDynamic *mempool_dynamic = NULL; - void OSUWP::initialize_core() { last_button_state = 0; @@ -161,32 +156,19 @@ void OSUWP::initialize_core() { ThreadUWP::make_default(); SemaphoreWindows::make_default(); MutexWindows::make_default(); + RWLockWindows::make_default(); FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES); FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_USERDATA); FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_FILESYSTEM); - //FileAccessBufferedFA<FileAccessWindows>::make_default(); DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_RESOURCES); DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_USERDATA); DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_FILESYSTEM); - //TCPServerWinsock::make_default(); - //StreamPeerWinsock::make_default(); - TCPServerWinsock::make_default(); StreamPeerWinsock::make_default(); PacketPeerUDPWinsock::make_default(); - mempool_static = new MemoryPoolStaticMalloc; -#if 1 - mempool_dynamic = memnew(MemoryPoolDynamicStatic); -#else -#define DYNPOOL_SIZE 4 * 1024 * 1024 - void *buffer = malloc(DYNPOOL_SIZE); - mempool_dynamic = memnew(MemoryPoolDynamicPrealloc(buffer, DYNPOOL_SIZE)); - -#endif - // We need to know how often the clock is updated if (!QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second)) ticks_per_second = 1000; @@ -259,13 +241,18 @@ void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_aud set_video_mode(vm); gl_context->make_current(); - rasterizer = memnew(RasterizerGLES2); - visual_server = memnew(VisualServerRaster(rasterizer)); + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); + + visual_server = memnew(VisualServerRaster); + // FIXME: Reimplement threaded rendering? Or remove? + /* if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); } + */ // physics_server = memnew(PhysicsServerSW); @@ -288,7 +275,7 @@ void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_aud ERR_PRINT("Initializing audio failed."); } - power_manager = memnew(PowerWinRT); + power_manager = memnew(PowerUWP); managed_object->update_clipboard(); @@ -381,14 +368,6 @@ void OSUWP::finalize() { if (gl_context) memdelete(gl_context); #endif - if (rasterizer) - memdelete(rasterizer); - - /* - if (debugger_connection_console) { - memdelete(debugger_connection_console); - } - */ memdelete(input); @@ -400,11 +379,8 @@ void OSUWP::finalize() { joypad = nullptr; } -void OSUWP::finalize_core() { - if (mempool_dynamic) - memdelete(mempool_dynamic); - delete mempool_static; +void OSUWP::finalize_core() { } void OSUWP::vprint(const char *p_format, va_list p_list, bool p_stderr) { @@ -880,15 +856,20 @@ String OSUWP::get_data_dir() const { return String(data_folder->Path->Data()).replace("\\", "/"); } -PowerState OSWinrt::get_power_state() { +bool OSUWP::check_feature_support(const String &p_feature) { + + return VisualServer::get_singleton()->has_os_feature(p_feature); +} + +PowerState OSUWP::get_power_state() { return power_manager->get_power_state(); } -int OSWinrt::get_power_seconds_left() { +int OSUWP::get_power_seconds_left() { return power_manager->get_power_seconds_left(); } -int OSWinrt::get_power_percent_left() { +int OSUWP::get_power_percent_left() { return power_manager->get_power_percent_left(); } diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 88a1dddae3..7d9e681da1 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -38,7 +38,7 @@ #include "main/input_default.h" #include "os/input.h" #include "os/os.h" -#include "power_winrt.h" +#include "power_uwp.h" #include "servers/audio_server.h" #include "servers/physics/physics_server_sw.h" #include "servers/physics_2d/physics_2d_server_sw.h" @@ -94,7 +94,6 @@ private: int old_x, old_y; Point2i center; VisualServer *visual_server; - Rasterizer *rasterizer; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; int pressrc; @@ -107,7 +106,7 @@ private: AudioDriverXAudio2 audio_driver; - PowerWinRT *power_manager; + PowerUWP *power_manager; MouseMode mouse_mode; bool alt_mem; @@ -237,6 +236,8 @@ public: virtual void move_window_to_foreground(); virtual String get_data_dir() const; + virtual bool check_feature_support(const String &p_feature); + void set_gl_context(ContextEGL *p_context); void screen_size_changed(); diff --git a/platform/uwp/power_uwp.cpp b/platform/uwp/power_uwp.cpp new file mode 100644 index 0000000000..a8f0f5ba6d --- /dev/null +++ b/platform/uwp/power_uwp.cpp @@ -0,0 +1,74 @@ +/*************************************************************************/ +/* power_uwp.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "power_uwp.h" + +PowerUWP::PowerUWP() + : nsecs_left(-1), percent_left(-1), power_state(POWERSTATE_UNKNOWN) { +} + +PowerUWP::~PowerUWP() { +} + +bool PowerUWP::UpdatePowerInfo() { + // TODO, WinRT: Battery info is available on at least one WinRT platform (Windows Phone 8). Implement UpdatePowerInfo as appropriate. */ + /* Notes from SDL: + - the Win32 function, GetSystemPowerStatus, is not available for use on WinRT + - Windows Phone 8 has a 'Battery' class, which is documented as available for C++ + - More info on WP8's Battery class can be found at http://msdn.microsoft.com/library/windowsphone/develop/jj207231 + */ + return false; +} + +PowerState PowerUWP::get_power_state() { + if (UpdatePowerInfo()) { + return power_state; + } else { + WARN_PRINT("Power management is not implemented on this platform, defaulting to POWERSTATE_UNKNOWN"); + return POWERSTATE_UNKNOWN; + } +} + +int PowerUWP::get_power_seconds_left() { + if (UpdatePowerInfo()) { + return nsecs_left; + } else { + WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); + return -1; + } +} + +int PowerUWP::get_power_percent_left() { + if (UpdatePowerInfo()) { + return percent_left; + } else { + WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); + return -1; + } +} diff --git a/platform/uwp/power_uwp.h b/platform/uwp/power_uwp.h new file mode 100644 index 0000000000..465473bc1d --- /dev/null +++ b/platform/uwp/power_uwp.h @@ -0,0 +1,55 @@ +/*************************************************************************/ +/* power_uwp.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef PLATFORM_UWP_POWER_UWP_H_ +#define PLATFORM_UWP_POWER_UWP_H_ + +#include "os/dir_access.h" +#include "os/file_access.h" +#include "os/power.h" + +class PowerUWP { + +private: + int nsecs_left; + int percent_left; + PowerState power_state; + + bool UpdatePowerInfo(); + +public: + PowerUWP(); + virtual ~PowerUWP(); + + PowerState get_power_state(); + int get_power_seconds_left(); + int get_power_percent_left(); +}; + +#endif /* PLATFORM_UWP_POWER_UWP_H_ */ diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index b54861a314..39eef89274 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -28,10 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "collision_polygon_2d.h" + #include "collision_object_2d.h" #include "scene/resources/concave_polygon_shape_2d.h" #include "scene/resources/convex_polygon_shape_2d.h" -#include "triangulator.h" + +#include "thirdparty/misc/triangulator.h" + void CollisionPolygon2D::_add_to_collision_object(Object *p_obj) { if (unparenting || !can_update_body) diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index aec6d7108b..807f72e81f 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -28,9 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "navigation_polygon.h" + #include "core_string_names.h" #include "navigation2d.h" -#include "triangulator.h" + +#include "thirdparty/misc/triangulator.h" void NavigationPolygon::set_vertices(const PoolVector<Vector2> &p_vertices) { diff --git a/scene/SCsub b/scene/SCsub index bd2da1eab9..df52e9c6cb 100644 --- a/scene/SCsub +++ b/scene/SCsub @@ -3,10 +3,23 @@ Import('env') env.scene_sources = [] + + +# Thirdparty code +thirdparty_dir = "#thirdparty/misc/" +thirdparty_sources = [ + # C sources + "mikktspace.c", +] +thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] +env.add_source_files(env.scene_sources, thirdparty_sources) + + +# Godot's own sources env.add_source_files(env.scene_sources, "*.cpp") -Export('env') +# Chain load SCsubs SConscript('main/SCsub') SConscript('gui/SCsub') SConscript('3d/SCsub') @@ -17,6 +30,8 @@ SConscript('resources/SCsub') SConscript('io/SCsub') +# Build it all as a library lib = env.Library("scene", env.scene_sources) - env.Prepend(LIBS=[lib]) + +Export('env') diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 835775e13b..cf5321e907 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -54,20 +54,24 @@ void WindowDialog::_fix_size() { // Windows require additional padding to keep the window chrome visible. Ref<StyleBoxTexture> panel = get_stylebox("panel", "WindowDialog"); - float top = panel->get_expand_margin_size(MARGIN_TOP); - float left = panel->get_expand_margin_size(MARGIN_LEFT); - float bottom = panel->get_expand_margin_size(MARGIN_BOTTOM); - float right = panel->get_expand_margin_size(MARGIN_RIGHT); - pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right)); - pos.y = MAX(top, MIN(pos.y, viewport_size.y - size.y - bottom)); - set_global_position(pos); - - // Also resize the window to fit if a resize should be possible at all. - if (resizable) { - size.x = MIN(size.x, viewport_size.x - left - right); - size.y = MIN(size.y, viewport_size.y - top - bottom); - set_size(size); + // Check validity, because the theme could contain a different type of StyleBox + if (panel.is_valid()) { + float top = panel->get_expand_margin_size(MARGIN_TOP); + float left = panel->get_expand_margin_size(MARGIN_LEFT); + float bottom = panel->get_expand_margin_size(MARGIN_BOTTOM); + float right = panel->get_expand_margin_size(MARGIN_RIGHT); + + pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right)); + pos.y = MAX(top, MIN(pos.y, viewport_size.y - size.y - bottom)); + set_global_position(pos); + + // Also resize the window to fit if a resize should be possible at all. + if (resizable) { + size.x = MIN(size.x, viewport_size.x - left - right); + size.y = MIN(size.y, viewport_size.y - top - bottom); + set_size(size); + } } } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 0acb7265e3..8bb6828fa6 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -633,8 +633,8 @@ void LineEdit::_notification(int p_what) { if (char_ofs >= t.length()) break; - CharType cchar = pass ? '*' : t[char_ofs]; - CharType next = pass ? '*' : t[char_ofs + 1]; + CharType cchar = (pass && !text.empty()) ? '*' : t[char_ofs]; + CharType next = (pass && !text.empty()) ? '*' : t[char_ofs + 1]; int char_width = font->get_char_size(cchar, next).width; // end of widget, break! diff --git a/scene/resources/SCsub b/scene/resources/SCsub index 60b16cd0d4..2ad90247a7 100644 --- a/scene/resources/SCsub +++ b/scene/resources/SCsub @@ -3,7 +3,6 @@ Import('env') env.add_source_files(env.scene_sources, "*.cpp") -env.add_source_files(env.scene_sources, "*.c") Export('env') diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp index 0a784c6496..397349bbf9 100644 --- a/scene/resources/dynamic_font_stb.cpp +++ b/scene/resources/dynamic_font_stb.cpp @@ -33,7 +33,6 @@ #define STB_TRUETYPE_IMPLEMENTATION #include "os/file_access.h" -#include "stb_truetype.h" void DynamicFontData::lock() { diff --git a/scene/resources/dynamic_font_stb.h b/scene/resources/dynamic_font_stb.h index 3862607ab5..a2c081a925 100644 --- a/scene/resources/dynamic_font_stb.h +++ b/scene/resources/dynamic_font_stb.h @@ -34,7 +34,8 @@ #include "font.h" #include "io/resource_loader.h" -#include "stb_truetype.h" + +#include "thirdparty/misc/stb_truetype.h" class DynamicFontAtSize; class DynamicFont; diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h index 6e52db218d..b143086e11 100644 --- a/scene/resources/surface_tool.h +++ b/scene/resources/surface_tool.h @@ -30,9 +30,10 @@ #ifndef SURFACE_TOOL_H #define SURFACE_TOOL_H -#include "mikktspace.h" #include "scene/resources/mesh.h" +#include "thirdparty/misc/mikktspace.h" + class SurfaceTool : public Reference { GDCLASS(SurfaceTool, Reference); diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index dd653ea891..9fe92f0fec 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -3751,7 +3751,7 @@ String ShaderLanguage::get_shader_type(const String &p_code) { String cur_identifier; - for (int i = 0; i < p_code.length() + 1; i++) { + for (int i = 0; i < p_code.length(); i++) { if (p_code[i] == ';') { break; diff --git a/thirdparty/README.md b/thirdparty/README.md index f6edff490f..1c4bad4836 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -1,6 +1,13 @@ # Third party libraries +## b2d_convexdecomp + +- Upstream: https://github.com/erincatto/Box2D (Contributions/Utilities/ConvexDecomposition) +- Version: TBD +- License: zlib + + ## certs - Upstream: ? @@ -142,6 +149,91 @@ changes to ensure they build for Javascript/HTML5. Those changes are marked with `// -- GODOT --` comments. +## minizip + +- Upstream: http://www.zlib.net +- Version: 1.2.4 (zlib contrib) +- License: zlib + +Files extracted from the upstream source: + +- contrib/minizip/{crypt.h,ioapi.{c,h},zip.{c,h},unzip.{c,h}} + +Important: Some files have Godot-made changes for use in core/io. +TODO: Properly sync with version 1.2.4 and document changes. + + +## misc + +Collection of single-file libraries used in Godot components. + +### core + +- `aes256.{cpp,h}` + * Upstream: http://www.literatecode.com/aes256 + * Version: latest, as of April 2017 + * License: ISC +- `base64.{c,h}` + * Upstream: http://episec.com/people/edelkind/c.html + * Version: latest, as of April 2017 + * License: Public Domain +- `fastlz.{c,h}` + * Upstream: https://code.google.com/archive/p/fastlz + * Version: svn (r12) + * License: MIT +- `hq2x.{cpp,h}` + * Upstream: https://github.com/brunexgeek/hqx + * Version: TBD, file structure differs + * License: Apache 2.0 +- `md5.{cpp,h}` + * Upstream: http://www.efgh.com/software/md5.htm + * Version: TBD, might not be latest from above URL + * License: RSA Message-Digest License +- `pcg.{cpp,h}` + * Upstream: http://www.pcg-random.org + * Version: minimal C implemention, http://www.pcg-random.org/download.html + * License: Apache 2.0 +- `sha256.{c,h}` + * Upstream: https://github.com/ilvn/SHA256 + * Version: git (35ff823, 2015) + * License: ISC +- `smaz.{c,h}` + * Upstream: https://github.com/antirez/smaz + * Version: git (150e125, 2009) + * License: BSD 3-clause + * Modifications: use `const char*` instead of `char*` for input string +- `triangulator.{cpp,h}` + * Upstream: https://github.com/ivanfratric/polypartition (`src/polypartition.cpp`) + * Version: TBD, class was renamed + * License: MIT + +### modules + +- `curl_hostcheck.{c,h}` + * Upstream: https://curl.haxx.se/ + * Version: ? (2013) + * License: MIT +- `yuv2rgb.h` + * Upstream: http://wss.co.uk/pinknoise/yuv2rgb/ (to check) + * Version: ? + * License: BSD + +### scene + +- `mikktspace.{c,h}` + * Upstream: https://wiki.blender.org/index.php/Dev:Shading/Tangent_Space_Normal_Maps + * Version: 1.0 + * License: zlib +- `stb_truetype.h` + * Upstream: https://github.com/nothings/stb + * Version: 1.11 + * License: Public Domain (Unlicense) or MIT +- `stb_vorbis.c` + * Upstream: https://github.com/nothings/stb + * Version: 1.09 + * License: Public Domain (Unlicense) or MIT + + ## openssl - Upstream: https://www.openssl.org diff --git a/drivers/convex_decomp/b2Glue.h b/thirdparty/b2d_convexdecomp/b2Glue.h index 425486356e..425486356e 100644 --- a/drivers/convex_decomp/b2Glue.h +++ b/thirdparty/b2d_convexdecomp/b2Glue.h diff --git a/drivers/convex_decomp/b2Polygon.cpp b/thirdparty/b2d_convexdecomp/b2Polygon.cpp index b6ead62c63..b6ead62c63 100644 --- a/drivers/convex_decomp/b2Polygon.cpp +++ b/thirdparty/b2d_convexdecomp/b2Polygon.cpp diff --git a/drivers/convex_decomp/b2Polygon.h b/thirdparty/b2d_convexdecomp/b2Polygon.h index c466e28f7e..c466e28f7e 100644 --- a/drivers/convex_decomp/b2Polygon.h +++ b/thirdparty/b2d_convexdecomp/b2Polygon.h diff --git a/drivers/convex_decomp/b2Triangle.cpp b/thirdparty/b2d_convexdecomp/b2Triangle.cpp index a0a30b9407..a0a30b9407 100644 --- a/drivers/convex_decomp/b2Triangle.cpp +++ b/thirdparty/b2d_convexdecomp/b2Triangle.cpp diff --git a/drivers/convex_decomp/b2Triangle.h b/thirdparty/b2d_convexdecomp/b2Triangle.h index 99ab5cba69..99ab5cba69 100644 --- a/drivers/convex_decomp/b2Triangle.h +++ b/thirdparty/b2d_convexdecomp/b2Triangle.h diff --git a/core/io/LICENSE-InfoZip.txt b/thirdparty/minizip/LICENSE-InfoZip.txt index bcfe47e978..bcfe47e978 100644 --- a/core/io/LICENSE-InfoZip.txt +++ b/thirdparty/minizip/LICENSE-InfoZip.txt diff --git a/core/io/LICENSE-MiniZip.txt b/thirdparty/minizip/LICENSE-MiniZip.txt index 0e8950f86f..0e8950f86f 100644 --- a/core/io/LICENSE-MiniZip.txt +++ b/thirdparty/minizip/LICENSE-MiniZip.txt diff --git a/core/io/crypt.h b/thirdparty/minizip/crypt.h index a01d08d932..a01d08d932 100644 --- a/core/io/crypt.h +++ b/thirdparty/minizip/crypt.h diff --git a/core/io/ioapi.c b/thirdparty/minizip/ioapi.c index d6063a5fe6..d6063a5fe6 100644 --- a/core/io/ioapi.c +++ b/thirdparty/minizip/ioapi.c diff --git a/core/io/ioapi.h b/thirdparty/minizip/ioapi.h index cb6cb7e766..cb6cb7e766 100644 --- a/core/io/ioapi.h +++ b/thirdparty/minizip/ioapi.h diff --git a/core/io/unzip.c b/thirdparty/minizip/unzip.c index 7aa0a86d13..7aa0a86d13 100644 --- a/core/io/unzip.c +++ b/thirdparty/minizip/unzip.c diff --git a/core/io/unzip.h b/thirdparty/minizip/unzip.h index f67c3b2fa8..f67c3b2fa8 100644 --- a/core/io/unzip.h +++ b/thirdparty/minizip/unzip.h diff --git a/core/io/zip.c b/thirdparty/minizip/zip.c index 27a3d3cdc1..27a3d3cdc1 100644 --- a/core/io/zip.c +++ b/thirdparty/minizip/zip.c diff --git a/core/io/zip.h b/thirdparty/minizip/zip.h index 37478b34c0..37478b34c0 100644 --- a/core/io/zip.h +++ b/thirdparty/minizip/zip.h diff --git a/core/io/aes256.cpp b/thirdparty/misc/aes256.cpp index dc271928b4..dc271928b4 100644 --- a/core/io/aes256.cpp +++ b/thirdparty/misc/aes256.cpp diff --git a/core/io/aes256.h b/thirdparty/misc/aes256.h index 8fcc25a4de..8fcc25a4de 100644 --- a/core/io/aes256.h +++ b/thirdparty/misc/aes256.h diff --git a/core/io/base64.c b/thirdparty/misc/base64.c index 0929ae5db5..0929ae5db5 100644 --- a/core/io/base64.c +++ b/thirdparty/misc/base64.c diff --git a/core/io/base64.h b/thirdparty/misc/base64.h index 456ef1811b..456ef1811b 100644 --- a/core/io/base64.h +++ b/thirdparty/misc/base64.h diff --git a/modules/openssl/curl_hostcheck.c b/thirdparty/misc/curl_hostcheck.c index feef232619..feef232619 100644 --- a/modules/openssl/curl_hostcheck.c +++ b/thirdparty/misc/curl_hostcheck.c diff --git a/modules/openssl/curl_hostcheck.h b/thirdparty/misc/curl_hostcheck.h index 1b7fbe81e3..1b7fbe81e3 100644 --- a/modules/openssl/curl_hostcheck.h +++ b/thirdparty/misc/curl_hostcheck.h diff --git a/core/io/fastlz.c b/thirdparty/misc/fastlz.c index 508f6ea2ae..508f6ea2ae 100644 --- a/core/io/fastlz.c +++ b/thirdparty/misc/fastlz.c diff --git a/core/io/fastlz.h b/thirdparty/misc/fastlz.h index e5ca8dfc02..e5ca8dfc02 100644 --- a/core/io/fastlz.h +++ b/thirdparty/misc/fastlz.h diff --git a/core/hq2x.cpp b/thirdparty/misc/hq2x.cpp index 7ebb505d64..7ebb505d64 100644 --- a/core/hq2x.cpp +++ b/thirdparty/misc/hq2x.cpp diff --git a/core/hq2x.h b/thirdparty/misc/hq2x.h index 8f119d2a01..8f119d2a01 100644 --- a/core/hq2x.h +++ b/thirdparty/misc/hq2x.h diff --git a/core/io/md5.cpp b/thirdparty/misc/md5.cpp index 5a88328dd4..1653ab0be5 100644 --- a/core/io/md5.cpp +++ b/thirdparty/misc/md5.cpp @@ -1,5 +1,3 @@ -#include "md5.h" - /* ********************************************************************** ** md5.c ** @@ -34,7 +32,7 @@ */ /* -- include the following line if the md5.h header file is separate -- */ -/* #include "md5.h" */ +#include "md5.h" /* forward declaration */ static void Transform (uint32_t *buf, uint32_t *in); diff --git a/core/io/md5.h b/thirdparty/misc/md5.h index e99d58b443..e99d58b443 100644 --- a/core/io/md5.h +++ b/thirdparty/misc/md5.h diff --git a/scene/resources/mikktspace.c b/thirdparty/misc/mikktspace.c index 62aa2da251..62aa2da251 100644 --- a/scene/resources/mikktspace.c +++ b/thirdparty/misc/mikktspace.c diff --git a/scene/resources/mikktspace.h b/thirdparty/misc/mikktspace.h index 52c44a713c..52c44a713c 100644 --- a/scene/resources/mikktspace.h +++ b/thirdparty/misc/mikktspace.h diff --git a/core/math/pcg.cpp b/thirdparty/misc/pcg.cpp index eac3b36d36..eac3b36d36 100644 --- a/core/math/pcg.cpp +++ b/thirdparty/misc/pcg.cpp diff --git a/core/math/pcg.h b/thirdparty/misc/pcg.h index 81f4c9770e..81f4c9770e 100644 --- a/core/math/pcg.h +++ b/thirdparty/misc/pcg.h diff --git a/core/io/sha256.c b/thirdparty/misc/sha256.c index 68a4339af9..68a4339af9 100644 --- a/core/io/sha256.c +++ b/thirdparty/misc/sha256.c diff --git a/core/io/sha256.h b/thirdparty/misc/sha256.h index e19e56b4cc..e19e56b4cc 100644 --- a/core/io/sha256.h +++ b/thirdparty/misc/sha256.h diff --git a/thirdparty/misc/smaz.c b/thirdparty/misc/smaz.c new file mode 100644 index 0000000000..555dfea844 --- /dev/null +++ b/thirdparty/misc/smaz.c @@ -0,0 +1,207 @@ +/* +Copyright (c) 2006-2009, Salvatore Sanfilippo +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of Smaz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include <string.h> + +/* Our compression codebook, used for compression */ +static const char *Smaz_cb[241] = { +"\002s,\266", "\003had\232\002leW", "\003on \216", "", "\001yS", +"\002ma\255\002li\227", "\003or \260", "", "\002ll\230\003s t\277", +"\004fromg\002mel", "", "\003its\332", "\001z\333", "\003ingF", "\001>\336", +"\001 \000\003 (\002nc\344", "\002nd=\003 on\312", +"\002ne\213\003hat\276\003re q", "", "\002ngT\003herz\004have\306\003s o\225", +"", "\003ionk\003s a\254\002ly\352", "\003hisL\003 inN\003 be\252", "", +"\003 fo\325\003 of \003 ha\311", "", "\002of\005", +"\003 co\241\002no\267\003 ma\370", "", "", "\003 cl\356\003enta\003 an7", +"\002ns\300\001\"e", "\003n t\217\002ntP\003s, \205", +"\002pe\320\003 we\351\002om\223", "\002on\037", "", "\002y G", "\003 wa\271", +"\003 re\321\002or*", "", "\002=\"\251\002ot\337", "\003forD\002ou[", +"\003 toR", "\003 th\r", "\003 it\366", +"\003but\261\002ra\202\003 wi\363\002</\361", "\003 wh\237", "\002 4", +"\003nd ?", "\002re!", "", "\003ng c", "", +"\003ly \307\003ass\323\001a\004\002rir", "", "", "", "\002se_", "\003of \"", +"\003div\364\002ros\003ere\240", "", "\002ta\310\001bZ\002si\324", "", +"\003and\a\002rs\335", "\002rt\362", "\002teE", "\003ati\316", "\002so\263", +"\002th\021", "\002tiJ\001c\034\003allp", "\003ate\345", "\002ss\246", +"\002stM", "", "\002><\346", "\002to\024", "\003arew", "\001d\030", +"\002tr\303", "", "\001\n1\003 a \222", "\003f tv\002veo", "\002un\340", "", +"\003e o\242", "\002a \243\002wa\326\001e\002", "\002ur\226\003e a\274", +"\002us\244\003\n\r\n\247", "\002ut\304\003e c\373", "\002we\221", "", "", +"\002wh\302", "\001f,", "", "", "", "\003d t\206", "", "", "\003th \343", +"\001g;", "", "", "\001\r9\003e s\265", "\003e t\234", "", "\003to Y", +"\003e\r\n\236", "\002d \036\001h\022", "", "\001,Q", "\002 a\031", "\002 b^", +"\002\r\n\025\002 cI", "\002 d\245", "\002 e\253", "\002 fh\001i\b\002e \v", +"", "\002 hU\001-\314", "\002 i8", "", "", "\002 l\315", "\002 m{", +"\002f :\002 n\354", "\002 o\035", "\002 p}\001.n\003\r\n\r\250", "", +"\002 r\275", "\002 s>", "\002 t\016", "", "\002g \235\005which+\003whi\367", +"\002 w5", "\001/\305", "\003as \214", "\003at \207", "", "\003who\331", "", +"\001l\026\002h \212", "", "\002, $", "", "\004withV", "", "", "", "\001m-", "", +"", "\002ac\357", "\002ad\350", "\003TheH", "", "", "\004this\233\001n\t", +"", "\002. y", "", "\002alX\003e, \365", "\003tio\215\002be\\", +"\002an\032\003ver\347", "", "\004that0\003tha\313\001o\006", "\003was2", +"\002arO", "\002as.", "\002at'\003the\001\004they\200\005there\322\005theird", +"\002ce\210", "\004were]", "", "\002ch\231\002l \264\001p<", "", "", +"\003one\256", "", "\003he \023\002dej", "\003ter\270", "\002cou", "", +"\002by\177\002di\201\002eax", "", "\002ec\327", "\002edB", "\002ee\353", "", +"", "\001r\f\002n )", "", "", "", "\002el\262", "", "\003in i\002en3", "", +"\002o `\001s\n", "", "\002er\033", "\003is t\002es6", "", "\002ge\371", +"\004.com\375", "\002fo\334\003our\330", "\003ch \301\001t\003", "\002hab", "", +"\003men\374", "", "\002he\020", "", "", "\001u&", "\002hif", "", +"\003not\204\002ic\203", "\003ed @\002id\355", "", "", "\002ho\273", +"\002r K\001vm", "", "", "", "\003t t\257\002il\360", "\002im\342", +"\003en \317\002in\017", "\002io\220", "\002s \027\001wA", "", "\003er |", +"\003es ~\002is%", "\002it/", "", "\002iv\272", "", +"\002t #\ahttp://C\001x\372", "\002la\211", "\001<\341", "\003, a\224" +}; + +/* Reverse compression codebook, used for decompression */ +static char *Smaz_rcb[254] = { +" ", "the", "e", "t", "a", "of", "o", "and", "i", "n", "s", "e ", "r", " th", +" t", "in", "he", "th", "h", "he ", "to", "\r\n", "l", "s ", "d", " a", "an", +"er", "c", " o", "d ", "on", " of", "re", "of ", "t ", ", ", "is", "u", "at", +" ", "n ", "or", "which", "f", "m", "as", "it", "that", "\n", "was", "en", +" ", " w", "es", " an", " i", "\r", "f ", "g", "p", "nd", " s", "nd ", "ed ", +"w", "ed", "http://", "for", "te", "ing", "y ", "The", " c", "ti", "r ", "his", +"st", " in", "ar", "nt", ",", " to", "y", "ng", " h", "with", "le", "al", "to ", +"b", "ou", "be", "were", " b", "se", "o ", "ent", "ha", "ng ", "their", "\"", +"hi", "from", " f", "in ", "de", "ion", "me", "v", ".", "ve", "all", "re ", +"ri", "ro", "is ", "co", "f t", "are", "ea", ". ", "her", " m", "er ", " p", +"es ", "by", "they", "di", "ra", "ic", "not", "s, ", "d t", "at ", "ce", "la", +"h ", "ne", "as ", "tio", "on ", "n t", "io", "we", " a ", "om", ", a", "s o", +"ur", "li", "ll", "ch", "had", "this", "e t", "g ", "e\r\n", " wh", "ere", +" co", "e o", "a ", "us", " d", "ss", "\n\r\n", "\r\n\r", "=\"", " be", " e", +"s a", "ma", "one", "t t", "or ", "but", "el", "so", "l ", "e s", "s,", "no", +"ter", " wa", "iv", "ho", "e a", " r", "hat", "s t", "ns", "ch ", "wh", "tr", +"ut", "/", "have", "ly ", "ta", " ha", " on", "tha", "-", " l", "ati", "en ", +"pe", " re", "there", "ass", "si", " fo", "wa", "ec", "our", "who", "its", "z", +"fo", "rs", ">", "ot", "un", "<", "im", "th ", "nc", "ate", "><", "ver", "ad", +" we", "ly", "ee", " n", "id", " cl", "ac", "il", "</", "rt", " wi", "div", +"e, ", " it", "whi", " ma", "ge", "x", "e c", "men", ".com" +}; + +int smaz_compress(const char *in, int inlen, char *out, int outlen) { + unsigned int h1,h2,h3=0; + int verblen = 0, _outlen = outlen; + char verb[256], *_out = out; + + while(inlen) { + int j = 7, needed; + char *flush = NULL; + char *slot; + + h1 = h2 = in[0]<<3; + if (inlen > 1) h2 += in[1]; + if (inlen > 2) h3 = h2^in[2]; + if (j > inlen) j = inlen; + + /* Try to lookup substrings into the hash table, starting from the + * longer to the shorter substrings */ + for (; j > 0; j--) { + switch(j) { + case 1: slot = Smaz_cb[h1%241]; break; + case 2: slot = Smaz_cb[h2%241]; break; + default: slot = Smaz_cb[h3%241]; break; + } + while(slot[0]) { + if (slot[0] == j && memcmp(slot+1,in,j) == 0) { + /* Match found in the hash table, + * prepare a verbatim bytes flush if needed */ + if (verblen) { + needed = (verblen == 1) ? 2 : 2+verblen; + flush = out; + out += needed; + outlen -= needed; + } + /* Emit the byte */ + if (outlen <= 0) return _outlen+1; + out[0] = slot[slot[0]+1]; + out++; + outlen--; + inlen -= j; + in += j; + goto out; + } else { + slot += slot[0]+2; + } + } + } + /* Match not found - add the byte to the verbatim buffer */ + verb[verblen] = in[0]; + verblen++; + inlen--; + in++; +out: + /* Prepare a flush if we reached the flush length limit, and there + * is not already a pending flush operation. */ + if (!flush && (verblen == 256 || (verblen > 0 && inlen == 0))) { + needed = (verblen == 1) ? 2 : 2+verblen; + flush = out; + out += needed; + outlen -= needed; + if (outlen < 0) return _outlen+1; + } + /* Perform a verbatim flush if needed */ + if (flush) { + if (verblen == 1) { + flush[0] = (signed char)254; + flush[1] = verb[0]; + } else { + flush[0] = (signed char)255; + flush[1] = (signed char)(verblen-1); + memcpy(flush+2,verb,verblen); + } + flush = NULL; + verblen = 0; + } + } + return out-_out; +} + +int smaz_decompress(const char *in, int inlen, char *out, int outlen) { + unsigned char *c = (unsigned char*) in; + char *_out = out; + int _outlen = outlen; + + while(inlen) { + if (*c == 254) { + /* Verbatim byte */ + if (outlen < 1) return _outlen+1; + *out = *(c+1); + out++; + outlen--; + c += 2; + inlen -= 2; + } else if (*c == 255) { + /* Verbatim string */ + int len = (*(c+1))+1; + if (outlen < len) return _outlen+1; + memcpy(out,c+2,len); + out += len; + outlen -= len; + c += 2+len; + inlen -= 2+len; + } else { + /* Codebook entry */ + const char *s = Smaz_rcb[*c]; + int len = strlen(s); + + if (outlen < len) return _outlen+1; + memcpy(out,s,len); + out += len; + outlen -= len; + c++; + inlen--; + } + } + return out-_out; +} diff --git a/thirdparty/misc/smaz.h b/thirdparty/misc/smaz.h new file mode 100644 index 0000000000..a9d8a337a7 --- /dev/null +++ b/thirdparty/misc/smaz.h @@ -0,0 +1,20 @@ +/* +Copyright (c) 2006-2009, Salvatore Sanfilippo +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of Smaz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _SMAZ_H +#define _SMAZ_H + +int smaz_compress(const char *in, int inlen, char *out, int outlen); +int smaz_decompress(const char *in, int inlen, char *out, int outlen); + +#endif diff --git a/scene/resources/stb_truetype.h b/thirdparty/misc/stb_truetype.h index 016972785a..016972785a 100644 --- a/scene/resources/stb_truetype.h +++ b/thirdparty/misc/stb_truetype.h diff --git a/thirdparty/stb_vorbis/stb_vorbis.c b/thirdparty/misc/stb_vorbis.c index c4f24d5898..c4f24d5898 100644 --- a/thirdparty/stb_vorbis/stb_vorbis.c +++ b/thirdparty/misc/stb_vorbis.c diff --git a/core/math/triangulator.cpp b/thirdparty/misc/triangulator.cpp index 75b2b064c4..75b2b064c4 100644 --- a/core/math/triangulator.cpp +++ b/thirdparty/misc/triangulator.cpp diff --git a/core/math/triangulator.h b/thirdparty/misc/triangulator.h index b6dd7e8236..b6dd7e8236 100644 --- a/core/math/triangulator.h +++ b/thirdparty/misc/triangulator.h diff --git a/modules/theora/yuv2rgb.h b/thirdparty/misc/yuv2rgb.h index a9bef76da8..a9bef76da8 100644 --- a/modules/theora/yuv2rgb.h +++ b/thirdparty/misc/yuv2rgb.h |