Ulysses

General => Developers Corner => Topic started by: DooBiiE on March 10, 2013, 11:56:13 AM

Title: how do i make the ulx motd open up with tabs?
Post by: DooBiiE on March 10, 2013, 11:56:13 AM
im trying to make my motd have tabs, for rules/forum/etc

Code: [Select]
<html>

local FrameColor = Color(255, 255, 255, 255) --You can set your own frame color, remember to decrease the alpha value.
local ButtonColor = Color(255, 0, 0, 255) --You can set your own button color, remember to decrease the alpha value.

function OpenMOTDMenu()

local MenuFrame = vgui.Create("DFrame")
MenuFrame.OPaint = MenuFrame.Paint
MenuFrame:SetSize(ScrW() * 0.95, ScrH() * 0.95)
MenuFrame:SetPos((ScrW() - MenuFrame:GetWide()) / 2, (ScrH() - MenuFrame:GetTall()) / 2)
MenuFrame:SetTitle("Welcome to " .. GetHostName())
MenuFrame:SetVisible(true)
MenuFrame:SetDraggable(true)
MenuFrame:ShowCloseButton(true)
MenuFrame.Paint = function()
MenuFrame.OPaint(MenuFrame)
surface.SetDrawColor(Color(60, 60, 60, 255))
surface.DrawLine(1, MenuFrame:GetTall() - 27, MenuFrame:GetWide() - 1, MenuFrame:GetTall() - 27)
draw.RoundedBox( 6, 0, 1, MenuFrame:GetWide(), MenuFrame:GetTall() + 1, FrameColor )
end
MenuFrame:MakePopup()

local CloseButton = vgui.Create("DButton", MenuFrame)
CloseButton.OPaint = CloseButton.Paint
CloseButton:SetSize(150, 35)
CloseButton:SetPos(MenuFrame:GetWide() * 0.75, MenuFrame:GetTall() - 27 - CloseButton:GetTall()/2)
CloseButton:SetText("Ok, now let me play!")
CloseButton.Paint = function()
    CloseButton.OPaint(CloseButton)
    surface.SetDrawColor(ButtonColor)
    surface.DrawRect(1, 1, CloseButton:GetWide() - 2, CloseButton:GetTall() - 2)
end
CloseButton.DoClick = function(button)
MenuFrame:Close()
end

local MenuPSheet = vgui.Create("DPropertySheet", MenuFrame)
MenuPSheet:SetPos(13, 30)
MenuPSheet:SetSize(MenuFrame:GetWide() - 25, MenuFrame:GetTall() - 84)

local MOTD = vgui.Create( "HTML", MenuFrame )
MOTD:SetPos( 25, 50 )
MOTD:SetSize( 250, 250 )
--MOTD:SetHTML([[]]) --use this for custom html code
MOTD:OpenURL("http://steamcommunity.com/groups/JustAwesomeGaming") -- JustAwesomeGaming steam group/

local Rules = vgui.Create( "HTML", MenuFrame )
Rules:SetPos( 25, 50 )
Rules:SetSize( 250, 250 )
--Rules:SetHTML([[]]) --use this for custom html code
Rules:OpenURL("") -- or this if you want to open an URL, remember that you must pick only one

local AdminList = vgui.Create( "HTML", MenuFrame )
AdminList:SetPos( 25, 50 )
AdminList:SetSize( 250, 250 )
--AdminList:SetHTML([[]]) --use this for custom html code
AdminList:OpenURL("") -- or this if you want to open an URL, remember that you must pick only one

local GroupPage = vgui.Create("HTML")
GroupPage:SetParent(MenuPSheet)
GroupPage:SetPos( 25, 50 )
GroupPage:SetSize( 250, 250 )
--GroupPage:SetHTML([[]]) --use this for custom html code
GroupPage:OpenURL("http://steamcommunity.com/groups/JustAwesomeGaming") -- or this if you want to open an URL, remember that you must pick only one

