• Print

Author Topic: DListView  (Read 7931 times)

0 Members and 1 Guest are viewing this topic.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
DListView
« on: May 06, 2014, 09:31:46 pm »
Alright, I'm very frustrated, and annoyed at this. About once a month, I come back to lua, and try for about two days, then I get frustrated because the wikis really suck, and then I just get annoyed, and quit again. I'm done quitting, and I need assistance on this.

Alright, I'm trying to make it so that I can select a name from DListView, and then when I press a button, it takes the name( or unique ID, i don't care) of that selected person, and sends it through a console command... that's all I want, but I just can't find out how to do this for the love of my life. I'm quit annoyed right now, so please excuse my terrible punctuation.

This is what I have so far.

Code: [Select]
GetGiveMoneyPlayers = vgui.Create("DListView", TabThree )
GetGiveMoneyPlayers:SetPos(273, 75)
GetGiveMoneyPlayers:SetSize(300, 175)
GetGiveMoneyPlayers:SetMultiSelect(false)
GetGiveMoneyPlayers:AddColumn("Name")
GetGiveMoneyPlayers:AddColumn("Points")
for k,v in pairs(player.GetAll()) do
    GetGiveMoneyPlayers:AddLine(v:Nick(),v:GetPData('MyXPPoints'))
end

GiveMoneyBox = vgui.Create( "DTextEntry", TabThree)
GiveMoneyBox:SetPos( 348,50 )
GiveMoneyBox:SetTall( 25 )
GiveMoneyBox:SetWide( 75 )
GiveMoneyBox:SetEnterAllowed( true )
GiveMoneyBox:SetValue(100)

MoneyButton = vgui.Create( "DButton", TabThree )
MoneyButton:SetSize( 72, 25 )
MoneyButton:SetPos( 88, 70 )
MoneyButton:SetPos( 273, 50 )
MoneyButton:SetText( "Give Money" )
MoneyButton.DoClick = function()
-- MsgN(GetGiveMoneyPlayers:GetSelectedLine())
PrintTable(GetGiveMoneyPlayers:GetSelected(GetGiveMoneyPlayers:GetSelectedLine()))

--    RunConsoleCommand( "TDMGiveMoney", GetGiveMoneyPlayers:GetSelected(), GiveMoneyBox:GetValue() )
--PrintTable(GetGiveMoneyPlayers:GetSelected():GetValue(1))
--MsgN(GetGiveMoneyPlayers:GetSelected():GetValue(1))
end
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: DListView
« Reply #1 on: May 07, 2014, 06:15:59 am »
You're very close.

You need to call the function GetLine( line index) and GetValue(index) where index is the index of the column you want the information from. If you want to return their name use this:

GetGiveMoneyPlayers:GetLine(GetGiveMoneyPlayers:GetSelectedLine()):GetValue(1)

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: DListView
« Reply #2 on: May 07, 2014, 04:18:36 pm »


Though, I have another issue, seeing as XGUI is made up all of client, maybe you guys could further help me. This might be asking for too much though, but never hurts to try, or find out another way of doing it.


So, I wanted to make it so that whenever any button is pressed, it updates all the "DListView", or when a player joins, it updates the DListView so that it will show more accurate results.

This is my entire code at the moment, I even tried to make it togglible menu, but I never got it to work. I think I asked you guys about the togglible menu before, in the past, but it never worked.
Code: [Select]
// CLIENT SIDE

function tdm_menu(data)
PlayerName = data:ReadString()
/*
local TestPanel = 0
if TestingPanel != nil then
if TestingPanel:IsVisible( ) then
MsgN('IsVisible')
else
MsgN('IsNotVisible')
end

else
*/
local GAMEMODE_VERSION = "1.0b"

