Skip to content

Commit

Permalink
code colllapse
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jul 27, 2018
1 parent e7cb98b commit 0d37b00
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local collapsed = false
local t = Def.ActorFrame{
BeginCommand=function(self)
self:queuecommand("Set"):visible(false)
Expand All @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: ")
Expand All @@ -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:")
Expand All @@ -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()
Expand All @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 36 additions & 13 deletions Themes/Til Death/BGAnimations/superscoreboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
},
Expand All @@ -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
Expand Down Expand Up @@ -224,7 +247,7 @@ local o = Def.ActorFrame{
},
}

local function makeGoalDisplay(i)
local function makeScoreDisplay(i)
local hs

local o = Def.ActorFrame{
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@ class LunaDownloadManager : public Luna<DownloadManager>
}

static int RequestChartLeaderBoard(T* p, lua_State* L) {
p->RequestChartLeaderBoard(SArg(1));
//p->RequestChartLeaderBoard(SArg(1));
p->MakeAThing(SArg(1));
vector<HighScore*> wot;
for (auto& zoop : p->athing)
Expand Down

0 comments on commit 0d37b00

Please sign in to comment.