diff --git a/assets/NotoEmoji-Regular.ttf b/assets/NotoEmoji-Regular.ttf new file mode 100644 index 0000000..19b7bad Binary files /dev/null and b/assets/NotoEmoji-Regular.ttf differ diff --git a/main.cpp b/main.cpp index 77ac549..4d11ac9 100644 --- a/main.cpp +++ b/main.cpp @@ -1,12 +1,13 @@ #include #include #include +#include #include #include #include #include -void LoadFonts() +void load_fonts() { const Rml::String directory = "assets/"; @@ -48,17 +49,38 @@ int main() return -1; } - LoadFonts(); + load_fonts(); - if (Rml::ElementDocument* document = context->LoadDocument("assets/demo.rml")) + Rml::ElementDocument* document = context->LoadDocument("assets/demo.rml"); + if (document) { document->Show(); } + const std::wstring assets_path = std::filesystem::absolute( + std::filesystem::current_path() / "assets").wstring(); + + HANDLE hNotif = FindFirstChangeNotification(assets_path.c_str(), + TRUE, FILE_NOTIFY_CHANGE_LAST_WRITE); + bool running = true; while (running) { - // Handle input and window events. + if (const DWORD wait_result = WaitForSingleObject(hNotif, 100); + wait_result == WAIT_OBJECT_0) + { + if (document) + context->UnloadDocument(document); + context->Update(); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + document = context->LoadDocument("assets/demo.rml"); + if (document) + { + document->ReloadStyleSheet(); + document->Show(); + } + FindNextChangeNotification(hNotif); + } running = Backend::ProcessEvents(context); context->Update(); Backend::BeginFrame();