// Start of Main Frame
local MainMenuFrame = vgui.Create( "DFrame" )
MainMenuFrame:SetSize( 600, 250 )
MainMenuFrame:SetTitle("Team Deathmatch Menu: Version "..GAMEMODE_VERSION )
MainMenuFrame:Center()
MainMenuFrame:ShowCloseButton(false)
MainMenuFrame:SetVisible( true )
MainMenuFrame:SetDraggable( false )
MainMenuFrame:MakePopup()
function MainMenuFrame:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color(team.GetColor(LocalPlayer():Team()).r,team.GetColor(LocalPlayer():Team()).g,team.GetColor(LocalPlayer():Team()).b,50))
surface.SetDrawColor(0,0,0)
surface.DrawOutlinedRect(1,1,w-1,h-1)
end

/*
if LocalPlayer():GetPData("TDMMenuOpen") == 1 || LocalPlayer():GetPData("TDMMenuOpen") == "1" then
LocalPlayer():SetPData("TDMMenuOpen", 0)
MainMenuFrame:Close()
MsgN('Should be closing')
return
end
LocalPlayer():SetPData("TDMMenuOpen", 1)
*/

local CloseButton = vgui.Create( "DButton", MainMenuFrame )
CloseButton:SetSize( 30, 18 )
CloseButton:SetPos( 565, 4 )
CloseButton:SetText( "Close" )
CloseButton.DoClick = function( btn )
LocalPlayer():SetPData("TDMMenuOpen", 0)
MainMenuFrame:Close()
end

/*
local TestingPanel = vgui.Create( "DPanel", MainMenuFrame )
TestingPanel:SetPos( 25, 50 )
TestingPanel:SetSize( 250, 250 )
TestingPanel.Paint = function() -- Paint function
    --Set our rect color below us; we do this so you can see items added to this panel
    surface.SetDrawColor( 50, 50, 50, 255 )
    surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) -- Draw the rect
end
*/

// Start of TabsList
local MainMenuSheet = vgui.Create( "DPropertySheet", MainMenuFrame )
MainMenuSheet:SetPos( 5, 27 )
MainMenuSheet:SetSize( 590, 217 )
 
local TabOne = vgui.Create( "DPanelList" )
TabOne:SetPos( 0, 0 )
TabOne:SetSize( MainMenuSheet:GetWide(), MainMenuSheet:GetTall() )
TabOne:SetSpacing( 5 )
TabOne:EnableHorizontal( false )
TabOne:EnableVerticalScrollbar( true )

local TabThree = vgui.Create( "DPanelList" )
TabThree:SetPos( 0, 0 )
TabThree:SetSize( MainMenuSheet:GetWide(), MainMenuSheet:GetTall() )
TabThree:SetSpacing( 5 )
TabThree:EnableHorizontal( false )
TabThree:EnableVerticalScrollbar( true )

local TabTwo = vgui.Create( "DPanelList" )
TabTwo:SetPos( 0, 0 )
TabTwo:SetSize( MainMenuSheet:GetWide(), MainMenuSheet:GetTall() )
TabTwo:SetSpacing( 5 )
TabTwo:EnableHorizontal( false )
TabTwo:EnableVerticalScrollbar( true )
// End of TabList


// Start of Team Tab
local ChooseATeam = vgui.Create("DLabel", TabOne)
ChooseATeam:SetPos(10,5)
ChooseATeam:SetColor( Color( 0, 0, 0, 255 ) )
ChooseATeam:SetFont("default")
ChooseATeam:SetText("Choose a Team:")
ChooseATeam:SizeToContents()

local PlayerTeamList = vgui.Create("DListView", TabOne)
PlayerTeamList:SetPos(273, 0)
PlayerTeamList:SetSize(300, 180)
PlayerTeamList:SetMultiSelect(false)
PlayerTeamList:AddColumn("Player")
PlayerTeamList:AddColumn("Team")
PlayerTeamList:AddColumn("Kills")
PlayerTeamList:AddColumn("Deaths")
for k,v in pairs(player.GetAll()) do
    PlayerTeamList:AddLine(v:Nick(),team.GetName(v:Team()),v:Frags(),v:Deaths())
end

local MenuButton = vgui.Create("DButton", TabOne)
MenuButton:SetText( "Team Chooser:" )
MenuButton:SetPos(7, 20)
MenuButton:SetSize( 150, 25 )
MenuButton.DoClick = function ( btn )
    local MenuButtonOptions = DermaMenu()
