diff --git a/src/object_store_ui.cpp b/src/object_store_ui.cpp index d50a932b..7ea9cf4a 100644 --- a/src/object_store_ui.cpp +++ b/src/object_store_ui.cpp @@ -1,21 +1,83 @@ #include "./object_store_ui.hpp" +#include #include #include #include +namespace MM { + +template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { + auto& c = registry.get(entity); + + const auto str = bin2hex(c.v); + ImGui::TextUnformatted(str.c_str()); +} + +template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { + auto& c = registry.get(entity); + + ImGui::Text("Total size: %lu", c.total_size); + if (ImGui::BeginTable("file list", 2, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingFixedFit)) { + ImGui::TableSetupColumn("name", ImGuiTableColumnFlags_WidthStretch); + ImGui::TableSetupColumn("size", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableHeadersRow(); + + for (const auto& entry : c.file_list) { + ImGui::TableNextColumn(); + ImGui::TextUnformatted(entry.file_name.c_str()); + + ImGui::TableNextColumn(); + ImGui::Text("%lu", entry.file_size); + } + + ImGui::EndTable(); + } +} + +template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { + auto& c = registry.get(entity); + + if (ImGui::BeginTable("file list", 1, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingFixedFit)) { + ImGui::TableSetupColumn("name", ImGuiTableColumnFlags_WidthStretch); + //ImGui::TableSetupColumn("size", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableHeadersRow(); + + for (const auto& entry : c.file_list) { + ImGui::TableNextColumn(); + ImGui::TextUnformatted(entry.c_str()); + } + + ImGui::EndTable(); + } +} + +template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { + auto& c = registry.get(entity); + ImGui::Text("total bytes received: %lu", c.total); +} + +template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { + auto& c = registry.get(entity); + ImGui::Text("total bytes sent: %lu", c.total); +} + +} // MM + ObjectStoreUI::ObjectStoreUI( ObjectStore2& os ) : _os(os) { - _ee.show_window = false; + _ee.show_window = true; _ee.registerComponent("ID"); _ee.registerComponent("DataCompressionType"); _ee.registerComponent("Transfer::FileInfo"); _ee.registerComponent("Transfer::FileInfoLocal"); + _ee.registerComponent("Transfer::BytesReceived"); + _ee.registerComponent("Transfer::BytesSent"); } void ObjectStoreUI::render(void) {