diff --git a/scripts/gameplay.lua b/scripts/gameplay.lua index f2defb2..68b8143 100644 --- a/scripts/gameplay.lua +++ b/scripts/gameplay.lua @@ -1,8 +1,10 @@ local VolforceWindow = require('components.volforceWindow') +local Banner = require('gameplay.banner') local CritLine = require('gameplay.crit_line') local Console = require('gameplay.console') +local Gauge = require('gameplay.gauge') local resx, resy = game.GetResolution() local desw, desh; @@ -18,6 +20,14 @@ end function render(deltaTime) resetLayoutInformation(); gfx.Scale(scale, scale); + + Banner.render(deltaTime); + Gauge.render( + deltaTime, + gameplay.gauge.type, + gameplay.gauge.value, + (game.GetSkinSetting('_gaugeARS') == 1) + ); end function render_crit_base(deltaTime) diff --git a/scripts/gameplay/banner.lua b/scripts/gameplay/banner.lua new file mode 100644 index 0000000..4d42dcc --- /dev/null +++ b/scripts/gameplay/banner.lua @@ -0,0 +1,27 @@ + +local bannerBaseImage = gfx.CreateSkinImage("gameplay/banner/base.png", 0) + +local BANNER_W = 1080; +local BANNER_H = 368; + + +local render = function (deltaTime) + -- Get the banner downscaled in whatever resolution it is, while maintaining the aspect ratio + local tw,th = gfx.ImageSize(bannerBaseImage); + BANNER_H = th * (1080/tw); + + gfx.BeginPath(); + gfx.ImageRect( + 0, + 0, + BANNER_W, + BANNER_H, + bannerBaseImage, + 1, + 0 + ); +end + +return { + render=render +} \ No newline at end of file diff --git a/scripts/gameplay/gauge.lua b/scripts/gameplay/gauge.lua new file mode 100644 index 0000000..6782ed7 --- /dev/null +++ b/scripts/gameplay/gauge.lua @@ -0,0 +1,118 @@ +local gaugeMarkerBgImage = gfx.CreateSkinImage("gameplay/gauges/marker_bg.png", 0) + +local gaugeWarnTransitionScale = 0; + +local gauges = { + { -- Effective + bg = gfx.CreateSkinImage("gameplay/gauges/effective/gauge_back.png", 0), + fill = gfx.CreateSkinImage("gameplay/gauges/effective/gauge_fill_fail.png", 0), + fillPass = gfx.CreateSkinImage("gameplay/gauges/effective/gauge_fill_pass.png", 0), + gaugeBreakpoint = 0.7, + gaugePass = 0.7 + }, + { -- Excessive + bg = gfx.CreateSkinImage("gameplay/gauges/excessive/gauge_back.png", 0), + bgArs = gfx.CreateSkinImage("gameplay/gauges/excessive/gauge_back_ars.png", 0), + fill = gfx.CreateSkinImage("gameplay/gauges/excessive/gauge_fill.png", 0), + gaugeBreakpoint = 0.3, + gaugeWarn = 0.3 + }, + { -- Permissive + bg = gfx.CreateSkinImage("gameplay/gauges/permissive/gauge_back.png", 0), + fill = gfx.CreateSkinImage("gameplay/gauges/permissive/gauge_fill.png", 0), + gaugeWarn = 0.3 + }, + { -- Blastive + bg = gfx.CreateSkinImage("gameplay/gauges/blastive/gauge_back.png", 0), + fill = gfx.CreateSkinImage("gameplay/gauges/blastive/gauge_fill.png", 0), + gaugeWarn = 0.3 + } +} + +local render = function (deltaTime, gaugeType, gaugeValue, isArsEnabled) + local gaugeIndex = math.min(gaugeType+1, 4) -- Any gauge type above blastive will be blastive as a fallback + local currentGauge = gauges[gaugeIndex] + + + local gaugeFillAlpha = 1; + local gaugeBgImage = currentGauge.bg; + local gaugeFillImage = currentGauge.fill; + + -- If the gauge has a specia bg for ARS, show it is ARS is enabled + if (currentGauge.bgArs and isArsEnabled) then + gaugeBgImage = currentGauge.bgArs + end + + -- If the pass threshold is defined + if (currentGauge.gaugePass) then + if (gaugeValue >= currentGauge.gaugePass) then + gaugeFillImage = currentGauge.fillPass + end + end + + -- If the warning threshold is defined + if (currentGauge.gaugeWarn) then + if gaugeValue < 0.3 then + gaugeFillAlpha = 1 - math.abs(gaugeWarnTransitionScale - 0.25); -- 100 -> 20 -> 100 + + gaugeWarnTransitionScale = gaugeWarnTransitionScale + deltaTime*10; + if gaugeWarnTransitionScale > 1 then + gaugeWarnTransitionScale = 0; + end + end + end + + local BgW, BgH = gfx.ImageSize(gaugeBgImage); + local FillW, FillH = gfx.ImageSize(gaugeFillImage); + local gaugePosX = 1080 - BgW - 110; + local gaugePosY = 1920/2 - BgH/2 - 95; + + gfx.BeginPath() + gfx.ImageRect(gaugePosX, gaugePosY, BgW, BgH, gaugeBgImage, 1, 0) + + gfx.GlobalAlpha(gaugeFillAlpha); + gfx.BeginPath() + gfx.Scissor(gaugePosX+18, gaugePosY+9+(FillH-(FillH*(gameplay.gauge.value))), FillW, FillH*(gameplay.gauge.value)) + gfx.ImageRect(gaugePosX+18, gaugePosY+9, FillW, FillH, gaugeFillImage, 1, 0) + gfx.ResetScissor(); + gfx.GlobalAlpha(1); + + -- Draw the breakpoint line if needed + if (currentGauge.gaugeBreakpoint) then + gfx.Save() + gfx.BeginPath() + gfx.GlobalAlpha(0.75); + + local lineY = gaugePosY+6+(FillH-(FillH*(currentGauge.gaugeBreakpoint))) + + gfx.MoveTo(gaugePosX+18, lineY) + gfx.LineTo(gaugePosX+36, lineY) + + gfx.StrokeWidth(2) + gfx.StrokeColor(255,255,255) + gfx.Stroke() + + gfx.ClosePath() + gfx.Restore() + end + + -- Draw gauge % label + local gaugeMarkerY = gaugePosY-6+(FillH-(FillH*(gaugeValue))) + + gfx.BeginPath() + gfx.ImageRect(gaugePosX-64, gaugeMarkerY, 83*0.85, 37*0.85, gaugeMarkerBgImage, 1, 0) + + gfx.BeginPath() + gfx.FillColor(255, 255, 255) + gfx.LoadSkinFont("Digital-Serial-Bold.ttf") + gfx.FontSize(22) + gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE) + gfx.Text(math.floor(gaugeValue * 100), gaugePosX-16, gaugeMarkerY+17) + + gfx.FontSize(16) + gfx.Text('%', gaugePosX-4, gaugeMarkerY+17) +end + +return { + render=render +} \ No newline at end of file diff --git a/textures/fill_top.png b/textures/gameplay/banner/base.png similarity index 100% rename from textures/fill_top.png rename to textures/gameplay/banner/base.png diff --git a/textures/gameplay/gauges/excessive_ars/gauge_back.png b/textures/gameplay/gauges/excessive/gauge_back_ars.png similarity index 100% rename from textures/gameplay/gauges/excessive_ars/gauge_back.png rename to textures/gameplay/gauges/excessive/gauge_back_ars.png diff --git a/textures/gameplay/gauges/excessive_ars/gauge_fill.png b/textures/gameplay/gauges/excessive_ars/gauge_fill.png deleted file mode 100644 index 9138638..0000000 Binary files a/textures/gameplay/gauges/excessive_ars/gauge_fill.png and /dev/null differ diff --git a/textures/gameplay/gauges/excessive_ars/gauge_front.png b/textures/gameplay/gauges/excessive_ars/gauge_front.png deleted file mode 100644 index 1914264..0000000 Binary files a/textures/gameplay/gauges/excessive_ars/gauge_front.png and /dev/null differ diff --git a/textures/gameplay/gauges/excessive_ars/gauge_mask.png b/textures/gameplay/gauges/excessive_ars/gauge_mask.png deleted file mode 100644 index a7501ac..0000000 Binary files a/textures/gameplay/gauges/excessive_ars/gauge_mask.png and /dev/null differ