Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require = GLOBAL.require
- local Text = require "widgets/text"
- local displayTemperature = GetModConfigData("displayTemperature")
- AddClassPostConstruct("widgets/badge", function(self)
- self.isFocused = false
- local oldOnLoseFocus = self.OnLoseFocus
- function self:OnLoseFocus()
- local result = oldOnLoseFocus(self)
- self.isFocused = false
- if self.num then
- self.num:Show()
- end
- if self.num2 then
- self.num2:Hide()
- end
- return result
- end
- local oldOnGainFocus = self.OnGainFocus
- function self:OnGainFocus()
- local result = oldOnGainFocus(self)
- self.isFocused = true
- if self.num then
- self.num:Hide()
- end
- if self.num2 then
- self.num2:Show()
- end
- return result
- end
- local oldSetPercent = self.SetPercent
- function self:SetPercent(val, max)
- local result = oldSetPercent(self, val, max)
- if self.num and self.isFocused == false then
- self.num:Show()
- end
- if not self.num2 then
- self.num2 = self:AddChild(Text(GLOBAL.BODYTEXTFONT, 33))
- self.num2:SetHAlign(GLOBAL.ANCHOR_MIDDLE)
- self.num2:SetPosition(5, 0, 0)
- self.num2:Hide()
- end
- self.num2:SetString(tostring(max))
- return result
- end
- end)
- -- Temperature in the clock area
- if displayTemperature == "yes" then
- AddClassPostConstruct("widgets/uiclock", function(self)
- local oldUpdateDayString = self.UpdateDayString
- function self:UpdateDayString()
- local result = oldUpdateDayString(self)
- self.text:SetPosition(5, 3/self.base_scale, 0)
- if not self.text2 then
- self.text2 = self:AddChild(Text(GLOBAL.BODYTEXTFONT, 25/self.base_scale))
- self.text2:SetPosition(5, -23/self.base_scale, 0)
- local temper = tostring(GLOBAL.GetPlayer().components.temperature.current or "?")
- self.inst:DoPeriodicTask(0.25, function(inst)
- temper=tostring(GLOBAL.GetPlayer().components.temperature.current or "?")
- temper=math.floor(temper)
- self.text2:SetString(temper.."\176C")
- end)
- end
- return result
- end
- self:UpdateDayString()
- end)
- end
- -- Moisture Meter: apparently not a widget/badge
- if (GLOBAL.IsDLCEnabled(1)) then
- AddClassPostConstruct("widgets/moisturemeter", function(self)
- local oldActivate = self.Activate
- function self:Activate()
- local result = oldActivate(self)
- if self.num then
- self.num:Show()
- end
- return result
- end
- local oldDeactivate = self.Deactivate
- function self:Deactivate()
- local result = oldDeactivate(self)
- if self.num then
- self.num:Hide()
- self.inst:DoTaskInTime(.25, function(inst)
- self.num:Hide()
- end)
- end
- return result
- end
- local oldOnLoseFocus = self.OnLoseFocus
- function self:OnLoseFocus()
- local result = oldOnLoseFocus(self)
- if self.num then
- self.num:Show()
- end
- return result
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement