chore: remove WinToast
This commit is contained in:
parent
d6c93e6966
commit
c99fb7c6a0
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -29,9 +29,6 @@
|
|||||||
[submodule "deps/udis86"]
|
[submodule "deps/udis86"]
|
||||||
path = deps/udis86
|
path = deps/udis86
|
||||||
url = https://github.com/vmt/udis86.git
|
url = https://github.com/vmt/udis86.git
|
||||||
[submodule "deps/WinToast"]
|
|
||||||
path = deps/WinToast
|
|
||||||
url = https://github.com/mohabouje/WinToast.git
|
|
||||||
[submodule "deps/zlib"]
|
[submodule "deps/zlib"]
|
||||||
path = deps/zlib
|
path = deps/zlib
|
||||||
url = https://github.com/madler/zlib.git
|
url = https://github.com/madler/zlib.git
|
||||||
|
1
deps/WinToast
vendored
1
deps/WinToast
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit a78ce469b456c06103b3b30d4bd37e7bb80da30c
|
|
@ -13,6 +13,8 @@
|
|||||||
#include <utils/hook.hpp>
|
#include <utils/hook.hpp>
|
||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
|
#define ALLOW_CUSTOM_BOT_NAMES
|
||||||
|
|
||||||
namespace bots
|
namespace bots
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
|
@ -1,109 +0,0 @@
|
|||||||
#include "toast.hpp"
|
|
||||||
#include "string.hpp"
|
|
||||||
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable: 6387)
|
|
||||||
#include <wintoastlib.h>
|
|
||||||
#pragma warning(pop)
|
|
||||||
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
bool initialize()
|
|
||||||
{
|
|
||||||
static bool initialized = false;
|
|
||||||
static bool success = false;
|
|
||||||
if (initialized)
|
|
||||||
{
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
auto* instance = WinToastLib::WinToast::instance();
|
|
||||||
if (!instance)
|
|
||||||
{
|
|
||||||
success = false;
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
instance->setAppName(L"s1-mod");
|
|
||||||
instance->setAppUserModelId(
|
|
||||||
WinToastLib::WinToast::configureAUMI(L"AlterWare", L"s1-mod", L"", L"20201212"));
|
|
||||||
|
|
||||||
WinToastLib::WinToast::WinToastError error;
|
|
||||||
success = instance->initialize(&error);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
class toast_handler : public WinToastLib::IWinToastHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void toastActivated() const override
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void toastActivated(const int /*actionIndex*/) const override
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void toastFailed() const override
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void toastDismissed(WinToastDismissalReason /*state*/) const override
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toast::toast(const int64_t id)
|
|
||||||
: id_(id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
toast::operator bool() const
|
|
||||||
{
|
|
||||||
return this->id_ >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void toast::hide() const
|
|
||||||
{
|
|
||||||
if (this->operator bool())
|
|
||||||
{
|
|
||||||
WinToastLib::WinToast::instance()->hideToast(this->id_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toast toast::show(const std::string& title, const std::string& text)
|
|
||||||
{
|
|
||||||
if (!initialize())
|
|
||||||
{
|
|
||||||
return toast{-1};
|
|
||||||
}
|
|
||||||
|
|
||||||
WinToastLib::WinToastTemplate toast_template(WinToastLib::WinToastTemplate::Text02);
|
|
||||||
toast_template.setTextField(string::convert(title), WinToastLib::WinToastTemplate::FirstLine);
|
|
||||||
toast_template.setTextField(string::convert(text), WinToastLib::WinToastTemplate::SecondLine);
|
|
||||||
toast_template.setDuration(WinToastLib::WinToastTemplate::Long);
|
|
||||||
|
|
||||||
return toast{WinToastLib::WinToast::instance()->showToast(toast_template, new toast_handler())};
|
|
||||||
}
|
|
||||||
|
|
||||||
toast toast::show(const std::string& title, const std::string& text, const std::string& image)
|
|
||||||
{
|
|
||||||
if (!initialize())
|
|
||||||
{
|
|
||||||
return {-1};
|
|
||||||
}
|
|
||||||
|
|
||||||
WinToastLib::WinToastTemplate toast_template(WinToastLib::WinToastTemplate::ImageAndText02);
|
|
||||||
toast_template.setTextField(string::convert(title), WinToastLib::WinToastTemplate::FirstLine);
|
|
||||||
toast_template.setTextField(string::convert(text), WinToastLib::WinToastTemplate::SecondLine);
|
|
||||||
toast_template.setDuration(WinToastLib::WinToastTemplate::Long);
|
|
||||||
toast_template.setImagePath(string::convert(image));
|
|
||||||
|
|
||||||
return {WinToastLib::WinToast::instance()->showToast(toast_template, new toast_handler())};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
class toast
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static toast show(const std::string& title, const std::string& text);
|
|
||||||
static toast show(const std::string& title, const std::string& text, const std::string& image);
|
|
||||||
|
|
||||||
operator bool() const;
|
|
||||||
void hide() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
toast(int64_t id);
|
|
||||||
int64_t id_;
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user