Skip to content

Commit

Permalink
Merge pull request #374 from etternagame/mouseover-refactor
Browse files Browse the repository at this point in the history
Mouseover refactoring
  • Loading branch information
MinaciousGrace authored Nov 26, 2018
2 parents 58ad984 + f6e20a8 commit 56f5e99
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,6 @@ local enabledJudgeCounter = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).
local leaderboardEnabled = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).leaderboardEnabled and DLMAN:IsLoggedIn()
local isReplay = GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerController() == "PlayerController_Replay"

-- restart button (MOVED OUT OF THEME IN FAVOR OF REMAPPING)
--[[
local function froot(loop)
if loop.DeviceInput.button == "DeviceButton_`" then
SCREENMAN:GetTopScreen():SetPrevScreenName("ScreenStageInformation"):begin_backing_out()
end
end
]]

local function arbitraryErrorBarValue(value)
errorBarFrameWidth = capWideScale(get43size(value), value)
wscale = errorBarFrameWidth / 180
Expand Down Expand Up @@ -173,9 +164,6 @@ local t =
local endTime = os.time() + GetPlayableTime()
GAMESTATE:UpdateDiscordPresence(largeImageTooltip, detail, state, endTime)

--[[if SCREENMAN:GetTopScreen():GetName() == "ScreenGameplay" then
SCREENMAN:GetTopScreen():AddInputCallback(froot)
end]]
screen = SCREENMAN:GetTopScreen()
usingReverse = GAMESTATE:GetPlayerState(PLAYER_1):GetCurrentPlayerOptions():UsingReverse()
Notefield = screen:GetChild("PlayerP1"):GetChild("NoteField")
Expand All @@ -192,8 +180,7 @@ local t =
Movable.DeviceButton_t.element = noteColumns
Movable.DeviceButton_r.condition = true
Movable.DeviceButton_t.condition = true
lifebar:AddChild(self:GetChild("Border"))
-- self:RemoveChild("Border") ayy lmao
self:GetChild("LifeP1"):GetChild("Border"):SetFakeParent(lifebar)
Movable.DeviceButton_j.element = lifebar
Movable.DeviceButton_j.condition = true
Movable.DeviceButton_k.element = lifebar
Expand Down Expand Up @@ -221,9 +208,11 @@ local t =
end
}

