From a66b747366c8dc36cb4ed6f40efee679e9516749 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Thu, 22 Jun 2017 00:53:02 -0700 Subject: [PATCH] DolphinWX: show simple message about scanning in statusbar. --- Source/Core/DolphinWX/Frame.cpp | 3 ++- Source/Core/DolphinWX/Frame.h | 2 +- Source/Core/DolphinWX/FrameAui.cpp | 3 +-- Source/Core/DolphinWX/FrameTools.cpp | 14 ++++++-------- Source/Core/DolphinWX/GameListCtrl.cpp | 11 +++++++++++ Source/Core/DolphinWX/Main.cpp | 2 +- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index d156ce8148..29a7b526c3 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -337,7 +337,8 @@ CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, wxRect geo wxFrame::CreateToolBar(wxTB_DEFAULT_STYLE | wxTB_TEXT | wxTB_FLAT)->Realize(); // Give it a status bar - SetStatusBar(CreateStatusBar(2, wxST_SIZEGRIP, ID_STATUSBAR)); + SetStatusBar( + CreateStatusBar(2, wxSTB_SIZEGRIP | wxSTB_ELLIPSIZE_END | wxSTB_SHOW_TIPS, ID_STATUSBAR)); if (!SConfig::GetInstance().m_InterfaceStatusbar) GetStatusBar()->Hide(); diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index 68bc2342fa..094df16173 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -102,7 +102,7 @@ public: void GameListRescan(); void ToggleLogWindow(bool bShow); void ToggleLogConfigWindow(bool bShow); - void StatusBarMessage(const char* Text, ...); + void StatusBarMessage(const char* format, ...); void ClearStatusBar(); void BootGame(const std::string& filename); bool RendererHasFocus(); diff --git a/Source/Core/DolphinWX/FrameAui.cpp b/Source/Core/DolphinWX/FrameAui.cpp index bfc2328be9..9ab5a035e7 100644 --- a/Source/Core/DolphinWX/FrameAui.cpp +++ b/Source/Core/DolphinWX/FrameAui.cpp @@ -511,8 +511,7 @@ void CFrame::OnPerspectiveMenu(wxCommandEvent& event) return; } SaveIniPerspectives(); - GetStatusBar()->SetStatusText( - StrToWxStr(std::string("Saved " + m_perspectives[m_active_perspective].name)), 0); + StatusBarMessage("Saved %s", m_perspectives[m_active_perspective].name.c_str()); break; case IDM_PERSPECTIVES_ADD_PANE_TOP: AddPane(ADD_PANE_TOP); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index ddb5f99b1e..007c6595db 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -1133,18 +1133,16 @@ void CFrame::ClearStatusBar() } } -void CFrame::StatusBarMessage(const char* Text, ...) +void CFrame::StatusBarMessage(const char* format, ...) { - const int MAX_BYTES = 1024 * 10; - char Str[MAX_BYTES]; - va_list ArgPtr; - va_start(ArgPtr, Text); - vsnprintf(Str, MAX_BYTES, Text, ArgPtr); - va_end(ArgPtr); + va_list args; + va_start(args, format); + std::string msg = StringFromFormatV(format, args); + va_end(args); if (this->GetStatusBar()->IsEnabled()) { - this->GetStatusBar()->SetStatusText(StrToWxStr(Str), 0); + this->GetStatusBar()->SetStatusText(StrToWxStr(msg), 0); } } diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index b79919b539..4e89a7051c 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -740,6 +740,15 @@ bool GameListCtrl::SyncCacheFile(bool write) void GameListCtrl::RescanList() { + auto post_status = [&](const wxString& status) { + auto event = new wxCommandEvent(wxEVT_HOST_COMMAND, IDM_UPDATE_STATUS_BAR); + event->SetInt(0); + event->SetString(status); + QueueEvent(event); + }; + + post_status(_("Scanning...")); + const std::vector search_extensions = {".gcm", ".tgc", ".iso", ".ciso", ".gcz", ".wbfs", ".wad", ".dol", ".elf"}; // TODO This could process paths iteratively as they are found @@ -783,6 +792,8 @@ void GameListCtrl::RescanList() // Post UI event to update the displayed list QueueEvent(new wxCommandEvent(DOLPHIN_EVT_REFRESH_GAMELIST)); + post_status(_("Scan complete!")); + SyncCacheFile(true); } diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index 8e50921d80..70f34ab482 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -478,7 +478,7 @@ void Host_SetWiiMoteConnectionState(int _State) event.SetString(_("Wii Remote Connected")); break; } - // Update field 1 or 2 + // The second field is used for auxiliary info such as this event.SetInt(1); NOTICE_LOG(WIIMOTE, "%s", static_cast(event.GetString().c_str()));