diff --git a/.gitignore b/.gitignore index 689234b..d0942bc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ engine modules/* logs/* +*.pyc +*.a *.d *.o *.meta diff --git a/custom_modules/sdl/DejaVuSans.ttf b/DejaVuSans.ttf similarity index 100% rename from custom_modules/sdl/DejaVuSans.ttf rename to DejaVuSans.ttf diff --git a/custom_modules/mqtt_server/libmqtt_server.a b/custom_modules/mqtt_server/libmqtt_server.a deleted file mode 100644 index 36f84cb..0000000 Binary files a/custom_modules/mqtt_server/libmqtt_server.a and /dev/null differ diff --git a/custom_modules/sdl/SCsub b/custom_modules/sdl/SCsub new file mode 100644 index 0000000..0cc3aaf --- /dev/null +++ b/custom_modules/sdl/SCsub @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +Import("env_mod") +Import("env") + +env_mod.core_sources = [] + +env_mod.add_source_files(env_mod.core_sources, "*.cpp") +env_mod.add_source_files(env_mod.core_sources, "core/*.cpp") +env_mod.add_source_files(env_mod.core_sources, "renderer/*.cpp") +env_mod.add_source_files(env_mod.core_sources, "widgets/*.cpp") + + +env_mod.Prepend(LINKFLAGS=["-lSDL2_ttf"]) +env.Prepend(LINKFLAGS=["-lSDL2_ttf"]) + +env_mod.Prepend(CPPPATH=["#../custom_modules/sdl"]) +env.Prepend(CPPPATH=["#../custom_modules/sdl"]) + +# Build it all as a library +lib = env_mod.add_library("sdl", env_mod.core_sources) +env.Prepend(LIBS=[lib]) diff --git a/custom_modules/sdl/detect.py b/custom_modules/sdl/detect.py new file mode 100644 index 0000000..9fb59ec --- /dev/null +++ b/custom_modules/sdl/detect.py @@ -0,0 +1,46 @@ +import os +import platform +import sys + + +def is_active(): + return True + + +def get_name(): + return "sdl2" + + +def can_build(): + if os.name == "posix" or sys.platform == "darwin": + x11_error = os.system("pkg-config --version > /dev/null") + if x11_error: + return False + + libevent_err = os.system("pkg-config sdl2 --modversion --silence-errors > /dev/null ") + + if libevent_err: + print("sdl2 not found!") + return False + + print("sdl2 found!") + + return True + + return False + + +def get_opts(): + return [] + +def get_flags(): + + return [] + + +def configure(env): + env.ParseConfig("pkg-config sdl2 --cflags --libs") + + env.Append(CPPDEFINES=["SDL_PRESENT"]) + + diff --git a/main.cpp b/main.cpp index e06b787..9cb65ee 100644 --- a/main.cpp +++ b/main.cpp @@ -2,9 +2,9 @@ #include #include -#include "core/http/web_application.h" -#include "core/file_cache.h" #include "core/bry_http/http_server.h" +#include "core/file_cache.h" +#include "core/http/web_application.h" #include "app/ic_application.h" @@ -16,6 +16,13 @@ #include "custom_modules/mqtt_server/mqtt_server.h" +#include + +#include +#include "application.h" +#include "renderer/renderer.h" +#include "impl_application.h" + #define MAIN_CLASS ICApplication void create_databases() { @@ -86,18 +93,33 @@ int main(int argc, char **argv) { MQTTServer *mqtt_server = new MQTTServer(); mqtt_server->initialize(); - mqtt_server->add_local_session("a/b", [](const std::string &client_id, const std::vector &data, void* obj){ reinterpret_cast(obj)->mqtt_sensor_callback(client_id, data); }, app); + mqtt_server->add_local_session( + "a/b", [](const std::string &client_id, const std::vector &data, void *obj) { reinterpret_cast(obj)->mqtt_sensor_callback(client_id, data); }, app); + + Renderer *renderer = new Renderer(); + ImplApplication *sdl_app = new ImplApplication(); if (!migrate) { printf("Initialized!\n"); - mqtt_server->run_async(); - server->main_loop(); + //mqtt_server->run_async(); + //server->main_loop(); + + TTF_Init(); + + while (sdl_app->running) { + sdl_app->main_loop(); + } + + TTF_Quit(); } else { printf("Running migrations.\n"); app->migrate(); } + delete sdl_app; + delete renderer; + delete mqtt_server; delete server; delete app; diff --git a/custom_modules/sdl/ti.bmp b/ti.bmp similarity index 100% rename from custom_modules/sdl/ti.bmp rename to ti.bmp