Adding buttons to GUI

How to I add buttons to GUI

I’m using Eclipse The Final Frontier and it dont have the friends/quest buttons

How I can Add?

Thanks!

In modGraphics under Sub DrawGUI find


' render menu

'If GUIWindow(GUI_MENU).Visible Then DrawMenu

Uncomment the If-Then Statement.

I want to create more buttons

I want to create the friends, quests, and skills buttons

For when you click each button, window appears them

Well that requires a programmer to render the new buttons and add hover/click/normal button functionalities.

How do I do that?

Can u tell me how do I do that?

Try searching for “buttons” in VB6 and seeing how they’re done. You can mimic the code for new buttons.

I’ve tried to do this

But when you open the game

Appears error 9 Subscript out of range

You can copy off of another Draw event such as the DrawMenu sub. I believe that’s where the buttons are drawn. In Sub InitialiseGUI you need to add more button values at the bottom of the sub. Use the ones there as a reference. You’ll have to add new button arrays. To do that search for MAX_BUTTONS and make sure it’s equal to the same amount you used in InitialiseGUI. Ummm. New click events will be needed in HandleMouseDown and HandleMouseUp.

This is just a quick jit of what you’ll have to do.

See if it’s right

I click in the button and the friends list dont appear

In Sub DrawMenu I put:


' little friend button

	 I = 56

If Buttons(I).Visible Then

	 ' set co-ordinate

	 x = GUIWindow(GUI_MENU).x + Buttons(I).x

	 y = GUIWindow(GUI_MENU).y + Buttons(I).y

	 Width = Buttons(I).Width

	 Height = Buttons(I).Height

	 ' check for state

	 If Buttons(I).state = 2 Then

		 ' we're clicked boyo

		 'EngineRenderRectangle Tex_Buttons_c(Buttons(i).PicNum), x, y, 0, 0, width, height, width, height, width, height

		 RenderTexture Tex_Buttons_c(Buttons(I).PicNum), x, y, 0, 0, Width, Height, Width, Height

	 ElseIf (GlobalX >= x And GlobalX <= x + Buttons(I).Width) And (GlobalY >= y And GlobalY <= y + Buttons(I).Height) Then

		 ' we're hoverin'

		 'EngineRenderRectangle Tex_Buttons_h(Buttons(i).PicNum), x, y, 0, 0, width, height, width, height, width, height

		 RenderTexture Tex_Buttons_h(Buttons(I).PicNum), x, y, 0, 0, Width, Height, Width, Height

		 ' play sound if needed

		 If Not lastButtonSound = I Then

			 PlaySound Sound_ButtonHover, -1, -1

			 lastButtonSound = I

		 End If

	 Else

		 ' we're normal

		 'EngineRenderRectangle Tex_Buttons(Buttons(i).PicNum), x, y, 0, 0, width, height, width, height, width, height

		 RenderTexture Tex_Buttons(Buttons(I).PicNum), x, y, 0, 0, Width, Height, Width, Height

		 ' reset sound if needed

	 If lastButtonSound = I Then lastButtonSound = 0

	 End If

End If

And in Sub initialisegui


	 ' main - little friend

With Buttons(56)

	 .state = 0 ' normal

	 .x = 30

	 .y = 5

	 .Width = 69

	 .Height = 29

	 .Visible = True

	 .PicNum = 27

End With

In MAX_BUTTONS


Public Const MAX_BUTTONS As Long = 56

In HandleMouseUp


                     Case GUI_FRIENDS

                         Buddies_MouseUp

						 mouseClicked = False

In HandleMouseDown


                     Case GUI_FRIENDS

                         Buddies_MouseDown

						 mouseState = GUI_FRIENDS

						 If Button = vbRightButton Then mouseClicked = True

What’s wrong?

You’re almost there! :D

What you’ve added into HandleMouseUp and Down are to add mouse functionality within GUI_FRIENDS, not to bring it up. You’ll probably want to to include this, but for now one thing at a time! Because the buttons will be in GUI_MAIN which already had mouse support, you didn’t have to add anything here to make the friends button.

Look under subs Menu_MouseDown and Menu_MouseUp.

Well it doesn’t go under GUI_FRIENDS.

That I know for sure.

!EDIT

I dont know why

But, the Guild button open the quest menu now… Why?

The button dont work… :(

Ok I put in Menu_MouseUp


' friend button

I = 56

x = GUIWindow(GUI_MENU).x + Buttons(I).x

y = GUIWindow(GUI_MENU).y + Buttons(I).y

' check if we're on the button

If (GlobalX >= x And GlobalX <= x + Buttons(I).Width) And (GlobalY >= y And GlobalY <= y + Buttons(I).Height) Then

	 If Buttons(I).state = 2 Then

		 ' do stuffs

OpenGuiWindow 8

		 ' play sound

		 PlaySound Sound_Buttonclick, -1, -1

	 End If

End If

And in Menu_MouseDown


	 ' friends button

I = 56

If Buttons(I).Visible Then

	 x = GUIWindow(GUI_MENU).x + Buttons(I).x

	 y = GUIWindow(GUI_MENU).y + Buttons(I).y

	 ' check if we're on the button

	 If (GlobalX >= x And GlobalX <= x + Buttons(I).Width) And (GlobalY >= y And GlobalY <= y + Buttons(I).Height) Then

		 Buttons(I).state = 2 ' clicked

	 End If

End If

You click it and the quest log opens? Great! You should feel pretty good about getting all that done.

I think you’re done once you fix one tiny little number. In Mouse_MenuDown you’ve got:

If Buttons(I).state = 2 Then

'do stuffs

OpenGuiWindow 8

GuiWindow 8 is the quest log. You want OpenGuiWindow 10. Check out Sub OpenGuiWindow for further clarification on the arrays for OpenGuiwindow.

OMG OMG OMG OMG

Thanks Zeno and escfoe2

This works!

Thank you so much!

Resolved!

Log in to reply