lots of refactoring

added core scripts, which overwrite and/or extend built-in functionality
This commit is contained in:
Hersi 2023-08-19 04:25:27 +02:00
parent 90580a9b61
commit 495f0dc68a
28 changed files with 442 additions and 401 deletions

View File

@ -1,17 +0,0 @@
require "api.platform"
local FileSys = require "api.platform.filesys_impl"
if os.name() == Platform.WINDOWS then
require "api.platform.win.filesys"
elseif os.name() == Platform.LINUX then
require "api.platform.linux.filesys"
elseif os.name() == Platform.MACOS then
game.Log("MacOS specific implementation missing, loading linux filesys module", game.LOGGER_WARNING)
require "api.platform.linux.filesys"
else
game.Log("OS Platform not recognized, loading linux filesys module", game.LOGGER_WARNING)
require "api.platform.linux.filesys"
end
return FileSys

View File

@ -1,39 +0,0 @@
---@note setup code from: https://stackoverflow.com/a/30960054
local BinaryFormat = package.cpath:match("%p[\\|/]?%p(%a+)")
if BinaryFormat == "dll" then
function os.name()
return "Windows"
end
elseif BinaryFormat == "so" then
function os.name()
return "Linux"
end
elseif BinaryFormat == "dylib" then
function os.name()
return "MacOS"
end
end
BinaryFormat = nil
Platform = {
WINDOWS = "Windows",
LINUX = "Linux",
MACOS = "MacOS"
}
---Get OS platform lua is running on
function GetPlatform()
return os.name()
end
---Merge base module table with implementation table, overwriting base
---@param base any
---@param implementation any
function MergeModules(base, implementation)
for key, value in pairs(implementation) do
base[key] = value
end
end

View File

@ -1,46 +0,0 @@
local FileSys = require "api.platform.filesys_impl"
FileSys.sep = "\\"
function FileSys.getcwd()
local cwd, popen = "", io.popen
local pfile, err = popen("cd")
if not pfile or err ~= 0 then
game.Log(tostring(FileSys) .. ".getcwd() : popen failed executing " .. tostring(err), game.LOGGER_ERROR)
return nil
end
cwd = pfile:read()
pfile:close()
return cwd
end
local baseNormpath = FileSys.normpath
function FileSys.normpath(path)
path = baseNormpath(path)
path = path:gsub("/", "\\")
return path
end
function FileSys.scandir(path)
local i, t, popen = 0, {}, io.popen
local pfile, err = popen('dir "' .. path .. '" /b /ad')
if not pfile or err ~= 0 then
game.Log(tostring(FileSys) .. ".scandir() : popen failed executing " .. tostring(err), game.LOGGER_ERROR)
return nil
end
for filename in pfile:lines() do
i = i + 1
t[i] = filename
end
pfile:close()
return t
end

View File

@ -1,105 +0,0 @@
require("common.globals")
--file reader utility functions
---Get game path
---@return string, string
local function getGamePath()
return debug.getinfo(1,"S").source:sub(2):match("(.*)([\\/])skins") -- this is very hacky :)
end
local function readBytes(_file)
local out = {}
repeat
local buffer = _file:read(4*1024)
for c in (buffer or ''):gmatch(".") do
table.insert(out, c:byte())
end
until not buffer
return out
end
---Read a file in the game folder by lines
---@param path string relative path to game file
---@param mode? openmode default "r"
---@return nil|string[]
function ReadGameFileLines(path, mode)
mode = mode or "r"
local gamepath, sep = getGamePath()
local lines = {}
local f = io.open(gamepath .. sep .. path, mode)
if not f then return nil end
for line in f:lines("l") do
table.insert(lines, line)
end
f:close()
return lines
end
---Read a file in the game folder
---@param path string # relative path to game file
---@param mode? openmode # default "r"
---@return nil|string|integer[]
function ReadGameFile(path, mode)
mode = mode or "r"
local gamepath, sep = getGamePath()
local out
local f = io.open(gamepath .. sep .. path, mode)
if not f then return nil end
if mode:match(".*b") then
out = readBytes(f)
else
out = f:read("a")
end
f:close()
return out
end
---Find patterns in file
---@param path string # relative path to game file
---@param pattern string # search pattern
---@return table # {{group1, group2, ...}, ...}
function FindPatterns(path, pattern)
local matches = {}
for _, line in ipairs(ReadGameFileLines(path, "r")) do
if line:match(pattern) then
table.insert(matches, {line:match(pattern)})
end
end
return matches
end
--- Check if a file or directory exists in this path
---@param file string # relative path to game file
---@return boolean # file exists
---@return string? # error message
function IsFileExists(file)
local gamepath, sep = getGamePath()
file = gamepath .. sep .. file
local ok, err, code = os.rename(file, file)
if not ok then
game.Log("err: "..err..", code: "..code, game.LOGGER_DEBUG)
if code == 13 then
-- Permission denied, but it exists
return true
end
end
return ok, err
end
--- Check if a directory exists in this path
---@param path string # relative path to game directory
---@return boolean # directory exists
function IsDir(path)
-- "/" works on both Unix and Windows
return IsFileExists(path .. "/")
end

