Skip to content

Commit

Permalink
Merge tiny discord rpc fixes etternagame#1122
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Jan 23, 2022
2 parents 6c694d3 + 7603f8f commit e01aea9
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ local t = Def.ActorFrame {
BeginCommand = function(self)
screen = SCREENMAN:GetTopScreen()
screen:AddInputCallback(evalInput)
updateDiscordStatus(true)
end,
OnCommand = function(self)
local score = SCOREMAN:GetMostRecentScore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local t = Def.ActorFrame {
Name = "GameplayElementsController",

BeginCommand = function(self)
updateDiscordStatusForGameplay()
updateDiscordStatus(false)
updateNowPlaying()

-- queue so it doesnt reach the children
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ t[#t+1] = LoadActor("../_mouse.lua")

-- header
t[#t+1] = LoadActorWithParams("../playerInfoFrame/main.lua", {visualizer = themeConfig:get_data().global.ShowVisualizer, screen = "ScreenSelectMusic"})
updateDiscordStatusForMenus()

return t
33 changes: 0 additions & 33 deletions Themes/Rebirth/Scripts/98 util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -437,39 +437,6 @@ function MiniToReceptorSize(mini)
return (1 - mini/2)
end

-- read the function name
function updateDiscordStatusForGameplay()
local profile = GetPlayerOrMachineProfile(PLAYER_1)
local song = GAMESTATE:GetCurrentSong()
local steps = GAMESTATE:GetCurrentSteps()
-- Discord thingies
local largeImageTooltip = string.format(
"%s: %5.2f",
profile:GetDisplayName(),
profile:GetPlayerRating()
)
local mode = GAMESTATE:GetGameplayMode()
local detail = string.format(
"%s: %s [%s]",
song:GetDisplayMainTitle(),
string.gsub(getCurRateDisplayString(), "Music", ""),
song:GetGroupName()
)
if mode == "GameplayMode_Replay" then
detail = "Replaying: "..detail
elseif mode == "GameplayMode_Practice" then
detail = "Practicing: "..detail
end
-- truncated to 128 characters(discord hard limit)
detail = #detail < 128 and detail or string.sub(detail, 1, 124) .. "..."
local state = string.format(
"MSD: %05.2f",
steps:GetMSD(getCurRateValue(), 1)
)
local endTime = os.time() + GetPlayableTime()
GAMESTATE:UpdateDiscordPresence(largeImageTooltip, detail, state, endTime)
end

-- writes to the install directory a nowplaying.txt
-- will be blank if not in gameplay
-- useful for stream overlays
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,29 +950,6 @@ if GAMESTATE:IsPlayerEnabled() then
end

t[#t + 1] = LoadActor("../offsetplot")

local score = SCOREMAN:GetMostRecentScore()
if not score then
score = SCOREMAN:GetTempReplayScore()
end
-- Discord thingies
local largeImageTooltip =
GetPlayerOrMachineProfile(PLAYER_1):GetDisplayName() ..
": " .. string.format("%5.2f", GetPlayerOrMachineProfile(PLAYER_1):GetPlayerRating())
local detail =
GAMESTATE:GetCurrentSong():GetDisplayMainTitle() ..
" " .. string.gsub(getCurRateDisplayString(), "Music", "") .. " [" .. GAMESTATE:GetCurrentSong():GetGroupName() .. "]"
if not STATSMAN:GetCurStageStats():GetLivePlay() then
detail = "Replayed: "..detail
end
-- truncated to 128 characters(discord hard limit)
detail = #detail < 128 and detail or string.sub(detail, 1, 124) .. "..."
local state =
"MSD: " ..
string.format("%05.2f", GAMESTATE:GetCurrentSteps():GetMSD(getCurRateValue(), 1)) ..
" - " ..
string.format("%05.2f%%", notShit.floor(score:GetWifeScore() * 10000) / 100) ..
" " .. THEME:GetString("Grade", ToEnumShortString(score:GetWifeGrade()))
GAMESTATE:UpdateDiscordPresence(largeImageTooltip, detail, state, 0)
updateDiscordStatus(true)

return t
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,7 @@ local t =
GAMESTATE:SetAutoplay(false)
end
-- Discord thingies
local largeImageTooltip =
GetPlayerOrMachineProfile(PLAYER_1):GetDisplayName() ..
": " .. string.format("%5.2f", GetPlayerOrMachineProfile(PLAYER_1):GetPlayerRating())
local mode = GAMESTATE:GetGameplayMode()
local detail =
GAMESTATE:GetCurrentSong():GetDisplayMainTitle() ..
" " ..
string.gsub(getCurRateDisplayString(), "Music", "") .. " [" .. GAMESTATE:GetCurrentSong():GetGroupName() .. "]"
if mode == "GameplayMode_Replay" then
detail = "Replaying: "..detail
elseif mode == "GameplayMode_Practice" then
detail = "Practicing: "..detail
end
-- truncated to 128 characters(discord hard limit)
detail = #detail < 128 and detail or string.sub(detail, 1, 124) .. "..."
local state = "MSD: " .. string.format("%05.2f", GAMESTATE:GetCurrentSteps():GetMSD(getCurRateValue(), 1))
local endTime = os.time() + GetPlayableTime()
GAMESTATE:UpdateDiscordPresence(largeImageTooltip, detail, state, endTime)
updateDiscordStatus(false)

-- now playing thing for streamers
local streamerstuff =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ t[#t + 1] = UIElements.TextToolTip(1, 1, "Common Large") .. {
t[#t + 1] = LoadActor("../_cursor")
t[#t + 1] = LoadActor("../_halppls")

GAMESTATE:UpdateDiscordMenu(
GetPlayerOrMachineProfile(PLAYER_1):GetDisplayName() ..
": " .. string.format("%5.2f", GetPlayerOrMachineProfile(PLAYER_1):GetPlayerRating())
)
updateDiscordStatusForMenus()

File.Write("nowplaying.txt", " ")
return t
61 changes: 61 additions & 0 deletions Themes/_fallback/Scripts/99 util.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
-- like the 8th utility file

-- update discord rpc for eval and gameplay
function updateDiscordStatus(inEvaluation)
local profile = GetPlayerOrMachineProfile(PLAYER_1)
local song = GAMESTATE:GetCurrentSong()
local steps = GAMESTATE:GetCurrentSteps()
-- Discord thingies
local largeImageTooltip = string.format(
"%s: %5.2f",
profile:GetDisplayName(),
profile:GetPlayerRating()
)
local mode = GAMESTATE:GetGameplayMode()
local detail = string.format(
"%s: %s [%s]",
song:GetDisplayMainTitle(),
string.gsub(getCurRateDisplayString(), "Music", ""),
song:GetGroupName()
)
if mode == "GameplayMode_Replay" then
detail = "Replaying: "..detail
elseif mode == "GameplayMode_Practice" then
detail = "Practicing: "..detail
end
-- truncated to 128 characters(discord hard limit)
detail = #detail < 128 and detail or string.sub(detail, 1, 124) .. "..."
local state = string.format(
"MSD: %05.2f",
steps:GetMSD(getCurRateValue(), 1)
)
local endTime = 0
if inEvaluation then
local score = SCOREMAN:GetMostRecentScore()
if not score then
score = SCOREMAN:GetTempReplayScore()
end

state = string.format(
"%s - %05.2f%% %s",
state,
notShit.floor(score:GetWifeScore() * 10000) / 100,
THEME:GetString("Grade", ToEnumShortString(score:GetWifeGrade()))
)
else
endTime = os.time() + GetPlayableTime()
end

GAMESTATE:UpdateDiscordPresence(largeImageTooltip, detail, state, endTime)
end

-- update discord rpc for ingame menus
function updateDiscordStatusForMenus()
local profile = GetPlayerOrMachineProfile(PLAYER_1)
local detail = string.format(
"%s: %5.2f",
profile:GetDisplayName(),
profile:GetPlayerRating()
)
GAMESTATE:UpdateDiscordMenu(detail)
end

0 comments on commit e01aea9

Please sign in to comment.