for k,v in pairs(team.GetAllTeams()) do
if k != 0 and k < 1000 then
MenuButtonOptions:AddOption(team.GetName(k), function() 
RunConsoleCommand( "SwitchTDMTeamIndex", tonumber(k) )
MainMenuFrame:Close()
end )
MenuButtonOptions:Open()
end
end

end
// End of Team Tab


// Start of Config Tab
local FriendlyFire = vgui.Create("DLabel", TabTwo)
FriendlyFire:SetPos(10,5)
FriendlyFire:SetColor( Color( 0, 0, 0, 255 ) )
FriendlyFire:SetFont("default")
FriendlyFire:SetText("Friendly Fire")
FriendlyFire:SizeToContents()

local FriendlyFireButton = vgui.Create( "DButton", TabTwo )
FriendlyFireButton:SetSize( 150, 25 )
FriendlyFireButton:SetPos( 7, 20 )
FriendlyFireButton:SetText( "Friendly Fire" )
FriendlyFireButton.DoClick = function( btn )
    local MenuButtonOptions = DermaMenu()
MenuButtonOptions:AddOption("Friendly Fire On", function() 
RunConsoleCommand( "TDMFriendlyFireButton", 1 )
end )
MenuButtonOptions:AddOption("Friendly Fire Off", function() 
RunConsoleCommand( "TDMFriendlyFireButton", 0 )
end )
MenuButtonOptions:Open()
end

local TDM_CONSOLE_HELP = vgui.Create("DLabel", TabTwo)
TDM_CONSOLE_HELP:SetPos(225,5)
TDM_CONSOLE_HELP:SetColor( Color( 0, 0, 0, 255 ) )
TDM_CONSOLE_HELP:SetFont("default")
TDM_CONSOLE_HELP:SetText("TDM HELP")
TDM_CONSOLE_HELP:SizeToContents()

local TDM_CONSOLE_HELP_BUTTON = vgui.Create( "DButton", TabTwo )
TDM_CONSOLE_HELP_BUTTON:SetSize( 150, 25 )
TDM_CONSOLE_HELP_BUTTON:SetPos( 175, 20 )
TDM_CONSOLE_HELP_BUTTON:SetText( "TDM HELP" )
TDM_CONSOLE_HELP_BUTTON.DoClick = function( btn )
    RunConsoleCommand( "tdm_help" )
    RunConsoleCommand( "tdm_help_message" )
end

local CustomGoalText = vgui.Create("DLabel", TabTwo)
CustomGoalText:SetPos(10,55)
CustomGoalText:SetColor( Color( 0, 0, 0, 255 ) )
CustomGoalText:SetFont("default")
CustomGoalText:SetText("Goal Score Limit (Number)")
CustomGoalText:SizeToContents()

local GoalDermaBox = vgui.Create( "DTextEntry", TabTwo)
GoalDermaBox:SetPos( 7,70 )
GoalDermaBox:SetTall( 25 )
GoalDermaBox:SetWide( 75 )
GoalDermaBox:SetEnterAllowed( true )
GoalDermaBox:SetValue(10)
GoalDermaBox.OnEnter = function()
    RunConsoleCommand( "TDMCustomGoalLimiter", GoalDermaBox:GetValue() )
end

local GoalButton = vgui.Create( "DButton", TabTwo )
GoalButton:SetSize( 72, 25 )
GoalButton:SetPos( 85, 70 )
GoalButton:SetText( "Set Goal" )
GoalButton.DoClick = function( btn )
    RunConsoleCommand( "TDMCustomGoalLimiter", GoalDermaBox:GetValue() )
end


local Armor = vgui.Create("DLabel", TabTwo)
Armor:SetPos(10,105)
Armor:SetColor( Color( 0, 0, 0, 255 ) )
Armor:SetFont("default")
Armor:SetText("Armor")
Armor:SizeToContents()

local ArmorButton = vgui.Create( "DButton", TabTwo )
ArmorButton:SetSize( 150, 25 )
ArmorButton:SetPos( 7, 120 )
ArmorButton:SetText( "Armor" )
ArmorButton.DoClick = function( btn )
    local MenuButtonOptions = DermaMenu()
