Skip to content
Snippets Groups Projects
Commit dfa62f08 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

expose lua scripts to asset system

parent daa97196
No related branches found
No related tags found
No related merge requests found
......@@ -23,15 +23,22 @@
#include "fggl/entity/module.hpp"
#include "fggl/script/engine.hpp"
#include "fggl/data/module.hpp"
#include "fggl/assets/packed/adapter.hpp"
namespace fggl::script::lua {
constexpr auto MIME_LUA = assets::from_mime("text/lua");
constexpr auto SCRIPT_LUA = assets::make_asset_type("script/lua");
struct Lua {
constexpr static const char* name = "fggl::script::lua";
constexpr static const std::array<modules::ModuleService, 1> provides = {
script::ScriptProvider::service
};
constexpr static const std::array<modules::ModuleService, 1> depends = {
data::SERVICE_STORAGE
constexpr static const std::array<modules::ModuleService, 2> depends = {
data::SERVICE_STORAGE,
assets::CheckinAdapted::service
};
static bool factory(modules::ModuleService name, modules::Services& serviceManager);
};
......
......@@ -21,11 +21,22 @@
namespace fggl::script::lua {
static assets::AssetTypeID is_lua(std::filesystem::path path) {
if ( path.extension() == ".lua" ) {
return SCRIPT_LUA;
}
return assets::INVALID_ASSET_TYPE;
}
bool Lua::factory(modules::ModuleService service, modules::Services &serviceManager) {
if ( service == ScriptProvider::service ) {
auto storageService = serviceManager.get<data::Storage>();
serviceManager.bind<ScriptProvider,LuaScriptProvider>(storageService);
auto *assetPacker = serviceManager.get<assets::CheckinAdapted>();
assetPacker->setLoader(MIME_LUA, assets::NEEDS_CHECKIN, is_lua);
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment