Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[REQUEST FOR TUT] GUI


Nexious
 Share

Recommended Posts

That's an easy to understand part of the code. A more complicated part is

' Shop
GUI(GUI_SHOP).X = (frmMain.ScaleWidth - GUI(GUI_SHOP).Width) * 0.5
GUI(GUI_SHOP).Y = (frmMain.ScaleHeight - GUI(GUI_SHOP).Height) * 0.5

This code will place the shop menu in the center of the screen. It gets the form size and the menu and centers them ( X/2 - Y/2 = c[X - Y] / 2 which will center)

***

' Options
GUI(GUI_OPTIONS).X = frmMain.ScaleWidth - 232
GUI(GUI_OPTIONS).Y = frmMain.ScaleHeight - GUI(GUI_OPTIONS).Height - (frmMain.ScaleHeight -
BTN(1).Y + btnOffset)

This code will make sure the option menu is always in the lower right corner of the screen. 232 is the option menu width and offset from the side of the screen.

BTN(1).Y is in that code to keep your menus above your buttons so that you don't have a menu blocking you from clicking a button). The offset is to keep the menus slightly above your buttons.

***

Thanks to deminizer for asking me to explain these to him in chat, showed me I should explain them instead of saying where to look :)
Link to comment
Share on other sites

No problem :)

To change the button locations

' Loop through the locations
For i = btnCount To 1 Step -1 ' Rows are done in order, columns are reversed: enum order is right to left and top to bottom
If i = btnCount Then
BTN(btnEnabled(i)).X = frmMain.ScaleWidth - BTN(btnEnabled(i)).Width - btnOffset
Else
If btnCount - i <= (btnCount / rows) * (tempRows + 1) Then
BTN(btnEnabled(i)).X = BTN(btnEnabled(i + 1)).X - BTN(btnEnabled(i)).Width - btnOffset
Else
BTN(btnEnabled(i)).X = frmMain.ScaleWidth - BTN(btnEnabled(i)).Width - btnOffset
tempRows = tempRows + 1
End If
End If

BTN(btnEnabled(i)).Y = frmMain.ScaleHeight - BTN(btnEnabled(i)).Height - btnOffset - ((tempRows) * (BTN(btnEnabled(i)).Height + btnOffset))
Next


This sub is in GUILoction as well. This will align the buttons to the lower right corner. The button sizes can be changed, but I suggest making them all similar heights (they use the current button height when placing the rows/assigning heights).
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...