MenuButtonOptions:AddOption("Armor On", function() 
RunConsoleCommand( "TDMArmorButton", 1 )
end )
MenuButtonOptions:AddOption("Armor Off", function() 
RunConsoleCommand( "TDMArmorButton", 0 )
end )
MenuButtonOptions:Open()
end
// End of Config Tab


// Start of Weapon Shop
local DisplayHeader = vgui.Create("DLabel", TabThree)
DisplayHeader:SetPos(10,5)
DisplayHeader:SetColor( Color( 0, 0, 0, 255 ) )
DisplayHeader:SetFont("default")
DisplayHeader:SetText("Greetings, ")
DisplayHeader:SizeToContents()

local DisplayName = vgui.Create("DLabel", TabThree)
DisplayName:SetPos(65,5)
DisplayName:SetColor( Color( 0, 0, 0, 255 ) )
DisplayName:SetFont("default")
DisplayName:SetText(PlayerName)
DisplayName:SizeToContents()

local DisplayerWarning = vgui.Create("DLabel", TabThree)
DisplayerWarning:SetPos(10,15)
DisplayerWarning:SetColor( Color( 255, 0, 0, 255 ) )
DisplayerWarning:SetFont("default")
DisplayerWarning:SetText("This Gunshop menu is a beta of this gamemode. So you may experience errors while using this.")
DisplayerWarning:SizeToContents()

local MenuButton = vgui.Create("DButton", TabThree)
MenuButton:SetText( "Weapons:" )
MenuButton:SetPos(10, 30)
MenuButton:SetSize( 150, 25 )
MenuButton.DoClick = function ( btn )
local MenuButtonOptions = DermaMenu()
for k,v in pairs(Weapons) do
local ov = string.Explode(":", v)
local nv = string.upper(v)
local nv = string.gsub(nv,"WEAPON","")
local nv = string.gsub(nv,"CS","")
local nv = string.gsub(nv,"_","")
local nv = string.Explode(":", nv)
MenuButtonOptions:AddOption(nv[1]..' - Cost: $'..nv[2], function() 
RunConsoleCommand( "BuyWeaponIndex", ov[1], ov[2], nv[1] )
MainMenuFrame:Close()
end )
MenuButtonOptions:Open()
end
end

-- Please don't touch below, also line breakers

GetGiveMoneyPlayers = vgui.Create("DListView", TabThree )
GetGiveMoneyPlayers:SetPos(273, 75)
GetGiveMoneyPlayers:SetSize(300, 175)
GetGiveMoneyPlayers:SetMultiSelect(false)
GetGiveMoneyPlayers:AddColumn("Name")
GetGiveMoneyPlayers:AddColumn("Points")
for k,v in pairs(player.GetAll()) do
    GetGiveMoneyPlayers:AddLine(v:Nick(),v:GetPData('MyXPPoints'))
end

GiveMoneyBox = vgui.Create( "DTextEntry", TabThree)
GiveMoneyBox:SetPos( 348,50 )
GiveMoneyBox:SetTall( 25 )
GiveMoneyBox:SetWide( 75 )
GiveMoneyBox:SetEnterAllowed( true )
GiveMoneyBox:SetValue(100)

MoneyButton = vgui.Create( "DButton", TabThree )
MoneyButton:SetSize( 72, 25 )
MoneyButton:SetPos( 88, 70 )
MoneyButton:SetPos( 273, 50 )
MoneyButton:SetText( "Give Money" )
MoneyButton.DoClick = function()
MsgN(GetGiveMoneyPlayers:GetLine(GetGiveMoneyPlayers:GetSelectedLine()):GetValue(1))
RunConsoleCommand( "TDMGiveMoney", GetGiveMoneyPlayers:GetLine(GetGiveMoneyPlayers:GetSelectedLine()):GetValue(1), GiveMoneyBox:GetValue() )
end

// End of Weapon Shop