View File

@ -1,11 +1,36 @@
require("common.filereader")
require("core.game")
GameConfig = {}
function RefreshConfig()
for _, match in ipairs(FindPatterns("Main.cfg", "(%w*)%s*=%s*\"?([^\"%s]*)\"?")) do
---Find patterns in file
---@param path string # relative path to game file
---@param pattern string # search pattern
---@return table? matches # {{group1, group2, ...}, ...}
---@return string? errmsg
local function match_all(path, pattern)
local matches = {}
local text, err = game.file.open(path, "r")
if not text then
return nil, err
end
for line in text:lines() do
if line:match(pattern) then
table.insert(matches, {line:match(pattern)})
end
end
return matches
end
function GameConfig.refresh()
local config, err = match_all("Main.cfg", "(%w*)%s*=%s*\"?([^\"%s]*)\"?")
if not config then
game.Log("Unable to refresh GameConfig, " .. err, game.LOGGER_ERROR)
return
end
for _, match in ipairs(config) do
GameConfig[match[1]] = match[2]
end
end
RefreshConfig()
GameConfig.refresh()

View File

@ -1,22 +0,0 @@
---Drewol, what are you doing? Why is there no game.LOGGER_DEBUG?
game.LOGGER_DEBUG = 0
-- add missing inputs
game.MOUSE_LEFT = 0
game.MOUSE_RIGHT = 1
game.MOUSE_MIDDLE = 2
game.KNOB_LEFT = 0
game.KNOB_RIGHT = 1
-- some cool extensions to the builtins ----------------------------------------
---Looks for the last match of pattern in the string.
---@param s string
---@param pattern string
---@param init? integer
---@param plain? boolean
function string.rfind(s, pattern, init, plain)
pattern = pattern:reverse()
return s:len() - s:reverse():find(pattern, init, plain) + 1
end

View File

@ -1,64 +1,7 @@
local function split(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
local function filter(tableIn, predicate)
local out = {}
for _, val in ipairs(tableIn) do
if predicate(val) then
table.insert(out, val)
end
end
return out
end
local function clamp(x, min, max)
if x < min then
x = min
end
if x > max then
x = max
end
return x
end
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
local function areaOverlap(x, y, areaX, areaY, areaW, areaH)
return x > areaX and y > areaY and x < areaX + areaW and y < areaY + areaH
end
local function lerp(x, x0, y0, x1, y1)
return y0 + (x - x0) * (y1 - y0) / (x1 - x0)
end
--modulo operation for index value
local function modIndex(index, mod)
return (index - 1) % mod + 1
@ -76,14 +19,7 @@ local function firstAlphaNum(s)
end
return {
split = split,
filter = filter,
clamp = clamp,
round = round,
sign = sign,
roundToZero = roundToZero,
areaOverlap = areaOverlap,
lerp = lerp,
modIndex = modIndex,
firstAlphaNum = firstAlphaNum,
}

View File

@ -1,21 +1,21 @@
local MAJOR = 0
local MINOR = 2
local PATCH = 2
local major = 0
local minor = 2
local patch = 2
local function getLongVersion()
return "USC:E:G:S:" .. MAJOR .. MINOR .. PATCH
local function long_version()
return "USC:E:G:S:" .. major .. minor .. patch
end
---Get version string
---@return string
local function getVersion()
return table.concat({MAJOR, MINOR, PATCH}, ".")
local function version()
return table.concat({major, minor, patch}, ".")
end
return {
MAJOR = MAJOR,
MINOR = MINOR,
PATCH = PATCH,
getLongVersion = getLongVersion,
getVersion = getVersion
}
major = major,
minor = minor,
patch = patch,
long_version = long_version,
version = version
}

