GalacticGlum Posted May 16, 2015 Author Share Posted May 16, 2015 Hello Eclipse!I'm Hackertatio and this is my first tutorial! This tutorial will teach you how to add a extra button in the ingame menu. This tutorial is for Eclipse Final Frontier but can be adapted to EO 3 and so fourth with a couple changes.If you have any questions, concerns, suggestions/information feel free to reply to this topic or PM me.I ask for one thing only if you use this tutorial a credit to me (credit Hackertatio).Let's begin! Shall we…**_We are only editing client side! _** In this tutorial the button I will be making is a friend button but can be adapted to another type of button by changing the "OpenGuiWindow #" to the specific window and by changing the button graphic to match your button (i.e shop button, etc..) It will look like this when finished (the button graphic will be different). The button graphics is not included but a button template is :)![](http://i60.tinypic.com/29krt6w.png)In modConstants find```Public Const MAX_BUTTONS As Long = 64```and change it to```Public Const MAX_BUTTONS As Long = 65```Next go to Menu_MouseUp located in modInput and find```' guild button I = 42 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 7 PlaySound Sound_ButtonClick, -1, -1 ' play sound PlaySound Sound_ButtonClick, -1, -1 End If```under it insert this```' friend buttonI = 65x = GUIWindow(GUI_MENU).x + Buttons(I).xy = GUIWindow(GUI_MENU).y + Buttons(I).y' check if we're on the buttonIf (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 stuffsOpenGuiWindow 10 ' play sound PlaySound Sound_ButtonClick, -1, -1 End IfEnd If```Next go to Menu_MouseDown located in modInput and find```' guild button I = 42 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```under it insert this```' friends buttonI = 65If 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 IfEnd If```Next go to Sub DrawMenu located in modGraphics and find ```' draw buttons For I = 1 To 6 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 Next I```under it insert this```' draw friend button I = 65 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 IfEnd If```Next go to Sub InitialiseGUI in modGeneral and under ```' main - gui buttons button With Buttons(64) .state = 0 ' normal .x = 25 '20 .y = 78 '73 .Width = 18 .Height = 18 .Visible = True .PicNum = 33 End With```insert this```' main - friend button With Buttons(65) .state = 0 ' normal .x = 231 .y = 41 .Width = 69 .Height = 29 .Visible = True .PicNum = 36 End With```**GREAT! You are done the code aspect.**Now you have to make the button graphic and put it in your **data files\graphics\gui\buttons** folder**The button picture number is "36".**Click [here](https://www.dropbox.com/s/nsbqcnjuj2bwv7a/button_temp.zip?dl=0) to download the button template.GREAT!!!! You are now fully done. Run your game and see if it works!How to change what the buttons opens?To change the button so it opens something else you have to change the "OpenGuiWindow 10" line to the specific OpenGuiWindow in the "Menu_MouseUp" and "Menu_MouseDown" code you inserted before. Check out Sub OpenGuiWindow for further clarification on the arrays for OpenGuiwindow. Optionally you can change the buttons graphic.Button template download[https://www.dropbox.com/s/nsbqcnjuj2bwv7a/button_temp.zip?dl=0](https://www.dropbox.com/s/nsbqcnjuj2bwv7a/button_temp.zip?dl=0)Thank you for reading!**If you have any questions, concerns, suggestions/information feel free to reply to this topic or PM me.**Cheers,Hackertatio, Link to comment Share on other sites More sharing options...
Tic Tac 2 Posted May 16, 2015 Share Posted May 16, 2015 I did this a long time ago, but new people having trouble with this should find this helpful :-)[http://i.snag.gy/k1ZLK.jpg](http://i.snag.gy/k1ZLK.jpg) Link to comment Share on other sites More sharing options...
GalacticGlum Posted May 16, 2015 Author Share Posted May 16, 2015 @[member="lurv"] Thank you! Link to comment Share on other sites More sharing options...
abhi2011 Posted May 16, 2015 Share Posted May 16, 2015 In the beginning, you say to change _MAX_BUTTONS _from 65 to 66\. But in the rest of the tutorial, you never use the index 66 for _Buttons_, you only use 65. i.e there is no, _With Buttons(66)_ anyone where to declare the 66th button.```' main - friend button With Buttons(65) .state = 0 ' normal .x = 231 .y = 41 .Width = 69 .Height = 29 .Visible = True .PicNum = 36 End With``` Link to comment Share on other sites More sharing options...
GalacticGlum Posted May 16, 2015 Author Share Posted May 16, 2015 @[member="Abhi"]Oh so sorry I made it 66 since I needed 66 buttons I'm gonna change that really quick.EDIT: Changed it Link to comment Share on other sites More sharing options...
GalacticGlum Posted May 23, 2015 Author Share Posted May 23, 2015 I just updated a small thing in the post. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now