diff --git a/config-definitions.json b/config-definitions.json index ac1c731..a60dc15 100644 --- a/config-definitions.json +++ b/config-definitions.json @@ -69,6 +69,27 @@ "default": true }, + "gameplay_earlyLateFor": { + "label": "Show Early/Late display for", + "type": "selection", + "default": "NEAR (or worse)", + "values": ["CRITICAL (or worse)", "NEAR (or worse)", "OFF"] + }, + + "gameplay_earlyLatePosition": { + "label": "Early/Late display position", + "type": "selection", + "default": "STANDARD", + "values": ["UPPER+", "UPPER", "STANDARD", "LOWER"] + }, + + "gameplay_msFor": { + "label": "Show millisecond display for", + "type": "selection", + "default": "NEAR (or worse)", + "values": ["ALL", "CRITICAL (or worse)", "NEAR (or worse)", "NONE"] + }, + "separator_f": {}, "Debug": { "type": "label" }, diff --git a/scripts/gameplay.lua b/scripts/gameplay.lua index 72771b4..024c25b 100644 --- a/scripts/gameplay.lua +++ b/scripts/gameplay.lua @@ -18,6 +18,7 @@ local Chain = require('gameplay.chain') local LaserAlert = require('gameplay.laser_alert') local HitFX = require 'gameplay.hitfx' +local EarlyLate = require 'gameplay.earlylate' local TrackEnd = require('gameplay.track_end') @@ -59,6 +60,8 @@ function render(deltaTime) Chain.render(deltaTime, gameplay.comboState, chain, gameplay.critLine.x, gameplay.critLine.y); LaserAlert.render(deltaTime); + + EarlyLate.render(deltaTime) end function render_crit_base(deltaTime) @@ -113,6 +116,10 @@ function button_hit(button, rating, delta) HitFX.TriggerAnimation("Crit", button + 1) end end + + if 0 < rating and rating < 3 then + EarlyLate.TriggerAnimation(rating, delta) + end end function laser_slam_hit(slamLength, startPos, endPost, index) diff --git a/scripts/gameplay/earlylate.lua b/scripts/gameplay/earlylate.lua index ce6aadf..df6fa69 100644 --- a/scripts/gameplay/earlylate.lua +++ b/scripts/gameplay/earlylate.lua @@ -1,30 +1,94 @@ +local Dimensions = require "common.dimensions" -local desw = 1080; -local desh = 1920; +-- Used for comparing button_hit()'s delta parameter with the +-- gameplay_earlyLateFor/gameplay_msDisplay skin settings values. +-- If the number is <= delta then the EarlyLate/ms should be shown +local compare = { + ["ALL"] = 2, + ["CRITICAL (or worse)"] = 2, + ["NEAR (or worse)"] = 1, + ["NONE"] = -1, + ["OFF"] = -1 +} -local transitionExistScale = 0; +local heightFractions = { + ["UPPER+"] = 2, + ["UPPER"] = 3, + ["STANDARD"] = 3.5, + ["LOWER"] = 5, +} -local tickTransitions = function (deltaTime) - - if transitionExistScale < 1 then - transitionExistScale = transitionExistScale + deltaTime / 2 -- transition should last for that time in seconds +local earlyLateFor = compare[game.GetSkinSetting("gameplay_earlyLateFor")] +local msFor = compare[game.GetSkinSetting("gameplay_msFor")] +local heightFraction = heightFractions[game.GetSkinSetting("gameplay_earlyLatePosition")] + +local EarlyLate = { + timer = 0, + lastMillisec = 0, + showEarlyLate = false, + showMillisec = false, +} + +function EarlyLate.render(deltaTime) + if EarlyLate.timer <= 0 then + return + end + + EarlyLate.timer = EarlyLate.timer - deltaTime * 100 + + local screenW, screenH = Dimensions.screen.width, Dimensions.screen.height + local screenCenterX = screenW / 2 + + local desh + + if screenH > screenW then + desh = 1920 + else + desh = 1080 + end + + local scale = desh / screenH + local y = screenH / 8 * heightFraction + + gfx.BeginPath() + gfx.LoadSkinFont("dfmarugoth.ttf") + gfx.FontSize(12 * scale) + + if EarlyLate.showEarlyLate then + gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_BASELINE) + + if EarlyLate.lastMillisec < 0 then + gfx.FillColor(224, 153, 179) + gfx.FastText("EARLY", screenCenterX - 100 * scale, y) + else + gfx.FillColor(90, 131, 211) + gfx.FastText("LATE", screenCenterX - 100 * scale, y) + end + end + + if EarlyLate.showMillisec then + local msString = string.format("%dms", EarlyLate.lastMillisec) + + if EarlyLate.lastMillisec >= 0 then + msString = "+"..msString -- prepend + sign for lates + end + + gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_BASELINE) + + gfx.FastText(msString, screenCenterX + 100 * scale, y) end end -local render = function (deltaTime, comboState, combo, critLineCenterX, critLineCenterY) - tickTransitions(deltaTime) +function EarlyLate.TriggerAnimation(rating, millisec) + local showEarlyLate = rating <= earlyLateFor + local showMillisec = rating <= msFor - if (transitionExistScale >= 1) then - return; + if showEarlyLate or showMillisec then + EarlyLate.timer = 120 + EarlyLate.lastMillisec = millisec + EarlyLate.showEarlyLate = showEarlyLate + EarlyLate.showMillisec = showMillisec end - - end -local trigger = function () - -end - -return { - render=render -} \ No newline at end of file +return EarlyLate \ No newline at end of file