local Forums = vgui.Create( "HTML", MenuFrame )
TabName:SetPos( 25, 50 )
TabName:SetSize( 250, 250 )
--TabName:SetHTML([[]]) --use this for custom html code
TabName:OpenURL(http://www.jagaming.co.uk/") -- or this if you want to open an URL, remember that you must pick only one

local Donations = vgui.Create( "HTML", MenuFrame )
TabName:SetPos( 25, 50 )
TabName:SetSize( 250, 250 )
--TabName:SetHTML([[]]) --use this for custom html code
TabName:OpenURL("") -- or this if you want to open an URL, remember that you must pick only one

--You can add your own tabs down here
/*EXAMPLE:
local TabName = vgui.Create( "HTML", MenuFrame )
TabName:SetPos( 25, 50 )
TabName:SetSize( 250, 250 )
--TabName:SetHTML([[]]) --use this for custom html code
--TabName:OpenURL("") -- or this if you want to open an URL, remember that you must pick only one
*/

--You can chane the popup order here, or add your own tab!

local order = {}
order[1] = {"Group Page", GroupPage, "gui/silkicons/group", false, false, "Group page here"}
order[2] = {"Rules", Rules, "gui/silkicons/exclamation", false, false, "Rules are listed here"}
order[3] = {"MOTD", MOTD, "gui/silkicons/page", false, false, "Message of the day"}
order[4] = {"Admin List", AdminList, "gui/silkicons/shield", false, false, "Admins are listed here"}
--order[5] = {"A name", TabName, "gui/silkicons/page", false, false, "A description"}

for _, tab in pairs(order) do
MenuPSheet:AddSheet(unpack(tab))
end

end

concommand.Add("showmotdmenu", OpenMOTDMenu)

</html>
 

this is my code, when the motd loads it just loads as is, i was wondering how to make it display as a tabbed motd?
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Marshy on May 20, 2013, 02:24:43 AM
bump
would also like info on this please :)
Title: Re: how do i make the ulx motd open up with tabs?
Post by: MrPresident on May 20, 2013, 07:11:39 AM
This isn't something ULX can do. You can, however, modify the MOTD panel yourself if you are so inclined.

Here is the control element to created a tabbed panel.

http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb285.html

It's a fairly simple process. You would just create tabbed panels as the example in the wiki shows and then parent an HTML frame to each of the individual panels.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Marshy on May 20, 2013, 08:04:02 AM
oh so it's just a normal dpanel sweet

thanks for this

leon.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: MrPresident on May 20, 2013, 08:10:25 AM
Sure thing, it's fairly easy to do. If you can't figure it out, let me know how many tabs you want and I can throw something together for you when I have a moment.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Vilusia on May 21, 2013, 08:36:26 AM
Hey would it be possible if you could make one with 3 tabs?
I tried doing it myself but I'm new to lua and I'm still learning. Derma is not my strong point :P
Thanks.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: MrPresident on May 21, 2013, 09:35:31 AM
Sure, give me time, I'm at work right now. What do you want the 3 tabs to be? What URLs do you want them to point to?
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Vilusia on May 21, 2013, 01:34:14 PM
Forum
www.vnbgameservers.net
Donate
http://www.vnbgameservers.net/misc.php?action=payments
Rules
http://www.vnbgameservers.net/thread-58.html

Thanks for doing this. I will study your code so I can better myself in the future. :)
Title: Re: how do i make the ulx motd open up with tabs?
Post by: MrPresident on May 21, 2013, 05:50:12 PM
Make sure your ULX and ULib are up to date with the most recent SVN and then replace this file:

replace all the code in this file with
addons/ULX/lua/ulx/modules/cl/motdmenu.lua

Code: [Select]
ulx.motdmenu_exists = true

local isUrl
local url

function ulx.showMotdMenu()
local url1 = "www.vnbgameservers.net"
local url2 = "http://www.vnbgameservers.net/misc.php?action=payments"
local url3 = "http://www.vnbgameservers.net/thread-58.html"

local window = vgui.Create( "DFrame" )
if ScrW() > 640 then -- Make it larger if we can.
window:SetSize( ScrW()*0.9, ScrH()*0.9 )
else
window:SetSize( 640, 480 )
end
window:Center()
window:SetTitle( "ULX MOTD" )
window:SetVisible( true )
window:MakePopup()

local tabmenu = vgui.Create( "DPropertySheet", window )


local html1 = vgui.Create( "HTML" )
local html2 = vgui.Create( "HTML" )
local html3 = vgui.Create( "HTML" )

local button = vgui.Create( "DButton", window )
button:SetText( "Close" )
button.DoClick = function() window:Close() end
button:SetSize( 100, 40 )
button:SetPos( (window:GetWide() - button:GetWide()) / 2, window:GetTall() - button:GetTall() - 10 )

tabmenu:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
tabmenu:SetPos( 10, 30 )

html1:SetSize( window:GetWide() - 30, window:GetTall() - button:GetTall() - 70 )
html1:SetPos( 15, 50 )
html1:OpenURL( url1 )

html2:SetSize( window:GetWide() - 30, window:GetTall() - button:GetTall() - 70 )
html2:SetPos( 15, 50 )
html2:OpenURL( url2 )

html3:SetSize( window:GetWide() - 30, window:GetTall() - button:GetTall() - 70 )
html3:SetPos( 15, 50 )
html3:OpenURL( url3 )

tabmenu:AddSheet( "Forum", html1, _, false, false, _)
tabmenu:AddSheet( "Donate", html2, _, false, false, _)
tabmenu:AddSheet( "Rules", html3, _, false, false, _)
end

