Skip to content

Commit

Permalink
Customize gameplay overhaul/update (#349)
Browse files Browse the repository at this point in the history
tldr:
* refactored/reorganized code so wifejudgmentspotting is sane again
* added borders to moveable stuffs
* added mouse control for moving elements to the borders
* active element is now a toggle instead of a hold down
* added support for leaderboard/replay buttons

commits:
* Add customization to the Leaderboard

Includes x, y, height, width and spacing between entries.

* Add customization to the replay buttons

* proof of concept element border

* Add border to the miniprogressbar in customize gameplay

* add basic xy movement functionality with mouse

* fix mouse clicks not toggling text properly

* allow directly toggling from one element to another with kb

also fix potential nil bools oops

* add wrapper function for updating property text

and fix update conditions for keyboard adjustments

* tone down opacity on active borders

* fix mouse not being able to select a button if keyboard toggled off

* first try at having border update to zoom without distorting

* add border to display percent

* diffuse borders slightly even if nothing is active

* add border to judgecounter

* add border to full progress bar

* add wrapper for adjusting aligned text to borders

* fiddle with display percent border/bg positioning

* add borders to target tracker

* remove buffer on miniprogressbar borders

if we do this it should be standardized in some way

* round mouse pos when moving things around

* remove unused values

* update textborder alignment function

* adjustments to xy have to be made equally if customization is on or off

this could be a point of confusion in the future

* update default gameplay elements positions to reflect coord refactoring

* set noborder on fullprogressbar so it doesnt update incorrectly

* update explanatory text to reflect toggle/mouse changes

* Try to centralize the customize gameplay into a single file

* Make the movable values global for customize gameplay

* Move everything else missing to the centralized customize gameplay

* we have to always call setbordersfortext

if we dont' there will be a position mismatch between customize gameplay position and regular gameplay

this is because setbordersfortext originally moved the borders only, but i changed it to move the text instead in order to keep the elmeent centered while moving it with the mouse

yes i know this is bad and should be handled differently but the use case is limited at the moment an di need time to figure out a better way to handle this

* added manual offsets for judgment since its center relative and valigned

* fix border reacting to zoom on judgment

* add border to combo

* fix border xy/spacing for leaderboards (zoom not done)

* reset active customize element when entering gameplay

* fix borders for nps display

* Fix border zoom for leaderboards

* fix nps graph border

* Fix the check for moving the leaderboards border

* fix borders for replay buttons (disabled zoom)

zoom desyncs the buttons from their rollovers

* strong alpha helper message when moused over
  • Loading branch information
caiohsr14 authored and MinaciousGrace committed Nov 10, 2018
1 parent 8c0c084 commit 5321555
Show file tree
Hide file tree
Showing 14 changed files with 1,416 additions and 1,050 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ t[#t + 1] = LoadActor("leaderboard")
if GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerController() == "PlayerController_Replay" then
t[#t + 1] = LoadActor("replayscrolling")
end
if playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).CustomizeGameplay then
t[#t + 1] = LoadActor("messagebox")
end
return t
21 changes: 10 additions & 11 deletions Themes/Til Death/BGAnimations/ScreenGameplay overlay/lanecover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ local cover
local laneColor = color("#333333")

local cols = GAMESTATE:GetCurrentStyle():ColumnsPerPlayer()
local keymode = getCurrentKeyMode()
local allowedCustomization = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).CustomizeGameplay

local isCentered = ((cols >= 6) or PREFSMAN:GetPreference("Center1Player")) and GAMESTATE:GetNumPlayersEnabled() == 1
-- load from prefs later
local width = 64 * cols * playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).GameplaySizes[keymode].NotefieldWidth
local width = 64 * cols * MovableValues.NotefieldWidth
local padding = 8
local styleType = ToEnumShortString(GAMESTATE:GetCurrentStyle():GetStyleType())

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

local P1X =
SCREEN_CENTER_X + playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).GameplayXYCoordinates[keymode].NotefieldX
SCREEN_CENTER_X + MovableValues.NotefieldX

if not isCentered then
P1X = THEME:GetMetric("ScreenGameplay", string.format("PlayerP1%sX", styleType))
Expand Down Expand Up @@ -102,11 +101,11 @@ end

local function input(event)
if getAutoplay() ~= 0 and playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).LaneCover ~= 0 then
if event.DeviceInput.button == "DeviceButton_r" then
rPressed = not (event.type == "InputEventType_Release")
if event.DeviceInput.button == "DeviceButton_r" and event.type ~= "InputEventType_Release" then
rPressed = rPressed and false or true
end
if event.DeviceInput.button == "DeviceButton_t" then
tPressed = not (event.type == "InputEventType_Release")
if event.DeviceInput.button == "DeviceButton_t" and event.type ~= "InputEventType_Release" then
tPressed = tPressed and false or true
end
if rPressed and event.type ~= "InputEventType_Release" then
if event.DeviceInput.button == "DeviceButton_left" then
Expand All @@ -118,11 +117,11 @@ local function input(event)
end
if tPressed and event.type ~= "InputEventType_Release" then
if event.DeviceInput.button == "DeviceButton_left" then
width = 64 * cols * playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).GameplaySizes[keymode].NotefieldWidth - 0.01
width = 64 * cols * MovableValues.NotefieldWidth - 0.01
cover:playcommand("Update")
end
if event.DeviceInput.button == "DeviceButton_right" then
width = 64 * cols * playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).GameplaySizes[keymode].NotefieldWidth + 0.01
width = 64 * cols * MovableValues.NotefieldWidth + 0.01
cover:playcommand("Update")
end
end
Expand Down Expand Up @@ -182,7 +181,7 @@ if enabledP1 then
end
end,
UpdateCommand = function(self)
P1X = SCREEN_CENTER_X + playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).GameplayXYCoordinates[keymode].NotefieldX
P1X = SCREEN_CENTER_X + MovableValues.NotefieldX
if isReverseP1 then
self:xy(P1X, SCREEN_TOP):zoomto((width + padding) * getNoteFieldScale(PLAYER_1), heightP1):valign(0):diffuse(
laneColor
Expand Down Expand Up @@ -254,7 +253,7 @@ local function Update(self)
end
self:SetUpdateRate(5)
if enabledP1 then
P1X = SCREEN_CENTER_X + playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).GameplayXYCoordinates[keymode].NotefieldX
P1X = SCREEN_CENTER_X + MovableValues.NotefieldX

