diff options
Diffstat (limited to 'src/lua/modules')
56 files changed, 434 insertions, 212 deletions
diff --git a/src/lua/modules/ai/je_lua_ai.h b/src/lua/modules/ai/je_lua_ai.h new file mode 100644 index 0000000..036bc3f --- /dev/null +++ b/src/lua/modules/ai/je_lua_ai.h @@ -0,0 +1,7 @@ +#ifndef __JE_LUA_AI_H__ +#define __JE_LUA_AI_H__ + +#include "je_lua_behavior_tree.h" +#include "je_lua_state_machine.h" + +#endif
\ No newline at end of file diff --git a/src/lua/modules/ai/je_lua_behavior_tree.cpp b/src/lua/modules/ai/je_lua_behavior_tree.cpp index f79d79a..20e8e55 100644 --- a/src/lua/modules/ai/je_lua_behavior_tree.cpp +++ b/src/lua/modules/ai/je_lua_behavior_tree.cpp @@ -5,7 +5,7 @@ namespace JinEngine namespace Lua { - + const char* Jin_Lua_BehaviorTree = "Texture"; } }
\ No newline at end of file diff --git a/src/lua/modules/ai/je_lua_behavior_tree.h b/src/lua/modules/ai/je_lua_behavior_tree.h new file mode 100644 index 0000000..083d12b --- /dev/null +++ b/src/lua/modules/ai/je_lua_behavior_tree.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_BEHAVIOR_TREE_H__ +#define __JE_LUA_BEHAVIOR_TREE_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_BehaviorTree; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/ai/je_lua_state_machine.cpp b/src/lua/modules/ai/je_lua_state_machine.cpp index 82899b4..86ce7a5 100644 --- a/src/lua/modules/ai/je_lua_state_machine.cpp +++ b/src/lua/modules/ai/je_lua_state_machine.cpp @@ -8,6 +8,8 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_StateMachine = "StateMachine"; + LUA_IMPLEMENT int l_addEnterCallback(lua_State* L) { //StateMachine* sm; diff --git a/src/lua/modules/ai/je_lua_state_machine.h b/src/lua/modules/ai/je_lua_state_machine.h new file mode 100644 index 0000000..3c78f75 --- /dev/null +++ b/src/lua/modules/ai/je_lua_state_machine.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_STATE_MACHINE_H__ +#define __JE_LUA_STATE_MACHINE_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_StateMachine; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/ai/je_lua_statemachine.cpp b/src/lua/modules/ai/je_lua_statemachine.cpp deleted file mode 100644 index f79d79a..0000000 --- a/src/lua/modules/ai/je_lua_statemachine.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "libjin/jin.h" - -namespace JinEngine -{ - namespace Lua - { - - - - } -}
\ No newline at end of file diff --git a/src/lua/modules/audio/je_lua_audio.cpp b/src/lua/modules/audio/je_lua_audio.cpp index 29705b2..6851018 100644 --- a/src/lua/modules/audio/je_lua_audio.cpp +++ b/src/lua/modules/audio/je_lua_audio.cpp @@ -1,7 +1,8 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" +#include "je_lua_source.h" using namespace JinEngine::Audio; using namespace JinEngine::Audio::SDL; @@ -97,8 +98,8 @@ namespace JinEngine luax_pushnil(L); return 1; } - Proxy* proxy = luax_newinstance(L, JIN_AUDIO_SOURCE); - proxy->bind(new Shared<Source>(src, JIN_AUDIO_SOURCE)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Source); + proxy->bind(new Shared<Source>(src, Jin_Lua_Source)); return 1; } diff --git a/src/lua/modules/audio/je_lua_audio.h b/src/lua/modules/audio/je_lua_audio.h new file mode 100644 index 0000000..fa66392 --- /dev/null +++ b/src/lua/modules/audio/je_lua_audio.h @@ -0,0 +1,6 @@ +#ifndef __JE_LUA_AUDIO_H__ +#define __JE_LUA_AUDIO_H__ + +#include "je_lua_audio.h" + +#endif
\ No newline at end of file diff --git a/src/lua/modules/audio/je_lua_source.cpp b/src/lua/modules/audio/je_lua_source.cpp index a451995..8978c22 100644 --- a/src/lua/modules/audio/je_lua_source.cpp +++ b/src/lua/modules/audio/je_lua_source.cpp @@ -1,7 +1,7 @@ #include "libjin/jin.h" #include "lua/modules/luax.h" #include "lua/common/je_lua_common.h" -#include "lua/modules/types.h" + using namespace JinEngine::Audio; @@ -10,11 +10,13 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_Source = "Source"; + typedef Shared<Source>& SharedSource; LUA_IMPLEMENT inline SharedSource checkSource(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_AUDIO_SOURCE); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Source); return proxy->getShared<Source>(); } @@ -87,7 +89,7 @@ namespace JinEngine LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_AUDIO_SOURCE); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Source); proxy->release(); return 0; } @@ -108,7 +110,7 @@ namespace JinEngine { 0, 0 } }; - luax_newtype(L, JIN_AUDIO_SOURCE, f); + luax_newtype(L, Jin_Lua_Source, f); return 0; } diff --git a/src/lua/modules/audio/je_lua_source.h b/src/lua/modules/audio/je_lua_source.h new file mode 100644 index 0000000..076a691 --- /dev/null +++ b/src/lua/modules/audio/je_lua_source.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_SOURCE_H__ +#define __JE_LUA_SOURCE_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Source; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/bit/je_lua_bit.h b/src/lua/modules/bit/je_lua_bit.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/bit/je_lua_bit.h diff --git a/src/lua/modules/core/je_lua_core.h b/src/lua/modules/core/je_lua_core.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/core/je_lua_core.h diff --git a/src/lua/modules/event/je_lua_event.h b/src/lua/modules/event/je_lua_event.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/event/je_lua_event.h diff --git a/src/lua/modules/filesystem/je_lua_filesystem.h b/src/lua/modules/filesystem/je_lua_filesystem.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/filesystem/je_lua_filesystem.h diff --git a/src/lua/modules/graphics/je_lua_bitmap.cpp b/src/lua/modules/graphics/je_lua_bitmap.cpp index 1491bee..4b7c492 100644 --- a/src/lua/modules/graphics/je_lua_bitmap.cpp +++ b/src/lua/modules/graphics/je_lua_bitmap.cpp @@ -1,7 +1,8 @@ #include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "libjin/jin.h" +#include "je_lua_bitmap.h" using namespace JinEngine::Graphics; @@ -10,11 +11,13 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_Bitmap = "Bitmap"; + typedef Shared<Bitmap>& SharedBitmap; LUA_IMPLEMENT inline SharedBitmap checkBitmap(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_BITMAP); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Bitmap); return proxy->getShared<Bitmap>(); } @@ -87,8 +90,8 @@ namespace JinEngine SharedBitmap shared = checkBitmap(L); Bitmap* bitmap = shared.getObject(); Bitmap* b = Bitmap::clone(bitmap); - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_BITMAP); - proxy->bind(new Shared<Bitmap>(b, JIN_GRAPHICS_BITMAP)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Bitmap); + proxy->bind(new Shared<Bitmap>(b, Jin_Lua_Bitmap)); return 1; } @@ -104,9 +107,9 @@ namespace JinEngine { "clone", l_clone }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_BITMAP, f); + luax_newtype(L, Jin_Lua_Bitmap, f); return 0; } - } // graphics + } // namespace Graphics } // namespace JinEngine
\ No newline at end of file diff --git a/src/lua/modules/graphics/je_lua_bitmap.h b/src/lua/modules/graphics/je_lua_bitmap.h new file mode 100644 index 0000000..047766e --- /dev/null +++ b/src/lua/modules/graphics/je_lua_bitmap.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_BITMAP_H__ +#define __JE_LUA_BITMAP_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Bitmap; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/graphics/je_lua_canvas.cpp b/src/lua/modules/graphics/je_lua_canvas.cpp index 70edfd1..be6bb84 100644 --- a/src/lua/modules/graphics/je_lua_canvas.cpp +++ b/src/lua/modules/graphics/je_lua_canvas.cpp @@ -1,7 +1,8 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" +#include "je_lua_canvas.h" using namespace JinEngine::Graphics; @@ -10,11 +11,13 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_Canvas = "Canvas"; + typedef Shared<Canvas>& SharedCanvas; LUA_IMPLEMENT inline SharedCanvas checkCanvas(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Canvas); return proxy->getShared<Canvas>(); } @@ -42,7 +45,7 @@ namespace JinEngine LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Canvas); proxy->release(); return 0; } @@ -56,7 +59,7 @@ namespace JinEngine { "getSize", l_getSize }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_CANVAS, f); + luax_newtype(L, Jin_Lua_Canvas, f); return 0; } diff --git a/src/lua/modules/graphics/je_lua_canvas.h b/src/lua/modules/graphics/je_lua_canvas.h new file mode 100644 index 0000000..c7b8504 --- /dev/null +++ b/src/lua/modules/graphics/je_lua_canvas.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_CANVAS_H__ +#define __JE_LUA_CANVAS_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Canvas; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp index 6b84651..c535216 100644 --- a/src/lua/modules/graphics/je_lua_graphics.cpp +++ b/src/lua/modules/graphics/je_lua_graphics.cpp @@ -3,9 +3,20 @@ #include "libjin/jin.h" #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" + +#include "je_lua_canvas.h" +#include "je_lua_sprite.h" #include "je_lua_spritesheet.h" +#include "je_lua_bitmap.h" +#include "je_lua_ttf.h" +#include "je_lua_ttf_data.h" +#include "je_lua_texture.h" +#include "je_lua_shader.h" +#include "je_lua_text.h" +#include "je_lua_texture_font.h" +#include "je_lua_page.h" using namespace std; using namespace JinEngine; @@ -165,8 +176,8 @@ namespace JinEngine return 1; } } - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_BITMAP); - proxy->bind(new Shared<Bitmap>(bitmap, JIN_GRAPHICS_BITMAP)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Bitmap); + proxy->bind(new Shared<Bitmap>(bitmap, Jin_Lua_Bitmap)); return 1; } @@ -174,9 +185,9 @@ namespace JinEngine LUA_IMPLEMENT int l_newTexture(lua_State* L) { Texture* texture = nullptr; - if (luax_istype(L, 1, JIN_GRAPHICS_BITMAP)) + if (luax_istype(L, 1, Jin_Lua_Bitmap)) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_BITMAP); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_Bitmap); Shared<Bitmap>& refBitmap = p->getShared<Bitmap>(); Bitmap* bitmap = refBitmap.getObject(); texture = Texture::createTexture(bitmap); @@ -186,8 +197,8 @@ namespace JinEngine const char* path = luax_checkstring(L, 1); texture = Texture::createTexture(path); } - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_TEXTURE); - proxy->bind(new Shared<Texture>(texture, JIN_GRAPHICS_TEXTURE)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Texture); + proxy->bind(new Shared<Texture>(texture, Jin_Lua_Texture)); return 1; } @@ -201,8 +212,8 @@ namespace JinEngine luax_pushnil(L); return 1; } - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_SHADER); - proxy->bind(new Shared<Shader>(jsl, JIN_GRAPHICS_SHADER)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Shader); + proxy->bind(new Shared<Shader>(jsl, Jin_Lua_Shader)); return 1; } @@ -225,8 +236,8 @@ namespace JinEngine luax_pushnil(L); return 1; } - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_SHADER); - proxy->bind(new Shared<Shader>(jsl, JIN_GRAPHICS_SHADER)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Shader); + proxy->bind(new Shared<Shader>(jsl, Jin_Lua_Shader)); return 1; } @@ -234,9 +245,9 @@ namespace JinEngine { int w = luax_checknumber(L, 1); int h = luax_checknumber(L, 2); - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_CANVAS); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Canvas); Canvas* cvs = Canvas::createCanvas(w, h); - proxy->bind(new Shared<Canvas>(cvs, JIN_GRAPHICS_CANVAS)); + proxy->bind(new Shared<Canvas>(cvs, Jin_Lua_Canvas)); return 1; } @@ -274,7 +285,7 @@ namespace JinEngine LUA_IMPLEMENT void l_draw_texture(lua_State* L) { - if (!luax_istype(L, 1, JIN_GRAPHICS_TEXTURE)) + if (!luax_istype(L, 1, Jin_Lua_Texture)) return; int x = luax_optnumber(L, 2, 0); int y = luax_optnumber(L, 3, 0); @@ -290,7 +301,7 @@ namespace JinEngine LUA_IMPLEMENT void l_draw_canvas(lua_State* L) { - if (!luax_istype(L, 1, JIN_GRAPHICS_CANVAS)) + if (!luax_istype(L, 1, Jin_Lua_Canvas)) return; int x = luax_optnumber(L, 2, 0); int y = luax_optnumber(L, 3, 0); @@ -307,7 +318,7 @@ namespace JinEngine /* jin.graphics.draw(text, font, x, y) */ LUA_IMPLEMENT void l_draw_text(lua_State* L) { - if (!luax_istype(L, 1, JIN_GRAPHICS_TEXT)) + if (!luax_istype(L, 1, Jin_Lua_Text)) return; Proxy* p = (Proxy*)luax_toudata(L, 1); Text* text = p->getObject<Text>(); @@ -316,12 +327,12 @@ namespace JinEngine int spacing = luax_optnumber(L, 6, 0); Font* font = nullptr; Proxy* p2 = (Proxy*)luax_toudata(L, 2); - if (luax_istype(L, 2, JIN_GRAPHICS_TEXTUREFONT)) + if (luax_istype(L, 2, Jin_Lua_TextureFont)) { TextureFont* tf = p2->getObject<TextureFont>(); font = tf; } - else if (luax_istype(L, 2, JIN_GRAPHICS_TTF)) + else if (luax_istype(L, 2, Jin_Lua_TTF)) { TTF* ttf = p2->getObject<TTF>(); font = ttf; @@ -337,7 +348,7 @@ namespace JinEngine /* jin.graphics.draw(page, x, y) */ LUA_IMPLEMENT void l_draw_page(lua_State* L) { - if (!luax_istype(L, 1, JIN_GRAPHICS_PAGE)) + if (!luax_istype(L, 1, Jin_Lua_Page)) return; int x = luax_optnumber(L, 2, 0); int y = luax_optnumber(L, 3, 0); @@ -349,13 +360,13 @@ namespace JinEngine LUA_IMPLEMENT int l_draw(lua_State* L) { - if (luax_istype(L, 1, JIN_GRAPHICS_TEXTURE)) + if (luax_istype(L, 1, Jin_Lua_Texture)) l_draw_texture(L); - else if (luax_istype(L, 1, JIN_GRAPHICS_CANVAS)) + else if (luax_istype(L, 1, Jin_Lua_Canvas)) l_draw_canvas(L); - else if (luax_istype(L, 1, JIN_GRAPHICS_TEXT)) + else if (luax_istype(L, 1, Jin_Lua_Text)) l_draw_text(L); - else if (luax_istype(L, 1, JIN_GRAPHICS_PAGE)) + else if (luax_istype(L, 1, Jin_Lua_Page)) l_draw_page(L); else { @@ -387,13 +398,13 @@ namespace JinEngine float ox = luax_optnumber(L, 8, 0); float oy = luax_optnumber(L, 9, 0); - if (luax_istype(L, 1, JIN_GRAPHICS_TEXTURE)) + if (luax_istype(L, 1, Jin_Lua_Texture)) { Proxy* proxy = (Proxy*)luax_toudata(L, 1); Shared<Texture>& tex = proxy->getShared<Texture>(); tex->render(q, x, y, sx, sy, r, ox, oy); } - else if (luax_istype(L, 1, JIN_GRAPHICS_CANVAS)) + else if (luax_istype(L, 1, Jin_Lua_Canvas)) { Proxy* proxy = (Proxy*)luax_toudata(L, 1); Shared<Canvas>& p = proxy->getShared<Canvas>(); @@ -459,7 +470,7 @@ namespace JinEngine Canvas::unbind(); return 0; } - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Canvas); Shared<Canvas>& shared = proxy->getShared<Canvas>(); Canvas::bind(shared.getObject()); return 0; @@ -478,9 +489,9 @@ namespace JinEngine Shader::unuse(); return 0; } - if (luax_istype(L, 1, JIN_GRAPHICS_SHADER)) + if (luax_istype(L, 1, Jin_Lua_Shader)) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SHADER); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Shader); Shared<Shader>& jsl = proxy->getShared<Shader>(); jsl->use(); } @@ -617,7 +628,7 @@ namespace JinEngine LUA_IMPLEMENT int l_newTTFData(lua_State* L) { - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_TTFDATA); + Proxy* proxy = luax_newinstance(L, Jin_Lua_TTFData); TTFData* fd = nullptr; { const char* path = luax_checkstring(L, 1); @@ -632,7 +643,7 @@ namespace JinEngine fs->read(path, b); fd = TTFData::createTTFData(&b, b.size()); } - proxy->bind(new Shared<TTFData>(fd, JIN_GRAPHICS_TTFDATA)); + proxy->bind(new Shared<TTFData>(fd, Jin_Lua_TTFData)); return 1; } @@ -655,30 +666,30 @@ namespace JinEngine unsigned length; const char* data = luax_checklstring(L, 1, &length); Text* text = new Text(encode, data, length); - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_TEXT); - proxy->bind(new Shared<Text>(text, JIN_GRAPHICS_TEXT)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Text); + proxy->bind(new Shared<Text>(text, Jin_Lua_Text)); return 1; } LUA_IMPLEMENT int l_newSprite(lua_State* L) { - Proxy* p = luax_newinstance(L, JIN_GRAPHICS_SPRITE); - p->bind(new Shared<Sprite>(new Sprite(), JIN_GRAPHICS_SPRITE)); + Proxy* p = luax_newinstance(L, Jin_Lua_Sprite); + p->bind(new Shared<Sprite>(new Sprite(), Jin_Lua_Sprite)); return 1; } LUA_IMPLEMENT int l_newSpriteSheet(lua_State* L) { Proxy* pxyGraphic = nullptr; - if (luax_istype(L, 1, JIN_GRAPHICS_TEXTURE)) - pxyGraphic = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTURE); - else if(luax_istype(L, 1, JIN_GRAPHICS_CANVAS)) - pxyGraphic = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS); + if (luax_istype(L, 1, Jin_Lua_Texture)) + pxyGraphic = (Proxy*)luax_checktype(L, 1, Jin_Lua_Texture); + else if(luax_istype(L, 1, Jin_Lua_Canvas)) + pxyGraphic = (Proxy*)luax_checktype(L, 1, Jin_Lua_Canvas); if (pxyGraphic != nullptr) { - Proxy* pxySSheet = luax_newinstance(L, JIN_GRAPHICS_SPRITESHEET); + Proxy* pxySSheet = luax_newinstance(L, Jin_Lua_SpriteSheet); Graphic* graphic = pxyGraphic->getObject<Graphic>(); - Shared<SpriteSheet>* shrSSheet = new Shared<SpriteSheet>(new SpriteSheet(graphic), JIN_GRAPHICS_SPRITESHEET); + Shared<SpriteSheet>* shrSSheet = new Shared<SpriteSheet>(new SpriteSheet(graphic), Jin_Lua_SpriteSheet); Shared<Graphic>& shrGraphic = pxyGraphic->getShared<Graphic>(); shrSSheet->setDependency((int)SpriteSheetDependency::DEP_GRAPHIC, &shrGraphic); pxySSheet->bind(shrSSheet); @@ -691,12 +702,12 @@ namespace JinEngine /* newTextureFont(bitmap, text, color | cellw, cellh) */ LUA_IMPLEMENT int l_newTextureFont(lua_State* L) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_BITMAP); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_Bitmap); Bitmap* bitmap = p->getObject<Bitmap>(); Text* text; - if (luax_istype(L, 2, JIN_GRAPHICS_TEXT)) + if (luax_istype(L, 2, Jin_Lua_Text)) { - Proxy* pt = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_TEXT); + Proxy* pt = (Proxy*)luax_checktype(L, 2, Jin_Lua_Text); text = pt->getObject<Text>(); } else if (luax_isstring(L, 2)) @@ -735,23 +746,23 @@ namespace JinEngine // Delete temporary text. delete text; } - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_TEXTUREFONT); - proxy->bind(new Shared<TextureFont>(textureFont, JIN_GRAPHICS_TEXTUREFONT)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_TextureFont); + proxy->bind(new Shared<TextureFont>(textureFont, Jin_Lua_TextureFont)); return 1; } /* setFont(font) */ LUA_IMPLEMENT int l_setFont(lua_State* L) { - if (luax_istype(L, 1, JIN_GRAPHICS_TTF)) + if (luax_istype(L, 1, Jin_Lua_TTF)) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTF); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_TTF); TTF* ttf = p->getObject<TTF>(); context.curFont = ttf; } - else if (luax_istype(L, 1, JIN_GRAPHICS_TEXTUREFONT)) + else if (luax_istype(L, 1, Jin_Lua_TextureFont)) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTUREFONT); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_TextureFont); TextureFont* tf = p->getObject<TextureFont>(); context.curFont = tf; } diff --git a/src/lua/modules/graphics/je_lua_graphics.h b/src/lua/modules/graphics/je_lua_graphics.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/graphics/je_lua_graphics.h diff --git a/src/lua/modules/graphics/je_lua_page.cpp b/src/lua/modules/graphics/je_lua_page.cpp index 3ebd557..526c2ec 100644 --- a/src/lua/modules/graphics/je_lua_page.cpp +++ b/src/lua/modules/graphics/je_lua_page.cpp @@ -1,5 +1,5 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" @@ -14,17 +14,19 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_Page = "Page"; + typedef Shared<Font>& SharedFont; Page* getPage(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_PAGE); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Page); return proxy->getObject<Page>(); } LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_PAGE); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Page); proxy->release(); return 0; } @@ -60,7 +62,7 @@ namespace JinEngine { "getHeight", l_getHeight }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_PAGE, f); + luax_newtype(L, Jin_Lua_Page, f); return 0; } diff --git a/src/lua/modules/graphics/je_lua_page.h b/src/lua/modules/graphics/je_lua_page.h index c9775e9..6ebf718 100644 --- a/src/lua/modules/graphics/je_lua_page.h +++ b/src/lua/modules/graphics/je_lua_page.h @@ -12,6 +12,8 @@ namespace JinEngine DEP_TEXTURE_FONT = 2, }; + extern const char* Jin_Lua_Page; + } } diff --git a/src/lua/modules/graphics/je_lua_particle_system.h b/src/lua/modules/graphics/je_lua_particle_system.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/graphics/je_lua_particle_system.h diff --git a/src/lua/modules/graphics/je_lua_shader.cpp b/src/lua/modules/graphics/je_lua_shader.cpp index 8c1c2e4..61c8eef 100644 --- a/src/lua/modules/graphics/je_lua_shader.cpp +++ b/src/lua/modules/graphics/je_lua_shader.cpp @@ -1,8 +1,12 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" +#include "je_lua_shader.h" +#include "je_lua_canvas.h" +#include "je_lua_texture.h" + using namespace JinEngine::Graphics; using namespace JinEngine::Graphics::Shaders; @@ -11,11 +15,13 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_Shader = "Shader"; + typedef Shared<Shader>& ShaderRef; static inline ShaderRef checkShader(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SHADER); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Shader); return proxy->getShared<Shader>(); } @@ -35,7 +41,7 @@ namespace JinEngine { ShaderRef shared = checkShader(L); const char* variable = luax_checkstring(L, 2); - Proxy* proxy = (Proxy*)luax_checktype(L, 3, JIN_GRAPHICS_TEXTURE); + Proxy* proxy = (Proxy*)luax_checktype(L, 3, Jin_Lua_Texture); Shared<Texture>& tex = proxy->getShared<Texture>(); shared->sendTexture(variable, tex.getObject()); return 0; @@ -45,7 +51,7 @@ namespace JinEngine { ShaderRef shared = checkShader(L); const char* variable = luax_checkstring(L, 2); - Proxy* proxy = (Proxy*)luax_checktype(L, 3, JIN_GRAPHICS_CANVAS); + Proxy* proxy = (Proxy*)luax_checktype(L, 3, Jin_Lua_Canvas); Shared<Canvas>& canvas = proxy->getShared<Canvas>(); shared->sendCanvas(variable, canvas.getObject()); return 0; @@ -106,7 +112,7 @@ namespace JinEngine LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SHADER); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Shader); proxy->release(); return 0; } @@ -124,7 +130,7 @@ namespace JinEngine { "sendColor", l_sendColor }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_SHADER, f); + luax_newtype(L, Jin_Lua_Shader, f); return 0; } diff --git a/src/lua/modules/graphics/je_lua_shader.h b/src/lua/modules/graphics/je_lua_shader.h new file mode 100644 index 0000000..57ad570 --- /dev/null +++ b/src/lua/modules/graphics/je_lua_shader.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_SHDER_H__ +#define __JE_LUA_SHDER_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Shader; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/graphics/je_lua_sprite.cpp b/src/lua/modules/graphics/je_lua_sprite.cpp index 511f877..ec5887c 100644 --- a/src/lua/modules/graphics/je_lua_sprite.cpp +++ b/src/lua/modules/graphics/je_lua_sprite.cpp @@ -1,8 +1,12 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" + #include "je_lua_sprite.h" +#include "je_lua_canvas.h" +#include "je_lua_texture.h" +#include "je_lua_shader.h" using namespace JinEngine::Graphics; using namespace JinEngine::Graphics::Shaders; @@ -11,18 +15,19 @@ namespace JinEngine { namespace Lua { + const char* Jin_Lua_Sprite = "Sprite"; typedef Shared<Sprite>& SharedSprite; LUA_IMPLEMENT inline SharedSprite checkSprite(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SPRITE); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Sprite); return proxy->getShared<Sprite>(); } LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SPRITE); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_Sprite); p->release(); return 0; } @@ -89,7 +94,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setShader(lua_State* L) { SharedSprite sprite = checkSprite(L); - Proxy* proxy = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_SHADER); + Proxy* proxy = (Proxy*)luax_checktype(L, 2, Jin_Lua_Shader); Shader* shader = proxy->getObject<Shader>(); sprite->setShader(shader); sprite.setDependency((int)SpriteDependency::DEP_SHADER, &proxy->getShared<Shader>()); @@ -101,10 +106,10 @@ namespace JinEngine SharedSprite sprite = checkSprite(L); Graphic* graphic = nullptr; Proxy* p = nullptr; - if (luax_istype(L, 2, JIN_GRAPHICS_TEXTURE)) - p = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_TEXTURE); - else if (luax_istype(L, 2, JIN_GRAPHICS_CANVAS)) - p = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_CANVAS); + if (luax_istype(L, 2, Jin_Lua_Texture)) + p = (Proxy*)luax_checktype(L, 2, Jin_Lua_Texture); + else if (luax_istype(L, 2, Jin_Lua_Canvas)) + p = (Proxy*)luax_checktype(L, 2, Jin_Lua_Canvas); if (p != nullptr) { sprite->setGraphic(p->getObject<Graphic>()); @@ -214,7 +219,7 @@ namespace JinEngine { "getColor", l_getColor }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_SPRITE, methods); + luax_newtype(L, Jin_Lua_Sprite, methods); return 0; } diff --git a/src/lua/modules/graphics/je_lua_sprite.h b/src/lua/modules/graphics/je_lua_sprite.h index cdd3a50..cbadc34 100644 --- a/src/lua/modules/graphics/je_lua_sprite.h +++ b/src/lua/modules/graphics/je_lua_sprite.h @@ -14,6 +14,8 @@ namespace JinEngine DEP_SPRITESHEET = 3 }; + extern const char* Jin_Lua_Sprite; + } } diff --git a/src/lua/modules/graphics/je_lua_spritesheet.cpp b/src/lua/modules/graphics/je_lua_spritesheet.cpp index 7994237..ef1bd85 100644 --- a/src/lua/modules/graphics/je_lua_spritesheet.cpp +++ b/src/lua/modules/graphics/je_lua_spritesheet.cpp @@ -1,5 +1,5 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" #include "je_lua_sprite.h" @@ -13,16 +13,18 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_SpriteSheet = "SpriteSheet"; + LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* pxySSheet = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SPRITESHEET); + Proxy* pxySSheet = (Proxy*)luax_checktype(L, 1, Jin_Lua_SpriteSheet); pxySSheet->release(); return 0; } LUA_IMPLEMENT int l_newSprite(lua_State* L) { - Proxy* pxySSheet = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SPRITESHEET); + Proxy* pxySSheet = (Proxy*)luax_checktype(L, 1, Jin_Lua_SpriteSheet); Shared<SpriteSheet>& shrSSheet = pxySSheet->getShared<SpriteSheet>(); SpriteSheet* sheet = pxySSheet->getObject<SpriteSheet>(); Quad quad; @@ -31,8 +33,8 @@ namespace JinEngine quad.w = luax_checkinteger(L, 4); quad.h = luax_checkinteger(L, 5); Sprite* spr = sheet->createSprite(quad); - Proxy* pxySprite = luax_newinstance(L, JIN_GRAPHICS_SPRITE); - Shared<Sprite>* shrSprite = new Shared<Sprite>(spr, JIN_GRAPHICS_SPRITE); + Proxy* pxySprite = luax_newinstance(L, Jin_Lua_Sprite); + Shared<Sprite>* shrSprite = new Shared<Sprite>(spr, Jin_Lua_Sprite); shrSprite->setDependency((int)SpriteDependency::DEP_SPRITESHEET, &shrSSheet); pxySprite->bind(shrSprite); return 1; @@ -45,7 +47,7 @@ namespace JinEngine { "newSprite", l_newSprite }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_SPRITESHEET, methods); + luax_newtype(L, Jin_Lua_SpriteSheet, methods); return 0; } diff --git a/src/lua/modules/graphics/je_lua_spritesheet.h b/src/lua/modules/graphics/je_lua_spritesheet.h index bedf945..ec94de8 100644 --- a/src/lua/modules/graphics/je_lua_spritesheet.h +++ b/src/lua/modules/graphics/je_lua_spritesheet.h @@ -11,6 +11,8 @@ namespace JinEngine DEP_GRAPHIC = 1 }; + extern const char* Jin_Lua_SpriteSheet; + } } diff --git a/src/lua/modules/graphics/je_lua_text.cpp b/src/lua/modules/graphics/je_lua_text.cpp index 3316a4c..5e12ff8 100644 --- a/src/lua/modules/graphics/je_lua_text.cpp +++ b/src/lua/modules/graphics/je_lua_text.cpp @@ -1,5 +1,5 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" @@ -10,9 +10,11 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_Text = "Text"; + LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXT); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_Text); p->release(); return 0; } @@ -23,7 +25,7 @@ namespace JinEngine { "__gc", l_gc }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_TEXT, f); + luax_newtype(L, Jin_Lua_Text, f); return 0; } diff --git a/src/lua/modules/graphics/je_lua_text.h b/src/lua/modules/graphics/je_lua_text.h new file mode 100644 index 0000000..bae5913 --- /dev/null +++ b/src/lua/modules/graphics/je_lua_text.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_TEXT_H__ +#define __JE_LUA_TEXT_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Text; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/graphics/je_lua_texture.cpp b/src/lua/modules/graphics/je_lua_texture.cpp index d7571b6..08a98eb 100644 --- a/src/lua/modules/graphics/je_lua_texture.cpp +++ b/src/lua/modules/graphics/je_lua_texture.cpp @@ -1,5 +1,5 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" @@ -9,12 +9,14 @@ namespace JinEngine { namespace Lua { + + const char* Jin_Lua_Texture = "Texture"; typedef Shared<Texture>& SharedTexture; LUA_IMPLEMENT inline SharedTexture checkTexture(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTURE); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Texture); return proxy->getShared<Texture>(); } @@ -42,7 +44,7 @@ namespace JinEngine LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTURE); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Texture); proxy->release(); return 0; } @@ -56,7 +58,7 @@ namespace JinEngine { "getSize", l_getSize }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_TEXTURE, f); + luax_newtype(L, Jin_Lua_Texture, f); return 0; } diff --git a/src/lua/modules/graphics/je_lua_texture.h b/src/lua/modules/graphics/je_lua_texture.h new file mode 100644 index 0000000..48f22ab --- /dev/null +++ b/src/lua/modules/graphics/je_lua_texture.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_TEXTURE_H__ +#define __JE_LUA_TEXTURE_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Texture; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/graphics/je_lua_texture_font.cpp b/src/lua/modules/graphics/je_lua_texture_font.cpp index 8be9a9d..0c3c4d9 100644 --- a/src/lua/modules/graphics/je_lua_texture_font.cpp +++ b/src/lua/modules/graphics/je_lua_texture_font.cpp @@ -1,8 +1,10 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" + #include "je_lua_page.h" +#include "je_lua_text.h" using namespace JinEngine::Graphics; using namespace JinEngine::Graphics::Fonts; @@ -12,9 +14,11 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_TextureFont = "TextureFont"; + LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTUREFONT); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_TextureFont); proxy->release(); return 0; } @@ -22,7 +26,7 @@ namespace JinEngine /* typeset(Text | string, lineheight, spacing) */ LUA_IMPLEMENT int l_typeset(lua_State* L) { - Proxy* pxyTexFont = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTUREFONT); + Proxy* pxyTexFont = (Proxy*)luax_checktype(L, 1, Jin_Lua_TextureFont); Shared<TextureFont>& shrTexFont = pxyTexFont->getShared<TextureFont>(); TextureFont* tf = pxyTexFont->getObject<TextureFont>(); int lineheight = luax_checkinteger(L, 3); @@ -35,14 +39,14 @@ namespace JinEngine Text text(Encode::UTF8, str, length); page = tf->typeset(text, lineheight, spacing); } - else if (luax_istype(L, 2, JIN_GRAPHICS_TEXT)) + else if (luax_istype(L, 2, Jin_Lua_Text)) { - Proxy* p2 = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_TEXT); + Proxy* p2 = (Proxy*)luax_checktype(L, 2, Jin_Lua_Text); Text* text = p2->getObject<Text>(); page = tf->typeset(*text, lineheight, spacing); } - Proxy* pxyPage = luax_newinstance(L, JIN_GRAPHICS_PAGE); - Shared<Page>* shrPage = new Shared<Page>(page, JIN_GRAPHICS_PAGE); + Proxy* pxyPage = luax_newinstance(L, Jin_Lua_Page); + Shared<Page>* shrPage = new Shared<Page>(page, Jin_Lua_Page); shrPage->setDependency((int)PageDependency::DEP_TEXTURE_FONT, &shrTexFont); pxyPage->bind(shrPage); return 1; @@ -55,7 +59,7 @@ namespace JinEngine { "typeset", l_typeset }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_TEXTUREFONT, f); + luax_newtype(L, Jin_Lua_TextureFont, f); return 0; } diff --git a/src/lua/modules/graphics/je_lua_texture_font.h b/src/lua/modules/graphics/je_lua_texture_font.h new file mode 100644 index 0000000..1339221 --- /dev/null +++ b/src/lua/modules/graphics/je_lua_texture_font.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_TEXTURE_FONT_H__ +#define __JE_LUA_TEXTURE_FONT_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_TextureFont; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/graphics/je_lua_ttf.cpp b/src/lua/modules/graphics/je_lua_ttf.cpp index 0216a9a..1f5be50 100644 --- a/src/lua/modules/graphics/je_lua_ttf.cpp +++ b/src/lua/modules/graphics/je_lua_ttf.cpp @@ -1,8 +1,10 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" + #include "je_lua_page.h" +#include "je_lua_text.h" using namespace JinEngine::Graphics; using namespace JinEngine::Graphics::Fonts; @@ -12,9 +14,11 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_TTF = "TTF"; + LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTF); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_TTF); proxy->release(); return 0; } @@ -22,7 +26,7 @@ namespace JinEngine /* typeset(Text | string, lineheight, spacing) */ LUA_IMPLEMENT int l_typeset(lua_State* L) { - Proxy* pxyTTF = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTF); + Proxy* pxyTTF = (Proxy*)luax_checktype(L, 1, Jin_Lua_TTF); Shared<TTF>& shrTTF = pxyTTF->getShared<TTF>(); TTF* ttf = pxyTTF->getObject<TTF>(); int lineheight = luax_optnumber(L, 3, ttf->getFontSize()); @@ -35,14 +39,14 @@ namespace JinEngine Text text(Encode::UTF8, str, length); page = ttf->typeset(text, lineheight, spacing); } - else if (luax_istype(L, 2, JIN_GRAPHICS_TEXT)) + else if (luax_istype(L, 2, Jin_Lua_Text)) { - Proxy* pxyText = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_TEXT); + Proxy* pxyText = (Proxy*)luax_checktype(L, 2, Jin_Lua_Text); Text* text = pxyText->getObject<Text>(); page = ttf->typeset(*text, lineheight, spacing); } - Proxy* pxyPage = luax_newinstance(L, JIN_GRAPHICS_PAGE); - Shared<Page>* refPage = new Shared<Page>(page, JIN_GRAPHICS_PAGE); + Proxy* pxyPage = luax_newinstance(L, Jin_Lua_Page); + Shared<Page>* refPage = new Shared<Page>(page, Jin_Lua_Page); refPage->setDependency((int)PageDependency::DEP_TTF, &shrTTF); pxyPage->bind(refPage); return 1; @@ -55,7 +59,7 @@ namespace JinEngine { "typeset", l_typeset }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_TTF, f); + luax_newtype(L, Jin_Lua_TTF, f); return 0; } diff --git a/src/lua/modules/graphics/je_lua_ttf.h b/src/lua/modules/graphics/je_lua_ttf.h new file mode 100644 index 0000000..01f99e6 --- /dev/null +++ b/src/lua/modules/graphics/je_lua_ttf.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_TTF_H__ +#define __JE_LUA_TTF_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_TTF; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/graphics/je_lua_ttf_data.cpp b/src/lua/modules/graphics/je_lua_ttf_data.cpp index 4df2f6e..fb43ae4 100644 --- a/src/lua/modules/graphics/je_lua_ttf_data.cpp +++ b/src/lua/modules/graphics/je_lua_ttf_data.cpp @@ -1,8 +1,11 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" +#include "je_lua_ttf.h" +#include "je_lua_ttf_data.h" + using namespace JinEngine::Graphics; using namespace JinEngine::Graphics::Fonts; @@ -11,28 +14,25 @@ namespace JinEngine namespace Lua { - enum TTFDependency - { - DEP_TTFDATA = 1, - }; + const char* Jin_Lua_TTFData = "TTFData"; LUA_IMPLEMENT int l_newTTF(lua_State* L) { - Proxy* pxyTTFData = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTFDATA); + Proxy* pxyTTFData = (Proxy*)luax_checktype(L, 1, Jin_Lua_TTFData); int fontsize = luax_checkinteger(L, 2); Shared<TTFData>& shrFontData = pxyTTFData->getShared<TTFData>(); TTFData* fontData = shrFontData.getObject(); - Proxy* pxyTTF = luax_newinstance(L, JIN_GRAPHICS_TTF); + Proxy* pxyTTF = luax_newinstance(L, Jin_Lua_TTF); TTF* font = fontData->createTTF(fontsize); - Shared<TTF>* shrTTF = new Shared<TTF>(font, JIN_GRAPHICS_TTF); - shrTTF->setDependency(DEP_TTFDATA, &shrFontData); + Shared<TTF>* shrTTF = new Shared<TTF>(font, Jin_Lua_TTF); + shrTTF->setDependency((int)TTFDependency::DEP_TTFDATA, &shrFontData); pxyTTF->bind(shrTTF); return 1; } LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTFDATA); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_TTFData); p->release(); return 0; } @@ -44,7 +44,7 @@ namespace JinEngine { "newTTF", l_newTTF }, { 0, 0 } }; - luax_newtype(L, JIN_GRAPHICS_TTFDATA, f); + luax_newtype(L, Jin_Lua_TTFData, f); return 0; } diff --git a/src/lua/modules/graphics/je_lua_ttf_data.h b/src/lua/modules/graphics/je_lua_ttf_data.h new file mode 100644 index 0000000..f858f1a --- /dev/null +++ b/src/lua/modules/graphics/je_lua_ttf_data.h @@ -0,0 +1,19 @@ +#ifndef __JE_LUA_TTFDATA_H__ +#define __JE_LUA_TTFDATA_H__ + +namespace JinEngine +{ + namespace Lua + { + + enum class TTFDependency + { + DEP_TTFDATA = 1, + }; + + extern const char* Jin_Lua_TTFData; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/joypad/je_lua_joypad.h b/src/lua/modules/joypad/je_lua_joypad.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/joypad/je_lua_joypad.h diff --git a/src/lua/modules/keyboard/je_lua_keyboard.h b/src/lua/modules/keyboard/je_lua_keyboard.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/keyboard/je_lua_keyboard.h diff --git a/src/lua/modules/math/je_lua_math.h b/src/lua/modules/math/je_lua_math.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/math/je_lua_math.h diff --git a/src/lua/modules/mouse/je_lua_mouse.h b/src/lua/modules/mouse/je_lua_mouse.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/mouse/je_lua_mouse.h diff --git a/src/lua/modules/net/je_lua_buffer.cpp b/src/lua/modules/net/je_lua_buffer.cpp index 751de05..2565d60 100644 --- a/src/lua/modules/net/je_lua_buffer.cpp +++ b/src/lua/modules/net/je_lua_buffer.cpp @@ -1,5 +1,5 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" #include "je_lua_buffer.h" @@ -8,11 +8,14 @@ namespace JinEngine { namespace Lua { + + const char* Jin_Lua_Buffer = "Buffer"; + typedef Shared<Net::Buffer>& SharedBuffer; static inline SharedBuffer checkNetBuffer(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_NETWORK_BUFFER); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Buffer); return proxy->getShared<Net::Buffer>(); } @@ -110,7 +113,7 @@ namespace JinEngine LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_NETWORK_BUFFER); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Buffer); proxy->release(); return 0; } @@ -127,7 +130,7 @@ namespace JinEngine { 0, 0 } }; - luax_newtype(L, JIN_NETWORK_BUFFER, netbuffer_function); + luax_newtype(L, Jin_Lua_Buffer, netbuffer_function); return 0; } diff --git a/src/lua/modules/net/je_lua_buffer.h b/src/lua/modules/net/je_lua_buffer.h index d713f53..d24a4e2 100644 --- a/src/lua/modules/net/je_lua_buffer.h +++ b/src/lua/modules/net/je_lua_buffer.h @@ -9,6 +9,9 @@ namespace JinEngine { namespace Lua { + + extern const char* Jin_Lua_Buffer; + namespace Net { diff --git a/src/lua/modules/net/je_lua_net.cpp b/src/lua/modules/net/je_lua_net.cpp index 1d0204a..795eb18 100644 --- a/src/lua/modules/net/je_lua_net.cpp +++ b/src/lua/modules/net/je_lua_net.cpp @@ -1,8 +1,10 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "libjin/jin.h" #include "lua/common/je_lua_common.h" + #include "je_lua_buffer.h" +#include "je_lua_socket.h" namespace JinEngine { @@ -48,17 +50,17 @@ namespace Lua } } Socket* socket = new Socket(info); - Proxy* proxy = luax_newinstance(L, JIN_NETWORK_SOCKET); - proxy->bind(new Shared<Socket>(socket, JIN_NETWORK_SOCKET)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Socket); + proxy->bind(new Shared<Socket>(socket, Jin_Lua_Socket)); return 1; } LUA_IMPLEMENT int l_Buffer(lua_State* L) { int size = luax_checkinteger(L, 1); - Proxy* proxy = luax_newinstance(L, JIN_NETWORK_BUFFER); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Buffer); Net::Buffer* buffer = new Net::Buffer(size); - proxy->bind(new Shared<Buffer>(buffer, JIN_NETWORK_BUFFER)); + proxy->bind(new Shared<Buffer>(buffer, Jin_Lua_Buffer)); return 1; } diff --git a/src/lua/modules/net/je_lua_net.h b/src/lua/modules/net/je_lua_net.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/net/je_lua_net.h diff --git a/src/lua/modules/net/je_lua_socket.cpp b/src/lua/modules/net/je_lua_socket.cpp index a51f5f3..309f92e 100644 --- a/src/lua/modules/net/je_lua_socket.cpp +++ b/src/lua/modules/net/je_lua_socket.cpp @@ -1,5 +1,5 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "lua/common/je_lua_common.h" #include "libjin/jin.h" #include "je_lua_buffer.h" @@ -12,19 +12,21 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_Socket = "Socket"; + typedef Shared<Socket>& SharedSocket; const int BUFFER_SIZE = 1024; LUA_IMPLEMENT inline SharedSocket checkSocket(lua_State* L, int pos = 1) { - Proxy* proxy = (Proxy*)luax_checktype(L, pos, JIN_NETWORK_SOCKET); + Proxy* proxy = (Proxy*)luax_checktype(L, pos, Jin_Lua_Socket); return proxy->getShared<Socket>(); } LUA_IMPLEMENT inline Shared<Buffer>& checkNetBuffer(lua_State* L, int pos = 1) { - Proxy* proxy = (Proxy*)luax_checktype(L, pos, JIN_NETWORK_BUFFER); + Proxy* proxy = (Proxy*)luax_checktype(L, pos, Jin_Lua_Buffer); return proxy->getShared<Buffer>(); } @@ -33,8 +35,8 @@ namespace JinEngine { SharedSocket socket = checkSocket(L); Socket* client = socket->accept(); - Proxy* proxy = luax_newinstance(L, JIN_NETWORK_SOCKET); - proxy->bind(new Shared<Socket>(client, JIN_NETWORK_SOCKET)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Socket); + proxy->bind(new Shared<Socket>(client, Jin_Lua_Socket)); return 1; } @@ -44,9 +46,9 @@ namespace JinEngine SharedSocket socket = checkSocket(L); char buffer[BUFFER_SIZE] = {0}; int size = socket->receive(buffer, BUFFER_SIZE); - Proxy* proxy = luax_newinstance(L, JIN_NETWORK_BUFFER); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Buffer); Net::Buffer* netBuffer = new Net::Buffer(buffer, size); - proxy->bind(new Shared<Buffer>(netBuffer, JIN_NETWORK_BUFFER)); + proxy->bind(new Shared<Buffer>(netBuffer, Jin_Lua_Buffer)); return 1; } @@ -59,8 +61,8 @@ namespace JinEngine char buffer[BUFFER_SIZE]; int size = socket->receiveFrom(buffer, BUFFER_SIZE, address, port); Net::Buffer* netBuffer = new Net::Buffer(buffer, size); - Proxy* proxy = luax_newinstance(L, JIN_NETWORK_BUFFER); - proxy->bind(new Shared<Buffer>(netBuffer, JIN_NETWORK_BUFFER)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Buffer); + proxy->bind(new Shared<Buffer>(netBuffer, Jin_Lua_Buffer)); return 1; } @@ -102,7 +104,7 @@ namespace JinEngine LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_NETWORK_SOCKET); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Socket); proxy->release(); return 0; } @@ -120,7 +122,7 @@ namespace JinEngine { "configBlocking", l_configBlocking }, { 0, 0 } }; - luax_newtype(L, JIN_NETWORK_SOCKET, socket_function); + luax_newtype(L, Jin_Lua_Socket, socket_function); return 0; } diff --git a/src/lua/modules/net/je_lua_socket.h b/src/lua/modules/net/je_lua_socket.h new file mode 100644 index 0000000..83c08fb --- /dev/null +++ b/src/lua/modules/net/je_lua_socket.h @@ -0,0 +1,14 @@ +#ifndef __JE_LUA_SOCKET_H__ +#define __JE_LUA_SOCKET_H__ + +namespace JinEngine +{ + namespace Lua + { + + extern const char* Jin_Lua_Socket; + + } +} + +#endif
\ No newline at end of file diff --git a/src/lua/modules/thread/je_lua_thread.cpp b/src/lua/modules/thread/je_lua_thread.cpp index 290de6e..19b3374 100644 --- a/src/lua/modules/thread/je_lua_thread.cpp +++ b/src/lua/modules/thread/je_lua_thread.cpp @@ -1,5 +1,5 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "libjin/jin.h" #include "lua/jin.h" #include "lua/common/je_lua_common.h" @@ -10,13 +10,15 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_Thread = "Thread"; + typedef Shared<Thread>& SharedThread; int luaopen_thread(lua_State* L); static inline SharedThread checkThread(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_THREAD_THREAD); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Thread); return proxy->getShared<Thread>(); } @@ -27,7 +29,7 @@ namespace JinEngine luax_openlibs(L); luaopen_jin(L); luax_getglobal(L, MODULE_NAME); - Proxy* proxy = luax_newinstance(L, JIN_THREAD_THREAD); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Thread); shared.retain(); proxy->bind(&shared); luax_setfield(L, -2, "_curThread"); @@ -38,7 +40,7 @@ namespace JinEngine LUA_IMPLEMENT int l_thread_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_THREAD_THREAD); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Thread); proxy->release(); return 0; } @@ -209,7 +211,7 @@ namespace JinEngine { 0, 0 } }; - luax_newtype(L, JIN_THREAD_THREAD, thread_function); + luax_newtype(L, Jin_Lua_Thread, thread_function); return 0; } @@ -218,9 +220,9 @@ namespace JinEngine { const char* name = luax_checkstring(L, 1); const char* code = luax_checkstring(L, 2); - Proxy* proxy = luax_newinstance(L, JIN_THREAD_THREAD); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Thread); Thread* thread = new Thread(name, code, threadRunner); - proxy->bind(new Shared<Thread>(thread, JIN_THREAD_THREAD)); + proxy->bind(new Shared<Thread>(thread, Jin_Lua_Thread)); return 1; } diff --git a/src/lua/modules/thread/je_lua_thread.h b/src/lua/modules/thread/je_lua_thread.h index 112af94..a3e4e76 100644 --- a/src/lua/modules/thread/je_lua_thread.h +++ b/src/lua/modules/thread/je_lua_thread.h @@ -6,6 +6,8 @@ namespace JinEngine namespace Lua { + extern const char* Jin_Lua_Thread; + class Thread { public: diff --git a/src/lua/modules/time/je_lua_time.cpp b/src/lua/modules/time/je_lua_time.cpp index 4546337..b0e82de 100644 --- a/src/lua/modules/time/je_lua_time.cpp +++ b/src/lua/modules/time/je_lua_time.cpp @@ -2,7 +2,9 @@ #include "lua/common/je_lua_common.h" #include "lua/modules/luax.h" #include "libjin/jin.h" -#include "../types.h" + + +#include "je_lua_timer.h" using namespace JinEngine::Time; @@ -32,8 +34,8 @@ namespace JinEngine LUA_IMPLEMENT int l_newTimer(lua_State* L) { - Proxy* proxy = luax_newinstance(L, JIN_TIME_TIMER); - proxy->bind(new Shared<Timer>(new Timer(), JIN_TIME_TIMER)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Timer); + proxy->bind(new Shared<Timer>(new Timer(), Jin_Lua_Timer)); return 1; } diff --git a/src/lua/modules/time/je_lua_time.h b/src/lua/modules/time/je_lua_time.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/lua/modules/time/je_lua_time.h diff --git a/src/lua/modules/time/je_lua_timer.cpp b/src/lua/modules/time/je_lua_timer.cpp index 6e5c390..67f92e2 100644 --- a/src/lua/modules/time/je_lua_timer.cpp +++ b/src/lua/modules/time/je_lua_timer.cpp @@ -1,4 +1,4 @@ -#include "../types.h" + #include "lua/common/je_lua_callback.h" #include "lua/common/je_lua_common.h" #include "je_lua_timer.h" @@ -10,6 +10,10 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_Timer = "Timer"; + + const char* Jin_Lua_Handler = "Handler"; + typedef Shared<Timer>& SharedTimer; static Timer::TimerCallback timerCallback = [](void* data)->void @@ -26,7 +30,7 @@ namespace JinEngine LUA_IMPLEMENT inline SharedTimer checkTimer(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_TIME_TIMER); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Timer); return proxy->getShared<Timer>(); } @@ -42,8 +46,8 @@ namespace JinEngine for(int i = 4; i <= n; ++i) func->pushParam(i); Timer::Handler* handler = timer->every(s, timerCallback, func, finishCallback); - Proxy* proxy = luax_newinstance(L, JIN_TIME_HANDLER); - proxy->bind(new Shared<Timer::Handler>(handler, JIN_TIME_HANDLER)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Handler); + proxy->bind(new Shared<Timer::Handler>(handler, Jin_Lua_Handler)); return 1; } @@ -59,8 +63,8 @@ namespace JinEngine for (int i = 4; i <= n; ++i) func->pushParam(i); Timer::Handler* handler = timer->after(s, timerCallback, func, finishCallback); - Proxy* proxy = luax_newinstance(L, JIN_TIME_HANDLER); - proxy->bind(new Shared<Timer::Handler>(handler, JIN_TIME_HANDLER)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Handler); + proxy->bind(new Shared<Timer::Handler>(handler, Jin_Lua_Handler)); return 1; } @@ -77,8 +81,8 @@ namespace JinEngine for (int i = 5; i <= n; ++i) func->pushParam(i); Timer::Handler* handler = timer->repeat(s, count, timerCallback, func, finishCallback); - Proxy* proxy = luax_newinstance(L, JIN_TIME_HANDLER); - proxy->bind(new Shared<Timer::Handler>(handler, JIN_TIME_HANDLER)); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Handler); + proxy->bind(new Shared<Timer::Handler>(handler, Jin_Lua_Handler)); return 1; } @@ -93,9 +97,9 @@ namespace JinEngine LUA_IMPLEMENT int l_cancel(lua_State* L) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_TIME_TIMER); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_Timer); Timer* timer = p->getObject<Timer>(); - Proxy* ph = (Proxy*)luax_checktype(L, 2, JIN_TIME_HANDLER); + Proxy* ph = (Proxy*)luax_checktype(L, 2, Jin_Lua_Handler); Timer::Handler* handler = ph->getObject<Timer::Handler>(); timer->cancel(handler); return 0; @@ -103,7 +107,7 @@ namespace JinEngine LUA_IMPLEMENT int l_cancelAll(lua_State* L) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_TIME_TIMER); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_Timer); Timer* timer = p->getObject<Timer>(); timer->cancelAll(); return 0; @@ -111,7 +115,7 @@ namespace JinEngine LUA_IMPLEMENT int l_gc(lua_State* L) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_TIME_TIMER); + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_Timer); p->release(); return 0; } @@ -129,7 +133,7 @@ namespace JinEngine { 0, 0 } }; - luax_newtype(L, JIN_TIME_TIMER, f); + luax_newtype(L, Jin_Lua_Timer, f); return 0; } diff --git a/src/lua/modules/time/je_lua_timer.h b/src/lua/modules/time/je_lua_timer.h index 6382c38..18081e7 100644 --- a/src/lua/modules/time/je_lua_timer.h +++ b/src/lua/modules/time/je_lua_timer.h @@ -7,6 +7,10 @@ namespace JinEngine { namespace Lua { + + extern const char* Jin_Lua_Timer; + + extern const char* Jin_Lua_Handler; } } diff --git a/src/lua/modules/types.h b/src/lua/modules/types.h deleted file mode 100644 index 7e5c4fd..0000000 --- a/src/lua/modules/types.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __JIN_MODULES_TYPES_H -#define __JIN_MODULES_TYPES_H - -// graphics module -#define JIN_GRAPHICS_TEXTURE "Texture" -#define JIN_GRAPHICS_SHADER "Shader" -#define JIN_GRAPHICS_CANVAS "Canvas" -#define JIN_GRAPHICS_TEXT "Text" -#define JIN_GRAPHICS_TTFDATA "TTFData" -#define JIN_GRAPHICS_TTF "TTF" -#define JIN_GRAPHICS_TEXTUREFONT "TextureFont" -#define JIN_GRAPHICS_PAGE "Page" -#define JIN_GRAPHICS_BITMAP "Bitmap" -#define JIN_GRAPHICS_SPRITE "Sprite" -#define JIN_GRAPHICS_SPRITESHEET "SpriteSheet" -#define JIN_GRAPHICS_SPRITEBATCH "SpriteBatch" - -// audio module -#define JIN_AUDIO_SOURCE "Source" - -// thread module -#define JIN_THREAD_THREAD "Thread" - -// network module -#define JIN_NETWORK_SOCKET "Socket" -#define JIN_NETWORK_BUFFER "Buffer" - -// time module -#define JIN_TIME_TIMER "Timer" -#define JIN_TIME_HANDLER "Handler" - -#endif
\ No newline at end of file |