summaryrefslogtreecommitdiff
path: root/source/libs
diff options
context:
space:
mode:
Diffstat (limited to 'source/libs')
-rw-r--r--source/libs/asura-lib-core/application.h4
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_canvas.cpp (renamed from source/libs/asura-lib-core/graphics/binding/canvas.binding.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_color.cpp (renamed from source/libs/asura-lib-core/graphics/binding/color.binding.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_gif.cpp (renamed from source/libs/asura-lib-core/graphics/binding/gif.binding.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_image.cpp (renamed from source/libs/asura-lib-core/graphics/binding/image.binding.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_image_data.cpp (renamed from source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_mesh2d.cpp (renamed from source/libs/asura-lib-core/graphics/binding/mesh2d.binding.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_mesh2d_data.cpp (renamed from source/libs/asura-lib-core/graphics/binding/mesh2d_data.binding.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_shader.cpp (renamed from source/libs/asura-lib-core/graphics/binding/shader.binding.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_sprite_batch.cpp (renamed from source/libs/asura-lib-core/graphics/binding/sprite_batch.binding.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_window.cpp (renamed from source/libs/asura-lib-core/graphics/binding/window.binding.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/image.h4
-rw-r--r--source/libs/asura-lib-core/graphics/stb_decoder.cpp4
-rw-r--r--source/libs/asura-lib-core/input/cursor.h23
-rw-r--r--source/libs/asura-lib-core/input/event.h45
-rw-r--r--source/libs/asura-lib-core/input/input_device.hpp9
-rw-r--r--source/libs/asura-lib-core/input/joypad.h (renamed from source/libs/asura-lib-core/stringmap.cpp)0
-rw-r--r--source/libs/asura-lib-core/input/mouse.defs7
-rw-r--r--source/libs/asura-lib-core/threading/binding/_coroutine.cpp (renamed from source/libs/asura-lib-utils/filesystem/resource_manager.cpp)0
-rw-r--r--source/libs/asura-lib-core/threading/binding/_thread.cpp0
-rw-r--r--source/libs/asura-lib-core/threading/coroutine.cpp0
-rw-r--r--source/libs/asura-lib-core/threading/coroutine.h27
-rw-r--r--source/libs/asura-lib-core/threading/thread.cpp0
-rw-r--r--source/libs/asura-lib-core/threading/thread.h0
-rw-r--r--source/libs/asura-lib-framework/scripts/component.lua6
-rw-r--r--source/libs/asura-lib-framework/scripts/entity.lua (renamed from source/libs/asura-lib-framework/scripts/gameobject.lua)49
-rw-r--r--source/libs/asura-lib-framework/scripts/filesystem/entity_loader.lua2
-rw-r--r--source/libs/asura-lib-framework/scripts/graphics/animator.lua6
-rw-r--r--source/libs/asura-lib-framework/scripts/graphics/particle_system.lua4
-rw-r--r--source/libs/asura-lib-framework/scripts/scene.lua2
-rw-r--r--source/libs/asura-lib-utils/filesystem/resource_manager.h48
-rw-r--r--source/libs/asura-lib-utils/io/binding/_compressor.cpp0
-rw-r--r--source/libs/asura-lib-utils/io/binding/_data_buffer.cpp (renamed from source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp)16
-rw-r--r--source/libs/asura-lib-utils/io/binding/_file.cpp186
-rw-r--r--source/libs/asura-lib-utils/io/binding/_file_data.cpp64
-rw-r--r--source/libs/asura-lib-utils/io/binding/_file_system.cpp267
-rw-r--r--source/libs/asura-lib-utils/io/compressor.cpp11
-rw-r--r--source/libs/asura-lib-utils/io/compressor.h30
-rw-r--r--source/libs/asura-lib-utils/io/data_buffer.cpp (renamed from source/libs/asura-lib-utils/filesystem/data_buffer.cpp)16
-rw-r--r--source/libs/asura-lib-utils/io/data_buffer.h (renamed from source/libs/asura-lib-utils/filesystem/data_buffer.h)19
-rw-r--r--source/libs/asura-lib-utils/io/decoded_data.cpp (renamed from source/libs/asura-lib-utils/filesystem/decoded_data.cpp)2
-rw-r--r--source/libs/asura-lib-utils/io/decoded_data.h (renamed from source/libs/asura-lib-utils/filesystem/decoded_data.h)2
-rw-r--r--source/libs/asura-lib-utils/io/file.cpp286
-rw-r--r--source/libs/asura-lib-utils/io/file.h132
-rw-r--r--source/libs/asura-lib-utils/io/file_data.cpp57
-rw-r--r--source/libs/asura-lib-utils/io/file_data.h68
-rw-r--r--source/libs/asura-lib-utils/io/file_system.cpp198
-rw-r--r--source/libs/asura-lib-utils/io/file_system.h110
-rw-r--r--source/libs/asura-lib-utils/io/reloadable.h (renamed from source/libs/asura-lib-utils/filesystem/reloadable.h)2
-rw-r--r--source/libs/asura-lib-utils/manager.hpp (renamed from source/libs/asura-lib-core/manager.hpp)0
-rw-r--r--source/libs/asura-lib-utils/math/rect.hpp19
-rw-r--r--source/libs/asura-lib-utils/scripting/portable.hpp7
-rw-r--r--source/libs/asura-lib-utils/singleton.hpp (renamed from source/libs/asura-lib-core/singleton.hpp)0
-rw-r--r--source/libs/asura-lib-utils/stringmap.cpp0
-rw-r--r--source/libs/asura-lib-utils/stringmap.hpp (renamed from source/libs/asura-lib-core/stringmap.hpp)0
-rw-r--r--source/libs/asura-lib-utils/type.h14
-rw-r--r--source/libs/asura-lib-utils/utils_config.h0
57 files changed, 1613 insertions, 133 deletions
diff --git a/source/libs/asura-lib-core/application.h b/source/libs/asura-lib-core/application.h
index 983dbce..b61154d 100644
--- a/source/libs/asura-lib-core/application.h
+++ b/source/libs/asura-lib-core/application.h
@@ -65,9 +65,9 @@ namespace AsuraEngine
private:
///
- /// Lua state.
+ /// ̵߳lua stateӦѭС
///
- lua_State* mLuaState;
+ lua_State* mMainLuaState;
///
/// Asura libsᰴն˳ʼ˳ʱִ˳
diff --git a/source/libs/asura-lib-core/graphics/binding/canvas.binding.cpp b/source/libs/asura-lib-core/graphics/binding/_canvas.cpp
index e69de29..e69de29 100644
--- a/source/libs/asura-lib-core/graphics/binding/canvas.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_canvas.cpp
diff --git a/source/libs/asura-lib-core/graphics/binding/color.binding.cpp b/source/libs/asura-lib-core/graphics/binding/_color.cpp
index e69de29..e69de29 100644
--- a/source/libs/asura-lib-core/graphics/binding/color.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_color.cpp
diff --git a/source/libs/asura-lib-core/graphics/binding/gif.binding.cpp b/source/libs/asura-lib-core/graphics/binding/_gif.cpp
index e69de29..e69de29 100644
--- a/source/libs/asura-lib-core/graphics/binding/gif.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_gif.cpp
diff --git a/source/libs/asura-lib-core/graphics/binding/image.binding.cpp b/source/libs/asura-lib-core/graphics/binding/_image.cpp
index e69de29..e69de29 100644
--- a/source/libs/asura-lib-core/graphics/binding/image.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_image.cpp
diff --git a/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp b/source/libs/asura-lib-core/graphics/binding/_image_data.cpp
index 72e33da..72e33da 100644
--- a/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_image_data.cpp
diff --git a/source/libs/asura-lib-core/graphics/binding/mesh2d.binding.cpp b/source/libs/asura-lib-core/graphics/binding/_mesh2d.cpp
index e69de29..e69de29 100644
--- a/source/libs/asura-lib-core/graphics/binding/mesh2d.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_mesh2d.cpp
diff --git a/source/libs/asura-lib-core/graphics/binding/mesh2d_data.binding.cpp b/source/libs/asura-lib-core/graphics/binding/_mesh2d_data.cpp
index 6e15052..6e15052 100644
--- a/source/libs/asura-lib-core/graphics/binding/mesh2d_data.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_mesh2d_data.cpp
diff --git a/source/libs/asura-lib-core/graphics/binding/shader.binding.cpp b/source/libs/asura-lib-core/graphics/binding/_shader.cpp
index 2f2f507..2f2f507 100644
--- a/source/libs/asura-lib-core/graphics/binding/shader.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_shader.cpp
diff --git a/source/libs/asura-lib-core/graphics/binding/sprite_batch.binding.cpp b/source/libs/asura-lib-core/graphics/binding/_sprite_batch.cpp
index e69de29..e69de29 100644
--- a/source/libs/asura-lib-core/graphics/binding/sprite_batch.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_sprite_batch.cpp
diff --git a/source/libs/asura-lib-core/graphics/binding/window.binding.cpp b/source/libs/asura-lib-core/graphics/binding/_window.cpp
index 3befc8c..3befc8c 100644
--- a/source/libs/asura-lib-core/graphics/binding/window.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_window.cpp
diff --git a/source/libs/asura-lib-core/graphics/image.h b/source/libs/asura-lib-core/graphics/image.h
index 2dd3a4a..d8577ad 100644
--- a/source/libs/asura-lib-core/graphics/image.h
+++ b/source/libs/asura-lib-core/graphics/image.h
@@ -69,8 +69,10 @@ namespace AsuraEngine
LUAX_DECL_METHOD(l_GetSize);
};
-
+
}
}
+namespace AEGraphics = AsuraEngine::Graphics;
+
#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-core/graphics/stb_decoder.cpp b/source/libs/asura-lib-core/graphics/stb_decoder.cpp
index b14d0f3..a13d6b8 100644
--- a/source/libs/asura-lib-core/graphics/stb_decoder.cpp
+++ b/source/libs/asura-lib-core/graphics/stb_decoder.cpp
@@ -1,6 +1,6 @@
-#include "STBDecoder.h"
+#include <asura-lib-utils/exceptions/exception.h>
-#include "Exceptions/Exception.h"
+#include "stb_decoder.h"
#include "stb/stb_image.h"
namespace AsuraEngine
diff --git a/source/libs/asura-lib-core/input/cursor.h b/source/libs/asura-lib-core/input/cursor.h
index da4a765..a8e53a6 100644
--- a/source/libs/asura-lib-core/input/cursor.h
+++ b/source/libs/asura-lib-core/input/cursor.h
@@ -4,16 +4,18 @@
#include <SDL2/SDL.h>
-#include "Scripting/Portable.h"
-#include "Graphics/ImageData.h"
-#include "InputDevice.hpp"
+#include <asura-lib-utils/scripting/portable.hpp>
+
+#include "../graphics/image_data.h"
+
+#include "input_device.hpp"
namespace AsuraEngine
{
namespace Input
{
- class Cursor : public Scripting::Portable
+ class Cursor ASURA_FINAL : public AEScripting::Portable<Cursor>
{
public:
@@ -29,6 +31,8 @@ namespace AsuraEngine
CursorType GetType() const;
SystemCursor GetSystemType() const;
+ LUAX_DECL_FACTORY(Cursor);
+
private:
SDL_Cursor* mCursorHandle;
@@ -36,17 +40,6 @@ namespace AsuraEngine
CursorType mType;
SystemCursor mSystemType;
- public:
-
- //----------------------------------------------------------------------------------------------------------
-
- LUAX_DECL_FACTORY(Cursor);
-
- LUAX_DECL_ENUM(EnumCursorType);
- LUAX_DECL_ENUM(EnumSystemCursor);
-
- //----------------------------------------------------------------------------------------------------------
-
};
}
diff --git a/source/libs/asura-lib-core/input/event.h b/source/libs/asura-lib-core/input/event.h
new file mode 100644
index 0000000..a24e806
--- /dev/null
+++ b/source/libs/asura-lib-core/input/event.h
@@ -0,0 +1,45 @@
+#ifndef __ASURA_ENGINE_EVENT_H__
+#define __ASURA_ENGINE_EVENT_H__
+
+namespace AsuraEngine
+{
+ namespace Input
+ {
+
+ enum EventType
+ {
+ EVENT_BEGIN_MOUSE__ ,
+ EVENT_LEFT_DOWN ,
+ EVENT_LEFT_UP ,
+ EVENT_LEFT_DCLICK ,
+ EVENT_MIDDLE_DOWN ,
+ EVENT_MIDDLE_UP ,
+ EVENT_MIDDLE_DCLICK ,
+ EVENT_RIGHT_DOWN ,
+ EVENT_RIGHT_UP ,
+ EVENT_RIGHT_DCLICK ,
+ EVENT_MOTION ,
+ EVENT_END_MOUSE__ ,
+ EVENT_ENTER_WINDOW ,
+ EVENT_LEAVE_WINDOW ,
+ EVENT_MOUSEWHEEL
+ };
+
+ struct Event
+ {
+ int type;
+ union
+ {
+ // 갴¼
+ struct {
+ int id;
+ } button;
+ };
+ };
+
+ }
+}
+
+namespace AEInput = AsuraEngine::Input;
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-core/input/input_device.hpp b/source/libs/asura-lib-core/input/input_device.hpp
index eb0b7a3..46f5be8 100644
--- a/source/libs/asura-lib-core/input/input_device.hpp
+++ b/source/libs/asura-lib-core/input/input_device.hpp
@@ -1,9 +1,10 @@
#ifndef __ASURA_ENGINE_INPUT_BASE_H__
#define __ASURA_ENGINE_INPUT_BASE_H__
-#include "Scripting/Portable.h"
-#include "Config.h"
-#include "Singleton.hpp"
+#include <asura-lib-utils/scripting/portable.hpp>
+
+#include "../core_config.h"
+#include "../singleton.hpp"
namespace AsuraEngine
{
@@ -15,7 +16,7 @@ namespace AsuraEngine
///
template<class T>
ASURA_ABSTRACT class InputDevice
- : virtual public Scripting::Portable
+ : virtual public Scripting::Portable<T>
, virtual public Singleton<T>
{
public:
diff --git a/source/libs/asura-lib-core/stringmap.cpp b/source/libs/asura-lib-core/input/joypad.h
index e69de29..e69de29 100644
--- a/source/libs/asura-lib-core/stringmap.cpp
+++ b/source/libs/asura-lib-core/input/joypad.h
diff --git a/source/libs/asura-lib-core/input/mouse.defs b/source/libs/asura-lib-core/input/mouse.defs
new file mode 100644
index 0000000..de1d117
--- /dev/null
+++ b/source/libs/asura-lib-core/input/mouse.defs
@@ -0,0 +1,7 @@
+
+enum MouseButton
+{
+ MOUSE_BUTTON_LEFT,
+ MOUSE_BUTTON_MIDDLE,
+ MOUSE_BUTTON_RIGHT,
+};
diff --git a/source/libs/asura-lib-utils/filesystem/resource_manager.cpp b/source/libs/asura-lib-core/threading/binding/_coroutine.cpp
index e69de29..e69de29 100644
--- a/source/libs/asura-lib-utils/filesystem/resource_manager.cpp
+++ b/source/libs/asura-lib-core/threading/binding/_coroutine.cpp
diff --git a/source/libs/asura-lib-core/threading/binding/_thread.cpp b/source/libs/asura-lib-core/threading/binding/_thread.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/threading/binding/_thread.cpp
diff --git a/source/libs/asura-lib-core/threading/coroutine.cpp b/source/libs/asura-lib-core/threading/coroutine.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/threading/coroutine.cpp
diff --git a/source/libs/asura-lib-core/threading/coroutine.h b/source/libs/asura-lib-core/threading/coroutine.h
new file mode 100644
index 0000000..f511e48
--- /dev/null
+++ b/source/libs/asura-lib-core/threading/coroutine.h
@@ -0,0 +1,27 @@
+#ifndef __ASURA_COROUTINE_H__
+#define __ASURA_COROUTINE_H__
+
+#include <asura-lib-utils/scripting/portable.hpp>
+
+namespace AsuraEngine
+{
+ namespace Threading
+ {
+
+ class Coroutine ASURA_FINAL
+ : public AEScripting::Portable<Coroutine>
+ {
+ public:
+
+ LUAX_DECL_FACTORY(Coroutine);
+
+ private:
+
+
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-core/threading/thread.cpp b/source/libs/asura-lib-core/threading/thread.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/threading/thread.cpp
diff --git a/source/libs/asura-lib-core/threading/thread.h b/source/libs/asura-lib-core/threading/thread.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/threading/thread.h
diff --git a/source/libs/asura-lib-framework/scripts/component.lua b/source/libs/asura-lib-framework/scripts/component.lua
index 9306f3b..b560bd3 100644
--- a/source/libs/asura-lib-framework/scripts/component.lua
+++ b/source/libs/asura-lib-framework/scripts/component.lua
@@ -3,7 +3,7 @@ AsuraEngine.Component = AsuraEngine.Class("Component")
local Component = AsuraEngine.Component
-- Component要显示在inspector的变量
-Component.gameobject = AsuraEngine.Type.GameObject
+Component.entity = AsuraEngine.Type.Entity
function Component.Extend(cname)
self.base(cname)
@@ -11,8 +11,8 @@ function Component.Extend(cname)
end
-function Component:Ctor(gameobject)
- self.gameobject = gameobject
+function Component:Ctor(entity)
+ self.entity = entity
end
function Component:OnEvent(e)
diff --git a/source/libs/asura-lib-framework/scripts/gameobject.lua b/source/libs/asura-lib-framework/scripts/entity.lua
index a2d20ef..ea8e14d 100644
--- a/source/libs/asura-lib-framework/scripts/gameobject.lua
+++ b/source/libs/asura-lib-framework/scripts/entity.lua
@@ -1,22 +1,23 @@
--
-- 实体,作为scene中的实体存在。Scene中唯一管理的就是实体entity,游戏里的所有component都依附于entity存在,包括camera组件。
--
+module "AsuraEngine"
require "transform"
-AsuraEngine.GameObject = AsuraEngine.Asset.Extend("GameObject")
+AsuraEngine.Entity = AsuraEngine.Asset.Extend("Entity")
-local GameObject = AsuraEngine.GameObject
+local Entity = AsuraEngine.Entity
-function GameObject:Ctor()
+function Entity:Ctor()
self.transform = AsuraEngine.Transform.New()
self.subentities = {} -- Extend node entities
end
-function GameObject:AddChild(gameobject)
- table.insert(self.child, gameobject)
+function Entity:AddChild(entity)
+ table.insert(self.child, entity)
end
-function GameObject:AddComponent(type, name)
+function Entity:AddComponent(type, name)
local cname = type
if name == nil then
cname = name
@@ -25,21 +26,19 @@ function GameObject:AddComponent(type, name)
self.components[cname] = compoennt
end
--- 根据组件名拿到组件
-function GameObject:GetComponent(name)
+function Entity:GetComponent(name)
return self.components[name]
end
--- 根据组件类型拿到组件
-function GameObject:GetComponentByType(tname)
+function Entity:GetComponentByType(type)
end
-function GameObject:OnEnable()
+function Entity:OnEnable()
end
-function GameObject:OnEvent(e)
+function Entity:OnEvent(e)
if self.components == nil or type(self.components) ~= "table" then
AsuraEditor.LogError("")
return
@@ -51,7 +50,7 @@ function GameObject:OnEvent(e)
end
end
-function GameObject:OnUpdate(dt)
+function Entity:OnUpdate(dt)
for name, component in self.components do
if component.OnUpdate ~= nil then
component:OnUpdate(dt)
@@ -59,7 +58,7 @@ function GameObject:OnUpdate(dt)
end
end
-function GameObject:OnRender()
+function Entity:OnRender()
for name, component in self.components do
if component.OnRender ~= nil then
component.OnRender()
@@ -67,7 +66,7 @@ function GameObject:OnRender()
end
end
-function GameObject:OnDisable()
+function Entity:OnDisable()
for name, component in self.components do
if component.OnDisable ~= nil then
component.OnDisable()
@@ -75,41 +74,41 @@ function GameObject:OnDisable()
end
end
-function GameObject:GetTrasform()
+function Entity:GetTrasform()
return self.transform
end
-function GameObject:GetPosition()
+function Entity:GetPosition()
end
-function GameObject:GetScale()
+function Entity:GetScale()
end
-function GameObject:GetRotation()
+function Entity:GetRotation()
end
-function GameObject:SetTrasform(transform)
+function Entity:SetTrasform(transform)
end
-function GameObject:SetPosition()
+function Entity:SetPosition()
end
-function GameObject:SetScale()
+function Entity:SetScale()
end
-function GameObject:SetRotation()
+function Entity:SetRotation()
end
--写asset
-function GameObject:ToAsset()
+function Entity:ToAsset()
end
-return GameObject \ No newline at end of file
+return Entity \ No newline at end of file
diff --git a/source/libs/asura-lib-framework/scripts/filesystem/entity_loader.lua b/source/libs/asura-lib-framework/scripts/filesystem/entity_loader.lua
index 57a890f..39ae0d9 100644
--- a/source/libs/asura-lib-framework/scripts/filesystem/entity_loader.lua
+++ b/source/libs/asura-lib-framework/scripts/filesystem/entity_loader.lua
@@ -1,4 +1,4 @@
-local loader = AsuraEngine.Loader.New("gameobject")
+local loader = AsuraEngine.Loader.New("entity")
function loader.OnLoad(asset)
diff --git a/source/libs/asura-lib-framework/scripts/graphics/animator.lua b/source/libs/asura-lib-framework/scripts/graphics/animator.lua
index c019dfa..fd2f979 100644
--- a/source/libs/asura-lib-framework/scripts/graphics/animator.lua
+++ b/source/libs/asura-lib-framework/scripts/graphics/animator.lua
@@ -8,9 +8,9 @@ local Animator = AsuraEngine.Animator
Animator.spriteRenderer = AsuraEngine.Type.SpriteRenderer
Animator.animation = AsuraEngine.Type.Animation
-function Animator:Ctor(gameobject, animation)
- self.base(gameobject)
- self.spriteRenderer = gameobject:GetSpriteRenderer()
+function Animator:Ctor(entity, animation)
+ self.base(entity)
+ self.spriteRenderer = entity:GetSpriteRenderer()
self.animation = animation
end
diff --git a/source/libs/asura-lib-framework/scripts/graphics/particle_system.lua b/source/libs/asura-lib-framework/scripts/graphics/particle_system.lua
index 8de3258..065a845 100644
--- a/source/libs/asura-lib-framework/scripts/graphics/particle_system.lua
+++ b/source/libs/asura-lib-framework/scripts/graphics/particle_system.lua
@@ -4,8 +4,8 @@ AsuraEngine.ParticleSystem = AsuraEngine.Component.Extend("ParticleSystem")
local ParticleSystem = AsuraEngine.ParticleSystem
-function ParticleSystem.Ctor(self, gameobject, def)
- self.base(gameobject)
+function ParticleSystem.Ctor(self, entity, def)
+ self.base(entity)
self.spriteRenderer = AsuraEngine.SpriteRenderer.New()
end
diff --git a/source/libs/asura-lib-framework/scripts/scene.lua b/source/libs/asura-lib-framework/scripts/scene.lua
index 3036ce1..11ac86c 100644
--- a/source/libs/asura-lib-framework/scripts/scene.lua
+++ b/source/libs/asura-lib-framework/scripts/scene.lua
@@ -6,7 +6,7 @@ AsuraEngine.Scene = AsuraEngine.Asset.Extend("Scene")
local Scene = AsuraEngine.Scene
function Scene.Ctor(self)
- self.rootGameObjects = {} --当前场景的所有root gameobject
+ self.rootGameObjects = {} --当前场景的所有root entity
self.super.Ctor(self)
end
diff --git a/source/libs/asura-lib-utils/filesystem/resource_manager.h b/source/libs/asura-lib-utils/filesystem/resource_manager.h
deleted file mode 100644
index 36d46cf..0000000
--- a/source/libs/asura-lib-utils/filesystem/resource_manager.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __ASURA_ENGINE_RESOURCE_MANAGER_H__
-#define __ASURA_ENGINE_RESOURCE_MANAGER_H__
-
-#include <string>
-
-#include "../scripting/portable.hpp"
-#include "data_buffer.h"
-
-namespace AsuraEngine
-{
- namespace Filesystem
- {
-
- ///
- /// Դء洢ԴָĿ¼ȡ
- ///
- class ResourceManager ASURA_FINAL
- {
- public:
-
- ResourceManager();
- ~ResourceManager();
-
- ///
- /// װظĿ¼
- ///
- void Mount(const std::string& root);
-
- ///
- /// ȡļһdata bufferעҪȷȷڴ棬ڵôʹunique_ptr
- ///
- DataBuffer* LoadFile(const std::string& path);
-
- ///
- /// data buffer
- ///
- void SaveFile(const std::string& path, const DataBuffer* buffer);
-
- //----------------------------------------------------------------------------------------------------------
-
- LUAX_DECL_SINGLETON(ResourceManager);
-
- };
-
- }
-}
-
-#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/io/binding/_compressor.cpp b/source/libs/asura-lib-utils/io/binding/_compressor.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/binding/_compressor.cpp
diff --git a/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp b/source/libs/asura-lib-utils/io/binding/_data_buffer.cpp
index 8e92eee..d9eca36 100644
--- a/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp
+++ b/source/libs/asura-lib-utils/io/binding/_data_buffer.cpp
@@ -4,17 +4,17 @@ using namespace Luax;
namespace AsuraEngine
{
- namespace Filesystem
+ namespace IO
{
LUAX_REGISTRY(DataBuffer)
{
LUAX_REGISTER_METHODS(state,
- { "New", _New },
- { "GetBuffer", _GetBuffer },
- { "GetSize", _GetSize },
- { "Load", _Load },
- { "Clear", _Clear }
+ { "New", _New },
+ { "GetBuffer", _GetData },
+ { "GetSize", _GetSize },
+ { "Load", _Load },
+ { "Clear", _Clear }
);
}
@@ -50,12 +50,12 @@ namespace AsuraEngine
}
// lsting, len = databuffer:GetBuffer()
- LUAX_IMPL_METHOD(DataBuffer, _GetBuffer)
+ LUAX_IMPL_METHOD(DataBuffer, _GetData)
{
LUAX_SETUP(L, "U");
DataBuffer* self = state.GetUserdata<DataBuffer>(1);
- lua_pushlstring(L, self->GetBuffer(), self->GetSize());
+ lua_pushlstring(L, self->GetData(), self->GetSize());
return 2;
}
diff --git a/source/libs/asura-lib-utils/io/binding/_file.cpp b/source/libs/asura-lib-utils/io/binding/_file.cpp
new file mode 100644
index 0000000..4120258
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/binding/_file.cpp
@@ -0,0 +1,186 @@
+#include "../file.h"
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+ LUAX_REGISTRY(File)
+ {
+ }
+
+ LUAX_POSTPROCESS(File)
+ {
+ LUAX_REGISTER_ENUM(state, "EFileMode",
+ { "CLOSED", FILE_MODE_CLOSED },
+ { "READ", FILE_MODE_READ },
+ { "WRITE", FILE_MODE_WRITE },
+ { "APPEND", FILE_MODE_APPEND }
+ );
+
+ LUAX_REGISTER_ENUM(state, "EBufferMode",
+ { "NONE", BUFFER_MODE_NONE},
+ { "LINE", BUFFER_MODE_LINE},
+ { "FULL", BUFFER_MODE_FULL}
+ );
+ }
+
+ // file = File.New(name)
+ LUAX_IMPL_METHOD(File, _New)
+ {
+ LUAX_STATE(L);
+
+ cc8* name = state.CheckParam<cc8*>(1);
+ File* file = new File(name);
+ file->PushLuaxUserdata(state);
+ return 1;
+ }
+
+ // successsed = file:Open(mode)
+ LUAX_IMPL_METHOD(File, _Open)
+ {
+ LUAX_PREPARE(L, File);
+
+ File::FileMode mode = (File::FileMode)state.CheckParam<int>(2);
+ state.Push(self->Open(mode));
+ return 1;
+ }
+
+ // successed = file:Close()
+ LUAX_IMPL_METHOD(File, _Close)
+ {
+ LUAX_PREPARE(L, File);
+
+ state.Push(self->Close());
+ return 1;
+ }
+
+ // opened = file:IsOpen()
+ LUAX_IMPL_METHOD(File, _IsOpen)
+ {
+ LUAX_PREPARE(L, File);
+
+ state.Push(self->IsOpen());
+ return 1;
+ }
+
+ // mode = file:GetMode()
+ LUAX_IMPL_METHOD(File, _GetMode)
+ {
+ LUAX_PREPARE(L, File);
+
+ File::FileMode mode = self->GetMode();
+ state.Push((int)mode);
+ return 1;
+ }
+
+ // size = file:GetSize()
+ LUAX_IMPL_METHOD(File, _GetSize)
+ {
+ LUAX_PREPARE(L, File);
+
+ state.Push(self->GetSize());
+ return 1;
+ }
+
+ // size = file:Read(dst, len)
+ // returns:
+ // size ʵʶĴС
+ // params:
+ // self ļ
+ // dst Ŀ껺
+ // len ĴС
+ LUAX_IMPL_METHOD(File, _Read)
+ {
+ LUAX_PREPARE(L, File);
+
+ DataBuffer* db = state.CheckUserdata<DataBuffer>(2);
+ if (!db) return state.ErrorType(2, "DataBuffer");
+ int len = state.CheckParam<int>(3);
+ int size = self->Read(db, len);
+ state.Push(size);
+ return 1;
+ }
+
+ // isEOF = file:IsEOF()
+ LUAX_IMPL_METHOD(File, _IsEOF)
+ {
+ LUAX_PREPARE(L, File);
+
+ state.Push(self->IsEOF());
+ return 1;
+ }
+
+ // isWrite = file:Write(data buffer)
+ LUAX_IMPL_METHOD(File, _Write)
+ {
+ LUAX_PREPARE(L, File);
+
+ DataBuffer* db = state.CheckUserdata<DataBuffer>(2);
+ if (!db) return state.ErrorType(2, "DataBuffer");
+ state.Push(self->Write(db));
+ return 1;
+ }
+
+ // isFlushed = file:Flush()
+ LUAX_IMPL_METHOD(File, _Flush)
+ {
+ LUAX_PREPARE(L, File);
+
+ state.Push(self->Flush());
+ return 1;
+ }
+
+ // pos = file:Tell()
+ LUAX_IMPL_METHOD(File, _Tell)
+ {
+ LUAX_PREPARE(L, File);
+
+ state.Push(self->Tell());
+ return 1;
+ }
+
+ // isSeek = file:Seek(pos)
+ LUAX_IMPL_METHOD(File, _Seek)
+ {
+ LUAX_PREPARE(L, File);
+
+ int pos = state.CheckParam<int>(2);
+ state.Push(self->Seek(pos));
+ return 1;
+ }
+
+ // isSetted = file:SetBuffer(mode, size)
+ LUAX_IMPL_METHOD(File, _SetBuffer)
+ {
+ LUAX_PREPARE(L, File);
+
+ BufferMode mode = (BufferMode)state.CheckParam<int>(2);
+ int size = state.CheckParam<int>(3);
+ state.Push(self->SetBuffer(mode, size));
+ return 1;
+ }
+
+ // size, mode = file:GetBuffer()
+ LUAX_IMPL_METHOD(File, _GetBuffer)
+ {
+ LUAX_PREPARE(L, File);
+
+ size_t size = 0;
+ BufferMode mode = self->GetBuffer(ASURA_OUT size);
+ state.Push((int)size);
+ state.Push((int)mode);
+ return 2;
+ }
+
+ // name = file:GetFileName()
+ LUAX_IMPL_METHOD(File, _GetFileName)
+ {
+ LUAX_PREPARE(L, File);
+
+ state.Push(self->GetFileName());
+ return 1;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/io/binding/_file_data.cpp b/source/libs/asura-lib-utils/io/binding/_file_data.cpp
new file mode 100644
index 0000000..56f65f7
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/binding/_file_data.cpp
@@ -0,0 +1,64 @@
+#include "../file_data.h"
+
+using namespace std;
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+#define PREPARE(L) \
+ LUAX_STATE(L); \
+ FileData* self = state.GetUserdata<FileData>(1);
+
+ LUAX_REGISTRY(FileData)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "GetFileName", _GetFileName },
+ { "GetExtension", _GetExtension },
+ { "GetName", _GetName },
+ { "GetDataBuffer", _GetDataBuffer }
+ );
+ }
+
+ LUAX_POSTPROCESS(FileData)
+ {
+ }
+
+ // filename = filedata:GetFileName()
+ LUAX_IMPL_METHOD(FileData, _GetFileName)
+ {
+ PREPARE(L);
+ string filename = self->GetFileName();
+ state.Push(filename);
+ return 1;
+ }
+
+ // extension = filedata:GetExtension()
+ LUAX_IMPL_METHOD(FileData, _GetExtension)
+ {
+ PREPARE(L);
+ string extension = self->GetExtension();
+ state.Push(extension);
+ return 1;
+ }
+
+ // name = filedata:GetName()
+ LUAX_IMPL_METHOD(FileData, _GetName)
+ {
+ PREPARE(L);
+ string extension = self->GetName();
+ state.Push(extension);
+ return 1;
+ }
+
+ // databuffer = filedata:GetDataBuffer()
+ LUAX_IMPL_METHOD(FileData, _GetDataBuffer)
+ {
+ PREPARE(L);
+ self->PushLuaxMemberRef(state, self->mDataRef);
+ return 1;
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-utils/io/binding/_file_system.cpp b/source/libs/asura-lib-utils/io/binding/_file_system.cpp
new file mode 100644
index 0000000..8cb60bc
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/binding/_file_system.cpp
@@ -0,0 +1,267 @@
+#include "../file_system.h"
+
+using namespace Luax;
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+#define PREPARE(l) \
+ LUAX_STATE(l); \
+ Filesystem* fs = Filesystem::Get();
+
+ LUAX_REGISTRY(Filesystem)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "Init", _Init },
+ { "Mount", _Mount },
+ { "Unmount", _Unmount },
+ { "GetMountPoint", _GetMountPoint },
+ { "SetWriteDirectory", _SetWriteDirectory },
+ { "GetWriteDirectory", _GetWriteDirectory },
+ { "CreateFile", _CreateFile },
+ { "CreateDirectory", _CreateDirectory },
+ { "Write", _Write },
+ { "Append", _Append },
+ { "Remove", _Remove },
+ { "Read", _Read },
+ { "GetFileInfo", _GetFileInfo },
+ { "GetDirectoryItems", _GetDirectoryItems }
+ );
+ }
+
+ LUAX_POSTPROCESS(Filesystem)
+ {
+ LUAX_REGISTER_ENUM(state, "EFileType",
+ { "FILE", FILE_TYPE_FILE },
+ { "DIRECTORY", FILE_TYPE_DIRECTORY },
+ { "SYMLINK", FILE_TYPE_SYMLINK },
+ { "OTHER", FILE_TYPE_OTHER }
+ );
+ }
+
+ // Filesystem.Init(arg0)
+ LUAX_IMPL_METHOD(Filesystem, _Init)
+ {
+ PREPARE(L);
+
+ const char* arg0 = state.CheckParam<const char*>(1);
+ fs->Init(arg0);
+ return 0;
+ }
+
+ // successed = Filesystem.Mount(path, mountpoint, prepend)
+ // successed = Filesystem.Mount(data buffer, archievename, mountpoint, prepend)
+ LUAX_IMPL_METHOD(Filesystem, _Mount)
+ {
+ PREPARE(L);
+ bool mounted = false;
+
+ if (state.IsType(1, LUA_TSTRING))
+ {
+ cc8* path = state.GetValue<cc8*>(1, "");
+ cc8* moutpoint = state.GetValue<cc8*>(2, "/");
+ bool prepend = state.GetValue<bool>(3, false);
+ mounted = fs->Mount(path, moutpoint, prepend);
+ }
+ else if (state.IsType(1, LUA_TUSERDATA))
+ {
+ DataBuffer* db = state.CheckUserdata<DataBuffer>(1);
+ if (!db)
+ return state.ErrorType(1, "Data Buffer");
+ cc8* arcname = state.GetValue<cc8*>(2, "");
+ cc8* mountpoint = state.GetValue<cc8*>(3, "/");
+ bool prepend = state.GetValue<bool>(4, false);
+ mounted = fs->Mount(db, arcname, mountpoint, prepend);
+ // retain
+ fs->LuaxRetain<DataBuffer>(state, db);
+ }
+ state.Push(mounted);
+ return 1;
+ }
+
+ // successed = Filesystem.Unmount(path)
+ // successed = Filesystem.Unmount(data buffer)
+ LUAX_IMPL_METHOD(Filesystem, _Unmount)
+ {
+ PREPARE(L);
+ bool unmounted = false;
+
+ if (state.IsType(1, LUA_TSTRING))
+ {
+ cc8* path = state.GetValue<cc8*>(1, "");
+ unmounted = fs->Unmount(path);
+ }
+ else if (state.IsType(1, LUA_TUSERDATA))
+ {
+ DataBuffer* db = state.CheckUserdata<DataBuffer>(1);
+ if (!db)
+ return state.ErrorType(1, "Data Buffer");
+ unmounted = fs->Unmount(db);
+ if (unmounted)
+ fs->LuaxRelease<DataBuffer>(state, db);
+ }
+ state.Push(unmounted);
+ return 1;
+ }
+
+ // moutpoint = Filesystem.GetMountPoint(path)
+ LUAX_IMPL_METHOD(Filesystem, _GetMountPoint)
+ {
+ PREPARE(L);
+
+ cc8* path = state.CheckParam<cc8*>(1);
+ std::string mp;
+ if (fs->GetMountPoint(path, ASURA_OUT mp))
+ state.Push(mp);
+ else
+ state.PushNil();
+
+ return 1;
+ }
+
+ // Filesystem.SetWriteDirectory(dir)
+ LUAX_IMPL_METHOD(Filesystem, _SetWriteDirectory)
+ {
+ PREPARE(L);
+
+ cc8* dir = state.CheckParam<cc8*>(1);
+ fs->SetWriteDirectory(dir);
+ return 0;
+ }
+
+ // dir = Filesystem.GetWriteDirectory()
+ LUAX_IMPL_METHOD(Filesystem, _GetWriteDirectory)
+ {
+ PREPARE(L);
+
+ std::string dir = fs->GetWriteDirectory();
+ state.Push(dir);
+ return 1;
+ }
+
+ // file = Filesystem.CreateFile(name)
+ LUAX_IMPL_METHOD(Filesystem, _CreateFile)
+ {
+ PREPARE(L);
+
+ cc8* name = state.CheckParam<cc8*>(1);
+ File* file = fs->NewFile(name);
+ if (file)
+ file->PushLuaxUserdata(state);
+ else
+ state.PushNil();
+ return 1;
+ }
+
+ // successed = Filesystem.CreateDirectory(name)
+ LUAX_IMPL_METHOD(Filesystem, _CreateDirectory)
+ {
+ PREPARE(L);
+
+ cc8* path = state.CheckParam<cc8*>(1);
+ state.Push(fs->NewDirectory(path));
+ return 1;
+ }
+
+ // successed = Filesystem.Write(path, data buffer)
+ LUAX_IMPL_METHOD(Filesystem, _Write)
+ {
+ PREPARE(L);
+
+ cc8* path = state.CheckParam<cc8*>(1);
+ DataBuffer* db = state.CheckUserdata<DataBuffer>(2);
+ state.Push(fs->Write(path, db));
+ return 1;
+ }
+
+ // successed = Filesystem.Append(path, data buffer)
+ LUAX_IMPL_METHOD(Filesystem, _Write)
+ {
+ PREPARE(L);
+
+ cc8* path = state.CheckParam<cc8*>(1);
+ DataBuffer* db = state.CheckUserdata<DataBuffer>(2);
+ state.Push(fs->Append(path, db));
+ return 1;
+ }
+
+ // successed = Filesystem.Remove(path)
+ LUAX_IMPL_METHOD(Filesystem, _Remove)
+ {
+ PREPARE(L);
+
+ cc8* path = state.CheckParam<cc8*>(1);
+ state.Push(fs->Remove(path));
+ return 1;
+ }
+
+ // filedata = Filesystem.Read(path)
+ LUAX_IMPL_METHOD(Filesystem, _Read)
+ {
+ PREPARE(L);
+
+ cc8* path = state.CheckParam<cc8*>(1);
+ FileData* fd = fs->Read(path);
+ if (fd)
+ {
+ fd->mData->PushLuaxUserdata(state);
+ fd->SetLuaxMemberRef(state, fd->mDataRef, -1); // fd->mDataRef = data buffer
+ state.Pop(1); // data buffer
+ fd->PushLuaxUserdata(state);
+ }
+ else
+ {
+ state.PushNil();
+ }
+ return 1;
+ }
+
+ // fileinfo = Filesystem.GetFileInfo(path)
+ // fileinfoĸʽ:
+ // {size = , modtime = , type =}
+ LUAX_IMPL_METHOD(Filesystem, _GetFileInfo)
+ {
+ PREPARE(L);
+
+ cc8* path = state.CheckParam<cc8*>(1);
+ FileInfo info;
+ if (fs->GetFileInfo(path, &info))
+ {
+ lua_newtable(L); // info table
+ state.SetField(-1, "size", info.size);
+ state.SetField(-1, "modetime", info.modtime);
+ state.SetField(-1, "type", info.type);
+ }
+ else
+ {
+ state.PushNil();
+ }
+ return 1;
+ }
+
+ // items = Filesystem.GetDirectoryItems(path)
+ LUAX_IMPL_METHOD(Filesystem, _GetDirectoryItems)
+ {
+ PREPARE(L);
+
+ cc8* path = state.CheckParam<cc8*>(1);
+ std::vector<std::string> items;
+ if(fs->GetDirectoryItems(path, ASURA_OUT items))
+ {
+ lua_newtable(L); // item list
+ for (int i = 0; i < items.size(); ++i)
+ {
+ state.SetFieldByIndex(-1, i + 1, items[i]);
+ }
+ }
+ else
+ {
+ state.PushNil();
+ }
+ return 1;
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-utils/io/compressor.cpp b/source/libs/asura-lib-utils/io/compressor.cpp
new file mode 100644
index 0000000..095eff4
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/compressor.cpp
@@ -0,0 +1,11 @@
+#include "compressor.h"
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+
+
+ }
+} \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/io/compressor.h b/source/libs/asura-lib-utils/io/compressor.h
new file mode 100644
index 0000000..30a074c
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/compressor.h
@@ -0,0 +1,30 @@
+#ifndef __ASURA_COMPRESSOR_H__
+#define __ASURA_COMPRESSOR_H__
+
+#include "../scripting/portable.hpp"
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+ class Compressor ASURA_FINAL
+ : public AEScripting::Portable<Compressor>
+ {
+ public:
+
+ LUAX_DECL_SINGLETON(Compressor);
+
+ private:
+
+ LUAX_DECL_METHOD(_Compress);
+ LUAX_DECL_METHOD(_Decompress);
+
+
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/data_buffer.cpp b/source/libs/asura-lib-utils/io/data_buffer.cpp
index 32a123f..98675e9 100644
--- a/source/libs/asura-lib-utils/filesystem/data_buffer.cpp
+++ b/source/libs/asura-lib-utils/io/data_buffer.cpp
@@ -4,7 +4,7 @@
namespace AsuraEngine
{
- namespace Filesystem
+ namespace IO
{
DataBuffer::DataBuffer(DataBuffer& src)
@@ -34,7 +34,7 @@ namespace AsuraEngine
void DataBuffer::Load(DataBuffer& db)
{
- Load(db.GetBuffer(), db.GetSize());
+ Load(db.GetData(), db.GetSize());
}
void DataBuffer::Load(const void* data, std::size_t size)
@@ -47,7 +47,17 @@ namespace AsuraEngine
memcpy(mBytes, data, size);
}
- byte* DataBuffer::GetBuffer()
+ void DataBuffer::Move(void* bytes, std::size_t size)
+ {
+ if (!mBytes)
+ {
+ delete[] mBytes;
+ }
+ mBytes = (byte*)bytes;
+ mSize = size;
+ }
+
+ byte* DataBuffer::GetData()
{
return mBytes;
}
diff --git a/source/libs/asura-lib-utils/filesystem/data_buffer.h b/source/libs/asura-lib-utils/io/data_buffer.h
index 5c80efb..c7383fa 100644
--- a/source/libs/asura-lib-utils/filesystem/data_buffer.h
+++ b/source/libs/asura-lib-utils/io/data_buffer.h
@@ -7,42 +7,39 @@
namespace AsuraEngine
{
- namespace Filesystem
+ namespace IO
{
///
/// ڴݵķװеʹData bufferװֱʹconst void*ͨresource managerȡ
///
class DataBuffer ASURA_FINAL
- : public Scripting::Portable<DataBuffer>
+ : public AEScripting::Portable<DataBuffer>
{
public:
+ LUAX_DECL_FACTORY(DataBuffer);
+
DataBuffer(DataBuffer& src);
DataBuffer(std::size_t size);
DataBuffer(const void* bytes, std::size_t size);
~DataBuffer();
- byte* GetBuffer();
+ byte* GetData();
size_t GetSize();
void Load(DataBuffer& db);
void Load(const void* bytes, std::size_t size);
+ void Move(void* bytes, std::size_t size);
void Clear();
private:
byte* mBytes;
size_t mSize;
-
- //------------------------------------------------------------------------------------------------------------
-
- public:
-
- LUAX_DECL_FACTORY(DataBuffer);
LUAX_DECL_METHOD(_New);
- LUAX_DECL_METHOD(_GetBuffer);
+ LUAX_DECL_METHOD(_GetData);
LUAX_DECL_METHOD(_GetSize);
LUAX_DECL_METHOD(_Load);
LUAX_DECL_METHOD(_Clear);
@@ -52,4 +49,6 @@ namespace AsuraEngine
}
}
+namespace AEIO = AsuraEngine::IO;
+
#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/decoded_data.cpp b/source/libs/asura-lib-utils/io/decoded_data.cpp
index 125c652..b208455 100644
--- a/source/libs/asura-lib-utils/filesystem/decoded_data.cpp
+++ b/source/libs/asura-lib-utils/io/decoded_data.cpp
@@ -3,7 +3,7 @@
namespace AsuraEngine
{
- namespace Filesystem
+ namespace IO
{
DecodedData::DecodedData(const DataBuffer* databuffer)
diff --git a/source/libs/asura-lib-utils/filesystem/decoded_data.h b/source/libs/asura-lib-utils/io/decoded_data.h
index 49b5815..e201e91 100644
--- a/source/libs/asura-lib-utils/filesystem/decoded_data.h
+++ b/source/libs/asura-lib-utils/io/decoded_data.h
@@ -9,7 +9,7 @@
namespace AsuraEngine
{
- namespace Filesystem
+ namespace IO
{
///
diff --git a/source/libs/asura-lib-utils/io/file.cpp b/source/libs/asura-lib-utils/io/file.cpp
new file mode 100644
index 0000000..092a90d
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/file.cpp
@@ -0,0 +1,286 @@
+#include <physfs/physfs.h>
+
+#include <asura-lib-utils/exceptions/exception.h>
+
+#include "file.h"
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+ File::File(const std::string& filename)
+ : mFileName(filename)
+ , mFileHandle(nullptr)
+ , mMode(FILE_MODE_CLOSED)
+ , mBufferMode(BUFFER_MODE_NONE)
+ , mBufferSize(0)
+ {
+ size_t dot = filename.rfind('.');
+ if (dot != std::string::npos)
+ {
+ mExtension = filename.substr(dot + 1);
+ mName = filename.substr(0, dot);
+ }
+ else
+ mName = filename;
+ }
+
+ File::~File()
+ {
+ if (mMode != FILE_MODE_CLOSED)
+ Close();
+ }
+
+ bool File::Open(FileMode mode)
+ {
+ if (!PHYSFS_isInit())
+ throw Exception("Physfs is NOT initialized.");
+
+ if (mode == FILE_MODE_CLOSED)
+ return;
+
+ if (mode == FILE_MODE_READ && !PHYSFS_exists(mFileName.c_str()))
+ throw Exception("Could NOT open file %s. Does not exist.", mFileName.c_str());
+
+ if (mode == FILE_MODE_APPEND || mode == FILE_MODE_WRITE)
+ {
+ if (!PHYSFS_getWriteDir())
+ {
+ throw Exception("Could NOT set write directory.");
+ }
+ }
+
+ // Ѿ֮ǰ򿪹Ͳٴµhandle
+ if (mFileHandle != nullptr)
+ return;
+
+ PHYSFS_getLastErrorCode();
+
+ PHYSFS_File* handle = nullptr;
+
+ switch (mode)
+ {
+ case FILE_MODE_READ:
+ handle = PHYSFS_openRead(mFileName.c_str());
+ break;
+ case FILE_MODE_APPEND:
+ handle = PHYSFS_openAppend(mFileName.c_str());
+ break;
+ case FILE_MODE_WRITE:
+ handle = PHYSFS_openWrite(mFileName.c_str());
+ break;
+ }
+
+ if (handle == nullptr)
+ {
+ const char *err = PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode());
+ if (err == nullptr)
+ err = "unknown error";
+ throw Exception("Could not open file %s (%s)", mFileName.c_str(), err);
+ }
+
+ mFileHandle = handle;
+ mMode = mode;
+
+ if (mFileHandle != nullptr && !SetBuffer(mBufferMode,mBufferSize))
+ {
+ mBufferMode = BUFFER_MODE_NONE;
+ mBufferSize = 0;
+ }
+
+ return mFileHandle != nullptr;
+ }
+
+ bool File::Close()
+ {
+ if (mFileHandle == nullptr || !PHYSFS_close(mFileHandle))
+ return false;
+ mMode = FILE_MODE_CLOSED;
+ mFileHandle = nullptr;
+ return true;
+ }
+
+ bool File::IsOpen()
+ {
+ return mMode != FILE_MODE_CLOSED && mFileHandle != nullptr;
+ }
+
+ size_t File::GetSize()
+ {
+ if (mFileHandle == nullptr)
+ {
+ Open(FILE_MODE_READ);
+ size_t size = PHYSFS_fileLength(mFileHandle);
+ Close();
+ return size;
+ }
+ return PHYSFS_fileLength(mFileHandle);
+ }
+
+ size_t File::Read(ASURA_OUT DataBuffer* dst, size_t length)
+ {
+ ASSERT(dst);
+
+ if (dst->GetSize() < length)
+ throw Exception("Data buffer is too small compares to read length.");
+
+ if (!mFileHandle || mMode != FILE_MODE_READ)
+ throw Exception("File \"%s\" is not opened for reading", mFileName);
+
+ size_t max = PHYSFS_fileLength(mFileHandle);
+ length = (length > max) ? max : length;
+
+ if (length < 0)
+ throw Exception("Invalid read size.");
+
+ return PHYSFS_readBytes(mFileHandle, dst->GetData(), length);
+ }
+
+ size_t File::ReadAll(ASURA_OUT DataBuffer* dst)
+ {
+ ASSERT(dst);
+
+ if (!mFileHandle || mMode != FILE_MODE_READ)
+ throw Exception("File \"%s\" is not opened for reading", mFileName);
+
+ size_t length = PHYSFS_fileLength(mFileHandle);
+
+ if (dst->GetSize() < length)
+ throw Exception("Data buffer is too small compares to file length.");
+
+ return PHYSFS_readBytes(mFileHandle, dst->GetData(), length);
+ }
+
+#ifdef ASURA_WINDOWS
+ inline bool test_eof(File *that, PHYSFS_File *)
+ {
+ int64 pos = that->Tell();
+ int64 size = that->GetSize();
+ return pos == -1 || size == -1 || pos >= size;
+ }
+#else
+ inline bool test_eof(File *, PHYSFS_File *file)
+ {
+ return PHYSFS_eof(file);
+ }
+#endif
+
+ bool File::IsEOF()
+ {
+ return mFileHandle == nullptr || test_eof(this, mFileHandle);
+ }
+
+ size_t File::Tell()
+ {
+ if (!mFileHandle)
+ return - 1;
+
+ return PHYSFS_tell(mFileHandle);
+ }
+
+ bool File::Seek(size_t pos)
+ {
+ return mFileHandle != nullptr && PHYSFS_seek(mFileHandle, pos) != 0;
+ }
+
+ bool File::Write(ASURA_REF DataBuffer* src)
+ {
+ if (!mFileHandle || (mMode != FILE_MODE_APPEND && mMode != FILE_MODE_WRITE))
+ throw Exception("File is not opened for writing.");
+
+ byte* data = src->GetData();
+ int size = src->GetSize();
+
+ if (size < 0)
+ throw Exception("Invalid write size.");
+
+ size_t written = PHYSFS_writeBytes(mFileHandle, data, size);
+
+ if (written != src->GetSize())
+ return false;
+
+ // л
+ if (mBufferSize == BUFFER_MODE_LINE && mBufferSize > size)
+ {
+ if (memchr(data, '\n', size) != nullptr)
+ Flush();
+ }
+
+ return true;
+ }
+
+ bool File::Flush()
+ {
+ if (!mFileHandle || (mMode != FILE_MODE_WRITE && mMode != FILE_MODE_APPEND))
+ throw Exception("File is not opened for writing.");
+
+ return PHYSFS_flush(mFileHandle) != 0;
+ }
+
+ bool File::SetBuffer(BufferMode mode, size_t size)
+ {
+ if (size < 0)
+ return false;
+
+ // If the file isn't open, we'll make sure the buffer values are set in
+ // File::open.
+ if (!IsOpen())
+ {
+ mBufferMode = mode;
+ mBufferSize = size;
+ return true;
+ }
+
+ int ret = 1;
+
+ switch (mode)
+ {
+ case BUFFER_MODE_NONE:
+ default:
+ ret = PHYSFS_setBuffer(mFileHandle, 0);
+ size = 0;
+ break;
+ case BUFFER_MODE_LINE:
+ case BUFFER_MODE_FULL:
+ ret = PHYSFS_setBuffer(mFileHandle, size);
+ break;
+ }
+
+ if (ret == 0)
+ return false;
+
+ mBufferMode = mode;
+ mBufferSize = size;
+
+ return true;
+ }
+
+ File::BufferMode File::GetBuffer(ASURA_OUT size_t& size)
+ {
+ size = mBufferSize;
+ return mBufferMode;
+ }
+
+ const std::string& File::GetFileName()
+ {
+ return mFileName;
+ }
+
+ const std::string& File::GetName()
+ {
+ return mName;
+ }
+
+ const std::string& File::GetExtension()
+ {
+ return mExtension;
+ }
+
+ File::FileMode File::GetMode()
+ {
+ return mMode;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/io/file.h b/source/libs/asura-lib-utils/io/file.h
new file mode 100644
index 0000000..e8f676e
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/file.h
@@ -0,0 +1,132 @@
+#ifndef __ASURA_ENGINE_FILE_H__
+#define __ASURA_ENGINE_FILE_H__
+
+#include "physfs/physfs.h"
+
+#include "../scripting/portable.hpp"
+
+#include "file_data.h"
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+ ///
+ /// ʽļָд㡢Сʹȡʱʹñ࣬ʹFilesystem.read()ֱӶȡļȫ
+ /// ݣһFileData
+ ///
+ class File ASURA_FINAL
+ : public AEScripting::Portable<File>
+ {
+ public:
+
+ LUAX_DECL_FACTORY(File);
+
+ ///
+ /// ļдģʽ
+ ///
+ enum FileMode
+ {
+ FILE_MODE_CLOSED,
+ FILE_MODE_READ,
+ FILE_MODE_WRITE,
+ FILE_MODE_APPEND,
+ };
+
+ ///
+ /// ļдʱΪ
+ ///
+ enum BufferMode
+ {
+ BUFFER_MODE_NONE, ///< ʹû壬дļ
+ BUFFER_MODE_LINE, ///< л壬зߴﵽСʱдļ
+ BUFFER_MODE_FULL, ///< ȫ壬ʱдļ
+ };
+
+ File(const std::string& filename);
+ ~File();
+
+ bool Open(FileMode mode);
+ bool Close();
+ bool IsOpen();
+ FileMode GetMode();
+ size_t GetSize();
+
+ ///
+ /// ȡdata bufferض
+ ///
+ size_t Read(ASURA_OUT DataBuffer* dst, size_t length);
+ size_t ReadAll(ASURA_OUT DataBuffer* dst);
+
+ ///
+ /// Ƿļβ
+ ///
+ bool IsEOF();
+
+ ///
+ /// data bufferед룬Ƿɹ
+ ///
+ bool Write(ASURA_REF DataBuffer* src);
+
+ ///
+ /// ˻壬ǿջдļ
+ ///
+ bool Flush();
+
+ ///
+ /// صǰдλ
+ ///
+ size_t Tell();
+
+ ///
+ /// Ӧλ
+ ///
+ bool Seek(size_t pos);
+
+ ///
+ /// ûСģʽ
+ ///
+ bool SetBuffer(BufferMode mode, size_t size);
+
+ ///
+ /// ȡСģʽ
+ ///
+ BufferMode GetBuffer(ASURA_OUT size_t& size);
+
+ const std::string& GetFileName();
+ const std::string& GetName();
+ const std::string& GetExtension();
+
+ private:
+
+ PHYSFS_File* mFileHandle; ///< physfs ļ
+ std::string mFileName; ///< ļ
+ std::string mExtension; ///< չ
+ std::string mName; ///< չļ
+ FileMode mMode; ///< ļģʽ
+ BufferMode mBufferMode; ///< д뻺ģʽ
+ size_t mBufferSize; ///< д뻺С
+
+ LUAX_DECL_METHOD(_New);
+ LUAX_DECL_METHOD(_Open);
+ LUAX_DECL_METHOD(_Close);
+ LUAX_DECL_METHOD(_IsOpen);
+ LUAX_DECL_METHOD(_GetMode);
+ LUAX_DECL_METHOD(_GetSize);
+ LUAX_DECL_METHOD(_Read);
+ LUAX_DECL_METHOD(_IsEOF);
+ LUAX_DECL_METHOD(_Write);
+ LUAX_DECL_METHOD(_Flush);
+ LUAX_DECL_METHOD(_Tell);
+ LUAX_DECL_METHOD(_Seek);
+ LUAX_DECL_METHOD(_SetBuffer);
+ LUAX_DECL_METHOD(_GetBuffer);
+ LUAX_DECL_METHOD(_GetFileName);
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/io/file_data.cpp b/source/libs/asura-lib-utils/io/file_data.cpp
new file mode 100644
index 0000000..47d9095
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/file_data.cpp
@@ -0,0 +1,57 @@
+#include "file_data.h"
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+ FileData::FileData(const std::string& filename)
+ : mData(nullptr)
+ , mFileName(filename)
+ {
+ size_t dot = filename.rfind('.');
+ if (dot != std::string::npos)
+ {
+ mExtension = filename.substr(dot + 1);
+ mName = filename.substr(0, dot);
+ }
+ else
+ mName = filename;
+ }
+
+ FileData::~FileData()
+ {
+ }
+
+ void FileData::BindData(DataBuffer* buffer)
+ {
+ mData = buffer;
+ }
+
+ const std::string& FileData::GetFileName()
+ {
+ return mFileName;
+ }
+
+ const std::string& FileData::GetExtension()
+ {
+ return mExtension;
+ }
+
+ const std::string& FileData::GetName()
+ {
+ return mName;
+ }
+
+ void FileData::BindData(ASURA_MOVE DataBuffer* buffer)
+ {
+ mData = buffer;
+ }
+
+ DataBuffer* FileData::GetDataBuffer()
+ {
+ return mData;
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-utils/io/file_data.h b/source/libs/asura-lib-utils/io/file_data.h
new file mode 100644
index 0000000..e20f41b
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/file_data.h
@@ -0,0 +1,68 @@
+#ifndef __ASURA_ENGINE_FILE_DATA_H__
+#define __ASURA_ENGINE_FILE_DATA_H__
+
+#include <string>
+
+#include <asura-lib-utils/scripting/portable.hpp>
+
+#include "data_buffer.h"
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+ class Filesystem;
+
+ ///
+ /// filesystemֱӶȡļʱFileDataļݺϢFilesystem
+ ///
+ class FileData ASURA_FINAL
+ : public AEScripting::Portable<FileData>
+ {
+ public:
+
+ LUAX_DECL_FACTORY(FileData);
+
+ ///
+ /// ļݣͨDatabufferݺʹСڲӿڶData bufferΪҲdata buffer
+ ///
+ DataBuffer* GetDataBuffer();
+
+ const std::string& GetFileName();
+ const std::string& GetExtension();
+ const std::string& GetName();
+
+ private:
+
+ friend class Filesystem;
+
+ FileData(const std::string& name);
+ ~FileData();
+
+ ///
+ /// data buffer
+ ///
+ void BindData(ASURA_MOVE DataBuffer* buffer);
+
+ ///
+ /// Data bufferfiledataʱ٣luaüΪ0ʱluaGC١mDataʱһԱá
+ ///
+ ASURA_REF DataBuffer* mData;
+ Luax::LuaxMemberRef mDataRef;
+
+ std::string mFileName; ///< չļ
+ std::string mExtension; ///< չ
+ std::string mName; ///< ͺ׺ļ
+
+ LUAX_DECL_METHOD(_GetFileName);
+ LUAX_DECL_METHOD(_GetExtension);
+ LUAX_DECL_METHOD(_GetName);
+ LUAX_DECL_METHOD(_GetDataBuffer);
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/io/file_system.cpp b/source/libs/asura-lib-utils/io/file_system.cpp
new file mode 100644
index 0000000..20f3cb2
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/file_system.cpp
@@ -0,0 +1,198 @@
+#include <physfs/physfs.h>
+
+#include "../exceptions/exception.h"
+
+#include "file.h"
+#include "file_data.h"
+#include "file_system.h"
+
+using namespace std;
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+#ifdef ASURA_WINDOWS
+ #include <windows.h>
+ #include <direct.h>
+#else
+ #include <sys/param.h>
+ #include <unistd.h>
+#endif
+
+ Filesystem::~Filesystem()
+ {
+ if (mInited) //PHYSFS_isInit
+ PHYSFS_deinit();
+ }
+
+ void Filesystem::Init(const char* arg0)
+ {
+ if (!PHYSFS_init(arg0))
+ throw Exception("Failed to initialize filesystem: %s", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
+
+ mInited = true;
+ }
+
+ bool Filesystem::Mount(const std::string& locpath, const std::string& montpoint/* = "/"*/, bool prepend /*= false*/)
+ {
+ if (!mInited)
+ return false;
+
+ return PHYSFS_mount(locpath.c_str(), montpoint.c_str(), !prepend);
+ }
+
+ bool Filesystem::Mount(DataBuffer* db, const std::string& archivename, const std::string& mountpoint /*= "/"*/, bool prepend /*= false*/)
+ {
+ if (!mInited)
+ return false;
+ if (PHYSFS_mountMemory(db->GetData(), db->GetSize(), nullptr, archivename.c_str(), mountpoint.c_str(), !prepend))
+ {
+ mMountData[archivename] = db;
+ return true;
+ }
+ return false;
+ }
+
+ bool Filesystem::Unmount(const std::string& locpath)
+ {
+ if (!mInited)
+ return false;
+
+ // ǹ鵵ӳɾ
+ auto datait = mMountData.find(locpath);
+ if (datait != mMountData.end() && PHYSFS_unmount(locpath.c_str()) != 0)
+ {
+ mMountData.erase(datait);
+ return true;
+ }
+
+ return PHYSFS_unmount(locpath.c_str());
+ }
+
+ bool Filesystem::Unmount(DataBuffer* db)
+ {
+ for (const auto& dp : mMountData)
+ {
+ if (dp.second == db)
+ {
+ std::string archive = dp.first;
+ return Unmount(archive);
+ }
+ }
+ }
+
+ bool Filesystem::GetMountPoint(const std::string& locpath, ASURA_OUT std::string& mountpoint)
+ {
+ if (!mInited)
+ return false;
+ const char* point = PHYSFS_getMountPoint(locpath.c_str());
+ if (point != nullptr)
+ {
+ mountpoint = point;
+ return true;
+ }
+ return false;
+ }
+
+ void Filesystem::SetWriteDirectory(const std::string locpath)
+ {
+ if (!mInited)
+ return;
+ if (!PHYSFS_setWriteDir(locpath.c_str()))
+ throw Exception("Failed to set write directory %s", locpath.c_str());
+ }
+
+ std::string Filesystem::GetWriteDirectory()
+ {
+ return PHYSFS_getWriteDir();
+ }
+
+ File* Filesystem::NewFile(const std::string& name)
+ {
+ return new File(name);
+ }
+
+ bool Filesystem::NewDirectory(const std::string& path)
+ {
+ if (!mInited)
+ return false;
+ if (!PHYSFS_getWriteDir())
+ return false;
+ if (!PHYSFS_mkdir(path.c_str()))
+ return false;
+ return true;
+ }
+
+ bool Filesystem::Write(const std::string& name, ASURA_REF DataBuffer* buffer)
+ {
+ File file(name);
+ file.Open(File::FILE_MODE_WRITE);
+ if (!file.Write(buffer))
+ throw Exception("Data could not be written.");
+ }
+
+ bool Filesystem::Append(const std::string& name, ASURA_REF DataBuffer* buffer)
+ {
+ File file(name);
+ file.Open(File::FILE_MODE_APPEND);
+ if (!file.Write(buffer))
+ throw Exception("Data could not be append.");
+ }
+
+ FileData* Filesystem::Read(const std::string& name)
+ {
+ File file = File(name);
+ file.Open(File::FILE_MODE_READ);
+ int size = file.GetSize();
+ DataBuffer* db = new DataBuffer(size);
+ if (db)
+ {
+ file.ReadAll(db);
+ FileData* fd = new FileData(name);
+ fd->BindData(db);
+ return fd;
+ }
+ return nullptr;
+ }
+
+ bool Filesystem::Remove(const std::string& path)
+ {
+ if (!mInited)
+ return false;
+ if (PHYSFS_getWriteDir() == 0)
+ return false;
+
+ if (!PHYSFS_delete(path.c_str()))
+ return false;
+
+ return true;
+ }
+
+ bool Filesystem::GetFileInfo(const std::string& filepath, ASURA_OUT FileInfo* info)
+ {
+ if (!mInited)
+ return false;
+
+ PHYSFS_Stat stat = {};
+ if (!PHYSFS_stat(filepath.c_str(), &stat))
+ return false;
+
+ info->size = (int64)stat.filesize;
+ info->modtime = (int64)stat.modtime;
+
+ if (stat.filetype == PHYSFS_FILETYPE_REGULAR)
+ info->type = FILE_TYPE_FILE;
+ else if (stat.filetype == PHYSFS_FILETYPE_DIRECTORY)
+ info->type = FILE_TYPE_DIRECTORY;
+ else if (stat.filetype == PHYSFS_FILETYPE_SYMLINK)
+ info->type = FILE_TYPE_SYMLINK;
+ else
+ info->type = FILE_TYPE_OTHER;
+
+ return true;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/io/file_system.h b/source/libs/asura-lib-utils/io/file_system.h
new file mode 100644
index 0000000..1af0292
--- /dev/null
+++ b/source/libs/asura-lib-utils/io/file_system.h
@@ -0,0 +1,110 @@
+#ifndef __ASURA_ENGINE_FILESYSTEM_H__
+#define __ASURA_ENGINE_FILESYSTEM_H__
+
+#include <map>
+#include <string>
+
+#include "../scripting/portable.hpp"
+#include "../singleton.hpp"
+#include "../type.h"
+
+#include "file_data.h"
+#include "file.h"
+
+namespace AsuraEngine
+{
+ namespace IO
+ {
+
+ enum FileType
+ {
+ FILE_TYPE_FILE, ///< ļ
+ FILE_TYPE_DIRECTORY, ///< ļ
+ FILE_TYPE_SYMLINK, ///<
+ FILE_TYPE_OTHER, ///<
+ };
+
+ struct FileInfo
+ {
+ int64 size;
+ int64 modtime;
+ FileType type;
+ };
+
+ ///
+ /// Դء洢ԴָĿ¼ȡ۱༭ʱҪƷʵĻƣûIJϷĿ¼
+ /// £file systemµġFilesystemʱͱ༭õ࣬AssetDatabaseԴ࣬framework
+ /// ʵ֣߼дFilesystemʵ֣AssetDatabaseṩļݴӦԴķ
+ ///
+ class Filesystem ASURA_FINAL
+ : public Singleton<Filesystem>
+ , public AEScripting::Portable<Filesystem>
+ {
+ public:
+
+ LUAX_DECL_SINGLETON(Filesystem);
+
+ void Init(const char* arg0);
+
+ ///
+ /// ǰִļļ
+ ///
+ std::string GetWorkingDirectory();
+
+ bool Mount(const std::string& locpath, const std::string& montpoint = "/", bool prepend = false);
+ bool Mount(DataBuffer* db, const std::string& archivename, const std::string& mountpoint = "/", bool prepend = false);
+
+ bool Unmount(const std::string& locpath);
+ bool Unmount(DataBuffer* db);
+
+ bool GetMountPoint(const std::string& locpath, ASURA_OUT std::string& mountpoint);
+
+ void SetWriteDirectory(const std::string locpath);
+ std::string GetWriteDirectory();
+ File* NewFile(const std::string& name);
+ bool NewDirectory(const std::string& path);
+ bool Write(const std::string& path, ASURA_REF DataBuffer* buffer);
+ bool Append(const std::string& path, ASURA_REF DataBuffer* buffer);
+ bool Remove(const std::string& path);
+
+ FileData* Read(const std::string& path);
+ bool GetFileInfo(const std::string& path, ASURA_OUT FileInfo* info);
+
+ bool GetDirectoryItems(const std::string& path, ASURA_OUT std::vector<std::string>& items);
+
+ private:
+
+ typedef std::map<std::string, DataBuffer*> MountDataMap;
+
+ bool mInited; ///< Ƿʼɹ
+ std::string mCwd; ///< ǰִļĹĿ¼
+ MountDataMap mMountData; ///< ·ѹĵӳ
+
+ LUAX_DECL_METHOD(_Init);
+ LUAX_DECL_METHOD(_Mount);
+ LUAX_DECL_METHOD(_Unmount);
+ LUAX_DECL_METHOD(_GetMountPoint);
+
+ LUAX_DECL_METHOD(_SetWriteDirectory);
+ LUAX_DECL_METHOD(_GetWriteDirectory);
+ LUAX_DECL_METHOD(_CreateFile);
+ LUAX_DECL_METHOD(_CreateDirectory);
+
+ LUAX_DECL_METHOD(_Write);
+ LUAX_DECL_METHOD(_Append);
+ LUAX_DECL_METHOD(_Remove);
+
+ LUAX_DECL_METHOD(_Read);
+
+ LUAX_DECL_METHOD(_GetFileInfo);
+
+ LUAX_DECL_METHOD(_GetDirectoryItems);
+
+ };
+
+ }
+}
+
+namespace AEIO = AsuraEngine::IO;
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/filesystem/reloadable.h b/source/libs/asura-lib-utils/io/reloadable.h
index 7c4ea52..cf30296 100644
--- a/source/libs/asura-lib-utils/filesystem/reloadable.h
+++ b/source/libs/asura-lib-utils/io/reloadable.h
@@ -5,7 +5,7 @@
namespace AsuraEngine
{
- namespace Filesystem
+ namespace IO
{
///
diff --git a/source/libs/asura-lib-core/manager.hpp b/source/libs/asura-lib-utils/manager.hpp
index 7b4e272..7b4e272 100644
--- a/source/libs/asura-lib-core/manager.hpp
+++ b/source/libs/asura-lib-utils/manager.hpp
diff --git a/source/libs/asura-lib-utils/math/rect.hpp b/source/libs/asura-lib-utils/math/rect.hpp
index f635007..1751634 100644
--- a/source/libs/asura-lib-utils/math/rect.hpp
+++ b/source/libs/asura-lib-utils/math/rect.hpp
@@ -13,8 +13,20 @@ namespace AsuraEngine
Rect();
~Rect(T x, T y, T w, T h);
- template <typename U>
- explicit Rect(const Rect<U>& rect);
+ ///
+ /// x,yǷrectڡ
+ ///
+ bool Contain(T x, T y);
+
+ ///
+ /// Ƿཻཻľ
+ ///
+ bool Intersect(const Rect& src, Rect& intersection);
+
+ ///
+ /// Ƿཻཻľ
+ ///
+ static bool Intersect(const Rect<T>& src1, const Rect<T>& src2, Rect<T>& intersection);
T x, y, w, h;
};
@@ -25,8 +37,11 @@ namespace AsuraEngine
typedef Rect<int> Recti;
typedef Rect<unsigned int> Rectu;
typedef Rect<float> Rectf;
+ typedef Rect<long> Reftl;
}
}
+namespace AEMath = AsuraEngine::Math;
+
#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/scripting/portable.hpp b/source/libs/asura-lib-utils/scripting/portable.hpp
index 00ede90..097a9fe 100644
--- a/source/libs/asura-lib-utils/scripting/portable.hpp
+++ b/source/libs/asura-lib-utils/scripting/portable.hpp
@@ -21,7 +21,14 @@ namespace AsuraEngine
template<typename T>
using Portable = Luax::LuaxNativeClass<T>;
+ ///
+ /// ҪΪ࣬userdatamember ref̳д࣬ע̳С
+ ///
+ using NativeAccessor = Luax::ILuaxNativeAccessor;
+
}
}
+namespace AEScripting = AsuraEngine::Scripting;
+
#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-core/singleton.hpp b/source/libs/asura-lib-utils/singleton.hpp
index 756209a..756209a 100644
--- a/source/libs/asura-lib-core/singleton.hpp
+++ b/source/libs/asura-lib-utils/singleton.hpp
diff --git a/source/libs/asura-lib-utils/stringmap.cpp b/source/libs/asura-lib-utils/stringmap.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/stringmap.cpp
diff --git a/source/libs/asura-lib-core/stringmap.hpp b/source/libs/asura-lib-utils/stringmap.hpp
index ddba128..ddba128 100644
--- a/source/libs/asura-lib-core/stringmap.hpp
+++ b/source/libs/asura-lib-utils/stringmap.hpp
diff --git a/source/libs/asura-lib-utils/type.h b/source/libs/asura-lib-utils/type.h
index 72ed8cc..aa00108 100644
--- a/source/libs/asura-lib-utils/type.h
+++ b/source/libs/asura-lib-utils/type.h
@@ -25,6 +25,8 @@ namespace AsuraEngine
typedef std::size_t size_t;
+ typedef const char cc8;
+
//----------------------------------------------------------------------------------------------------------------
#ifndef ASSERT
@@ -51,6 +53,8 @@ namespace AsuraEngine
#define ASURA_ATTRIBUTE_USED
#define ASURA_ABSTRACT
#define ASURA_API ASURA_LIBRARY_EXPORT
+
+ #define ASURA_WINDOWS 1
#else
#define ASURA_FINAL final
#define ASURA_LIBRARY_EXPORT __attribute__((visibility("default")))
@@ -61,6 +65,16 @@ namespace AsuraEngine
#define ASURA_ABSTRACT
#define ASURA_API ASURA_LIBRARY_EXPORT
#endif
+
+ ///
+ /// ò
+ ///
+#define ASURA_OUT
+#define ASURA_REF
+ ///
+ /// ƶָȨ
+ ///
+#define ASURA_MOVE
//----------------------------------------------------------------------------------------------------------------
diff --git a/source/libs/asura-lib-utils/utils_config.h b/source/libs/asura-lib-utils/utils_config.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-utils/utils_config.h