Subversion Repositories psp

[/] [trunk/] [neopop/] [System_PSP/] [psplib/] [ui.c] - Diff between revs 136 and 145

Show entire file | Details | Blame | View Log

Rev 136 Rev 145
Line 39... Line 39...
  *YesNoCancelDialogButtonTemplate =
  *YesNoCancelDialogButtonTemplate =
    "\026\001\020 Yes\t\026"PSP_CHAR_SQUARE"\020 No\t\026\002\020 Cancel",
    "\026\001\020 Yes\t\026"PSP_CHAR_SQUARE"\020 No\t\026\002\020 Cancel",
 
 
  *SelectorTemplate = "\026\001\020 Confirm\t\026\002\020 Cancel",
  *SelectorTemplate = "\026\001\020 Confirm\t\026\002\020 Cancel",
 
 
  *BrowserCancelTemplate    = "\026\002\020 Cancel",
  *BrowserTemplates[] = {
  *BrowserEnterDirTemplate  = "\026\001\020 Enter directory",
    "\026\002\020 Cancel\t\026\001\020 Open",
  *BrowserOpenTemplate      = "\026\001\020 Open",
    "\026\002\020 Cancel\t\026\001\020 Enter directory",
  *BrowserParentDirTemplate = "\026\243\020 Parent directory",
    "\026\002\020 Cancel\t\026\001\020 Open\t\026"PSP_CHAR_TRIANGLE"\020 Parent directory",
 
    "\026\002\020 Cancel\t\026\001\020 Enter directory\t\026"PSP_CHAR_TRIANGLE"\020 Parent directory"
 
   },
 
 
  *SplashStatusBarTemplate  = "\026\255\020/\026\256\020 Switch tabs",
  *SplashStatusBarTemplate  = "\026\255\020/\026\256\020 Switch tabs",
 
 
  *OptionModeTemplate =
  *OptionModeTemplate =
    "\026\245\020/\026\246\020 Select\t\026\247\020/\026\002\020 Cancel\t\026\250\020/\026\001\020 Confirm";
    "\026\245\020/\026\246\020 Select\t\026\247\020/\026\002\020 Cancel\t\026\250\020/\026\001\020 Confirm";
 
 
 
enum
 
{
 
  BrowserTemplateOpenTop  = 0,
 
  BrowserTemplateEnterTop = 1,
 
  BrowserTemplateOpen     = 2,
 
  BrowserTemplateEnter    = 3,
 
};
 
 
 
