diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index c6712d17..84537e05 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -846,7 +846,6 @@ float ChatGui4::render(float time_delta) { ImGuiInputTextFlags_CtrlEnterForNewLine; if (ImGui::InputTextMultiline("##text_input", &_text_input_buffer, {-0.001f, -0.001f}, input_flags)) { - //_mm.sendMessage(*_selected_contact, MessageType::TEXT, text_buffer); _rmm.sendText(*_selected_contact, _text_input_buffer); _text_input_buffer.clear(); evil_enter_looses_focus_hack = true; diff --git a/src/main_screen.cpp b/src/main_screen.cpp index d49a6c2c..8da67ca3 100644 --- a/src/main_screen.cpp +++ b/src/main_screen.cpp @@ -46,7 +46,7 @@ MainScreen::MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme cg(conf, os, rmm, cr, sdlrtu, contact_tc, msg_tc, theme), sw(conf), osui(os), - tuiu(tc, conf), + tuiu(tc, conf, &tpi), tdch(tpi), smui(os, sm), dvt(os, sm, sdlrtu) diff --git a/src/start_screen.cpp b/src/start_screen.cpp index 15796c55..7eaad59c 100644 --- a/src/start_screen.cpp +++ b/src/start_screen.cpp @@ -168,7 +168,7 @@ StartScreen::StartScreen(const std::vector& args, SDL_Renderer } Screen* StartScreen::render(float, bool&) { - const float TEXT_LOAD_WIDTH = ImGui::CalcTextSize("load").x; + const float TEXT_PROCEED_WIDTH = ImGui::CalcTextSize("proceed").x; const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing(); @@ -283,7 +283,7 @@ Screen* StartScreen::render(float, bool&) { // load but file missing ImGui::BeginDisabled(); - ImGui::Button("load", {TEXT_LOAD_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f}); + ImGui::Button("proceed", {TEXT_PROCEED_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f}); ImGui::EndDisabled(); if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled)) { @@ -293,14 +293,14 @@ Screen* StartScreen::render(float, bool&) { // new but file exists ImGui::BeginDisabled(); - ImGui::Button("load", {TEXT_LOAD_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f}); + ImGui::Button("proceed", {TEXT_PROCEED_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f}); ImGui::EndDisabled(); if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled)) { ImGui::SetTooltip("file already exists"); } } else { - if (ImGui::Button("load", {TEXT_LOAD_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f})) { + if (ImGui::Button("proceed", {TEXT_PROCEED_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f})) { auto new_screen = std::make_unique(std::move(_conf), _renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths); return new_screen.release(); diff --git a/src/tox_ui_utils.cpp b/src/tox_ui_utils.cpp index b1bc3bd0..fd954b6b 100644 --- a/src/tox_ui_utils.cpp +++ b/src/tox_ui_utils.cpp @@ -2,6 +2,8 @@ #include "./tox_client.hpp" +#include + #include #include @@ -13,8 +15,9 @@ ToxUIUtils::ToxUIUtils( ToxClient& tc, - ConfigModelI& conf -) : _tc(tc), _conf(conf) { + ConfigModelI& conf, + ToxPrivateI* tp +) : _tc(tc), _conf(conf), _tp(tp) { } void ToxUIUtils::render(void) { @@ -44,6 +47,30 @@ void ToxUIUtils::render(void) { ImGui::EndMenu(); } + + switch (_tc.toxSelfGetConnectionStatus()) { + case TOX_CONNECTION_NONE: + ImGui::TextColored({1.0,0.5,0.5,0.8}, "Offline"); + break; + case TOX_CONNECTION_TCP: + ImGui::TextColored({0.0,1.0,0.8,0.8}, "Online-TCP"); + break; + case TOX_CONNECTION_UDP: + ImGui::TextColored({0.3,1.0,0.0,0.8}, "Online-UDP"); + break; + } + + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Tox Onion connection status"); + } + + if (_tp != nullptr) { + ImGui::Text("(%d)", _tp->toxDHTGetNumCloselist()); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Number of connected DHT nodes"); + } + } + ImGui::EndMenuBar(); } @@ -64,6 +91,12 @@ void ToxUIUtils::render(void) { // TODO: add string_view variant to utils auto [_, err_r] = _tc.toxFriendAdd(hex2bin(std::string{tox_id}), message); err = err_r; + + { // reset everything + for (size_t i = 0; i < sizeof(tox_id); i++) { + tox_id[i] = '\0'; + } + } } if (err != Tox_Err_Friend_Add::TOX_ERR_FRIEND_ADD_OK) { ImGui::SameLine(); diff --git a/src/tox_ui_utils.hpp b/src/tox_ui_utils.hpp index 0a00ccb3..02a9af2a 100644 --- a/src/tox_ui_utils.hpp +++ b/src/tox_ui_utils.hpp @@ -2,6 +2,7 @@ class ToxClient; struct ConfigModelI; +struct ToxPrivateI; class ToxUIUtils { bool _show_add_friend_window {false}; @@ -9,11 +10,13 @@ class ToxUIUtils { ToxClient& _tc; ConfigModelI& _conf; + ToxPrivateI* _tp{nullptr}; public: ToxUIUtils( ToxClient& tc, - ConfigModelI& conf + ConfigModelI& conf, + ToxPrivateI* tp = nullptr ); void render(void);