minor API changes
This commit is contained in:
parent
2c34f362d4
commit
f543cd21f4
|
@ -7,7 +7,6 @@ local exclusiveAudioSample = nil
|
||||||
---@field path string
|
---@field path string
|
||||||
---@field exclusive boolean
|
---@field exclusive boolean
|
||||||
---@field loop boolean
|
---@field loop boolean
|
||||||
---@field playing boolean
|
|
||||||
local AudioSample = {
|
local AudioSample = {
|
||||||
__name = "AudioSample"
|
__name = "AudioSample"
|
||||||
}
|
}
|
||||||
|
@ -26,24 +25,22 @@ function AudioSample.new(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
function AudioSample:play()
|
function AudioSample:play()
|
||||||
if not self.playing then
|
if not game.IsSamplePlaying(self.path) then
|
||||||
if self.exclusive then
|
if self.exclusive then
|
||||||
if exclusiveAudioSample and self ~= exclusiveAudioSample then
|
if exclusiveAudioSample and self ~= exclusiveAudioSample then
|
||||||
exclusiveAudioSample:stop()
|
exclusiveAudioSample:stop()
|
||||||
end
|
end
|
||||||
exclusiveAudioSample = self
|
exclusiveAudioSample = self
|
||||||
end
|
end
|
||||||
self.playing = true
|
|
||||||
game.PlaySample(self.path)
|
game.PlaySample(self.path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function AudioSample:stop()
|
function AudioSample:stop()
|
||||||
if self.playing then
|
if game.IsSamplePlaying(self.path) then
|
||||||
if self.exclusive and self == exclusiveAudioSample then
|
if self.exclusive and self == exclusiveAudioSample then
|
||||||
exclusiveAudioSample = nil
|
exclusiveAudioSample = nil
|
||||||
end
|
end
|
||||||
self.playing = false
|
|
||||||
game.StopSample(self.path)
|
game.StopSample(self.path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,8 +33,10 @@ local Image = { };
|
||||||
|
|
||||||
---Image constructor
|
---Image constructor
|
||||||
---@param imagePath string # The path to the skin image to load
|
---@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
|
---@return Image
|
||||||
function Image.new(imagePath, noFallback)
|
function Image.new(imagePath, noFallback)
|
||||||
|
noFallback = noFallback or false
|
||||||
local handle = gfx.CreateSkinImage(imagePath or '', 0);
|
local handle = gfx.CreateSkinImage(imagePath or '', 0);
|
||||||
if (not handle) then
|
if (not handle) then
|
||||||
game.Log('Failed to load image "' .. imagePath .. '"', game.LOGGER_ERROR);
|
game.Log('Failed to load image "' .. imagePath .. '"', game.LOGGER_ERROR);
|
||||||
|
@ -119,13 +121,9 @@ function Image:render(params)
|
||||||
local b = 255;
|
local b = 255;
|
||||||
|
|
||||||
if (params.color) then
|
if (params.color) then
|
||||||
r = params.color[1];
|
r, g, b = table.unpack(params.color)
|
||||||
g = params.color[2];
|
|
||||||
b = params.color[3];
|
|
||||||
elseif (self.color) then
|
elseif (self.color) then
|
||||||
r = self.color[1];
|
r, g, b = table.unpack(self.color)
|
||||||
g = self.color[2];
|
|
||||||
b = self.color[3];
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local a = params.alpha or self.alpha or 1;
|
local a = params.alpha or self.alpha or 1;
|
||||||
|
|
|
@ -59,9 +59,12 @@ function Page:handleKnobInput(knob, delta) end
|
||||||
---@param button integer
|
---@param button integer
|
||||||
function Page:handleMouseInput(x, y, button) end
|
function Page:handleMouseInput(x, y, button) end
|
||||||
|
|
||||||
|
---Event callback on page initialization
|
||||||
function Page:onInit() end
|
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
|
---@param deltaTime number # frametime in seconds
|
||||||
function Page:drawBackground(deltaTime) end
|
function Page:drawBackground(deltaTime) end
|
||||||
|
|
Loading…
Reference in New Issue