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; }
int pspVideoPrintCenter(PspFont *font, int sx, int sy, int dx, const char *string, uint32_t color) { const unsigned char *ch; int width, c = color, max; width = pspFontGetTextWidth(font, string); sx += (dx - sx) / 2 - width / 2; for (ch = (unsigned char*)string, width = 0, max = 0; *ch; ch++) { if (*ch < 32) { if (*ch >= PSP_FONT_RESTORE && *ch <= PSP_FONT_WHITE) { c = (*ch == PSP_FONT_RESTORE) ? color : PspFontColor[(int)(*ch) - PSP_FONT_RESTORE]; continue; } else if (*ch == '\n') { sy += font->Height; width = 0; continue; } } width += PutChar(font, sx + width, sy, (uint8_t)(*ch), c); if (width > max) max = width; } return max; }
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); }
inline int PutChar(PspFont *font, int sx, int sy, unsigned char sym, int color) { if(!font->font){ font->font=vita2d_load_font_mem(stockfont,stockfont_size); font->Height=pspFontGetLineHeight(font); font->Ascent=font->Height; } /* Instead of a tab, skip 4 spaces */ if (sym == (uint8_t)'\t') return pspFontGetTextWidth(font," ") * 4; /* This function should be rewritten to write directly to VRAM, probably */ char buf[2]; buf[0]=sym; buf[1]='\0'; int w = vita2d_font_draw_text(font->font,sx+1,sy+1,PSP_COLOR_BLACK,PSP_FONT_SIZE,buf); w = vita2d_font_draw_text(font->font,sx,sy,color,PSP_FONT_SIZE,buf); return w; }
/* 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); } }