Merge pull request 'Fix crash on invalid idol animation' (#44) from 43-fix-crash-invalid-crew into master

Reviewed-on: #44
This commit is contained in:
Hersi 2022-11-12 12:10:03 +00:00
commit 20600b9ca5
5 changed files with 52 additions and 36 deletions

View File

@ -33,7 +33,7 @@
"Crew": { "type": "label" },
"single_idol": {
"label": "!!!ALWAYS MATCH THE NAME!!!",
"label": "Crew idol animations, folder name in `crew/anim/`",
"type": "text",
"default": "nothing"
},

View File

@ -1,6 +1,6 @@
local MAJOR = 0
local MINOR = 2
local PATCH = 2
local PATCH = 3
local function getLongVersion()
return "USC:E:G:S:" .. MAJOR .. MINOR .. PATCH

View File

@ -7,7 +7,7 @@ local spinnybg = require('components.background');
local msg = game.GetSkinSetting("MSG");
local normname = game.GetSkinSetting("username")
local creww = game.GetSkinSetting("single_idol")
local crew = game.GetSkinSetting("single_idol")
local m_jacket = gfx.CreateSkinImage("multi/lobby/multi_jacket.png", 1);
local m_base_panel = gfx.CreateSkinImage("multi/lobby/multi_base_panel.png", 1);
@ -28,9 +28,11 @@ local bg = gfx.CreateSkinImage("multi/lobby/bg.png", 1);
local bg_graid1 = gfx.CreateSkinImage("multi/lobby/gradient_bottom.png", 1);
local bg_graid2 = gfx.CreateSkinImage("multi/lobby/gradient_top.png", 1);
local idolAnimation = gfx.LoadSkinAnimation('crew/anim/'..creww, 1 / 30, 0, true);
local idolAnimation = gfx.LoadSkinAnimation('crew/anim/'..crew, 1 / 30, 0, true);
local idolAnimTransitionScale = 0;
if not idolAnimation then
game.Log("Crew folder crew/anim/"..crew.." does not exist.", game.LOGGER_WARNING)
end
local resX,resY = game.GetResolution()
@ -118,6 +120,7 @@ end
local SERVER = game.GetSkinSetting("multi.server")
local drawIdol = function(deltaTime)
if idolAnimation then
local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime);
if idolAnimTickRes == 1 then
gfx.GlobalAlpha(idolAnimTransitionScale);
@ -130,6 +133,7 @@ local drawIdol = function(deltaTime)
gfx.ImageRect(0, 0, resX,resY, idolAnimation, 1, 0);
gfx.GlobalAlpha(1);
end
end
end
songjacket = function() -- self explanatory

View File

@ -8,7 +8,7 @@ local lang = require("language.call")
require('common.gameconfig')
local creww = game.GetSkinSetting("single_idol")
local crew = game.GetSkinSetting("single_idol")
local VolforceWindow = require('components.volforceWindow')
@ -137,7 +137,11 @@ local clearBadgeImages = {
}
-- ANIMS
local idolAnimation = gfx.LoadSkinAnimation('crew/anim/'..creww, 1 / 30, 0, true);
local idolAnimation = gfx.LoadSkinAnimation('crew/anim/'..crew, 1 / 30, 0, true);
if not idolAnimation then
game.Log("Crew folder crew/anim/"..crew.." does not exist.", game.LOGGER_WARNING)
end
local transitionEnterScale = 0;
local idolAnimTransitionScale = 0;
@ -265,6 +269,7 @@ function drawTimingBar(y, value, max, type)
end
local drawIdol = function(deltaTime)
if idolAnimation then
local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime);
if idolAnimTickRes == 1 then
gfx.GlobalAlpha(idolAnimTransitionScale);
@ -277,6 +282,7 @@ local drawIdol = function(deltaTime)
gfx.ImageRect(0, 0, desw, desh, idolAnimation, 1, 0);
gfx.GlobalAlpha(1);
end
end
end
local drawbgrade = function()

View File

@ -40,6 +40,10 @@ local resources = {
}
}
if not resources.anims.idolAnimation then
game.Log("Crew folder crew/anim/"..crew.." does not exist.", game.LOGGER_WARNING)
end
-- load audio samples
for _, path in pairs(resources.audiosamples) do
game.LoadSkinSample(path)
@ -306,6 +310,7 @@ local function draw_titlescreen(deltaTime)
gfx.BeginPath()
Background.draw(deltaTime)
if resources.anims.idolAnimation then
local idolAnimTickRes = gfx.TickAnimation(resources.anims.idolAnimation, deltaTime)
if idolAnimTickRes == 1 then
gfx.GlobalAlpha(idolAnimTransitionScale)
@ -317,6 +322,7 @@ local function draw_titlescreen(deltaTime)
gfx.ImageRect(0, 0, Dim.design.width, Dim.design.height, resources.anims.idolAnimation, 1, 0)
gfx.GlobalAlpha(1)
end
end
-- Draw selector background
gfx.BeginPath()