+ banner and gauge to gameplay & - excessive ars gauge variant since that's merged with normal excessive now

This commit is contained in:
FajsiEx 2021-08-31 19:52:02 +02:00
parent e444354f32
commit 5744aa735d
8 changed files with 155 additions and 0 deletions

View File

@ -1,8 +1,10 @@
local VolforceWindow = require('components.volforceWindow') local VolforceWindow = require('components.volforceWindow')
local Banner = require('gameplay.banner')
local CritLine = require('gameplay.crit_line') local CritLine = require('gameplay.crit_line')
local Console = require('gameplay.console') local Console = require('gameplay.console')
local Gauge = require('gameplay.gauge')
local resx, resy = game.GetResolution() local resx, resy = game.GetResolution()
local desw, desh; local desw, desh;
@ -18,6 +20,14 @@ end
function render(deltaTime) function render(deltaTime)
resetLayoutInformation(); resetLayoutInformation();
gfx.Scale(scale, scale); gfx.Scale(scale, scale);
Banner.render(deltaTime);
Gauge.render(
deltaTime,
gameplay.gauge.type,
gameplay.gauge.value,
(game.GetSkinSetting('_gaugeARS') == 1)
);
end end
function render_crit_base(deltaTime) function render_crit_base(deltaTime)

View File

@ -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
}

118
scripts/gameplay/gauge.lua Normal file
View File

@ -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
}

View File

Before

Width:  |  Height:  |  Size: 646 KiB

After

Width:  |  Height:  |  Size: 646 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB