galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
LuaResource.cpp
Go to the documentation of this file.
1
7
8#include <sol/sol.hpp>
9
10#include "galaxy/core/ServiceLocator.hpp"
18
19#include "Lua.hpp"
20
21namespace galaxy
22{
23 namespace lua
24 {
26 {
27 auto& lua = core::ServiceLocator<sol::state>::ref();
28
29 auto anims_type = lua.new_usertype<resource::Animations>("Animations", sol::no_constructor);
30 anims_type["clear"] = &resource::Animations::clear;
31 anims_type["empty"] = &resource::Animations::empty;
32 anims_type["get"] = &resource::Animations::get;
33 anims_type["has"] = &resource::Animations::has;
34 anims_type["keys"] = &resource::Animations::keys;
35 anims_type["size"] = &resource::Animations::size;
36 anims_type["insert"] = &resource::Animations::insert;
37 anims_type["load"] = &resource::Animations::load;
38 anims_type["load_folder"] = &resource::Animations::load_folder;
39
40 auto fonts_type = lua.new_usertype<resource::Fonts>("Fonts", sol::no_constructor);
41 fonts_type["clear"] = &resource::Fonts::clear;
42 fonts_type["empty"] = &resource::Fonts::empty;
43 fonts_type["get"] = &resource::Fonts::get;
44 fonts_type["has"] = &resource::Fonts::has;
45 fonts_type["keys"] = &resource::Fonts::keys;
46 fonts_type["size"] = &resource::Fonts::size;
47 fonts_type["insert"] = &resource::Fonts::insert;
48 fonts_type["load"] = &resource::Fonts::load;
49 fonts_type["load_folder"] = &resource::Fonts::load_folder;
50
51 auto soundcache_type = lua.new_usertype<resource::SoundCache>("SoundCaches", sol::no_constructor);
52 soundcache_type["clear"] = &resource::SoundCache::clear;
53 soundcache_type["empty"] = &resource::SoundCache::empty;
54 soundcache_type["get"] = &resource::SoundCache::get;
55 soundcache_type["has"] = &resource::SoundCache::has;
56 soundcache_type["keys"] = &resource::SoundCache::keys;
57 soundcache_type["size"] = &resource::SoundCache::size;
58 soundcache_type["insert"] = &resource::SoundCache::insert;
59 soundcache_type["load"] = &resource::SoundCache::load;
60 soundcache_type["load_folder"] = &resource::SoundCache::load_folder;
61
62 auto musiccache_type = lua.new_usertype<resource::MusicCache>("MusicCache", sol::no_constructor);
63 musiccache_type["clear"] = &resource::MusicCache::clear;
64 musiccache_type["empty"] = &resource::MusicCache::empty;
65 musiccache_type["get"] = &resource::MusicCache::get;
66 musiccache_type["has"] = &resource::MusicCache::has;
67 musiccache_type["keys"] = &resource::MusicCache::keys;
68 musiccache_type["size"] = &resource::MusicCache::size;
69 musiccache_type["insert"] = &resource::MusicCache::insert;
70 musiccache_type["load"] = &resource::MusicCache::load;
71 musiccache_type["load_folder"] = &resource::MusicCache::load_folder;
72
73 auto voicecache_type = lua.new_usertype<resource::VoiceCache>("VoiceCache", sol::no_constructor);
74 voicecache_type["clear"] = &resource::VoiceCache::clear;
75 voicecache_type["empty"] = &resource::VoiceCache::empty;
76 voicecache_type["get"] = &resource::VoiceCache::get;
77 voicecache_type["has"] = &resource::VoiceCache::has;
78 voicecache_type["keys"] = &resource::VoiceCache::keys;
79 voicecache_type["size"] = &resource::VoiceCache::size;
80 voicecache_type["insert"] = &resource::VoiceCache::insert;
81 voicecache_type["load"] = &resource::VoiceCache::load;
82 voicecache_type["load_folder"] = &resource::VoiceCache::load_folder;
83
84 auto videocache_type = lua.new_usertype<resource::VideoCache>("VideoCache", sol::no_constructor);
85 videocache_type["clear"] = &resource::VideoCache::clear;
86 videocache_type["empty"] = &resource::VideoCache::empty;
87 videocache_type["get"] = &resource::VideoCache::get;
88 videocache_type["has"] = &resource::VideoCache::has;
89 videocache_type["keys"] = &resource::VideoCache::keys;
90 videocache_type["size"] = &resource::VideoCache::size;
91 videocache_type["insert"] = &resource::VideoCache::insert;
92 videocache_type["load"] = &resource::VideoCache::load;
93 videocache_type["load_folder"] = &resource::VideoCache::load_folder;
94
95 auto prefabs_type = lua.new_usertype<resource::Prefabs>("Prefabs", sol::no_constructor);
96 prefabs_type["clear"] = &resource::Prefabs::clear;
97 prefabs_type["empty"] = &resource::Prefabs::empty;
98 prefabs_type["get"] = &resource::Prefabs::get;
99 prefabs_type["has"] = &resource::Prefabs::has;
100 prefabs_type["keys"] = &resource::Prefabs::keys;
101 prefabs_type["size"] = &resource::Prefabs::size;
102 prefabs_type["insert"] = &resource::Prefabs::insert;
103 prefabs_type["load"] = &resource::Prefabs::load;
104 prefabs_type["load_folder"] = &resource::Prefabs::load_folder;
105
106 auto scripts_type = lua.new_usertype<resource::Scripts>("Scripts", sol::no_constructor);
107 scripts_type["clear"] = &resource::Scripts::clear;
108 scripts_type["empty"] = &resource::Scripts::empty;
109 scripts_type["get"] = &resource::Scripts::get;
110 scripts_type["has"] = &resource::Scripts::has;
111 scripts_type["keys"] = &resource::Scripts::keys;
112 scripts_type["size"] = &resource::Scripts::size;
113 scripts_type["insert"] = &resource::Scripts::insert;
114 scripts_type["load"] = &resource::Scripts::load;
115 scripts_type["load_folder"] = &resource::Scripts::load_folder;
116
117 auto shaders_type = lua.new_usertype<resource::Shaders>("Shaders", sol::no_constructor);
118 shaders_type["clear"] = &resource::Shaders::clear;
119 shaders_type["empty"] = &resource::Shaders::empty;
120 shaders_type["get"] = &resource::Shaders::get;
121 shaders_type["has"] = &resource::Shaders::has;
122 shaders_type["keys"] = &resource::Shaders::keys;
123 shaders_type["size"] = &resource::Shaders::size;
124 shaders_type["insert"] = &resource::Shaders::insert;
125 shaders_type["load"] = &resource::Shaders::load;
126 shaders_type["load_folder"] = &resource::Shaders::load_folder;
127
128 auto textures_type = lua.new_usertype<resource::Textures>("Textures", sol::no_constructor);
129 textures_type["clear"] = &resource::Textures::clear;
130 textures_type["empty"] = &resource::Textures::empty;
131 textures_type["get"] = &resource::Textures::get;
132 textures_type["has"] = &resource::Textures::has;
133 textures_type["keys"] = &resource::Textures::keys;
134 textures_type["size"] = &resource::Textures::size;
135 textures_type["insert"] = &resource::Textures::insert;
136 textures_type["load"] = &resource::Textures::load;
137 textures_type["load_folder"] = &resource::Textures::load_folder;
138 }
139 } // namespace lua
140} // namespace galaxy
Cache for resources such as audio, fonts, etc.
Definition Cache.hpp:31
void clear()
Destroy resources.
Definition Cache.hpp:118
void load(const std::string &file)
Load a resource.
Definition Cache.hpp:55
std::size_t size() const
Get amount of resources cached.
Definition Cache.hpp:151
void insert(std::string_view id, std::unique_ptr< Resource > &resource)
Insert a resource directly into the cache.
Definition Cache.hpp:82
void load_folder(const std::string &dir)
Load resources of a specific type.
Definition Cache.hpp:66
bool has(std::string_view id)
Check if a resource exists.
Definition Cache.hpp:131
Resource * get(std::string_view id)
Retrieve a resource.
Definition Cache.hpp:103
const meta::vector< std::string > & keys()
Get a list of keys in the cache.
Definition Cache.hpp:173
bool empty() const
Does the cache have any resources.
Definition Cache.hpp:142
void inject_resources()
Timer.hpp galaxy.
Definition Async.hpp:17