[Proxy] Use IW4x icon for toast

This commit is contained in:
momo5502 2017-02-18 19:42:36 +01:00
parent 0535070402
commit f2df11883c
3 changed files with 25 additions and 2 deletions

View File

@ -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;

View File

@ -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
{

View File

@ -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);