Problema con vuelta atras en menu [C] [SOLUCIONADO]

Moderadores: Kravenbcn, largeroliker, fidelcastro, cerealkiller, pspCaracas, dark_sasuke, m0skit0, LnD, ka69, zacky06

Responder
jdelmejor
Desarrollador
Desarrollador
Mensajes: 63
Registrado: 04 Abr 2010, 15:02

Problema con vuelta atras en menu [C] [SOLUCIONADO]

Mensaje por jdelmejor »

EDIT: Ya lo solucione gracias al usuario "petaboy" (de otro foro).
La solucion esta en usar otro switch para la posicion del menu.
:oki:

Hola, tengo un problema que llevo dias intentando hacer. Me intentare explicar, tengo un menu, con opciones, todo funciona perfecto, pero me gustaria que al entrar en una de las opciones, pudiese volver pulsando (O) [Circulo]. En ese caso tengo el problema de la opcion de volver al menu.

EJ:

Código: Seleccionar todo

#include <pspsdk.h>    
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <pspdebug.h> 
#include <framebuffer.h>
#include <graphics.h>
 
PSP_MODULE_INFO("Rompepsps",0,1,0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
 
SceCtrlData currentPad, lastPad; //variables para los controles
 
int main()
{
 
pspDebugScreenInit();
pspDebugScreenPrintf("Cargando...\n");
 
int up =1;//definimos que la posicion y la opcion sea 1
int down = 1;
int opcion = 1;
int posicion = 1;
 
pspDebugScreenPrintf("Pulsa el boton (X)");
 
while (1)  // Comenzamos la definicion de botones //
{      
sceCtrlReadBufferPositive(¤tPad, 1);      
if( currentPad.Buttons != lastPad.Buttons )
{
lastPad = currentPad;
 
if(currentPad.Buttons & PSP_CTRL_CROSS) 
{   
pspDebugScreenClear();
pspDebugScreenPrintf("-> Hello Word by jd\n");
pspDebugScreenPrintf("   Ver procesando");
 
void menu_1()//establecemos el menu1
{
     up =1;//definimos que la posicion y la opcion sea 1
     down = 1;
     opcion = 1;
 
   pspDebugScreenClear();
   pspDebugScreenPrintf("-> Hello Word by jd\n");
   pspDebugScreenPrintf("   Ver procesando");
}
 
void menu_2()//establecemos el menu2
{
     up =2;//igual que antes pero ahora definimos la posicion y la opcion en 2
     down = 2;
     opcion = 2;
 
   pspDebugScreenClear();
   pspDebugScreenPrintf("   Hello Word by jd\n");
   pspDebugScreenPrintf("-> Ver procesando");
}
 
 
void opcion_1()
{
  pspDebugScreenClear();
  pspDebugScreenPrintf("Hola!\n");
  pspDebugScreenPrintf("(X) para salir (O) para volver al menu\n");
 
  while (1)  // Comenzamos la definicion de botones //
  {      
  sceCtrlReadBufferPositive(¤tPad, 1);      
  if( currentPad.Buttons != lastPad.Buttons )
  {
  lastPad = currentPad;
 
  if(currentPad.Buttons & PSP_CTRL_CIRCLE) 
  {
     pspDebugScreenPrintf("Volviendo al menu...\n");               
     sceKernelDelayThread(2*1000*1000);
     posicion = 2;
  }
}
}
}
 
 
void opcion_2()//igual que arriba xD
{
 
   pspDebugScreenClear();
   pspDebugScreenPrintf("Procesando.\n");
   pspDebugScreenPrintf("(X) para salir (O) para volver al menu\n");
   while (1)  // Comenzamos la definicion de botones //
   {      
   sceCtrlReadBufferPositive(¤tPad, 1);      
   if( currentPad.Buttons != lastPad.Buttons )
   {
   lastPad = currentPad;
 
   if(currentPad.Buttons & PSP_CTRL_CIRCLE) 
   {
     pspDebugScreenPrintf("Volviendo al menu...\n");               
     sceKernelDelayThread(2*1000*1000);
     posicion = 2;
   }
   }
   }
}   
 
while(1)      
  {
  sceCtrlReadBufferPositive(¤tPad, 1);
 
    if( currentPad.Buttons != lastPad.Buttons )
   {
   lastPad = currentPad;
 
    if(currentPad.Buttons & PSP_CTRL_DOWN)//si pulsamos abajo... 
    {
        switch(down)//switch condicionado por la variable down
        {
        case 1:
        menu_2();
        break;
        case 2:
        menu_1();
        }
 
    }
    if(currentPad.Buttons & PSP_CTRL_UP)
    {
        switch(up)//igual que arriba pero con la variable up
        {
        case 1:
        menu_2();
        break;
        case 2:
        menu_1();
        break;
        }         
    }
 
    if(currentPad.Buttons & PSP_CTRL_CROSS)
    {
        switch(opcion) // igual pero con la variable opcion
        {
        case 1:
        opcion_1();
        break;
        case 2:
        opcion_2();
        break;
        }
    }
 
    if(currentPad.Buttons & PSP_CTRL_CIRCLE)
    {
        switch(posicion) // igual pero con la variable posicion//
        {
        case 1: //Estamos en el menu principal así que no hacemos nada;
        break;
        case 2: // Estamos en opción_1, así que volvemos al menu principal;       
        menu_1();
        break;       
        }
    }
    }
  }

}
}
return 0;
}


Me gustaria que VUELVA AL MENU AL PULSAR (O).

Salu2 y aver si alguien es capaz de ayudarme :oops:.
Última edición por jdelmejor el 30 Ene 2011, 17:54, editado 4 veces en total.

Avatar de Usuario
m0skit0
Administrador
Administrador
Mensajes: 5585
Registrado: 03 Sep 2009, 09:35
Ubicación: 0xdeadbeef

Re: Problema con vuelta atras en menu [C]

Mensaje por m0skit0 »

No se entiende qué quieres, amigo.
Imagen

jdelmejor
Desarrollador
Desarrollador
Mensajes: 63
Registrado: 04 Abr 2010, 15:02

Re: Problema con vuelta atras en menu [C]

Mensaje por jdelmejor »

m0skit0 escribió:No se entiende qué quieres, amigo.


Uff pues ya lo he editado, con un nuevo codigo y demas.
Salu2 ;).

Responder