Setting up data, and added SQLite and TOML
This commit is contained in:
@@ -14,8 +14,14 @@ find_package(Lua REQUIRED)
|
||||
pkg_check_modules(LUNASVG REQUIRED IMPORTED_TARGET lunasvg)
|
||||
add_library(lunasvg::lunasvg ALIAS PkgConfig::LUNASVG)
|
||||
|
||||
pkg_check_modules(SQLITE3 REQUIRED IMPORTED_TARGET sqlite3)
|
||||
add_library(sqlite3::sqlite3 ALIAS PkgConfig::SQLITE3)
|
||||
|
||||
find_package(toml11 CONFIG REQUIRED)
|
||||
|
||||
find_package(RmlUi CONFIG REQUIRED)
|
||||
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
src/main.cpp
|
||||
vendor/rmlui_backend/RmlUi_Backend_GLFW_GL3.cpp
|
||||
@@ -37,6 +43,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Freetype::Freetype
|
||||
lunasvg::lunasvg
|
||||
glfw
|
||||
sqlite3::sqlite3
|
||||
toml11::toml11
|
||||
)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
<link type="text/rcss" href="styles/main.rcss" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body data-model="app_data">
|
||||
<h1>{{page_title}}</h1>
|
||||
<p>Hello world!</p>
|
||||
</body>
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
raylib
|
||||
glfw
|
||||
libGL
|
||||
clang-tools
|
||||
libX11
|
||||
libXcursor
|
||||
libXrandr
|
||||
@@ -67,7 +66,8 @@
|
||||
freetype
|
||||
lunasvg
|
||||
lua
|
||||
lua-language-server
|
||||
sqlite.dev
|
||||
toml11
|
||||
];
|
||||
in
|
||||
{
|
||||
|
||||
35
src/critter.hpp
Normal file
35
src/critter.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CritterEvent {
|
||||
public:
|
||||
std::string name;
|
||||
std::string date;
|
||||
std::string time;
|
||||
std::string description;
|
||||
};
|
||||
|
||||
class CritterDocument {
|
||||
public:
|
||||
std::string name;
|
||||
std::string doc_type;
|
||||
std::string cached_path;
|
||||
};
|
||||
|
||||
class Critter {
|
||||
|
||||
enum Sex {Male, Female};
|
||||
|
||||
public:
|
||||
std::string name;
|
||||
Sex sex;
|
||||
std::string birthdate;
|
||||
Critter *mother;
|
||||
Critter *father;
|
||||
std::vector<Critter*> children;
|
||||
std::string notes;
|
||||
std::vector<CritterEvent> events;
|
||||
std::vector<CritterDocument> documents;
|
||||
};
|
||||
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