Subversion Repositories psp

[/] [branches/] [smsplus_adhoc/] [psp/] [psplib/] [ui.c] - Diff between revs 353 and 354

Show entire file | Details | Blame | View Log

Rev 353 Rev 354
Line 2716... Line 2716...
        }
        }
 
 
  pspImageDestroy(screen);
  pspImageDestroy(screen);
}
}
 
 
 No newline at end of file
 No newline at end of file
 
int pspUiBETA(PspMAC mac, int host)
 
{
 
  const char *message = "Waiting for the other party to resume ...";
 
  PspImage *screen = NULL;
 
  int sx, sy, dx, dy, th, fh, mw, cw, w, h;
 
  int i, n = UI_ANIM_FRAMES;
 
  char *instr = strdup("\026"PSP_CHAR_SQUARE"\020 Disconnect\t\026\002\020 Cancel");
 
  ReplaceIcons(instr);
 
 
 
  mw = pspFontGetTextWidth(UiMetric.Font, message);
 
  cw = pspFontGetTextWidth(UiMetric.Font, instr);
 
  fh = pspFontGetLineHeight(UiMetric.Font);
 
  th = pspFontGetTextHeight(UiMetric.Font, message);
 
 
 
  w = ((mw > cw) ? mw : cw) + 50;
 
  h = th + fh * 3;
 
  sx = SCR_WIDTH / 2 - w / 2;
 
  sy = SCR_HEIGHT / 2 - h / 2;
 
  dx = sx + w;
 
  dy = sy + h;
 
 
 
  /* Intro animation */
 
  if (UiMetric.Animate)
 
  {
 
    /* Get copy of screen */
 
    screen = pspVideoGetVramBufferCopy();
 
 
 
    for (i = 0; i < n; i++)
 
    {
 
          pspVideoBegin();
 
 
 
          /* Clear screen */
 
          pspVideoPutImage(screen, 0, 0, screen->Viewport.Width, screen->Height);
 
 
 
          /* Apply fog and draw frame */
 
          pspVideoFillRect(0, 0, SCR_WIDTH, SCR_HEIGHT,
 
            COLOR(0,0,0,UI_ANIM_FOG_STEP*i));
 
          pspVideoFillRect(SCR_WIDTH/2-(((dx-sx)/n)*i)/2,
 
            SCR_HEIGHT/2-(((dy-sy)/n)*i)/2,
 
            SCR_WIDTH/2+(((dx-sx)/n)*i)/2, SCR_HEIGHT/2+(((dy-sy)/n)*i)/2,
 
            COLOR(RED_32(UiMetric.MenuOptionBoxBg),
 
              GREEN_32(UiMetric.MenuOptionBoxBg),
 
              BLUE_32(UiMetric.MenuOptionBoxBg),(0xff/n)*i));
 
 
 
          pspVideoEnd();
 
 
 
      /* Swap buffers */
 
      pspVideoWaitVSync();
 
      pspVideoSwapBuffers();
 
        }
 
  }
 
 
 
  pspVideoBegin();
 
 
 
  if (UiMetric.Animate)
 
    pspVideoPutImage(screen, 0, 0, screen->Viewport.Width, screen->Height);
 
  pspVideoFillRect(0, 0, SCR_WIDTH, SCR_HEIGHT,
 
    COLOR(0,0,0,UI_ANIM_FOG_STEP*n));
 
  pspVideoFillRect(sx, sy, dx, dy, UiMetric.MenuOptionBoxBg);
 
  pspVideoPrint(UiMetric.Font, SCR_WIDTH / 2 - mw / 2, sy + fh * 0.5, message,
 
    UiMetric.TextColor);
 
  pspVideoPrint(UiMetric.Font, SCR_WIDTH / 2 - cw / 2, dy - fh * 1.5, instr,
 
    UiMetric.TextColor);
 
  pspVideoGlowRect(sx, sy, dx - 1, dy - 1,
 
    COLOR(0xff,0xff,0xff,UI_ANIM_FOG_STEP*n), 2);
 
 
 
  pspVideoEnd();
 
 
 
  /* Swap buffers */
 
  pspVideoWaitVSync();
 
  pspVideoSwapBuffers();
 
 
 
  SceCtrlData pad;
 
  unsigned int confirm = 0xDEADBEEF;
 
 
 
  /* Loop until X or O is pressed */
 
  while (!ExitPSP)
 
  {
 
    if (!pspCtrlPollControls(&pad))
 
      continue;
 
 
 
    if (host)
 
      pspAdhocSend(mac, &confirm, sizeof(confirm));
 
    else
 
    {
 
      unsigned int recvd = 0;
 
      pspAdhocRecv(&recvd, sizeof(recvd));
 
 
 
      if (recvd == confirm)
 
        break;
 
    }
 
 
 
    sceKernelDelayThread(1000000);
 
 
 
    if (pad.Buttons & UiMetric.CancelButton
 
      || pad.Buttons & PSP_CTRL_SQUARE) break;
 
  }
 
 
 
  if (!ExitPSP && UiMetric.Animate)
 
  {
 
          /* Exit animation */
 
          for (i = n - 1; i >= 0; i--)
 
          {
 
                  pspVideoBegin();
 
 
 
                  /* Clear screen */
 
                  pspVideoPutImage(screen, 0, 0, screen->Viewport.Width, screen->Height);
 
 
 
                  /* Apply fog and draw frame */
 
          pspVideoFillRect(0, 0, SCR_WIDTH, SCR_HEIGHT,
 
            COLOR(0,0,0,UI_ANIM_FOG_STEP*i));
 
          pspVideoFillRect(SCR_WIDTH/2-(((dx-sx)/n)*i)/2,
 
            SCR_HEIGHT/2-(((dy-sy)/n)*i)/2,
 
            SCR_WIDTH/2+(((dx-sx)/n)*i)/2, SCR_HEIGHT/2+(((dy-sy)/n)*i)/2,
 
            COLOR(RED_32(UiMetric.MenuOptionBoxBg),
 
              GREEN_32(UiMetric.MenuOptionBoxBg),
 
              BLUE_32(UiMetric.MenuOptionBoxBg),(0xff/n)*i));
 
 
 
                  pspVideoEnd();
 
 
 
            /* Swap buffers */
 
            pspVideoWaitVSync();
 
            pspVideoSwapBuffers();
 
                }
 
        }
 
 
 
  if (screen) pspImageDestroy(screen);
 
  free(instr);
 
 
 
  if (pad.Buttons & UiMetric.CancelButton) return PSP_UI_CANCEL;
 
  else if (pad.Buttons & PSP_CTRL_SQUARE) return PSP_UI_NO;
 
  else return PSP_UI_YES;
 
}
 
 
 
 
 
 
 No newline at end of file
 No newline at end of file