#define BROWSER_TEMPLATE_COUNT 4
 
 
struct UiPos
struct UiPos
{
{
  int Index;
  int Index;
  int Offset;
  int Offset;
  const PspMenuItem *Top;
  const PspMenuItem *Top;
};
};
 
 
/* TODO: dynamically allocate */
/* TODO: dynamically allocate ?? */
static unsigned int __attribute__((aligned(16))) call_list[262144];
static unsigned int __attribute__((aligned(16))) call_list[524288];//262144];
 
 
/* Gets status string - containing current time and battery information */
/* Gets status string - containing current time and battery information */
static void GetStatusString(char *status, int length)
static void GetStatusString(char *status, int length)
{
{
  static char main_str[128], batt_str[32];
  static char main_str[128], batt_str[32];
Line 563... Line 575...
  PspFile *file;
  PspFile *file;
  PspFileList *list;
  PspFileList *list;
  const PspMenuItem *sel, *last_sel;
  const PspMenuItem *sel, *last_sel;
  PspMenuItem *item;
  PspMenuItem *item;
  SceCtrlData pad;
  SceCtrlData pad;
  char *instr;
  char *instructions[BROWSER_TEMPLATE_COUNT];
 
 
 
  /* Initialize instruction strings */
 
  int i;
 
  for (i = 0; i < BROWSER_TEMPLATE_COUNT; i++)
 
  {
 
    instructions[i] = strdup(BrowserTemplates[i]);
 
    ReplaceIcons(instructions[i]);
 
  }
 
 
  if (!start_path)
  if (!start_path)
    start_path = pspGetAppDirectory();
    start_path = pspGetAppDirectory();
 
 
  char *cur_path = pspFileIoGetParentDirectory(start_path);
  char *cur_path = pspFileIoGetParentDirectory(start_path);
  const char *cur_file = pspFileIoGetFilename(start_path);
  const char *cur_file = pspFileIoGetFilename(start_path);
  struct UiPos pos;
  struct UiPos pos;
  int lnmax, lnhalf, instr_len;
  int lnmax, lnhalf;
  int sby, sbh, i, j, h, w, fh = pspFontGetLineHeight(UiMetric.Font);
  int sby, sbh, j, h, w, fh = pspFontGetLineHeight(UiMetric.Font);
  int sx, sy, dx, dy;
  int sx, sy, dx, dy;
  int hasparent, is_dir;
  int hasparent, is_dir;
 
 
  sx = UiMetric.Left;
  sx = UiMetric.Left;
  sy = UiMetric.Top + fh + UiMetric.TitlePadding;
  sy = UiMetric.Top + fh + UiMetric.TitlePadding;
Line 585... Line 605...
  w = dx - sx - UiMetric.ScrollbarWidth;
  w = dx - sx - UiMetric.ScrollbarWidth;
  h = dy - sy;
  h = dy - sy;
 
 
  menu = pspMenuCreate();
  menu = pspMenuCreate();
 
 
  /* Compute max. space needed for instructions */
 
  instr_len = strlen(BrowserCancelTemplate) + 1;
 
  instr_len += 1
 
    + ((strlen(BrowserEnterDirTemplate) > strlen(BrowserOpenTemplate))
 
      ? strlen(BrowserEnterDirTemplate) : strlen(BrowserOpenTemplate));
 
  instr_len += 1 + strlen(BrowserParentDirTemplate);
 
  instr = (char*)malloc(sizeof(char) * instr_len);
 
 
 
  u32 ticks_per_sec, ticks_per_upd;
 
  u64 current_tick, last_tick;
 
 
 
  memset(call_list, 0, sizeof(call_list));
  memset(call_list, 0, sizeof(call_list));
 
 
  int sel_top = 0, last_sel_top = 0, fast_scroll;
  int sel_top = 0, last_sel_top = 0, fast_scroll;
 
 
  /* Begin browsing (outer) loop */
  /* Begin browsing (outer) loop */
Line 675... Line 684...
      }
      }
    }
    }
 
 
    pspVideoWaitVSync();
    pspVideoWaitVSync();
 
 
    /* Compute update frequency */
 
    ticks_per_sec = sceRtcGetTickResolution();
 
    sceRtcGetCurrentTick(&last_tick);
 
    ticks_per_upd = ticks_per_sec / UiMetric.MenuFps;
 
 
 
    /* Begin navigation (inner) loop */
    /* Begin navigation (inner) loop */
    while (!ExitPSP)
    while (!ExitPSP)
    {
    {
      if (!pspCtrlPollControls(&pad))
      if (!pspCtrlPollControls(&pad))
        continue;
        continue;
Line 794... Line 798...
      pspVideoPrint(UiMetric.Font, sx, UiMetric.Top, cur_path,
      pspVideoPrint(UiMetric.Font, sx, UiMetric.Top, cur_path,
        UiMetric.TitleColor);
        UiMetric.TitleColor);
      pspVideoDrawLine(UiMetric.Left, UiMetric.Top + fh - 1, UiMetric.Left + w,
      pspVideoDrawLine(UiMetric.Left, UiMetric.Top + fh - 1, UiMetric.Left + w,
        UiMetric.Top + fh - 1, UiMetric.TitleColor);
        UiMetric.Top + fh - 1, UiMetric.TitleColor);
 
 
      /* Draw instructions */
      const char *instruction;
      strcpy(instr, BrowserCancelTemplate);
 
      if (sel)
 
      {
 
        strcat(instr, "\t");
 
        strcat(instr, (is_dir) ? BrowserEnterDirTemplate : BrowserOpenTemplate);
 
      }
 
      if (hasparent)
      if (hasparent)
      {
        instruction = instructions[(is_dir)
        strcat(instr, "\t");
          ? BrowserTemplateEnter : BrowserTemplateOpen];
        strcat(instr, BrowserParentDirTemplate);
      else
      }
        instruction = instructions[(is_dir)
      ReplaceIcons(instr);
          ? BrowserTemplateEnterTop : BrowserTemplateOpenTop];
 
 
      pspVideoPrintCenter(UiMetric.Font,
      pspVideoPrintCenter(UiMetric.Font,
        sx, SCR_HEIGHT - fh, dx, instr, UiMetric.StatusBarColor);
        sx, SCR_HEIGHT - fh, dx, instruction, UiMetric.StatusBarColor);
 
 
      /* Draw scrollbar */
      /* Draw scrollbar */
      if (sbh > 0)
      if (sbh > 0)
      {
      {
        sby = sy + (int)((float)(h - sbh)
        sby = sy + (int)((float)(h - sbh)
Line 886... Line 885...
 
 
      sceGuCallList(call_list);
      sceGuCallList(call_list);
 
 
      pspVideoEnd();
      pspVideoEnd();
 
 
      /* Wait if needed */
 
      do { sceRtcGetCurrentTick(&current_tick); }
 
      while (current_tick - last_tick < ticks_per_upd);
 
      last_tick = current_tick;
 
 
 
      /* Swap buffers */
      /* Swap buffers */
      pspVideoWaitVSync();
      pspVideoWaitVSync();
      pspVideoSwapBuffers();
      pspVideoSwapBuffers();
 
 
      last_sel = sel;
      last_sel = sel;
Line 902... Line 896...
    }
    }
  }
  }
 
 
exit_browser:
exit_browser:
 
 
  pspMenuDestroy(menu);
  /* Free instruction strings */
 
  for (i = 0; i < BROWSER_TEMPLATE_COUNT; i++)
 
    free(instructions[i]);
 
 
 
  pspMenuDestroy(menu);
  free(cur_path);
  free(cur_path);
  free(instr);
 
}
}
 
 
void pspUiOpenGallery(const PspUiGallery *gallery, const char *title)
void pspUiOpenGallery(const PspUiGallery *gallery, const char *title)
{
{
  PspMenu *menu = gallery->Menu;
  PspMenu *menu = gallery->Menu;