Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 10 11 12 13 14 … 18 Next »
Release GUI Lib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Mode
Release GUI Lib
28-10-2015, 09:40 PM, (This post was last modified: 29-10-2015, 02:06 AM by SuperPlayer.)
#1
SuperPlayer Offline
TSCM Super Member
****
Posts: 234
Threads: 30
Joined: Oct 2014
GUI Lib
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


Attached Files
.txt   GUILib_Main.txt (Size: 3.36 KB / Downloads: 5)
.txt   GUILib_Objects.txt (Size: 7.61 KB / Downloads: 2)
.txt   GUILib_Manuel.txt (Size: 5.96 KB / Downloads: 2)
.txt   GUILib_Example.txt (Size: 1.42 KB / Downloads: 2)
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
GUI Lib - by SuperPlayer - 28-10-2015, 09:40 PM
RE: GUI Lib - by Destiny's Player - 28-10-2015, 10:04 PM
RE: GUI Lib - by SuperPlayer - 29-10-2015, 12:38 AM
RE: GUI Lib - by TheOneAndOnlyTee - 28-10-2015, 11:52 PM
RE: GUI Lib - by TheOneAndOnlyTee - 29-10-2015, 01:51 AM
RE: GUI Lib - by SuperPlayer - 29-10-2015, 02:04 AM
RE: GUI Lib - by TheOneAndOnlyTee - 29-10-2015, 02:30 AM
RE: GUI Lib - by SuperPlayer - 29-10-2015, 06:47 PM

  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.