Welcome! Log In Create A New Profile

Advanced

Menu in non-graphical homebrew?

Posted by jackos2500 
Menu in non-graphical homebrew?
June 08, 2010 09:04AM
Is it possible to make a menu in a non-graphical homebrew using printf()? Also, is it possible to create an option menu using the same method? e.g. If I wanted the user to pick a number between 1 and 10, rather than seeing all the options at one time, they could just use left and right on d-pad to switch between numbers. Thanks in advance! :P



Edited 2 time(s). Last edit at 06/08/2010 04:47PM by jackos2500.
Re: Menu in non-graphical homebrew?
June 08, 2010 11:53AM
Yes. Google ANSI escape sequences.
Re: Menu in non-graphical homebrew?
June 08, 2010 04:50PM
Quote
chris
Yes. Google ANSI escape sequences.
Thanks! :) But, if possible, could I have an example or a link to one?
Re: Menu in non-graphical homebrew?
June 08, 2010 09:40PM
This is really far too basic and generally applicable to be discussed in the Coding section of our forum.
Re: Menu in non-graphical homebrew?
June 08, 2010 09:51PM
Quote
Arikado
This is really far too basic and generally applicable to be discussed in the Coding section of our forum.
Whoops, I'm pretty new to this so I didn't know. Sorry.
Re: Menu in non-graphical homebrew?
June 10, 2010 04:54PM
Plz help!!!! :/
Re: Menu in non-graphical homebrew?
June 10, 2010 06:04PM
Here's a simple example, that should work I think for what you want.

int nSelected = 0;
int tracker = 1;
int nTotal = 3; //number of options

for(;;){
WPAD_ScanPads();

if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_A)
break;

if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_RIGHT)
tracker++;

if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_LEFT)
tracker--;

if(tracker < 1)
tracker = 1;

if(tracker > nTotal)
tracker = nTotal;

if(tracker == 1)
nSelected = 1;

if(tracker == 2)
nSelected = 2;

if(tracker == 3)
nSelected = 3;

printf("Choice: %d", nSelected);
}

(This code is modified from some Arikado gave me a while ago for one of the early versions of dop-IOS MOD)

Obviously you'd have to add more to this to make it 1-10, as it is, it's 1-3.

EDIT: Actually, this may work, with a fair bit less code:

int nSelected = 0;
int tracker = 1;
int nTotal = 10; //number of options

for(;;){
WPAD_ScanPads();

if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_A)
break;

if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_RIGHT)
tracker++;

if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_LEFT)
tracker--;

if(tracker < 1)
tracker = 1;

if(tracker > nTotal)
tracker = nTotal;

nSelected = tracker

printf("Choice: %d", nSelected);
}

Pressing A will select the number displayed, and it will be stored in "nSelected".
This version will only work if you want consecutive numbers (or at least numbers in a pattern, like increasing by three). With the original code above, you can have it jump from 1 to 3 and then to 7, then to 4 if you really want.



Edited 2 time(s). Last edit at 06/10/2010 06:10PM by SifJar.
Re: Menu in non-graphical homebrew?
June 10, 2010 10:58PM
Thanks! But, if possible do you know an example using ansi escape codes?
Re: Menu in non-graphical homebrew?
June 11, 2010 12:27AM
Dunno what that is, so I'm gonna say no.

If you just want a menu where the user can select between 1 and 10, that'll do the job, no need for "ANSI escape sequences". If I have a moment in a couple of minutes, I'll lookup ANSI escape sequences and see if I can work it out, but I probably won't be able to, because I really can't program.
Re: Menu in non-graphical homebrew?
June 11, 2010 02:55AM
Quote
jackos2500
Thanks! But, if possible do you know an example using ansi escape codes?
There are ANSI escape codes in that code SifJar posted.
printf("Choice: %d", nSelected);
Since you appear to know what they do, use them as you please. They will all work.
Sorry, only registered users may post in this forum.

Click here to login