Team Spartan Cookies & Milk Forums
Release GUI Lib - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: Release GUI Lib (/thread-1433.html)



GUI Lib - SuperPlayer - 28-10-2015

Hello everyone,

Welcome to the GUI lib. The gui lib allowes you to create windows. You can move windows arround your whole starfall screen and make them any size you want. The window which was used the last will always be rendered on top of the other windows. This manuel will just cover how the GUI lib works.
The GUI lib has almost every function which is needed to draw on a screen. You need to use the gui function to make it work. The objects you draw on your windows will NOT be drawn over the size of the window. The position coordinates are based on the size of the window they are put on. So a window with size 100x100 will have a coordinates set from 100x100. The red button on the right top on the windows makes them close. To re-enable them or close them through other code instances do:
 GUI.Frames[Window Name].Active = true/false
To move a window press use on the grey bar and then move your mouse. Press use a gain to stop moving the window.
Ok lets start:
Please not that parent should always be 'p' or the name of the window the object should belong to. This is VERY important for the lib to work.
The functions are working like the normal starfall functions.
1.) Creating a window

GUI.createWindow(Name,Shown,X,Y,W,H,Color,function(p)
--Here you put everything which should be drawn on the window.
--Use the function i explained
end)

Name = The name your window should have
Shown is either true or false. It determains whether the window should be drawn or not. Usefull if you want to create some sort of OS.
x and y are the coordinates where your window should appear first
w and h are representing the size of the window
Color is the color the window should have. Ex. Color(120,120,120,200) wil create a window with a grey color where you can look through
In the function you put everything of the following elements.

2.) Making a button
GUI.AddButton(index,x,y,w,h,parent,func)--This wil create a button
index is the name you want to give the button. Dont use a button twice
x and y are the coordinates where your button should be
w and h are representing the size of the button
Parent is the string name of the window the button should belong to
func is the function which you want to call when the button is pressed
The function also passes the player who pressed the button
Example:
GUI.AddButton("Test",5,5,80,30,p,function(Ply)
print("You pressed the button")
end)
3.) Drawing a rectangle
GUI.drawRect(x,y,w,h,Color,parent)--Draws a normal rectangle
x and y are the coordinates where your rectangle should be on the window. Use the window size as orientation. So if your window has the size 100 x 100 you can use the coordinates from 0 to 100 for x and y
w and h are representing the size of the rectangle. Please note that rectangles dont draw beyond the size of the window
Color is the color the button should have.
Parent is the string name of the window the rectangle should belong to

4.) Drawing an outlined rectangle
GUI.drawRectOutline(x,y,w,h,Color,parent)--Draws a outline rectangle
x and y are the coordinates where your rectangle should be on the window. Use the window size as orientation. So if your window has the size 100 x 100 you can use the coordinates from 0 to 100 for x and y
w and h are representing the size of the rectangle. Please note that rectangles dont draw beyond the size of the window
Color is the color the button should have.
Parent is the string name of the window the rectangle should belong to

5.) Drawing a textured rectangle
GUI.drawTexturedRect(x,y,w,h,Color,parent)--Draws a textured rectangle
x and y are the coordinates where your rectangle should be on the window. Use the window size as orientation. So if your window has the size 100 x 100 you can use the coordinates from 0 to 100 for x and y
w and h are representing the size of the rectangle. Please note that rectangles dont draw beyond the size of the window
Color is the color the button should have.
Parent is the string name of the window the rectangle should belong to

6.) Drawing a normal circle
GUI.drawCircle(x,y,rad,Color,parent)--Draws a cricle
x and y are the coordinates where your circle should be on the window. Use the window size as orientation. So if your window has the size 100 x 100 you can use the coordinates from 0 to 100 for x and y
w and h are representing the size of the circle. Please note that circles dont draw beyond the size of the window
Color is the color the button should have.
Parent is the string name of the window the circle should belong to

7.) Drawing a filled circle
GUI.drawFilledCircle(x,y,w,h,Color,parent)--Draws a filled circle
x and y are the coordinates where your circle should be on the window. Use the window size as orientation. So if your window has the size 100 x 100 you can use the coordinates from 0 to 100 for x and y
w and h are representing the size of the circle. Please note that circles dont draw beyond the size of the window
Color is the color the button should have.
Parent is the string name of the window the circle should belong to

