File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change
1
+ " hello world"
Original file line number Diff line number Diff line change 1
1
#include < imgui.h>
2
2
#include < app.hpp>
3
+ #include < djson/json.hpp>
4
+ #include < log.hpp>
3
5
4
6
namespace miracle {
5
7
namespace {
@@ -8,7 +10,13 @@ constexpr auto context_ci = le::Context::CreateInfo{
8
10
};
9
11
} // namespace
10
12
11
- App::App () : m_context(context_ci) {}
13
+ App::App () : m_context(context_ci), m_data_loader(le::FileDataLoader::upfind(" assets" )) {
14
+ bind_services ();
15
+
16
+ // test code, remove later.
17
+ auto json = dj::Json{};
18
+ if (m_services.get <le::IDataLoader>().load_json (json, " test_file.json" )) { log.info (" loaded JSON: {}" , json); }
19
+ }
12
20
13
21
void App::run () {
14
22
while (m_context.is_running ()) {
@@ -19,4 +27,11 @@ void App::run() {
19
27
m_context.present ();
20
28
}
21
29
}
30
+
31
+ void App::bind_services () {
32
+ m_services.bind (&m_context);
33
+ // m_data_loader is bound to both the interface and the concrete class for use through either type.
34
+ m_services.bind <le::IDataLoader>(&m_data_loader);
35
+ m_services.bind <le::FileDataLoader>(&m_data_loader);
36
+ }
22
37
} // namespace miracle
Original file line number Diff line number Diff line change 1
1
#pragma once
2
2
#include < le2d/context.hpp>
3
+ #include < le2d/file_data_loader.hpp>
4
+ #include < le2d/service_locator.hpp>
3
5
4
6
namespace miracle {
5
7
class App {
@@ -9,6 +11,11 @@ class App {
9
11
void run ();
10
12
11
13
private:
14
+ void bind_services ();
15
+
12
16
le::Context m_context;
17
+ le::FileDataLoader m_data_loader{};
18
+
19
+ le::ServiceLocator m_services{};
13
20
};
14
21
} // namespace miracle
You can’t perform that action at this time.
0 commit comments