Fixed not being able to access arguments list on most commands. Fixes #34

Fixed error occuring in some parts of XGUI. Fixes #29 #33
Fixed error when typing in slider textboxes
Disabled variable arguments (ulx vote choices) in the commands menu for now.
This commit is contained in:
SticklyMan 2012-10-27 17:03:38 -06:00
parent 8de0f4a140
commit defdc5b635
3 changed files with 24 additions and 23 deletions

View File

@ -434,7 +434,7 @@ local function xgui_helpers()
outPanel = xlib.makepanel{ h=35 }
outPanel.val = xlib.makeslider{ w=160, min=min, max=max, value=min, decimal=0, parent=outPanel }
outPanel.interval = xlib.makemultichoice{ w=75, parent=outPanel }
outPanel.interval = xlib.makecombobox{ w=75, parent=outPanel }
local divisor = {}
local sensiblemax = {}
@ -452,14 +452,14 @@ local function xgui_helpers()
outPanel.val:SetMax( outPanel.val.maxvalue )
outPanel.val:SetMin( outPanel.val.minvalue )
outPanel.val:SetValue( math.Clamp( tonumber( outPanel.val:GetValue() ), outPanel.val.minvalue, outPanel.val.maxvalue ) )
outPanel.val:PerformLayout()
--outPanel.val:PerformLayout() --TODO: Sliders broken
end
function outPanel.val:ValueChanged( val )
val = math.Clamp( tonumber( val ), self.minvalue, self.maxvalue )
self.Slider:SetSlideX( self.Wang:GetFraction( val ) )
self:OnValueChanged( val )
self.Wang.TextEntry:SetText( val )
self.Wang:SetText( val )
end
outPanel.interval:ChooseOptionID( 1 )

View File

