• Weird error when using DFrame with DHorizontalScroller
    6 replies, posted
For some reason I can't use DFrame with DHorizontalScroller however it's working fine with DImage. I'm very confusion. Works: local _ = 0 mainmenucharacterselectionframe = vgui.Create("DHorizontalScroller",mainmenubackgroundframe) mainmenucharacterselectionframe:SetSize(ScrW(),ScrH()-(ScrH() / 8 * 3)) mainmenucharacterselectionframe:SetPos(0,ScrH()/8) mainmenucharacterselectionframe:SetOverlap( -DM.FW:getWSize(mainmenucharacterselectionframe) / 100 ) mainmenucharacterselectionframe:SetVisible(true) mainmenucharacterselectionframe:MoveToFront() mainmenucharacterselectionframe:SetDrawOnTop(true) mainmenucharacterselectionframe:SetMouseInputEnabled(true) --[[mainmenucharacterselectionframe.btnLeft:Remove() mainmenucharacterselectionframe.btnRight:Remove()]] mainmenucharacterselectionframe.PanelCount = 5 mainmenucharacterselectionframe.MaxScroll = ((DM.FW:getWSize(mainmenucharacterselectionframe) / 4 - DM.FW:getWSize(mainmenucharacterselectionframe)/100 * 1.25) * (mainmenucharacterselectionframe.PanelCount - 4) ) + ((DM.FW:getWSize(mainmenucharacterselectionframe)/100) * (mainmenucharacterselectionframe.PanelCount - 6) ) mainmenucharacterselectionframe.FullScroll = 0 mainmenucharacterselectionframe.SetFullScroll = function(scrollamount) mainmenucharacterselectionframe.FullScroll = math.Clamp(scrollamount,0,mainmenucharacterselectionframe.MaxScroll + DM.FW:getWSize(mainmenucharacterselectionframe) / 100 * 2) end mainmenucharacterselectionframe.Think = function() if mainmenucharacterselectionframe.FullScroll <= DM.FW:getWSize(mainmenucharacterselectionframe)/100 then mainmenucharacterselectionframe:SetPos(DM.FW:getWSize(mainmenucharacterselectionframe)/100 - mainmenucharacterselectionframe.FullScroll ,ScrH()/8) elseif mainmenucharacterselectionframe.MaxScroll - mainmenucharacterselectionframe.FullScroll <= DM.FW:getWSize(mainmenucharacterselectionframe)/100 then mainmenucharacterselectionframe:SetPos( -(DM.FW:getWSize(mainmenucharacterselectionframe)/100 - math.Clamp(mainmenucharacterselectionframe.MaxScroll - mainmenucharacterselectionframe.FullScroll, 0 , 999999999)) ,ScrH()/8) else mainmenucharacterselectionframe:SetPos(0,ScrH()/8) end mainmenucharacterselectionframe:SetScroll(math.Clamp(mainmenucharacterselectionframe.FullScroll - DM.FW:getWSize(mainmenucharacterselectionframe)/100,0,999999999)) _ = _ + 50 mainmenucharacterselectionframe.SetFullScroll(_) end mainmenucharacterselectionframe.Paint = function() end mainmenucharacterselectionframe.OnClose = function() mainmenucharacterselectionframe:Remove() end for i = 1, mainmenucharacterselectionframe.PanelCount do local selectionimage = vgui.Create( "DImage", mainmenucharacterselectionframe ) selectionimage:SetSize(DM.FW:getWSize(mainmenucharacterselectionframe)/4 - (DM.FW:getWSize(mainmenucharacterselectionframe)/100 * 1.25) ,DM.FW:getHSize(mainmenucharacterselectionframe)) selectionimage:SetPos(0,0) selectionimage:SetImage( "scripted/breen_fakemonitor_1" ) mainmenucharacterselectionframe:AddPanel( selectionimage ) end Doesn't Work: local _ = 0 mainmenucharacterselectionframe = vgui.Create("DHorizontalScroller",mainmenubackgroundframe) mainmenucharacterselectionframe:SetSize(ScrW(),ScrH()-(ScrH() / 8 * 3)) mainmenucharacterselectionframe:SetPos(0,ScrH()/8) mainmenucharacterselectionframe:SetOverlap( -DM.FW:getWSize(mainmenucharacterselectionframe) / 100 ) mainmenucharacterselectionframe:SetVisible(true) mainmenucharacterselectionframe:MoveToFront() mainmenucharacterselectionframe:SetDrawOnTop(true) mainmenucharacterselectionframe:SetMouseInputEnabled(true) --[[mainmenucharacterselectionframe.btnLeft:Remove() mainmenucharacterselectionframe.btnRight:Remove()]] mainmenucharacterselectionframe.PanelCount = 5 mainmenucharacterselectionframe.MaxScroll = ((DM.FW:getWSize(mainmenucharacterselectionframe) / 4 - DM.FW:getWSize(mainmenucharacterselectionframe)/100 * 1.25) * (mainmenucharacterselectionframe.PanelCount - 4) ) + ((DM.FW:getWSize(mainmenucharacterselectionframe)/100) * (mainmenucharacterselectionframe.PanelCount - 6) ) mainmenucharacterselectionframe.FullScroll = 0 mainmenucharacterselectionframe.SetFullScroll = function(scrollamount) mainmenucharacterselectionframe.FullScroll = math.Clamp(scrollamount,0,mainmenucharacterselectionframe.MaxScroll + DM.FW:getWSize(mainmenucharacterselectionframe) / 100 * 2) end mainmenucharacterselectionframe.Think = function() if mainmenucharacterselectionframe.FullScroll <= DM.FW:getWSize(mainmenucharacterselectionframe)/100 then mainmenucharacterselectionframe:SetPos(DM.FW:getWSize(mainmenucharacterselectionframe)/100 - mainmenucharacterselectionframe.FullScroll ,ScrH()/8) elseif mainmenucharacterselectionframe.MaxScroll - mainmenucharacterselectionframe.FullScroll <= DM.FW:getWSize(mainmenucharacterselectionframe)/100 then mainmenucharacterselectionframe:SetPos( -(DM.FW:getWSize(mainmenucharacterselectionframe)/100 - math.Clamp(mainmenucharacterselectionframe.MaxScroll - mainmenucharacterselectionframe.FullScroll, 0 , 999999999)) ,ScrH()/8) else mainmenucharacterselectionframe:SetPos(0,ScrH()/8) end mainmenucharacterselectionframe:SetScroll(math.Clamp(mainmenucharacterselectionframe.FullScroll - DM.FW:getWSize(mainmenucharacterselectionframe)/100,0,999999999)) _ = _ + 50 mainmenucharacterselectionframe.SetFullScroll(_) end mainmenucharacterselectionframe.Paint = function() end mainmenucharacterselectionframe.OnClose = function() mainmenucharacterselectionframe:Remove() end for i = 1, mainmenucharacterselectionframe.PanelCount do local selectionimage = vgui.Create( "DFrame", mainmenucharacterselectionframe ) selectionimage:SetSize(DM.FW:getWSize(mainmenucharacterselectionframe)/4 - (DM.FW:getWSize(mainmenucharacterselectionframe)/100 * 1.25) ,DM.FW:getHSize(mainmenucharacterselectionframe)) selectionimage:SetPos(0,0) mainmenucharacterselectionframe:AddPanel( selectionimage ) end
How about you make your code a lot more readable by replacing "mainmenucharacterselectionframe" with something a lot shorter like "frame" as a start?
I'm sorry I just straight copied it over, my bad. You have any ideas on how to actually fix it tho?
The actual problem lies more with the base game itself rather than your code unfortunately. Too bad I didn't see it before the April update. I can get it fixed on Monday, but your code will not work until the next update. I guess you could do something like this in the mean time: itemframe.ApplySchemeSettings = function() end frame:AddPanel( itemframe )
OK thank you.
There's frame:GetWidth()
No GetHigh(height) tho.
Sorry, you need to Log In to post a reply to this thread.