Hornete Posted April 29, 2019 Share Posted April 29, 2019 I have a widget in place that for some reason covers up the UI and inventory, How can I fix this? Widget Code Quote local Widget = require "widgets/widget" local Image = require "widgets/image" local VisorOver = Class(Widget, function(self, owner) self.owner = owner Widget._ctor(self, "VisorOver") self:SetClickable(false) self.bg = self:AddChild(Image("images/fx6.xml", "reduced_over.tex")) self.bg:SetHAnchor(ANCHOR_MIDDLE) self.bg:SetVAnchor(ANCHOR_MIDDLE) self.bg:SetScaleMode(SCALEMODE_FILLSCREEN) self.bg:SetVRegPoint(ANCHOR_MIDDLE) self.bg:SetHRegPoint(ANCHOR_MIDDLE) self.inst:DoPeriodicTask(0.1, function() return self:UpdateState() end) self:Hide() end) function VisorOver:UpdateState(data) local hat = self.owner.replica.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) if hat and hat:HasTag("visorvision") then self:Show() else self:Hide() end end return VisorOver Modmain code Quote AddClassPostConstruct( "widgets/controls", function(self) local ownr = self.owner if ownr == nil then return end local VisorOver = require "widgets/visorover" self.visorover = self:AddChild(VisorOver(ownr) ) end) Link to comment Share on other sites More sharing options...
Hornete Posted April 30, 2019 Author Share Posted April 30, 2019 No one? Link to comment Share on other sites More sharing options...
Ultroman Posted April 30, 2019 Share Posted April 30, 2019 Full disclosure: I know nothing about widgets. That said, from what I'm reading, this sounds like a sorting layer issue. I can't figure out how those work in the widgets, but I noticed that there are two functions called MoveToBack() and MoveToFront(), and you can call them on just about any UI element it seems. Buttons, images etc. Try calling myentity:MoveToBack() Link to comment Share on other sites More sharing options...
Hornete Posted April 30, 2019 Author Share Posted April 30, 2019 27 minutes ago, Ultroman said: Full disclosure: I know nothing about widgets. That said, from what I'm reading, this sounds like a sorting layer issue. I can't figure out how those work in the widgets, but I noticed that there are two functions called MoveToBack() and MoveToFront(), and you can call them on just about any UI element it seems. Buttons, images etc. Try calling myentity:MoveToBack() Sorry, but where should I put the MoveToBack()? Link to comment Share on other sites More sharing options...
Ultroman Posted April 30, 2019 Share Posted April 30, 2019 I have no idea, but a qualified guess would be AddClassPostConstruct( "widgets/controls", function(self) local ownr = self.owner if ownr == nil then return end local VisorOver = require "widgets/visorover" self.visorover = self:AddChild(VisorOver(ownr) ) self:MoveToBack() end) Again, I have no idea about this. I just read through the widget code, saw this and its sister-function MoveToFront() being used for what I think is the purpose of moving widgets from the front of the sorting layers to the back or vice versa. I searched the game files for usage of it and its origins, and found that widget.lua has this function, but it just calls a function by the same name on the widget's entity, and I can't find the code for that function on the entity anywhere, so I don't know what it does xD Link to comment Share on other sites More sharing options...
Hornete Posted April 30, 2019 Author Share Posted April 30, 2019 38 minutes ago, Ultroman said: I have no idea, but a qualified guess would be AddClassPostConstruct( "widgets/controls", function(self) local ownr = self.owner if ownr == nil then return end local VisorOver = require "widgets/visorover" self.visorover = self:AddChild(VisorOver(ownr) ) self:MoveToBack() end) Again, I have no idea about this. I just read through the widget code, saw this and its sister-function MoveToFront() being used for what I think is the purpose of moving widgets from the front of the sorting layers to the back or vice versa. I searched the game files for usage of it and its origins, and found that widget.lua has this function, but it just calls a function by the same name on the widget's entity, and I can't find the code for that function on the entity anywhere, so I don't know what it does xD THANK YOU! I got it to work! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now