Add setdiscordstate command
This commit is contained in:
parent
21efd3eceb
commit
39ed85b23e
@ -1,8 +1,11 @@
|
||||
#include <stdinc.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
#include "scheduler.hpp"
|
||||
|
||||
#include "game/game.hpp"
|
||||
|
||||
#include "scheduler.hpp"
|
||||
#include "command.hpp"
|
||||
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include <discord_rpc.h>
|
||||
@ -12,6 +15,7 @@ namespace discord
|
||||
namespace
|
||||
{
|
||||
DiscordRichPresence discord_presence;
|
||||
std::string state;
|
||||
|
||||
void update_discord()
|
||||
{
|
||||
@ -32,7 +36,7 @@ namespace discord
|
||||
const auto mapname = game::UI_SafeTranslateString(utils::string::va("PRESENCE_SP_%s", map));
|
||||
|
||||
discord_presence.details = mapname;
|
||||
discord_presence.state = "";
|
||||
discord_presence.state = state.data();
|
||||
|
||||
if (!discord_presence.startTimestamp)
|
||||
{
|
||||
@ -64,6 +68,17 @@ namespace discord
|
||||
scheduler::loop(update_discord, scheduler::pipeline::async, 5s);
|
||||
|
||||
initialized_ = true;
|
||||
|
||||
command::add("setdiscordstate", [](const command::params& params)
|
||||
{
|
||||
const std::string _state = params.join(1);
|
||||
|
||||
scheduler::once([_state]()
|
||||
{
|
||||
state = _state;
|
||||
update_discord();
|
||||
}, scheduler::pipeline::async);
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
@ -74,6 +89,7 @@ namespace discord
|
||||
ZeroMemory(&discord_presence, sizeof(discord_presence));
|
||||
|
||||
discord_presence.instance = 1;
|
||||
discord_presence.state = "";
|
||||
|
||||
Discord_UpdatePresence(&discord_presence);
|
||||
}
|
||||
|
@ -170,6 +170,11 @@ namespace scripting::lua
|
||||
command::execute(command, false);
|
||||
};
|
||||
|
||||
game_type["setdiscordstate"] = [](const game&, const std::string& state)
|
||||
{
|
||||
command::execute(utils::string::va("setdiscordstate %s", state.data()), false);
|
||||
};
|
||||
|
||||
game_type["say"] = [](const game&, const std::string& msg)
|
||||
{
|
||||
chat::print(msg);
|
||||
|
@ -76,7 +76,7 @@ namespace game
|
||||
|
||||
WEAK symbol<const char*> g_assetNames{0xBEF280};
|
||||
|
||||
WEAK symbol<gentity_s> g_entities{0x52DDEC0};
|
||||
WEAK symbol<gentity_s> g_entities{0x52DDDA0};
|
||||
|
||||
WEAK symbol<int> keyCatchers{0x203F3C0};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user