From adf7c3f20b87b67fd10321aa0bbfa636302eccf0 Mon Sep 17 00:00:00 2001 From: iota97 Date: Wed, 15 Sep 2021 09:56:36 +0200 Subject: [PATCH] Fix jumpy resolve while typing --- UI/GameSettingsScreen.cpp | 19 +++++++++---------- UI/GameSettingsScreen.h | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index b20236c225..9e94717fb1 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1858,12 +1858,8 @@ void HostnameSelectScreen::CreatePopupContents(UI::ViewGroup *parent) { parent->Add(ipRows_); listIP.clear(); listIP.shrink_to_fit(); - errorView_ = parent->Add(new TextView(n->T("Invalid IP or hostname"), ALIGN_HCENTER, false, new LinearLayoutParams(Margins(0, 10, 0, 0)))); - errorView_->SetTextColor(0xFF3030FF); - errorView_->SetVisibility(V_GONE); - progressView_ = parent->Add(new TextView(n->T("Validating address..."), ALIGN_HCENTER, false, new LinearLayoutParams(Margins(0, 10, 0, 0)))); - progressView_->SetVisibility(V_GONE); + progressView_->SetVisibility(V_INVISIBLE); } void HostnameSelectScreen::SendEditKey(int keyCode, int flags) { @@ -1950,6 +1946,8 @@ void HostnameSelectScreen::ResolverThread() { } bool HostnameSelectScreen::CanComplete(DialogResult result) { + auto n = GetI18NCategory("Networking"); + if (result != DR_OK) return true; @@ -1981,12 +1979,12 @@ bool HostnameSelectScreen::CanComplete(DialogResult result) { lastResolvedResult_ = toResolveResult_; if (lastResolvedResult_) { - errorView_->SetVisibility(UI::V_GONE); + progressView_->SetVisibility(UI::V_INVISIBLE); } else { - errorView_->SetVisibility(UI::V_VISIBLE); + progressView_->SetText(n->T("Invalid IP or hostname")); + progressView_->SetTextColor(0xFF3030FF); + progressView_->SetVisibility(UI::V_VISIBLE); } - progressView_->SetVisibility(UI::V_GONE); - return true; } @@ -1998,8 +1996,9 @@ bool HostnameSelectScreen::CanComplete(DialogResult result) { toResolve_ = value; resolverCond_.notify_one(); + progressView_->SetText(n->T("Validating address...")); + progressView_->SetTextColor(0xFFFFFFFF); progressView_->SetVisibility(UI::V_VISIBLE); - errorView_->SetVisibility(UI::V_GONE); return false; } diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index c82bef73ca..fb892d6ea9 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -213,7 +213,6 @@ private: std::string *value_; UI::TextEdit *addrView_ = nullptr; - UI::TextView *errorView_ = nullptr; UI::TextView *progressView_ = nullptr; UI::LinearLayout *ipRows_ = nullptr;