예제 #1
0
////////////////////////////////////////////////////////////////////////////////////////
// Multiple lines message box
////////////////////////////////////////////////////////////////////////////////////////
int msgBoxLines(const char *msg,int delay_vblank) {
	int len,width;
	unsigned char c;
	char str[256];
	int i,j,x,y,lines,ret;
	
	if (!msg) return -1;
  if (!(msg[0])) return -1;
	
	pgCopyScreen();
	
	lines=1;	
	j=0;
	len=0;
	width=0;
	while ((c=msg[len])) {
		if (((c>=0x80) && (c<0xa0)) || (c>=0xe0)) {
			len++;
		} else {
			if (c=='\n') {
				lines++;			
				if (width<(len-j)) width=len-j;
				j=len+1;
			}
		}
		len++;
	}	
	if (width<(len-j)) width=len-j;
	if (!width) width=strlen(msg);
	
	y=(272-lines*12)/2;
	x=(480-width*6)/2;
	
	pgFillBox(x-12-1,y-6-1,x+width*6+12+1,y+lines*12+6,BOX_COLOR);
	pgDrawFrame(x-12,y-6,x+width*6+12,y+lines*12+6-1,FRAME_COLOR);
	
	len=0;
	for (i=0;i<lines;i++){
		j=0;
		while ((c=msg[len])) {
			if (((c>=0x80) && (c<0xa0)) || (c>=0xe0)) {
				str[j++]=msg[len++];
			} else {
				if (c=='\n') break;
			}
			str[j++]=msg[len++];
		}
		if (msg[len]=='\n') len++;
		str[j]=0;
		mh_printCenter(y,str,TEXT_COLOR);
		ret=y;
		y+=12;
	}


	pgScreenFlipV();
	if (delay_vblank>0) pgWaitVn(delay_vblank);
	return ret;
}
예제 #2
0
int xmain(int ra)
{
	SetupCallbacks();

	pgInit();
	pgScreenFrame(1, 0);
	pgFillvram(0);

	mainImpl();
	
	pgWaitVn(500);
	sceKernelExitGame();

	return 0;
}
예제 #3
0
////////////////////////////////////////////////////////////////////////////////////////
// Message box
////////////////////////////////////////////////////////////////////////////////////////
void msgBox(const char *msg,int delay_vblank) {
	int len;
	char str[60];
	
	pgCopyScreen();
	
	memcpy(str,msg,50);
	str[50]=0;
	len=strlen(msg);
	if (len>=50) {
		str[50-3]=str[50-2]=str[50-1]='.';
		len=49;
	}
	len*=8;

	pgFillBox(240-len/2-20-1,136-12-1,240+len/2+20+1,136+18+1,BOX_COLOR);
	pgDrawFrame(240-len/2-20,136-12,240+len/2+20,136+18,FRAME_COLOR);

	pgPrintCenter(17,TEXT_COLOR,str);

	pgScreenFlipV();
	if (delay_vblank<=0) delay_vblank=1;
	pgWaitVn(delay_vblank);
}
예제 #4
0
// Picks an IP address - int[4]
int IP_picker(int* address)
{
    u32 buttonsLast = 0;
    int bRedraw = 1;
    int iPick = 0;
    int ipaddr[4];

    if (address == NULL)
        return -1; // nowhere to store the IP!

    // copy the address
    for (iPick = 0;iPick<4;iPick++) ipaddr[iPick]=address[iPick];
    iPick = 0;
    
    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(0); // digital

    char number[5];
    while (1)
    {
        int i;
        SceCtrlData pad;
        u32 buttonsNew;


        if (bRedraw)
        {
            pgFillvram(0);
            pgPrint4AtPixel(X_TITLE, X_TITLE, COLOR_GREY50, "Server IP");
            for (i = 0; i < 4; i++)
            {
                u32 color1 = COLOR_GREY25;
                if (i == iPick)
		{
                    color1 = COLOR_GREY75;
                    // underline selected number
                    pgPrint2AtPixel(i*16*4+32, MIDSCREEN+16, COLOR_WHITE, "---");
                }
                sprintf(number,"%3d",ipaddr[i]);
                if (i < 3) {
		    number[3]='.';
		    number[4]=0;
                }
                pgPrint2AtPixel(i*16*4+32, MIDSCREEN, color1, number);
            }
            pgScreenFlipV();
            bRedraw = 0;
        }

        // handle inputs
        sceCtrlReadBufferPositive(&pad, 1);
        buttonsNew = pad.Buttons & ~buttonsLast;
        buttonsLast = pad.Buttons;
        if (buttonsNew & PSP_CTRL_RIGHT)
        {
            iPick++;
            if (iPick >= 4)
                iPick = 0;
            bRedraw = 1;
        }
        else if (buttonsNew & PSP_CTRL_LEFT)
        {
            iPick--;
            if (iPick < 0)
                iPick = 3;
            bRedraw = 1;
        }
        else if (buttonsLast & PSP_CTRL_UP) {
             ipaddr[iPick]++;
             if (ipaddr[iPick]>255) ipaddr[iPick]=0;
             bRedraw = 1;
        }
        else if (buttonsLast & PSP_CTRL_DOWN) {
             ipaddr[iPick]--;
             if (ipaddr[iPick]<0) ipaddr[iPick]=255;
             bRedraw = 1;
        }
        else if (buttonsNew & (PSP_CTRL_CIRCLE | PSP_CTRL_CROSS))
        {
                break; // picked !
        }
        else if (buttonsNew & PSP_CTRL_TRIANGLE)
        {
            iPick = -1; // cancel
            break;
        }
    }

    // show_confirmation: show final selection for a short time
    pgFillvram(0);
    pgPrint4AtPixel(X_TITLE, Y_TITLE, COLOR_GREY50, "Server IP");
    if (iPick != -1) {
	int i;
	for (i=0;i<4;i++) address[i]=ipaddr[i];
    }
    
    for (iPick = 0; iPick<4; iPick++) {
        sprintf(number,"%3d",address[iPick]);
    	if (iPick < 3) {
	    number[3]='.';
	    number[4]=0;
        }
        pgPrint2AtPixel(iPick*16*4+32, MIDSCREEN, COLOR_WHITE, number);
    }
    pgScreenFlipV();
    pgWaitVn(50);

    return 0;
}
예제 #5
0
int my_picker(const PICKER* pickerP)
{
    int iPick = pickerP->pick_start;
    u32 buttonsLast = 0;
    int bRedraw = 1;

    if (pickerP->pick_count == 0)
        return -1; // nothing to pick

    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(0); // digital

    while (1)
    {
        int i;
        SceCtrlData pad;
        u32 buttonsNew;

        if (pickerP->pick_count == 1)
        {
            // auto-pick if only one
            iPick = 0;
            break;
        }

        if (bRedraw)
        {
            pgFillvram(0);
            pgPrint4AtPixel(X_TITLE, X_TITLE, COLOR_GREY50, pickerP->szTitle);
            for (i = 0; i < pickerP->pick_count; i++)
            {
                PICKER_INFO const* pickP = &pickerP->picks[i];
                u32 color1 = COLOR_GREY25;
                u32 color2 = COLOR_GREY12;
                int y2;
                if (i == iPick)
                {
                    color1 = COLOR_GREY75;
                    color2 = COLOR_GREY50;
                    pgPrint4AtPixel(0, Y_PICK(i), COLOR_WHITE, STR_PICK);
                }
                pgPrint4AtPixel(X_PICK, Y_PICK(i), color1, pickP->szBig);
                y2 = Y_PICK_FINEPRINT(i);
                if (i != MAX_PICK-1)
                    y2 += 2;    // space it out a little
                pgPrint1AtPixel(X_PICK_FINEPRINT, y2, color2, pickP->szFinePrint);
            }
            pgScreenFlipV();
            bRedraw = 0;
        }

        // handle up/down inputs
        sceCtrlReadBufferPositive(&pad, 1); 
        buttonsNew = pad.Buttons & ~buttonsLast;
        buttonsLast = pad.Buttons;
        if (buttonsNew & PSP_CTRL_DOWN)
        {
            iPick++;
            if (iPick >= pickerP->pick_count)
                iPick = pickerP->pick_count-1;
            bRedraw = 1;
        }
        else if (buttonsNew & PSP_CTRL_UP)
        {
            iPick--;
            if (iPick < 0)
                iPick = 0;
            bRedraw = 1;
        }
        else if (buttonsNew & (PSP_CTRL_CIRCLE | PSP_CTRL_CROSS))
        {
            if (iPick >= 0 && iPick < pickerP->pick_count)
                break; // picked !
        }
        else if (buttonsNew & PSP_CTRL_TRIANGLE)
        {
            iPick = -1; // cancel
            break;
        }
    }

    // show_confirmation: show final selection for a short time
    pgFillvram(0);
    pgPrint4AtPixel(X_TITLE, Y_TITLE, COLOR_GREY50, pickerP->szTitle);
    if (iPick != -1)
        pgPrint4AtPixel(X_PICK, Y_PICK(iPick), COLOR_WHITE, pickerP->picks[iPick].szBig);
    else
        pgPrint4AtPixel(X_PICK, Y_PICK(2), COLOR_WHITE, "[Cancel]");
    pgScreenFlipV();
    pgWaitVn(50);

    return iPick;
}