mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 09:46:02 +08:00
Formatting.
This commit is contained in:
parent
9fcb5007ec
commit
0bfeff771e
@ -90,7 +90,7 @@ Error SpineBinaryResourceImportPlugin::import(const String &source_file, const S
|
|||||||
#endif
|
#endif
|
||||||
Ref<SpineSkeletonFileResource> skeleton_file_res(memnew(SpineSkeletonFileResource));
|
Ref<SpineSkeletonFileResource> skeleton_file_res(memnew(SpineSkeletonFileResource));
|
||||||
Error error = skeleton_file_res->load_from_file(source_file);
|
Error error = skeleton_file_res->load_from_file(source_file);
|
||||||
if (error != OK) return error;
|
if (error != OK) return error;
|
||||||
|
|
||||||
String file_name = vformat("%s.%s", save_path, get_save_extension());
|
String file_name = vformat("%s.%s", save_path, get_save_extension());
|
||||||
#if VERSION_MAJOR > 3
|
#if VERSION_MAJOR > 3
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public:
|
|||||||
#if VERSION_MAJOR > 3
|
#if VERSION_MAJOR > 3
|
||||||
int get_import_order() const override { return IMPORT_ORDER_DEFAULT; }
|
int get_import_order() const override { return IMPORT_ORDER_DEFAULT; }
|
||||||
|
|
||||||
float get_priority() const override { return 1; }
|
float get_priority() const override { return 1; }
|
||||||
|
|
||||||
void get_import_options(const String &path, List<ImportOption> *options, int preset) const override;
|
void get_import_options(const String &path, List<ImportOption> *options, int preset) const override;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ public:
|
|||||||
#if VERSION_MAJOR > 3
|
#if VERSION_MAJOR > 3
|
||||||
int get_import_order() const override { return IMPORT_ORDER_DEFAULT; }
|
int get_import_order() const override { return IMPORT_ORDER_DEFAULT; }
|
||||||
|
|
||||||
float get_priority() const override { return 1; }
|
float get_priority() const override { return 1; }
|
||||||
|
|
||||||
void get_import_options(const String &path, List<ImportOption> *options, int preset) const override {}
|
void get_import_options(const String &path, List<ImportOption> *options, int preset) const override {}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ public:
|
|||||||
#if VERSION_MAJOR > 3
|
#if VERSION_MAJOR > 3
|
||||||
int get_import_order() const override { return IMPORT_ORDER_DEFAULT; }
|
int get_import_order() const override { return IMPORT_ORDER_DEFAULT; }
|
||||||
|
|
||||||
float get_priority() const override { return 1; }
|
float get_priority() const override { return 1; }
|
||||||
|
|
||||||
void get_import_options(const String &path, List<ImportOption> *options, int preset) const override {}
|
void get_import_options(const String &path, List<ImportOption> *options, int preset) const override {}
|
||||||
|
|
||||||
|
|||||||
@ -39,93 +39,93 @@
|
|||||||
|
|
||||||
|
|
||||||
struct BinaryInput {
|
struct BinaryInput {
|
||||||
const unsigned char *cursor;
|
const unsigned char *cursor;
|
||||||
const unsigned char *end;
|
const unsigned char *end;
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned char readByte(BinaryInput *input) {
|
static unsigned char readByte(BinaryInput *input) {
|
||||||
return *input->cursor++;
|
return *input->cursor++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int readVarint(BinaryInput *input, bool optimizePositive) {
|
static int readVarint(BinaryInput *input, bool optimizePositive) {
|
||||||
unsigned char b = readByte(input);
|
unsigned char b = readByte(input);
|
||||||
int value = b & 0x7F;
|
int value = b & 0x7F;
|
||||||
if (b & 0x80) {
|
if (b & 0x80) {
|
||||||
b = readByte(input);
|
b = readByte(input);
|
||||||
value |= (b & 0x7F) << 7;
|
value |= (b & 0x7F) << 7;
|
||||||
if (b & 0x80) {
|
if (b & 0x80) {
|
||||||
b = readByte(input);
|
b = readByte(input);
|
||||||
value |= (b & 0x7F) << 14;
|
value |= (b & 0x7F) << 14;
|
||||||
if (b & 0x80) {
|
if (b & 0x80) {
|
||||||
b = readByte(input);
|
b = readByte(input);
|
||||||
value |= (b & 0x7F) << 21;
|
value |= (b & 0x7F) << 21;
|
||||||
if (b & 0x80) value |= (readByte(input) & 0x7F) << 28;
|
if (b & 0x80) value |= (readByte(input) & 0x7F) << 28;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!optimizePositive) {
|
if (!optimizePositive) {
|
||||||
value = (((unsigned int) value >> 1) ^ -(value & 1));
|
value = (((unsigned int) value >> 1) ^ -(value & 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *readString(BinaryInput *input) {
|
static char *readString(BinaryInput *input) {
|
||||||
int length = readVarint(input, true);
|
int length = readVarint(input, true);
|
||||||
char *string;
|
char *string;
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
string = spine::SpineExtension::alloc<char>(length, __FILE__, __LINE__);
|
string = spine::SpineExtension::alloc<char>(length, __FILE__, __LINE__);
|
||||||
memcpy(string, input->cursor, length - 1);
|
memcpy(string, input->cursor, length - 1);
|
||||||
input->cursor += length - 1;
|
input->cursor += length - 1;
|
||||||
string[length - 1] = '\0';
|
string[length - 1] = '\0';
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeletonFileResource::_bind_methods() {
|
void SpineSkeletonFileResource::_bind_methods() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkVersion(const char *version) {
|
static bool checkVersion(const char *version) {
|
||||||
if (!version) return false;
|
if (!version) return false;
|
||||||
char *result = (char *) (strstr(version, SPINE_VERSION_STRING) - version);
|
char *result = (char *) (strstr(version, SPINE_VERSION_STRING) - version);
|
||||||
return result == 0;
|
return result == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkJson(const char *jsonData) {
|
static bool checkJson(const char *jsonData) {
|
||||||
spine::Json json(jsonData);
|
spine::Json json(jsonData);
|
||||||
spine::Json *skeleton = spine::Json::getItem(&json, "skeleton");
|
spine::Json *skeleton = spine::Json::getItem(&json, "skeleton");
|
||||||
if (!skeleton) return false;
|
if (!skeleton) return false;
|
||||||
const char *version = spine::Json::getString(skeleton, "spine", 0);
|
const char *version = spine::Json::getString(skeleton, "spine", 0);
|
||||||
if (!version) return false;
|
if (!version) return false;
|
||||||
|
|
||||||
return checkVersion(version);
|
return checkVersion(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkBinary(const char *binaryData, int length) {
|
static bool checkBinary(const char *binaryData, int length) {
|
||||||
BinaryInput input;
|
BinaryInput input;
|
||||||
input.cursor = (const unsigned char *) binaryData;
|
input.cursor = (const unsigned char *) binaryData;
|
||||||
input.end = (const unsigned char *) binaryData + length;
|
input.end = (const unsigned char *) binaryData + length;
|
||||||
// Skip hash
|
// Skip hash
|
||||||
input.cursor += 8;
|
input.cursor += 8;
|
||||||
char *version = readString(&input);
|
char *version = readString(&input);
|
||||||
bool result = checkVersion(version);
|
bool result = checkVersion(version);
|
||||||
spine::SpineExtension::free(version, __FILE__, __LINE__);
|
spine::SpineExtension::free(version, __FILE__, __LINE__);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error SpineSkeletonFileResource::load_from_file(const String &path) {
|
Error SpineSkeletonFileResource::load_from_file(const String &path) {
|
||||||
Error error = OK;
|
Error error = OK;
|
||||||
if (path.ends_with(".spjson") || path.ends_with(".json")) {
|
if (path.ends_with(".spjson") || path.ends_with(".json")) {
|
||||||
json = FileAccess::get_file_as_string(path, &error);
|
json = FileAccess::get_file_as_string(path, &error);
|
||||||
if (error != OK) return error;
|
if (error != OK) return error;
|
||||||
if (!checkJson(json.utf8())) return ERR_INVALID_DATA;
|
if (!checkJson(json.utf8())) return ERR_INVALID_DATA;
|
||||||
} else {
|
} else {
|
||||||
binary = FileAccess::get_file_as_array(path, &error);
|
binary = FileAccess::get_file_as_array(path, &error);
|
||||||
if (error != OK) return error;
|
if (error != OK) return error;
|
||||||
if (!checkBinary((const char*)binary.ptr(), binary.size())) return ERR_INVALID_DATA;
|
if (!checkBinary((const char *) binary.ptr(), binary.size())) return ERR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ export class GLTexture extends Texture implements Disposable, Restorable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static usesMipMaps(filter: TextureFilter) {
|
static usesMipMaps (filter: TextureFilter) {
|
||||||
switch (filter) {
|
switch (filter) {
|
||||||
case TextureFilter.MipMap:
|
case TextureFilter.MipMap:
|
||||||
case TextureFilter.MipMapLinearLinear:
|
case TextureFilter.MipMapLinearLinear:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user