View File

@ -31,7 +31,7 @@ local function drawFooter()
gfx.FontSize(20)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
gfx.FillColor(255, 255, 255, 255)
gfx.Text("EXPERIMENTALGEAR " .. version.MAJOR .. "." .. version.MINOR .. "." .. version.PATCH .. "", 8, 1895)
gfx.Text("EXPERIMENTALGEAR " .. version.major .. "." .. version.minor .. "." .. version.patch .. "", 8, 1895)
end
local function progressTransitions(deltaTime)

13
scripts/core/filesys.lua Normal file
View File

@ -0,0 +1,13 @@
require("core.os")
if os.platform() == Platform.WINDOWS then
require "core.platform.win.filesys"
elseif os.platform() == Platform.LINUX then
require "core.platform.linux.filesys"
elseif os.platform() == Platform.MACOS then
game.Log("MacOS platform not implemented, loading linux filesys module as fallback", game.LOGGER_WARNING)
require "core.platform.linux.filesys"
else
game.Log("OS Platform not recognized, loading linux filesys module", game.LOGGER_WARNING)
require "core.platform.linux.filesys"
end

108
scripts/core/game.lua Normal file
View File

@ -0,0 +1,108 @@
---Drewol, what are you doing? Why is there no game.LOGGER_DEBUG?
game.LOGGER_DEBUG = 0
-- add missing inputs
game.MOUSE_LEFT = 0
game.MOUSE_RIGHT = 1
game.MOUSE_MIDDLE = 2
game.KNOB_LEFT = 0
game.KNOB_RIGHT = 1
--file reader utility functions
require("core.filesys")
game.file = {
__name = "game.file"
}
---Get game path
---@return string, string # path, separator
local function get_game_path()
return debug.getinfo(1,"S").source:sub(2):match("(.*)([\\/])skins") -- this is very hacky :)
end
---Read bytes out of binary file
---@param _file file*
---@return integer[]
local function read_bytes(_file)
local out = {}
repeat
local buffer = _file:read(4*1024)
for c in (buffer or ''):gmatch(".") do
table.insert(out, c:byte())
end
until not buffer
return out
end
---Read a file in the game folder
---@param path string # relative path to game file
---@param mode? openmode # default "r"
---@return file*? lines
---@return string? errmsg
function game.file.open(path, mode)
mode = mode or "r"
local gamepath, sep = get_game_path()
return io.open(gamepath .. sep .. path, mode)
end
---Read a file in the game folder
---@param path string # relative path to game file
---@return string? text
---@return string? errmsg
function game.file.readfile(path)
local gamepath, sep = get_game_path()
local out
local f, err = io.open(gamepath .. sep .. path)
if not f then
return nil, err
end
out = f:read("a")
f:close()
return out
end
---Read a file in the game folder
---@param path string # relative path to game file
---@return integer[]? bytes
---@return string? errmsg
function game.file.readbinary(path)
local gamepath, sep = get_game_path()
local out
local f, err = io.open(gamepath .. sep .. path, "rb")
if not f then
return nil, err
end
out = read_bytes(f)
f:close()
return out
end
--- Check if a file or directory exists at the path
---@param path string # relative path to game file
---@return boolean # file exists
---@return string? # error message
function game.file.exists(path)
local gamepath, sep = get_game_path()
path = gamepath .. sep .. path
return filesys.exists(path)
end
--- Check if a directory exists in this path
---@param path string # relative path to game directory
---@return boolean # directory exists
---@return string? # error message
function game.file.isdir(path)
-- "/" works on both Unix and Windows
return game.file.exists(path .. "/")
end

6
scripts/core/init.lua Normal file
View File

@ -0,0 +1,6 @@
require("core.game")
require("core.os")
require("core.filesys")
require("core.math")
require("core.string")
require("core.table")

50
scripts/core/math.lua Normal file
View File

