Discord rpc fixes
This commit is contained in:
parent
aef84a037e
commit
50ca5bc5c9
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -12,7 +12,7 @@
|
||||
url = https://github.com/TsudaKageyu/minhook.git
|
||||
[submodule "deps/discord-rpc"]
|
||||
path = deps/discord-rpc
|
||||
url = https://github.com/discord/discord-rpc.git
|
||||
url = https://github.com/fedddddd/discord-rpc.git
|
||||
[submodule "deps/asmjit"]
|
||||
path = deps/asmjit
|
||||
url = https://github.com/asmjit/asmjit.git
|
||||
|
@ -135,12 +135,7 @@ function addrequest(request)
|
||||
font = CoD.TextSettings.BodyFontBold.Font
|
||||
})
|
||||
|
||||
local requesttext = nil
|
||||
if (request.discriminator == "0") then
|
||||
requesttext = Engine.Localize("LUA_MENU_DISCORD_REQUEST", truncatename(request.username, 18))
|
||||
else
|
||||
requesttext = Engine.Localize("LUA_MENU_DISCORD_REQUEST_DISCRIMINATOR", truncatename(request.username, 18), request.discriminator)
|
||||
end
|
||||
local requesttext = Engine.Localize("LUA_MENU_DISCORD_REQUEST", truncatename(request.displayname, 18))
|
||||
|
||||
username:setText(requesttext)
|
||||
|
||||
@ -178,8 +173,8 @@ function addrequest(request)
|
||||
return button
|
||||
end
|
||||
|
||||
local accepttext = Engine.Localize("LUA_MENU_DISCORD_ACCEPT", Engine.GetBinding("discord_accept"))
|
||||
local denytext = Engine.Localize("LUA_MENU_DISCORD_DENY", Engine.GetBinding("discord_deny"))
|
||||
local accepttext = Engine.Localize("LUA_MENU_DISCORD_ACCEPT", game:getcommandbind("discord_accept"))
|
||||
local denytext = Engine.Localize("LUA_MENU_DISCORD_DENY", game:getcommandbind("discord_deny"))
|
||||
|
||||
buttons:addElement(createbutton(accepttext, true))
|
||||
buttons:addElement(createbutton(denytext))
|
||||
|
2
deps/discord-rpc
vendored
2
deps/discord-rpc
vendored
@ -1 +1 @@
|
||||
Subproject commit 963aa9f3e5ce81a4682c6ca3d136cddda614db33
|
||||
Subproject commit b3383798b353c31ea6770fee673740c27f6e3489
|
@ -267,6 +267,22 @@ namespace discord
|
||||
}, scheduler::pipeline::main);
|
||||
}
|
||||
|
||||
std::string get_display_name(const DiscordUser* user)
|
||||
{
|
||||
if (user->discriminator != nullptr && user->discriminator != "0"s)
|
||||
{
|
||||
return std::format("{}#{}", user->username, user->discriminator);
|
||||
}
|
||||
else if (user->globalName[0] != 0)
|
||||
{
|
||||
return user->globalName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return user->username;
|
||||
}
|
||||
}
|
||||
|
||||
void join_request(const DiscordUser* request)
|
||||
{
|
||||
console::debug("Discord: Join request from %s (%s)\n", request->username, request->userId);
|
||||
@ -283,6 +299,7 @@ namespace discord
|
||||
const std::string avatar = request->avatar;
|
||||
const std::string discriminator = request->discriminator;
|
||||
const std::string username = request->username;
|
||||
const auto display_name = get_display_name(request);
|
||||
|
||||
const auto now = std::chrono::high_resolution_clock::now();
|
||||
auto iter = last_requests.find(user_id);
|
||||
@ -309,6 +326,7 @@ namespace discord
|
||||
request_table.set("discriminator", discriminator);
|
||||
request_table.set("userid", user_id);
|
||||
request_table.set("username", username);
|
||||
request_table.set("displayname", display_name);
|
||||
|
||||
ui_scripting::notify("discord_join_request",
|
||||
{
|
||||
|
@ -335,6 +335,29 @@ namespace ui_scripting
|
||||
material.data()));
|
||||
};
|
||||
|
||||
game_type["getcommandbind"] = [](const game&, const std::string& cmd)
|
||||
{
|
||||
const auto binding = ::game::Key_GetBindingForCmd(cmd.data());
|
||||
auto key = -1;
|
||||
for (auto i = 0; i < 256; i++)
|
||||
{
|
||||
if (::game::playerKeys[0].keys[i].binding == binding)
|
||||
{
|
||||
key = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (key == -1)
|
||||
{
|
||||
return ::game::UI_SafeTranslateString("KEY_UNBOUND");
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto loc_string = ::game::Key_KeynumToString(key, 1, 0);
|
||||
return ::game::UI_SafeTranslateString(loc_string);
|
||||
}
|
||||
};
|
||||
|
||||
auto server_list_table = table();
|
||||
lua["serverlist"] = server_list_table;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user