mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 08:07:17 +07:00
dummy library asset binds
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
using json_uptr = std::unique_ptr<rapidjson::Document>;
|
||||
using json_uptr = std::shared_ptr<rapidjson::Document>;
|
||||
class json_asset final : public content_asset<json_asset, json_uptr> {
|
||||
public:
|
||||
static const char* type_name() noexcept { return "json_asset"; }
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
using xml_uptr = std::unique_ptr<pugi::xml_document>;
|
||||
using xml_uptr = std::shared_ptr<pugi::xml_document>;
|
||||
class xml_asset final : public content_asset<xml_asset, xml_uptr> {
|
||||
public:
|
||||
static const char* type_name() noexcept { return "xml_asset"; }
|
||||
|
||||
15
samples/bin/library/scripts/emmy/assets/atlas.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/atlas.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class atlas
|
||||
local atlas = {
|
||||
}
|
||||
|
||||
---@type atlas
|
||||
_G.atlas = _G.atlas or atlas
|
||||
|
||||
---@class atlas_asset
|
||||
local atlas_asset = {
|
||||
---@type atlas
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type atlas_asset
|
||||
_G.atlas_asset = _G.atlas_asset or atlas_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/binary.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/binary.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class binary
|
||||
local binary = {
|
||||
}
|
||||
|
||||
---@type binary
|
||||
_G.binary = _G.binary or binary
|
||||
|
||||
---@class binary_asset
|
||||
local binary_asset = {
|
||||
---@type binary
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type binary_asset
|
||||
_G.binary_asset = _G.binary_asset or binary_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/flipbook.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/flipbook.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class flipbook
|
||||
local flipbook = {
|
||||
}
|
||||
|
||||
---@type flipbook
|
||||
_G.flipbook = _G.flipbook or flipbook
|
||||
|
||||
---@class flipbook_asset
|
||||
local flipbook_asset = {
|
||||
---@type flipbook
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type flipbook_asset
|
||||
_G.flipbook_asset = _G.flipbook_asset or flipbook_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/font.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/font.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class font
|
||||
local font = {
|
||||
}
|
||||
|
||||
---@type font
|
||||
_G.font = _G.font or font
|
||||
|
||||
---@class font_asset
|
||||
local font_asset = {
|
||||
---@type font
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type font_asset
|
||||
_G.font_asset = _G.font_asset or font_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/image.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/image.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class image
|
||||
local image = {
|
||||
}
|
||||
|
||||
---@type image
|
||||
_G.image = _G.image or image
|
||||
|
||||
---@class image_asset
|
||||
local image_asset = {
|
||||
---@type image
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type image_asset
|
||||
_G.image_asset = _G.image_asset or image_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/json.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/json.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class json
|
||||
local json = {
|
||||
}
|
||||
|
||||
---@type json
|
||||
_G.json = _G.json or json
|
||||
|
||||
---@class json_asset
|
||||
local json_asset = {
|
||||
---@type json
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type json_asset
|
||||
_G.json_asset = _G.json_asset or json_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/material.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/material.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class material
|
||||
local material = {
|
||||
}
|
||||
|
||||
---@type material
|
||||
_G.material = _G.material or material
|
||||
|
||||
---@class material_asset
|
||||
local material_asset = {
|
||||
---@type material
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type material_asset
|
||||
_G.material_asset = _G.material_asset or material_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/mesh.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/mesh.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class mesh
|
||||
local mesh = {
|
||||
}
|
||||
|
||||
---@type mesh
|
||||
_G.mesh = _G.mesh or mesh
|
||||
|
||||
---@class mesh_asset
|
||||
local mesh_asset = {
|
||||
---@type mesh
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type mesh_asset
|
||||
_G.mesh_asset = _G.mesh_asset or mesh_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/model.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/model.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class model
|
||||
local model = {
|
||||
}
|
||||
|
||||
---@type model
|
||||
_G.model = _G.model or model
|
||||
|
||||
---@class model_asset
|
||||
local model_asset = {
|
||||
---@type model
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type model_asset
|
||||
_G.model_asset = _G.model_asset or model_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/prefab.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/prefab.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class prefab
|
||||
local prefab = {
|
||||
}
|
||||
|
||||
---@type prefab
|
||||
_G.prefab = _G.prefab or prefab
|
||||
|
||||
---@class prefab_asset
|
||||
local prefab_asset = {
|
||||
---@type prefab
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type prefab_asset
|
||||
_G.prefab_asset = _G.prefab_asset or prefab_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/script.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/script.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class script
|
||||
local script = {
|
||||
}
|
||||
|
||||
---@type script
|
||||
_G.script = _G.script or script
|
||||
|
||||
---@class script_asset
|
||||
local script_asset = {
|
||||
---@type script
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type script_asset
|
||||
_G.script_asset = _G.script_asset or script_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/shader.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/shader.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class shader
|
||||
local shader = {
|
||||
}
|
||||
|
||||
---@type shader
|
||||
_G.shader = _G.shader or shader
|
||||
|
||||
---@class shader_asset
|
||||
local shader_asset = {
|
||||
---@type shader
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type shader_asset
|
||||
_G.shader_asset = _G.shader_asset or shader_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/shape.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/shape.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class shape
|
||||
local shape = {
|
||||
}
|
||||
|
||||
---@type shape
|
||||
_G.shape = _G.shape or shape
|
||||
|
||||
---@class shape_asset
|
||||
local shape_asset = {
|
||||
---@type shape
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type shape_asset
|
||||
_G.shape_asset = _G.shape_asset or shape_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/sound.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/sound.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class sound
|
||||
local sound = {
|
||||
}
|
||||
|
||||
---@type sound
|
||||
_G.sound = _G.sound or sound
|
||||
|
||||
---@class sound_asset
|
||||
local sound_asset = {
|
||||
---@type sound
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type sound_asset
|
||||
_G.sound_asset = _G.sound_asset or sound_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/spine.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/spine.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class spine
|
||||
local spine = {
|
||||
}
|
||||
|
||||
---@type spine
|
||||
_G.spine = _G.spine or spine
|
||||
|
||||
---@class spine_asset
|
||||
local spine_asset = {
|
||||
---@type spine
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type spine_asset
|
||||
_G.spine_asset = _G.spine_asset or spine_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/sprite.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/sprite.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class sprite
|
||||
local sprite = {
|
||||
}
|
||||
|
||||
---@type sprite
|
||||
_G.sprite = _G.sprite or sprite
|
||||
|
||||
---@class sprite_asset
|
||||
local sprite_asset = {
|
||||
---@type sprite
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type sprite_asset
|
||||
_G.sprite_asset = _G.sprite_asset or sprite_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/text.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/text.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class text
|
||||
local text = {
|
||||
}
|
||||
|
||||
---@type text
|
||||
_G.text = _G.text or text
|
||||
|
||||
---@class text_asset
|
||||
local text_asset = {
|
||||
---@type text
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type text_asset
|
||||
_G.text_asset = _G.text_asset or text_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/texture.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/texture.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class texture
|
||||
local texture = {
|
||||
}
|
||||
|
||||
---@type texture
|
||||
_G.texture = _G.texture or texture
|
||||
|
||||
---@class texture_asset
|
||||
local texture_asset = {
|
||||
---@type texture
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type texture_asset
|
||||
_G.texture_asset = _G.texture_asset or texture_asset
|
||||
15
samples/bin/library/scripts/emmy/assets/xml.lua
Normal file
15
samples/bin/library/scripts/emmy/assets/xml.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@class xml
|
||||
local xml = {
|
||||
}
|
||||
|
||||
---@type xml
|
||||
_G.xml = _G.xml or xml
|
||||
|
||||
---@class xml_asset
|
||||
local xml_asset = {
|
||||
---@type xml
|
||||
content = nil
|
||||
}
|
||||
|
||||
---@type xml_asset
|
||||
_G.xml_asset = _G.xml_asset or xml_asset
|
||||
101
samples/bin/library/scripts/emmy/high/library.lua
Normal file
101
samples/bin/library/scripts/emmy/high/library.lua
Normal file
@@ -0,0 +1,101 @@
|
||||
---@class library
|
||||
local library = {
|
||||
}
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return atlas_asset
|
||||
function library.load_atlas(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return binary_asset
|
||||
function library.load_binary(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return flipbook_asset
|
||||
function library.load_flipbook(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return font_asset
|
||||
function library.load_font(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return image_asset
|
||||
function library.load_image(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return json_asset
|
||||
function library.load_json(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return material_asset
|
||||
function library.load_material(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return mesh_asset
|
||||
function library.load_mesh(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return model_asset
|
||||
function library.load_model(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return prefab_asset
|
||||
function library.load_prefab(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return script_asset
|
||||
function library.load_script(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return shader_asset
|
||||
function library.load_shader(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return shape_asset
|
||||
function library.load_shape(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return sound_asset
|
||||
function library.load_sound(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return spine_asset
|
||||
function library.load_spine(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return sprite_asset
|
||||
function library.load_sprite(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return text_asset
|
||||
function library.load_text(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return texture_asset
|
||||
function library.load_texture(self, address) end
|
||||
|
||||
---@param self library
|
||||
---@param address string
|
||||
---@return xml_asset
|
||||
function library.load_xml(self, address) end
|
||||
|
||||
---@type library
|
||||
_G.the_library = _G.the_library or library
|
||||
@@ -26,7 +26,7 @@ namespace e2d
|
||||
return library.load_asset_async<text_asset>(address)
|
||||
.then([](const text_asset::load_result& json_data){
|
||||
return the<deferrer>().do_in_worker_thread([json_data](){
|
||||
auto json = std::make_unique<rapidjson::Document>();
|
||||
auto json = std::make_shared<rapidjson::Document>();
|
||||
if ( json->Parse(json_data->content().c_str()).HasParseError() ) {
|
||||
throw json_asset_loading_exception();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace e2d
|
||||
return library.load_asset_async<text_asset>(address)
|
||||
.then([](const text_asset::load_result& xml_data){
|
||||
return the<deferrer>().do_in_worker_thread([xml_data](){
|
||||
auto xml = std::make_unique<pugi::xml_document>();
|
||||
auto xml = std::make_shared<pugi::xml_document>();
|
||||
if ( !xml->load_string(xml_data->content().c_str()) ) {
|
||||
throw xml_asset_loading_exception();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,18 +1,77 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include "_high_binds.hpp"
|
||||
|
||||
#include <enduro2d/high/library.hpp>
|
||||
#include <enduro2d/high/assets/atlas_asset.hpp>
|
||||
#include <enduro2d/high/assets/binary_asset.hpp>
|
||||
#include <enduro2d/high/assets/flipbook_asset.hpp>
|
||||
#include <enduro2d/high/assets/font_asset.hpp>
|
||||
#include <enduro2d/high/assets/image_asset.hpp>
|
||||
#include <enduro2d/high/assets/json_asset.hpp>
|
||||
#include <enduro2d/high/assets/material_asset.hpp>
|
||||
#include <enduro2d/high/assets/mesh_asset.hpp>
|
||||
#include <enduro2d/high/assets/model_asset.hpp>
|
||||
#include <enduro2d/high/assets/prefab_asset.hpp>
|
||||
#include <enduro2d/high/assets/script_asset.hpp>
|
||||
#include <enduro2d/high/assets/shader_asset.hpp>
|
||||
#include <enduro2d/high/assets/shape_asset.hpp>
|
||||
#include <enduro2d/high/assets/sound_asset.hpp>
|
||||
#include <enduro2d/high/assets/spine_asset.hpp>
|
||||
#include <enduro2d/high/assets/sprite_asset.hpp>
|
||||
#include <enduro2d/high/assets/text_asset.hpp>
|
||||
#include <enduro2d/high/assets/texture_asset.hpp>
|
||||
#include <enduro2d/high/assets/xml_asset.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace e2d;
|
||||
|
||||
template < typename Asset >
|
||||
void bind_asset(const str& base_name, sol::state& l) {
|
||||
l.new_usertype<Asset>(base_name + "_asset",
|
||||
sol::no_constructor,
|
||||
|
||||
"content", sol::property([](const Asset& a){
|
||||
return a.content();
|
||||
})
|
||||
);
|
||||
|
||||
l["library"][str("load_") + base_name] =
|
||||
[](const library& l, str_view address){
|
||||
return l.load_main_asset<Asset>(address);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d::bindings::high
|
||||
{
|
||||
void bind_library(sol::state& l) {
|
||||
l["e2d"].get_or_create<sol::table>()
|
||||
["high"].get_or_create<sol::table>()
|
||||
.new_usertype<library>("library");
|
||||
l.new_usertype<library>("library",
|
||||
sol::no_constructor
|
||||
);
|
||||
|
||||
bind_asset<atlas_asset>("atlas", l);
|
||||
bind_asset<binary_asset>("binary", l);
|
||||
bind_asset<flipbook_asset>("flipbook", l);
|
||||
bind_asset<font_asset>("font", l);
|
||||
bind_asset<image_asset>("image", l);
|
||||
bind_asset<json_asset>("json", l);
|
||||
bind_asset<material_asset>("material", l);
|
||||
bind_asset<mesh_asset>("mesh", l);
|
||||
bind_asset<model_asset>("model", l);
|
||||
bind_asset<prefab_asset>("prefab", l);
|
||||
bind_asset<script_asset>("script", l);
|
||||
bind_asset<shader_asset>("shader", l);
|
||||
bind_asset<shape_asset>("shape", l);
|
||||
bind_asset<sound_asset>("sound", l);
|
||||
bind_asset<spine_asset>("spine", l);
|
||||
bind_asset<sprite_asset>("sprite", l);
|
||||
bind_asset<text_asset>("text", l);
|
||||
bind_asset<texture_asset>("texture", l);
|
||||
bind_asset<xml_asset>("xml", l);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user