int pspVideoPrintClipped(PspFont *font, int sx, int sy, const char* string, int max_w, char* clip, uint32_t color) { int str_w = pspFontGetTextWidth(font, string); if (str_w <= max_w) return pspVideoPrint(font, sx, sy, string, color); int w, len; const char *ch; int clip_w = pspFontGetTextWidth(font, clip); for (ch=string, w=0, len=0; *ch && (w + clip_w < max_w); ch++, len++) { if (*ch == '\t') w += pspFontGetTextWidth(font," ") * 4; else { char buf[2]; buf[0]=*ch; buf[1]='\0'; w += pspFontGetTextWidth(font,buf); } } w = pspVideoPrintN(font, sx, sy, string, len - 1, color); pspVideoPrint(font, sx + w, sy, clip, color); return w + clip_w; }
void OnSplashRender(const void *splash, const void *null) { int fh, i, x, y, height; const char *lines[] = { PSP_APP_NAME" version "PSP_APP_VER" ("__DATE__")", "\026https://github.com/frangarcj/Genesis-Plus-GX", " ", "2015 Frangarcj", "2006 eke-eke", "1998-2004 Charles MacDonald", NULL }; fh = pspFontGetLineHeight(UiMetric.Font); for (i = 0; lines[i]; i++); height = fh * (i - 1); /* Render lines */ for (i = 0, y = SCR_HEIGHT / 2 - height / 2; lines[i]; i++, y += fh) { x = SCR_WIDTH / 2 - pspFontGetTextWidth(UiMetric.Font, lines[i]) / 2; pspVideoPrint(UiMetric.Font, x, y, lines[i], PSP_COLOR_GRAY); } /* Render PSP status */ OnGenericRender(splash, null); }
/*** * Prints the current FPS to the screen. */ void show_fps() { static char fps_display[32]; sprintf(fps_display, "FPS: %3.02f", curr_fps); int width = pspFontGetTextWidth(&PspStockFont, fps_display); int height = pspFontGetLineHeight(&PspStockFont); pspVideoFillRect(0, 0, width, height, PSP_COLOR_BLACK); pspVideoPrint(&PspStockFont, 0, 0, fps_display, PSP_COLOR_WHITE); }
/* Handles drawing of generic items */ void OnGenericRender(const void *uiobject, const void *item_obj) { /* Draw tabs */ int height = pspFontGetLineHeight(UiMetric.Font); int width; int i, x; for (i = 0, x = 5; i <= TAB_MAX; i++, x += width + 10) { width = -10; if (!GAME_LOADED && (i == TAB_STATE || i == TAB_SYSTEM)) continue; /* Determine width of text */ width = pspFontGetTextWidth(UiMetric.Font, TabLabel[i]); /* Draw background of active tab */ if (i == TabIndex) pspVideoFillRect(x - 5, 0, x + width + 5, height + 1, UiMetric.TabBgColor); /* Draw name of tab */ pspVideoPrint(UiMetric.Font, x, 0, TabLabel[i], PSP_COLOR_WHITE); } }