[Friends] Better toasts

This commit is contained in:
momo5502 2017-02-12 20:36:38 +01:00
parent c51b14a0f2
commit e6fb206d21
5 changed files with 37 additions and 13 deletions

View File

@ -198,14 +198,7 @@ namespace Components
{ {
if (ConnectProtocol::Used()) if (ConnectProtocol::Used())
{ {
if (!FastFiles::Ready()) Command::Execute(Utils::String::VA("connect %s", ConnectProtocol::ConnectString.data()), false);
{
QuickPatch::Once(ConnectProtocol::Invocation);
}
else
{
Command::Execute(Utils::String::VA("connect %s", ConnectProtocol::ConnectString.data()), false);
}
} }
} }
@ -218,7 +211,7 @@ namespace Components
}); });
// Invocation handler // Invocation handler
QuickPatch::Once(ConnectProtocol::Invocation); QuickPatch::OnReady(ConnectProtocol::Invocation);
ConnectProtocol::InstallProtocol(); ConnectProtocol::InstallProtocol();
ConnectProtocol::EvaluateProtocol(); ConnectProtocol::EvaluateProtocol();

View File

@ -113,7 +113,8 @@ namespace Components
Friends::SortList(); Friends::SortList();
if(Dvar::Var("cl_notifyFriendState").get<bool>() && gotOnline) int notify = Dvar::Var("cl_notifyFriendState").get<int>();
if(gotOnline && (notify == -1 || (notify == 1 && !Game::CL_IsCgameInitialized())))
{ {
Toast::Show("cardicon_weed", entry->name, "Is playing IW4x", 3000); Toast::Show("cardicon_weed", entry->name, "Is playing IW4x", 3000);
} }
@ -417,7 +418,7 @@ namespace Components
{ {
if (Dedicated::IsEnabled() ||ZoneBuilder::IsEnabled()) return; if (Dedicated::IsEnabled() ||ZoneBuilder::IsEnabled()) return;
Dvar::Register<bool>("cl_anonymous", false, Game::DVAR_FLAG_SAVED, ""); Dvar::Register<bool>("cl_anonymous", false, Game::DVAR_FLAG_SAVED, "");
Dvar::Register<bool>("cl_notifyFriendState", false, Game::DVAR_FLAG_SAVED, ""); // False by default, might set default to true and add that to the options! Dvar::Register<int>("cl_notifyFriendState", 1, -1, 1, Game::DVAR_FLAG_SAVED, "");
// Hook Live_ShowFriendsList // Hook Live_ShowFriendsList
Utils::Hook(0x4D6C70, []() Utils::Hook(0x4D6C70, []()

View File

@ -2,6 +2,8 @@
namespace Components namespace Components
{ {
bool QuickPatch::ReadyPassed = false;
Utils::Signal<QuickPatch::Callback> QuickPatch::ReadySignal;
Utils::Signal<QuickPatch::Callback> QuickPatch::ShutdownSignal; Utils::Signal<QuickPatch::Callback> QuickPatch::ShutdownSignal;
int64_t* QuickPatch::GetStatsID() int64_t* QuickPatch::GetStatsID()
@ -10,6 +12,23 @@ namespace Components
return &id; return &id;
} }
void QuickPatch::OnReady(Utils::Slot<QuickPatch::Callback> callback)
{
if(QuickPatch::ReadyPassed) QuickPatch::Once(callback);
else QuickPatch::ReadySignal.connect(callback);
}
void QuickPatch::ReadyHandler()
{
if (!FastFiles::Ready()) QuickPatch::Once(QuickPatch::ReadyHandler);
else
{
QuickPatch::ReadyPassed = true;
QuickPatch::ReadySignal();
QuickPatch::ReadySignal.clear();
}
}
void QuickPatch::OnShutdown(Utils::Slot<QuickPatch::Callback> callback) void QuickPatch::OnShutdown(Utils::Slot<QuickPatch::Callback> callback)
{ {
QuickPatch::ShutdownSignal.connect(callback); QuickPatch::ShutdownSignal.connect(callback);
@ -174,6 +193,9 @@ namespace Components
QuickPatch::QuickPatch() QuickPatch::QuickPatch()
{ {
QuickPatch::ReadyPassed = false;
QuickPatch::Once(QuickPatch::ReadyHandler);
// Make sure preDestroy is called when the game shuts down // Make sure preDestroy is called when the game shuts down
QuickPatch::OnShutdown(Loader::PreDestroy); QuickPatch::OnShutdown(Loader::PreDestroy);
@ -485,6 +507,7 @@ namespace Components
QuickPatch::~QuickPatch() QuickPatch::~QuickPatch()
{ {
QuickPatch::ReadySignal.clear();
QuickPatch::ShutdownSignal.clear(); QuickPatch::ShutdownSignal.clear();
} }

View File

@ -18,16 +18,20 @@ namespace Components
static void UnlockStats(); static void UnlockStats();
static void OnShutdown(Utils::Slot<Callback> callback); static void OnShutdown(Utils::Slot<Callback> callback);
static void OnFrame(Utils::Slot<Callback> callback); static void OnFrame(Utils::Slot<Callback> callback);
static void OnReady(Utils::Slot<Callback> callback);
static void Once(Utils::Slot<Callback> callback); static void Once(Utils::Slot<Callback> callback);
private: private:
static bool ReadyPassed;
static Utils::Signal<Callback> ReadySignal;
static Utils::Signal<Callback> ShutdownSignal; static Utils::Signal<Callback> ShutdownSignal;
static int64_t* GetStatsID(); static int64_t* GetStatsID();
static void ShutdownStub(int num); static void ShutdownStub(int num);
static void ReadyHandler();
static void SelectStringTableEntryInDvarStub(); static void SelectStringTableEntryInDvarStub();
static int MsgReadBitsCompressCheckSV(const char *from, char *to, int size); static int MsgReadBitsCompressCheckSV(const char *from, char *to, int size);

View File

@ -125,7 +125,10 @@ namespace Components
Toast::Toast() Toast::Toast()
{ {
Renderer::OnFrame(Toast::Handler); QuickPatch::OnReady([]()
{
Renderer::OnFrame(Toast::Handler);
});
Command::Add("testtoast", [] (Command::Params*) Command::Add("testtoast", [] (Command::Params*)
{ {