Fix crash on invalid idol animation #44

Merged
hersi merged 1 commits from 43-fix-crash-invalid-crew into master 2022-11-12 13:10:04 +01:00
5 changed files with 52 additions and 36 deletions

View File

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

View File

@ -1,6 +1,6 @@
local MAJOR = 0 local MAJOR = 0
local MINOR = 2 local MINOR = 2
local PATCH = 2 local PATCH = 3
local function getLongVersion() local function getLongVersion()
return "USC:E:G:S:" .. MAJOR .. MINOR .. PATCH 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 msg = game.GetSkinSetting("MSG");
local normname = game.GetSkinSetting("username") 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_jacket = gfx.CreateSkinImage("multi/lobby/multi_jacket.png", 1);
local m_base_panel = gfx.CreateSkinImage("multi/lobby/multi_base_panel.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_graid1 = gfx.CreateSkinImage("multi/lobby/gradient_bottom.png", 1);
local bg_graid2 = gfx.CreateSkinImage("multi/lobby/gradient_top.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; 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() local resX,resY = game.GetResolution()
@ -118,6 +120,7 @@ end
local SERVER = game.GetSkinSetting("multi.server") local SERVER = game.GetSkinSetting("multi.server")
local drawIdol = function(deltaTime) local drawIdol = function(deltaTime)
if idolAnimation then
local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime); local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime);
if idolAnimTickRes == 1 then if idolAnimTickRes == 1 then
gfx.GlobalAlpha(idolAnimTransitionScale); gfx.GlobalAlpha(idolAnimTransitionScale);
@ -131,6 +134,7 @@ local drawIdol = function(deltaTime)
gfx.GlobalAlpha(1); gfx.GlobalAlpha(1);
end end
end end
end
songjacket = function() -- self explanatory songjacket = function() -- self explanatory

View File

@ -8,7 +8,7 @@ local lang = require("language.call")
require('common.gameconfig') require('common.gameconfig')
local creww = game.GetSkinSetting("single_idol") local crew = game.GetSkinSetting("single_idol")
local VolforceWindow = require('components.volforceWindow') local VolforceWindow = require('components.volforceWindow')
@ -137,7 +137,11 @@ local clearBadgeImages = {
} }
-- ANIMS -- 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 transitionEnterScale = 0;
local idolAnimTransitionScale = 0; local idolAnimTransitionScale = 0;
@ -265,6 +269,7 @@ function drawTimingBar(y, value, max, type)
end end
local drawIdol = function(deltaTime) local drawIdol = function(deltaTime)
if idolAnimation then
local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime); local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime);
if idolAnimTickRes == 1 then if idolAnimTickRes == 1 then
gfx.GlobalAlpha(idolAnimTransitionScale); gfx.GlobalAlpha(idolAnimTransitionScale);
@ -278,6 +283,7 @@ local drawIdol = function(deltaTime)
gfx.GlobalAlpha(1); gfx.GlobalAlpha(1);
end end
end end
end
local drawbgrade = function() local drawbgrade = function()
gfx.BeginPath(); gfx.BeginPath();

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 -- load audio samples
for _, path in pairs(resources.audiosamples) do for _, path in pairs(resources.audiosamples) do
game.LoadSkinSample(path) game.LoadSkinSample(path)
@ -306,6 +310,7 @@ local function draw_titlescreen(deltaTime)
gfx.BeginPath() gfx.BeginPath()
Background.draw(deltaTime) Background.draw(deltaTime)
if resources.anims.idolAnimation then
local idolAnimTickRes = gfx.TickAnimation(resources.anims.idolAnimation, deltaTime) local idolAnimTickRes = gfx.TickAnimation(resources.anims.idolAnimation, deltaTime)
if idolAnimTickRes == 1 then if idolAnimTickRes == 1 then
gfx.GlobalAlpha(idolAnimTransitionScale) 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.ImageRect(0, 0, Dim.design.width, Dim.design.height, resources.anims.idolAnimation, 1, 0)
gfx.GlobalAlpha(1) gfx.GlobalAlpha(1)
end end
end
-- Draw selector background -- Draw selector background
gfx.BeginPath() gfx.BeginPath()