// Start of TabListName
MainMenuSheet:AddSheet( "Team", TabOne, "icon16/group.png", false, false, "Select a team to be on." )
MainMenuSheet:AddSheet( "Weapon Shop", TabThree, "icon16/wand.png", false, false, "Weapon Shop - Beta" )
--MainMenuSheet:AddSheet( "Leaderboards", TabFour, "icon16/vcard.png", false, false, "Server Leaderboards" )
MainMenuSheet:AddSheet( "Config", TabTwo, "icon16/key.png", false, false, "Administrative Configurations" )
// End of TabListName
end
--end

concommand.Add( "tdm_menu", tdm_menu )
usermessage.Hook( "MyMenu", tdm_menu )
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: DListView
« Reply #3 on: May 08, 2014, 12:13:14 am »
Put the code that draws your DListView inside of a function (make sure it's not local).

When a new player joins (using the appropriate hooks clientside) or inside of your button press functions just run that function.

At the top of the function make sure you clear the existing content of the list before adding new stuff to it.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: DListView
« Reply #4 on: May 08, 2014, 11:30:42 am »
Oh man, looking at all of the lines required for creating Derma elements reminded me why I created xlib for XGUI :P Building off what Mr. President said, I'm going to let you know what I did for XGUI. Note that my information may be slightly outdated as I'm going off of what I remember from working on XGUI a couple years back.

Anyways, the design philosophy I chose to stick with for XGUI was to:
1) Create all GUI elements, functions, hooks, etc. once if possible. (can be done when the script is loaded or when it's first opened)
2) Rely on hooks, initialization functions, or serverside calls to populate the data in the menu when ready.
3) Use show/hide functions to handle the visibility of the GUI.

#1 is obvious- Creating the VGUI elements takes up a bit more processing time than you'd think. Back in the day, I believe the spawnmenu used to recreate VGUI controls each time it was opened, which caused a nice tiny freeze each time you opened it. I'm pretty sure it doesn't do that anymore, though. #3 will handle the opening and closing of the VGUI without the need to do anything extra.

So, in a nutshell, the skeleton of your GUI should look something like this:
Code: Lua
  1. local tdm_menu = {}  --Set a table that will store all of your GUI elements in it, so they can be referenced in this whole file. It can be local or not.
  2. local tdm_menu.GAMEMODE_VERSION = "1.0b"
  3.  
  4. function tdm_menu.initialize()
  5.         -- This is where all of your VGUI creation, static functions, etc. go
  6.         -- It should only be called ONCE
  7.         tdm_menu.MainMenuFrame = vgui.Create( "DFrame" )
  8.         tdm_menu.MainMenuFrame:SetSize( 600, 250 )
  9.         tdm_menu.MainMenuFrame:SetTitle("Team Deathmatch Menu: Version "..GAMEMODE_VERSION )
  10.         tdm_menu.MainMenuFrame:Center()
  11.         tdm_menu.MainMenuFrame:ShowCloseButton(false)
  12.         tdm_menu.MainMenuFrame:SetVisible( true )
  13.         tdm_menu.MainMenuFrame:SetDraggable( false )
  14.         tdm_menu.MainMenuFrame:MakePopup()
  15.         function tdm_menu.MainMenuFrame:Paint( w, h )
  16.                 draw.RoundedBox( 0, 0, 0, w, h, Color(team.GetColor(LocalPlayer():Team()).r,team.GetColor(LocalPlayer():Team()).g,team.GetColor(LocalPlayer():Team()).b,50))
  17.                 surface.SetDrawColor(0,0,0)
  18.                 surface.DrawOutlinedRect(1,1,w-1,h-1)
  19.         end
  20.        
  21.         -- (Rest of GUI creation code here)
  22.        
  23.        
  24.         -- Be sure to call any populate functions here, for first-time population. (created and explained below)
  25.         tdm_menu.populatePlayers()
  26.        
  27.        
  28.         -- Since hooks only need to be created once, here's a good place to put them.
  29.         -- I forgot how to hooks, but I think this is right
  30.         hook.Add( "PlayerConnect", "tdm_menu_PlayerConnect", tdm_menu.populatePlayers )
  31.         hook.Add( "PlayerDisconnect", "tdm_menu_PlayerDisconnect", tdm_menu.populatePlayers )
  32.  
  33.         -- Not sure what you had planned with this line, but you can hook it up to a data refresh or toggling the GUI.
  34.         usermessage.Hook( "MyMenu", tdm_menu.toggleMenu )
  35. end
  36.  
  37.  
  38. function tdm_menu.populatePlayers()
  39.         -- This is where all of the code to handle any lists of players will go.
  40.         -- As Mr. President said, since this is tecnically a refresh function, you'll want to clear out any existing lines before adding new ones.
  41.        
  42.         tdm_menu.PlayerTeamList:Clear()
  43.         tdm_menu.GetGiveMoneyPlayers:Clear()
  44.        
  45.         for k,v in pairs(player.GetAll()) do
  46.                 tdm_menu.PlayerTeamList:AddLine(v:Nick(),team.GetName(v:Team()),v:Frags(),v:Deaths())
  47.         end
  48.        
  49.         for k,v in pairs(player.GetAll()) do
  50.                 tdm_menu.GetGiveMoneyPlayers:AddLine(v:Nick(),v:GetPData('MyXPPoints'))
  51.         end
  52. end
  53.  
  54.  
  55. function tdm_menu.toggleMenu()
  56.         -- Check if the menu has been created
  57.         if base.MainMenuFrame == nil then
  58.                 tdm_menu.initialize()
  59.         else
  60.                 -- Show or hide the frame based on if it's visible or not.
  61.                 if tdm_menu.MainMenuFrame:IsVisible() then
  62.                         tdm_menu.MainMenuFrame:hide()
  63.                 else
  64.                         tdm_menu.MainMenuFrame:show()
  65.                 end
  66.         end
  67. end
  68.  
  69. -- Console command to toggle (or initialize) the menu
  70. concommand.Add( "tdm_menu", tdm_menu.toggleMenu )
  71.  
  72. -- Uncomment this line if you want the GUI to initialize when the script is loaded instead of first open.
  73. -- tdm_menu.initialize()

