Skip to content

Commit

Permalink
Kartong: Able to add complex items to Selector widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Apr 7, 2024
1 parent 4ed728a commit 21fe933
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
19 changes: 14 additions & 5 deletions data/Source/Scripts/Views/GamePlayOptionsView.xdi
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@ GamePlayOptionsView.__flipboardId = "OPTIONS_GAMEPLAY"
function GamePlayOptionsView:new(parent)
Container.new(self, parent, TableLayout({0}, {0}, 0, 0, 16, 16))
local ct = Container(self, TableLayout({0, 100}, {0}, 0, 0, 16, 16))
local sl = Selector(self)
:setHorizontalAlign(Widget.ALIGN_CENTER)
local ct = Container(sl, TableLayout({100,0}, {0}, 0, 0, 16, 0))
Static(ct, "BOOSTERS")
:setTextSize(70)
:setTextColor(Color4f(1, 1, 1, 1))
CheckBox(ct)
:setVerticalAlign(Widget.ALIGN_CENTER)
sl:add(ct)
local ct = Container(sl, TableLayout({100,0}, {0}, 0, 0, 16, 0))
Static(ct, "PICKUPS")
:setTextSize(70)
:setTextColor(Color4f(1, 1, 1, 1))
CheckBox(ct)
PushButton(self, "RETURN")
:setOnClick(function() self._fnReturn() end)
:setVerticalAlign(Widget.ALIGN_CENTER)
sl:add(ct)
self._fnReturn = function() end
end
Expand All @@ -29,6 +37,7 @@ function GamePlayOptionsView:setOnReturn(fn)
self._fnReturn = fn
return self
end
]]>
</text>
</object>
25 changes: 17 additions & 8 deletions data/Source/Scripts/Views/Widgets/Selector.xdi
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ function Selector:place(x, y, width, height)
end
function Selector:add(item)
local s = Static(self, item)
:setTextSize(70)
table.insert(self._items, s)
if type(item) == "string" then
local s = Static(self, item)
:setTextSize(70)
table.insert(self._items, s)
else
table.insert(self._items, item)
end
self:_layout()
return self
end
Expand Down Expand Up @@ -70,12 +74,16 @@ function Selector:_layout()
for idx, mc in ipairs(self._items) do
local x < const > = (w - mc:getPreferredSize().width) / 2
mc:place(x, y + 12, p.width, 80)
if idx == self._index + 1 then
mc:setTextColor(Color4f(1, 1, 1, 1))
else
mc:setTextColor(Color4f(1, 1, 1, 0.75))
mc:place(x, y + 12, w - x * 2, 80)
if mc.setTextColor ~= nil then
if idx == self._index + 1 then
mc:setTextColor(Color4f(1, 1, 1, 1))
else
mc:setTextColor(Color4f(1, 1, 1, 0.75))
end
end
y = y + 80
end
Expand Down Expand Up @@ -111,6 +119,7 @@ function Selector:_onKeyUp(event)
end
end
end
]]>
</text>
</object>
5 changes: 3 additions & 2 deletions data/Source/UI/UI_Scaffolding.xdi
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function UI_Scaffolding:setup(frame)
local fb = Flipboard(frame)
HudView(fb)
HudView(fb, 4)
MainView(fb)
:setHorizontalAlign(Widget.ALIGN_CENTER)
Expand All @@ -49,13 +49,14 @@ function UI_Scaffolding:setup(frame)
:setHorizontalAlign(Widget.ALIGN_CENTER)
:setVerticalAlign(Widget.ALIGN_CENTER)
fb:showPage("MAIN")
fb:showPage("OPTIONS_GAMEPLAY")
end
function UI_Scaffolding:getResourceKits()
return { "\{43489F5B-5785-1249-A7BA-CB5259C3F064}", "\{27DDC0FD-39DE-0946-BB1B-7D84A001C522}", "\{5ABEAE05-EB26-934F-932F-7F3C7C582383}" }
end
]]>
</text>
</object>

0 comments on commit 21fe933

Please sign in to comment.