The latest build has a new Table container. Its primarily aimed at data tables (like the commodity trade list). It has a really simple API and will automatically align rows and columns and add scrollbars as necessary. Basically what we've already been doing with grids+vboxes, but without the pain. I do have some future plans for it (horizontal scroll, row/column spanning, live reordering (replacing SmartTable)), but this will do for now. Its already in action in the InfoView, but not everywhere yet. A nice project for someone wanting to try things out would be to rewrite the mission list to use it. The code will end up being very much nicer.
The other thing is a little convenience. If you add a string to a container instead of a widget, a Label widget will automatically be created from it. So now you don't need masses of ui:Label everywhere. Just the string will do.
All of this is me building out what I need to move the station screens to the new UI. Armed with these tools, here's what I have after a few minutes hacking:
And the code:
Code: Select all
local commodityMarket = function (args)
local station = Game.player:GetDockedWith()
local table = ui:Table():SetColumnSpacing(10)
table:SetHeadingRow({ "", "Name", "Price", "In stock" })
for k,v in pairs(EquipDef) do
if v.slot == "CARGO" then
table:AddRow({ ui:Image("icons/goods/Animal_Meat.png"), k, station:GetEquipmentPrice(k), station:GetEquipmentStock(k) })
end
end
return ui:Expand():SetInnerWidget(table)
end