@ -0,0 +1,50 @@
---Clamp value between minimum and maximum
---@param x number
---@param min number
---@param max number
---@return number
function math.clamp(x, min, max)
if x < min then
x = min
end
if x > max then
x = max
end
return x
end
---Return closest numerical value to number
---@param num number
---@return integer
---@note From https://stackoverflow.com/a/76576968
function math.round(num)
return math.floor((math.floor(num*2) + 1)/2)
end
---Return sign of number
---@param x number
---@return integer
function math.sign(x)
if (x > 0) then
return 1
end
if (x < 0) then
return -1
end
return 0
end
---Linear interpolation
---@param x number # x to interpolate
---@param x0 number # x value begin
---@param x1 number # x value end
---@param y0 number # y value at x0
---@param y1 number # y value at x1
---@return number # interpolated y value at x
function math.lerp(x, x0, x1, y0, y1)
return y0 + (x - x0) * (y1 - y0) / (x1 - x0)
end

47
scripts/core/os.lua Normal file
View File

@ -0,0 +1,47 @@
---@enum Platform
Platform = {
WINDOWS = 0,
LINUX = 1,
MACOS = 2,
UNKNOWN = 3
}
function os.platform()
return Platform.UNKNOWN
end
function os.name()
return "Unknown"
end
---@note setup code from: https://stackoverflow.com/a/30960054
local binary_format = package.cpath:match("%p[\\|/]?%p(%a+)")
if binary_format == "dll" then
function os.platform()
return Platform.WINDOWS
end
function os.name()
return "Windows"
end
elseif binary_format == "so" then
function os.platform()
return Platform.LINUX
end
function os.name()
return "Linux"
end
elseif binary_format == "dylib" then
function os.platform()
return Platform.MACOS
end
function os.name()
return "MacOS"
end
end

View File

