Skip to content

Commit

Permalink
Make filter ui code even worse
Browse files Browse the repository at this point in the history
this makes the numeric input for only the best clear percent line more intuitive and has no comments in the code and also looks really bad
and it also fixes incorrect input and output here
  • Loading branch information
poco0317 committed Feb 14, 2021
1 parent e58b54f commit a7040e5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Everything relating to the gameplay screen is gradually moved to WifeJudgmentSpotting.lua
local inReplay = GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerController() == "PlayerController_Replay"
local inReplay = GAMESTATE:GetPlayerState():GetPlayerController() == "PlayerController_Replay"
local inCustomize = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).CustomizeGameplay
local isPractice = GAMESTATE:IsPracticeMode()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ for i = 1, #ms.SkillSets + 2 do
SSQuery[0][i] = "0"
SSQuery[1][i] = "0"
end
local numbersafterthedecimal = 0

local function FilterInput(event)
if event.type ~= "InputEventType_Release" and ActiveSS > 0 and active then
Expand Down Expand Up @@ -55,10 +56,12 @@ local function FilterInput(event)
local num = 0
if ActiveSS == #ms.SkillSets+2 then
local q = SSQuery[activebound][ActiveSS]
numbersafterthedecimal = 0
if #q > 2 then
numbersafterthedecimal = #q-2
local n = tonumber(q) / (10 ^ (#q-2))
n = notShit.floor(n, 3)
num = tonumber(n)
n = notShit.round(n, numbersafterthedecimal)
num = n
else
num = tonumber(q)
end
Expand Down Expand Up @@ -451,8 +454,18 @@ local function CreateFilterInputBox(i)
)
end,
SetCommand = function(self)
local fval = notShit.floor(FILTERMAN:GetSSFilter(i, 0), 3) -- lower bounds
self:settext(fval)
local fval = notShit.round(FILTERMAN:GetSSFilter(i, 0), numbersafterthedecimal) -- lower bounds
local fmtstr = ""
if i == #ms.SkillSets+2 then
if numbersafterthedecimal > 0 then
fmtstr = "%5."..numbersafterthedecimal.."f"
else
fmtstr = "%02d."
end
else
fmtstr = "%d"
end
self:settextf(fmtstr, fval)
if fval <= 0 and ActiveSS ~= i then
self:diffuse(color("#666666"))
elseif activebound == 0 then
Expand Down Expand Up @@ -507,8 +520,18 @@ local function CreateFilterInputBox(i)
)
end,
SetCommand = function(self)
local fval = notShit.round(FILTERMAN:GetSSFilter(i, 1), 3) -- upper bounds
self:settext(fval)
local fval = notShit.round(FILTERMAN:GetSSFilter(i, 1), numbersafterthedecimal) -- upper bounds
local fmtstr = "%5."
if i == #ms.SkillSets+2 then
if numbersafterthedecimal > 0 then
fmtstr = "%5."..numbersafterthedecimal.."f"
else
fmtstr = "%02d."
end
else
fmtstr = "%d"
end
self:settextf(fmtstr, fval)
if fval <= 0 and ActiveSS ~= i then
self:diffuse(color("#666666"))
elseif activebound == 1 then
Expand Down Expand Up @@ -541,6 +564,7 @@ f[#f + 1] =
SSQuery[0][i] = "0"
SSQuery[1][i] = "0"
end
numbersafterthedecimal = 0
activebound = 0
ActiveSS = 0
MESSAGEMAN:Broadcast("UpdateFilter")
Expand Down

0 comments on commit a7040e5

Please sign in to comment.