function ulx.rcvMotd( isUrl_, text )
isUrl = isUrl_
if not isUrl then
ULib.fileWrite( "data/ulx_motd.txt", text )
else
if text:find( "://", 1, true ) then
url = text
else
url = "http://" .. text
end
end
end
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Vilusia on May 21, 2013, 06:02:56 PM
Thanks so much! You are amazing!
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Marshy on May 22, 2013, 07:24:29 AM
awesome work mr president

ho could i add fma fam fam icon on the tabs?
Title: Re: how do i make the ulx motd open up with tabs?
Post by: MrPresident on May 22, 2013, 07:44:13 AM
Take a look at the link I posted a couple of posts up. There is a field in the :AddSheet function where you can assign a silkicon. I left it null, but you can add them if you want.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Marshy on May 22, 2013, 12:10:00 PM
heya sorry to be a pain but ive looked at the dpanel wiki and cant make sence :/

help?

thanks in advanced,
Leon.






Title: Re: how do i make the ulx motd open up with tabs?
Post by: JamminR on May 22, 2013, 01:59:32 PM
heya sorry to be a pain but ive looked at the dpanel wiki and cant make sence :/

help?

thanks in advanced,
Leon.
You're hijacking someone elses thread that quite reasonably had questions answered....'what' are you wanting 'help' with.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: MrPresident on May 22, 2013, 04:50:13 PM
I think he was referring to his post before my last one asking how to add the silkicons to the tabs. Did you even look at the wiki article for the DPropertySheet:AddSheet() (http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexa201-2.html)

It's fairly self explanatory.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Marshy on May 22, 2013, 05:35:58 PM
yeh i did check it out but at first it went over my head but i have the hang of it now thanks anyway.

Regards,
leon.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: JamminR on May 22, 2013, 07:50:03 PM
Oh. Yes.
What MrP said.
If you can't see it by looking, you might not be ready for doing a project such as this.
I've never done derma, it terrifies me, but I can quite easily tell it's the 3rd parameter in the derma property MrP references.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Jihad on June 09, 2013, 12:41:43 PM
Hi! How do I change the color of the frame and button?
Thanks
Jihad
Title: Re: how do i make the ulx motd open up with tabs?
Post by: JamminR on June 09, 2013, 01:53:38 PM
Hi! How do I change the color of the frame and button?
Thanks
Jihad

When looking over the example code in this post, is it not obvious the code dealing with color?

http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb9b1.html
Experiment within the code. there are several times it's used, both for the main panels, and the buttons.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Jihad on June 10, 2013, 01:35:49 AM
When looking over the example code in this post, is it not obvious the code dealing with color?

http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb9b1.html
Experiment within the code. there are several times it's used, both for the main panels, and the buttons.
That link is broken
Jihad
Title: Re: how do i make the ulx motd open up with tabs?
Post by: MrPresident on June 10, 2013, 08:04:05 AM
no it's not. Try again. sometimes the wiki backup on maurtis has issues.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Jihad on June 10, 2013, 09:02:11 AM
no it's not. Try again. sometimes the wiki backup on maurtis has issues.

Ok, but I'm kinda a newbie to coding. I know some stuff, but not alot. Is this ok?
Code: [Select]
surface.SetDrawColor(0,0,205)
Thanks
Jihad
Title: Re: how do i make the ulx motd open up with tabs?
Post by: freepox on September 28, 2013, 03:45:31 PM
Can we get a up-to-date version of this?  :P
Im trying to get a mutiple-tapped MOTD for my server, but the code does not seem to work.
Here's my error:

[ERROR] addons/ulx/lua/ulx/modules/cl/motdmenu.lua:58: attempt to call field 'fileWrite' (a nil value)
1. fn - addons/ulx/lua/ulx/modules/cl/motdmenu.lua:58
2. func - addons/ulib/lua/ulib/client/cl_util.lua:22
3. unknown - lua/includes/modules/net.lua:31
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Megiddo on September 28, 2013, 04:43:10 PM
It would seem you're not using the latest version of ULib, freepox. :P
Title: Re: how do i make the ulx motd open up with tabs?
Post by: freepox on September 28, 2013, 04:49:15 PM
It would seem you're not using the latest version of ULib, freepox. :P
Probably not. Its not my fault that the CP my host provide, doesnt have the latest versions then ^^ Is there a fix for this?
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Megiddo on September 28, 2013, 05:35:10 PM
The fix is using the latest version.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: JamminR on September 28, 2013, 07:00:34 PM
If your host won't get it for you, determine how to upload yourself.
Most hosts allow sFTP, or file transfer using some CP.
Title: Re: how do i make the ulx motd open up with tabs?
Post by: freepox on September 29, 2013, 12:59:46 AM
Yeah, i did that, and it works! Thanks!
Title: Re: how do i make the ulx motd open up with tabs?
Post by: Eccid on September 30, 2013, 08:21:31 AM
For anyone else wanting to do this, I use this guide (http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe102.html) whenever I'm messing with derma. It covers most things and was really helpful, and allowed me to add more tabs to my motd, as well as work with derma for other scripts.