@ -6,7 +6,12 @@ cmds.selcmd = nil
cmds.mask = xlib.makepanel{ x=160, y=30, w=425, h=335, parent=cmds }
cmds.argslist = xlib.makelistlayout{ w=170, h=335, parent=cmds.mask }
cmds.argslist.secondaryPos = nil
cmds.argslist:SetVisible( false )
function cmds.argslist.IsVisible( self )
return self.scroll:IsVisible( self.scroll )
end
cmds.argslist.scroll:SetVisible( false )
function cmds.argslist:Open( cmd, secondary )
if secondary then
if cmds.plist:IsVisible() then
@ -187,8 +192,9 @@ function cmds.buildArgsList( cmd )
panel.button = xlib.makebutton{ label="Add", w=80, parent=panel }
panel.button.DoClick = function( self )
local parent = self:GetParent()
table.insert( cmds.argslist:GetChildren(), parent.insertPos, parent.arg.type.x_getcontrol( parent.arg, parent.argnum ) )
cmds.argslist:GetChildren()[parent.insertPos]:SetParent( cmds.argslist.pnlCanvas )
--table.insert( cmds.argslist:GetChildren(), parent.insertPos, parent.arg.type.x_getcontrol( parent.arg, parent.argnum ) )
--cmds.argslist:GetChildren()[parent.insertPos]:SetParent( cmds.argslist.pnlCanvas ) --TODO: Broken
--cmds.argslist:GetChildren()[parent.insertPos]:SetParent( parent ) -- does this help?
cmds.argslist:InvalidateLayout()
panel.numItems = panel.numItems + 1
parent.insertPos = parent.insertPos + 1
@ -198,14 +204,15 @@ function cmds.buildArgsList( cmd )
panel.button2 = xlib.makebutton{ label="Remove", x=80, w=80, disabled=true, parent=panel }
panel.button2.DoClick = function( self )
local parent = self:GetParent()
cmds.argslist:GetChildren()[parent.insertPos-1]:Remove()
table.remove( cmds.argslist:GetChildren(), parent.insertPos - 1 )
--cmds.argslist:GetChildren()[parent.insertPos-1]:Remove() --TODO: Broken
--table.remove( cmds.argslist:GetChildren(), parent.insertPos - 1 )
cmds.argslist:InvalidateLayout()
panel.numItems = panel.numItems - 1
parent.insertPos = parent.insertPos - 1
if panel.numItems < parent.arg.repeat_min then self:SetDisabled( true ) end
if panel.button:GetDisabled() then panel.button:SetDisabled( false ) end
end
--panel:SizeToChildren()
cmds.argslist:Add( panel )
elseif curitem and curitem.type == ULib.cmds.NumArg then
cmds.argslist:GetChildren()[#cmds.argslist:GetChildren()].Wang.OnEnter = function( self )
@ -333,7 +340,6 @@ cmds.refresh = function( permissionChanged )
end
cmds.permissionChanged = nil
end
cmds.refresh()
--------------
--ANIMATIONS--
@ -351,28 +357,23 @@ function cmds.argslist:openAnim( cmd, secondary )
xlib.addToAnimQueue( function() cmds.argslist.secondaryPos = secondary end )
xlib.addToAnimQueue( cmds.buildArgsList, cmd )
if secondary then
xlib.addToAnimQueue( "pnlSlide", { panel=self, startx=-170, starty=0, endx=0, endy=0, setvisible=true } )
xlib.addToAnimQueue( "pnlSlide", { panel=self.scroll, startx=-170, starty=0, endx=0, endy=0, setvisible=true } )
else
xlib.addToAnimQueue( "pnlSlide", { panel=self, startx=80, starty=0, endx=255, endy=0, setvisible=true } )
xlib.addToAnimQueue( "pnlSlide", { panel=self.scroll, startx=80, starty=0, endx=255, endy=0, setvisible=true } )
end
end
function cmds.argslist:closeAnim( secondary )
if secondary then
xlib.addToAnimQueue( "pnlSlide", { panel=self, startx=0, starty=0, endx=-170, endy=0, setvisible=false } )
xlib.addToAnimQueue( "pnlSlide", { panel=self.scroll, startx=0, starty=0, endx=-170, endy=0, setvisible=false } )
else
--Apparently derma is REALLY picky when working with panels that aren't visible. To fix a minor drawing issue, we're going to keep the argslist panel
--visible, set it's position manually off the screen, then wait a frame or two. If the panel hasn't been moved since then, then we make it invisible.
xlib.addToAnimQueue( "pnlSlide", { panel=self, startx=255, starty=0, endx=80, endy=0, setvisible=true } )
xlib.addToAnimQueue( self.SetPos, self, -170, 0 )
xlib.addToAnimQueue( timer.Simple, 0.1, function()
local x,y = cmds.argslist:GetPos()
if x == -170 then cmds.argslist:SetVisible( false ) end end )
xlib.addToAnimQueue( "pnlSlide", { panel=self.scroll, startx=255, starty=0, endx=80, endy=0, setvisible=false } )
end
xlib.addToAnimQueue( function() cmds.argslist.secondaryPos = nil end )
end
--------------
cmds.refresh()
hook.Add( "UCLChanged", "xgui_RefreshPlayerCmds", cmds.refresh )
hook.Add( "ULibPlayerNameChanged", "xgui_plyUpdateCmds", cmds.playerNameChanged )
xgui.addModule( "Cmds", cmds, "icon16/user_gray.png" )

View File

@ -684,8 +684,8 @@ function groups.populateRestrictionArgs( cmd, accessStr )
local curinterval = ( irmin or iargmin or "Permanent" )
local curval = vrmin or vargmin or 0
outPanel.min = xlib.makeslider{ x=25, y=5, w=150, min=( vargmin or 0 ), max=( vargmax or 100 ), value=curval, decimal=0, disabled=( curinterval=="Permanent" ), parent=outPanel }
--outPanel.min.Wang.TextEntry:SetText( curval ) --Set the value of the textentry manually to show decimals even though decimal=0. --TODO: Fix sliders
outPanel.minterval = xlib.makemultichoice{ x=50, y=5, w=60, text=curinterval, choices={ "Permanent", "Minutes", "Hours", "Days", "Weeks", "Years" }, disabled=( rmin==nil ), parent=outPanel }
outPanel.min.Wang:SetText( curval ) --Set the value of the textentry manually to show decimals even though decimal=0.
outPanel.minterval = xlib.makecombobox{ x=50, y=5, w=60, text=curinterval, choices={ "Permanent", "Minutes", "Hours", "Days", "Weeks", "Years" }, disabled=( rmin==nil ), parent=outPanel }
outPanel.minterval.OnSelect = function( self, index, value, data )
outPanel.min:SetDisabled( value == "Permanent" )
end
@ -697,8 +697,8 @@ function groups.populateRestrictionArgs( cmd, accessStr )
local curinterval = ( irmax or iargmax or "Permanent" )
local curval = vrmax or vargmax or 0
outPanel.max = xlib.makeslider{ x=25, y=45, w=150, min=( vargmin or 0 ), max=( vargmax or 100 ), value=curval, decimal=0, disabled=( curinterval=="Permanent" ), parent=outPanel }
outPanel.max.Wang.TextEntry:SetText( curval )
outPanel.maxterval = xlib.makemultichoice{ x=50, y=45, w=60, text=curinterval, choices={ "Permanent", "Minutes", "Hours", "Days", "Weeks", "Years" }, disabled=( rmax==nil ), parent=outPanel }
outPanel.max.Wang:SetText( curval )
outPanel.maxterval = xlib.makecombobox{ x=50, y=45, w=60, text=curinterval, choices={ "Permanent", "Minutes", "Hours", "Days", "Weeks", "Years" }, disabled=( rmax==nil ), parent=outPanel }
outPanel.maxterval.OnSelect = function( self, index, value, data )
outPanel.max:SetDisabled( value == "Permanent" )
end