Skip to content

Commit

Permalink
Merge branch 'develop' into audisualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram authored Feb 13, 2019
2 parents 0be9670 + ff79587 commit 2f30c72
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ local jdgCur -- Note: only for judgments with OFFSETS, might reorganize a bit l
local tDiff
local wifey
local judgect
local pbtarget
local positive = getMainColor("positive")
local highlight = getMainColor("highlight")
local negative = getMainColor("negative")

local jdgCounts = {} -- Child references for the judge counter


-- We can also pull in some localized aliases for workhorse functions for a modest speed increase
local Round = notShit.round
local Floor = notShit.floor
Expand Down Expand Up @@ -209,11 +213,14 @@ local t =
jdgct = msg.Val
if msg.Offset ~= nil then
dvCur = msg.Offset
else
dvCur = 1000
end
if msg.WifePBGoal ~= nil then
pbtarget = msg.WifePBGoal
end
jdgCur = msg.Judgment
queuecommand(self, "SpottedOffset")
if jdgCounts[jdgCur] ~= nil then
queuecommand(self, "SpottedOffset")
end
end
}

Expand Down Expand Up @@ -298,9 +305,8 @@ else
end
self:settextf("")
end,
JudgmentMessageCommand = function(self, msg)
if tDiff then
local pbtarget = msg.WifePBGoal
SpottedOffsetCommand = function(self, msg)
if pbtarget then
if tDiff >= 0 then
diffuse(self, color("#00ff00"))
else
Expand Down Expand Up @@ -387,7 +393,6 @@ local countFontSize = 0.35
local gradeFontSize = 0.45
--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--

local jdgCounts = {} -- Child references for the judge counter