@ -1,36 +1,38 @@
require "common.globals"
---@diagnostic disable: duplicate-set-field
---@class FileSys
local FileSys = {
__name = "FileSys",
require("core.string")
---@class filesys
filesys = {
__name = "filesys",
sep = "/"
}
---Return a normalized absolutized version of `path`
---@param path string
---@return string
function FileSys.abspath(path)
return FileSys.normpath(FileSys.join(FileSys.getcwd(), path))
function filesys.abspath(path)
return filesys.normpath(filesys.join(filesys.getcwd(), path))
end
---Return the base name of `path`
---@param path string
---@return string
function FileSys.basename(path)
return string.sub(path, string.rfind(path, FileSys.sep, 1, true) + 1)
function filesys.basename(path)
return string.sub(path, string.rfind(path, filesys.sep, 1, true) + 1)
end
---Return the directory name of `path`
---@param path string
---@return string
function FileSys.dirname(path)
return FileSys.split(path)[1]
function filesys.dirname(path)
return filesys.split(path)[1]
end
---Return true if `path` refers to an existing path
---@param path string
---@return boolean, string?
function FileSys.exists(path)
function filesys.exists(path)
local ok, err, code = os.rename(path, path)
if not ok then
game.Log("err: "..err..", code: "..code, game.LOGGER_DEBUG)
@ -44,8 +46,8 @@ end
---Return a string representing the current working directory
---@return string
function FileSys.getcwd()
assert(false, FileSys.__name .. ".getcwd() : Not Implemented")
function filesys.getcwd()
assert(false, filesys.__name .. ".getcwd() : Not Implemented")
return ""
end
@ -53,12 +55,12 @@ end
---@param path string
---@param ... string
---@return string
function FileSys.join(path, ...)
function filesys.join(path, ...)
local vargs = { select(1, ...) }
local joinedpath = path
for _, value in ipairs(vargs) do
joinedpath = joinedpath .. FileSys.sep .. value
joinedpath = joinedpath .. filesys.sep .. value
end
return joinedpath
@ -67,8 +69,8 @@ end
---Normalize `path`, collapse redundant separators and up references
---@param path string
---@return string
function FileSys.normpath(path)
local sep = FileSys.sep
function filesys.normpath(path)
local sep = filesys.sep
--remove multiple slashes
path = path:gsub("("..sep..")"..sep.."+", "%1")
@ -93,8 +95,8 @@ end
---@param path string
---@param relativeTo? string
---@return string
function FileSys.relpath(path, relativeTo)
relativeTo = relativeTo or FileSys.getcwd()
function filesys.relpath(path, relativeTo)
relativeTo = relativeTo or filesys.getcwd()
path = path:sub(path:find(relativeTo, 1, true)[2] + 1)
return path
end
@ -102,25 +104,23 @@ end
---Return a list of files and directory names in `path`
---@param path string
---@return string[]
function FileSys.scandir(path)
assert(false, FileSys.__name .. ".scandir() : Not Implemented")
function filesys.scandir(path)
assert(false, filesys.__name .. ".scandir() : Not Implemented")
return {}
end
---Split `path` to (head, tail), tail is the last component, head is everything else
---@param path string
---@return string, string
function FileSys.split(path)
local lastSep = path:rfind(FileSys.sep, 1, true)
function filesys.split(path)
local lastSep = path:rfind(filesys.sep, 1, true)
return path:sub(1, lastSep), path:sub(lastSep + 1)
end
---Split `path` to (root, ext), such that `root + ext == path`, ext is either empty or starts with a '.'
---@param path string
---@return string, string
function FileSys.splitext(path)
function filesys.splitext(path)
local lastSep = path:rfind(".", 1, true)
return path:sub(1, lastSep - 1), path:sub(lastSep)
end
return FileSys

View File

@ -1,29 +1,36 @@
local FileSys = require "api.platform.filesys_impl"
---@diagnostic disable: duplicate-set-field
require("core.platform.filesys")
FileSys.sep = "/"
filesys.sep = "/"
function FileSys.getcwd()
---Return a string representing the current working directory
---@return string
function filesys.getcwd()
local cwd, popen = "", io.popen
local pfile, err = popen("pwd")
if not pfile or err ~= 0 then
game.Log(tostring(FileSys) .. ".getcwd() : popen failed executing " .. tostring(err), game.LOGGER_ERROR)
return nil
game.Log(tostring(filesys) .. ".getcwd() : popen failed executing " .. tostring(err), game.LOGGER_ERROR)
return ""
end
cwd = pfile:read()
cwd = pfile:read() or ""
pfile:close()
return cwd
end
function FileSys.scandir(path)
---Return a list of files and directory names in `path`
---@param path string
---@return string[]
function filesys.scandir(path)
local i, t, popen = 0, {}, io.popen
local pfile, err = popen('find "' .. path .. '" -maxdepth 1 -print0')
if not pfile or err ~= 0 then
game.Log(tostring(FileSys) .. ".scandir() : popen failed executing " .. tostring(err), game.LOGGER_ERROR)
return nil
game.Log(tostring(filesys) .. ".scandir() : popen failed executing " .. tostring(err), game.LOGGER_ERROR)
return {}
end
for filename in pfile:lines() do

View File

@ -0,0 +1,56 @@
---@diagnostic disable: duplicate-set-field
require("core.platform.filesys")
filesys.sep = "\\"
---Return a string representing the current working directory
---@return string
function filesys.getcwd()
local cwd, popen = "", io.popen
local pfile, err = popen("cd")
if not pfile or err ~= 0 then
game.Log(tostring(filesys) .. ".getcwd() : popen failed executing " .. tostring(err), game.LOGGER_ERROR)
return ""
end
cwd = pfile:read() or ""
pfile:close()
return cwd
end
local _normpath = filesys.normpath
---Normalize `path`, collapse redundant separators and up references
---@param path string
---@return string
function filesys.normpath(path)
path = _normpath(path)
path = path:gsub("/", "\\")
return path
end
---Return a list of files and directory names in `path`
---@param path string
---@return string[]
function filesys.scandir(path)
local i, t, popen = 0, {}, io.popen
local pfile, err = popen('dir "' .. path .. '" /b /ad')
if not pfile or err ~= 0 then
game.Log(tostring(filesys) .. ".scandir() : popen failed executing " .. tostring(err), game.LOGGER_ERROR)
return {}
end
for filename in pfile:lines() do
i = i + 1
t[i] = filename
end
pfile:close()
return t
end

23
scripts/core/string.lua Normal file
View File

@ -0,0 +1,23 @@
---Looks for the last match of pattern in the string.
---@param s string
---@param pattern string
---@param init? integer
---@param plain? boolean
function string.rfind(s, pattern, init, plain)
pattern = pattern:reverse()
return s:len() - s:reverse():find(pattern, init, plain) + 1
end
---Split string into list
---@param s string
---@param delimiter? string # default " "
---@return string[]
function string.split(s, delimiter)
delimiter = delimiter or " "
local result = {}
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match)
end
return result
end

