Skip to content

Instantly share code, notes, and snippets.

@mk-fg
Created March 20, 2018 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mk-fg/f0cd2bec2d347ae640e957a00caf512e to your computer and use it in GitHub Desktop.
Save mk-fg/f0cd2bec2d347ae640e957a00caf512e to your computer and use it in GitHub Desktop.
UIWorkshiftUpdate = function(self, building, shift)
-- function num : 0_56 , upvalues : shift_names, _ENV, WorkerSlot, OpenSlot, ClosedSlot
self:SetRolloverTitle(shift_names[shift])
local training = not building:IsKindOf("TrainingBuilding") or building.max_visitors > 0
local workplace = not building:IsKindOf("Workplace") or building.max_workers > 0
local shift_active = building:IsShiftUIActive(shift)
local shift_closed = building:IsClosedShift(shift)
if workplace then
local shift_overtime = (building.overtime)[shift]
end
local single_shift = not workplace or building.active_shift ~= 0
;
(self.idActive):SetVisible(shift_active)
if shift_closed then
if single_shift then
self:SetIcon("UI/Icons/Sections/workshifts_stop.tga")
self:SetTitle(T({130, "N/A"}))
else
self:SetIcon("UI/Icons/Sections/workshifts_pause.tga")
if (not workplace and not training) or not T({7359, "Stopped Work Shift"}) then
self:SetTitle(T({6771, "<red>OFF</red>"}))
self:SetIcon("UI/Icons/Sections/workshifts_active.tga")
if (not workplace and not training) or not "" then
self:SetTitle(T({6772, "<green>ON</green>"}))
rawset(self, "ProcessToggle", function(self, context, broadcast)
-- function num : 0_56_0 , upvalues : _ENV
local building = ResolvePropObj(context)
if broadcast then
local closed = not not building:IsClosedShift(context.shift)
do
BroadcastAction(building, function(obj)
-- function num : 0_56_0_0 , upvalues : closed, context
if closed == not not obj:IsClosedShift(context.shift) then
obj:ToggleShift(context.shift)
end
end
)
end
else
do
building:ToggleShift(context.shift)
RebuildInfopanel(building)
end
end
end
)
self.OnActivate = function(self, context, gamepad)
-- function num : 0_56_1 , upvalues : _ENV
self:ProcessToggle(context, (not gamepad and IsMassUIModifierPressed()))
-- DECOMPILER ERROR: 2 unprocessed JMP targets
end
self.OnAltActivate = function(self, context, gamepad)
-- function num : 0_56_2
if gamepad then
self:ProcessToggle(context, true)
end
end
local max_workers = (building:IsKindOf("TrainingBuilding") and building.max_visitors) or (building:IsKindOf("Workplace") and building.max_workers) or 0
if #self.idWorkers ~= max_workers then
(self.idWorkers):DeleteChildren()
for i = 1, max_workers do
local person = XTemplateSpawn("InfopanelPerson", self.idWorkers)
person.OnPress = function(self)
-- function num : 0_56_3 , upvalues : _ENV
if self.context then
(self.context):Select(WorkplaceCycle)
end
end
person.OnAltPress = function(self)
-- function num : 0_56_4 , upvalues : _ENV, building, shift
local i = (table.find)(self.parent, self)
if self.context then
(self.context):GetFired()
else
if self:GetIcon() == "UI/Infopanel/colonist_empty.tga" then
building:ClosePositions(shift, i)
else
building:OpenPositions(shift, i)
end
end
ObjModified(building)
end
end
;
(self.idWorkers):ResolveRelativeFocusOrder()
end
;
(self.idWorkers):SetVisible((max_workers > 0 and not shift_closed))
local closed_slots = building.max_workers - ((training and (not (building.closed_visitor_slots)[shift] and building.max_visitors - (max_workers <= 0 or 0)) or (building.closed_workplaces)[shift]) or 0)
if not training or not (building.visitors)[shift] then
local workers = (building.workers)[shift]
end
for i,win in ipairs(self.idWorkers) do
local worker = workers[i]
;
(win.idSpecialization):SetVisible(worker)
if worker then
win:SetIcon(worker:GetInfopanelIcon())
;
(win.idSpecialization):SetImage(worker.ip_specialization_icon)
SetObjPropertyList(win, WorkerSlot)
elseif i <= closed_slots then
SetObjPropertyList(win, OpenSlot)
else
SetObjPropertyList(win, ClosedSlot)
end
win:SetContext(worker)
XRecreateRolloverWindow(win)
end
;
(self.idOvertime):SetVisible(workplace)
if workplace then
if shift_overtime then
(self.idOvertime):RemoveModifier("desat")
else
(self.idOvertime):AddInterpolation({id = "desat", type = const.intDesaturation, startValue = 255})
end
;
(self.idOvertime):SetRow(shift_active and 2 or 1)
-- DECOMPILER ERROR at PC279: Confused about usage of register: R10 in 'UnsetPending'
if not shift_overtime or not T({4212, "Heavy workload"}) then
(self.context).UIOvertimeText = T({4213, "Normal workload"})
self.GetRolloverText = function(self)
-- function num : 0_56_5 , upvalues : _ENV
local shift = (self.context).shift
local building = ResolvePropObj(self.context)
local items = {T({7360, "Toggle the current work shift ON or OFF. The building will operate only during active work shifts."})}
local is_workplace = building:IsKindOf("Workplace")
if is_workplace then
if building.active_shift > 0 then
items[#items + 1] = T({228, "<em>This building operates on a single work shift</em>"})
else
items[#items + 1] = T({7361, "You’ll need a separate crew of workers for each shift."})
end
if building.active_shift > 0 or shift == 3 then
items[#items + 1] = ""
if shift == 3 then
items[#items + 1] = T({7362, "<em>Workers will lose Sanity if they work during the night shift.</em>"})
end
end
end
items[#items + 1] = ""
items[#items + 1] = T({7363, "Working hours<right><number1>-<number2>h"; number1 = ((const.DefaultWorkshifts)[shift])[1], number2 = ((const.DefaultWorkshifts)[shift])[2]})
if not building:IsClosedShift(shift) or not T({6771, "<red>OFF</red>"}) then
items[#items + 1] = T({7364, "Status: <status>"; status = T({6772, "<green>ON</green>"})})
if is_workplace then
items[#items + 1] = Untranslated("\n")
if shift ~= building.current_shift or not T({7634, "Building performance<right><performance>"}) then
items[#items + 1] = T({7635, "Building performance"})
do
local texts = building:GetPerformanceReasons(shift)
texts = (table.concat)(texts, "\n")
items[#items + 1] = T({texts, building})
return (table.concat)(items, "<newline><left>")
end
end
end
end
end
-- DECOMPILER ERROR: 40 unprocessed JMP targets
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment