impr: Various web build improvements, API cleanup (#1541)

This commit is contained in:
Nik
2024-02-10 23:31:05 +01:00
committed by GitHub
parent 4b20e35fd2
commit bcbcb1f23c
43 changed files with 977 additions and 847 deletions

View File

@@ -17,6 +17,9 @@ namespace hex {
AutoReset<std::optional<std::string>> s_layoutStringToLoad;
AutoReset<std::vector<LayoutManager::Layout>> s_layouts;
AutoReset<std::vector<LayoutManager::LoadCallback>> s_loadCallbacks;
AutoReset<std::vector<LayoutManager::StoreCallback>> s_storeCallbacks;
bool s_layoutLocked = false;
}
@@ -130,4 +133,24 @@ namespace hex {
s_layoutLocked = locked;
}
void LayoutManager::registerLoadCallback(const LoadCallback &callback) {
s_loadCallbacks->push_back(callback);
}
void LayoutManager::registerStoreCallback(const StoreCallback &callback) {
s_storeCallbacks->push_back(callback);
}
void LayoutManager::onLoad(std::string_view line) {
for (const auto &callback : *s_loadCallbacks)
callback(line);
}
void LayoutManager::onStore(ImGuiTextBuffer *buffer) {
for (const auto &callback : *s_storeCallbacks)
callback(buffer);
}
}