From f2df11883cdd6a79aacea4bbd6c29a236a992e99 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 18 Feb 2017 19:42:36 +0100 Subject: [PATCH] [Proxy] Use IW4x icon for toast --- src/Components/Modules/Toast.cpp | 13 +++++++++++++ src/Components/Modules/Toast.hpp | 2 ++ src/Steam/Proxy.cpp | 12 ++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/Toast.cpp b/src/Components/Modules/Toast.cpp index 5864a9ad..501db34a 100644 --- a/src/Components/Modules/Toast.cpp +++ b/src/Components/Modules/Toast.cpp @@ -20,6 +20,19 @@ namespace Components return WinToastLib::WinToast::instance()->showToast(toast, Toast::ToastHandler); } + std::string Toast::GetIcon() + { + char ourPath[MAX_PATH] = { 0 }; + std::string file(ourPath, GetModuleFileNameA(GetModuleHandle(nullptr), ourPath, sizeof(ourPath))); + + auto pos = file.find_last_of("/\\"); + if(pos != std::string::npos) file = file.substr(0, pos); + + file.append("\\iw4x\\images\\icon.png"); + Utils::String::Replace(file, "/", "\\"); + return file; + } + void Toast::Draw(UIToast* toast) { if (!toast) return; diff --git a/src/Components/Modules/Toast.hpp b/src/Components/Modules/Toast.hpp index fc579094..fced4813 100644 --- a/src/Components/Modules/Toast.hpp +++ b/src/Components/Modules/Toast.hpp @@ -18,6 +18,8 @@ namespace Components static void Show(std::string image, std::string title, std::string description, int length); static bool ShowNative(const WinToastLib::WinToastTemplate& toast); + static std::string GetIcon(); + private: class UIToast { diff --git a/src/Steam/Proxy.cpp b/src/Steam/Proxy.cpp index e3f89e60..b5aa36db 100644 --- a/src/Steam/Proxy.cpp +++ b/src/Steam/Proxy.cpp @@ -275,7 +275,11 @@ namespace Steam void Proxy::StartSteamIfNecessary() { - if (!Steam::Enabled() || Proxy::GetSteamDirectory().empty()) return; + if (Proxy::GetSteamDirectory().empty() +#ifndef DEBUG + || !Steam::Enabled() +#endif + ) return; HKEY hRegKey; DWORD pid = 0; @@ -305,9 +309,13 @@ namespace Steam std::string steamExe = Proxy::GetSteamDirectory() + "\\steam.exe"; if (::Utils::IO::FileExists(steamExe)) { - Components::Toast::Template templ = Components::Toast::Template(Components::Toast::Template::TextTwoLines); + Components::Toast::Template templ = Components::Toast::Template(Components::Toast::Template::ImageWithTwoLines); templ.setTextField(L"IW4x", Components::Toast::Template::FirstLine); templ.setTextField(L"Starting Steam...", Components::Toast::Template::SecondLine); + + std::string icon = Components::Toast::GetIcon(); + templ.setImagePath(std::wstring(icon.begin(), icon.end())); + Components::Toast::ShowNative(templ); ShellExecuteA(nullptr, nullptr, steamExe.data(), "-silent", nullptr, 1);