-- lifebar border, this is really ghetto i dont like it
t[#t + 1] = MovableBorder(200, 5, 1, -35, 0)

-- lifebard
t[#t + 1] = Def.ActorFrame{
Name = "LifeP1",
MovableBorder(200, 5, 1, -35, 0)
}
--[[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**LaneCover**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -347,6 +336,11 @@ local cp =
end
self:zoom(MovableValues.DisplayPercentZoom):x(MovableValues.DisplayPercentX):y(MovableValues.DisplayPercentY)
end,
Def.Quad {
InitCommand = function(self)
self:zoomto(60, 13):diffuse(color("0,0,0,0.4")):halign(1):valign(0)
end
},
-- Displays your current percentage score
LoadFont("Common Large") .. {
Name = "DisplayPercent",
Expand All @@ -355,7 +349,7 @@ local cp =
end,
OnCommand = function(self)
if allowedCustomization then
self:settextf("%05.2f%%", -10000)
self:settextf("%05.2f%%", -10000)
setBorderAlignment(self:GetParent():GetChild("Border"), 1, 0)
setBorderToText(self:GetParent():GetChild("Border"), self)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ g[#g + 1] =
PlayingSampleMusicMessageCommand = function(self)
local leaderboardEnabled =
playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).leaderboardEnabled and DLMAN:IsLoggedIn()
if leaderboardEnabled then
if leaderboardEnabled and GAMESTATE:GetCurrentSteps(PLAYER_1) then
local chartkey = GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey()
DLMAN:RequestChartLeaderBoardFromOnline(
chartkey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ t[#t + 1] =
PlayingSampleMusicMessageCommand = function(self)
local leaderboardEnabled =
playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).leaderboardEnabled and DLMAN:IsLoggedIn()
if leaderboardEnabled then
if leaderboardEnabled and GAMESTATE:GetCurrentSteps(PLAYER_1) then
local chartkey = GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey()
DLMAN:RequestChartLeaderBoardFromOnline(
chartkey,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local t =
Def.ActorFrame {
BeginCommand = function(self)
self:queuecommand("Set"):visible(false)
self:GetChild("GoalDisplay"):xy(10, 60):visible(false)
self:queuecommand("Set")
self:GetChild("GoalDisplay"):xy(10, 60)
end,
OffCommand = function(self)
self:bouncebegin(0.2):xy(-500, 0):diffusealpha(0)
Expand All @@ -14,11 +14,10 @@ local t =
self:finishtweening(1)
if getTabIndex() == 6 then
self:queuecommand("On")
self:visible(true) -- input filter has a get:visible check so it doesn't eat inputs if the element isn't displayed
self:GetChild("GoalDisplay"):visible(true) -- however it isn't recursive, so we set the child explicitly, leaving this here to remind myself
else -- to look into changing the getvisible logic or adding a new recursive function maybe -mina
self:visible(true)
else
self:queuecommand("Off")
self:GetChild("GoalDisplay"):xy(10, 60):visible(false)
self:visible(false)
end
end,
TabChangedMessageCommand = function(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ local function BroadcastIfActive(msg)
end

local function ButtonActive(self, scale)
return isOverScaled(self, scale) and update
return isOver(self) and update
end

local r =
Expand Down Expand Up @@ -409,19 +409,6 @@ local b2 =
end
}

--Add chart button
-- b2[#b2+1] = LoadFont("Common Large") .. {InitCommand=cmd(zoom,0.3;x,245;settext,"Add Chart")}
-- b2[#b2+1] = Def.Quad{
-- InitCommand=function(self)
-- self:x(245):diffusealpha(buttondiffuse):zoomto(80,20)
-- end,
-- MouseLeftClickMessageCommand=function(self)
-- if ButtonActive(self) and singleplaylistactive then
-- pl:AddChart(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey())
-- end
-- end
-- }
-- Play As Course button
b2[#b2 + 1] =
LoadFont("Common Large") ..
{
Expand Down Expand Up @@ -722,21 +709,6 @@ local b =
end
}

-- zzzz button positioning is lame... use shortcut key for now whynot
-- New Playlist
-- b[#b+1] = LoadFont("Common Large") .. {InitCommand=cmd(zoom,0.3;settext,"New Playlist")}
-- b[#b+1] = Def.Quad{
-- InitCommand=function(self)
-- self:diffusealpha(buttondiffuse):zoomto(110,20)
-- end,
-- MouseLeftClickMessageCommand=function(self)
-- if ButtonActive(self,0.3) and allplaylistsactive then
-- SONGMAN:NewPlaylist()
-- MESSAGEMAN:Broadcast("DisplayAll")
-- end
-- end
-- }

playlists[#playlists + 1] = b

for i = 1, chartsperplaylist do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,35 +45,9 @@ 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

-- should maybe make some of these generic
local function highlight(self)
if self:GetVisible() then
if self:IsVisible() then
self:queuecommand("Highlight")
end
end
Expand Down Expand Up @@ -223,7 +197,7 @@ local ret =
local cheese
-- eats only inputs that would scroll to a new score
local function input(event)
if cheese:GetVisible() and isOver(cheese:GetChild("FrameDisplay")) then
if isOver(cheese:GetChild("FrameDisplay")) then
if event.DeviceInput.button == "DeviceButton_mousewheel up" and event.type == "InputEventType_FirstPress" then
moving = true
if nestedTab == 1 and rtTable and rtTable[rates[rateIndex]] ~= nil then
Expand Down Expand Up @@ -254,7 +228,7 @@ local t =
SCREENMAN:GetTopScreen():AddInputCallback(input)
end,
OnCommand = function(self)
if nestedTab == 1 and self:GetVisible() then
if nestedTab == 1 and self:IsVisible() then
if GAMESTATE:GetCurrentSong() ~= nil then
rtTable = getRateTable()
if rtTable ~= nil then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local t =
if song ~= bong then
song = bong
self:queuecommand("MortyFarts")
if noteField and mcbootlarder:GetChild("NoteField"):GetVisible() and song then
if noteField and mcbootlarder:GetChild("NoteField"):IsVisible() and song then
song:Borp()
end
end
Expand All @@ -54,7 +54,7 @@ local t =
self:queuecommand("On")
update = true
else
if GAMESTATE:GetCurrentSong() and noteField and mcbootlarder:GetVisible() then
if GAMESTATE:GetCurrentSong() and noteField and mcbootlarder:IsVisible() then
mcbootlarder:visible(false)
mcbootlarder:GetChild("NoteField"):visible(false)
MESSAGEMAN:Broadcast("ChartPreviewOff")
Expand All @@ -65,7 +65,7 @@ local t =
end
end,
MilkyTartsCommand=function(self) -- when entering pack screenselectmusic explicitly turns visibilty on notefield off -mina
if noteField and mcbootlarder:GetVisible() then
if noteField and mcbootlarder:IsVisible() then
mcbootlarder:visible(false)
MESSAGEMAN:Broadcast("ChartPreviewOff")
heyiwasusingthat = true
Expand Down Expand Up @@ -127,7 +127,7 @@ local function toggleNoteField()
return end

if song then
if mcbootlarder:GetVisible() then
if mcbootlarder:IsVisible() then
mcbootlarder:visible(false)
mcbootlarder:GetChild("NoteField"):visible(false)
MESSAGEMAN:Broadcast("ChartPreviewOff")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ local hhh = SCREEN_HEIGHT * 0.8
local rtzoom = 0.6

local function dooting(self)
if self:GetVisible() then
if self:IsVisible() then
self:GetChild("BGQframe"):queuecommand("dooting")
end
end
Expand Down
4 changes: 2 additions & 2 deletions Themes/Til Death/BGAnimations/_chorddensitygraph.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ local t = Def.ActorFrame {
self:queuecommand("GraphUpdate")
end,
CurrentRateChangedMessageCommand = function(self)
if self:GetParent():GetVisible() then
if self:IsVisible() then
self:queuecommand("GraphUpdate")
end
end,
Expand All @@ -111,7 +111,7 @@ t[#t+1] =
Def.ActorMultiVertex {
Name = "CDGraphDrawer",
GraphUpdateCommand = function(self)
if self:GetParent():GetVisible() then
if self:IsVisible() then
updateGraphMultiVertex(cdg, self)
self:GetParent():linear(0.3)
self:GetParent():diffusealpha(1)
Expand Down
4 changes: 2 additions & 2 deletions Themes/Til Death/BGAnimations/goaldisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ local cheese

-- will eat any mousewheel inputs to scroll pages while mouse is over the background frame
local function input(event)
if cheese:GetVisible() and isOver(cheese:GetChild("FrameDisplay")) then
if 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,7 +40,7 @@ local function input(event)
end

local function highlight(self)
if cheese:GetVisible() then
if cheese:IsVisible() then
self:queuecommand("Highlight")
end
end
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/BGAnimations/packlistDisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ local function makePackDisplay(i)
highlightIfOver(self)
end,
MouseLeftClickMessageCommand = function(self)
if isOver(self) and self:GetParent():GetParent():GetVisible() then -- probably should have the isOver function do a recursive parent check?
if isOver(self) then -- now contains recursive visibility checks -mina
local urlstringyo = "https://etternaonline.com/pack/" .. packinfo:GetID() -- not correct value for site id
GAMESTATE:ApplyGameCommand("urlnoexit," .. urlstringyo)
end
Expand Down
33 changes: 5 additions & 28 deletions Themes/Til Death/BGAnimations/superscoreboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ local isGlobalRanking = true

-- will eat any mousewheel inputs to scroll pages while mouse is over the background frame
local function input(event)
if cheese:GetVisible() and isOver(cheese:GetChild("FrameDisplay")) then
if isOver(cheese:GetChild("FrameDisplay")) then -- visibility checks are built into isover now -mina
if event.DeviceInput.button == "DeviceButton_mousewheel up" and event.type == "InputEventType_FirstPress" then
moving = true
cheese:queuecommand("PrevPage")
Expand All @@ -43,34 +43,8 @@ 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)
if self:GetVisible() then
if self:IsVisible() then
self:queuecommand("Highlight")
self:queuecommand("WHAZZZAAAA")
end
Expand Down Expand Up @@ -118,6 +92,9 @@ local o =
self:playcommand("Update")
end,
UpdateCommand = function(self)
if not scoretable then
scoretable = {}
end
if ind == #scoretable then
ind = ind - numscores
elseif ind > #scoretable - (#scoretable % numscores) then
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/Graphics/Player combo/default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ local t =
c.Number:visible(true)
c.Label:visible(true)
c.Number:settext(1000)
Movable.DeviceButton_3.propertyOffsets = {getTrueX(self) -6, getTrueY(self) + c.Number:GetHeight()*1.5} -- centered to screen/valigned
Movable.DeviceButton_3.propertyOffsets = {self:GetTrueX() -6, self:GetTrueY() + c.Number:GetHeight()*1.5} -- centered to screen/valigned
setBorderAlignment(c.Border, 0.5, 1)
end
arbitraryComboZoom(MovableValues.ComboZoom)
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/Graphics/Player judgment/default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ local t =
Movable.DeviceButton_2.condition = enabledJudgment
Movable.DeviceButton_2.DeviceButton_up.arbitraryFunction = judgmentZoom
Movable.DeviceButton_2.DeviceButton_down.arbitraryFunction = judgmentZoom
Movable.DeviceButton_1.propertyOffsets = {getTrueX(self) , getTrueY(self) - c.Judgment:GetHeight()} -- centered to screen/valigned
Movable.DeviceButton_1.propertyOffsets = {self:GetTrueX() , self:GetTrueY() - c.Judgment:GetHeight()} -- centered to screen/valigned
end
end,
JudgmentMessageCommand = function(self, param)
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/Graphics/StepsDisplayListRow frame.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local function highlight(self)
if self:GetParent():GetVisible() then
if self:IsVisible() then
self:queuecommand("Highlight")
end
end
Expand Down
Loading

0 comments on commit 56f5e99

Please sign in to comment.