Things to note:
That's entirely untested, I'm sure there are minor syntax errors that should be easy to fix.
In order to properly access all of your GUI elements throughout the file, it is proper to store everything in it's own table.
You can make the tdm_menu global if you want to access it in-game via console, which is useful for debugging.
You'll obviously want to make more functions like poulatePlayers() to update non-player or other data that gets updated from different hooks/triggers.
DermaMenus are always created at the time of clicking on them, so you can keep most of that code in initialize()



... seeing as XGUI is made up all of client ...
Just an FYI, XGUI does have both serverside and clientside code. Here's the general layout for XGUI code:
The base XGUI code can be found in lua/ulx/modules/cl, with xgui_client.lua, xgui_helpers.lua, and xlib.lua.
The base XGUI serverside code is found at lua/ulx/modules/xgui_server.lua.
Individual client-side modules for XGUI are found in lua/ulx/xgui/, except the 'server' folder.
The serverside code for the clientside modules is found in lua/ulx/xgui/server/.

Hope that helps!
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: DListView
« Reply #5 on: May 08, 2014, 11:31:24 pm »
It slightly, worked. Hopefully, I can understand this more later. Though, I ended up changing a few things, and as you said, it was untested, and I wasn't expecting you to give such a great detailed example. Though, server side disliked this code:

Code: [Select]
// Server Side Menu

function ISaid( ply, saywhat )
local name = ply:Nick()
if string.find(saywhat, "!tdm") == 1 then
    umsg.Start( "MyMenu", ply )
umsg.String(ply:Nick())
    umsg.End()
/*
local GetPlayers = player.GetAll()
for k,v in pairs(GetPlayers) do
if v:IsValid() then
local GetScore4File = file.Read("TDM/GoalLimit/GoalLimit.txt")
v:SetPData("TDM_Total_Score_Ok", GetScore4File)
umsg.Start("PlaceScoreForMenu")
umsg.Short(k)
umsg.Short(GetScore4File)
umsg.End()
end
end
*/
end
end
hook.Add( "PlayerSay", "ISaid", ISaid );


function MyMenu( ply )
    umsg.Start( "MyMenu", ply )
umsg.String(ply:Nick())
    umsg.End()