local j =
Def.ActorFrame {
Expand All @@ -405,7 +410,7 @@ local j =
end
end,
SpottedOffsetCommand = function(self)
if jdgCur then
if jdgCur and jdgCounts[jdgCur] ~= nil then
settext(jdgCounts[jdgCur], jdgct)
end
end,
Expand Down Expand Up @@ -513,8 +518,10 @@ local e =
end,
SpottedOffsetCommand = function(self)
if enabledErrorBar == 1 then
currentbar = ((currentbar) % barcount) + 1
queuecommand(ingots[currentbar], "UpdateErrorBar") -- Update the next bar in the queue
if jdgCounts[jdgCur] ~= nil and jdgCur ~= "HoldNoteScore_LetGo" and jdgCur ~= "TapNoteScore_Miss" and jdgCur ~= "HoldNoteScore_Held" then
currentbar = ((currentbar) % barcount) + 1
queuecommand(ingots[currentbar], "UpdateErrorBar") -- Update the next bar in the queue
end
end
end,
DootCommand = function(self)
Expand Down Expand Up @@ -577,9 +584,11 @@ if enabledErrorBar == 2 then
end
end,
SpottedOffsetCommand = function(self)
avg = alpha * dvCur + (1 - alpha) * lastAvg
lastAvg = avg
self:x(MovableValues.ErrorBarX + avg * wscale)
if jdgCounts[jdgCur] and jdgCur ~= "HoldNoteScore_LetGo" and jdgCur ~= "TapNoteScore_Miss" and jdgCur ~= "HoldNoteScore_Held" then
avg = alpha * dvCur + (1 - alpha) * lastAvg
lastAvg = avg
self:x(MovableValues.ErrorBarX + avg * wscale)
end
end
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ curScore = {
return DLMAN:GetUsername()
end,
GetWifeGrade = function()
return curScore.curGrade
return GetGradeFromPercent(curScore.curWifeScore)
end,
GetWifeScore = function()
return curScore.curWifeScore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,17 @@ local function updateLeaderBoardForCurrentChart()
if top:GetMusicWheel():IsSettled() and ((getTabIndex() == 2 and nestedTab == 2) or collapsed) then
local steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
if steps then
DLMAN:RequestChartLeaderBoardFromOnline(
steps:GetChartKey(),
function(leaderboard)
moped:queuecommand("SetFromLeaderboard", leaderboard)
end
)
local leaderboardAttempt = DLMAN:GetChartLeaderboard(steps:GetChartKey())
if #leaderboardAttempt > 0 then
moped:playcommand("SetFromLeaderboard", leaderboardAttempt)
else
DLMAN:RequestChartLeaderBoardFromOnline(
steps:GetChartKey(),
function(leaderboard)
moped:queuecommand("SetFromLeaderboard", leaderboard)
end
)
end
else
moped:playcommand("SetFromLeaderboard", {})
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local prevY = 55
local prevrevY = 208
local boolthatgetssettotrueonsongchangebutonlyifonatabthatisntthisone = false
local boolthatgetssettotrueonsongchangebutonlyifonthegeneraltabandthepreviewhasbeentoggledoff = false
local songChanged = false

local update = false
local t =
Expand All @@ -37,6 +38,7 @@ local t =
if getTabIndex() == 0 and noteField and not mcbootlarder:GetChild("NoteField"):IsVisible() then
boolthatgetssettotrueonsongchangebutonlyifonthegeneraltabandthepreviewhasbeentoggledoff = true
end
songChanged = true
end,
MintyFreshCommand = function(self)
self:finishtweening()
Expand Down Expand Up @@ -137,7 +139,10 @@ local function toggleNoteField()
if usingreverse then
mcbootlarder:GetChild("NoteField"):y(prevY * 1.5 + prevrevY)
end
song:Borp() -- catches a dumb bug that isn't worth explaining -mina
if songChanged then
song:Borp() -- catches a dumb bug that isn't worth explaining -mina
songChanged = false
end
return
end

Expand Down Expand Up @@ -747,7 +752,6 @@ t[#t + 1] =
if noteField and oldstyle ~= GAMESTATE:GetCurrentStyle() then
SCREENMAN:GetTopScreen():DeletePreviewNoteField(mcbootlarder)
noteField = false
toggleNoteField()
SCREENMAN:GetTopScreen():setTimeout(
function()
toggleNoteField()
Expand Down
61 changes: 56 additions & 5 deletions Themes/Til Death/BGAnimations/_PlayerInfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ local function highlight(self)
self:GetChild("refreshbutton"):queuecommand("Highlight")
end

local function highlight2(self)
self:GetChild("refreshbutton"):queuecommand("Highlight")
self:GetChild("loginlogout"):queuecommand("Highlight")
end

local function highlightIfOver(self)
if isOver(self) then
self:diffusealpha(0.6)
Expand Down Expand Up @@ -109,8 +114,9 @@ t[#t + 1] =
},
LoadFont("Common Normal") ..
{
Name = "loginlogout",
InitCommand = function(self)
self:xy(SCREEN_CENTER_X, AvatarY + 20):halign(0.5):zoom(0.5):diffuse(getMainColor("positive"))
self:xy(SCREEN_CENTER_X, AvatarY + 26):halign(0.5):zoom(0.5):diffuse(getMainColor("positive"))
end,
BeginCommand = function(self)
self:queuecommand("Set")
Expand All @@ -126,29 +132,74 @@ t[#t + 1] =
if SCREENMAN:GetTopScreen():GetName() == "ScreenSelectMusic" then
self:settext("Click to login")
else
self:settextf("Not logged in")
self:settext("Not logged in")
end
end,
LoginMessageCommand = function(self) --this seems a little clunky -mina
if SCREENMAN:GetTopScreen() and SCREENMAN:GetTopScreen():GetName() == "ScreenSelectMusic" then
self:settextf(
"%s",
"Click to Logout"
)
else
self:settextf("")
end
end,
OnlineUpdateMessageCommand = function(self)
self:queuecommand("Set")
end,
HighlightCommand=function(self)
highlightIfOver(self)
end
},
LoadFont("Common Normal") ..
{
InitCommand = function(self)
self:xy(SCREEN_CENTER_X, AvatarY + 20):halign(0.5):zoom(0.5):diffuse(getMainColor("positive"))
end,
BeginCommand = function(self)
self:queuecommand("Set")
end,
SetCommand = function(self)
if DLMAN:IsLoggedIn() then
self:queuecommand("Login")
else
self:queuecommand("LogOut")
end
end,
LogOutMessageCommand = function(self)
if SCREENMAN:GetTopScreen():GetName() == "ScreenSelectMusic" then
self:settextf("")
self:GetParent():SetUpdateFunction(highlight2)
else
self:settextf("")
self:GetParent():SetUpdateFunction(highlight)
end
end,
LoginMessageCommand = function(self) --this seems a little clunky -mina
if SCREENMAN:GetTopScreen() and SCREENMAN:GetTopScreen():GetName() == "ScreenSelectMusic" then
self:settextf(
"Logged in as %s (%5.2f: #%i) \n%s",
"Logged in as %s (%5.2f: #%i) \n",
DLMAN:GetUsername(),
DLMAN:GetSkillsetRating("Overall"),
DLMAN:GetSkillsetRank(ms.SkillSets[1]),
"Click to Logout"
DLMAN:GetSkillsetRank(ms.SkillSets[1])
)
self:GetParent():SetUpdateFunction(highlight2)
else
self:settextf(
"Logged in as %s (%5.2f: #%i)",
DLMAN:GetUsername(),
DLMAN:GetSkillsetRating("Overall"),
DLMAN:GetSkillsetRank(ms.SkillSets[1])
)
self:GetParent():SetUpdateFunction(highlight)
end
end,
OnlineUpdateMessageCommand = function(self)
self:queuecommand("Set")
end,
HighlightCommand=function(self)
highlightIfOver(self)
end
},
Def.Quad {
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/Scripts/01 color_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ local defaultConfig = {
SDG = "#448844",
FC = "#66cc66",
MF = "#cc6666",
SDCB = "#666666",
SDCB = "#33bbff",
Clear = "#33aaff",
Failed = "#e61e25",
Invalid = "#e61e25",
Expand Down
40 changes: 25 additions & 15 deletions Themes/Til Death/Scripts/ClearType.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,36 @@ local function clearTypes(grade, playCount, perfcount, greatcount, misscount, re
else
if grade == "Grade_Failed" then -- failed
clearlevel = 11
elseif perfcount < 10 and perfcount > 1 then -- SDP
clearlevel = 3
elseif greatcount < 10 and greatcount > 1 then -- SDG
clearlevel = 6
elseif perfcount == 1 and greatcount + misscount == 0 then -- whiteflag
clearlevel = 2
elseif greatcount == 1 and misscount == 0 then -- blackflag
clearlevel = 5
elseif perfcount + greatcount + misscount == 0 then -- MFC
clearlevel = 1
elseif greatcount + misscount == 0 then -- PFC
clearlevel = 4
elseif misscount == 0 then -- FC
clearlevel = 7
else
elseif misscount > 0 then
if misscount == 1 then
clearlevel = 8 -- missflag
elseif misscount > 1 and misscount < 10 then
clearlevel = 9 -- SDCB
else
clearlevel = 10 -- Clear
end
elseif misscount == 0 then
if greatcount == 0 then
if perfcount == 0 then -- MFC
clearlevel = 1
elseif perfcount == 1 then -- whiteflag
clearlevel = 2
elseif perfcount < 10 and perfcount > 1 then -- SDP
clearlevel = 3
else -- PFC
clearlevel = 4
end
else
if greatcount < 10 and greatcount > 1 then -- SDG
clearlevel = 6
elseif greatcount == 1 then -- blackflag
clearlevel = 5
else -- FC
clearlevel = 7
end
end
else
clearlevel = 12 -- this would mean negative misses
end
end
return getClearTypeItem(clearlevel, returntype)
Expand Down
2 changes: 1 addition & 1 deletion src/GameSoundManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class GameSoundManager : MessageSubscriber
float GetFrameTimingAdjustment(float fDeltaTime);

static float GetPlayerBalance(PlayerNumber pn);
void GameSoundManager::WithRageSoundPlaying(function<void(RageSound*)> f);
void WithRageSoundPlaying(function<void(RageSound*)> f);
TimingData GetPlayingMusicTiming();

void StartMusic(MusicToPlay& ToPlay);
Expand Down
2 changes: 1 addition & 1 deletion src/RageSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class RageSound : public RageSoundBase
int64_t m_iStreamFrame;

void* fftwBuffer{nullptr};
void RageSound::ActuallySetPlayBackCallback(LuaReference& f, unsigned int bufSize);
void ActuallySetPlayBackCallback(LuaReference& f, unsigned int bufSize);
std::atomic<bool> inPlayCallback{ false };
std::mutex recentSamplesMutex; // For all operations related to sound play callbacks
unsigned int recentPCMSamplesBufferSize{ 1024 };
Expand Down
43 changes: 43 additions & 0 deletions src/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,49 @@ Screen::EndScreen()
m_bRunning = false;
}

inline void
Screen::UpdateTimedFunctions(float fDeltaTime)
{
for (auto it = delayedFunctions.begin(); it != delayedFunctions.end();
++it) {
auto& delayedF = *it;
delayedF.second -= fDeltaTime;
if (delayedF.second <= 0) {
delayedF.first();
}
}
// Doing this in place did weird things
delayedFunctions.erase(std::remove_if(delayedFunctions.begin(),
delayedFunctions.end(),
[](pair<function<void()>, float>& x) {
return x.second <= 0;
}),
delayedFunctions.end());
if (!delayedPeriodicFunctionIdsToDelete.empty()) {
auto* L = LUA->Get();
for (auto id : delayedPeriodicFunctionIdsToDelete) {
luaL_unref(L, LUA_REGISTRYINDEX, id);
auto& vec = this->delayedPeriodicFunctions;
vec.erase(std::remove_if(
vec.begin(),
vec.end(),
[id](tuple<function<void()>, float, float, int>& x) {
return std::get<3>(x) == id;
}),
vec.end());
}
LUA->Release(L);
delayedPeriodicFunctionIdsToDelete.clear();
}
for (auto& delayedF : delayedPeriodicFunctions) {
std::get<1>(delayedF) -= fDeltaTime;
if (std::get<1>(delayedF) <= 0) {
std::get<0>(delayedF)();
std::get<1>(delayedF) = std::get<2>(delayedF);
}
}
}

void
Screen::UpdateTimedFunctions(float fDeltaTime)
{
Expand Down
Loading

0 comments on commit 2f30c72

Please sign in to comment.