13
scripts/core/table.lua Normal file
View File

@ -0,0 +1,13 @@
---Filter elements of a table where the predicate is true
---@param t table
---@param predicate fun(x: any): boolean
---@return table
function table.filter(t, predicate)
local out = {}
for _, val in ipairs(t) do
if predicate(val) then
table.insert(out, val)
end
end
return out
end

View File

@ -1,22 +0,0 @@
local call = nil
local EN = require("language.EN")
local DE = require("language.DE")
local SK = require("language.SK")
local HU = require("language.HU")
local test2 = require("language.test2")
if game.GetSkinSetting('words') == "EN" then
call = EN
elseif game.GetSkinSetting('words') == "DE" then
call = DE
elseif game.GetSkinSetting('words') == "SK" then
call = SK
elseif game.GetSkinSetting('words') == "HU" then
call = HU
elseif game.GetSkinSetting('words') == "test2" then
call = test2
end
return call

15
scripts/language/init.lua Normal file
View File

@ -0,0 +1,15 @@
local language = nil
if game.GetSkinSetting('words') == "EN" then
language = require("language.EN")
elseif game.GetSkinSetting('words') == "DE" then
language = require("language.DE")
elseif game.GetSkinSetting('words') == "SK" then
language = require("language.SK")
elseif game.GetSkinSetting('words') == "HU" then
language = require("language.HU")
elseif game.GetSkinSetting('words') == "test2" then
language = require("language.test2")
end
return language

View File

@ -29,13 +29,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-- c = change == ending - beginning
-- d = duration (total time)
local sin = math.sin
local cos = math.cos
local pi = math.pi
local sqrt = math.sqrt
local abs = math.abs
local asin = math.asin
local function linear(t, b, c, d)
return c * t / d + b
end
@ -164,15 +157,15 @@ local function outInQuint(t, b, c, d)
end
local function inSine(t, b, c, d)
return -c * cos(t / d * (pi / 2)) + c + b
return -c * math.cos(t / d * (math.pi / 2)) + c + b
end
local function outSine(t, b, c, d)
return c * sin(t / d * (pi / 2)) + b
return c * math.sin(t / d * (math.pi / 2)) + b
end
local function inOutSine(t, b, c, d)
return -c / 2 * (cos(pi * t / d) - 1) + b
return -c / 2 * (math.cos(math.pi * t / d) - 1) + b
end
local function outInSine(t, b, c, d)
@ -221,21 +214,21 @@ end
local function inCirc(t, b, c, d)
t = t / d
return(-c * (sqrt(1 - (t ^ 2)) - 1) + b)
return(-c * (math.sqrt(1 - (t ^ 2)) - 1) + b)
end
local function outCirc(t, b, c, d)
t = t / d - 1
return(c * sqrt(1 - (t ^ 2)) + b)
return(c * math.sqrt(1 - (t ^ 2)) + b)
end
local function inOutCirc(t, b, c, d)
t = t / d * 2
if t < 1 then
return -c / 2 * (sqrt(1 - t * t) - 1) + b
return -c / 2 * (math.sqrt(1 - t * t) - 1) + b
else
t = t - 2
return c / 2 * (sqrt(1 - t * t) + 1) + b
return c / 2 * (math.sqrt(1 - t * t) + 1) + b
end
end
@ -258,16 +251,16 @@ local function inElastic(t, b, c, d, a, p)
local s
if not a or a < abs(c) then
if not a or a < math.abs(c) then
a = c
s = p / 4
else
s = p / (2 * pi) * asin(c/a)
s = p / (2 * math.pi) * math.asin(c/a)
end
t = t - 1
return -(a * (2 ^ (10 * t)) * sin((t * d - s) * (2 * pi) / p)) + b
return -(a * (2 ^ (10 * t)) * math.sin((t * d - s) * (2 * math.pi) / p)) + b
end
-- a: amplitud
@ -283,14 +276,14 @@ local function outElastic(t, b, c, d, a, p)
local s
if not a or a < abs(c) then
if not a or a < math.abs(c) then
a = c
s = p / 4
else
s = p / (2 * pi) * asin(c/a)
s = p / (2 * math.pi) * math.asin(c/a)
end
return a * (2 ^ (10 * t)) * sin((t * d - s) * (2 * pi) / p) + c + b
return a * (2 ^ (10 * t)) * math.sin((t * d - s) * (2 * math.pi) / p) + c + b
end
-- p = period
@ -307,19 +300,19 @@ local function inOutElastic(t, b, c, d, a, p)
local s
if not a or a < abs(c) then
if not a or a < math.abs(c) then
a = c
s = p / 4
else
s = p / (2 * pi) * asin(c / a)
s = p / (2 * math.pi) * math.asin(c / a)
end
if t < 1 then
t = t - 1
return -0.5 * (a * (2 ^ (10 * t)) * sin((t * d - s) * (2 * pi) / p)) + b
return -0.5 * (a * (2 ^ (10 * t)) * math.sin((t * d - s) * (2 * math.pi) / p)) + b
else
t = t - 1
return a * (2 ^ (-10 * t)) * sin((t * d - s) * (2 * pi) / p ) * 0.5 + c + b
return a * (2 ^ (-10 * t)) * math.sin((t * d - s) * (2 * math.pi) / p ) * 0.5 + c + b
end
end
@ -443,4 +436,4 @@ return {
outBounce = outBounce,
inOutBounce = inOutBounce,
outInBounce = outInBounce,
}
}

