Skip to content

Commit

Permalink
Fix for issue3117
Browse files Browse the repository at this point in the history
  • Loading branch information
PVJeltz committed Nov 1, 2014
1 parent 129a8de commit c5a9381
Showing 1 changed file with 51 additions and 51 deletions.
102 changes: 51 additions & 51 deletions data/ui/StationView.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ ui.templates.StationView = function (args)
local player = Game.player

local function createCashLabel()
local cashLabel = ui:NumberLabel("MONEY")
cashLabel:Bind("value", player, "cash")
return cashLabel
local cashLabel = ui:NumberLabel("MONEY")
cashLabel:Bind("value", player, "cash")
return cashLabel
end

local function cargoUpdate (fields)
Expand All @@ -48,63 +48,63 @@ ui.templates.StationView = function (args)
end

local function capacityUpdate (fields)
local totalCapacity = player.usedCapacity + player.freeCapacity
local totalCapacity = player.usedCapacity + player.freeCapacity
fields["gauge"]:SetUpperValue(totalCapacity)
fields["gauge"]:SetValue(player.usedCapacity)
fields["usedLabel"]:SetText(string.interp(l.CARGO_T_USED, { amount = player.usedCapacity }))
fields["freeLabel"]:SetText(string.interp(l.CARGO_T_FREE, { amount = player.freeCapacity }))
end

local function cabinUpdate (fields)
local cap = player.cabin_cap or 0
local count = player:GetEquipCountOccupied("cabin")
fields["gauge"]:SetUpperValue(count)
fields["gauge"]:SetValue(count-cap)
fields["usedLabel"]:SetText(string.interp(l.CABIN_USED, { amount = count-cap }))
fields["freeLabel"]:SetText(string.interp(l.CABIN_FREE, { amount = cap}))
end

local function createGauge(text, connectTo, funcUpdate)
local gauge = ui:Gauge()
local usedLabel = ui:Label("")
local freeLabel = ui:Label("")
local fields = {}
fields["gauge"] = gauge;
fields["usedLabel"] = usedLabel;
fields["freeLabel"] = freeLabel;
local function innerFuncUpdate()
funcUpdate(fields);
end
for k,v in pairs(connectTo) do
player:Connect(v, innerFuncUpdate)
end
innerFuncUpdate()
local function cabinUpdate (fields)
local cap = player.cabin_cap or 0
local count = player:GetEquipCountOccupied("cabin")
fields["gauge"]:SetUpperValue(count)
fields["gauge"]:SetValue(count-cap)
fields["usedLabel"]:SetText(string.interp(l.CABIN_USED, { amount = count-cap }))
fields["freeLabel"]:SetText(string.interp(l.CABIN_FREE, { amount = cap}))
end

local function createGauge(text, connectTo, funcUpdate)
local gauge = ui:Gauge()
local usedLabel = ui:Label("")
local freeLabel = ui:Label("")
local fields = {}
fields["gauge"] = gauge;
fields["usedLabel"] = usedLabel;
fields["freeLabel"] = freeLabel;
local function innerFuncUpdate()
funcUpdate(fields);
end
for k,v in pairs(connectTo) do
player:Connect(v, innerFuncUpdate)
end
innerFuncUpdate()

return ui:Margin(10, "HORIZONTAL",
ui:HBox(10):PackEnd({
ui:Align("MIDDLE",
ui:HBox(10):PackEnd({
text..":",
gauge,
})
),
ui:VBox():PackEnd({
usedLabel,
freeLabel,
}):SetFont("XSMALL"),
})
)
end
return ui:Margin(10, "HORIZONTAL",
ui:HBox(10):PackEnd({
ui:Align("MIDDLE",
ui:HBox(10):PackEnd({
text..":",
gauge,
})
),
ui:VBox():PackEnd({
usedLabel,
freeLabel,
}):SetFont("XSMALL"),
})
)
end

local function createFooter(type)
type = type or "default"

local leftGauge = nil
if type == "default" then
leftGauge = createGauge(l.CARGO, { "usedCargo", "totalCargo" }, cargoUpdate)
elseif type == "equip" then
leftGauge = createGauge(l.CAPACITY, { "usedCapacity", "freeCapacity" }, capacityUpdate)
end
type = type or "default"

local leftGauge = nil
if type == "default" then
leftGauge = createGauge(l.CARGO, { "usedCargo", "totalCargo" }, cargoUpdate)
elseif type == "equip" then
leftGauge = createGauge(l.CAPACITY, { "usedCapacity", "freeCapacity" }, capacityUpdate)
end

return ui:Margin(15, "TOP",
ui:Margin(5, "VERTICAL",
Expand Down

0 comments on commit c5a9381

Please sign in to comment.