refactor file from messages to objects (#27)

* part 1 move files from messages to objects tomato - did not touch chat_gui yet, but image loaders and other stuff
* part 1.1
* part 2, mostly chatgui - also ngcft1 behind the scenes
* part 3 - port over rest, except for avatar_manager, which is effectivly disabled
* fix surface missused causing bmp loader to crash
* fixing small issues and small forward refactor
This commit is contained in:
Erik Scholz
2024-07-31 18:10:52 +02:00
committed by GitHub
parent f27d178b78
commit 2abf09ac06
17 changed files with 621 additions and 348 deletions

View File

@ -2,20 +2,25 @@
#include <solanaceae/util/utils.hpp>
#include <solanaceae/object_store/meta_components.hpp>
#include <solanaceae/object_store/meta_components_file.hpp>
#include "./os_comps.hpp"
#include <imgui/imgui.h>
#include <solanaceae/message3/components.hpp>
namespace MM {
template<> void ComponentEditorWidget<ObjectStore::Components::ID>(entt::basic_registry<Object>& registry, Object entity) {
auto& c = registry.get<ObjectStore::Components::ID>(entity);
const auto str = bin2hex(c.v);
if (ImGui::SmallButton("copy")) {
ImGui::SetClipboardText(str.c_str());
}
ImGui::SameLine();
ImGui::TextUnformatted(str.c_str());
}
#if 0
template<> void ComponentEditorWidget<Message::Components::Transfer::FileInfo>(entt::basic_registry<Object>& registry, Object entity) {
auto& c = registry.get<Message::Components::Transfer::FileInfo>(entity);
@ -54,14 +59,30 @@ template<> void ComponentEditorWidget<Message::Components::Transfer::FileInfoLoc
}
}
template<> void ComponentEditorWidget<Message::Components::Transfer::BytesReceived>(entt::basic_registry<Object>& registry, Object entity) {
auto& c = registry.get<Message::Components::Transfer::BytesReceived>(entity);
ImGui::Text("total bytes received: %lu", c.total);
#endif
template<> void ComponentEditorWidget<ObjComp::F::SingleInfo>(entt::basic_registry<Object>& registry, Object entity) {
auto& c = registry.get<ObjComp::F::SingleInfo>(entity);
if (!c.file_name.empty()) {
ImGui::Text("file name: %s", c.file_name.c_str());
}
ImGui::Text("file size: %lu", c.file_size);
}
template<> void ComponentEditorWidget<Message::Components::Transfer::BytesSent>(entt::basic_registry<Object>& registry, Object entity) {
auto& c = registry.get<Message::Components::Transfer::BytesSent>(entity);
ImGui::Text("total bytes sent: %lu", c.total);
template<> void ComponentEditorWidget<ObjComp::F::SingleInfoLocal>(entt::basic_registry<Object>& registry, Object entity) {
auto& c = registry.get<ObjComp::F::SingleInfoLocal>(entity);
if (!c.file_path.empty()) {
ImGui::Text("file path: %s", c.file_path.c_str());
}
}
template<> void ComponentEditorWidget<ObjComp::Ephemeral::File::TransferStats>(entt::basic_registry<Object>& registry, Object entity) {
auto& c = registry.get<ObjComp::Ephemeral::File::TransferStats>(entity);
ImGui::Text("upload rate : %.1f bytes/s", c.rate_up);
ImGui::Text("download rate: %.1f bytes/s", c.rate_down);
ImGui::Text("total bytes uploaded : %lu bytes", c.total_up);
ImGui::Text("total bytes downloaded: %lu bytes", c.total_down);
}
} // MM
@ -74,10 +95,20 @@ ObjectStoreUI::ObjectStoreUI(
_ee.registerComponent<ObjectStore::Components::ID>("ID");
_ee.registerComponent<ObjectStore::Components::DataCompressionType>("DataCompressionType");
_ee.registerComponent<Message::Components::Transfer::FileInfo>("Transfer::FileInfo");
_ee.registerComponent<Message::Components::Transfer::FileInfoLocal>("Transfer::FileInfoLocal");
_ee.registerComponent<Message::Components::Transfer::BytesReceived>("Transfer::BytesReceived");
_ee.registerComponent<Message::Components::Transfer::BytesSent>("Transfer::BytesSent");
_ee.registerComponent<ObjComp::Ephemeral::FilePath>("Ephemeral::FilePath");
_ee.registerComponent<ObjComp::F::SingleInfo>("File::SingleInfo");
_ee.registerComponent<ObjComp::F::SingleInfoLocal>("File::SingleInfoLocal");
_ee.registerComponent<ObjComp::F::Collection>("File::Collection");
_ee.registerComponent<ObjComp::F::CollectionInfo>("File::CollectionInfo");
_ee.registerComponent<ObjComp::F::CollectionInfoLocal>("File::CollectionInfoLocal");
_ee.registerComponent<ObjComp::F::LocalHaveBitset>("File::LocalHaveBitset");
_ee.registerComponent<ObjComp::F::RemoteHaveBitset>("File::RemoteHaveBitset");
_ee.registerComponent<ObjComp::Ephemeral::File::DownloadPriority>("Ephemeral::File::DownloadPriority");
_ee.registerComponent<ObjComp::Ephemeral::File::ReadHeadHint>("Ephemeral::File::ReadHeadHint");
_ee.registerComponent<ObjComp::Ephemeral::File::TransferStats>("Ephemeral::File::TransferStats");
_ee.registerComponent<ObjComp::Ephemeral::File::TransferStatsSeparated>("Ephemeral::File::TransferStatsSeparated");
}
void ObjectStoreUI::render(void) {