8.) Drawing a line
GUI.drawLine(x1,y1,x2,y2,Color,parent)--Draws a line
x1 and y1 are the start coordinates
x2 and y2 are the end coordinates
Color is the color the line should have.
Parent is the string name of the window the line should belong to

9.) Drawing a poly
GUI.drawPoly(Table,Color,parent)
Table is a table of the coordinates your poly should draw
Color is the color the poly should have.
Parent is the string name of the window the poly should belong to
Example :
GUI.drawPoly({{10,30},{40,30},{25,60}},Color(0,100,100,255),"Window 1")

10.) Writing text
GUI.drawText( font, x, y, text, alignment ,parent )
font is the font the should have
x and y are the coordinates
text is the string text
alignment is the alignment used in the normal drawText
Parent is the string name of the window the text should belong to

For a better understanding please look through the code of the GUILib_Example.
Lets hope i didnt forget anything Big Grin
If you have any function request or questions feel free to contact me. You can download the lib here and put the files into : "C:\Program Files (x86)\Steam\SteamApps\common\GarrysMod\garrysmod\data\starfall\lib\gui" ( Every file except for the example) or you can download the gui lib and the example from my shared folder. lib/gui -> download package for the lib and GUILib_Example for the example script. Use
--@require lib/gui/GUILib_Main.txt
to include the lib in your scripts.
I hope you enjoy this lib.



SuperPlayer


RE: GUI Lib - Destiny's Player - 28-10-2015

Welp, welcome to the future, guys, we're here.
Anyway, I remember seeing your windows, and they're pretty darn amazing. Hope that you and other people create some amazing stuff with this stuff.


RE: GUI Lib - TheOneAndOnlyTee - 28-10-2015

Do these functions use parameters like LocInts functions or normal render.drawRect()


RE: GUI Lib - SuperPlayer - 29-10-2015

(28-10-2015, 10:04 PM)Destinys Player Wrote: Welp, welcome to the future, guys, we're here.
Anyway, I remember seeing your windows, and they're pretty darn amazing. Hope that you and other people create some amazing stuff with this stuff.
Actually I am working on a project which is uses the lib. Its still very early but there will probably be something coming sooner or later.Big Grin

T-17 Wrote:Do these functions use parameters like LocInts functions or normal render.drawRect()
They use the normal parameters, just like the standard starfall stuff. I added it also to the discription.


RE: GUI Lib - TheOneAndOnlyTee - 29-10-2015

you forgot to include the Shown parameter in GUI.createWindow() example
EDIT: also what's the Func parameter for GUI.createWindow() do?

EDIT2:

GUI.createWindow("Menu",true,10,40,100,300,Color(51,209,255))
GUI.drawRect(0,0,100,300,Color(30,30,30),"Menu")
GUI.drawRect(0,0,100,20,Blue_1,"Menu")
Using that code i can't seem to see the Close button or Frame and I also can't move it around.
EDIT3:
facepalm, didn't read the example and now i know where i went wrong


RE: GUI Lib - SuperPlayer - 29-10-2015

(29-10-2015, 01:51 AM)T-17 Wrote: you forgot to include the Shown parameter in GUI.createWindow() example
EDIT: also what's the Func parameter for GUI.createWindow() do?
Ahh damn. That was the old code. I am going to adjust the example:


GUI.createWindow(Name,Shown,X,Y,W,H,Color,function(p)
--Here you put everything which should be drawn on the window.
--Use the function i explained
end)



RE: GUI Lib - TheOneAndOnlyTee - 29-10-2015

Noticed that for your close button function that you use 'GUI.Frames[string.sub(i,7,999)]' to determine the frame to close, you can merely use GUI.Frames[string.sub(i,7)] because leaving the 999 out tells string.sub() goto the end of the string.

EDIT: just added a minimise button and change the move window button width to w/2, if you want to see it i'll chuck the changes into a file for you


RE: GUI Lib - SuperPlayer - 29-10-2015

Sure! Maybe i will implement something of it into the lib.