From e7db39d20a19269ed462934d60c8b2feef29d612 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sat, 21 Oct 2023 18:07:06 +0200 Subject: [PATCH] small debuggabilty improvements (scouting for an avatar bug) --- src/chat_gui4.cpp | 18 ++++++++++++------ src/chat_gui4.hpp | 3 ++- src/settings_window.cpp | 2 +- src/tox_avatar_manager.cpp | 10 ++++++---- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index f36a07b4..89f17654 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -154,11 +154,11 @@ void ChatGui4::render(void) { if (ImGui::BeginChild("message_log", {0, -100}, false, ImGuiWindowFlags_MenuBar)) { if (ImGui::BeginMenuBar()) { - ImGui::Checkbox("show extra info", &_show_chat_extra_info); - if (ImGui::SmallButton("test")) { - _cr.emplace_or_replace(*_selected_contact, "tomato_v1_256.png"); - _cr.emplace_or_replace(*_selected_contact); - std::cout << "DEBUG: added AvatarFile comp to contact\n"; + if (ImGui::BeginMenu("debug")) { + ImGui::Checkbox("show extra info", &_show_chat_extra_info); + ImGui::Checkbox("show avatar transfers", &_show_chat_avatar_tf); + + ImGui::EndMenu(); } ImGui::EndMenuBar(); } @@ -466,7 +466,13 @@ void ChatGui4::renderMessageBodyText(Message3Registry& reg, const Message3 e) { } void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { - if (reg.all_of(e) && reg.get(e).kind == 1) { + if ( + !_show_chat_avatar_tf + && ( + reg.all_of(e) + && reg.get(e).kind == 1 + ) + ) { // TODO: this looks ugly ImGui::TextDisabled("set avatar"); return; diff --git a/src/chat_gui4.hpp b/src/chat_gui4.hpp index 73b57397..df7d3754 100644 --- a/src/chat_gui4.hpp +++ b/src/chat_gui4.hpp @@ -31,7 +31,8 @@ class ChatGui4 { // TODO: per contact std::string _text_input_buffer; - bool _show_chat_extra_info {true}; + bool _show_chat_extra_info {false}; + bool _show_chat_avatar_tf {false}; float TEXT_BASE_WIDTH {1}; float TEXT_BASE_HEIGHT {1}; diff --git a/src/settings_window.cpp b/src/settings_window.cpp index 44681200..e67e2615 100644 --- a/src/settings_window.cpp +++ b/src/settings_window.cpp @@ -109,7 +109,7 @@ void SettingsWindow::render(void) { if (ImGui::BeginMenuBar()) { ImGui::Separator(); if (ImGui::BeginMenu("Settings")) { - if (ImGui::MenuItem("show settings window")) { + if (ImGui::MenuItem("settings window")) { _show_window = true; } ImGui::EndMenu(); diff --git a/src/tox_avatar_manager.cpp b/src/tox_avatar_manager.cpp index 8efa480a..cd98ed53 100644 --- a/src/tox_avatar_manager.cpp +++ b/src/tox_avatar_manager.cpp @@ -140,14 +140,14 @@ void ToxAvatarManager::checkMsg(Message3Handle h) { const auto& file_info = h.get(); + const auto contact = h.get().c; + // TCS-2.2.4 if (file_info.total_size > 65536ul) { // TODO: mark handled? return; // too large } - const auto contact = h.get().c; - // TCS-2.2.10 if (file_info.file_list.empty() || file_info.file_list.front().file_name.empty() || file_info.total_size == 0) { // reset @@ -186,16 +186,18 @@ void ToxAvatarManager::checkMsg(Message3Handle h) { h.emplace_or_replace(); } else { - const auto& supposed_file_hash = h.get().id; - // check file id for existing hash if (std::filesystem::is_regular_file(file_path)) { + //const auto& supposed_file_hash = h.get().id; // load file // hash file //_t.toxHash(); + std::filesystem::remove(file_path); // hack, hard replace existing file } + std::cout << "TAM: accepted avatar ft\n"; + // if not already on disk _accept_queue.push_back(AcceptEntry{h, file_path}); }