added skipIntro skin setting

moved json.lua into common
renamed common.lua to util.lua
moved stopMusic() into common/sound.lua
moved numbers.lua into components
removed unused shared directory
removed unused settingswheel.lua
This commit is contained in:
Hersi 2022-03-04 04:06:19 +01:00
parent 98ab8bfb62
commit af71838493
23 changed files with 124 additions and 134 deletions

View File

@ -23,6 +23,12 @@
"default": false
},
"animations_skipIntro": {
"type": "bool",
"label": "Skip intro splash screens",
"default": false
},
"separator_c": {},
"Crew": { "type": "label" },

View File

@ -1,9 +1,10 @@
local Easing = require("common.easing");
local Footer = require("components.footer");
local DiffRectangle = require('components.diff_rectangle');
local common = require('common.common');
local Numbers = require('common.numbers')
local common = require('common.util');
local Sound = require("common.sound")
local Numbers = require('components.numbers')
local VolforceWindow = require("components.volforceWindow")
-- Window variables
@ -89,7 +90,7 @@ end
local function handleSfx()
if not bgSfxPlayed then
common.stopMusic();
Sound.stopMusic();
game.PlaySample("challenge_result.wav", true)
bgSfxPlayed = true
end

11
scripts/common/sound.lua Normal file
View File

@ -0,0 +1,11 @@
local stopMusic = function ()
local musicPlaying = game.GetSkinSetting('_musicPlaying');
if musicPlaying and musicPlaying ~= '' then
game.StopSample(musicPlaying);
game.SetSkinSetting("_musicPlaying", "")
end
end
return {
stopMusic = stopMusic
}

View File

@ -1,11 +1,3 @@
local stopMusic = function ()
local musicPlaying = game.GetSkinSetting('_musicPlaying');
if musicPlaying and musicPlaying ~= '' then
game.StopSample(musicPlaying);
game.SetSkinSetting("_musicPlaying", "")
end
end
local function splitString(inputstr, sep)
if sep == nil then
sep = "%s"
@ -42,10 +34,31 @@ local function round(num)
return num + (2^52 + 2^51) - (2^52 + 2^51)
end
local function sign(x)
return (
(x > 0) and 1
or
(x < 0) and -1
or
0
)
end
local function roundToZero(x)
if x < 0 then
return math.ceil(x)
elseif x > 0 then
return math.floor(x)
else
return 0
end
end
return {
stopMusic = stopMusic,
splitString = splitString,
filter = filter,
clamp = clamp,
round = round
round = round,
sign = sign,
roundToZero = roundToZero
}

View File

@ -1,4 +1,4 @@
json = require "json"
json = require "common.json"
local header = {}
header["user-agent"] = "unnamed_sdvx_clone"

View File

@ -13,7 +13,7 @@ local LaserAlert = require('gameplay.laser_alert')
local TrackEnd = require('gameplay.track_end')
local json = require "json"
local json = require("common.json")
-- Window variables
local resX, resY

View File

@ -1,4 +1,4 @@
local Numbers = require('common.numbers')
local Numbers = require('components.numbers')
local chainLabel = gfx.CreateSkinImage("gameplay/chain/label.png", 0)

View File

@ -1,4 +1,4 @@
local Numbers = require('common.numbers')
local Numbers = require('components.numbers')
local bgImage = gfx.CreateSkinImage("gameplay/score_panel/bg.png", 0)

View File

@ -1,4 +1,4 @@
local Common = require('common.common')
local Common = require('common.util')
local Easing = require('common.easing')
local bgImage = gfx.CreateSkinImage("gameplay/track_end/bg.png", 0)

View File

@ -1,6 +1,7 @@
json = require "json"
local json = require("common.json")
local common = require('common.common');
local common = require('common.util');
local Sound = require("common.sound")
local difbar = require("components.diff_rectangle");
local spinnybg = require('components.background');
local msg = game.GetSkinSetting("MSG");
@ -833,7 +834,7 @@ render = function(deltaTime)
portrait = resY > resX
IR_Handle()
common.stopMusic();
Sound.stopMusic();
doffset = doffset * 0.9
ioffset = ioffset * 0.9

View File

@ -1,7 +1,7 @@
local Numbers = require('common.numbers')
local Easing = require('common.easing');
local Background = require('components.background');
local Footer = require('components.footer');
local Numbers = require('components.numbers')
local DiffRectangle = require('components.diff_rectangle');
local lang = require("language.call")

View File

@ -1,13 +0,0 @@
local idols ={
-- SDVX IV
nearnoah_summer={"crew/anim/nearnoah_summer", 1 / 30, 0, true}
-- SDVX V
-- SDVX III
}
return idols

View File

