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

Adding buttons to GUI


vulcano
 Share

Recommended Posts

I want to create more buttons

![](http://www.freemmorpgmaker.com/uploadfiles/1f372fe337e0b0db62213e6468f80ad0.png)

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

For when you click each button, window appears them
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

You're almost there! ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)

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.
Link to comment
Share on other sites

!EDIT

I dont know why

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

The button dont work... ![:(](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/sad.png)

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

```
Link to comment
Share on other sites

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.
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...