diff --git a/config-definitions.json b/config-definitions.json index 844db8a..4236561 100644 --- a/config-definitions.json +++ b/config-definitions.json @@ -46,5 +46,14 @@ "label": "Turn on Rasis", "type": "bool", "default": false + }, + + "separator_e": {}, + "Gameplay": { "type": "label" }, + + "gameplay_ucDifferentColor": { + "label": "Use different colors for UC and PUC chain numbers", + "type": "bool", + "default": false } } diff --git a/scripts/challengeresult.lua b/scripts/challengeresult.lua index 278a63c..b246413 100644 --- a/scripts/challengeresult.lua +++ b/scripts/challengeresult.lua @@ -1,5 +1,7 @@ local Easing = require("common.easings"); local Footer = require("components.footer"); +local DiffRectangle = require('components.diff_rectangle'); +local common = require('common.common'); local VolforceWindow = require("components.volforceWindow") @@ -23,9 +25,41 @@ local appealCardImage = gfx.CreateSkinImage("crew/appeal_card.png", 0); local danBadgeImage = gfx.CreateSkinImage("dan/inf.png", 0); local crewImage = gfx.CreateSkinImage("crew/portrait.png", 0); +local notchesImage = gfx.CreateSkinImage("challenge_result/notches.png", 0); +local trackBarsImage = gfx.CreateSkinImage("challenge_result/track_bars.png", 0); + +local completionFailImage = gfx.CreateSkinImage("challenge_result/pass_states/fail.png", 0); +local completionPassImage = gfx.CreateSkinImage("challenge_result/pass_states/pass.png", 0); + local irHeartbeatRequested = false; local IRserverName = ""; +local badgeImages = { + gfx.CreateSkinImage("song_select/medal/nomedal.png", 1), + gfx.CreateSkinImage("song_select/medal/played.png", 1), + gfx.CreateSkinImage("song_select/medal/clear.png", 1), + gfx.CreateSkinImage("song_select/medal/hard.png", 1), + gfx.CreateSkinImage("song_select/medal/uc.png", 1), + gfx.CreateSkinImage("song_select/medal/puc.png", 1), +} + +local gradeImages = { + S = gfx.CreateSkinImage("common/grades/S.png", 0), + AAA_P = gfx.CreateSkinImage("common/grades/AAA+.png", 0), + AAA = gfx.CreateSkinImage("common/grades/AAA.png", 0), + AA_P = gfx.CreateSkinImage("common/grades/AA+.png", 0), + AA = gfx.CreateSkinImage("common/grades/AA.png", 0), + A_P = gfx.CreateSkinImage("common/grades/A+.png", 0), + A = gfx.CreateSkinImage("common/grades/A.png", 0), + B = gfx.CreateSkinImage("common/grades/B.png", 0), + C = gfx.CreateSkinImage("common/grades/C.png", 0), + D = gfx.CreateSkinImage("common/grades/D.png", 0), + none = gfx.CreateSkinImage("common/grades/none.png", 0), +} + +local percRequired = 1; +local percGet = 0; + -- AUDIO game.LoadSkinSample("challenge_result.wav") @@ -38,6 +72,7 @@ end local function handleSfx() if not bgSfxPlayed then + common.stopMusic(); game.PlaySample("challenge_result.wav", true) bgSfxPlayed = true end @@ -49,6 +84,17 @@ local function handleSfx() end end +function splitString(inputstr, sep) + if sep == nil then + sep = "%s" + end + local t={} + for str in string.gmatch(inputstr, "([^"..sep.."]+)") do + table.insert(t, str) + end + return t +end + local function load_number_image(path) local images = {} for i = 0, 9 do @@ -127,21 +173,100 @@ end local scoreNumber = load_number_image("score_num"); -function drawScorePanelContent() - game.Log("Drawing scores...", game.LOGGER_INFO) -- debug +function drawChartResult(deltaTime, x, y, chartResult) + gfx.Save() + gfx.LoadSkinFont('NotoSans-Regular.ttf') + + gfx.FontSize(28) + gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE) + gfx.BeginPath() + gfx.GlobalAlpha(1); + gfx.Text(chartResult.title, x+160,y+32); + + DiffRectangle.render(deltaTime, x+287.5, y+67, 0.85, chartResult.difficulty, chartResult.level) + + local score = chartResult.score or 0; + + draw_number(x + 500, y+80, 1.0, math.floor(score / 10000), 4, scoreNumber, true, 0.30, 1.12) + draw_number(x + 655, y+85, 1.0, score, 4, scoreNumber, true, 0.22, 1.12) + + + local gradeImageKey = string.gsub(chartResult.grade, '+', '_P'); + local gradeImage = gradeImages[gradeImageKey] or gradeImages.D + gfx.BeginPath() + gfx.ImageRect(x+800, y+12, 79, 79, gradeImage, 1, 0) + + + if chartResult.badge then + local badgeImage = badgeImages[chartResult.badge+1]; + gfx.BeginPath() + gfx.ImageRect(x+900, y+16, 79*1.05, 69*1.05, badgeImage, 1, 0) + end + + + gfx.Restore() +end + +function drawScorePanelContent(deltaTime) + -- game.Log("Drawing scores...", game.LOGGER_INFO) -- debug for i, chart in ipairs(result.charts) do - if chart.score == nil then - game.Log("Score does not exist? Quitting loop...", game.LOGGER_WARNING) - break - end - game.Log("#" .. i .. " chart.score: " .. chart.score, game.LOGGER_INFO) -- debug - -- Draw score - draw_number(250, 150, 1.0, math.floor(chart.score / 10000), 4, scoreNumber, true, 0.40, 1.12) - -- still not sure how ui scaling/layers works in this game, still figuring it out :p + -- if chart.score == nil then + -- game.Log("Score does not exist? Quitting loop...", game.LOGGER_WARNING) + -- break + -- end + + drawChartResult(deltaTime, 0, 836+(165*(i-1)), chart); end end +function drawDecorations() + gfx.BeginPath() + gfx.ImageRect(118, 846.5, 43*0.855, 429*0.855, notchesImage, 1, 0) + + gfx.BeginPath() + gfx.ImageRect(400, 807, 367*0.857, 429*0.857, trackBarsImage, 1, 0) +end + +function drawCompletion() + local completitionImage = completionFailImage; + if result.passed then + completitionImage = completionPassImage; + end + + gfx.BeginPath() + gfx.ImageRect(63, 1331, 766*0.85, 130*0.85, completitionImage, 1, 0) + + draw_number(925, 1370, 1.0, percGet, 3, scoreNumber, true, 0.3, 1.12) + + + gfx.BeginPath(); + gfx.Rect(741, 1402, 278*math.min(1, percGet / percRequired), 6); + gfx.FillColor(255, 128, 0, 255); + gfx.Fill() +end + + +function result_set() + local reqTextWords = splitString(result.requirement_text, ' '); + for index, word in ipairs(reqTextWords) do + if string.find(word, '%%') ~= nil then -- %% = %, because % is an escape char + local percNumber = tonumber(string.gsub(word, '%%', ''), 10) + percRequired = percNumber; + end + end + + game.Log(percRequired, game.LOGGER_ERROR); + + local a = 0; + for i, chart in ipairs(result.charts) do + a = a + chart.percent; + game.Log('#' .. i .. ' got ' .. chart.percent .. '% // ACC at ' .. a, game.LOGGER_ERROR); + end + percGet = a / #result.charts; +end + + local IR_HeartbeatResponse = function(res) if res.statusCode == IRData.States.Success then IRserverName = res.body.serverName .. " " .. res.body.irVersion; @@ -167,9 +292,13 @@ function render(deltaTime) drawBackground() + drawDecorations() + drawPlayerInfo() - drawScorePanelContent() + drawScorePanelContent(deltaTime) + + drawCompletion() drawHeader() Footer.draw(deltaTime); diff --git a/scripts/gameplay.lua b/scripts/gameplay.lua index 8921315..796ecbd 100644 --- a/scripts/gameplay.lua +++ b/scripts/gameplay.lua @@ -59,7 +59,7 @@ function render(deltaTime) end function render_crit_base(deltaTime) - CritLine.renderBase(deltaTime, gameplay.critLine.x, gameplay.critLine.y, -gameplay.critLine.rotation); + CritLine.renderBase(deltaTime, gameplay.critLine.x, gameplay.critLine.y, -gameplay.critLine.rotation, gameplay.critLine.cursors); Console.render(deltaTime, gameplay.critLine.x, gameplay.critLine.y, -gameplay.critLine.rotation); end diff --git a/scripts/gameplay/chain.lua b/scripts/gameplay/chain.lua index 1076974..ed2ffb6 100644 --- a/scripts/gameplay/chain.lua +++ b/scripts/gameplay/chain.lua @@ -81,6 +81,10 @@ local render = function (deltaTime, comboState, combo, critLineCenterX, critLine chainNumbers = chainNumbersPUC --puc elseif comboState == 1 then chainNumbers = chainNumbersUC --uc + + if (not game.GetSkinSetting('gameplay_ucDifferentColor')) then + chainNumbers = chainNumbersPUC -- force the PUC numbers in case the setting is turned off + end end -- \_ chain _/ diff --git a/scripts/gameplay/crit_line.lua b/scripts/gameplay/crit_line.lua index 0bbf9cc..f5f8875 100644 --- a/scripts/gameplay/crit_line.lua +++ b/scripts/gameplay/crit_line.lua @@ -1,6 +1,7 @@ local baseImage = gfx.CreateSkinImage("gameplay/crit_line/base.png", 0) local textImage = gfx.CreateSkinImage("gameplay/crit_line/text.png", 0) +local cursorImage = gfx.CreateSkinImage("gameplay/crit_line/cursor.png", 0) local CRITBAR_W = 1496 local CRITBAR_H = 348 @@ -16,7 +17,28 @@ local setUpTransforms = function (x,y,rotation) gfx.Scale(scale,scale) end -local renderBase = function (deltaTime, centerX, centerY, rotation) +local drawCursors = function (cursors) + local cursorW = 598*0.2; + local cursorH = 673*0.2; + for i = 0, 1, 1 do + gfx.Save(); + local cursor = cursors[i]; + gfx.BeginPath(); + gfx.SkewX(cursor.skew) + gfx.ImageRect( + cursor.pos - cursorW/2, + -cursorH/2, + cursorW, + cursorH, + cursorImage, + cursor.alpha, + 0 + ); + gfx.Restore(); + end +end + +local renderBase = function (deltaTime, centerX, centerY, rotation, cursors) setUpTransforms(centerX, centerY, rotation) gfx.BeginPath() @@ -35,6 +57,8 @@ local renderBase = function (deltaTime, centerX, centerY, rotation) 0 ); + drawCursors(cursors) + gfx.ResetTransform() end diff --git a/scripts/songtransition.lua b/scripts/songtransition.lua index 362d394..b046019 100644 --- a/scripts/songtransition.lua +++ b/scripts/songtransition.lua @@ -1,4 +1,6 @@ +local common = require('common.common'); + game.LoadSkinSample('song_transition_screen/transition_enter.wav'); local refBgImage = gfx.CreateSkinImage("songtransition/bg_old.png", 0) @@ -75,6 +77,7 @@ end function render(deltaTime) if not wasEnterSfxPlayed then + common.stopMusic(); game.PlaySample('song_transition_screen/transition_enter.wav'); wasEnterSfxPlayed = true; end @@ -135,14 +138,14 @@ function render_screen(progress) gfx.BeginPath() gfx.ImageRect(37.5, 1074, 1180*0.85, 343*0.85, infoOverlayPanel,1,0); + gfx.BeginPath() + gfx.ImageRect(10, 195.5, 1060, 1015, albumBgImage,1,0); + local jacket = song.jacket == 0 and noJacket or song.jacket gfx.BeginPath(); gfx.ImageRect(235, 385, 608, 608, jacket, 1, 0) gfx.ClosePath(); - gfx.BeginPath() - gfx.ImageRect(10, 195.5, 1060, 1015, albumBgImage,1,0); - gfx.TextAlign(gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE) gfx.FontSize(55) diff --git a/scripts/transition.lua b/scripts/transition.lua index 11e5c7e..a9de747 100644 --- a/scripts/transition.lua +++ b/scripts/transition.lua @@ -1,4 +1,6 @@ +local common = require('common.common'); + local transitionEnterAnimation; local transitionLeaveAnimation; @@ -19,6 +21,8 @@ function loadAnimations() end function render(deltaTime) + common.stopMusic(); + if not transitionEnterAnimation then loadAnimations() end diff --git a/textures/challenge_result/bar glows 3.png b/textures/challenge_result/notches.png similarity index 100% rename from textures/challenge_result/bar glows 3.png rename to textures/challenge_result/notches.png diff --git a/textures/challenge_result/track text.png b/textures/challenge_result/track_bars.png similarity index 100% rename from textures/challenge_result/track text.png rename to textures/challenge_result/track_bars.png diff --git a/textures/gameplay/crit_line/cursor.png b/textures/gameplay/crit_line/cursor.png new file mode 100644 index 0000000..924ba71 Binary files /dev/null and b/textures/gameplay/crit_line/cursor.png differ