Some vars for drawTextSystem consistency
Sort generated filter-types PdImage,PdFont -> pd_image,pd_font
This commit is contained in:
parent
67c2b81fc3
commit
110d02fe2c
|
@ -4,44 +4,36 @@ drawRectanglesSystem = filteredSystem("drawRectangles", { position = T.XyPair, d
|
|||
gfx.fillRect(e.position.x, e.position.y, e.drawAsRectangle.size.x, e.drawAsRectangle.size.y)
|
||||
end)
|
||||
|
||||
drawSpriteSystem = filteredSystem("drawSprites", { position = T.XyPair, drawAsSprite = T.PdImage }, function(e, dt, system)
|
||||
drawSpriteSystem = filteredSystem("drawSprites", { position = T.XyPair, drawAsSprite = T.pd_image }, function(e, dt, system)
|
||||
e.drawAsSprite:draw(e.position.x, e.position.y)
|
||||
end)
|
||||
|
||||
local textHeight = AshevilleSans14Bold:getHeight()
|
||||
local xMargin = 4
|
||||
|
||||
drawTextSystem = filteredSystem("drawText",
|
||||
{ position = T.XyPair, drawAsText = { text = T.str, style = Maybe(T.str), font = Maybe(T.PdFont) } },
|
||||
{ position = T.XyPair, drawAsText = { text = T.str, style = Maybe(T.str), font = Maybe(T.pd_font) } },
|
||||
function(e)
|
||||
local textWidth = AshevilleSans14Bold:getTextWidth(e.drawAsText.text)
|
||||
local font = e.drawAsText.font or AshevilleSans14Bold
|
||||
local textHeight = font:getHeight()
|
||||
local textWidth = font:getTextWidth(e.drawAsText.text)
|
||||
|
||||
local bgLeftEdge = e.position.x - xMargin - textWidth / 2
|
||||
local bgTopEdge = e.position.y - 2
|
||||
local bgWidth, bgHeight = textWidth + (xMargin * 2), textHeight + 2
|
||||
|
||||
if e.drawAsText.style == TextStyle.Inverted then
|
||||
gfx.fillRect(
|
||||
e.position.x - xMargin - textWidth / 2,
|
||||
e.position.y - 2,
|
||||
textWidth + (xMargin * 2),
|
||||
textHeight + 2
|
||||
)
|
||||
gfx.fillRect(bgLeftEdge, bgTopEdge, textWidth + (xMargin * 2), textHeight + 2)
|
||||
gfx.setImageDrawMode(gfx.kDrawModeInverted)
|
||||
end
|
||||
if e.drawAsText.style == TextStyle.Bordered then
|
||||
elseif e.drawAsText.style == TextStyle.Bordered then
|
||||
gfx.setColor(gfx.kColorWhite)
|
||||
gfx.fillRect(
|
||||
e.position.x - xMargin - textWidth / 2,
|
||||
e.position.y - 2,
|
||||
textWidth + (xMargin * 2),
|
||||
textHeight + 2
|
||||
)
|
||||
gfx.setColor(gfx.kColorBlack)
|
||||
gfx.fillRect(bgLeftEdge, bgTopEdge, bgWidth, bgHeight)
|
||||
|
||||
gfx.setImageDrawMode(gfx.kDrawModeCopy)
|
||||
gfx.drawRect(
|
||||
e.position.x - xMargin - textWidth / 2,
|
||||
e.position.y - 2,
|
||||
textWidth + (xMargin * 2),
|
||||
textHeight + 2
|
||||
)
|
||||
gfx.setColor(gfx.kColorBlack)
|
||||
gfx.drawRect(bgLeftEdge, bgTopEdge, bgWidth, bgHeight)
|
||||
end
|
||||
AshevilleSans14Bold:drawTextAligned(e.drawAsText.text, e.position.x, e.position.y, kTextAlignment.center)
|
||||
|
||||
font:drawTextAligned(e.drawAsText.text, e.position.x, e.position.y, kTextAlignment.center)
|
||||
if e.drawAsText.style == TextStyle.Inverted then
|
||||
gfx.setImageDrawMode(gfx.kDrawModeCopy)
|
||||
end
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
|
||||
-- This file is composed of, essentially, "base types"
|
||||
|
||||
---@alias BitMask number
|
||||
---@alias CanBeBounced { flat: XyPair, mult = XyPair }
|
||||
---@alias CanSpawn { entity: Entity }
|
||||
---@alias Collision { collisionBetween: Entity[] }
|
||||
---@alias CanBeBounced { flat: XyPair, mult = XyPair }
|
||||
---@alias XyPair { x: number, y: number }
|
||||
---@alias BitMask number
|
||||
---@alias Entity table
|
||||
---@alias InRelations Entity[]
|
||||
---@alias InputState { aJustPressed: boolean, bJustPressed: boolean, upJustPressed: boolean, downJustPressed: boolean, leftJustPressed: boolean, rightJustPressed: boolean }
|
||||
---@alias Entity table
|
||||
---@alias RoundStateAction "end" | "start"
|
||||
---@alias XyPair { x: number, y: number }
|
||||
|
||||
|
||||
T = {
|
||||
|
@ -29,26 +29,28 @@ T = {
|
|||
mult = XyPair,
|
||||
},
|
||||
---@type pd_image
|
||||
PdImage = {},
|
||||
pd_image = {},
|
||||
---@type pd_font
|
||||
pd_font = {},
|
||||
|
||||
---@type BitMask
|
||||
BitMask = 0,
|
||||
---@type CanBeBounced
|
||||
CanBeBounced = {},
|
||||
---@type CanSpawn
|
||||
CanSpawn = {},
|
||||
---@type Collision
|
||||
Collision = {},
|
||||
---@type CanBeBounced
|
||||
CanBeBounced = {},
|
||||
---@type XyPair
|
||||
XyPair = {},
|
||||
---@type BitMask
|
||||
BitMask = 0,
|
||||
---@type Entity
|
||||
Entity = {},
|
||||
---@type InRelations
|
||||
InRelations = {},
|
||||
---@type InputState
|
||||
InputState = {},
|
||||
---@type Entity
|
||||
Entity = {},
|
||||
---@type RoundStateAction
|
||||
RoundStateAction = "start",
|
||||
---@type XyPair
|
||||
XyPair = {},
|
||||
}
|
||||
|
||||
---@generic T
|
||||
|
|
|
@ -21,7 +21,15 @@ end
|
|||
|
||||
function tMany(tObj)
|
||||
local ret = ""
|
||||
local keyValues = {}
|
||||
for k, v in pairs(tObj) do
|
||||
keyValues[#keyValues + 1] = { key = k, value = v }
|
||||
end
|
||||
table.sort(keyValues, function(a, b)
|
||||
return a.key < b.key
|
||||
end)
|
||||
for _, kv in ipairs(keyValues) do
|
||||
local k, v = kv.key, kv.value
|
||||
if type(v) == "string" then
|
||||
ret = ret .. t(k, v) .. "\n"
|
||||
else
|
||||
|
@ -53,7 +61,7 @@ end
|
|||
CanSpawn = "{ entity: Entity }",
|
||||
InRelations = "Entity[]",
|
||||
CanBeBounced = "{ flat: XyPair, mult = XyPair }",
|
||||
InputState = "{ aJustPressed: boolean, bJustPressed: boolean, upJustPressed: boolean, downJustPressed: boolean, leftJustPressed: boolean, rightJustPressed: boolean }"
|
||||
InputState = "{ aJustPressed: boolean, bJustPressed: boolean, upJustPressed: boolean, downJustPressed: boolean, leftJustPressed: boolean, rightJustPressed: boolean }",
|
||||
}))
|
||||
|
||||
T = {
|
||||
|
@ -71,7 +79,9 @@ T = {
|
|||
mult = XyPair,
|
||||
},
|
||||
---@type pd_image
|
||||
PdImage = {},
|
||||
pd_image = {},
|
||||
---@type pd_font
|
||||
pd_font = {},
|
||||
!!(dumpTypeObjects())
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
collectedEntities = filteredSystem("collectedEntities", { collected = T.PdImage })
|
||||
collectedEntities = filteredSystem("collectedEntities", { collected = T.pd_image })
|
||||
|
||||
local onCollidingRemove = { "mass", "velocity", "canCollideWith" }
|
||||
|
||||
|
|
Loading…
Reference in New Issue