Skip to content

Commit

Permalink
Prevent nil issues with notefield spacing
Browse files Browse the repository at this point in the history
eeehhhh wow this uhhhh
  • Loading branch information
poco0317 committed Jul 6, 2020
1 parent f4a698e commit 2ff47a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ local function arbitraryErrorBarValue(value)
end

local function spaceNotefieldCols(inc)
if inc == nil then inc = 0 end
local hCols = math.floor(#noteColumns/2)
for i, col in ipairs(noteColumns) do
col:addx((i-hCols-1) * inc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ local allowedCustomization = playerConfig:get_data(pn_to_profile_slot(PLAYER_1))

local isCentered = ((cols >= 6) or PREFSMAN:GetPreference("Center1Player")) and GAMESTATE:GetNumPlayersEnabled() == 1
-- load from prefs later
local width = 64 * cols * MovableValues.NotefieldWidth + MovableValues.NotefieldSpacing * (evencols)
local nfspace = MovableValues.NotefieldSpacing and MovableValues.NotefieldSpacing or 0
local width = 64 * cols * MovableValues.NotefieldWidth + nfspace * (evencols)
local padding = 8
local styleType = ToEnumShortString(GAMESTATE:GetCurrentStyle():GetStyleType())

Expand All @@ -28,7 +29,7 @@ end
local heightP1 = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).LaneCoverHeight

local P1X =
SCREEN_CENTER_X + MovableValues.NotefieldX + (cols % 2 == 0 and -MovableValues.NotefieldSpacing / 2 or 0)
SCREEN_CENTER_X + MovableValues.NotefieldX + (cols % 2 == 0 and -nfspace / 2 or 0)

if not isCentered then
P1X = THEME:GetMetric("ScreenGameplay", string.format("PlayerP1%sX", styleType))
Expand Down
6 changes: 3 additions & 3 deletions Themes/Til Death/Graphics/Notefield board.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ local function laneHighlight()
self:xy((-(arrowWidth * (cols / 2)) + ((i - 1) * arrowWidth) + (arrowWidth / 2)) + (i-(cols/2)-(1/2))*colWidth*(thewidth),-receptor)
-- mimic the behavior of the moving function for spacing to set the last bit of x position
-- this moves all columns except "the middle" by however much the spacing requires
self:addx((i - hCols - 1) * MovableValues.NotefieldSpacing)
self:addx((i - hCols - 1) * (MovableValues.NotefieldSpacing and MovableValues.NotefieldSpacing or 0))
self:fadebottom(0.6):fadetop(0.6)
self:visible(false)
end,
Expand Down Expand Up @@ -151,9 +151,9 @@ t[#t + 1] =
Def.Quad {
Name = "SinglePlayerFilter",
InitCommand = function(self)
self:zoomto(filterWidth * noteFieldWidth + MovableValues.NotefieldSpacing * evenCols, SCREEN_HEIGHT * 2)
self:zoomto(filterWidth * noteFieldWidth + (MovableValues.NotefieldSpacing and MovableValues.NotefieldSpacing or 0) * evenCols, SCREEN_HEIGHT * 2)
-- offset the filter by this much for even column counts
self:addx(cols % 2 == 0 and -MovableValues.NotefieldSpacing / 2 or 0)
self:addx(cols % 2 == 0 and -(MovableValues.NotefieldSpacing and MovableValues.NotefieldSpacing or 0) / 2 or 0)
self:diffusecolor(filterColor)
self:diffusealpha(filterAlphas)
filter = self
Expand Down

0 comments on commit 2ff47a4

Please sign in to comment.