@ -1,5 +1,5 @@
local Common = require("common.common")
local Numbers = require("common.numbers")
local Common = require("common.util")
local Numbers = require('components.numbers')
local DiffRectangle = require("components.diff_rectangle")
local Header = require("components.headers.challengeSelectHeader")
local Footer = require("components.footer")

View File

@ -1,36 +0,0 @@
resx,resy = game.GetResolution()
local wheelY = -resy
local bgFade = 0
local yoff = 0
local lastSelected = 0
render = function(deltaTime, shown)
gfx.ResetTransform()
gfx.BeginPath();
gfx.LoadSkinFont("segoeui.ttf");
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE);
gfx.FontSize(40);
if shown then
bgFade = math.min(bgFade + deltaTime * 10, 1)
wheelY = math.min(wheelY + deltaTime * resy * 10, 0)
else
wheelY = math.max(wheelY - deltaTime * resy * 10, -resy)
bgFade = math.max(bgFade - deltaTime * 10, 0)
end
gfx.FillColor(0,0,0,math.floor(200 * bgFade))
gfx.Rect(0,0,resx,resy)
gfx.Fill()
gfx.BeginPath()
yoff = 0.8 * yoff + (settings.currentSelection - lastSelected)
lastSelected = settings.currentSelection
if bgFade > 0 then
for i,setting in ipairs(settings) do
if i == settings.currentSelection then
gfx.FillColor(255,255,255)
else
gfx.FillColor(70,70,70)
end
gfx.FastText(string.format("%s: %s", setting.name, setting.value), resx/2, resy/2 + 40 * (i - settings.currentSelection + yoff) + wheelY, 40, gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE);
end
end
end

View File

@ -1,8 +1,9 @@
require('common')
local Easing = require('common.easing')
local Background = require('components.background')
local common = require('common.common')
local Numbers = require('common.numbers')
local common = require('common.util')
local Sound = require("common.sound")
local Numbers = require('components.numbers')
local VolforceCalc = require('components.volforceCalc')
@ -949,7 +950,7 @@ render = function (deltaTime)
game.SetSkinSetting('_currentScreen', 'songwheel')
common.stopMusic();
Sound.stopMusic();
-- detect resolution change
local resx, resy = game.GetResolution();

View File

@ -1,6 +1,7 @@
local common = require('common.common');
local Numbers = require('common.numbers')
local common = require('common.util');
local Sound = require("common.sound")
local Numbers = require('components.numbers')
game.LoadSkinSample('song_transition_screen/transition_enter.wav');
@ -62,7 +63,7 @@ end
function render(deltaTime)
if not wasEnterSfxPlayed then
common.stopMusic();
Sound.stopMusic();
game.PlaySample('song_transition_screen/transition_enter.wav');
wasEnterSfxPlayed = true;
end

View File

