Compare commits
17 Commits
hp-bar-the
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 284f2ac204 | |||
| 970047bded | |||
| 47dea647a0 | |||
| af00e8abd4 | |||
| 4161044dcc | |||
| 5c1a0b0c19 | |||
| 75550148f7 | |||
| 29e001e20f | |||
| 00f3db4ff9 | |||
| f5e5bce3ef | |||
| 9ce9b85dfa | |||
| e952d22d7f | |||
| 586ea68d2b | |||
| 2012035eb6 | |||
| 615738d06a | |||
| 7394249cb8 | |||
| c61c1875e7 |
91
assets/fonts/Roboto_Mono/OFL.txt
Normal file
91
assets/fonts/Roboto_Mono/OFL.txt
Normal file
@ -0,0 +1,91 @@
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
BIN
assets/fonts/Roboto_Mono/font.ttf
Normal file
BIN
assets/fonts/Roboto_Mono/font.ttf
Normal file
Binary file not shown.
94
assets/fonts/WDXL_Lubrifont_TC/OFL.txt
Normal file
94
assets/fonts/WDXL_Lubrifont_TC/OFL.txt
Normal file
@ -0,0 +1,94 @@
|
||||
Copyright 2025 The WDXL Lubrifont Project Authors (https://github.com/NightFurySL2001/WD-XL-font)
|
||||
Copyright 2018-2020 The ZCOOL QingKe HuangYou Project Authors (https://www.github.com/googlefonts/zcool-qingke-huangyou)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
BIN
assets/fonts/WDXL_Lubrifont_TC/font.ttf
Normal file
BIN
assets/fonts/WDXL_Lubrifont_TC/font.ttf
Normal file
Binary file not shown.
@ -17,7 +17,7 @@ local camera = {
|
||||
velocity = Vec3 {},
|
||||
acceleration = 0.2,
|
||||
speed = 5,
|
||||
pixelsPerMeter = 24,
|
||||
pixelsPerMeter = 32,
|
||||
}
|
||||
|
||||
function camera:getDefaultScale()
|
||||
@ -38,7 +38,7 @@ local controlMap = {
|
||||
}
|
||||
|
||||
function camera:update(dt)
|
||||
if self.animationNode and not (self.animationNode.t >= 1) then
|
||||
if self.animationNode and self.animationNode.state == "running" then
|
||||
self.animationNode:update(dt) -- тик анимации
|
||||
self.position = utils.lerp(self.animationBeginPosition, self.animationEndPosition, self.animationNode:getValue())
|
||||
return
|
||||
@ -100,7 +100,7 @@ end
|
||||
--- @param position Vec3
|
||||
--- @param animationNode AnimationNode
|
||||
function camera:animateTo(position, animationNode)
|
||||
if self.animationNode then self.animationNode:finish() end
|
||||
if self.animationNode and self.animationNode.state ~= "finished" then self.animationNode:finish() end
|
||||
self.animationNode = animationNode
|
||||
self.animationEndPosition = position
|
||||
self.animationBeginPosition = self.position
|
||||
|
||||
@ -35,7 +35,6 @@ function level:update(dt)
|
||||
el:update(dt)
|
||||
end)
|
||||
|
||||
self.camera:update(dt)
|
||||
self.selector:update(dt)
|
||||
end
|
||||
|
||||
|
||||
@ -34,11 +34,8 @@ function selector:update(dt)
|
||||
|
||||
char:try(Tree.behaviors.spellcaster, function(b)
|
||||
if not b.cast then
|
||||
-- тут какая-то страшная дичь, я даже не уверен что оно работает
|
||||
-- зато я точно уверен, что это надо было писать не так
|
||||
if not selectedId then self:select(selectedId) end
|
||||
if selectedId ~= Tree.level.turnOrder.current and Tree.level.turnOrder.isTurnsEnabled then return end
|
||||
return self:select(selectedId)
|
||||
if not selectedId then self:select(nil) end
|
||||
return
|
||||
end
|
||||
if b.cast:cast(char, mousePosition) then
|
||||
self:lock()
|
||||
|
||||
@ -30,7 +30,6 @@ end
|
||||
---
|
||||
--- Если в очереди на ход больше никого нет, заканчиваем раунд
|
||||
function turnOrder:next()
|
||||
Tree.level.selector:select(nil)
|
||||
self.actedQueue:insert(self.current)
|
||||
local next = self.pendingQueue:peek()
|
||||
if not next then return self:endRound() end
|
||||
|
||||
@ -39,7 +39,11 @@ end
|
||||
|
||||
--- Рисует границу вокруг элемента (с псевдо-затенением)
|
||||
--- @param type "outer" | "inner"
|
||||
function uiElement:drawBorder(type)
|
||||
--- @param width? number
|
||||
function uiElement:drawBorder(type, width)
|
||||
local w = width or 4
|
||||
love.graphics.setLineWidth(w)
|
||||
|
||||
if type == "inner" then
|
||||
love.graphics.setColor(0.2, 0.2, 0.2)
|
||||
love.graphics.line({
|
||||
@ -55,18 +59,37 @@ function uiElement:drawBorder(type)
|
||||
self.bounds.x, self.bounds.y + self.bounds.height,
|
||||
})
|
||||
else
|
||||
love.graphics.setColor(0.2, 0.2, 0.2)
|
||||
love.graphics.setColor(0.3, 0.3, 0.3)
|
||||
-- love.graphics.line({
|
||||
-- self.bounds.x, self.bounds.y + self.bounds.height,
|
||||
-- self.bounds.x, self.bounds.y,
|
||||
-- self.bounds.x + self.bounds.width, self.bounds.y,
|
||||
-- })
|
||||
love.graphics.line({
|
||||
self.bounds.x + self.bounds.width, self.bounds.y,
|
||||
self.bounds.x + self.bounds.width, self.bounds.y + self.bounds.height,
|
||||
self.bounds.x, self.bounds.y + self.bounds.height,
|
||||
self.bounds.x, self.bounds.y + self.bounds.height - w,
|
||||
self.bounds.x, self.bounds.y + w,
|
||||
})
|
||||
|
||||
love.graphics.setColor(0.3, 0.3, 0.3)
|
||||
love.graphics.line({
|
||||
self.bounds.x, self.bounds.y + self.bounds.height,
|
||||
self.bounds.x, self.bounds.y,
|
||||
self.bounds.x + self.bounds.width, self.bounds.y,
|
||||
self.bounds.x + w, self.bounds.y,
|
||||
self.bounds.x + self.bounds.width - w, self.bounds.y,
|
||||
})
|
||||
|
||||
love.graphics.setColor(0.2, 0.2, 0.2)
|
||||
-- love.graphics.line({
|
||||
-- self.bounds.x + self.bounds.width, self.bounds.y,
|
||||
-- self.bounds.x + self.bounds.width, self.bounds.y + self.bounds.height,
|
||||
-- self.bounds.x, self.bounds.y + self.bounds.height,
|
||||
-- })
|
||||
|
||||
love.graphics.line({
|
||||
self.bounds.x + self.bounds.width, self.bounds.y + w,
|
||||
self.bounds.x + self.bounds.width, self.bounds.y + self.bounds.height - w,
|
||||
})
|
||||
|
||||
love.graphics.line({
|
||||
self.bounds.x + self.bounds.width - w, self.bounds.y + self.bounds.height,
|
||||
self.bounds.x + w, self.bounds.y + self.bounds.height,
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
71
lib/simple_ui/level/bar.lua
Normal file
71
lib/simple_ui/level/bar.lua
Normal file
@ -0,0 +1,71 @@
|
||||
local Element = require "lib.simple_ui.element"
|
||||
|
||||
|
||||
--- @class BarElement : UIElement
|
||||
--- @field getter fun() : number
|
||||
--- @field value number
|
||||
--- @field maxValue number
|
||||
--- @field color Color
|
||||
--- @field useDividers boolean
|
||||
--- @field drawText boolean
|
||||
local barElement = setmetatable({}, Element)
|
||||
barElement.__index = barElement
|
||||
barElement.useDividers = false
|
||||
barElement.drawText = false
|
||||
|
||||
function barElement:update(dt)
|
||||
local val = self.getter()
|
||||
self.value = val < 0 and 0 or val > self.maxValue and self.maxValue or val
|
||||
end
|
||||
|
||||
function barElement:draw()
|
||||
local valueWidth = self.bounds.width * self.value / self.maxValue
|
||||
local emptyWidth = self.bounds.width - valueWidth
|
||||
|
||||
--- шум
|
||||
love.graphics.setShader(Tree.assets.files.shaders.soft_uniform_noise)
|
||||
love.graphics.rectangle("fill", self.bounds.x, self.bounds.y, self.bounds.width, self.bounds.height)
|
||||
love.graphics.setShader()
|
||||
|
||||
--- закраска пустой части
|
||||
love.graphics.setColor(0.05, 0.05, 0.05)
|
||||
love.graphics.setBlendMode("multiply", "premultiplied")
|
||||
love.graphics.rectangle("fill", self.bounds.x + valueWidth, self.bounds.y, emptyWidth,
|
||||
self.bounds.height)
|
||||
love.graphics.setBlendMode("alpha")
|
||||
|
||||
--- закраска значимой части её цветом
|
||||
love.graphics.setColor(self.color.r, self.color.g, self.color.b)
|
||||
love.graphics.setBlendMode("multiply", "premultiplied")
|
||||
love.graphics.rectangle("fill", self.bounds.x, self.bounds.y, valueWidth,
|
||||
self.bounds.height)
|
||||
love.graphics.setBlendMode("alpha")
|
||||
|
||||
--- мерки
|
||||
love.graphics.setColor(38 / 255, 50 / 255, 56 / 255)
|
||||
if self.useDividers then
|
||||
local count = self.maxValue - 1
|
||||
local measureWidth = self.bounds.width / self.maxValue
|
||||
|
||||
for i = 1, count, 1 do
|
||||
love.graphics.line(self.bounds.x + i * measureWidth, self.bounds.y, self.bounds.x + i * measureWidth,
|
||||
self.bounds.y + self.bounds.height)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
--- текст поверх
|
||||
if self.drawText then
|
||||
local font = Tree.fonts:getDefaultTheme():getVariant("medium")
|
||||
local t = love.graphics.newText(font, tostring(self.value) .. "/" .. tostring(self.maxValue))
|
||||
love.graphics.draw(t, math.floor(self.bounds.x + self.bounds.width / 2 - t:getWidth() / 2),
|
||||
math.floor(self.bounds.y + self.bounds.height / 2 - t:getHeight() / 2))
|
||||
end
|
||||
|
||||
self:drawBorder("inner")
|
||||
|
||||
self:drawGradientOverlay()
|
||||
end
|
||||
|
||||
return function(values) return barElement:new(values) end
|
||||
86
lib/simple_ui/level/bottom_bars.lua
Normal file
86
lib/simple_ui/level/bottom_bars.lua
Normal file
@ -0,0 +1,86 @@
|
||||
local Element = require "lib.simple_ui.element"
|
||||
local Rect = require "lib.simple_ui.rect"
|
||||
local Color = require "lib.simple_ui.color"
|
||||
local Bar = require "lib.simple_ui.level.bar"
|
||||
|
||||
--- @class BottomBars : UIElement
|
||||
--- @field hpBar BarElement
|
||||
--- @field manaBar BarElement
|
||||
local bottomBars = setmetatable({}, Element)
|
||||
bottomBars.__index = bottomBars;
|
||||
|
||||
--- @param cid Id
|
||||
function bottomBars.new(cid)
|
||||
local t = setmetatable({}, bottomBars)
|
||||
|
||||
t.hpBar =
|
||||
Bar {
|
||||
getter = function()
|
||||
local char = Tree.level.characters[cid]
|
||||
return char:try(Tree.behaviors.stats, function(stats)
|
||||
return stats.hp or 0
|
||||
end)
|
||||
end,
|
||||
color = Color { r = 130 / 255, g = 8 / 255, b = 8 / 255 },
|
||||
drawText = true,
|
||||
maxValue = 20
|
||||
}
|
||||
|
||||
t.manaBar =
|
||||
Bar {
|
||||
getter = function()
|
||||
local char = Tree.level.characters[cid]
|
||||
return char:try(Tree.behaviors.stats, function(stats)
|
||||
return stats.mana or 0
|
||||
end)
|
||||
end,
|
||||
color = Color { r = 51 / 255, g = 105 / 255, b = 30 / 255 },
|
||||
useDividers = true,
|
||||
maxValue = 10
|
||||
}
|
||||
|
||||
|
||||
return t
|
||||
end
|
||||
|
||||
function bottomBars:update(dt)
|
||||
local height = 16
|
||||
local margin = 2
|
||||
|
||||
self.bounds.height = height
|
||||
self.bounds.y = self.bounds.y - height
|
||||
|
||||
self.hpBar.bounds = Rect {
|
||||
width = -2 * margin + self.bounds.width / 2,
|
||||
height = height - margin,
|
||||
x = self.bounds.x + margin,
|
||||
y = self.bounds.y + margin
|
||||
}
|
||||
|
||||
self.manaBar.bounds = Rect {
|
||||
width = -2 * margin + self.bounds.width / 2,
|
||||
height = height - margin,
|
||||
x = self.bounds.x + margin + self.bounds.width / 2,
|
||||
y = self.bounds.y + margin
|
||||
}
|
||||
|
||||
self.hpBar:update(dt)
|
||||
self.manaBar:update(dt)
|
||||
end
|
||||
|
||||
function bottomBars:draw()
|
||||
-- шум
|
||||
love.graphics.setShader(Tree.assets.files.shaders.soft_uniform_noise)
|
||||
love.graphics.rectangle("fill", self.bounds.x, self.bounds.y, self.bounds.width, self.bounds.height)
|
||||
love.graphics.setShader()
|
||||
|
||||
love.graphics.setColor(38 / 255, 50 / 255, 56 / 255)
|
||||
love.graphics.setBlendMode("multiply", "premultiplied")
|
||||
love.graphics.rectangle("fill", self.bounds.x, self.bounds.y, self.bounds.width, self.bounds.height)
|
||||
love.graphics.setBlendMode("alpha")
|
||||
|
||||
self.hpBar:draw()
|
||||
self.manaBar:draw()
|
||||
end
|
||||
|
||||
return bottomBars.new
|
||||
128
lib/simple_ui/level/cpanel.lua
Normal file
128
lib/simple_ui/level/cpanel.lua
Normal file
@ -0,0 +1,128 @@
|
||||
local easing = require "lib.utils.easing"
|
||||
local AnimationNode = require "lib.animation_node"
|
||||
local Element = require "lib.simple_ui.element"
|
||||
local Rect = require "lib.simple_ui.rect"
|
||||
local SkillRow = require "lib.simple_ui.level.skill_row"
|
||||
local Bars = require "lib.simple_ui.level.bottom_bars"
|
||||
local EndTurnButton = require "lib.simple_ui.level.end_turn"
|
||||
|
||||
--- @class CharacterPanel : UIElement
|
||||
--- @field animationNode AnimationNode
|
||||
--- @field state "show" | "idle" | "hide"
|
||||
--- @field skillRow SkillRow
|
||||
--- @field bars BottomBars
|
||||
--- @field endTurnButton EndTurnButton
|
||||
local characterPanel = setmetatable({}, Element)
|
||||
characterPanel.__index = characterPanel
|
||||
|
||||
function characterPanel.new(characterId)
|
||||
local t = {}
|
||||
t.state = "show"
|
||||
t.skillRow = SkillRow(characterId)
|
||||
t.bars = Bars(characterId)
|
||||
t.endTurnButton = EndTurnButton {}
|
||||
return setmetatable(t, characterPanel)
|
||||
end
|
||||
|
||||
function characterPanel:show()
|
||||
AnimationNode {
|
||||
function(animationNode)
|
||||
if self.animationNode then self.animationNode:finish() end
|
||||
self.animationNode = animationNode
|
||||
self.state = "show"
|
||||
end,
|
||||
duration = 300,
|
||||
onEnd = function()
|
||||
self.state = "idle"
|
||||
end,
|
||||
easing = easing.easeOutCubic
|
||||
}:run()
|
||||
end
|
||||
|
||||
function characterPanel:hide()
|
||||
AnimationNode {
|
||||
function(animationNode)
|
||||
if self.animationNode then self.animationNode:finish() end
|
||||
self.animationNode = animationNode
|
||||
self.state = "hide"
|
||||
end,
|
||||
duration = 300,
|
||||
easing = easing.easeOutCubic
|
||||
}:run()
|
||||
end
|
||||
|
||||
--- @type love.Canvas
|
||||
local characterPanelCanvas;
|
||||
|
||||
function characterPanel:update(dt)
|
||||
if self.animationNode then self.animationNode:update(dt) end
|
||||
self.skillRow:update(dt)
|
||||
self.bars.bounds = Rect {
|
||||
width = self.skillRow.bounds.width,
|
||||
x = self.skillRow.bounds.x,
|
||||
y = self.skillRow.bounds.y
|
||||
}
|
||||
self.bars:update(dt)
|
||||
|
||||
self.bounds = Rect {
|
||||
x = self.bars.bounds.x,
|
||||
y = self.bars.bounds.y,
|
||||
width = self.bars.bounds.width,
|
||||
height = self.bars.bounds.height + self.skillRow.bounds.height
|
||||
}
|
||||
|
||||
self.endTurnButton:layout()
|
||||
self.endTurnButton.bounds.x = self.bounds.x + self.bounds.width + 32
|
||||
self.endTurnButton.bounds.y = self.bounds.y + self.bounds.height / 2 - self.endTurnButton.bounds.height / 2
|
||||
|
||||
self.endTurnButton:update(dt)
|
||||
|
||||
if not characterPanelCanvas then
|
||||
characterPanelCanvas = love.graphics.newCanvas(self.bounds.width, self.bounds.height)
|
||||
end
|
||||
|
||||
--- анимация появления
|
||||
local alpha = 1
|
||||
if self.state == "show" then
|
||||
alpha = self.animationNode:getValue()
|
||||
elseif self.state == "hide" then
|
||||
alpha = 1 - self.animationNode:getValue()
|
||||
end
|
||||
local revealShader = Tree.assets.files.shaders.reveal
|
||||
revealShader:send("t", alpha)
|
||||
end
|
||||
|
||||
function characterPanel:draw()
|
||||
self.skillRow:draw()
|
||||
|
||||
--- @TODO: переписать этот ужас с жонглированием координатами, а то слишком хардкод (skillRow рисуется относительно нуля и не закрывает канвас)
|
||||
love.graphics.push()
|
||||
local canvas = love.graphics.getCanvas()
|
||||
love.graphics.translate(0, self.bars.bounds.height)
|
||||
love.graphics.setCanvas(characterPanelCanvas)
|
||||
love.graphics.clear()
|
||||
love.graphics.draw(canvas)
|
||||
love.graphics.pop()
|
||||
|
||||
love.graphics.push()
|
||||
love.graphics.translate(-self.bounds.x, -self.bounds.y)
|
||||
self.bars:draw()
|
||||
self:drawBorder("outer")
|
||||
love.graphics.pop()
|
||||
|
||||
--- рисуем текстуру шейдером появления
|
||||
love.graphics.setCanvas()
|
||||
love.graphics.setShader(Tree.assets.files.shaders.reveal)
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
|
||||
self.endTurnButton:draw()
|
||||
|
||||
love.graphics.push()
|
||||
love.graphics.translate(self.bounds.x, self.bounds.y)
|
||||
love.graphics.draw(characterPanelCanvas)
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.pop()
|
||||
love.graphics.setShader()
|
||||
end
|
||||
|
||||
return characterPanel.new
|
||||
66
lib/simple_ui/level/end_turn.lua
Normal file
66
lib/simple_ui/level/end_turn.lua
Normal file
@ -0,0 +1,66 @@
|
||||
local Element = require "lib.simple_ui.element"
|
||||
local AnimationNode = require "lib.animation_node"
|
||||
local easing = require "lib.utils.easing"
|
||||
|
||||
--- @class EndTurnButton : UIElement
|
||||
--- @field hovered boolean
|
||||
--- @field onClick function?
|
||||
local endTurnButton = setmetatable({}, Element)
|
||||
endTurnButton.__index = endTurnButton
|
||||
|
||||
function endTurnButton:update(dt)
|
||||
local mx, my = love.mouse.getPosition()
|
||||
if self:hitTest(mx, my) then
|
||||
self.hovered = true
|
||||
if Tree.controls:isJustPressed("select") then
|
||||
if self.onClick then self.onClick() end
|
||||
Tree.controls:consume("select")
|
||||
end
|
||||
else
|
||||
self.hovered = false
|
||||
end
|
||||
end
|
||||
|
||||
function endTurnButton:layout()
|
||||
local font = Tree.fonts:getDefaultTheme():getVariant("headline")
|
||||
self.text = love.graphics.newText(font, "Завершить ход")
|
||||
self.bounds.width = self.text:getWidth() + 32
|
||||
self.bounds.height = self.text:getHeight() + 16
|
||||
end
|
||||
|
||||
function endTurnButton:draw()
|
||||
love.graphics.setColor(38 / 255, 50 / 255, 56 / 255, 0.9)
|
||||
love.graphics.rectangle("fill", self.bounds.x, self.bounds.y, self.bounds.width, self.bounds.height)
|
||||
|
||||
if self.hovered then
|
||||
love.graphics.setColor(0.1, 0.1, 0.1)
|
||||
love.graphics.rectangle("fill", self.bounds.x, self.bounds.y, self.bounds.width, self.bounds.height)
|
||||
end
|
||||
|
||||
love.graphics.setColor(0.95, 0.95, 0.95)
|
||||
love.graphics.draw(self.text, self.bounds.x + 16, self.bounds.y + 8)
|
||||
|
||||
self:drawBorder("outer")
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
end
|
||||
|
||||
function endTurnButton:onClick()
|
||||
Tree.level.turnOrder:next()
|
||||
Tree.level.selector:select(nil)
|
||||
local cid = Tree.level.turnOrder.current
|
||||
local playing = Tree.level.characters[cid]
|
||||
if not playing:has(Tree.behaviors.map) then return end
|
||||
|
||||
AnimationNode {
|
||||
function(node)
|
||||
Tree.level.camera:animateTo(playing:has(Tree.behaviors.map).displayedPosition, node)
|
||||
end,
|
||||
duration = 1500,
|
||||
easing = easing.easeInOutCubic,
|
||||
onEnd = function() Tree.level.selector:select(cid) end
|
||||
}:run()
|
||||
end
|
||||
|
||||
return function(values)
|
||||
return endTurnButton:new(values)
|
||||
end
|
||||
@ -1,254 +1,19 @@
|
||||
local easing = require "lib.utils.easing"
|
||||
local AnimationNode = require "lib.animation_node"
|
||||
local Element = require "lib.simple_ui.element"
|
||||
local Rect = require "lib.simple_ui.rect"
|
||||
local SkillRow = require "lib.simple_ui.level.skill_row"
|
||||
local Color = require "lib.simple_ui.color"
|
||||
local CPanel = require "lib.simple_ui.level.cpanel"
|
||||
|
||||
--- @class BarElement : UIElement
|
||||
--- @field getter fun() : number
|
||||
--- @field value number
|
||||
--- @field maxValue number
|
||||
--- @field color Color
|
||||
--- @field useDividers boolean
|
||||
--- @field drawText boolean
|
||||
local barElement = setmetatable({}, Element)
|
||||
barElement.__index = barElement
|
||||
barElement.useDividers = false
|
||||
barElement.drawText = false
|
||||
local build
|
||||
|
||||
function barElement:update(dt)
|
||||
local val = self.getter()
|
||||
self.value = val < 0 and 0 or val > self.maxValue and self.maxValue or val
|
||||
end
|
||||
|
||||
function barElement:draw()
|
||||
local valueWidth = self.bounds.width * self.value / self.maxValue
|
||||
local emptyWidth = self.bounds.width - valueWidth
|
||||
|
||||
--- шум
|
||||
love.graphics.setShader(Tree.assets.files.shaders.soft_uniform_noise)
|
||||
love.graphics.rectangle("fill", self.bounds.x, self.bounds.y, self.bounds.width, self.bounds.height)
|
||||
love.graphics.setShader()
|
||||
|
||||
--- закраска пустой части
|
||||
love.graphics.setColor(0.05, 0.05, 0.05)
|
||||
love.graphics.setBlendMode("multiply", "premultiplied")
|
||||
love.graphics.rectangle("fill", self.bounds.x + valueWidth, self.bounds.y, emptyWidth,
|
||||
self.bounds.height)
|
||||
love.graphics.setBlendMode("alpha")
|
||||
|
||||
--- закраска значимой части её цветом
|
||||
love.graphics.setColor(self.color.r, self.color.g, self.color.b)
|
||||
love.graphics.setBlendMode("multiply", "premultiplied")
|
||||
love.graphics.rectangle("fill", self.bounds.x, self.bounds.y, valueWidth,
|
||||
self.bounds.height)
|
||||
love.graphics.setBlendMode("alpha")
|
||||
|
||||
--- мерки
|
||||
love.graphics.setColor(38 / 255, 50 / 255, 56 / 255)
|
||||
if self.useDividers then
|
||||
local count = self.maxValue - 1
|
||||
local measureWidth = self.bounds.width / self.maxValue
|
||||
|
||||
for i = 1, count, 1 do
|
||||
love.graphics.line(self.bounds.x + i * measureWidth, self.bounds.y, self.bounds.x + i * measureWidth,
|
||||
self.bounds.y + self.bounds.height)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
--- текст поверх
|
||||
if self.drawText then
|
||||
love.graphics.printf(tostring(self.value) .. "/" .. tostring(self.maxValue), self.bounds.x,
|
||||
self.bounds.y, self.bounds.width, "center")
|
||||
end
|
||||
|
||||
self:drawGradientOverlay()
|
||||
end
|
||||
|
||||
--- @class BottomBars : UIElement
|
||||
--- @field hpBar BarElement
|
||||
--- @field manaBar BarElement
|
||||
local bottomBars = setmetatable({}, Element)
|
||||
bottomBars.__index = bottomBars;
|
||||
|
||||
--- @param cid Id
|
||||
function bottomBars.new(cid)
|
||||
local t = setmetatable({}, bottomBars)
|
||||
|
||||
t.hpBar =
|
||||
barElement:new {
|
||||
getter = function()
|
||||
local char = Tree.level.characters[cid]
|
||||
return char:try(Tree.behaviors.stats, function(stats)
|
||||
return stats.hp or 0
|
||||
end)
|
||||
end,
|
||||
color = Color { r = 130 / 255, g = 8 / 255, b = 8 / 255 },
|
||||
drawText = true,
|
||||
maxValue = 20
|
||||
}
|
||||
|
||||
t.manaBar =
|
||||
barElement:new {
|
||||
getter = function()
|
||||
local char = Tree.level.characters[cid]
|
||||
return char:try(Tree.behaviors.stats, function(stats)
|
||||
return stats.mana or 0
|
||||
end)
|
||||
end,
|
||||
color = Color { r = 51 / 255, g = 105 / 255, b = 30 / 255 },
|
||||
useDividers = true,
|
||||
maxValue = 10
|
||||
}
|
||||
|
||||
|
||||
return t
|
||||
end
|
||||
|
||||
function bottomBars:update(dt)
|
||||
local height = 14
|
||||
local margin = 2
|
||||
|
||||
self.bounds.height = height
|
||||
self.bounds.y = self.bounds.y - height
|
||||
|
||||
self.hpBar.bounds = Rect {
|
||||
width = -2 * margin + self.bounds.width / 2,
|
||||
height = height,
|
||||
x = self.bounds.x + margin,
|
||||
y = self.bounds.y
|
||||
}
|
||||
|
||||
self.manaBar.bounds = Rect {
|
||||
width = -2 * margin + self.bounds.width / 2,
|
||||
height = height,
|
||||
x = self.bounds.x + margin + self.bounds.width / 2,
|
||||
y = self.bounds.y
|
||||
}
|
||||
|
||||
self.hpBar:update(dt)
|
||||
self.manaBar:update(dt)
|
||||
end
|
||||
|
||||
function bottomBars:draw()
|
||||
-- шум
|
||||
love.graphics.setShader(Tree.assets.files.shaders.soft_uniform_noise)
|
||||
love.graphics.rectangle("fill", self.bounds.x, self.bounds.y, self.bounds.width, self.bounds.height)
|
||||
love.graphics.setShader()
|
||||
|
||||
love.graphics.setColor(38 / 255, 50 / 255, 56 / 255)
|
||||
love.graphics.setBlendMode("multiply", "premultiplied")
|
||||
love.graphics.rectangle("fill", self.bounds.x, self.bounds.y, self.bounds.width, self.bounds.height)
|
||||
love.graphics.setBlendMode("alpha")
|
||||
|
||||
self.hpBar:draw()
|
||||
self.manaBar:draw()
|
||||
end
|
||||
|
||||
local c = love.graphics.newCanvas(1280, 720) --- @TODO: выставлять канвасу правильный размер в зависимости от окна
|
||||
|
||||
--- @class CharacterPanel : UIElement
|
||||
--- @field animationNode AnimationNode
|
||||
--- @field state "show" | "idle" | "hide"
|
||||
--- @field skillRow SkillRow
|
||||
--- @field bars BottomBars
|
||||
local characterPanel = setmetatable({}, Element)
|
||||
characterPanel.__index = characterPanel
|
||||
|
||||
function characterPanel.new(characterId)
|
||||
local t = {}
|
||||
t.state = "show"
|
||||
t.skillRow = SkillRow(characterId)
|
||||
t.bars = bottomBars.new(characterId)
|
||||
return setmetatable(t, characterPanel)
|
||||
end
|
||||
|
||||
function characterPanel:show()
|
||||
AnimationNode {
|
||||
function(animationNode)
|
||||
if self.animationNode then self.animationNode:finish() end
|
||||
self.animationNode = animationNode
|
||||
self.state = "show"
|
||||
end,
|
||||
duration = 300,
|
||||
onEnd = function()
|
||||
self.state = "idle"
|
||||
end,
|
||||
easing = easing.easeOutCubic
|
||||
}:run()
|
||||
end
|
||||
|
||||
function characterPanel:hide()
|
||||
AnimationNode {
|
||||
function(animationNode)
|
||||
if self.animationNode then self.animationNode:finish() end
|
||||
self.animationNode = animationNode
|
||||
self.state = "hide"
|
||||
end,
|
||||
duration = 300,
|
||||
easing = easing.easeOutCubic
|
||||
}:run()
|
||||
end
|
||||
|
||||
function characterPanel:update(dt)
|
||||
if self.animationNode then self.animationNode:update(dt) end
|
||||
self.skillRow:update(dt)
|
||||
self.bars.bounds = Rect {
|
||||
width = self.skillRow.bounds.width,
|
||||
x = self.skillRow.bounds.x,
|
||||
y = self.skillRow.bounds.y
|
||||
}
|
||||
self.bars:update(dt)
|
||||
|
||||
self.bounds = Rect {
|
||||
x = self.bars.bounds.x,
|
||||
y = self.bars.bounds.y,
|
||||
width = self.bars.bounds.width,
|
||||
height = self.bars.bounds.height + self.skillRow.bounds.height
|
||||
}
|
||||
|
||||
--- анимация появления
|
||||
local alpha = 1
|
||||
if self.state == "show" then
|
||||
alpha = self.animationNode:getValue()
|
||||
elseif self.state == "hide" then
|
||||
alpha = 1 - self.animationNode:getValue()
|
||||
end
|
||||
local revealShader = Tree.assets.files.shaders.reveal
|
||||
revealShader:send("t", alpha)
|
||||
end
|
||||
|
||||
function characterPanel:draw()
|
||||
love.graphics.setCanvas(c)
|
||||
love.graphics.clear()
|
||||
self.skillRow:draw()
|
||||
self.bars:draw()
|
||||
|
||||
self:drawBorder("outer")
|
||||
|
||||
--- рисуем текстуру шейдером появления
|
||||
love.graphics.setCanvas()
|
||||
love.graphics.setShader(Tree.assets.files.shaders.reveal)
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(c)
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.setShader()
|
||||
end
|
||||
|
||||
-----------------------------------
|
||||
local layout = {}
|
||||
function layout:update(dt)
|
||||
if self.characterPanel then self.characterPanel:update(dt) end
|
||||
|
||||
local cid = Tree.level.selector:selected()
|
||||
if cid then
|
||||
self.characterPanel = characterPanel.new(cid)
|
||||
self.characterPanel = CPanel(cid)
|
||||
self.characterPanel:show()
|
||||
self.characterPanel:update(dt)
|
||||
elseif Tree.level.selector:deselected() then
|
||||
self.characterPanel:hide()
|
||||
end
|
||||
if self.characterPanel then self.characterPanel:update(dt) end
|
||||
end
|
||||
|
||||
function layout:draw()
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
local UI_SCALE = 0.8 -- выдуманное значение для dependency injection
|
||||
local UI_SCALE = 0.75 -- выдуманное значение для dependency injection, надо подбирать так, чтобы UI_SCALE * 64 было целым числом
|
||||
return UI_SCALE
|
||||
|
||||
@ -103,8 +103,11 @@ function skillRow.new(characterId)
|
||||
return t
|
||||
end
|
||||
|
||||
--- @type love.Canvas
|
||||
local c;
|
||||
|
||||
function skillRow:update(dt)
|
||||
local iconSize = 64 * UI_SCALE
|
||||
local iconSize = math.floor(64 * UI_SCALE)
|
||||
local screenW, screenH = love.graphics.getDimensions()
|
||||
local padding, margin = 8, 4
|
||||
local count = #self.children -- слоты под скиллы
|
||||
@ -121,16 +124,22 @@ function skillRow:update(dt)
|
||||
y = self.bounds.y + margin, height = iconSize, width = iconSize }
|
||||
skb:update(dt)
|
||||
end
|
||||
|
||||
if not c then
|
||||
c = love.graphics.newCanvas(self.bounds.width, self.bounds.height)
|
||||
end
|
||||
end
|
||||
|
||||
local c = love.graphics.newCanvas(1280, 720) --- @TODO: выставлять канвасу правильный размер в зависимости от окна
|
||||
|
||||
function skillRow:draw()
|
||||
local oldCanvas = love.graphics.getCanvas()
|
||||
love.graphics.setCanvas({ c, stencil = true })
|
||||
love.graphics.clear()
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
|
||||
do
|
||||
--- рисуем в локальных координатах текстурки
|
||||
love.graphics.push()
|
||||
love.graphics.translate(-self.bounds.x, -self.bounds.y)
|
||||
|
||||
-- сначала иконки скиллов
|
||||
for _, skb in ipairs(self.children) do
|
||||
skb:draw()
|
||||
@ -148,6 +157,7 @@ function skillRow:draw()
|
||||
end, "replace", 1)
|
||||
love.graphics.setShader()
|
||||
|
||||
|
||||
-- дальше рисуем панель, перекрывая иконки
|
||||
love.graphics.setStencilTest("less", 1)
|
||||
-- шум
|
||||
@ -165,10 +175,10 @@ function skillRow:draw()
|
||||
|
||||
--затенение
|
||||
self:drawGradientOverlay()
|
||||
love.graphics.pop()
|
||||
end
|
||||
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.setCanvas(oldCanvas)
|
||||
love.graphics.draw(c)
|
||||
end
|
||||
|
||||
return skillRow.new
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
Tree = {
|
||||
assets = (require "lib.utils.asset_bundle"):load()
|
||||
}
|
||||
Tree.fonts = (require "lib.utils.font_manager"):load("WDXL_Lubrifont_TC"):loadTheme("Roboto_Mono") -- дефолтный шрифт
|
||||
Tree.panning = require "lib/panning"
|
||||
Tree.controls = require "lib.controls"
|
||||
Tree.level = (require "lib.level.level").new("procedural", "flower_plains") -- для теста у нас только один уровень, который сразу же загружен
|
||||
|
||||
@ -51,7 +51,7 @@ function AssetBundle.loadFile(path)
|
||||
elseif (ext == "lua") then
|
||||
return require(string.gsub(path, ".lua", ""))
|
||||
end
|
||||
return nil
|
||||
return filedata
|
||||
end
|
||||
|
||||
function AssetBundle.cutExtension(filename)
|
||||
|
||||
94
lib/utils/font_manager.lua
Normal file
94
lib/utils/font_manager.lua
Normal file
@ -0,0 +1,94 @@
|
||||
--- @alias FontVariant "smallest" | "small" | "medium" | "large" | "headline"
|
||||
|
||||
--- @class TextTheme
|
||||
--- @field private _sizes {[FontVariant]: integer}
|
||||
local theme = {
|
||||
_sizes = {
|
||||
smallest = 10,
|
||||
small = 12,
|
||||
medium = 14,
|
||||
large = 16,
|
||||
headline = 20,
|
||||
}
|
||||
}
|
||||
theme.__index = theme
|
||||
|
||||
--- @param loader fun(size: integer): love.Font?
|
||||
function theme.new(loader)
|
||||
local t = {}
|
||||
for tag, size in pairs(theme._sizes) do
|
||||
local f = loader(size)
|
||||
if not f then return nil end
|
||||
t[tag] = f
|
||||
end
|
||||
|
||||
return setmetatable(t, theme)
|
||||
end
|
||||
|
||||
--- @param variant FontVariant
|
||||
--- @return love.Font
|
||||
function theme:getVariant(variant)
|
||||
return self[variant]
|
||||
end
|
||||
|
||||
----------------------------------------------------------
|
||||
|
||||
--- A singleton to handle fonts
|
||||
--- @class FontManager
|
||||
--- @field private _themes table
|
||||
--- @field defaultTheme string?
|
||||
local FontManager = {
|
||||
_themes = {}
|
||||
}
|
||||
|
||||
--- @param name string
|
||||
--- @param size integer
|
||||
function FontManager.newFont(name, size)
|
||||
local err = function()
|
||||
print("[FontManager]: font " .. name .. " not found!")
|
||||
end
|
||||
local fontDir = Tree.assets.files.fonts[name]
|
||||
if not fontDir then return err() end
|
||||
local font = fontDir.font
|
||||
if not font then return err() end
|
||||
return love.graphics.newFont(font, size)
|
||||
end
|
||||
|
||||
--- @param name string
|
||||
--- @return FontManager
|
||||
function FontManager:loadTheme(name)
|
||||
self._themes[name] = theme.new(
|
||||
function(size)
|
||||
return self.newFont(name, size)
|
||||
end
|
||||
)
|
||||
return self
|
||||
end
|
||||
|
||||
--- @param name string
|
||||
--- @return TextTheme?
|
||||
function FontManager:getTheme(name)
|
||||
return self._themes[name]
|
||||
end
|
||||
|
||||
--- @return TextTheme
|
||||
function FontManager:getDefaultTheme()
|
||||
return self._themes[self.defaultTheme]
|
||||
end
|
||||
|
||||
--- initial setup
|
||||
--- @param defaultFontName string
|
||||
function FontManager:load(defaultFontName)
|
||||
local t = self:loadTheme(defaultFontName):getTheme(defaultFontName)
|
||||
if not t then
|
||||
print("[FontManager]: default font " .. defaultFontName .. " is missing")
|
||||
return self
|
||||
end
|
||||
self.defaultTheme = defaultFontName
|
||||
|
||||
local f = t:getVariant("medium")
|
||||
love.graphics.setFont(f)
|
||||
return self
|
||||
end
|
||||
|
||||
return FontManager
|
||||
21
main.lua
21
main.lua
@ -18,28 +18,18 @@ function love.load()
|
||||
end
|
||||
Tree.level.turnOrder:endRound()
|
||||
print("Now playing:", Tree.level.turnOrder.current)
|
||||
love.window.setMode(1280, 720, { resizable = false, msaa = 0, vsync = true })
|
||||
love.window.setMode(1280, 720, { resizable = true, msaa = 4, vsync = true })
|
||||
end
|
||||
|
||||
local lt = "0"
|
||||
function love.update(dt)
|
||||
local t1 = love.timer.getTime()
|
||||
Tree.controls:poll()
|
||||
testLayout:update(dt) -- логика UI-слоя должна отработать раньше всех, потому что нужно перехватить жесты и не пустить их дальше
|
||||
Tree.level.camera:update(dt) -- сначала логика камеры, потому что на нее завязан UI
|
||||
testLayout:update(dt) -- потом UI, потому что нужно перехватить жесты и не пустить их дальше
|
||||
Tree.panning:update(dt)
|
||||
Tree.level:update(dt)
|
||||
|
||||
-- для тестов очереди ходов
|
||||
-- удалить как только появится ui для людей
|
||||
if Tree.controls:isJustPressed("endTurnTest") then
|
||||
Tree.level.turnOrder:next()
|
||||
print("Now playing:", Tree.level.turnOrder.current)
|
||||
end
|
||||
if Tree.controls:isJustPressed("toggleTurns") then
|
||||
print('toggle turns')
|
||||
Tree.level.turnOrder:toggleTurns()
|
||||
end
|
||||
|
||||
Tree.controls:cache()
|
||||
|
||||
local t2 = love.timer.getTime()
|
||||
@ -74,7 +64,10 @@ function love.draw()
|
||||
testLayout:draw()
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
|
||||
local stats = "fps: " .. love.timer.getFPS() .. " lt: " .. lt .. " dt: " .. dt
|
||||
love.graphics.setFont(Tree.fonts:getTheme("Roboto_Mono"):getVariant("medium"))
|
||||
local stats = "fps: " ..
|
||||
love.timer.getFPS() ..
|
||||
" lt: " .. lt .. " dt: " .. dt .. " mem: " .. string.format("%.2f MB", collectgarbage("count") / 1000)
|
||||
love.graphics.print(stats, 10, 10)
|
||||
|
||||
local t2 = love.timer.getTime()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user