add reload
This commit is contained in:
BIN
assets/NotoEmoji-Regular.ttf
Normal file
BIN
assets/NotoEmoji-Regular.ttf
Normal file
Binary file not shown.
30
main.cpp
30
main.cpp
@@ -1,12 +1,13 @@
|
||||
#include <print>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <RmlUi/Core.h>
|
||||
#include <RmlUi/Debugger.h>
|
||||
#include <RmlUi_Backend.h>
|
||||
#include <RmlUi_Include_Windows.h>
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user