@ -1,7 +1,9 @@
local splashScreen = require('titlescreen.splash');
local titleScreen = require('titlescreen.title');
local modeSelectScreen = require('titlescreen.mode_select');
local serviceScreen = require('titlescreen.service');
local Common = require("common.util")
local splashScreen = require('titlescreen.splash')
local titleScreen = require('titlescreen.title')
local modeSelectScreen = require('titlescreen.mode_select')
local serviceScreen = require('titlescreen.service')
local screens = {
splash = {
@ -18,21 +20,26 @@ local screens = {
}
}
local currentScreen = screens.splash;
local url, version = game.UpdateAvailable()
local currentScreen = (
url and screens.service or ( -- if update available, show service screen,
game.GetSkinSetting("animations_skipIntro") and screens.title or screens.splash -- else show splash screen, if skipIntro is not set.
)
)
local function handleScreenResponse(res)
if (res.eventType == 'switch') then
if (not screens[res.toScreen]) then
game.Log('Undefined screen ' .. res.toScreen, game.LOGGER_ERROR);
return;
game.Log('Undefined screen ' .. res.toScreen, game.LOGGER_ERROR)
return
end
currentScreen = screens[res.toScreen]
end
end
function render(deltaTime)
handle_controller();
handle_controller()
local res = currentScreen.screen.render(deltaTime)
if res then
@ -43,32 +50,19 @@ end
function mouse_pressed(button)
if true then return 0 end
if (currentScreen.screen.onMousePressed) then
currentScreen.screen.onMousePressed(button);
currentScreen.screen.onMousePressed(button)
end
end
function button_pressed(button)
if (currentScreen.screen.onButtonPressed) then
currentScreen.screen.onButtonPressed(button);
end
end
function sign(x) return x > 0 and 1 or x < 0 and -1 or 0 end
function roundToZero(x)
if x < 0 then
return math.ceil(x)
elseif x > 0 then
return math.floor(x)
else
return 0
currentScreen.screen.onButtonPressed(button)
end
end
function deltaKnob(delta)
if math.abs(delta) > 1.5 * math.pi then
return delta + 2 * math.pi * sign(delta) * -1
return delta + 2 * math.pi * Common.sign(delta) * -1
end
return delta
end
@ -85,10 +79,8 @@ function handle_controller()
else
local newKnobs = {game.GetKnob(0), game.GetKnob(1)}
knobProgress = knobProgress - deltaKnob(lastKnobs[1] - newKnobs[1]) *
1.2
knobProgress = knobProgress - deltaKnob(lastKnobs[2] - newKnobs[2]) *
1.2
knobProgress = knobProgress - deltaKnob(lastKnobs[1] - newKnobs[1]) * 1.2
knobProgress = knobProgress - deltaKnob(lastKnobs[2] - newKnobs[2]) * 1.2
lastKnobs = newKnobs
@ -100,7 +92,7 @@ function handle_controller()
-- Positive
currentScreen.screen.onKnobsChange(1)
end
knobProgress = knobProgress - roundToZero(knobProgress)
knobProgress = knobProgress - Common.roundToZero(knobProgress)
end
end
end

View File

@ -1,3 +1,6 @@
local Dim = require("common.dimensions")
local Wallpaper = require("components.wallpaper")
local triggerSplashScreen = false
local rootMenu = {
@ -44,7 +47,13 @@ local menu = rootMenu
local index = 1;
render = function(deltaTime)
local function render(deltaTime)
Dim.updateResolution()
Wallpaper.render()
Dim.transformToScreenSpace()
gfx.BeginPath();
gfx.FillColor(0, 0, 0, 255);
gfx.Rect(0, 0, 1080, 1920);
@ -124,4 +133,7 @@ local onButtonPressed = function(button)
end
end
return {render = render, onButtonPressed = onButtonPressed}
return {
render = render,
onButtonPressed = onButtonPressed
}

View File

@ -1,6 +1,6 @@
local Common = require("common.common")
local Common = require("common.util")
local Dim = require("common.dimensions")
local BGPattern = require("components.wallpaper")
local Wallpaper = require("components.wallpaper")
local Easing = require("common.easing")
local splash1BgColor = {182, 0, 20}
@ -111,7 +111,7 @@ end
function render(deltaTime)
Dim.updateResolution()
BGPattern.render()
Wallpaper.render()
gfx.BeginPath()
Dim.transformToScreenSpace()

View File

@ -1,31 +1,31 @@
local Version = require('common.version')
local Dim = require("common.dimensions")
local version = require('common.version');
local Wallpaper = require("components.wallpaper")
local splash1Image = gfx.CreateSkinImage('titlescreen/title/background.png', 0);
local splash1Image = gfx.CreateSkinImage('titlescreen/title/background.png', 0)
local triggerModeSelect = false;
local triggerModeSelect = false
-- game.LoadSkinSample('titlescreen/splash/splash1.wav');
-- local splash1SfxPlayed = false;
local function render(deltaTime)
Dim.updateResolution()
local render = function (deltaTime)
gfx.BeginPath();
gfx.ImageRect(0, 0, 1080, 1920, splash1Image, 1, 0);
Wallpaper.render()
Dim.transformToScreenSpace()
gfx.BeginPath()
gfx.ImageRect(0, 0, Dim.design.width, Dim.design.height, splash1Image, 1, 0)
gfx.LoadSkinFont("segoeui.ttf")
gfx.FillColor(255, 255, 255, 255);
gfx.FillColor(255, 255, 255, 255)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
gfx.FontSize(28);
gfx.FontSize(28)
gfx.Text("USC:E:G:S:" .. version.MAJOR .. '.' .. version.MINOR .. '.' .. version.PATCH, 10, 10);
-- if (not splash1SfxPlayed) then
-- splash1SfxPlayed = true;
-- game.PlaySample('titlescreen/splash/splash1.wav');
-- end
gfx.Text("USC:E:G:S:" .. Version.MAJOR .. '.' .. Version.MINOR .. '.' .. Version.PATCH, 10, 10)
if (triggerModeSelect) then
triggerModeSelect = false;
triggerModeSelect = false
return {
eventType = 'switch',
toScreen = 'mode_select'
@ -33,9 +33,9 @@ local render = function (deltaTime)
end
end
local onButtonPressed = function(button)
local function onButtonPressed(button)
if button == game.BUTTON_STA then
triggerModeSelect = true;
triggerModeSelect = true
end
end

View File

@ -1,5 +1,6 @@
local common = require('common.common');
local common = require('common.util');
local Sound = require("common.sound")
local transitionEnterAnimation;
local transitionLeaveAnimation;
@ -46,7 +47,7 @@ function render(deltaTime)
gfx.BeginPath()
common.stopMusic();
Sound.stopMusic();
if not transitionEnterAnimation then
loadAnimations()