From 35ac51be7d50c611dcc793d81ad4453f24d4a766 Mon Sep 17 00:00:00 2001 From: domdoc Date: Tue, 19 Jul 2022 18:02:11 +0200 Subject: [PATCH] Added console glow effects (knobs disabled) --- scripts/gameplay/console.lua | 78 ++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 12 deletions(-) diff --git a/scripts/gameplay/console.lua b/scripts/gameplay/console.lua index 6c5d24f..568fde9 100644 --- a/scripts/gameplay/console.lua +++ b/scripts/gameplay/console.lua @@ -1,11 +1,49 @@ local Dimensions = require 'common.dimensions' -local consoleBaseImage = gfx.CreateSkinImage("gameplay/console/base.png", 0) - local CONSOLE_W = 1352; local CONSOLE_H = 712; +local function createConsoleImage(name) + return gfx.CreateSkinImage("gameplay/console/"..name..".png", 0) +end + +local function renderConsoleImage(image, alpha) + gfx.BeginPath(); + gfx.ImageRect( + -CONSOLE_W/2, + -CONSOLE_H/2+350, + CONSOLE_W, + CONSOLE_H, + image, + alpha, + 0 + ); +end + +local consoleBaseImage = createConsoleImage("base") + +local buttonGlowImages = { + [0] = createConsoleImage("glow_bta"), + createConsoleImage("glow_btb"), + createConsoleImage("glow_btc"), + createConsoleImage("glow_btd"), + createConsoleImage("glow_fxl"), + createConsoleImage("glow_fxr"), +}; + +local knobGlowImages = { + [0] = createConsoleImage("glow_voll"), + createConsoleImage("glow_volr"), +}; + +local lastKnobState = { + [0] = -1, + -1 +}; + +local doFlash = true; + local render = function (deltaTime, critLineCenterX, critLineCenterY, critLineRotation) local resx, resy = game.GetResolution(); if (resx > resy) then @@ -18,16 +56,32 @@ local render = function (deltaTime, critLineCenterX, critLineCenterY, critLineRo critLineRotation ) - gfx.BeginPath(); - gfx.ImageRect( - -CONSOLE_W/2, - -CONSOLE_H/2+350, - CONSOLE_W, - CONSOLE_H, - consoleBaseImage, - 1, - 0 - ); + renderConsoleImage(consoleBaseImage, 1) + + if doFlash then + for button=0,5 do + if game.GetButton(button) then + renderConsoleImage(buttonGlowImages[button], 0.75) + end + end + + -- Knobs also work + -- commented out do to missing/incorrect textures + + --[[ + for knob=0,1 do + local state = game.GetKnob(knob) + + if state ~= lastKnobState[knob] then + renderConsoleImage(knobGlowImages[knob], 1) + + lastKnobState[knob] = state + end + end + ]] + end + + doFlash = not doFlash; end return { -- 2.40.1