View File

@ -4,7 +4,7 @@ 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")
local lang = require("language")
local creww = game.GetSkinSetting("single_idol")

View File

@ -33,7 +33,7 @@ function BootPage.new(params)
self:onInvalidation(reason)
end
self:addField(ServiceField.new{posX = 32, posY = 32, label = Version.getLongVersion(), value = ""})
self:addField(ServiceField.new{posX = 32, posY = 32, label = Version.long_version(), value = ""})
self:addField(ServiceField.new{posX = 64, posY = 64, label = "UNNAMED SDVX CLONE STARTUP...", value = ""})
local valueOffX = 220

View File

@ -5,7 +5,7 @@ local Footer = require("components.footer")
local Wallpaper = require("components.wallpaper")
local Background = require("components.background")
local Dim = require("common.dimensions")
local lang = require("language.call")
local lang = require("language")
local util = require("common.util")
local cursorIndex = 3
@ -516,4 +516,4 @@ function MainMenuPage:drawForeground(deltaTime)
Footer.draw(deltaTime)
end
return MainMenuPage
return MainMenuPage

View File

@ -2,7 +2,7 @@ require "common.class"
local Dim = require "common.dimensions"
local Lang = require "language.call"
local Lang = require "language"
local AudioSample = require "api.audiosample"
local Page = require "api.page.page"

View File

@ -35,7 +35,7 @@ function VersionInfoPage.new(params)
local logStr = ReadGameFile("log_usc-game.exe.txt") or ReadGameFile("log_usc-game.txt")
local list = ListField.new{selectedIndex = 2, locked = true}
list:addField(ServiceField.new{label = "SKIN ID CODE", value = Version.getLongVersion(), MARGIN = {0, 0, 0, 24}})
list:addField(ServiceField.new{label = "SKIN ID CODE", value = Version.long_version(), MARGIN = {0, 0, 0, 24}})
list:addField(UpdateField.new{label = "USC VERSION", value = getGameLogValue("Version", logStr)})
list:addField(ServiceField.new{label = "USC BRANCH", value = GameConfig["UpdateChannel"]})
list:addField(ServiceField.new{label = "USC GIT COMMIT", value = getGameLogValue("Git commit", logStr), MARGIN = {0, 0, 0, 24}})

View File

@ -7,7 +7,7 @@ local Image = require "api.image"
local Page = require "api.page.page"
local versionString = Version.getLongVersion()
local versionString = Version.long_version()
---@class TitlePage : Page
---@field background_img Image
@ -51,4 +51,4 @@ function TitlePage:drawForeground(deltaTime)
gfx.Text(versionString, 10, 10)
end
return TitlePage
return TitlePage