Welcome! Log In Create A New Profile

Advanced

Libwiigui window prompt help

Posted by marth_010 
Libwiigui window prompt help
January 09, 2010 08:19AM
Ok, so I'm trying to create a simple soundboard with Libwiigui but I'm stuck on incorporating the window prompt into it. I want my menu to have a 'character selection' type thing (when you click on the button the window prompt pops up and you click on the picture of the character you want).

Soo, my problem is: How can I make it so that I click on something in the window prompt and it changes my choice selection on the main menu and, with the choice changing, change a picture on the main menu into something else? Any suggestions?
Re: Libwiigui window prompt help
January 09, 2010 12:43PM
to do this you will need some customising, since i dont know the source off by heart and neither do i have time to check the source so that i can give exact code but i can provide directions (luckily for you i had the directory with my copy of the source open)

the below function is the one you are referring to, it returns an integer depending on user choice, you will use this to figure the players choice, currently the function only allows 2 options, BUT, you should be able to play around with the source enough so that you can create more buttons and change image of the buttons so that they represent the characters
int
WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label)

i found the function in the menu.cpp file in libwiigui source, the function is quite large so i wont be posting the entire source
Re: Libwiigui window prompt help
January 09, 2010 09:10PM
Ok, I think I got how to customize the prompt with that function but I'm still having trouble on how to use that choice in the main menu. What I'm trying to do right now is initialize a 'selection' element to go along with the choices from the window prompt (i.e..)

If(selection == 1)
show picture 1
else if(selection = 2)
show picture 2

To determine the choice, I'm trying to get my 'select character' button to have the prompt come up and give the player a choice. However, I can't seem to incoorperate the choice in the main menu. Can anyone give me some advice on this?
Re: Libwiigui window prompt help
January 10, 2010 03:19AM
what i would do is make your own prompt window function. just use the generic prompt as a guide. then in the new prompt function, you should create a GuiImageData for each possible picture that can be displayed. And make a GuiImage and set whatever you want as the default image data. then just use GuiImage blabla.SetImage() to change what the picture looks like depending on what the user selects. Also, the generic prompt window is really limited on the amount of choices that it can display, so you would either need to fill it up with buttons, or put a optionbrowser type deal on the prompt to support a bunch of choices.



in regards to your second question, you would just use the GetSelectedOption() for optionbrowser or if you have a bunch of buttons, say

if(button1.GetState()==STATE_SELECTED){theImageName.SetImage(theImageDataName);}

where button1 is a guibutton, theImageName is a guiimage, and theImageDataName is one of the guiimagedata for the player images.
Re: Libwiigui window prompt help
January 10, 2010 09:14AM
Ok, so I did what you said giantpune and made my own window prompt. However, when I declared my images inside of the prompt function and click on a guibutton to have it appear, the image popped up in the prompt!

I know I'm doing something completely wrong and absentminded but could someone tell me how to get the image to appear in the main menu and have the prompt close when I push the guibutton in the prompt?
Re: Libwiigui window prompt help
January 10, 2010 10:56AM
in that case you want to create the guiimage and all the guiimagedata (in an array) in the base window. then somithing in that window will call a prompt. the prompt will ask what character they wish to use. and you should call the prompt and the user will select a character and this prompt will return a number. then you will be back in the base window and you can say the guiImage.SetImage() stuff.

so something like

GuiImageData *data[number_of_players] = NULL;
data[0] = new guiimagedata player1data(blabla);
data[1] = new guiimagedata player2data(blabla);

GuiImage image(NULL);
image.SetImage(data[windowprompt("pick a character","text","player 1 name","player 2 name")-1]);

this is a dumbed down version, but you get the idea. windowprompt() is really just a number. and you just make sure that whatever number the prompt can return is a valid image in the array of imagedata. you can place the "image.setimage()" anywhere after you declare the image. it doesn't have to be right afterwards. and you must remember to get rid of the pointer properly when you are done with it.



Edited 2 time(s). Last edit at 01/10/2010 11:01AM by giantpune.
Re: Libwiigui window prompt help
January 16, 2010 03:57AM
I still have no idea what I need to do in order to get a picture to display in the main menu after pushing a button on the window prompt. I tried what you did but I can't seem to make sense of this at all. Do you think you could lead me through it a little more? For example, where do I put the..?

GuiImage image(NULL);
image.SetImage(data[windowprompt("pick a character","text","player 1 name","player 2 name")-1]);

Under the button that pulls up the prompt?

(Sorry for replying so late. Busy week lol)
Re: Libwiigui window prompt help
January 16, 2010 07:10AM
i would put the line to create the GuiImage in the section of code where you are creating all the other images and buttons. then you have a part where you append all those elements to a GuiWindow and append the guiWindow to the main window. and then the while() loop. i would put the image.SetImage bit after the append stuff and before the while() loop if you only want to give them 1 chance to select the character. if you want to give them a choice to change their mind about the character i would do something like this
guiwindow w(screenwidth, screenheight);
create all your buttons and images
haltgui();
append a button and whatever else to the guiwindow
w.append(& image);
mainwindow->append(&w);
resumegui();
while(menu!=menu_exit)
{
if(aButton.getState()==STATE_CLICKED)
{
image.SetImage(data[windowprompt("pick a character","text","player 1 name","player 2 name")-1]);
aButton.ResetState();
}

//the rest of your loop is here

}
haltgui();
mainwindow->remove(&w);
resumegui();
return menu;

so every time they click aButton it will prompt for them to pick a character. and the prompt will return a number. then it will tell the image to use whatever imagedata from that array for the picture.
Re: Libwiigui window prompt help
January 17, 2010 06:58AM
Ok, I'm getting somewhere. However, when I declare my images in the main window, they all appear in the top right corner when I start up the program. Do you know a way to fix this and have them only appear when I click the button in the prompt? I'm really appreciating all of your help right now dude
Re: Libwiigui window prompt help
January 18, 2010 05:54AM
they are appearing there because you have said
w.append(&blabla);

all you have to do is create the guiimagedata for each of the different pictures and create 1 guiimage with no data. and just append that 1 image to the window. then when you set that image to use different guiimagedata, your image will appear.
Sorry, only registered users may post in this forum.

Click here to login