| View previous topic :: View next topic |
| Author |
Message |
PsPfReAK
Joined: 28 Mar 2009 Posts: 61
|
Posted: Sat Apr 11, 2009 9:56 pm Post subject: help with my Menu |
|
|
| Code: | #include <pspsdk.h>
#include <pspkernel.h>
#include <psppower.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("Sample Menu", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
SceCtrlData currentPad, lastPad;
int option = 1;
int down = 1;
int up = 1;
void Menu_A()
{
option = 1;
down = 1;
up = 1;
pspDebugScreenClear();
pspDebugScreenSetTextColor(0xFF0000);
printf("\n Sample Menu\n\n\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" Select an option:\n\n");
pspDebugScreenSetTextColor(0x0000FF);
printf(" -> Option 1\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" -> Option 2\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" -> Exit\n\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" -> Test selected\n");
pspDebugScreenSetTextColor(0x00FF00);
printf(" Press X to select the option.");
}
void Menu_B()
{
option = 2;
down = 2;
up = 2;
pspDebugScreenClear();
pspDebugScreenSetTextColor(0xFF0000);
printf("\n Sample Menu\n\n\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" Select an option:\n\n");
printf(" -> Option 1\n");
pspDebugScreenSetTextColor(0x0000FF);
printf(" -> Option 2\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" -> Exit\n\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" -> Test selected\n");
pspDebugScreenSetTextColor(0x00FF00);
printf(" Press X to select the option.");
}
void Menu_C()
{
option = 3;
down = 3;
up = 3;
pspDebugScreenClear();
pspDebugScreenSetTextColor(0xFF0000);
printf("\n Sample Menu\n\n\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" Select an option:\n\n");
printf(" -> Option 1\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" -> Option 2\n");
pspDebugScreenSetTextColor(0x0000FF);
printf(" -> Exit\n\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" -> Test selected\n");
pspDebugScreenSetTextColor(0x00FF00);
printf(" Press X to select the option.");
}
void Menu_D()
{
option = 4;
down = 4;
up = 4;
pspDebugScreenClear();
pspDebugScreenSetTextColor(0xFF0000);
printf("\n Sample Menu\n\n\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" Select an option:\n\n");
printf(" -> Option 1\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" -> Option 2\n");
pspDebugScreenSetTextColor(0x0000FF);
printf(" -> Exit\n\n");
pspDebugScreenSetTextColor(0xFFFFFF);
printf(" -> Test selected\n");
pspDebugScreenSetTextColor(0x00FF00);
printf(" Press X to select the option.");
}
void Option_A()
{
pspDebugScreenClear();
pspDebugScreenSetTextColor(0x00FF00);
printf("\n Welcome to option A");
sceKernelDelayThread(2*1000*1000);
Menu_A();
}
void Option_B()
{
pspDebugScreenClear();
pspDebugScreenSetTextColor(0x00FF00);
printf("\n Welcome to Option B");
sceKernelDelayThread(2*1000*1000);
Menu_A();
}
void Option_C()
{
pspDebugScreenSetTextColor(0x00FF00);
printf("\n\n Bye Bye\n\n Now exiting...");
sceKernelDelayThread(2*1000*1000);
sceKernelExitGame();
}
void Option_D()
{
pspDebugScreenSetTextColor(0x00FF00);
pspDebugScreenClear();
printf("Test Selected");
sceKernelDelayThread(2*1000*1000);
Menu_A();
}
int main()
{
sceCtrlReadBufferPositive(&lastPad, 1);
pspDebugScreenInit();
Menu_A();
while(1)
{
sceCtrlReadBufferPositive(¤tPad, 1);
if( currentPad.Buttons != lastPad.Buttons )
{
lastPad = currentPad;
if(currentPad.Buttons & PSP_CTRL_DOWN)
{
switch(down)
{
case 1: Menu_B();
break;
case 2: Menu_C();
break;
case 3: Menu_D();
break;
case 4: Menu_A();
break;
}
}
if(currentPad.Buttons & PSP_CTRL_UP)
{
switch(up)
{
case 1: Menu_D();
break;
case 2: Menu_A();
break;
case 3: Menu_B();
break;
case 4: Menu_C();
break;
}
}
}
if(currentPad.Buttons & PSP_CTRL_CROSS)
{
switch(option)
{
case 1: Option_A();
break;
case 2: Option_B();
break;
case 3: Option_C();
break;
case 4: Option_D();
break;
}
}
}
}
|
well its selecting all four tags like its supposed to but its only highlighting the 1st three and not the last.
how do i correct this? |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sat Apr 11, 2009 11:21 pm Post subject: |
|
|
| Correct the color setting in menu d... it's the same as menu c. |
|
| Back to top |
|
 |
PsPfReAK
Joined: 28 Mar 2009 Posts: 61
|
Posted: Sat Apr 11, 2009 11:40 pm Post subject: |
|
|
| J.F. wrote: | | Correct the color setting in menu d... it's the same as menu c. |
theyre all the same?
this is my first menu, can you expand what you mean please? |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Apr 12, 2009 2:04 pm Post subject: |
|
|
| Notice that each menu sets the background and foreground color before printing the text for the menu. The "hilite" is done by making the text for the menu items not under the cursor one color, and the hilited item a different color. Each menu prints all the items, with the hilite color set for that particular item. Menu a hilites item a, menu b hilites menu b, and so on. Looking at the code above, menu c and d are both hiliting item c instead of c and then d. |
|
| Back to top |
|
 |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
Posted: Sun Apr 12, 2009 4:03 pm Post subject: |
|
|
You need to discover the magic of simple arrays and for-next loops :)
Its not hard to pick up I was doing this kind of stuff in grade 7...
It may not seem like it but it's easier to learn the basics than program like that. XD
Here's a more proper way to do it:
http://www.mediafire.com/download.php?x2zmgwk2j2w |
|
| Back to top |
|
 |
PsPfReAK
Joined: 28 Mar 2009 Posts: 61
|
Posted: Sun Apr 12, 2009 10:47 pm Post subject: |
|
|
| Ooblik wrote: | You need to discover the magic of simple arrays and for-next loops :)
Its not hard to pick up I was doing this kind of stuff in grade 7...
It may not seem like it but it's easier to learn the basics than program like that. XD
Here's a more proper way to do it:
http://www.mediafire.com/download.php?x2zmgwk2j2w |
thanks i'll have a look
EDIT: im gonna stick to my menu, its more simple. lol
but thank you for the sample. when i get better at C and understand it more better then i might use it and give you credit.
but thank you for everyone that helped. |
|
| Back to top |
|
 |
|