/*
local GetPlayers = player.GetAll()
for k,v in pairs(GetPlayers) do
if v:IsValid() then
local GetScore4File = file.Read("TDM/GoalLimit/GoalLimit.txt")
v:SetPData("TDM_Total_Score_Ok", GetScore4File)
umsg.Start("PlaceScoreForMenu")
umsg.Short(k)
umsg.Short(GetScore4File)
umsg.End()
end
end
*/
end
hook.Add("ShowTeam", "MyHook", MyMenu)


/*
function MyShopMenu( ply )
    umsg.Start( "ShowShopMenuXP", ply )
    umsg.End()
end
hook.Add("ShowHelp", "MyShopMenu", MyShopMenu)
*/


function tdm_help_message( ply )
    umsg.Start( "TDM_HELP_CONSOLE", ply )
    umsg.End()
end
concommand.Add( "tdm_help_message", tdm_help_message )
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: DListView
« Reply #6 on: June 23, 2014, 02:44:37 pm »
Alright, I'm going to have to dig up some old threads. Though, this is important to me now. I've been remaking my gamemode from scratch again, and I created all the commands and such, but now I kinda want to make the menu act like xgui. Basically, what I'm requesting is that when you press F2 (is possible), it opens my menu, and when you press F2 again, it goes away. Can you explain this in the best way you can do Sticky?

I believe the code to do that would be like this
Code: [Select]
hook.Add("ShowTeam", "MyHook", MyMenu)
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: DListView
« Reply #7 on: June 24, 2014, 03:50:03 am »
Alright, so I found out how to do everything.. except update like as in when a player joins it would update the listing. Any suggestions?
« Last Edit: June 24, 2014, 07:33:31 am by chaos13125 »
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: DListView
« Reply #8 on: June 24, 2014, 01:40:20 pm »
How XGUI does the show/hide menu window is just to call :show() and :hide() on the base frame. You can then use isVisible() to check whether or not it's opened and closed.

I can't remember what the hook is for player joins, but the easiest way would be to create a "refresh" function- it would first clear the list of stuff then readd things based on available information. Have the player join and player leave hooks call that refresh button, and it should keep your information up-to-date.
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: DListView
« Reply #9 on: June 27, 2014, 07:01:38 am »
Fantastic, thank you sir. Everything works, I basically followed what you said, I had to jimmy-rig some things here and there, but still works like how I want it to work. Though, now I have two questions.

For a DListView, is it possible to have it select a line, like as in when you open the menu, it already has a selected line selected, via listingID?

Secondly, how does one get a listing of all the current models in the server? Because I'm pretty sure it's possible?
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: DListView
« Reply #10 on: June 27, 2014, 02:06:00 pm »
No problem! ;D

For a DListView, is it possible to have it select a line, like as in when you open the menu, it already has a selected line selected, via listingID?

Not sure what you're asking here exactly- but DListView's do support multiselect, and you can force lines to be selected by using DListView:SelectItem(Panel Line), but you'll need to have a reference to the line object itself (or get it with :GetLine(id)).

Secondly, how does one get a listing of all the current models in the server? Because I'm pretty sure it's possible?

I haven't looked at how Gmod13 handles models- I've only ever needed to get a list of playermodels, which I was able to do using player_manager.AllValidModels().

Hope that helps!
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: DListView
« Reply #11 on: June 27, 2014, 06:20:09 pm »
I'll check out the second thing later, and hopefully get back to you on that. Though, as for the first part, I'm getting this error, and I'm not really sure why.


Code: [Select]
[ERROR] lua/vgui/dlistview.lua:578: attempt to index local 'Item' (a number valu
e)
  1. SelectItem - lua/vgui/dlistview.lua:578
   2. unknown - gamemodes/tdm2/gamemode/menu/cl_menu.lua:1825
    3. unknown - lua/includes/modules/concommand.lua:69
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: DListView
« Reply #12 on: June 30, 2014, 08:20:48 am »
You're passing an integer to list:SelectItem(blah). If you're passing in the index of the line into the function, then you can instead do list:SelectItem(list:GetLine(blah))
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

  • Print