From 0d37b003243669da6efd0a06ba90f84c2cef2b4b Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 26 Jul 2018 21:28:19 -0400 Subject: [PATCH] code colllapse --- .../goaltracker.lua | 20 +----- .../ScreenSelectMusic decorations/score.lua | 71 ++++++++++++++----- .../songsearch.lua | 2 +- .../BGAnimations/superscoreboard.lua | 49 +++++++++---- src/DownloadManager.cpp | 2 +- 5 files changed, 92 insertions(+), 52 deletions(-) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua index 49cb7ed847..f336f4301e 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua @@ -1,4 +1,3 @@ -local collapsed = false local t = Def.ActorFrame{ BeginCommand=function(self) self:queuecommand("Set"):visible(false) @@ -11,32 +10,17 @@ local t = Def.ActorFrame{ self:bouncebegin(0.2):xy(SCREEN_LEFT,SCREEN_TOP - 10):diffusealpha(1) end, SetCommand=function(self) - self:hurrytweening(1) + self:finishtweening(1) if getTabIndex() == 6 then self:queuecommand("On") self:visible(true) - elseif collapsed and getTabIndex() == 0 then - self:queuecommand("On") - self:visible(true) - elseif collapsed and getTabIndex() ~= 0 then - self:queuecommand("Off") - elseif not collapsed then + else self:queuecommand("Off") end end, TabChangedMessageCommand=function(self) self:queuecommand("Set") end, - CollapseCommand=function(self) - collapsed = true - resetTabIndex() - MESSAGEMAN:Broadcast("TabChanged") - end, - ExpandCommand=function(self) - collapsed = true - setTabIndex(6) - MESSAGEMAN:Broadcast("TabChanged") - end } t[#t+1] = LoadActor("../GoalDisplay") diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/score.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/score.lua index 7515a10226..c3a59a99e8 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/score.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/score.lua @@ -36,6 +36,30 @@ else defaultRateText = "All" end +local function isOver(element) + if element:GetParent():GetParent():GetVisible() == false then + return false end + if element:GetParent():GetVisible() == false then + return false end + if element:GetVisible() == false then + return false end + local x = getTrueX(element) + local y = getTrueY(element) + local hAlign = element:GetHAlign() + local vAlign = element:GetVAlign() + local w = element:GetZoomedWidth() + local h = element:GetZoomedHeight() + + local mouseX = INPUTFILTER:GetMouseX() + local mouseY = INPUTFILTER:GetMouseY() + + local withinX = (mouseX >= (x-(hAlign*w))) and (mouseX <= ((x+w)-(hAlign*w))) + local withinY = (mouseY >= (y-(vAlign*h))) and (mouseY <= ((y+h)-(vAlign*h))) + + return (withinX and withinY) +end + + local ret = Def.ActorFrame{ BeginCommand=function(self) self:queuecommand("Set"):visible(false) @@ -48,13 +72,17 @@ local ret = Def.ActorFrame{ self:bouncebegin(0.2):xy(0,0):diffusealpha(1) end, SetCommand=function(self) - self:hurrytweening(1) + self:hurrytweening(2) if getTabIndex() == 2 then - self:queuecommand("On") - self:visible(true) - update = true - self:playcommand("InitScore") - MESSAGEMAN:Broadcast("ScoreUpdate") + if collapsed then + self:queuecommand("Expand") + else + self:queuecommand("On") + self:visible(true) + update = true + self:playcommand("InitScore") + MESSAGEMAN:Broadcast("ScoreUpdate") + end elseif collapsed and getTabIndex() == 0 then self:queuecommand("On") self:visible(true) @@ -131,8 +159,11 @@ local ret = Def.ActorFrame{ MESSAGEMAN:Broadcast("TabChanged") end, ExpandCommand=function(self) - collapsed = true - setTabIndex(2) + collapsed = false + if getTabIndex() ~= 2 then + setTabIndex(2) + end + self:GetChild("ScoreDisplay"):xy(10,60) MESSAGEMAN:Broadcast("TabChanged") end } @@ -169,7 +200,7 @@ t[#t+1] = LoadFont("Common Large")..{ self:xy(frameX+offsetX,frameY+offsetY+20):zoom(0.6):halign(0):maxwidth(50/0.6) end, SetCommand=function(self) - if score and update then + if score and update and nestedTab == 0 then self:settext(THEME:GetString("Grade",ToEnumShortString(score:GetWifeGrade()))) self:diffuse(getGradeColor(score:GetWifeGrade())) else @@ -188,7 +219,7 @@ t[#t+1] = LoadFont("Common Normal")..{ self:xy(frameX+offsetX+55,frameY+offsetY+15):zoom(0.5):halign(0) end, SetCommand=function(self) - if score and update then + if score and update and nestedTab == 0 then if score:GetWifeScore() == 0 then self:settextf("NA (%s)", "Wife") else @@ -209,7 +240,7 @@ t[#t+1] = LoadFont("Common Normal")..{ self:xy(frameX+offsetX+55,frameY+offsetY+33):zoom(0.5):halign(0) end, SetCommand=function(self) - if score and update then + if score and update and nestedTab == 0 then if score:GetWifeScore() == 0 then self:settext("") else @@ -230,7 +261,7 @@ t[#t+1] = LoadFont("Common Normal")..{ self:xy(frameX+offsetX,frameY+offsetY+41):zoom(0.5):halign(0) end; SetCommand=function(self) - if score and update then + if score and update and nestedTab == 0 then self:settext(getClearTypeFromScore(pn,score,0)) self:diffuse(getClearTypeFromScore(pn,score,2)) end @@ -246,7 +277,7 @@ t[#t+1] = LoadFont("Common Normal")..{ self:xy(frameX+offsetX,frameY+offsetY+58):zoom(0.4):halign(0) end; SetCommand=function(self) - if score and update then + if score and update and nestedTab == 0 then local maxCombo = getScoreMaxCombo(score) self:settextf("Max Combo: %d",maxCombo) else @@ -286,7 +317,7 @@ t[#t+1] = LoadFont("Common Normal")..{ self:xy(frameX+offsetX,frameY+offsetY+88):zoom(0.4):halign(0) end; SetCommand=function(self) - if score and update then + if score and update and nestedTab == 0 then self:settext("Date Achieved: "..getScoreDate(score)) else self:settext("Date Achieved: ") @@ -303,7 +334,7 @@ t[#t+1] = LoadFont("Common Normal")..{ self:xy(frameX+offsetX,frameY+offsetY+103):zoom(0.4):halign(0) end; SetCommand=function(self) - if score and update then + if score and update and nestedTab == 0 then self:settext("Mods: " ..score:GetModifiers()) else self:settext("Mods:") @@ -321,7 +352,7 @@ t[#t+1] = LoadFont("Common Normal")..{ end, SetCommand=function(self) local steps = GAMESTATE:GetCurrentSteps(pn) - if score and update then + if score and update and nestedTab == 0 then local diff = getDifficulty(steps:GetDifficulty()) local stype = ToEnumShortString(steps:GetStepsType()):gsub("%_"," ") local meter = steps:GetMeter() @@ -341,7 +372,7 @@ t[#t+1] = LoadFont("Common Normal")..{ self:xy(frameX+frameWidth-offsetX,frameY+frameHeight-10):zoom(0.4):halign(1) end, SetCommand=function(self) - if rates ~= nil and rtTable[rates[rateIndex]] ~= nil and update then + if rates ~= nil and rtTable[rates[rateIndex]] ~= nil and update and nestedTab == 0 then self:settextf("Rate %s - Showing %d/%d",rates[rateIndex],scoreIndex,#rtTable[rates[rateIndex]]) else self:settext("No Scores Saved") @@ -358,7 +389,7 @@ t[#t+1] = LoadFont("Common Normal")..{ self:xy(frameX+frameWidth/40,frameY+frameHeight-10):zoom(0.4):halign(0) end, SetCommand=function(self) - if score and update then + if score and update and nestedTab == 0 then if score:GetChordCohesion() == true then self:settext("Chord Cohesion: Yes") else @@ -583,9 +614,11 @@ function nestedTabButton(i) } } end + +ret[#ret+1] = LoadActor("../superscoreboard") for i=1,#nestedTabs do ret[#ret+1] = nestedTabButton(i) end -ret[#ret+1] = LoadActor("../superscoreboard") + return ret \ No newline at end of file diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua index c0869e4883..77771c02bf 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/songsearch.lua @@ -29,7 +29,7 @@ local function searchInput(event) searchstring = searchstring..HOOKS:GetClipboard() else --if not nil and (not a number or (ctrl pressed and not online)) - local CtrlPressed = INPUTFILTER:IsBeingPressed("left ctrl") or INPUTFILTER:IsBeingPressed("right ctrl") + local CtrlPressed = INPUTFILTER:IsBeingPressed("left ctrl", nil) or INPUTFILTER:IsBeingPressed("right ctrl", nil) if event.char and event.char:match("[%%%+%-%!%@%#%$%^%&%*%(%)%=%_%.%,%:%;%'%\"%>%<%?%/%~%|%w]") and (not tonumber(event.char) or CtrlPressed == (SCREENMAN:GetTopScreen():GetName() == "ScreenSelectMusic")) then searchstring = searchstring..event.char end diff --git a/Themes/Til Death/BGAnimations/superscoreboard.lua b/Themes/Til Death/BGAnimations/superscoreboard.lua index ec62b3fdc3..91ddb48e55 100644 --- a/Themes/Til Death/BGAnimations/superscoreboard.lua +++ b/Themes/Til Death/BGAnimations/superscoreboard.lua @@ -25,7 +25,7 @@ local collapsed = false -- will eat any mousewheel inputs to scroll pages while mouse is over the background frame local function input(event) - if isOver(cheese:GetChild("FrameDisplay")) then + if cheese:GetVisible() and isOver(cheese:GetChild("FrameDisplay")) then if event.DeviceInput.button == "DeviceButton_mousewheel up" and event.type == "InputEventType_FirstPress" then moving = true cheese:queuecommand("PrevPage") @@ -40,6 +40,29 @@ local function input(event) return false end +local function isOver(element) + if element:GetParent():GetParent():GetVisible() == false then + return false end + if element:GetParent():GetVisible() == false then + return false end + if element:GetVisible() == false then + return false end + local x = getTrueX(element) + local y = getTrueY(element) + local hAlign = element:GetHAlign() + local vAlign = element:GetVAlign() + local w = element:GetZoomedWidth() + local h = element:GetZoomedHeight() + + local mouseX = INPUTFILTER:GetMouseX() + local mouseY = INPUTFILTER:GetMouseY() + + local withinX = (mouseX >= (x-(hAlign*w))) and (mouseX <= ((x+w)-(hAlign*w))) + local withinY = (mouseY >= (y-(vAlign*h))) and (mouseY <= ((y+h)-(vAlign*h))) + + return (withinX and withinY) +end + local function highlight(self) self:queuecommand("Highlight") self:queuecommand("WHAZZZAAAA") @@ -75,12 +98,12 @@ local o = Def.ActorFrame{ end, OnCommand=function(self) GetPlayerOrMachineProfile(PLAYER_1):SetFromAll() - self:queuecommand("GoalTableRefresh") + self:queuecommand("ScoreTableRefresh") end, - GoalTableRefreshMessageCommand=function(self) - scoretable = DLMAN:RequestChartLeaderBoard(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey()) - ind = 0 - self:queuecommand("Update") + ChartLeaderboardUpdateMessageCommand=function(self) + scoretable = DLMAN:RequestChartLeaderBoard(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey()) + ind = 0 + self:playcommand("Update") end, UpdateCommand=function(self) if ind == #scoretable then @@ -167,9 +190,9 @@ local o = Def.ActorFrame{ end, MouseRightClickMessageCommand=function(self) if isOver(self) and not collapsed then - self:GetParent():GetParent():queuecommand("Collapse") + self:GetParent():GetParent():playcommand("Collapse") elseif isOver(self) then - self:GetParent():GetParent():queuecommand("Expand") + self:GetParent():GetParent():playcommand("Expand") end end, }, @@ -184,14 +207,14 @@ local o = Def.ActorFrame{ -- grabby thing Def.Quad{ InitCommand=function(self) - self:xy(dwidth/4, headeroff):zoomto(dwidth,pdh):halign(0):diffusealpha(1):diffuse(color("#111111")) + self:xy(dwidth/4, headeroff):zoomto(dwidth - dwidth/4,pdh):halign(0):diffusealpha(1):diffuse(color("#111111")) end, WHAZZZAAAACommand=function(self) if isOver(self) and collapsed then self:diffusealpha(0.6):diffuse(color("#fafafa")) if INPUTFILTER:IsBeingPressed("Mouse 0", "Mouse") then - self:diffusealpha(0):zoomto(200,200) - self:GetParent():xy(INPUTFILTER:GetMouseX()-width/2, INPUTFILTER:GetMouseY()) + self:diffusealpha(0):zoomto(400,400) + self:GetParent():xy(INPUTFILTER:GetMouseX()-width/2, INPUTFILTER:GetMouseY() - self:GetY()) else self:zoomto(dwidth/2,pdh/2) end @@ -224,7 +247,7 @@ local o = Def.ActorFrame{ }, } -local function makeGoalDisplay(i) +local function makeScoreDisplay(i) local hs local o = Def.ActorFrame{ @@ -391,7 +414,7 @@ local function makeGoalDisplay(i) end for i=1,numscores do - o[#o+1] = makeGoalDisplay(i) + o[#o+1] = makeScoreDisplay(i) end return o \ No newline at end of file diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp index e465e3537c..4843fb6ca6 100644 --- a/src/DownloadManager.cpp +++ b/src/DownloadManager.cpp @@ -1763,7 +1763,7 @@ class LunaDownloadManager : public Luna } static int RequestChartLeaderBoard(T* p, lua_State* L) { - p->RequestChartLeaderBoard(SArg(1)); + //p->RequestChartLeaderBoard(SArg(1)); p->MakeAThing(SArg(1)); vector wot; for (auto& zoop : p->athing)