if moveDownP1 then
if isReverseP1 then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
local allowedCustomization = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).CustomizeGameplay
local leaderboardEnabled = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).leaderboardEnabled and DLMAN:IsLoggedIn()

local entryActors = {}
local t =
Widg.Container {
y = SCREEN_HEIGHT / 10
x = MovableValues.LeaderboardX,
y = MovableValues.LeaderboardY,
name = "Leaderboard"
}
local leaderboardEnabled = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).leaderboardEnabled and DLMAN:IsLoggedIn()

if not leaderboardEnabled then
return t
end
Expand All @@ -19,6 +25,15 @@ local jdgs = {
"TapNoteScore_W5"
}

local function arbitraryLeaderboardSpacing(value)
for i, entry in ipairs(entryActors) do
entry.container:addy((i-1) * value)
end
if allowedCustomization then
Movable.DeviceButton_s.Border:playcommand("ChangeHeight", {val = entryActors[#entryActors].container:GetY() + ENTRY_HEIGHT})
end
end

if not DLMAN:GetCurrentRateFilter() then
DLMAN:ToggleRateFilter()
end
Expand Down Expand Up @@ -72,15 +87,14 @@ for i = 1, NUM_ENTRIES do
end
end

local entryActors = {}
for i = 1, NUM_ENTRIES do
entryActors[i] = {}
end
function scoreEntry(i)
local entryActor
local entry =
Widg.Container {
x = WIDTH / 40,
x = 0,
y = (i - 1) * ENTRY_HEIGHT * 1.3,
onInit = function(self)
entryActor = self
Expand Down Expand Up @@ -200,4 +214,24 @@ t.JudgmentMessageCommand = function(self, params)
end
end

t[#t + 1] = MovableBorder(WIDTH, 200, 1, 0, 0)

t.OnCommand = function(self, params)
if allowedCustomization then
Movable.DeviceButton_a.element = self
Movable.DeviceButton_s.element = self
Movable.DeviceButton_a.condition = true
Movable.DeviceButton_s.condition = true
Movable.DeviceButton_d.condition = NUM_ENTRIES > 1
Movable.DeviceButton_d.DeviceButton_up.arbitraryFunction = arbitraryLeaderboardSpacing
Movable.DeviceButton_d.DeviceButton_down.arbitraryFunction = arbitraryLeaderboardSpacing
Movable.DeviceButton_s.Border = self:GetChild("Border")
Movable.DeviceButton_d.Border = self:GetChild("Border")
setBorderAlignment(self:GetChild("Border"), 0, 0)
end
arbitraryLeaderboardSpacing(MovableValues.LeaderboardSpacing)
self:zoomtowidth(MovableValues.LeaderboardWidth)
self:zoomtoheight(MovableValues.LeaderboardHeight)
end

return t
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
local settext = BitmapText.settext

local function highlight(self)
self:queuecommand("Highlight")
end

local function highlightIfOver(self)
if isOver(self) then
self:diffusealpha(0.2)
else
self:diffusealpha(1)
end
end

return Def.ActorFrame {
OnCommand = function(self)
SCREENMAN:GetTopScreen():AddInputCallback(MovableInput)
self:SetUpdateFunction(highlight)
end,
Def.BitmapText {
Name = "message",
Font = "Common Normal",
InitCommand = function(self)
Movable.message = self
self:horizalign(left):vertalign(top):shadowlength(2):xy(10, 20):zoom(.5):visible(false)
end
},
Def.BitmapText {
Name = "Instructions",
Font = "Common Normal",
InitCommand = function(self)
self:horizalign(left):vertalign(top):xy(SCREEN_WIDTH - 240, 20):zoom(.5):visible(true)
end,
HighlightCommand = function(self)
highlightIfOver(self)
end,
OnCommand = function(self)
local text = {
"Enable AutoplayCPU with shift+f8\n",
"Press keys to toggle active elements",
"Right click cancels any active element\n",
"1: Judgement Text Position",
"2: Judgement Text Size",
"3: Combo Text Position",
"4: Combo Text Size",
"5: Error Bar Text Position",
"6: Error Bar Text Size",
"7: Target Tracker Text Position",
"8: Target Tracker Text Size",
"9: Full Progress Bar Position",
"0: Full Progress Bar Size",
"q: Mini Progress Bar Position",
"w: Display Percent Text Position",
"e: Display Percent Text Size",
"r: Notefield Position",
"t: Notefield Size",
"y: NPS Display Text Position",
"u: NPS Display Text Size",
"i: NPS Graph Position",
"o: NPS Graph Size",
"p: Judge Counter Position",
"a: Leaderboard Position",
"s: Leaderboard Size",
"d: Leaderboard Spacing",
"f: Replay Buttons Position",
--"g: Replay Buttons Size",
"h: Replay Buttons Spacing"
}
if playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).LaneCover ~= 0 then
table.insert(text, "/: Lane Cover Height")
end
self:settext(table.concat(text, "\n"))
end
}
}
Loading

0 comments on commit 5321555

Please sign in to comment.