• DIconLayout & SetScissorRect Issue
    3 replies, posted
Hello, I'm making a small addon that has a shop system. To present the items in the shop, I've used a 'DIconLayout' with a 'DScrollPanel' whose items are custom panel that contains a 'DModelPanel' to display the model. Anyway, the issue is that when I scroll up/down the list, the models overflow out of the list - another guy who had the same problem posted a picture [URL="http://www.facepunch.com/showthread.php?t=1293629"]HERE[/URL]. After doing a quick Google, I found out I had to add a SetScissorRect to my 'DModelPanel' that's inside of my item panel. Here is my code: [CODE] local storeScrollSheet = vgui.Create( "DScrollPanel" ) storeScrollSheet:SetSize( widthPortion*2-35, heightPortion-40) storeScrollSheet:SetPos( 10, 8 ) local storeList = vgui.Create( "DIconLayout", storeScrollSheet ) storeList:SetSize(storeScrollSheet:GetWide(), storeScrollSheet:GetTall()) storeList:SetPos( 0, 8 ) storeList:SetSpaceY( 5 ) storeList:SetSpaceX( 5 ) -- Sorts out items by cost table.SortByMember(clickerItemList, "Cost", function(a, b) return a > b end) clickerSettings.secretAllowPurchase = true for k, itemData in pairs(clickerItemList) do local listItem = storeList:Add( "clickerItem" ) listItem:SetSize( (storeList:GetWide()/2)-10, 100 ) listItem:SetData(itemData) end propertySheet:AddSheet( "Store", storeScrollSheet, "icon16/money.png", false, false, "A wide variety of items that help increase your melon production!" ) [/CODE] And here is my 'clickerItem' 'SetData' code (I attempted to use SetScissorRect to try to fix it: [CODE] self.preview = vgui.Create( "clickerModelPanel", self ) self.preview:SetModel( self.Model ) self.preview:SetSize( self:GetTall(), self:GetTall() ) local prevPaint = self.preview.Paint function self.preview:Paint() local pnl = self:GetParent():GetParent() local x2, y2 = pnl:LocalToScreen( 0, 0 ) local w2, h2 = pnl:GetSize() render.SetScissorRect( x2, y2, x2 + w2, y2 + h2, true ) oldpaint( self ) render.SetScissorRect( 0, 0, 0, 0, false ) end [/CODE] Thanks for any help :)
[lua]local oldPaint = DModelPanel.Paint ModelPanel.Paint = function( self ) local x, y = self:LocalToScreen( 0, 0 ) local w, h = self:GetSize() local sl, st, sr, sb = x, y, x + w, y + h local p = self while p:GetParent() do p = p:GetParent() local pl, pt = p:LocalToScreen( 0, 0 ) local pr, pb = pl + p:GetWide(), pt + p:GetTall() sl = sl < pl and pl or sl st = st < pt and pt or st sr = sr > pr and pr or sr sb = sb > pb and pb or sb end render.SetScissorRect( sl, st, sr, sb, true ) oldPaint(self) render.SetScissorRect( 0, 0, 0, 0, false ) end[/lua] It's a copy from Undefineds Pointshop.
[QUOTE=Netheous;43383120][lua]local oldPaint = DModelPanel.Paint ModelPanel.Paint = function( self ) local x, y = self:LocalToScreen( 0, 0 ) local w, h = self:GetSize() local sl, st, sr, sb = x, y, x + w, y + h local p = self while p:GetParent() do p = p:GetParent() local pl, pt = p:LocalToScreen( 0, 0 ) local pr, pb = pl + p:GetWide(), pt + p:GetTall() sl = sl < pl and pl or sl st = st < pt and pt or st sr = sr > pr and pr or sr sb = sb > pb and pb or sb end render.SetScissorRect( sl, st, sr, sb, true ) oldPaint(self) render.SetScissorRect( 0, 0, 0, 0, false ) end[/lua] It's a copy from Undefineds Pointshop.[/QUOTE] I found this yesterday while checking his source and it fixed my issue, thanks for posting though! :)
[QUOTE=Braden1996;43401029]I found this yesterday while checking his source and it fixed my issue, thanks for posting though! :)[/QUOTE] When your issue is solved, click "Solved" so people don't waste time trying to help you.
Sorry, you need to Log In to post a reply to this thread.