Compare commits

...

2 Commits

Author SHA1 Message Date
Gabriel Tofvesson
145bc90eae Redesign simple item info 2024-10-12 00:48:31 +02:00
Gabriel Tofvesson
1a63a7054f Handle events in children before parents 2024-10-12 00:41:26 +02:00
2 changed files with 39 additions and 13 deletions

View File

@ -122,10 +122,6 @@ function Children:with(elementType)
end end
function elementType:handleEvent(evt) function elementType:handleEvent(evt)
if Element.handleEvent(self, evt) then
return true
end
local evtLocalCoords = Event.toElementLocalPosition(evt, self) local evtLocalCoords = Event.toElementLocalPosition(evt, self)
if Event.isClickEvent(evt) then if Event.isClickEvent(evt) then
@ -139,15 +135,15 @@ function Children:with(elementType)
return true return true
end end
end end
return false
else else
for _,child in self:_iterateChildren() do for _,child in self:_iterateChildren() do
if child:handleEvent(evtLocalCoords) then if child:handleEvent(evtLocalCoords) then
return true return true
end end
end end
return false
end end
return Element.handleEvent(self, evt)
end end
return elementType return elementType

View File

@ -331,11 +331,36 @@ local PAGES = {
bgColor = colors.gray bgColor = colors.gray
} }
local itemCount = Text:new{ local simpleDetailsList = List:new{
text = "Count: "..tostring(group:getItemCount()), [Orientation:getId()] = Orientation.HORIZONTAL,
} [Children:getId()] = {
local itemSlots = Text:new{ Padding:new{
text = "Slots: "..tostring(group:getStackCount()) top = 0,
left = 1,
right = 1,
bottom = 0,
element = List:new{
[Orientation:getId()] = Orientation.VERTICAL,
[Children:getId()] = {
Text:new{ text = "Count" },
Text:new{ text = tostring(group:getItemCount()) }
}
}
},
Padding:new{
top = 0,
left = 1,
right = 1,
bottom = 0,
element = List:new{
[Orientation:getId()] = Orientation.VERTICAL,
[Children:getId()] = {
Text:new{ text = "Slot" },
Text:new{ text = tostring(group:getStackCount()) }
}
}
}
}
} }
local damage = group:getDamage() local damage = group:getDamage()
@ -353,8 +378,13 @@ local PAGES = {
local infoElements = List:new{ local infoElements = List:new{
[Children:getId()] = { [Children:getId()] = {
paddedTitle, paddedTitle,
itemCount, Padding:new{
itemSlots, top = 0,
bottom = 1,
left = 0,
right = 0,
element = simpleDetailsList
},
damageBar damageBar
}, },
[Orientation:getId()] = Orientation.VERTICAL, [Orientation:getId()] = Orientation.VERTICAL,