Initial Commit
196
addons/gdata_orm/condition.gd
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
@tool
|
||||
extends RefCounted
|
||||
class_name Condition
|
||||
## A programatically way to define Conditions.
|
||||
##
|
||||
## Condition is a way to define SQL Statements to be used with GDataORM. You can create
|
||||
## full SQL Statements, or Simple conditions to be used when fetching data from the [SQLite]
|
||||
## database.[br][br]
|
||||
##
|
||||
## [b]Example:[/b]
|
||||
## [codeblock]
|
||||
## var fetch_like_mar: Condition = Condition.new().select("*").from("my_table").where() \
|
||||
## .like("name", "Mar%")
|
||||
## var fetch_gold: Condition = Condition.new().select(["gold"]).from("inventories").where() \
|
||||
## .greater("gold",0)
|
||||
## var low_health: Condition = Condition.new().lesser("health",5)
|
||||
## var mid_health: Condition = Condition.new().between("health",25,75)
|
||||
## var full_health: Condition = Condition.new().greater_equal("health",100)
|
||||
## [/codeblock]
|
||||
|
||||
enum _CT {
|
||||
NOT,
|
||||
EQUAL,
|
||||
LESS_THAN,
|
||||
GREATER_THAN,
|
||||
LESS_THAN_EQUAL,
|
||||
GREATER_THAN_EQUAL,
|
||||
AND,
|
||||
BETWEEN,
|
||||
IN,
|
||||
LIKE,
|
||||
OR,
|
||||
SELECT,
|
||||
FROM,
|
||||
WHERE,
|
||||
}
|
||||
|
||||
var _conditions: Array = []
|
||||
|
||||
func _single_op(op: _CT) -> Dictionary:
|
||||
return {"type": op}
|
||||
|
||||
func _param_op(op: _CT, param: Variant) -> Dictionary:
|
||||
return {"type": op, "param": param}
|
||||
|
||||
func _comparison_op(op: _CT, column: Variant, value: Variant) -> Dictionary:
|
||||
return {"type": op, "column": column, "value": value}
|
||||
|
||||
## Binary operator to invert true and false in a statement.
|
||||
func is_not() -> Condition:
|
||||
_conditions.append(_single_op(_CT.NOT))
|
||||
return self
|
||||
|
||||
## Evaluates the equality of a [param column] value and the [param value] given.
|
||||
func equal(column: String, value: Variant) -> Condition:
|
||||
_conditions.append(_comparison_op(_CT.EQUAL, column, value))
|
||||
return self
|
||||
|
||||
## Evaluates the [param column] value to be lesser than [param value] given.
|
||||
func lesser(column: String, value: Variant) -> Condition:
|
||||
_conditions.append(_comparison_op(_CT.LESS_THAN, column, value))
|
||||
return self
|
||||
|
||||
## Evaluates the [param column] value to be greater than [param value] given.
|
||||
func greater(column: String, value: Variant) -> Condition:
|
||||
_conditions.append(_comparison_op(_CT.GREATER_THAN, column, value))
|
||||
return self
|
||||
|
||||
## Evaluates the [param column] value to be lesser than or equal to [param value] given.
|
||||
func lesser_equal(column: String, value: Variant) -> Condition:
|
||||
_conditions.append(_comparison_op(_CT.LESS_THAN_EQUAL, column, value))
|
||||
return self
|
||||
|
||||
## Evaluates the [param column] value to be greater than or equal to [param value] given.
|
||||
func greater_equal(column: String, value: Variant) -> Condition:
|
||||
_conditions.append(_comparison_op(_CT.GREATER_THAN_EQUAL, column, value))
|
||||
return self
|
||||
|
||||
## Binary operator for AND'ing two evaluation values together.
|
||||
func also() -> Condition:
|
||||
_conditions.append(_single_op(_CT.AND))
|
||||
return self
|
||||
|
||||
## Evaluates the [param column] value to be between [param lower]'s value and [param upper]'s value.
|
||||
func between(column: String, lower: Variant, upper: Variant) -> Condition:
|
||||
_conditions.append(_comparison_op(_CT.BETWEEN, column, [lower, upper]))
|
||||
return self
|
||||
|
||||
## Evaluates the [param column] to see if [param value] is included in it. You can pass an array
|
||||
## of values to this, or use a [Condition] to fetch data from another table.
|
||||
func includes(column: String, value: Variant) -> Condition:
|
||||
_conditions.append(_comparison_op(_CT.IN, column, value))
|
||||
return self
|
||||
|
||||
## Evaluates the [param column] to see if [param value] matches the given string. This utilizes
|
||||
## [SQLite]'s LIKE statement, which means that you can use wildcard operators '%' and '_' in the
|
||||
## pattern string.[br][br]
|
||||
## [b]Wildcard Patterns:[/b][br]
|
||||
## - '%' match any 1 or more characters in a pattern, EG: "Mar%" will return "Mario", "Mark", "Margin" etc etc.[br]
|
||||
## - '_' match only 1 wildcard character before moving to the next. EG: "h_nt" will return "hunt", "hint", or
|
||||
## "__pple" will return "topple", "supple", "tipple"[br]
|
||||
## [b][color=red]NOTE:[/color][/b] [SQLite]'s engine is case-insensitive, so [code]"A" LIKE "a"[/code] will return true, but
|
||||
## unicode characters that are not in the ASCII range are case-sensitive, so [code]"Ä" LIKE "ä"[/code] will return false.
|
||||
func like(column: String, value: Variant) -> Condition:
|
||||
_conditions.append(_comparison_op(_CT.LIKE, column, value))
|
||||
return self
|
||||
|
||||
## Binary operator for OR'ing two evaluations together.
|
||||
func otherwise() -> Condition:
|
||||
_conditions.append(_single_op(_CT.OR))
|
||||
return self
|
||||
|
||||
## Statement, fetches [param columns] from a table during execution. [param columns] can be a string value of "*" or "column1, column2, column3" or an
|
||||
## array of strings such as ["column1","column2","column3"].
|
||||
func select(columns: Variant) -> Condition:
|
||||
_conditions.append(_param_op(_CT.SELECT, columns))
|
||||
return self
|
||||
|
||||
## Statement Modifier, used in conjunction with [method Condition.select] to define which table the data is to be fetched from.
|
||||
func from(table: String) -> Condition:
|
||||
_conditions.append(_param_op(_CT.FROM, table))
|
||||
return self
|
||||
|
||||
## Statement Modifier, defines the conditions that must match in order to fetch data from the table.
|
||||
func where() -> Condition:
|
||||
_conditions.append(_single_op(_CT.WHERE))
|
||||
return self
|
||||
|
||||
func _to_string() -> String:
|
||||
var str = ""
|
||||
var pos := 0
|
||||
|
||||
for cond in _conditions:
|
||||
match cond.type:
|
||||
#NOTE Single Operation _single_op()
|
||||
_CT.NOT:
|
||||
if _conditions[pos+1].type == _CT.BETWEEN:
|
||||
pos += 1
|
||||
continue
|
||||
str += "NOT "
|
||||
_CT.AND:
|
||||
str += "AND "
|
||||
_CT.OR:
|
||||
str += "OR "
|
||||
_CT.WHERE:
|
||||
str += "WHERE "
|
||||
|
||||
#NOTE Param Operation _param_op()
|
||||
_CT.SELECT:
|
||||
var param = ""
|
||||
if cond.param is Array:
|
||||
param = ", ".join(cond.param)
|
||||
elif cond.param is String:
|
||||
param = cond.param
|
||||
else:
|
||||
assert(false, "SELECT statement only takes a String or Array parameters.")
|
||||
str += "SELECT %s " % param
|
||||
_CT.FROM:
|
||||
str += "FROM %s " % cond.param
|
||||
|
||||
#NOTE Comparison Operation _comparison_op()
|
||||
_CT.EQUAL:
|
||||
if typeof(cond.value) == TYPE_STRING:
|
||||
str += "%s = '%s'" % [cond.column, cond.value]
|
||||
else:
|
||||
str += "%s = %s " % [cond.column, cond.value]
|
||||
_CT.LESS_THAN:
|
||||
str += "%s < %s " % [cond.column, cond.value]
|
||||
_CT.GREATER_THAN:
|
||||
str += "%s > %s " % [cond.column, cond.value]
|
||||
_CT.LESS_THAN_EQUAL:
|
||||
str += "%s <= %s " % [cond.column, cond.value]
|
||||
_CT.GREATER_THAN_EQUAL:
|
||||
str += "%s >= %s " % [cond.column, cond.value]
|
||||
_CT.BETWEEN:
|
||||
if _conditions[pos-1].type == _CT.NOT:
|
||||
str += "%s NOT BETWEEN " % cond.column
|
||||
else:
|
||||
str += "%s BETWEEN " % cond.column
|
||||
str += "%s and %s" % cond.value
|
||||
_CT.IN:
|
||||
if _conditions[pos-1].type == _CT.NOT:
|
||||
str += "%s NOT IN " % cond.column
|
||||
else:
|
||||
str += "%s IN " % cond.column
|
||||
if cond.value is Condition:
|
||||
str += "(%s) " % cond.value.to_string()
|
||||
elif cond.value is Array:
|
||||
str += "(%s) " % ", ".join(cond.value)
|
||||
else:
|
||||
assert(false, "IN only takes Array of values or a Condition")
|
||||
_CT.LIKE:
|
||||
str += "%s LIKE '%s' " % [cond.column, cond.value]
|
||||
pos += 1
|
||||
|
||||
return str.strip_edges()
|
||||
1
addons/gdata_orm/condition.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b3fmxmewptm3k
|
||||
86
addons/gdata_orm/context.gd
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
extends RefCounted
|
||||
class_name Context
|
||||
## The Central core for interacting with Databases.
|
||||
##
|
||||
## Context is the class which creates a Database Connection to a [SQLite] database,
|
||||
## and sets up all tables as defined by the DbSet definitions of the class.[br][br]
|
||||
##
|
||||
## [b]Example:[/b]
|
||||
## [codeblock]
|
||||
## extends Context
|
||||
## class_name AppContext
|
||||
##
|
||||
## var characters: DbSet
|
||||
## var inventories: DbSet
|
||||
## var items: DbSet
|
||||
##
|
||||
## func _init() -> void:
|
||||
## characters = DbSet.new(Character)
|
||||
## inventories = DbSet.new(Inventory)
|
||||
## items = DbSet.new(Item)
|
||||
##
|
||||
## [/codeblock]
|
||||
|
||||
## The path in which to find the database, Example: `my_context.file_path = "user://my_database.db"`
|
||||
@export var file_path: String
|
||||
|
||||
var _db: SQLite
|
||||
|
||||
## Called to initialize the Context. This should be called just after the creation of the context, in order to
|
||||
## register all [DbSet]'s with the Context, as well, as call [method SQLiteObject.setup] on all SQLiteObject's
|
||||
## that have been defined as a DbSet of this class.
|
||||
func setup() -> void:
|
||||
var props = get_property_list()
|
||||
for prop in props:
|
||||
if not prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE:
|
||||
continue
|
||||
if prop.type != TYPE_OBJECT or prop.class_name != "DbSet":
|
||||
continue
|
||||
|
||||
var dbset: DbSet = get(prop.name)
|
||||
dbset._klass.setup(dbset._klass)
|
||||
|
||||
## Opens the [SQLite] database, allowing for the usages of the [DbSet]s defined in this context.
|
||||
func open_db(db_path: String = "") -> void:
|
||||
var props = get_property_list()
|
||||
if db_path != "":
|
||||
file_path = db_path
|
||||
_db = SQLite.new()
|
||||
_db.path = file_path
|
||||
_db.open_db()
|
||||
for prop in props:
|
||||
if not prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE:
|
||||
continue
|
||||
if prop.type != TYPE_OBJECT or prop.class_name != "DbSet":
|
||||
continue
|
||||
var dbset: DbSet = get(prop.name)
|
||||
dbset.set_db(_db)
|
||||
|
||||
## Closes the database when finished interacting with this instance.
|
||||
func close_db() -> void:
|
||||
_db.close_db()
|
||||
|
||||
|
||||
## Ensures that all tables defined as [DbSet] in this context, are properly created in the database.
|
||||
func ensure_tables() -> void:
|
||||
var props = get_property_list()
|
||||
for prop in props:
|
||||
if not prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE:
|
||||
continue
|
||||
if prop.type != TYPE_OBJECT or prop.class_name != "DbSet":
|
||||
continue
|
||||
var dbset: DbSet = get(prop.name)
|
||||
if not dbset.table_exists():
|
||||
dbset.create_table(false)
|
||||
|
||||
## Forces the creation of all tables defined as [DbSet] in this context, are properly created, dropping
|
||||
## the table if it already exists.
|
||||
func force_create_tables() -> void:
|
||||
var props = get_property_list()
|
||||
for prop in props:
|
||||
if not prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE:
|
||||
continue
|
||||
if prop.type != TYPE_OBJECT or prop.class_name != "DbSet":
|
||||
continue
|
||||
var dbset: DbSet = get(prop.name)
|
||||
dbset.create_table(true)
|
||||
1
addons/gdata_orm/context.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://baaxskalxregg
|
||||
86
addons/gdata_orm/db_set.gd
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
@tool
|
||||
extends Resource
|
||||
class_name DbSet
|
||||
## A Central point for fetching/storing [SQLiteObject]s in a Database.
|
||||
##
|
||||
## DbSet is used to create a link between [SQLiteObject]s and the tables they are stored in. Functions for
|
||||
## inserting, fetching, and removing [SQLiteObject]s in a database, along with support functions for checking
|
||||
## if a table exists, and creating tables.[br][br]
|
||||
##
|
||||
## [b]Example:[/b]
|
||||
## [codeblock]
|
||||
## extends Context
|
||||
## class_name AppContext
|
||||
##
|
||||
## var characters: DbSet
|
||||
## var inventories: DbSet
|
||||
## var items: DbSet
|
||||
##
|
||||
## func _init() -> void:
|
||||
## characters = DbSet.new(Character)
|
||||
## inventories = DbSet.new(Inventory)
|
||||
## items = DbSet.new(Item)
|
||||
##
|
||||
## [/codeblock]
|
||||
|
||||
var _klass: GDScript
|
||||
var _db: SQLite
|
||||
|
||||
## Create an instance of DbSet, specifying the [SQLiteObject] inherited class that represents
|
||||
## the table that this set should interact with.
|
||||
func _init(h_klass: GDScript) -> void:
|
||||
_klass = h_klass
|
||||
|
||||
## Set the [SQLite] database handle for this [DbSet]. This is handled internally by [method Context.setup],
|
||||
## but you can also set a custom database handle for this DbSet.
|
||||
func set_db(db_conn: SQLite) -> void:
|
||||
_db = db_conn
|
||||
|
||||
## Creates the backing table for the [SQLiteObject] inherited backing class for the object.
|
||||
func create_table(drop_if_exists: bool) -> void:
|
||||
SQLiteObject._create_table(_db, _klass, drop_if_exists)
|
||||
|
||||
## Check to see if the table exists or not.
|
||||
func table_exists() -> bool:
|
||||
return SQLiteObject._table_exists(_db, _klass)
|
||||
|
||||
## Check's the [SQLite] database to see if the ID exists in the database. Require's [method SQLiteObject.set_column_flags]
|
||||
## being called assigning a column as a Primary Key.
|
||||
func has_id(id: Variant) -> bool:
|
||||
return SQLiteObject._has_id(_db, _klass, id)
|
||||
|
||||
## Searches the [SQLite] database for an object that matches the [Condition] as given. Returns the
|
||||
## [SQLiteObject] instance if found, otherwise returns null if it found nothing.
|
||||
func find_one(conditions: Condition) -> SQLiteObject:
|
||||
return SQLiteObject._find_one(_db, _klass, conditions)
|
||||
|
||||
## Searches the [SQLite] database for any matching object that matches the [Condition] given. Returns
|
||||
## an Array of [SQLiteObject]s that was found, otherwise returns an Empty array if nothing is found.
|
||||
func find_many(conditions: Condition) -> Array:
|
||||
return SQLiteObject._find_many(_db, _klass, conditions)
|
||||
|
||||
## Returns all saved [SQLiteObject]s stored in the [SQLite] database.
|
||||
func all() -> Array:
|
||||
return SQLiteObject._all(_db, _klass)
|
||||
|
||||
## Stores a [SQLiteObject] in the [SQLite] database. Until this is called, an [SQLiteObject] is not
|
||||
## saved in the database, and [method SQLiteObject.save] will not work. Using this method will
|
||||
## automatically save the data to the Database when executed.[br][br]
|
||||
## [b][color=red]NOTE:[/color][/b] [SQLiteObject]s defined with an Auto-Increment Primary key, will
|
||||
## set their primary key variable once this method is run automatically for you. If the primary
|
||||
## key is not set after calling this method, then it was not saved to the database.
|
||||
func append(obj: SQLiteObject) -> void:
|
||||
assert(obj.get_script() == _klass, "Attempting to add an SQLiteObject of %s to table of type %s!" %
|
||||
[obj.get_script().get_global_name(), _klass.get_global_name()]
|
||||
)
|
||||
obj._db = _db
|
||||
obj.save()
|
||||
|
||||
## Removes a [SQLiteObject] from the [SQLite] database. This function calls [method SQLiteObject.delete]
|
||||
## function to remove it from the database. You can use either method to remove the object from the database.
|
||||
func erase(obj: SQLiteObject) -> void:
|
||||
assert(obj.get_script() == _klass, "Attempting to remove an SQLiteObject of %s to table of type %s!" %
|
||||
[obj.get_script().get_global_name(), _klass.get_global_name()]
|
||||
)
|
||||
obj._db = _db
|
||||
obj.delete()
|
||||
1
addons/gdata_orm/db_set.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c2buvo3nsojg
|
||||
21
addons/gdata_orm/godot-sqlite/LICENSE.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019-2024 Piet Bronders & Jeroen De Geeter
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>AvailableLibraries</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>libgdsqlite.ios.template_debug.a</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libgdsqlite.ios.template_debug.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>libgdsqlite.ios.template_debug.simulator.a</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64_x86_64-simulator</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libgdsqlite.ios.template_debug.simulator.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
<string>x86_64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
<key>SupportedPlatformVariant</key>
|
||||
<string>simulator</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XFWK</string>
|
||||
<key>XCFrameworkFormatVersion</key>
|
||||
<string>1.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>AvailableLibraries</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>libgdsqlite.ios.template_release.a</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libgdsqlite.ios.template_release.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>libgdsqlite.ios.template_release.simulator.a</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64_x86_64-simulator</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libgdsqlite.ios.template_release.simulator.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
<string>x86_64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
<key>SupportedPlatformVariant</key>
|
||||
<string>simulator</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XFWK</string>
|
||||
<key>XCFrameworkFormatVersion</key>
|
||||
<string>1.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>libgdsqlite.template_debug</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.godotengine.libgdsqlite</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>libgdsqlite.macos.template_debug</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.0</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.12</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>libgdsqlite.template_release</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.godotengine.libgdsqlite</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>libgdsqlite.macos.template_release</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.0</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.12</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>AvailableLibraries</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>libgodot-cpp.ios.template_debug.arm64.a</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libgodot-cpp.ios.template_debug.arm64.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>libgodot-cpp.ios.template_debug.universal.simulator.a</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64_x86_64-simulator</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libgodot-cpp.ios.template_debug.universal.simulator.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
<string>x86_64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
<key>SupportedPlatformVariant</key>
|
||||
<string>simulator</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XFWK</string>
|
||||
<key>XCFrameworkFormatVersion</key>
|
||||
<string>1.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>AvailableLibraries</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>libgodot-cpp.ios.template_release.arm64.a</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libgodot-cpp.ios.template_release.arm64.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>libgodot-cpp.ios.template_release.universal.simulator.a</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64_x86_64-simulator</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libgodot-cpp.ios.template_release.universal.simulator.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
<string>x86_64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
<key>SupportedPlatformVariant</key>
|
||||
<string>simulator</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XFWK</string>
|
||||
<key>XCFrameworkFormatVersion</key>
|
||||
<string>1.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
32
addons/gdata_orm/godot-sqlite/gdsqlite.gdextension
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
[configuration]
|
||||
|
||||
entry_symbol = "sqlite_library_init"
|
||||
compatibility_minimum = "4.4"
|
||||
|
||||
[libraries]
|
||||
|
||||
macos.debug = "./bin/libgdsqlite.macos.template_debug.framework"
|
||||
macos.release = "./bin/libgdsqlite.macos.template_release.framework"
|
||||
windows.debug.x86_64 = "./bin/libgdsqlite.windows.template_debug.x86_64.dll"
|
||||
windows.release.x86_64 = "./bin/libgdsqlite.windows.template_release.x86_64.dll"
|
||||
linux.debug.x86_64 = "./bin/libgdsqlite.linux.template_debug.x86_64.so"
|
||||
linux.release.x86_64 = "./bin/libgdsqlite.linux.template_release.x86_64.so"
|
||||
android.debug.arm64 = "./bin/libgdsqlite.android.template_debug.arm64.so"
|
||||
android.release.arm64 = "./bin/libgdsqlite.android.template_release.arm64.so"
|
||||
android.debug.x86_64 = "./bin/libgdsqlite.android.template_debug.x86_64.so"
|
||||
android.release.x86_64 = "./bin/libgdsqlite.android.template_release.x86_64.so"
|
||||
ios.debug = "./bin/libgdsqlite.ios.template_debug.xcframework"
|
||||
ios.release = "./bin/libgdsqlite.ios.template_release.xcframework"
|
||||
web.debug.threads.wasm32 = "./bin/libgdsqlite.web.template_debug.wasm32.wasm"
|
||||
web.release.threads.wasm32 = "./bin/libgdsqlite.web.template_release.wasm32.wasm"
|
||||
web.debug.wasm32 = "./bin/libgdsqlite.web.template_debug.wasm32.nothreads.wasm"
|
||||
web.release.wasm32 = "./bin/libgdsqlite.web.template_release.wasm32.nothreads.wasm"
|
||||
|
||||
[dependencies]
|
||||
|
||||
ios.debug = {
|
||||
"./bin/libgodot-cpp.ios.template_debug.xcframework": ""
|
||||
}
|
||||
ios.release = {
|
||||
"./bin/libgodot-cpp.ios.template_release.xcframework": ""
|
||||
}
|
||||
1
addons/gdata_orm/godot-sqlite/gdsqlite.gdextension.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ca6ikrilfs4se
|
||||
14
addons/gdata_orm/godot-sqlite/godot-sqlite.gd
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# ############################################################################ #
|
||||
# Copyright © 2019-2025 Piet Bronders & Jeroen De Geeter <piet.bronders@gmail.com>
|
||||
# Licensed under the MIT License.
|
||||
# See LICENSE in the project root for license information.
|
||||
# ############################################################################ #
|
||||
|
||||
@tool
|
||||
extends EditorPlugin
|
||||
|
||||
func _enter_tree():
|
||||
pass
|
||||
|
||||
func _exit_tree():
|
||||
pass
|
||||
1
addons/gdata_orm/godot-sqlite/godot-sqlite.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cwsfv71x0jo4e
|
||||
7
addons/gdata_orm/godot-sqlite/plugin.cfg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[plugin]
|
||||
|
||||
name="Godot SQLite"
|
||||
description="GDNative wrapper for SQLite (Godot 4.X+), making it possible to use SQLite databases as data storage in all your future games."
|
||||
author="Piet Bronders & Jeroen De Geeter"
|
||||
version="4.5"
|
||||
script="godot-sqlite.gd"
|
||||
7
addons/gdata_orm/plugin.cfg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[plugin]
|
||||
|
||||
name="GDataORM"
|
||||
description="Godot based Data ORM (Object-Relational-Mapping) system based on SQLite."
|
||||
author="Mario Steele"
|
||||
version="0.1"
|
||||
script="plugin.gd"
|
||||
23
addons/gdata_orm/plugin.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
@tool
|
||||
extends EditorPlugin
|
||||
|
||||
|
||||
func _enable_plugin() -> void:
|
||||
EditorInterface.set_plugin_enabled("./godot-sqlite", true)
|
||||
pass
|
||||
|
||||
|
||||
func _disable_plugin() -> void:
|
||||
EditorInterface.set_plugin_enabled("./godot-sqlite", false)
|
||||
# Remove autoloads here.
|
||||
pass
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
# Initialization of the plugin goes here.
|
||||
pass
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
# Clean-up of the plugin goes here.
|
||||
pass
|
||||
1
addons/gdata_orm/plugin.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://6kjkv8ueyjhd
|
||||
430
addons/gdata_orm/sqlite_object.gd
Normal file
|
|
@ -0,0 +1,430 @@
|
|||
extends Resource
|
||||
class_name SQLiteObject
|
||||
## A Data Object representative of data to store in [SQLite] database.
|
||||
##
|
||||
## [SQLiteObject] is the core class for GDataORM. It handles the grunt work
|
||||
## of defining what table structure is and any special flags that are needed
|
||||
## for SQLite.[br][br]
|
||||
##
|
||||
## [b]Example:[/b]
|
||||
## [codeblock]
|
||||
## extends SQLiteObject
|
||||
## class_name Account
|
||||
##
|
||||
## var id: int
|
||||
## var username: String
|
||||
## var password: String
|
||||
## var address: Address
|
||||
##
|
||||
## static func _setup() -> void:
|
||||
## set_table_name(Account, "accounts")
|
||||
## set_column_flags(Account, "id", Flags.PRIMARY_KEY | Flags.AUTO_INCREMENT | Flags.NOT_NULL)
|
||||
## set_column_flags(Account, "username", Flags.NOT_NULL)
|
||||
## set_column_flags(Account, "password", Flags.NOT_NULL)
|
||||
## [/codeblock]
|
||||
|
||||
## The supported types of [SQLiteObject]
|
||||
enum DataType {
|
||||
## A [bool] Value
|
||||
BOOL,
|
||||
## An [int] Value
|
||||
INT,
|
||||
## A [float] Value
|
||||
REAL,
|
||||
## A Variable Length [String] Value
|
||||
STRING,
|
||||
## A [Dictionary] Value
|
||||
DICTIONARY,
|
||||
## An [Array] Value
|
||||
ARRAY,
|
||||
## A value of a built-in Godot DataType, or Object of a Custom Class.
|
||||
GODOT_DATATYPE,
|
||||
## A Fixed-size [String] value, like [PackedStringArray]
|
||||
CHAR,
|
||||
## A Binary value, like [PackedByteArray]
|
||||
BLOB
|
||||
}
|
||||
|
||||
const _BaseTypes = {
|
||||
TYPE_BOOL: DataType.BOOL,
|
||||
TYPE_INT: DataType.INT,
|
||||
TYPE_FLOAT: DataType.REAL,
|
||||
TYPE_STRING: DataType.STRING,
|
||||
TYPE_DICTIONARY: DataType.DICTIONARY,
|
||||
TYPE_ARRAY: DataType.ARRAY,
|
||||
}
|
||||
|
||||
const _DEFINITION = [
|
||||
"int",
|
||||
"int",
|
||||
"real",
|
||||
"text",
|
||||
"text",
|
||||
"text",
|
||||
"blob",
|
||||
"char(%d)",
|
||||
"blob"
|
||||
]
|
||||
|
||||
## SQLite flags used for column definitions.
|
||||
enum Flags {
|
||||
## No Flags Associated with this Column
|
||||
NONE = 1 << 0,
|
||||
## Column must not be Null.
|
||||
NOT_NULL = 1 << 1,
|
||||
## Column must be Unique
|
||||
UNIQUE = 1 << 2,
|
||||
## Column has a Default value.
|
||||
DEFAULT = 1 << 3,
|
||||
## Column is defined as a Primary Key for this table.
|
||||
PRIMARY_KEY = 1 << 4,
|
||||
## Column is defined as auto-incrementing.
|
||||
AUTO_INCREMENT = 1 << 5,
|
||||
## Column is a Foreign Key (See [SQLite] about Foreign Keys)
|
||||
FOREIGN_KEY = 1 << 6,
|
||||
}
|
||||
|
||||
class TableDefs:
|
||||
var columns: Dictionary[String, Dictionary] = {}
|
||||
var types: Dictionary[String, DataType] = {}
|
||||
var klass: GDScript
|
||||
var table_name: String
|
||||
|
||||
static var _tables: Dictionary[GDScript, TableDefs] = {}
|
||||
static var _registry: Dictionary[String, GDScript] = {}
|
||||
var _db: SQLite
|
||||
|
||||
## A debugging utility to see what classes have been registered with [SQLiteObject].
|
||||
## This is printed out to the terminal/output window for easy review.
|
||||
static func print_registered_classes() -> void:
|
||||
print("SQLiteObject Registered Classes:")
|
||||
for klass_name in _registry:
|
||||
print(klass_name)
|
||||
|
||||
## A debugging utility to see the structure of all the classes registered with [SQLiteObject].
|
||||
## This is printed out to the terminal/output window for easy review.
|
||||
static func print_data_structure() -> void:
|
||||
print("SQLite Object Data Structure:")
|
||||
print("-----------------------------")
|
||||
for klass in _tables:
|
||||
var table = _tables[klass]
|
||||
print("SQLiteObject>%s" % klass.get_global_name())
|
||||
print("Table Name: %s" % table.table_name)
|
||||
print("COLUMNS:")
|
||||
|
||||
for column in table.columns:
|
||||
var keys: Array = table.columns[column].keys().filter(func(x): return x != "data_type")
|
||||
var columns := [table.columns[column].data_type]
|
||||
columns.append_array(keys)
|
||||
print("\t%s(DataType.%s) - SQLite: (%s)" % [
|
||||
column,
|
||||
DataType.find_key(table.types[column]),
|
||||
", ".join(columns)
|
||||
])
|
||||
print("")
|
||||
pass
|
||||
|
||||
## This function is called once when setting up the class. This is automatically done with classes
|
||||
## that are registered as a [DbSet] by the [method Context.setup] static function call.
|
||||
static func setup(klass: GDScript) -> void:
|
||||
_registry[klass.get_global_name()] = klass
|
||||
var table: TableDefs
|
||||
if _tables.has(klass):
|
||||
table = _tables[klass]
|
||||
else:
|
||||
table = TableDefs.new()
|
||||
table.klass = klass
|
||||
table.table_name = klass.get_global_name()
|
||||
_tables[klass] = table
|
||||
|
||||
for prop in klass.get_script_property_list():
|
||||
if not prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE:
|
||||
continue
|
||||
|
||||
if prop.name.begins_with("_"):
|
||||
continue
|
||||
|
||||
var def = {}
|
||||
if _BaseTypes.has(prop.type):
|
||||
def.data_type = _DEFINITION[_BaseTypes[prop.type]]
|
||||
table.types[prop.name] = _BaseTypes[prop.type]
|
||||
else:
|
||||
def.data_type = _DEFINITION[DataType.GODOT_DATATYPE]
|
||||
table.types[prop.name] = DataType.GODOT_DATATYPE
|
||||
|
||||
table.columns[prop.name] = def
|
||||
|
||||
klass._setup()
|
||||
|
||||
## This is a virtual function that is called when setup() is called. This allows you to
|
||||
## setup the data class information such as Column Flags, Table Name and Column Types.
|
||||
static func _setup() -> void:
|
||||
push_warning("No setup has been defined for this class. No special column flags or types will be used.")
|
||||
|
||||
## This function allows you to set SQLite specific flags for columns, when storing the data.
|
||||
## This function should only be called in [method SQLiteObject._setup] which is part of the
|
||||
## initialization of the data.[br][br]
|
||||
## [b]Example:[/b]
|
||||
## [codeblock]
|
||||
## static func _setup() -> void:
|
||||
## # Ensure ID is an Auto-Increment Primary key in the database, that is not allowed to be null.
|
||||
## set_column_flag(MyDataClass, "id", Flags.PRIMARY_KEY | Flags.AUTO_INCREMENT | Flags.NOT_NULL)
|
||||
## # Ensure that name is not null in the database, and that it doesn't match any other row of data.
|
||||
## set_column_flag(MyDataClass, "name", Flags.NOT_NULL | Flags.UNIQUE)
|
||||
## [/codeblock]
|
||||
static func set_column_flags(klass: GDScript, column: String, flags: int, extra_params: Dictionary = {}) -> void:
|
||||
assert(_tables.has(klass), "Setup must be called first, before setting any column flags!")
|
||||
assert(_tables[klass].columns.has(column), "Column has not been defined! Make sure to declare the variable first!")
|
||||
|
||||
var data_type = _tables[klass].types[column]
|
||||
var col_def = _tables[klass].columns[column]
|
||||
|
||||
if flags & Flags.DEFAULT and not extra_params.has("default"):
|
||||
assert(false,"Attempting to set a default, without defining it in extra parameters!")
|
||||
if flags & Flags.AUTO_INCREMENT and not [DataType.INT, DataType.REAL].has(data_type):
|
||||
assert(false, "Attempting to set Auto Increment flag on Non-Integer column!")
|
||||
if flags & Flags.FOREIGN_KEY:
|
||||
if not extra_params.has("table"):
|
||||
assert(false, "Attempting to set Foreign Key flag without defining the Table it associates with!")
|
||||
if not extra_params.has("foreign_key"):
|
||||
assert(false, "Attempting to set Foreign Key flag without defining the Foreign Key!")
|
||||
|
||||
|
||||
if flags & Flags.NOT_NULL: col_def.not_null = true
|
||||
if flags & Flags.UNIQUE: col_def.unique = true
|
||||
if flags & Flags.DEFAULT: col_def.default = extra_params.default
|
||||
if flags & Flags.AUTO_INCREMENT: col_def.auto_increment = true
|
||||
if flags & Flags.PRIMARY_KEY: col_def.primary_key = true
|
||||
if flags & Flags.FOREIGN_KEY:
|
||||
col_def.foreign_key = extra_params.foreign_key
|
||||
col_def.foreign_table = extra_params.table
|
||||
_tables[klass].columns[column] = col_def
|
||||
|
||||
## Sets the table name to use in the [SQLite] database for storing/fetching data
|
||||
## from the database.
|
||||
static func set_table_name(klass: GDScript, table_name: String) -> void:
|
||||
assert(_tables.has(klass), "Setup must be called first, before setting the table name!")
|
||||
_tables[klass].table_name = table_name if table_name != "" else klass.get_global_name()
|
||||
|
||||
## Sets the column type of [enum SQLiteObject.DataType] along with any extra parameters needed.[br][br]
|
||||
## [b][color=red]NOTE:[/color][/b] Only use this function if you know what you are doing. GDataORM
|
||||
## attempts to match the SQLite data type, with the Godot data type as best as possible.
|
||||
static func set_column_type(klass: GDScript, column: String, type: DataType, extra_params: Dictionary = {}) -> void:
|
||||
assert(_tables.has(klass), "Setup must be called first, before setting any column types!")
|
||||
assert(_tables[klass].columns.has(column), "Column has not been defined! Make sure to declare the variable first!")
|
||||
|
||||
if type == DataType.CHAR and not extra_params.has("size"):
|
||||
assert(false, "Attempting to set Column type to CHAR without a size parameter!")
|
||||
|
||||
_tables[klass].types[column] = _DEFINITION[type] if type != DataType.CHAR else _DEFINITION[type] % extra_params.size
|
||||
|
||||
## Sets a variable that has been defined in the class, to be ignored, so as to not persist the data in the
|
||||
## [SQLite] database. The variable must be defined, in order for it to be ignored.[br][br]
|
||||
## [b][color=red]NOTE:[/color][/b] By default, GDataORM ignore's any variables that start with [code]_[/code] character.
|
||||
static func ignore_column(klass: GDScript, column: String) -> void:
|
||||
assert(_tables.has(klass), "Setup must be called first, before ignoring any column types!")
|
||||
assert(_tables[klass].columns.has(column), "Column has not been defined! Make sure to declare the variable first!")
|
||||
|
||||
_tables[klass].types.erase(column)
|
||||
_tables[klass].columns.erase(column)
|
||||
|
||||
## Adds a variable that is normally ignored in the class, to not be ignoerd, so that it can persist the data
|
||||
## in the [SQLite] database. The variable must be defined, in order for this function to succeed.
|
||||
static func add_column(klass: GDScript, column: String) -> void:
|
||||
assert(_tables.has(klass), "Setup must be called first, before adding any column types!")
|
||||
var props = klass.get_property_list()
|
||||
var res = props.filter(func(x): return x.name == column)
|
||||
assert(res.size() > 0, "You cannot add a column, that does not have the variable defined for it!")
|
||||
|
||||
var prop = res[0]
|
||||
var def = {}
|
||||
if _BaseTypes.has(prop.type):
|
||||
def.data_type = _DEFINITION[_BaseTypes[prop.type]]
|
||||
_tables[klass].types[prop.name] = _BaseTypes[prop.type]
|
||||
else:
|
||||
def.data_type = _DEFINITION[DataType.GODOT_DATATYPE]
|
||||
_tables[klass].types[prop.name] = DataType.GODOT_DATATYPE
|
||||
|
||||
_tables[klass].columns[prop.name] = def
|
||||
|
||||
static func _create_table(db: SQLite, klass: GDScript, drop_if_exists = false) -> void:
|
||||
assert(_tables.has(klass), "Setup must be called first, before setting any column types!")
|
||||
assert(not _tables[klass].columns.is_empty(), "No columns has been defined, either no variables are defined in the GDScript source, or setup was not called first!")
|
||||
if _table_exists(db, klass):
|
||||
if drop_if_exists:
|
||||
db.drop_table(_tables[klass].table_name)
|
||||
else:
|
||||
assert(false, "Table already exists!")
|
||||
db.create_table(_tables[klass].table_name, _tables[klass].columns)
|
||||
|
||||
static func _table_exists(db: SQLite, klass: GDScript) -> bool:
|
||||
assert(_tables.has(klass), "Setup must be called first, before setting any column types!")
|
||||
var table := _tables[klass]
|
||||
db.query_with_bindings("SELECT name FROM sqlite_master WHERE type='table' AND name=?;", [table.table_name])
|
||||
return not db.query_result.is_empty()
|
||||
|
||||
static func _has_id(db: SQLite, klass: GDScript, id: Variant) -> bool:
|
||||
var primary_key = _get_primary_key(klass)
|
||||
var table := _tables[klass]
|
||||
if typeof(id) == TYPE_STRING:
|
||||
db.query_with_bindings("SELECT ? FROM ? WHERE ?='?'", [primary_key, table.table_name, primary_key, id])
|
||||
else:
|
||||
db.query_with_bindings("SELECT ? FROM ? WHERE ?=?;", [primary_key, table.table_name, primary_key, id])
|
||||
return not db.query_result.is_empty()
|
||||
|
||||
static func _get_primary_key(klass: GDScript) -> String:
|
||||
assert(_tables.has(klass), "Setup must be called first, before setting any column types!")
|
||||
var table := _tables[klass]
|
||||
var primary_key: String = ""
|
||||
for column in table.columns:
|
||||
if table.columns[column].has("primary_key"):
|
||||
primary_key = column
|
||||
break
|
||||
|
||||
assert(primary_key != "", "No primary key has been defined!")
|
||||
return primary_key
|
||||
|
||||
static func _populate_object(table: TableDefs, obj: SQLiteObject, data: Dictionary) -> void:
|
||||
var props = obj.get_property_list()
|
||||
for key in data:
|
||||
if not props.any(func(x): return x.name == key):
|
||||
continue
|
||||
var prop = props.filter(func(x): return x.name == key)[0]
|
||||
if (table.types[key] == DataType.ARRAY or
|
||||
table.types[key] == DataType.DICTIONARY):
|
||||
obj.get(key).assign(JSON.parse_string(data[key]))
|
||||
elif table.types[key] == DataType.GODOT_DATATYPE:
|
||||
if _registry.has(prop.class_name):
|
||||
var klass := _registry[prop.class_name]
|
||||
var cond := Condition.new()
|
||||
var pk: String = _get_primary_key(klass)
|
||||
cond.equal(pk, bytes_to_var(data[key]))
|
||||
var nobj = _find_one(obj._db, klass, cond)
|
||||
obj.set(key, nobj)
|
||||
else:
|
||||
obj.set(key, bytes_to_var(data[key]))
|
||||
else:
|
||||
obj.set(key, data[key])
|
||||
|
||||
static func _find_one(db: SQLite, klass: GDScript, conditions: Condition) -> SQLiteObject:
|
||||
assert(_tables.has(klass), "Setup must be called first, before setting any column types!")
|
||||
var table := _tables[klass]
|
||||
var res := db.select_rows(table.table_name, conditions.to_string(), table.columns.keys())
|
||||
|
||||
if res.is_empty():
|
||||
return null
|
||||
else:
|
||||
var obj = klass.new()
|
||||
obj._db = db
|
||||
_populate_object(table, obj, res[0])
|
||||
return obj
|
||||
|
||||
static func _find_many(db: SQLite, klass: GDScript, conditions: Condition) -> Array:
|
||||
assert(_tables.has(klass), "Setup must be called first, before setting any column types!")
|
||||
var table := _tables[klass]
|
||||
var objs: Array = []
|
||||
var res = db.select_rows(table.table_name, conditions.to_string(), table.columns.keys())
|
||||
|
||||
for data in res:
|
||||
var obj = klass.new()
|
||||
obj._db = db
|
||||
_populate_object(table, obj, data)
|
||||
objs.append(obj)
|
||||
return objs
|
||||
|
||||
static func _all(db: SQLite, klass: GDScript) -> Array:
|
||||
assert(_tables.has(klass), "Setup must be called first, before setting any column types!")
|
||||
var table := _tables[klass]
|
||||
var objs: Array = []
|
||||
var res = db.select_rows(table.table_name, "", table.columns.keys())
|
||||
|
||||
for data in res:
|
||||
var obj = klass.new()
|
||||
obj._db = db
|
||||
_populate_object(table, obj, data)
|
||||
objs.append(obj)
|
||||
return objs
|
||||
|
||||
## Verify that the [SQLiteObject] exists in the database.
|
||||
func exists() -> bool:
|
||||
assert(_tables.has(self.get_script()), "Setup must be called first, before setting any column types!")
|
||||
assert(_db, "exists(): This instance was not fetched from the database, or has not been added to a DbSet!")
|
||||
var table := _tables[self.get_script()]
|
||||
var primary_key = _get_primary_key(self.get_script())
|
||||
assert(primary_key != "", "A Primary Key has not been defined for this class.")
|
||||
var res = _db.select_rows(table.table_name,
|
||||
Condition.new().equal(primary_key, self.get(primary_key)).to_string(),
|
||||
[primary_key])
|
||||
return not res.is_empty()
|
||||
|
||||
## Saves the [SQLiteObject] to the database file.[br][br]
|
||||
## [b][color=red]NOTE:[/color][/b] Of special note, an object needs to be added to a [DbSet] first through
|
||||
## [method DbSet.append] for this function to work. [method DbSet.append] will save the object when
|
||||
## it is first added. This function is mostly for recording updates to the [SQLiteObject] data.
|
||||
func save() -> void:
|
||||
assert(_tables.has(self.get_script()), "Setup must be called first, before setting any column types!")
|
||||
assert(_db, "save(): This instance was not fetched from the database, or has not been added to a DbSet!")
|
||||
var table := _tables[self.get_script()]
|
||||
var primary_key = _get_primary_key(self.get_script())
|
||||
|
||||
var sql_data = {}
|
||||
var data: Variant
|
||||
for key in table.columns.keys():
|
||||
data = get(key)
|
||||
if (table.types[key] == DataType.ARRAY or
|
||||
table.types[key] == DataType.DICTIONARY
|
||||
):
|
||||
sql_data[key] = JSON.stringify(data)
|
||||
elif table.types[key] == DataType.GODOT_DATATYPE:
|
||||
if typeof(data) == TYPE_OBJECT:
|
||||
if _registry.has(data.get_script().get_global_name()):
|
||||
var pk := _get_primary_key(data.get_script())
|
||||
var pk_val = data.get(pk)
|
||||
sql_data[key] = var_to_bytes(pk_val)
|
||||
else:
|
||||
sql_data[key] = var_to_bytes(data)
|
||||
else:
|
||||
sql_data[key] = var_to_bytes(data)
|
||||
else:
|
||||
sql_data[key] = data
|
||||
|
||||
if primary_key != "" and exists():
|
||||
_db.update_rows(table.table_name,Condition.new().equal(primary_key, get(primary_key)).to_string(), sql_data)
|
||||
else:
|
||||
if primary_key != "" and table.columns[primary_key].auto_increment:
|
||||
sql_data.erase(primary_key)
|
||||
|
||||
_db.insert_row(table.table_name, sql_data)
|
||||
|
||||
if primary_key != "" and table.columns[primary_key].auto_increment:
|
||||
var cond := Condition.new().equal("name","%s" % table.table_name)
|
||||
var res := _db.select_rows("sqlite_sequence", cond.to_string(), ["seq"])
|
||||
assert(not res.is_empty(), "Failed to insert record into %s." % [table.table_name])
|
||||
set(primary_key, res[0].seq)
|
||||
|
||||
## Removes the [SQLiteObject] from the database. This will fail, if the object was not fetched
|
||||
## from the database first. You can also use [method DbSet.erase] to remove an object from the
|
||||
## database.
|
||||
func delete() -> void:
|
||||
assert(_tables.has(self.get_script()), "Setup must be called first, before setting any column types!")
|
||||
assert(_db, "delete(): This instance was not fetched from the database, or has not been added to a DbSet!")
|
||||
var table := _tables[self.get_script()]
|
||||
var primary_key = _get_primary_key(self.get_script())
|
||||
|
||||
assert(primary_key != "", "In order to delete data from the database, it must have a primary key!")
|
||||
|
||||
if not exists():
|
||||
push_warning("Attempting to delete a record that doesn't exist!")
|
||||
return
|
||||
|
||||
_db.delete_rows(table.table_name, Condition.new().equal(primary_key, get(primary_key)).to_string())
|
||||
|
||||
func _to_string() -> String:
|
||||
assert(_tables.has(self.get_script()), "Setup must be called first, before setting any column types!")
|
||||
var table := _tables[self.get_script()]
|
||||
var primary_key = _get_primary_key(self.get_script())
|
||||
var kname = self.get_script().get_global_name()
|
||||
if primary_key != "":
|
||||
return "<%s:%s:%s>" % [kname, table.table_name, get(primary_key)]
|
||||
else:
|
||||
return "<%s:%s:G-%s>" % [kname, table.table_name, get_instance_id()]
|
||||
1
addons/gdata_orm/sqlite_object.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://uvaml64lmuws
|
||||
504
addons/gde_gozen/LICENSE
Normal file
|
|
@ -0,0 +1,504 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random
|
||||
Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
17
addons/gde_gozen/README.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# GDE GoZen
|
||||
## Adding the addon to your project
|
||||
Put this folder, `gde_gozen`, inside of a folder called `addons` inside of your Godot project and re-open your project. After reloading you will have access to a new node, `VideoPlayback`. This node has a lot of documentation comments so by pressing F1 inside Godot and search for the node `VideoPlayback`, you'll find it's documentation and more notes on how to use it.
|
||||
|
||||
## Videos in the file tree
|
||||
To see video files in your projects file tree, you need to add `mp4` and any other video extensions you might use to your Editor settings in `docks/filesystem/other_file_extensions`.
|
||||
|
||||
## Exporting your project
|
||||
1. When exporting, you'll have your executable and the GDE GoZen library file, these do need to be both shared for the application to work.
|
||||
2. Also, you will have to add `*.mp4` and other extension names of your video files to the resources which need to get exported for each platform you want to export for, otherwise your video files will not be included in your final export.
|
||||
|
||||
## Help needed?
|
||||
You can go to the [GitHub repo](https://github.com/VoylinsGamedevJourney/gde_gozen/issues) to report problems, or visit out [Discord server](discord.gg/BdbUf7VKYC) for help/advice.
|
||||
|
||||
> This software uses libraries from the FFmpeg project under the LGPLv2.1
|
||||
|
||||
[](https://ko-fi.com/R6R4M1UM6)
|
||||
BIN
addons/gde_gozen/bin/libgozen.android.template_debug.arm32.so
Normal file
BIN
addons/gde_gozen/bin/libgozen.android.template_debug.arm64.so
Normal file
BIN
addons/gde_gozen/bin/libgozen.android.template_release.arm32.so
Normal file
BIN
addons/gde_gozen/bin/libgozen.android.template_release.arm64.so
Normal file
BIN
addons/gde_gozen/bin/libgozen.linux.template_debug.arm64.so
Normal file
BIN
addons/gde_gozen/bin/libgozen.linux.template_debug.x86_64.so
Normal file
BIN
addons/gde_gozen/bin/libgozen.linux.template_release.arm64.so
Normal file
BIN
addons/gde_gozen/bin/libgozen.linux.template_release.x86_64.so
Normal file
BIN
addons/gde_gozen/bin/libgozen.macos.template_debug.arm64.dylib
Normal file
BIN
addons/gde_gozen/bin/libgozen.macos.template_debug.x86_64.dylib
Normal file
BIN
addons/gde_gozen/bin/libgozen.macos.template_release.arm64.dylib
Normal file
BIN
addons/gde_gozen/bin/libgozen.windows.template_debug.x86_64.dll
Normal file
29
addons/gde_gozen/gozen.gdextension
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
[configuration]
|
||||
|
||||
entry_symbol = "gozen_library_init"
|
||||
compatibility_minimum = "4.3"
|
||||
|
||||
[libraries]
|
||||
|
||||
linux.debug.x86_64 = "res://addons/gde_gozen/bin/libgozen.linux.template_debug.x86_64.so"
|
||||
linux.release.x86_64 = "res://addons/gde_gozen/bin/libgozen.linux.template_release.x86_64.so"
|
||||
linux.debug.arm64 = "res://addons/gde_gozen/bin/libgozen.linux.template_debug.arm64.so"
|
||||
linux.release.arm64 = "res://addons/gde_gozen/bin/libgozen.linux.template_release.arm64.so"
|
||||
|
||||
windows.debug.x86_64 = "res://addons/gde_gozen/bin/libgozen.windows.template_debug.x86_64.dll"
|
||||
windows.release.x86_64 = "res://addons/gde_gozen/bin/libgozen.windows.template_release.x86_64.dll"
|
||||
windows.debug.arm64 = "res://addons/gde_gozen/bin/libgozen.windows.template_debug.arm64.dll"
|
||||
windows.release.arm64 = "res://addons/gde_gozen/bin/libgozen.windows.template_release.arm64.dll"
|
||||
|
||||
macos.debug.x86_64 = "res://addons/gde_gozen/bin/libgozen.macos.template_debug.x86_64.dylib"
|
||||
macos.release.x86_64 = "res://addons/gde_gozen/bin/libgozen.macos.template_release.x86_64.dylib"
|
||||
macos.debug.arm64 = "res://addons/gde_gozen/bin/libgozen.macos.template_debug.arm64.dylib"
|
||||
macos.release.arm64 = "res://addons/gde_gozen/bin/libgozen.macos.template_release.arm64.dylib"
|
||||
|
||||
web.debug.wasm32 = "res://addons/gde_gozen/bin/libgozen.web.template_debug.wasm32.wasm"
|
||||
web.release.wasm32 = "res://addons/gde_gozen/bin/libgozen.web.template_release.wasm32.wasm"
|
||||
|
||||
android.debug.arm64 = "res://addons/gde_gozen/bin/libgozen.android.template_debug.arm64.so"
|
||||
android.release.arm64 = "res://addons/gde_gozen/bin/libgozen.android.template_release.arm64.so"
|
||||
android.debug.arm32 = "res://addons/gde_gozen/bin/libgozen.android.template_debug.arm32.so"
|
||||
android.release.arm32 = "res://addons/gde_gozen/bin/libgozen.android.template_release.arm32.so"
|
||||
1
addons/gde_gozen/gozen.gdextension.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bbi0kdfadrphl
|
||||
252
addons/gde_gozen/icon.svg
Normal file
|
After Width: | Height: | Size: 94 KiB |
43
addons/gde_gozen/icon.svg.import
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bijjjb1qmqf7f"
|
||||
path="res://.godot/imported/icon.svg-ac53c9c419a88eda808214a4d44243c3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/gde_gozen/icon.svg"
|
||||
dest_files=["res://.godot/imported/icon.svg-ac53c9c419a88eda808214a4d44243c3.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
BIN
addons/gde_gozen/icon.webp
Normal file
|
After Width: | Height: | Size: 17 KiB |
40
addons/gde_gozen/icon.webp.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dbk4jierdjfrf"
|
||||
path="res://.godot/imported/icon.webp-a5a23a9a73b8ba8140cf260e6bfffac7.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/gde_gozen/icon.webp"
|
||||
dest_files=["res://.godot/imported/icon.webp-a5a23a9a73b8ba8140cf260e6bfffac7.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
7
addons/gde_gozen/plugin.cfg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[plugin]
|
||||
|
||||
name="gde_gozen"
|
||||
description="Providing performant video playback."
|
||||
author="Voylin's Gamedev Journey"
|
||||
version="v9.1"
|
||||
script="plugin.gd"
|
||||
17
addons/gde_gozen/plugin.gd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
@tool
|
||||
class_name GoZenServer
|
||||
extends EditorPlugin
|
||||
## GoZenServer is only used for adding the node to the node list.
|
||||
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
add_custom_type(
|
||||
"VideoPlayback", "Control",
|
||||
load("res://addons/gde_gozen/video_playback.gd"),
|
||||
load("res://addons/gde_gozen/icon.webp"))
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
remove_custom_type("VideoPlayback")
|
||||
|
||||
1
addons/gde_gozen/plugin.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://1vr5dotnqnh5
|
||||
610
addons/gde_gozen/video_playback.gd
Normal file
|
|
@ -0,0 +1,610 @@
|
|||
class_name VideoPlayback
|
||||
extends Control
|
||||
## Video playback and seeking inside of Godot.
|
||||
##
|
||||
## To use this node, just add it anywhere and resize it to the desired size. Use the function [code]set_video_path(new_path)[/code] and the video will load. Take in mind that long video's can take a second or longer to load. If this is an issue you can preload the Video on startup of your project and set the video variable yourself, just remember to use the function [code]update_video()[/code] before the moment that you'd like to use it.
|
||||
|
||||
enum COLOR_PROFILE { AUTO, BT470, BT601, BT709, BT2020, BT2100 }
|
||||
enum STREAM_TYPE { VIDEO = 0, AUDIO = 1, SUBTITLE = 2 }
|
||||
|
||||
|
||||
signal frame_changed(frame_nr: int) ## Emitted when the current frame has changed, for showing and skipped frames.
|
||||
signal next_frame_called(frame_nr: int) ## Emitted when a new frame is showing.
|
||||
|
||||
signal video_loaded ## Emitted when the video is ready for playback.
|
||||
signal video_ended ## Emitted when the last frame has been shown.
|
||||
|
||||
signal playback_started ## Emitted when playback started/resumed.
|
||||
signal playback_paused ## Emitted when playback is paused.
|
||||
signal playback_ready ## Emitted when the node if fully setup and ready for playback.
|
||||
|
||||
|
||||
const SHADER_PATH: String = "res://addons/gde_gozen/yuv_to_rgb.gdshader"
|
||||
const PLAYBACK_SPEED_MIN: float = 0.25
|
||||
const PLAYBACK_SPEED_MAX: float = 4
|
||||
const AUDIO_OFFSET_THRESHOLD: float = 0.1
|
||||
|
||||
|
||||
@export_file var path: String = "": set = set_video_path ## Full path to video file.
|
||||
@export var enable_audio: bool = true ## Enable/Disable audio playback. When setting this on false before loading the audio, the audio playback won't be loaded meaning that the video will load faster. If you want audio but only disable it at certain moments, switch this value to false *after* the video is loaded.
|
||||
@export var audio_speed_to_sync: bool = false ## Enable/Disable a slight audio playback speed increase/reduction when syncing audio and video to avoid a hard cut.
|
||||
@export var enable_auto_play: bool = false ## Enable/disable auto video playback.
|
||||
@export_range(PLAYBACK_SPEED_MIN, PLAYBACK_SPEED_MAX, 0.05)
|
||||
var playback_speed: float = 1.0: set = set_playback_speed ## Adjust the video playback speed, 0.5 = half the speed and 2 = double the speed.
|
||||
@export var pitch_adjust: bool = true: set = set_pitch_adjust ## When changing playback speed, do you want the pitch to change or stay the same?
|
||||
@export var loop: bool = false ## Enable/disable looping on video_ended.
|
||||
@export_group("Extra's")
|
||||
@export var color_profile: COLOR_PROFILE = COLOR_PROFILE.AUTO: set = _set_color_profile ## Force a specific color profile if needed.
|
||||
@export var debug: bool = false ## Enable/disable the printing of debug info.
|
||||
|
||||
var video: GoZenVideo = null ## Video class object of GDE GoZen which interacts with video files through FFmpeg.
|
||||
|
||||
var video_texture: TextureRect = TextureRect.new() ## The texture rect is the view of the video, you can adjust the scaling options as you like, it is set to always center and scale the image to fit within the main VideoPlayback node size.
|
||||
var audio_player: AudioStreamPlayer = AudioStreamPlayer.new() ## Audio player is the AudioStreamPlayer which handles the audio playback for the video, only mess with the settings if you know what you are doing and know what you'd like to achieve.
|
||||
|
||||
var is_playing: bool = false ## Bool to check if the video is currently playing or not.
|
||||
var current_frame: int = 0: set = _set_current_frame ## Current frame number which the video playback is at.
|
||||
|
||||
var video_streams: PackedInt32Array = [] ## List of video streams in the video file.
|
||||
var audio_streams: PackedInt32Array = [] ## List of audio streams in the video file.
|
||||
var subtitle_streams: PackedInt32Array = [] ## List of subtitle streams in the video file.
|
||||
var chapters: Array[Chapter] = [] ## List of chapters in the video file.
|
||||
|
||||
var _time_elapsed: float = 0.
|
||||
var _frame_time: float = 0
|
||||
var _skips: int = 0
|
||||
|
||||
var _rotation: int = 0
|
||||
var _padding: int = 0
|
||||
var _frame_rate: float = 0.
|
||||
var _frame_count: int = 0
|
||||
var _has_alpha: bool = false
|
||||
|
||||
var _resolution: Vector2i = Vector2i.ZERO
|
||||
var _shader_material: ShaderMaterial = null
|
||||
|
||||
var _video_thread: int = -1
|
||||
var _audio_pitch_effect: AudioEffectPitchShift = AudioEffectPitchShift.new()
|
||||
|
||||
var y_texture: ImageTexture
|
||||
var u_texture: ImageTexture
|
||||
var v_texture: ImageTexture
|
||||
var a_texture: ImageTexture
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------ TREE FUNCTIONS
|
||||
func _enter_tree() -> void:
|
||||
var empty_image: Image = Image.create_empty(2,2,false, Image.FORMAT_R8)
|
||||
|
||||
y_texture = ImageTexture.create_from_image(empty_image)
|
||||
u_texture = ImageTexture.create_from_image(empty_image)
|
||||
v_texture = ImageTexture.create_from_image(empty_image)
|
||||
a_texture = ImageTexture.create_from_image(empty_image)
|
||||
|
||||
_shader_material = ShaderMaterial.new()
|
||||
_shader_material.shader = preload(SHADER_PATH)
|
||||
|
||||
video_texture.material = _shader_material
|
||||
video_texture.texture = ImageTexture.new()
|
||||
video_texture.anchor_right = TextureRect.ANCHOR_END
|
||||
video_texture.anchor_bottom = TextureRect.ANCHOR_END
|
||||
video_texture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
video_texture.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
|
||||
add_child(video_texture)
|
||||
add_child(audio_player)
|
||||
|
||||
AudioServer.add_bus()
|
||||
audio_player.bus = AudioServer.get_bus_name(AudioServer.bus_count - 1)
|
||||
AudioServer.add_bus_effect(AudioServer.bus_count - 1, _audio_pitch_effect)
|
||||
|
||||
if debug and OS.get_name().to_lower() != "web":
|
||||
_print_system_debug()
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
# Making certain no remaining tasks are running in separate threads.
|
||||
if _video_thread != -1:
|
||||
var error: int = WorkerThreadPool.wait_for_task_completion(_video_thread)
|
||||
|
||||
if error != OK:
|
||||
printerr("Something went wrong waiting for task completion! %s" % error)
|
||||
_video_thread = -1
|
||||
|
||||
if video != null:
|
||||
close()
|
||||
|
||||
AudioServer.remove_bus(AudioServer.get_bus_index(audio_player.bus))
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
playback_ready.emit()
|
||||
|
||||
|
||||
#------------------------------------------------ VIDEO DATA HANDLING
|
||||
## This is the starting point for video playback, provide a path of where
|
||||
## the video file can be found and it will load a Video object. After which
|
||||
## [code]_update_video()[/code] get's run and set's the first frame image.
|
||||
func set_video_path(new_path: String) -> void:
|
||||
if video != null:
|
||||
close()
|
||||
|
||||
if !is_node_ready():
|
||||
await ready
|
||||
if !get_tree().root.is_node_ready():
|
||||
await get_tree().root.ready
|
||||
|
||||
audio_player.stream = null # Cleaning up the stream just in case.
|
||||
|
||||
if new_path == "" or new_path.ends_with(".tscn"):
|
||||
return
|
||||
elif new_path.split(":")[0] == "uid":
|
||||
new_path = ResourceUID.get_id_path(ResourceUID.text_to_id(new_path))
|
||||
|
||||
path = new_path
|
||||
video = GoZenVideo.new()
|
||||
|
||||
if debug:
|
||||
video.enable_debug()
|
||||
else:
|
||||
video.disable_debug()
|
||||
|
||||
_video_thread = WorkerThreadPool.add_task(_open_video)
|
||||
|
||||
if enable_audio:
|
||||
_open_audio()
|
||||
|
||||
|
||||
## Update the video manually by providing a GoZenVideo instance and an optional AudioStreamWAV.
|
||||
func update_video(video_instance: GoZenVideo) -> void:
|
||||
if video != null:
|
||||
close()
|
||||
|
||||
_update_video(video_instance)
|
||||
_open_audio()
|
||||
|
||||
|
||||
## Only run this function after manually having added a Video object to the `video` variable. A good reason for doing this is to load your video's at startup time to prevent your program for freezing for a second when loading in big video files. Some video formats load faster then others so if you are experiencing issues with long loading times, try to use this function and create the video object on startup, or try switching the video format which you are using.
|
||||
func _update_video(new_video: GoZenVideo) -> void:
|
||||
video = new_video
|
||||
if !is_open():
|
||||
printerr("Video isn't open!")
|
||||
return
|
||||
|
||||
var image: Image
|
||||
var rotation_radians: float = deg_to_rad(video.get_rotation())
|
||||
|
||||
is_playing = false
|
||||
current_frame = 0
|
||||
|
||||
# Getting video data
|
||||
_padding = video.get_padding()
|
||||
_rotation = video.get_rotation()
|
||||
_frame_rate = video.get_framerate()
|
||||
_resolution = video.get_resolution()
|
||||
_frame_count = video.get_frame_count()
|
||||
_has_alpha = video.get_has_alpha()
|
||||
|
||||
video_streams = video.get_streams(STREAM_TYPE.VIDEO)
|
||||
audio_streams = video.get_streams(STREAM_TYPE.AUDIO)
|
||||
subtitle_streams = video.get_streams(STREAM_TYPE.SUBTITLE)
|
||||
|
||||
chapters.clear()
|
||||
for i: int in range(video.get_chapter_count()):
|
||||
@warning_ignore("UNSAFE_CALL_ARGUMENT")
|
||||
var chapter: Chapter = Chapter.new(
|
||||
video.get_chapter_start(i),
|
||||
video.get_chapter_end(i),
|
||||
video.get_chapter_metadata(i).get("title", "")
|
||||
)
|
||||
chapters.append(chapter)
|
||||
|
||||
if abs(_rotation) == 90:
|
||||
image = Image.create_empty(_resolution.y, _resolution.x, false, Image.FORMAT_R8)
|
||||
else:
|
||||
image = Image.create_empty(_resolution.x, _resolution.y, false, Image.FORMAT_R8)
|
||||
|
||||
image.fill(Color.WHITE)
|
||||
|
||||
if debug:
|
||||
_print_video_debug()
|
||||
|
||||
@warning_ignore("UNSAFE_METHOD_ACCESS")
|
||||
video_texture.texture.set_image(image)
|
||||
|
||||
# Applying shader params.
|
||||
_shader_material.set_shader_parameter("resolution", video.get_actual_resolution())
|
||||
_shader_material.set_shader_parameter("full_color", video.is_full_color_range())
|
||||
_shader_material.set_shader_parameter("interlaced", video.get_interlaced())
|
||||
_shader_material.set_shader_parameter("rotation", rotation_radians)
|
||||
_set_color_profile()
|
||||
|
||||
y_texture.set_image(video.get_y_data())
|
||||
u_texture.set_image(video.get_u_data())
|
||||
v_texture.set_image(video.get_v_data())
|
||||
a_texture.set_image(video.get_a_data() if _has_alpha else image)
|
||||
|
||||
_shader_material.set_shader_parameter("y_data", y_texture)
|
||||
_shader_material.set_shader_parameter("u_data", u_texture)
|
||||
_shader_material.set_shader_parameter("v_data", v_texture)
|
||||
_shader_material.set_shader_parameter("a_data", a_texture)
|
||||
|
||||
set_playback_speed(playback_speed)
|
||||
video_loaded.emit()
|
||||
|
||||
|
||||
## Sometimes color profiles are unknown from video files and in case that happens, the colors might be slightly off. Changing the export variable `color_profile` might help fixing the colors.
|
||||
func _set_color_profile(new_profile: COLOR_PROFILE = color_profile) -> void:
|
||||
var color_data: Vector4
|
||||
var profile_str: String = video.get_color_profile()
|
||||
|
||||
color_profile = new_profile
|
||||
|
||||
if new_profile != COLOR_PROFILE.AUTO:
|
||||
profile_str = str(COLOR_PROFILE.find_key(COLOR_PROFILE.BT2100)).to_lower()
|
||||
|
||||
match profile_str:
|
||||
"bt2020", "bt2100": color_data = Vector4(1.4746, 0.16455, 0.57135, 1.8814)
|
||||
"bt601", "bt470": color_data = Vector4(1.402, 0.344136, 0.714136, 1.772)
|
||||
_: color_data = Vector4(1.5748, 0.1873, 0.4681, 1.8556) # bt709 and unknown
|
||||
|
||||
_shader_material.set_shader_parameter("color_profile", color_data)
|
||||
|
||||
|
||||
## Seek frame can be used to switch to a frame number you want. Remember that some video codecs report incorrect video end frames or can't seek to the last couple of frames in a video file which may result in an error. Only use this when going to far distances in the video file, else you can use [code]next_frame()[/code].
|
||||
func seek_frame(new_frame_nr: int) -> void:
|
||||
if !is_open() and new_frame_nr == current_frame:
|
||||
return
|
||||
|
||||
current_frame = clamp(new_frame_nr, 0, _frame_count)
|
||||
if video.seek_frame(current_frame):
|
||||
printerr("Couldn't seek frame!")
|
||||
else:
|
||||
_set_frame_image()
|
||||
|
||||
if enable_audio and audio_player.stream.get_length() != 0:
|
||||
audio_player.set_stream_paused(false)
|
||||
audio_player.play(current_frame / _frame_rate)
|
||||
audio_player.set_stream_paused(!is_playing)
|
||||
|
||||
|
||||
## Seeking frames can be slow, so when you just need to go a couple of frames ahead, you can use next_frame and set skip to false for the last frame.
|
||||
func next_frame(skip: bool = false) -> void:
|
||||
if video.next_frame(skip) and !skip:
|
||||
_set_frame_image()
|
||||
next_frame_called.emit(current_frame)
|
||||
elif !skip:
|
||||
print("Something went wrong getting next frame!")
|
||||
|
||||
|
||||
func close() -> void:
|
||||
if video != null:
|
||||
if is_playing:
|
||||
pause()
|
||||
|
||||
video = null
|
||||
|
||||
|
||||
#------------------------------------------------ PLAYBACK HANDLING
|
||||
func _process(delta: float) -> void:
|
||||
if is_playing:
|
||||
_skips = 0
|
||||
_time_elapsed += delta
|
||||
|
||||
if _time_elapsed < _frame_time:
|
||||
return
|
||||
|
||||
while _time_elapsed >= _frame_time and _skips < 5:
|
||||
_time_elapsed -= _frame_time
|
||||
current_frame += 1
|
||||
_skips += 1
|
||||
|
||||
if current_frame >= _frame_count:
|
||||
is_playing = !is_playing
|
||||
|
||||
if enable_audio and audio_player.stream != null:
|
||||
audio_player.set_stream_paused(true)
|
||||
|
||||
video_ended.emit()
|
||||
|
||||
if loop:
|
||||
seek_frame(0)
|
||||
play()
|
||||
else:
|
||||
_sync_audio_video()
|
||||
|
||||
while _skips != 1:
|
||||
next_frame(true)
|
||||
_skips -= 1
|
||||
next_frame()
|
||||
elif _video_thread != -1:
|
||||
var error: int = WorkerThreadPool.wait_for_task_completion(_video_thread)
|
||||
|
||||
if error != OK:
|
||||
printerr("Something went wrong waiting for task completion! %s" % error)
|
||||
|
||||
_video_thread = -1
|
||||
_update_video(video)
|
||||
|
||||
if enable_auto_play:
|
||||
play()
|
||||
|
||||
|
||||
## Start the video playback. This will play until reaching the end of the video and then pause and go back to the start.
|
||||
func play() -> void:
|
||||
if video != null and !is_open() and is_playing:
|
||||
return
|
||||
is_playing = true
|
||||
|
||||
if enable_audio and audio_player.stream.get_length() != 0:
|
||||
audio_player.set_stream_paused(false)
|
||||
audio_player.play((current_frame + 1) / _frame_rate)
|
||||
audio_player.set_stream_paused(!is_playing)
|
||||
|
||||
playback_started.emit()
|
||||
|
||||
|
||||
## Pausing the video.
|
||||
func pause() -> void:
|
||||
is_playing = false
|
||||
|
||||
if enable_audio and audio_player.stream != null:
|
||||
audio_player.set_stream_paused(true)
|
||||
|
||||
playback_paused.emit()
|
||||
|
||||
|
||||
## Ensures the audio playback is in sync with the video
|
||||
func _sync_audio_video() -> void:
|
||||
if _time_elapsed < 1.20:
|
||||
return
|
||||
elif enable_audio and audio_player.stream.get_length() != 0:
|
||||
var audio_offset: float = audio_player.get_playback_position() + AudioServer.get_time_since_last_mix() - (current_frame + 1) / _frame_rate
|
||||
|
||||
if abs(audio_player.get_playback_position() + AudioServer.get_time_since_last_mix() - (current_frame + 1) / _frame_rate) > AUDIO_OFFSET_THRESHOLD:
|
||||
if debug: print("Audio Sync: time correction: ", audio_offset)
|
||||
audio_player.seek((current_frame + 1) / _frame_rate)
|
||||
audio_player.pitch_scale = playback_speed
|
||||
elif audio_speed_to_sync:
|
||||
if is_zero_approx(audio_player.pitch_scale - playback_speed):
|
||||
if audio_offset > AUDIO_OFFSET_THRESHOLD / 2:
|
||||
audio_player.pitch_scale = playback_speed * 0.99
|
||||
if debug: print("Audio Sync: slow down")
|
||||
elif audio_offset < -AUDIO_OFFSET_THRESHOLD / 2:
|
||||
audio_player.pitch_scale = playback_speed * 1.01
|
||||
if debug: print("Audio Sync: speed up")
|
||||
else:
|
||||
if not (audio_player.pitch_scale > playback_speed) != not (audio_offset < 0):
|
||||
audio_player.pitch_scale = playback_speed
|
||||
if debug: print("Audio Sync: back to normal")
|
||||
|
||||
|
||||
#------------------------------------------------ GETTERS
|
||||
## Getting the total amount of frames found in the video file.
|
||||
func get_video_frame_count() -> int:
|
||||
return _frame_count
|
||||
|
||||
|
||||
## Getting the framerate of the video
|
||||
func get_video_framerate() -> float:
|
||||
return _frame_rate
|
||||
|
||||
|
||||
## Getting the length of the video in seconds
|
||||
func get_video_length() -> int:
|
||||
return int(_frame_count / _frame_rate)
|
||||
|
||||
|
||||
## Getting the current playback position of the video in seconds
|
||||
func get_current_playback_position() -> int:
|
||||
return int(current_frame / _frame_rate)
|
||||
|
||||
|
||||
## Getting the rotation in degrees of the video
|
||||
func get_video_rotation() -> int:
|
||||
return _rotation
|
||||
|
||||
|
||||
## Check the alpha value of a video to know if this video has alpha or not
|
||||
func is_video_alpha() -> bool:
|
||||
return _has_alpha
|
||||
|
||||
|
||||
## Getting the title of a stream.
|
||||
func get_stream_title(stream: int) -> String:
|
||||
if not is_open():
|
||||
printerr("Video is not open!")
|
||||
return ""
|
||||
|
||||
return video.get_stream_metadata(stream).get("title")
|
||||
|
||||
|
||||
## Getting the language of a stream.
|
||||
func get_stream_language(stream: int) -> String:
|
||||
if not is_open():
|
||||
printerr("Video is not open!")
|
||||
return ""
|
||||
|
||||
return video.get_stream_metadata(stream).get("language")
|
||||
|
||||
|
||||
## Checking to see if the video is open or not, trying to run functions without checking if open can crash your project.
|
||||
func is_open() -> bool:
|
||||
return video != null and video.is_open()
|
||||
|
||||
|
||||
func _get_img_tex(image_data: PackedByteArray, width: int, height: int, r8: bool = true) -> ImageTexture:
|
||||
var format: Image.Format = Image.FORMAT_R8 if r8 else Image.FORMAT_RG8
|
||||
var image: Image = Image.create_from_data(width, height, false, format, image_data)
|
||||
|
||||
return ImageTexture.create_from_image(image)
|
||||
|
||||
|
||||
#------------------------------------------------ SETTERS
|
||||
func _set_current_frame(new_current_frame: int) -> void:
|
||||
current_frame = new_current_frame
|
||||
frame_changed.emit(current_frame)
|
||||
|
||||
|
||||
func _set_frame_image() -> void:
|
||||
RenderingServer.texture_2d_update(y_texture.get_rid(), video.get_y_data(), 0)
|
||||
RenderingServer.texture_2d_update(u_texture.get_rid(), video.get_u_data(), 0)
|
||||
RenderingServer.texture_2d_update(v_texture.get_rid(), video.get_v_data(), 0)
|
||||
|
||||
if _has_alpha:
|
||||
RenderingServer.texture_2d_update(a_texture.get_rid(), video.get_a_data(), 0)
|
||||
|
||||
|
||||
func set_playback_speed(new_playback_value: float) -> void:
|
||||
playback_speed = clampf(new_playback_value, 0.5, 2)
|
||||
_frame_time = (1.0 / _frame_rate) / playback_speed
|
||||
|
||||
if enable_audio and audio_player.stream != null:
|
||||
audio_player.pitch_scale = playback_speed
|
||||
_set_pitch_adjust()
|
||||
|
||||
if is_playing:
|
||||
audio_player.play(current_frame * (1.0 / _frame_rate))
|
||||
|
||||
|
||||
func set_pitch_adjust(new_pitch_value: bool) -> void:
|
||||
pitch_adjust = new_pitch_value
|
||||
_set_pitch_adjust()
|
||||
|
||||
|
||||
func _set_pitch_adjust() -> void:
|
||||
if pitch_adjust:
|
||||
_audio_pitch_effect.pitch_scale = clamp(1.0 / playback_speed, 0.5, 2.0)
|
||||
elif _audio_pitch_effect.pitch_scale != 1.0:
|
||||
_audio_pitch_effect.pitch_scale = 1.0
|
||||
|
||||
|
||||
func set_audio_stream(stream: int) -> void:
|
||||
if not is_open():
|
||||
printerr("Video is not open!")
|
||||
return
|
||||
|
||||
if not stream in audio_streams:
|
||||
printerr("Invalid audio stream!")
|
||||
return
|
||||
|
||||
if enable_audio:
|
||||
_open_audio(stream)
|
||||
if is_playing and audio_player.stream.get_length() != 0:
|
||||
audio_player.set_stream_paused(false)
|
||||
audio_player.play(current_frame / _frame_rate)
|
||||
audio_player.set_stream_paused(!is_playing)
|
||||
|
||||
|
||||
#------------------------------------------------ MISC
|
||||
## Converts the given duration as seconds in a formatted string. (hh):mm:ss
|
||||
func duration_to_formatted_string(duration_in_seconds: float) -> String:
|
||||
var hours: int = floori(duration_in_seconds / 3600.0)
|
||||
var minutes: int = floori(duration_in_seconds / 60.0) % 60
|
||||
var seconds: int = floori(duration_in_seconds) % 60
|
||||
|
||||
if hours == 0:
|
||||
return "%02d:%02d" % [minutes, seconds]
|
||||
return "%02d:%02d:%02d" % [hours, minutes, seconds]
|
||||
|
||||
|
||||
func _open_video() -> void:
|
||||
if video.open(path):
|
||||
printerr("Error opening video!")
|
||||
|
||||
|
||||
func _open_audio(stream_id: int = -1) -> void:
|
||||
var stream: AudioStreamFFmpeg = AudioStreamFFmpeg.new()
|
||||
|
||||
if stream.open(path, stream_id) != OK:
|
||||
printerr("Failed to open AudioStreamFFmpeg for: %s" % path)
|
||||
return
|
||||
|
||||
audio_player.set_stream.call_deferred(stream)
|
||||
|
||||
|
||||
func _print_stream_info(streams: PackedInt32Array) -> void:
|
||||
for i: int in range(len(streams)):
|
||||
var metadata: Dictionary = video.get_stream_metadata(streams[i])
|
||||
var title: String = metadata.get("title")
|
||||
var language: String = metadata.get("language")
|
||||
|
||||
if title == "":
|
||||
title = "Track " + str(i + 1)
|
||||
if language != "":
|
||||
title += " - %s" % language
|
||||
|
||||
print("- %s" % title)
|
||||
|
||||
|
||||
func _print_system_debug() -> void:
|
||||
print_rich("[b]System info")
|
||||
print("OS name: ", OS.get_name())
|
||||
print("Distro name: ", OS.get_distribution_name())
|
||||
print("OS version: ", OS.get_version())
|
||||
print_rich("Memory info:\n\t", OS.get_memory_info())
|
||||
print("CPU name: ", OS.get_processor_name())
|
||||
print("Threads count: ", OS.get_processor_count())
|
||||
|
||||
|
||||
func _print_video_debug() -> void:
|
||||
print_rich("[b]Video debug info")
|
||||
print("Extension: ", path.get_extension())
|
||||
print("Resolution: ", _resolution)
|
||||
print("Actual resolution: ", video.get_actual_resolution())
|
||||
print("Pixel format: ", video.get_pixel_format())
|
||||
print("Color profile: ", video.get_color_profile())
|
||||
print("Framerate: ", _frame_rate)
|
||||
print("Duration (in frames): ", _frame_count)
|
||||
print("Padding: ", _padding)
|
||||
print("Rotation: ", _rotation)
|
||||
print("Alpha: ", _has_alpha)
|
||||
print("Full color range: ", video.is_full_color_range())
|
||||
print("Interlaced flag: ", video.get_interlaced())
|
||||
print("Using sws: ", video.is_using_sws())
|
||||
print("Sar: ", video.get_sar())
|
||||
|
||||
if video_streams.size() != 0:
|
||||
print_rich("Video streams: [i](%s)" % video_streams.size())
|
||||
_print_stream_info(video_streams)
|
||||
else:
|
||||
print("No video streams found.")
|
||||
|
||||
if audio_streams.size() != 0:
|
||||
print_rich("Audio streams: [i](%s)" % audio_streams.size())
|
||||
_print_stream_info(audio_streams)
|
||||
else:
|
||||
print("No audio streams found.")
|
||||
|
||||
if subtitle_streams.size() != 0:
|
||||
print_rich("Subtitle streams: [i](%s)" % subtitle_streams.size())
|
||||
_print_stream_info(subtitle_streams)
|
||||
else:
|
||||
print("No subtitle streams found.")
|
||||
|
||||
if chapters.size() != 0:
|
||||
print_rich("Chapters: [i](%s)" % chapters.size())
|
||||
for i: int in range(chapters.size()):
|
||||
var title: String = chapters[i].title
|
||||
if title == "":
|
||||
title = "Chapter " + str(i + 1)
|
||||
print("- %s-%s - %s" % [
|
||||
duration_to_formatted_string(chapters[i].start),
|
||||
duration_to_formatted_string(chapters[i].end),
|
||||
title
|
||||
])
|
||||
else:
|
||||
print("No chapters found.")
|
||||
|
||||
|
||||
|
||||
class Chapter:
|
||||
var start: float ## Start of the chapter in seconds.
|
||||
var end: float ## End of the chapter in seconds.
|
||||
var title: String
|
||||
|
||||
func _init(_start: float, _end: float, _title: String) -> void:
|
||||
start = _start
|
||||
end = _end
|
||||
title = _title
|
||||
1
addons/gde_gozen/video_playback.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ivx7m2bfysip
|
||||
66
addons/gde_gozen/yuv_to_rgb.gdshader
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D y_data;
|
||||
uniform sampler2D u_data;
|
||||
uniform sampler2D v_data;
|
||||
uniform sampler2D a_data;
|
||||
|
||||
uniform vec2 resolution;
|
||||
uniform vec4 color_profile;
|
||||
uniform bool full_color;
|
||||
uniform int interlaced; // 0 = no, 1 = top first, 2 = bottom first
|
||||
uniform float rotation;
|
||||
|
||||
varying vec2 tex_uv;
|
||||
varying vec2 chroma_uv;
|
||||
varying vec4 modulate;
|
||||
|
||||
const vec3 LIMITED_Y_OFFSET = vec3(16.0/255.0, 128.0/255.0, 128.0/255.0);
|
||||
const vec3 LIMITED_SCALE = vec3(255.0/219.0, 255.0/224.0, 255.0/224.0);
|
||||
|
||||
|
||||
|
||||
void vertex() {
|
||||
// Handling rotation in vertex
|
||||
float c = cos(rotation);
|
||||
float s = sin(rotation);
|
||||
mat2 rot_mat = mat2(vec2(c, s), vec2(-s, c));
|
||||
|
||||
vec2 centered_uv = UV - 0.5;
|
||||
vec2 rotated_uv = rot_mat * centered_uv;
|
||||
|
||||
tex_uv = rotated_uv + 0.5;
|
||||
chroma_uv = tex_uv;
|
||||
|
||||
modulate = COLOR;
|
||||
}
|
||||
|
||||
|
||||
void fragment() {
|
||||
if (tex_uv.x < 0.0 || tex_uv.x > 1.0 || tex_uv.y < 0.0 || tex_uv.y > 1.0) {
|
||||
COLOR = vec4(0.0);
|
||||
} else {
|
||||
float y_val;
|
||||
|
||||
// Deinterlacing by blending (slight blur, but viewable image)
|
||||
if (interlaced > 0) {
|
||||
float pixel_h = 1.0 / resolution.y;
|
||||
float offset_dir = (interlaced == 1) ? -pixel_h : pixel_h;
|
||||
vec2 offset_uv = clamp(tex_uv + vec2(0.0, offset_dir), 0.0, 1.0);
|
||||
float y_neighbor = texture(y_data, offset_uv).r;
|
||||
|
||||
y_val = mix(texture(y_data, tex_uv).r, y_neighbor, 0.5);
|
||||
} else y_val = texture(y_data, tex_uv).r;
|
||||
|
||||
vec3 yuv = vec3(y_val, texture(u_data, tex_uv).r, texture(v_data, tex_uv).r);
|
||||
|
||||
if (full_color) yuv.yz -= 0.5; // Full range just needs Chroma offset
|
||||
else yuv = (yuv - LIMITED_Y_OFFSET) * LIMITED_SCALE;
|
||||
|
||||
COLOR = vec4( // Applying color profile and returning color
|
||||
yuv.x + (yuv.z * color_profile.x),
|
||||
yuv.x - (yuv.y * color_profile.y) - (yuv.z * color_profile.z),
|
||||
yuv.x + (yuv.y * color_profile.w),
|
||||
texture(a_data, tex_uv).r) * modulate;
|
||||
}
|
||||
}
|
||||
1
addons/gde_gozen/yuv_to_rgb.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dx78avppolbai
|
||||
14
addons/kenny_spritesheet_importer/editor_plugin.gd
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
@tool
|
||||
extends EditorPlugin
|
||||
|
||||
var import_plugin = null
|
||||
|
||||
func _enter_tree():
|
||||
import_plugin = preload("import_plugin.gd").new()
|
||||
# Initialization of the plugin goes here.
|
||||
add_import_plugin(import_plugin)
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
remove_import_plugin(import_plugin)
|
||||
import_plugin = null
|
||||
1
addons/kenny_spritesheet_importer/editor_plugin.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cshumauwb262n
|
||||
131
addons/kenny_spritesheet_importer/import_plugin.gd
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
|
||||
@tool
|
||||
extends EditorImportPlugin
|
||||
|
||||
enum Presets { DEFAULT }
|
||||
|
||||
func _get_importer_name():
|
||||
return "iseesharp83.kenney.spritesheet.importer"
|
||||
|
||||
func _get_visible_name():
|
||||
return "Kenney Spritesheet"
|
||||
|
||||
func _get_recognized_extensions():
|
||||
return ["png"]
|
||||
|
||||
func _get_priority():
|
||||
return 0.5
|
||||
|
||||
func _get_import_order():
|
||||
return 0
|
||||
|
||||
func _get_save_extension():
|
||||
return "res"
|
||||
|
||||
func _get_resource_type():
|
||||
return "Resource"
|
||||
|
||||
func _get_preset_count():
|
||||
return Presets.size()
|
||||
|
||||
func _get_preset_name(preset_index):
|
||||
match preset_index:
|
||||
Presets.DEFAULT: return "Default"
|
||||
|
||||
func _get_import_options(path, preset_index):
|
||||
var options := [
|
||||
{
|
||||
"name": "spritesheet_xml_file",
|
||||
"default_value": path.replacen(".png", ".xml"),
|
||||
"property_hint": PROPERTY_HINT_FILE,
|
||||
"hint_string": "*.xml"
|
||||
},
|
||||
{
|
||||
"name": "destination_folder",
|
||||
"default_value": path.get_basename(),
|
||||
"property_hint": PROPERTY_HINT_DIR
|
||||
}]
|
||||
match preset_index:
|
||||
Presets.DEFAULT:
|
||||
return options
|
||||
_:
|
||||
return []
|
||||
|
||||
func _get_option_visibility(path, option_name, options):
|
||||
return true
|
||||
|
||||
func _import(source_file, save_path, options, platform_variants, gen_files):
|
||||
var atlas = read_kenney_sprite_sheet(options.spritesheet_xml_file)
|
||||
var folder = options.destination_folder
|
||||
create_folder(folder)
|
||||
|
||||
var full_image = ImageTexture.create_from_image(Image.load_from_file(source_file))
|
||||
|
||||
if not full_image:
|
||||
printerr("Failed to load image file: " + source_file)
|
||||
return ERR_FILE_NOT_FOUND
|
||||
|
||||
create_atlas_textures(folder, full_image, atlas, gen_files)
|
||||
return ResourceSaver.save(Resource.new(), "%s.%s" % [save_path, _get_save_extension()])
|
||||
|
||||
func create_folder(folder):
|
||||
var dir := DirAccess.open("res://")
|
||||
if not dir.dir_exists(folder):
|
||||
if not dir.make_dir_recursive(folder) == OK:
|
||||
printerr("Failed to create folder: " + folder)
|
||||
|
||||
func create_atlas_textures(folder, full_image, atlas, gen_files):
|
||||
for sprite in atlas.sprites:
|
||||
if not create_atlas_texture(folder, full_image, sprite, gen_files):
|
||||
return false
|
||||
return true
|
||||
|
||||
func create_atlas_texture(folder, full_image, sprite, gen_files):
|
||||
var name = "%s/%s.%s" % [folder, sprite.name.get_basename(), "tres"]
|
||||
var texture
|
||||
if ResourceLoader.exists(name, "AtlasTexture"):
|
||||
texture = ResourceLoader.load(name, "AtlasTexture")
|
||||
else:
|
||||
texture = AtlasTexture.new()
|
||||
|
||||
texture.atlas = full_image
|
||||
texture.region = Rect2(sprite.x, sprite.y, sprite.width, sprite.height)
|
||||
gen_files.push_back(name)
|
||||
return save_resource(name, texture)
|
||||
|
||||
func save_resource(name, texture):
|
||||
create_folder(name.get_base_dir())
|
||||
var status = ResourceSaver.save(texture, name)
|
||||
if status != OK:
|
||||
printerr("Failed to save resource " + name)
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
func read_kenney_sprite_sheet(source_file):
|
||||
var atlas = null
|
||||
var sprites = []
|
||||
var parser = XMLParser.new()
|
||||
if OK == parser.open(source_file):
|
||||
var read = parser.read()
|
||||
if read == OK:
|
||||
atlas = {}
|
||||
atlas["sprites"] = sprites
|
||||
while read != ERR_FILE_EOF:
|
||||
if parser.get_node_type() == XMLParser.NODE_ELEMENT:
|
||||
var node_name = parser.get_node_name()
|
||||
match node_name:
|
||||
"TextureAtlas":
|
||||
var imagePath = parser.get_named_attribute_value("imagePath")
|
||||
"SubTexture":
|
||||
var sprite = {}
|
||||
sprite['name'] = parser.get_named_attribute_value("name")
|
||||
sprite['x'] = float(parser.get_named_attribute_value("x"))
|
||||
sprite['y'] = float(parser.get_named_attribute_value("y"))
|
||||
sprite['width'] = float(parser.get_named_attribute_value("width"))
|
||||
sprite['height'] = float(parser.get_named_attribute_value("height"))
|
||||
sprites.append(sprite)
|
||||
read = parser.read()
|
||||
return atlas
|
||||
|
||||
|
||||
1
addons/kenny_spritesheet_importer/import_plugin.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://befkjtwvjfcfb
|
||||
7
addons/kenny_spritesheet_importer/plugin.cfg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[plugin]
|
||||
|
||||
name="Kenney Spritesheet Importer"
|
||||
description="Imports 2D Spritesheets from Kenney assets. These are normally found in the Spritesheets folder, and include a png and an xml file with <TextureAtlas> and <SubTexture> nodes."
|
||||
author="iseesharp83"
|
||||
version="1.0.0"
|
||||
script="editor_plugin.gd"
|
||||
1
addons/script_splitter/assets/Close.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 3 10 10M3 13 13 3" fill="none" stroke="#e0e0e0" stroke-width="2"/></svg>
|
||||
|
After Width: | Height: | Size: 168 B |
43
addons/script_splitter/assets/Close.svg.import
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://4juherhkw8hp"
|
||||
path="res://.godot/imported/Close.svg-9cdf2c31c5bc249987a101663dde96f2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/script_splitter/assets/Close.svg"
|
||||
dest_files=["res://.godot/imported/Close.svg-9cdf2c31c5bc249987a101663dde96f2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
39
addons/script_splitter/assets/LTabBar.svg
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
width="16"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="LTabBar.svg"
|
||||
inkscape:version="1.4 (86a8ad7, 2024-10-11)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#eeeeee"
|
||||
borderopacity="1"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#505050"
|
||||
inkscape:zoom="35.664698"
|
||||
inkscape:cx="8.6920685"
|
||||
inkscape:cy="10.416463"
|
||||
inkscape:window-width="1803"
|
||||
inkscape:window-height="1046"
|
||||
inkscape:window-x="106"
|
||||
inkscape:window-y="-11"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg1" />
|
||||
<path
|
||||
d="m 3,11.5 c 0,1.108 0.907,1.818 2,2 l 6,1 V 16 h 2 V 2 h -2 v 1.5 l -6,1 C 3.907,4.682 3,5.392 3,6.5 Z"
|
||||
fill="#8eef97"
|
||||
id="path1"
|
||||
style="fill:#bfbfbf;fill-opacity:1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
43
addons/script_splitter/assets/LTabBar.svg.import
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cod0nie30hnjp"
|
||||
path="res://.godot/imported/LTabBar.svg-0e9371d55bcb56b674582e235e5d8a1d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/script_splitter/assets/LTabBar.svg"
|
||||
dest_files=["res://.godot/imported/LTabBar.svg-0e9371d55bcb56b674582e235e5d8a1d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
39
addons/script_splitter/assets/RTabBar.svg
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
width="16"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="RTabBar.svg"
|
||||
inkscape:version="1.4 (86a8ad7, 2024-10-11)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#eeeeee"
|
||||
borderopacity="1"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#505050"
|
||||
inkscape:zoom="35.664698"
|
||||
inkscape:cx="8.6920685"
|
||||
inkscape:cy="10.416463"
|
||||
inkscape:window-width="1803"
|
||||
inkscape:window-height="1046"
|
||||
inkscape:window-x="106"
|
||||
inkscape:window-y="-11"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg1" />
|
||||
<path
|
||||
d="m 13,11.5 c 0,1.108 -0.907,1.818 -2,2 l -6,1 V 16 H 3 V 2 h 2 v 1.5 l 6,1 c 1.093,0.182 2,0.892 2,2 z"
|
||||
fill="#8eef97"
|
||||
id="path1"
|
||||
style="fill:#bfbfbf;fill-opacity:1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
43
addons/script_splitter/assets/RTabBar.svg.import
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://di3qxejijgp0e"
|
||||
path="res://.godot/imported/RTabBar.svg-1cf63dac5b4ec3a67a7cdab390c157d7.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/script_splitter/assets/RTabBar.svg"
|
||||
dest_files=["res://.godot/imported/RTabBar.svg-1cf63dac5b4ec3a67a7cdab390c157d7.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
39
addons/script_splitter/assets/TabBar.svg
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
width="16"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="TabBar.svg"
|
||||
inkscape:version="1.4 (86a8ad7, 2024-10-11)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#eeeeee"
|
||||
borderopacity="1"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#505050"
|
||||
inkscape:zoom="35.664698"
|
||||
inkscape:cx="8.6920685"
|
||||
inkscape:cy="10.430482"
|
||||
inkscape:window-width="1803"
|
||||
inkscape:window-height="1046"
|
||||
inkscape:window-x="106"
|
||||
inkscape:window-y="-11"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg1" />
|
||||
<path
|
||||
d="M5.5 4c-1.108 0-1.818.907-2 2l-1 6H1v2h14v-2h-1.5l-1-6c-.182-1.093-.892-2-2-2z"
|
||||
fill="#8eef97"
|
||||
id="path1"
|
||||
style="fill:#bfbfbf;fill-opacity:1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
43
addons/script_splitter/assets/TabBar.svg.import
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dceedsu8mfraw"
|
||||
path="res://.godot/imported/TabBar.svg-e83cf2d6da8a41e35756355b8a0f3b2b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/script_splitter/assets/TabBar.svg"
|
||||
dest_files=["res://.godot/imported/TabBar.svg-e83cf2d6da8a41e35756355b8a0f3b2b.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
BIN
addons/script_splitter/assets/atop.png
Normal file
|
After Width: | Height: | Size: 345 B |
40
addons/script_splitter/assets/atop.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://r6u1jtnbr4eg"
|
||||
path="res://.godot/imported/atop.png-fdfd8a2738a7960f4b5badd36ef62418.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/script_splitter/assets/atop.png"
|
||||
dest_files=["res://.godot/imported/atop.png-fdfd8a2738a7960f4b5badd36ef62418.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
9
addons/script_splitter/assets/expand.svg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
|
||||
<svg fill="#ffffff" width="64px" height="64px" viewBox="0 0 24.00 24.00" xmlns="http://www.w3.org/2000/svg" stroke="#ffffff" stroke-width="0.00024000000000000003" transform="rotate(0)">
|
||||
<g id="SVGRepo_bgCarrier" stroke-width="0"/>
|
||||
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<g id="SVGRepo_iconCarrier">
|
||||
<path d="M17 11H7V7l-5 5 5 5v-4h10v4l5-5-5-5z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 591 B |
43
addons/script_splitter/assets/expand.svg.import
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cractge21enk"
|
||||
path="res://.godot/imported/expand.svg-c8a40c528bdc9ff1c7945508158c04ee.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/script_splitter/assets/expand.svg"
|
||||
dest_files=["res://.godot/imported/expand.svg-c8a40c528bdc9ff1c7945508158c04ee.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
BIN
addons/script_splitter/assets/file_in.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
40
addons/script_splitter/assets/file_in.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cxds5tr6aq5v3"
|
||||
path="res://.godot/imported/file_in.png-349fab3e88dcbece78de5e93090cc9f9.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/script_splitter/assets/file_in.png"
|
||||
dest_files=["res://.godot/imported/file_in.png-349fab3e88dcbece78de5e93090cc9f9.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
55
addons/script_splitter/assets/fill_expand.svg
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Expand icon by Arthur Shlain from Usefulicons.com -->
|
||||
|
||||
<svg
|
||||
xml:space="preserve"
|
||||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 16 16"
|
||||
width="16"
|
||||
height="16"
|
||||
id="svg4"
|
||||
sodipodi:docname="fill_expand.svg"
|
||||
inkscape:version="1.4 (86a8ad7, 2024-10-11)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||
id="defs4" /><sodipodi:namedview
|
||||
id="namedview4"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#eeeeee"
|
||||
borderopacity="1"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#505050"
|
||||
inkscape:zoom="16"
|
||||
inkscape:cx="7.84375"
|
||||
inkscape:cy="21.71875"
|
||||
inkscape:window-width="1803"
|
||||
inkscape:window-height="1046"
|
||||
inkscape:window-x="106"
|
||||
inkscape:window-y="-11"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg4" /><g
|
||||
style="fill:#bfbfbf;fill-opacity:1"
|
||||
id="g4"
|
||||
transform="matrix(0.2,0,0,0.2,-2,-2)"><path
|
||||
d="M 10,40 H 25 V 25 H 40 V 10 H 10 Z"
|
||||
stroke="none"
|
||||
id="path1"
|
||||
style="fill:#bfbfbf;fill-opacity:1" /><path
|
||||
d="M 60,10 V 25 H 75 V 40 H 90 V 10 Z"
|
||||
stroke="none"
|
||||
id="path2"
|
||||
style="fill:#bfbfbf;fill-opacity:1" /><path
|
||||
d="M 75,75 H 60 V 90 H 90 V 57.5 H 75 Z"
|
||||
stroke="none"
|
||||
id="path3"
|
||||
style="fill:#bfbfbf;fill-opacity:1" /><path
|
||||
d="M 25,60 H 10 V 90 H 40 V 75 H 25 Z"
|
||||
stroke="none"
|
||||
id="path4"
|
||||
style="fill:#bfbfbf;fill-opacity:1" /></g></svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
43
addons/script_splitter/assets/fill_expand.svg.import
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cejhhnje48450"
|
||||
path="res://.godot/imported/fill_expand.svg-82bbfe3ae93c5fe880e9ec053c7ac4d3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/script_splitter/assets/fill_expand.svg"
|
||||
dest_files=["res://.godot/imported/fill_expand.svg-82bbfe3ae93c5fe880e9ec053c7ac4d3.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
199
addons/script_splitter/assets/github_CodeNameTwister.svg
Normal file
|
After Width: | Height: | Size: 35 KiB |