HomePortalFAQSearchMemberlistUsergroupsRegisterLog in
The domain www.kitopen.com will expire on 2018-08-17. Update your bookmarks to point at http://kito.forumotion.com/
Meet the new KITO admins & hear their plans here.
You can use google search to find threads and posts here now. Example

Share | 
 

 Creating menu Button

Go down 
AuthorMessage
dev_begin

avatar

Game username : devr
Male Posts : 7
Join date : 2018-03-27
Location : Russia

PostSubject: Creating menu Button   Tue Mar 27, 2018 8:09 pm

Hi everyone. I'm new here and new to OOP at all. I'm using KITO 6.0 source and want to add a new button to main menu. I can see "New game", "Multiplayer" and "Quit".
I added my button to enums, placed it on the StartScreen, declared showmybuttonOverlay void and then I declared a button action for it.
Code:
void MagixGUI::showInfoScreenOverlay(bool flag)
{
   if (flag)
   {
      OverlayManager::getSingleton().getByName("GUIOverlay/InfoScreen")->show();
      mBox[GUI_INFO]->show();
   }
So, my question is about mBox[GUI_INFO]->show();
I saw setTop and setHeight parameters for other Boxes and idk how to use and if it is nesessary at all.
And how to place "go back" button on screen opened by pressing my button
Back to top Go down
Hyper
Admin
avatar

Game username : Hyper
Server : Azoptaos
Male Posts : 560
Join date : 2014-02-09
Age : 20

PostSubject: Re: Creating menu Button   Wed Mar 28, 2018 2:39 am

are you just making a button, or an entire box? if its just a button, you should add it to the start screen overlay where the other buttons are defined, and you should be using mButton not mBox. you dont need a new function if its just a single button, cause if you place it in the GUIOverlay/StartScreen then itll hide it automatically with the rest of them

setTop and setHeight set the placement and size of the button. if you did all that in the gui.overlay then you dont need to worry about using them

________________________________
i can code you things
Back to top Go down
http://azoptaos.boards.net/
dev_begin

avatar

Game username : devr
Male Posts : 7
Join date : 2018-03-27
Location : Russia

PostSubject: Re: Creating menu Button   Wed Mar 28, 2018 7:28 am

Hyper wrote:
are you just making a button, or an entire box? if its just a button, you should add it to the start screen overlay where the other buttons are defined, and you should be using mButton not mBox. you dont need a new function if its just a single button, cause if you place it in the GUIOverlay/StartScreen then itll hide it automatically with the rest of them

setTop and setHeight set the placement and size of the button. if you did all that in the gui.overlay then you dont need to worry about using them
I want to add "About" button, just information about the project.
So, I added buttons to the ss gui:
Code:
//StartScreenGUI
   mBox[GUI_STARTSCREENBOX] = OverlayManager::getSingleton().getOverlayElement("GUI/StartScreenBox");
   mButton[BUTTON_NEWGAME] = OverlayManager::getSingleton().getOverlayElement("GUI/StartScreenButton1");
   mButtonText[BUTTON_NEWGAME] = OverlayManager::getSingleton().getOverlayElement("GUI/StartScreenButtonText1");
   mButton[BUTTON_MULTIPLAYER] = OverlayManager::getSingleton().getOverlayElement("GUI/StartScreenButton2");
   mButtonText[BUTTON_MULTIPLAYER] = OverlayManager::getSingleton().getOverlayElement("GUI/StartScreenButtonText2");
   //MyCode
   mButton[BUTTON_INFO] = OverlayManager::getSingleton().getOverlayElement("GUI/StartScreenInfoButton");
   mButtonText[BUTTON_INFO] = OverlayManager::getSingleton().getOverlayElement("GUI/StartScreenInfoButtonText");
   mButton[BUTTON_QUIT] = OverlayManager::getSingleton().getOverlayElement("GUI/StartScreenButton3");
   mButtonText[BUTTON_QUIT] = OverlayManager::getSingleton().getOverlayElement("GUI/StartScreenButtonText3");
Then I created similar void for my button, like for optionsOverlay, for example:
Code:
void MagixGUI::showInfoScreenOverlay(bool flag)
{
   if (flag)
   {
      OverlayManager::getSingleton().getByName("GUIOverlay/InfoScreen")->show();
      mBox[GUI_INFO]->show();
   }
   else
   {
      OverlayManager::getSingleton().getByName("GUIOverlay/InfoScreen")->hide();
      mBox[GUI_INFO]->hide();
   }
}
Button action:
Code:
   if (mHoverButton == mButton[BUTTON_INFO])
         {
            showServerOverlay(false);
            showOptionsOverlay(false);
            showInfoScreenOverlay(true);
            return;
         }
That's it. What should I add or remove?
Back to top Go down
Hyper
Admin
avatar

Game username : Hyper
Server : Azoptaos
Male Posts : 560
Join date : 2014-02-09
Age : 20

PostSubject: Re: Creating menu Button   Wed Mar 28, 2018 10:52 am

oh, i got you. you did add everything to the gui.overlay, right? youll need to make a new overlay for your info screen and add the About button to the startscreen overlay

________________________________
i can code you things
Back to top Go down
http://azoptaos.boards.net/
dev_begin

avatar

Game username : devr
Male Posts : 7
Join date : 2018-03-27
Location : Russia

PostSubject: Re: Creating menu Button   Wed Mar 28, 2018 8:01 pm

Hyper wrote:
oh, i got you. you did add everything to the gui.overlay, right? youll need to make a new overlay for your info screen and add the About button to the startscreen overlay
Here is everything I've added to gui.overlay:
Code:
container Panel(GUI/StartScreenInfoButton) : GUITemplate/BasicButton
{
left 0.51
top 0.90
width 0.16
height 0.04

element TextArea(GUI/StartScreenInfoButtonText) : GUITemplate/CenteredText
{
caption Info
}
}
Info screen overlay:

So, game crashes when I press my button. What's wrong?
UPD: is using of mBox in my previous post ok?
Back to top Go down
Hyper
Admin
avatar

Game username : Hyper
Server : Azoptaos
Male Posts : 560
Join date : 2014-02-09
Age : 20

PostSubject: Re: Creating menu Button   Thu Mar 29, 2018 2:58 am

did you define mBox and its components? as in, add the mBox[GUI_INFO] = (gui overlay here) like how you did wiht your button

mBox is fine since youre creating a whole new overlay, you just need to make sure its actually defined

________________________________
i can code you things
Back to top Go down
http://azoptaos.boards.net/
dev_begin

avatar

Game username : devr
Male Posts : 7
Join date : 2018-03-27
Location : Russia

PostSubject: Re: Creating menu Button   Thu Mar 29, 2018 6:20 am

Hyper wrote:
did you define mBox and its components? as in, add the mBox[GUI_INFO] = (gui overlay here) like how you did wiht your button

mBox is fine since youre creating a whole new overlay, you just need to make sure its actually defined
ohhh. This is what i haven't done yet. Can you tell me if it is nesessary for my idea? I mean I nedd button, which opens window with info about my server. Should I really use mBox with overlay for it or there is easier way?
Back to top Go down
Hyper
Admin
avatar

Game username : Hyper
Server : Azoptaos
Male Posts : 560
Join date : 2014-02-09
Age : 20

PostSubject: Re: Creating menu Button   Thu Mar 29, 2018 7:22 am

it depends on what exactly youre trying to bring up. if you want a box to pop up similar to the item/stash/bio etc boxes ingame, then yeah, making the new overlay is probably ideal. it just keeps everything cleaner and easier to manage

________________________________
i can code you things
Back to top Go down
http://azoptaos.boards.net/
dev_begin

avatar

Game username : devr
Male Posts : 7
Join date : 2018-03-27
Location : Russia

PostSubject: Re: Creating menu Button   Thu Mar 29, 2018 9:33 am

Hyper wrote:
it depends on what exactly youre trying to bring up. if you want a box to pop up similar to the item/stash/bio etc boxes ingame, then yeah, making the new overlay is probably ideal. it just keeps everything cleaner and easier to manage
So, I want to see the window like this:
But my code gives me this(buttons dont work):

So, how can I re-code it?
Back to top Go down
Hyper
Admin
avatar

Game username : Hyper
Server : Azoptaos
Male Posts : 560
Join date : 2014-02-09
Age : 20

PostSubject: Re: Creating menu Button   Thu Mar 29, 2018 10:37 am

the buttons only work if you code them to do something. if you want it centered, you just have to play around with its top/left settings in the overlay. if you want it to look like the campaign screen, i suggest looking at how the campaign overlay is coded and work from there

________________________________
i can code you things
Back to top Go down
http://azoptaos.boards.net/
dev_begin

avatar

Game username : devr
Male Posts : 7
Join date : 2018-03-27
Location : Russia

PostSubject: Re: Creating menu Button   Thu Mar 29, 2018 8:07 pm

Hyper wrote:
the buttons only work if you code them to do something. if you want it centered, you just have to play around with its top/left settings in the overlay. if you want it to look like the campaign screen, i suggest looking at how the campaign overlay is coded and work from there
Hell yeah. I've done it taking "New game" button as example. The only thing I've added is back button and coded it in "button actions". Solved. Thank you, Hyper
Back to top Go down
Hyper
Admin
avatar

Game username : Hyper
Server : Azoptaos
Male Posts : 560
Join date : 2014-02-09
Age : 20

PostSubject: Re: Creating menu Button   Fri Mar 30, 2018 1:33 am

no problem! glad you got it figured out

________________________________
i can code you things
Back to top Go down
http://azoptaos.boards.net/
Sponsored content




PostSubject: Re: Creating menu Button   

Back to top Go down
 
Creating menu Button
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Keeping I.T. Open :: SUPPORT :: Support :: Solved Support Issues-
Jump to: