Setting up data, and added SQLite and TOML
This commit is contained in:
36
src/main.cpp
36
src/main.cpp
@@ -1,4 +1,6 @@
|
||||
#include <RmlUi/Config/Config.h>
|
||||
#include <RmlUi/Core/Core.h>
|
||||
#include <RmlUi/Core/DataModelHandle.h>
|
||||
#include <RmlUi/Core/ElementDocument.h>
|
||||
#include <RmlUi/Core/Math.h>
|
||||
#include <RmlUi/Lua/Interpreter.h>
|
||||
@@ -10,18 +12,37 @@
|
||||
#include <RmlUi/Core/Context.h>
|
||||
#include <lua.h>
|
||||
#include <RmlUi/Debugger/Debugger.h>
|
||||
|
||||
|
||||
#include "critter.hpp"
|
||||
#include <sqlite3.h>
|
||||
|
||||
static bool is_initalized = false;
|
||||
static bool is_running = false;
|
||||
static Rml::Context *ctx;
|
||||
|
||||
struct AppData {
|
||||
Rml::String page_title = "Main";
|
||||
sqlite3 *db;
|
||||
} app_data;
|
||||
|
||||
void Shutdown() {
|
||||
Rml::Shutdown();
|
||||
Backend::Shutdown();
|
||||
}
|
||||
|
||||
bool SetupDataBinding(Rml::Context *context, Rml::DataModelHandle &model_handle) {
|
||||
Rml::DataModelConstructor dmc = ctx->CreateDataModel("app_data");
|
||||
if (!dmc) {
|
||||
std::cout << "[ERROR] could not create 'app_data' data binding.";
|
||||
return false;
|
||||
}
|
||||
|
||||
dmc.Bind("page_title", &app_data.page_title);
|
||||
|
||||
model_handle = dmc.GetModelHandle();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Initalize() {
|
||||
if (!Backend::Initialize("CritterFolio", 800, 600, true)) {
|
||||
std::cout << "[ERROR] Failed to initalize the backend.";
|
||||
@@ -41,11 +62,16 @@ bool Initalize() {
|
||||
|
||||
Rml::Debugger::Initialise(ctx);
|
||||
|
||||
|
||||
|
||||
// lua_State *L = Rml::Lua::Interpreter::GetLuaState();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Update(Rml::DataModelHandle model_handle) {
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello world!\n";
|
||||
@@ -59,6 +85,10 @@ int main() {
|
||||
|
||||
is_running = true;
|
||||
|
||||
Rml::DataModelHandle app_data_handle;
|
||||
|
||||
SetupDataBinding(ctx, app_data_handle);
|
||||
|
||||
Rml::ElementDocument *doc;
|
||||
doc = ctx->LoadDocument("./assets/main.rml");
|
||||
if (!doc) {
|
||||
@@ -72,6 +102,8 @@ int main() {
|
||||
while(is_running) {
|
||||
is_running = Backend::ProcessEvents(ctx);
|
||||
|
||||
Update(app_data_handle);
|
||||
|
||||
ctx->Update();
|
||||
Backend::BeginFrame();
|
||||
ctx->Render();
|
||||
|
||||
Reference in New Issue
Block a user