diff options
author | chai <chaifix@163.com> | 2018-11-03 21:11:41 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-11-03 21:11:41 +0800 |
commit | 281f8feabffd69928a0a0f08aa31f70b36f5e6bd (patch) | |
tree | a22413447a5480a5dffe625c677ad7c4140350c5 /src/lua/modules/graphics/je_lua_graphics.cpp | |
parent | f6ef5d6c0188e7dc6b39803ca37fe736f0eb3962 (diff) |
*增加游戏目录选择
Diffstat (limited to 'src/lua/modules/graphics/je_lua_graphics.cpp')
-rw-r--r-- | src/lua/modules/graphics/je_lua_graphics.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp index 6324e00..7efb2e7 100644 --- a/src/lua/modules/graphics/je_lua_graphics.cpp +++ b/src/lua/modules/graphics/je_lua_graphics.cpp @@ -128,30 +128,30 @@ namespace JinEngine { const char* f = luax_checkstring(L, 1); AssetDatabase* fs = AssetDatabase::get(); - if (!fs->exists(f)) + Buffer b; + try { - error(L, "No such image file %s", f); - goto fail; + if (!fs->exists(f)) + throw Exception("No such image file %s.", f); + fs->read(f, b); } - Buffer b; - if (!fs->read(f, b)) + catch (Exception& e) { error(L, "Failed to read image %s", f); - goto fail; + luax_pushnil(L); + return 1; } bitmap = Bitmap::createBitmap(&b, b.size()); if (bitmap == nullptr) { error(L, "Failed to decode image file %s", f); - goto fail; + luax_pushnil(L); + return 1; } } Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_BITMAP, sizeof(Proxy)); proxy->bind(new Ref<Bitmap>(bitmap, JIN_GRAPHICS_BITMAP)); return 1; - fail: - luax_pushnil(L); - return 1; } /* jin.graphics.newTexture(bitmap) */ |