minor API changes

This commit is contained in:
Hersi 2022-06-29 00:23:16 +02:00
parent 2c34f362d4
commit f543cd21f4
3 changed files with 10 additions and 12 deletions

View File

@ -7,7 +7,6 @@ local exclusiveAudioSample = nil
---@field path string
---@field exclusive boolean
---@field loop boolean
---@field playing boolean
local AudioSample = {
__name = "AudioSample"
}
@ -26,24 +25,22 @@ function AudioSample.new(params)
end
function AudioSample:play()
if not self.playing then
if not game.IsSamplePlaying(self.path) then
if self.exclusive then
if exclusiveAudioSample and self ~= exclusiveAudioSample then
exclusiveAudioSample:stop()
end
exclusiveAudioSample = self
end
self.playing = true
game.PlaySample(self.path)
end
end
function AudioSample:stop()
if self.playing then
if game.IsSamplePlaying(self.path) then
if self.exclusive and self == exclusiveAudioSample then
exclusiveAudioSample = nil
end
self.playing = false
game.StopSample(self.path)
end
end

View File

@ -33,8 +33,10 @@ local Image = { };
---Image constructor
---@param imagePath string # The path to the skin image to load
---@param noFallback? boolean # If loading fails it displays a missing image asset instead, default false
---@return Image
function Image.new(imagePath, noFallback)
noFallback = noFallback or false
local handle = gfx.CreateSkinImage(imagePath or '', 0);
if (not handle) then
game.Log('Failed to load image "' .. imagePath .. '"', game.LOGGER_ERROR);
@ -119,13 +121,9 @@ function Image:render(params)
local b = 255;
if (params.color) then
r = params.color[1];
g = params.color[2];
b = params.color[3];
r, g, b = table.unpack(params.color)
elseif (self.color) then
r = self.color[1];
g = self.color[2];
b = self.color[3];
r, g, b = table.unpack(self.color)
end
local a = params.alpha or self.alpha or 1;

View File

@ -59,9 +59,12 @@ function Page:handleKnobInput(knob, delta) end
---@param button integer
function Page:handleMouseInput(x, y, button) end
---Event callback on page initialization
function Page:onInit() end
function Page:onInvalidation() end
---Event callback on page invalidation
---@param reason? any # reason for the invalidation
function Page:onInvalidation(reason) end
---@param deltaTime number # frametime in seconds
function Page:drawBackground(deltaTime) end