Improved code

This commit is contained in:
TheFloW 2017-12-30 00:23:08 +01:00
parent 104c080e8b
commit 078cf049e9
16 changed files with 120 additions and 113 deletions

View File

@ -189,6 +189,6 @@ add_custom_target(send
)
add_custom_target(copy
COMMAND cp eboot.bin F:/app/${VITA_TITLEID}/eboot.bin
COMMAND cp eboot.bin H:/app/${VITA_TITLEID}/eboot.bin
DEPENDS eboot.bin
)

View File

@ -43,7 +43,7 @@ float getCenteroffset(float sx,float ex,char* string){
return sx;
float drawWidthSpace = ex - sx;
uint16_t stringWidth = vita2d_pgf_text_width(font,FONT_SIZE,string);
uint16_t stringWidth = pgf_text_width(string);
return stringWidth > drawWidthSpace ? sx : sx + (drawWidthSpace - stringWidth) / 2 ;
}
@ -101,14 +101,14 @@ void drawLyrics(Lyrics* lyrics, const char *cur_time_string, uint64_t* totalms,
uint32_t m_index = *lyricsIndex >= 1 ? (*lyricsIndex - 1) : *lyricsIndex;
float right_max_x = SCREEN_WIDTH - SHELL_MARGIN_X;
//draw current lyrics
pgf_draw_textf(getCenteroffset(lrcSpaceX,right_max_x,lyrics->lrclines[m_index].word),lrcSpaceY, AUDIO_INFO_ASSIGN, FONT_SIZE, "%s",lyrics->lrclines[m_index].word);
pgf_draw_textf(getCenteroffset(lrcSpaceX,right_max_x,lyrics->lrclines[m_index].word),lrcSpaceY, AUDIO_INFO_ASSIGN, "%s",lyrics->lrclines[m_index].word);
int i;
for (i = 1;i < 7; i++){//draw 6 line lyrics for preview
int n_index = m_index + i;
if(n_index + 1 > lyrics->lyricscount)
break;
pgf_draw_textf(getCenteroffset(lrcSpaceX,right_max_x,lyrics->lrclines[n_index].word),lrcSpaceY + FONT_Y_SPACE * i, AUDIO_INFO, FONT_SIZE, "%s",lyrics->lrclines[n_index].word);
pgf_draw_textf(getCenteroffset(lrcSpaceX,right_max_x,lyrics->lrclines[n_index].word),lrcSpaceY + FONT_Y_SPACE * i, AUDIO_INFO, "%s",lyrics->lrclines[n_index].word);
}
if (*totalms >= (lyrics->lrclines[*lyricsIndex].totalms) ){
@ -123,7 +123,7 @@ void shortenString(char *out, const char *in, int width) {
int i;
for (i = strlen(out)-1; i > 0; i--) {
if (vita2d_pgf_text_width(font, FONT_SIZE, out) < width)
if (pgf_text_width(out) < width)
break;
out[i] = '\0';
@ -378,11 +378,11 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
// Info
float x = 2.0f * SHELL_MARGIN_X + cover_size;
pgf_draw_text(x, START_Y + (0 * FONT_Y_SPACE), AUDIO_INFO_ASSIGN, FONT_SIZE, language_container[TITLE]);
pgf_draw_text(x, START_Y + (1 * FONT_Y_SPACE), AUDIO_INFO_ASSIGN, FONT_SIZE, language_container[ALBUM]);
pgf_draw_text(x, START_Y + (2 * FONT_Y_SPACE), AUDIO_INFO_ASSIGN, FONT_SIZE, language_container[ARTIST]);
pgf_draw_text(x, START_Y + (3 * FONT_Y_SPACE), AUDIO_INFO_ASSIGN, FONT_SIZE, language_container[GENRE]);
pgf_draw_text(x, START_Y + (4 * FONT_Y_SPACE), AUDIO_INFO_ASSIGN, FONT_SIZE, language_container[YEAR]);
pgf_draw_text(x, START_Y + (0 * FONT_Y_SPACE), AUDIO_INFO_ASSIGN, language_container[TITLE]);
pgf_draw_text(x, START_Y + (1 * FONT_Y_SPACE), AUDIO_INFO_ASSIGN, language_container[ALBUM]);
pgf_draw_text(x, START_Y + (2 * FONT_Y_SPACE), AUDIO_INFO_ASSIGN, language_container[ARTIST]);
pgf_draw_text(x, START_Y + (3 * FONT_Y_SPACE), AUDIO_INFO_ASSIGN, language_container[GENRE]);
pgf_draw_text(x, START_Y + (4 * FONT_Y_SPACE), AUDIO_INFO_ASSIGN, language_container[YEAR]);
x += 120.0f;
@ -392,7 +392,7 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
float title_x = x;
uint32_t color = AUDIO_INFO;
int width = (int)vita2d_pgf_text_width(font, FONT_SIZE, fileinfo->title);
int width = (int)pgf_text_width(fileinfo->title);
if (width >= 390.0f) {
if (scroll_count < 60) {
scroll_x = title_x;
@ -410,11 +410,11 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
title_x = scroll_x;
}
pgf_draw_text(title_x, START_Y + (0 * FONT_Y_SPACE), color, FONT_SIZE, fileinfo->title[0] == '\0' ? "-" : fileinfo->title);
pgf_draw_text(x, START_Y + (1 * FONT_Y_SPACE), AUDIO_INFO, FONT_SIZE, fileinfo->album[0] == '\0' ? "-" : fileinfo->album);
pgf_draw_text(x, START_Y + (2 * FONT_Y_SPACE), AUDIO_INFO, FONT_SIZE, fileinfo->artist[0] == '\0' ? "-" : fileinfo->artist);
pgf_draw_text(x, START_Y + (3 * FONT_Y_SPACE), AUDIO_INFO, FONT_SIZE, fileinfo->genre[0] == '\0' ? "-" : fileinfo->genre);
pgf_draw_text(x, START_Y + (4 * FONT_Y_SPACE), AUDIO_INFO, FONT_SIZE, fileinfo->year[0] == '\0' ? "-" : fileinfo->year);
pgf_draw_text(title_x, START_Y + (0 * FONT_Y_SPACE), color, fileinfo->title[0] == '\0' ? "-" : fileinfo->title);
pgf_draw_text(x, START_Y + (1 * FONT_Y_SPACE), AUDIO_INFO, fileinfo->album[0] == '\0' ? "-" : fileinfo->album);
pgf_draw_text(x, START_Y + (2 * FONT_Y_SPACE), AUDIO_INFO, fileinfo->artist[0] == '\0' ? "-" : fileinfo->artist);
pgf_draw_text(x, START_Y + (3 * FONT_Y_SPACE), AUDIO_INFO, fileinfo->genre[0] == '\0' ? "-" : fileinfo->genre);
pgf_draw_text(x, START_Y + (4 * FONT_Y_SPACE), AUDIO_INFO, fileinfo->year[0] == '\0' ? "-" : fileinfo->year);
vita2d_disable_clipping();
@ -434,7 +434,7 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
icon = fastforward_image;
}
pgf_draw_textf(x + 45.0f, y, AUDIO_SPEED, FONT_SIZE, "%dx", abs(getPlayingSpeedFunct() + (getPlayingSpeedFunct() < 0 ? -1 : 1)));
pgf_draw_textf(x + 45.0f, y, AUDIO_SPEED, "%dx", abs(getPlayingSpeedFunct() + (getPlayingSpeedFunct() < 0 ? -1 : 1)));
} else {
if (isPlayingFunct()) {
icon = pause_image;
@ -448,11 +448,11 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
// Time
char string[32];
sprintf(string, "%s / %s", cur_time_string, fileinfo->strLength);
float time_x = ALIGN_RIGHT(SCREEN_WIDTH-SHELL_MARGIN_X, vita2d_pgf_text_width(font, FONT_SIZE, string));
float time_x = ALIGN_RIGHT(SCREEN_WIDTH-SHELL_MARGIN_X, pgf_text_width(string));
int w = pgf_draw_text(time_x, y, AUDIO_TIME_CURRENT, FONT_SIZE, cur_time_string);
pgf_draw_text(time_x + (float)w, y, AUDIO_TIME_SLASH, FONT_SIZE, " /");
pgf_draw_text(ALIGN_RIGHT(SCREEN_WIDTH-SHELL_MARGIN_X, vita2d_pgf_text_width(font, FONT_SIZE, fileinfo->strLength)), y, AUDIO_TIME_TOTAL, FONT_SIZE, fileinfo->strLength);
int w = pgf_draw_text(time_x, y, AUDIO_TIME_CURRENT, cur_time_string);
pgf_draw_text(time_x + (float)w, y, AUDIO_TIME_SLASH, " /");
pgf_draw_text(ALIGN_RIGHT(SCREEN_WIDTH-SHELL_MARGIN_X, pgf_text_width(fileinfo->strLength)), y, AUDIO_TIME_TOTAL, fileinfo->strLength);
float length = SCREEN_WIDTH - 3.0f * SHELL_MARGIN_X - cover_size;
vita2d_draw_rectangle(x, (y) + FONT_Y_SPACE + 10.0f, length, 8, AUDIO_TIME_BAR_BG);

View File

@ -111,7 +111,7 @@ void drawContextMenu() {
color = INVISIBLE_COLOR;
// Draw entry text
pgf_draw_text(SCREEN_WIDTH - ctx_cur_menu_width + CONTEXT_MENU_MARGIN, y, color, FONT_SIZE, language_container[ctx->entries[i].name]);
pgf_draw_text(SCREEN_WIDTH - ctx_cur_menu_width + CONTEXT_MENU_MARGIN, y, color, language_container[ctx->entries[i].name]);
// Draw arrow for 'More'
if (ctx->entries[i].more) {
@ -124,11 +124,13 @@ void drawContextMenu() {
}
}
pgf_draw_text(SCREEN_WIDTH - ctx_cur_menu_width + ctx->max_width - vita2d_pgf_text_width(font, FONT_SIZE, arrow) - CONTEXT_MENU_MARGIN, y, color, FONT_SIZE, arrow);
pgf_draw_text(SCREEN_WIDTH - ctx_cur_menu_width + ctx->max_width - pgf_text_width(arrow) - CONTEXT_MENU_MARGIN, y, color, arrow);
}
}
if (ctx_menu_mode == CONTEXT_MENU_MORE_CLOSING || ctx_menu_mode == CONTEXT_MENU_MORE_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENING) {
if (ctx_menu_mode == CONTEXT_MENU_MORE_CLOSING ||
ctx_menu_mode == CONTEXT_MENU_MORE_OPENED ||
ctx_menu_mode == CONTEXT_MENU_MORE_OPENING) {
for (i = 0; i < cur_ctx->n_entries; i++) {
float y = START_Y + (cur_ctx->entries[i].pos * FONT_Y_SPACE);
@ -144,7 +146,7 @@ void drawContextMenu() {
color = INVISIBLE_COLOR;
// Draw entry text
pgf_draw_text(SCREEN_WIDTH - ctx_cur_menu_width + ctx->max_width + CONTEXT_MENU_MARGIN, y, color, FONT_SIZE, language_container[cur_ctx->entries[i].name]);
pgf_draw_text(SCREEN_WIDTH - ctx_cur_menu_width + ctx->max_width + CONTEXT_MENU_MARGIN, y, color, language_container[cur_ctx->entries[i].name]);
}
}
}

View File

@ -279,36 +279,36 @@ int coredumpViewer(const char *file) {
float y = START_Y;
// Exception
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, FONT_SIZE, "Exception");
pgf_draw_text(COREDUMP_INFO_X, y, TEXT_COLOR, FONT_SIZE, getCauseName(cause));
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, "Exception");
pgf_draw_text(COREDUMP_INFO_X, y, TEXT_COLOR, getCauseName(cause));
y += FONT_Y_SPACE;
// Thread ID
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, FONT_SIZE, "Thread ID");
pgf_draw_textf(COREDUMP_INFO_X, y, TEXT_COLOR, FONT_SIZE, "0x%08X", thid);
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, "Thread ID");
pgf_draw_textf(COREDUMP_INFO_X, y, TEXT_COLOR, "0x%08X", thid);
y += FONT_Y_SPACE;
// Thread name
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, FONT_SIZE, "Thread name");
pgf_draw_text(COREDUMP_INFO_X, y, TEXT_COLOR, FONT_SIZE, thname);
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, "Thread name");
pgf_draw_text(COREDUMP_INFO_X, y, TEXT_COLOR, thname);
y += FONT_Y_SPACE;
// EPC
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, FONT_SIZE, "EPC");
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, "EPC");
if (rel_epc != -1)
pgf_draw_textf(COREDUMP_INFO_X, y, TEXT_COLOR, FONT_SIZE, "%s + 0x%08X", modname, rel_epc);
pgf_draw_textf(COREDUMP_INFO_X, y, TEXT_COLOR, "%s + 0x%08X", modname, rel_epc);
else
pgf_draw_textf(COREDUMP_INFO_X, y, TEXT_COLOR, FONT_SIZE, "0x%08X", epc);
pgf_draw_textf(COREDUMP_INFO_X, y, TEXT_COLOR, "0x%08X", epc);
y += FONT_Y_SPACE;
// Cause
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, FONT_SIZE, "Cause");
pgf_draw_textf(COREDUMP_INFO_X, y, TEXT_COLOR, FONT_SIZE, "0x%08X", cause);
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, "Cause");
pgf_draw_textf(COREDUMP_INFO_X, y, TEXT_COLOR, "0x%08X", cause);
y += FONT_Y_SPACE;
// BadVAddr
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, FONT_SIZE, "BadVAddr");
pgf_draw_textf(COREDUMP_INFO_X, y, TEXT_COLOR, FONT_SIZE, "0x%08X", bad_v_addr);
pgf_draw_text(SHELL_MARGIN_X, y, TEXT_COLOR, "BadVAddr");
pgf_draw_textf(COREDUMP_INFO_X, y, TEXT_COLOR, "0x%08X", bad_v_addr);
y += FONT_Y_SPACE;
// Registers
@ -318,10 +318,10 @@ int coredumpViewer(const char *file) {
int i;
for (i = 0; i < 4; i++) {
pgf_draw_textf(x, y, TEXT_COLOR, FONT_SIZE, "%s:", regnames[j * 4 + i]);
pgf_draw_textf(x, y, TEXT_COLOR, "%s:", regnames[j * 4 + i]);
x += COREDUMP_REGISTER_NAME_SPACE;
pgf_draw_textf(x, y, TEXT_COLOR, FONT_SIZE, "0x%08X", regs[j * 4 + i]);
pgf_draw_textf(x, y, TEXT_COLOR, "0x%08X", regs[j * 4 + i]);
x += COREDUMP_REGISTER_SPACE;
}

14
hex.c
View File

@ -308,14 +308,14 @@ int hexViewer(const char *file) {
drawScrollBar(pos, n_lines);
// Offset/size
pgf_draw_textf(HEX_CHAR_X, START_Y, HEX_OFFSET_COLOR, FONT_SIZE, "%08X/%08X", rel_pos+base_pos, size);
pgf_draw_textf(HEX_CHAR_X, START_Y, HEX_OFFSET_COLOR, "%08X/%08X", rel_pos+base_pos, size);
// Offset x
pgf_draw_text(SHELL_MARGIN_X, START_Y, HEX_OFFSET_COLOR, FONT_SIZE, language_container[OFFSET]);
pgf_draw_text(SHELL_MARGIN_X, START_Y, HEX_OFFSET_COLOR, language_container[OFFSET]);
int x;
for (x = 0; x < 0x10; x++) {
pgf_draw_textf(HEX_OFFSET_X + (x * HEX_OFFSET_SPACE), START_Y, HEX_OFFSET_COLOR, FONT_SIZE, "%02X", x);
pgf_draw_textf(HEX_OFFSET_X + (x * HEX_OFFSET_SPACE), START_Y, HEX_OFFSET_COLOR, "%02X", x);
}
HexListEntry *entry = list.head;
@ -343,19 +343,19 @@ int hexViewer(const char *file) {
// Character hex
uint8_t high_nibble = (ch >> 4) & 0xF;
uint8_t low_nibble = ch & 0xF;
int w = pgf_draw_textf(HEX_OFFSET_X + (x * HEX_OFFSET_SPACE), START_Y + ((y + 1) * FONT_Y_SPACE), (on_line && nibble_x == nibble_pos) ? HEX_NIBBLE_COLOR : color, FONT_SIZE, "%01X", high_nibble);
pgf_draw_textf(HEX_OFFSET_X + (x * HEX_OFFSET_SPACE) + w, START_Y + ((y + 1) * FONT_Y_SPACE), (on_line && (nibble_x + 1) == nibble_pos) ? HEX_NIBBLE_COLOR : color, FONT_SIZE, "%01X", low_nibble);
int w = pgf_draw_textf(HEX_OFFSET_X + (x * HEX_OFFSET_SPACE), START_Y + ((y + 1) * FONT_Y_SPACE), (on_line && nibble_x == nibble_pos) ? HEX_NIBBLE_COLOR : color, "%01X", high_nibble);
pgf_draw_textf(HEX_OFFSET_X + (x * HEX_OFFSET_SPACE) + w, START_Y + ((y + 1) * FONT_Y_SPACE), (on_line && (nibble_x + 1) == nibble_pos) ? HEX_NIBBLE_COLOR : color, "%01X", low_nibble);
// Character
ch = (ch >= 0x20) ? ch : '.';
int width = font_size_cache[(int)ch];
uint8_t byte_nibble_pos = nibble_pos - (nibble_pos % 2);
pgf_draw_textf(HEX_CHAR_X + (x * FONT_X_SPACE) + (FONT_X_SPACE - width) / 2.0f, START_Y + ((y + 1) * FONT_Y_SPACE), (on_line && nibble_x == byte_nibble_pos) ? HEX_NIBBLE_COLOR : color, FONT_SIZE, "%c", ch);
pgf_draw_textf(HEX_CHAR_X + (x * FONT_X_SPACE) + (FONT_X_SPACE - width) / 2.0f, START_Y + ((y + 1) * FONT_Y_SPACE), (on_line && nibble_x == byte_nibble_pos) ? HEX_NIBBLE_COLOR : color, "%c", ch);
}
// Offset y
if (x > 0)
pgf_draw_textf(SHELL_MARGIN_X, START_Y + ((y + 1) * FONT_Y_SPACE), HEX_OFFSET_COLOR, FONT_SIZE, "%08X", base_pos + (y * 0x10));
pgf_draw_textf(SHELL_MARGIN_X, START_Y + ((y + 1) * FONT_Y_SPACE), HEX_OFFSET_COLOR, "%08X", base_pos + (y * 0x10));
// It's the end, break
if (x < 0x10)

48
main.c
View File

@ -221,7 +221,9 @@ int refreshFileList() {
dirUp();
}
} while (res < 0);
// TODO: make better position correction
// Correct position after deleting the latest entry of the file list
while ((base_pos + rel_pos) >= file_list.length) {
if (base_pos > 0) {
@ -240,7 +242,7 @@ int refreshFileList() {
}
}
}
return ret;
}
@ -383,7 +385,7 @@ void drawShellInfo(const char *path) {
if (version[3] == '0')
version[3] = '\0';
pgf_draw_textf(SHELL_MARGIN_X, SHELL_MARGIN_Y, TITLE_COLOR, FONT_SIZE, "VitaShell %s", version);
pgf_draw_textf(SHELL_MARGIN_X, SHELL_MARGIN_Y, TITLE_COLOR, "VitaShell %s", version);
// Status bar
float x = SCREEN_WIDTH - SHELL_MARGIN_X;
@ -425,8 +427,8 @@ void drawShellInfo(const char *path) {
char string[64];
snprintf(string, sizeof(string), "%s %s", date_string, time_string);
float date_time_x = ALIGN_RIGHT(x, vita2d_pgf_text_width(font, FONT_SIZE, string));
pgf_draw_text(date_time_x, SHELL_MARGIN_Y, DATE_TIME_COLOR, FONT_SIZE, string);
float date_time_x = ALIGN_RIGHT(x, pgf_text_width(string));
pgf_draw_text(date_time_x, SHELL_MARGIN_Y, DATE_TIME_COLOR, string);
x = date_time_x - STATUS_BAR_SPACE_X;
@ -447,7 +449,7 @@ void drawShellInfo(const char *path) {
char ch_width = font_size_cache[(int)path[i]];
// Too long
if ((line_width+ch_width) >= MAX_WIDTH)
if ((line_width + ch_width) >= MAX_WIDTH)
break;
// Increase line width
@ -463,12 +465,12 @@ void drawShellInfo(const char *path) {
// home (SAFE/UNSAFE MODE)
if (strcmp(path_first_line, HOME_PATH) == 0) {
pgf_draw_textf(SHELL_MARGIN_X, PATH_Y, PATH_COLOR, FONT_SIZE, "%s (%s)", HOME_PATH,
is_safe_mode ? language_container[SAFE_MODE] : language_container[UNSAFE_MODE]);
pgf_draw_textf(SHELL_MARGIN_X, PATH_Y, PATH_COLOR, "%s (%s)", HOME_PATH,
is_safe_mode ? language_container[SAFE_MODE] : language_container[UNSAFE_MODE]);
} else {
// Path
pgf_draw_text(SHELL_MARGIN_X, PATH_Y, PATH_COLOR, FONT_SIZE, path_first_line);
pgf_draw_text(SHELL_MARGIN_X, PATH_Y + FONT_Y_SPACE, PATH_COLOR, FONT_SIZE, path_second_line);
pgf_draw_text(SHELL_MARGIN_X, PATH_Y, PATH_COLOR, path_first_line);
pgf_draw_text(SHELL_MARGIN_X, PATH_Y + FONT_Y_SPACE, PATH_COLOR, path_second_line);
}
}
@ -1417,7 +1419,7 @@ static int fileBrowserMenuCtrl() {
int type = handleFile(cur_file, file_entry);
// Archive mode
if ((type == FILE_TYPE_ZIP) | (type == FILE_TYPE_RAR)) {
if ((type == FILE_TYPE_ZIP) || (type == FILE_TYPE_RAR)) {
is_in_archive = 1;
archive_type = type;
dir_level_archive = dir_level;
@ -1621,7 +1623,7 @@ static int shellMain() {
float x = FILE_X;
if (i == rel_pos) {
int width = (int)vita2d_pgf_text_width(font, FONT_SIZE, file_entry->name);
int width = (int)pgf_text_width(file_entry->name);
if (width >= MAX_NAME_WIDTH) {
if (scroll_count < 60) {
scroll_x = x;
@ -1640,7 +1642,7 @@ static int shellMain() {
}
}
pgf_draw_text(x, y, color, FONT_SIZE, file_entry->name);
pgf_draw_text(x, y, color, file_entry->name);
vita2d_disable_clipping();
@ -1648,8 +1650,8 @@ static int shellMain() {
if (strcmp(file_entry->name, DIR_UP) != 0) {
if (dir_level == 0) {
char used_size_string[16], max_size_string[16];
int max_size_x = ALIGN_RIGHT(INFORMATION_X, vita2d_pgf_text_width(font, FONT_SIZE, "0000.00 MB"));
int separator_x = ALIGN_RIGHT(max_size_x, vita2d_pgf_text_width(font, FONT_SIZE, " / "));
int max_size_x = ALIGN_RIGHT(INFORMATION_X, pgf_text_width("0000.00 MB"));
int separator_x = ALIGN_RIGHT(max_size_x, pgf_text_width(" / "));
if (file_entry->size != 0 && file_entry->size2 != 0) {
getSizeString(used_size_string, file_entry->size2 - file_entry->size);
getSizeString(max_size_string, file_entry->size2);
@ -1658,11 +1660,11 @@ static int shellMain() {
strcpy(max_size_string, "-");
}
float x = ALIGN_RIGHT(INFORMATION_X, vita2d_pgf_text_width(font, FONT_SIZE, max_size_string));
pgf_draw_text(x, y, color, FONT_SIZE, max_size_string);
pgf_draw_text(separator_x, y, color, FONT_SIZE, " /");
x = ALIGN_RIGHT(separator_x, vita2d_pgf_text_width(font, FONT_SIZE, used_size_string));
pgf_draw_text(x, y, color, FONT_SIZE, used_size_string);
float x = ALIGN_RIGHT(INFORMATION_X, pgf_text_width(max_size_string));
pgf_draw_text(x, y, color, max_size_string);
pgf_draw_text(separator_x, y, color, " /");
x = ALIGN_RIGHT(separator_x, pgf_text_width(used_size_string));
pgf_draw_text(x, y, color, used_size_string);
} else {
char *str = NULL;
if (!file_entry->is_folder) {
@ -1673,7 +1675,7 @@ static int shellMain() {
} else {
str = language_container[FOLDER];
}
pgf_draw_text(ALIGN_RIGHT(INFORMATION_X, vita2d_pgf_text_width(font, FONT_SIZE, str)), y, color, FONT_SIZE, str);
pgf_draw_text(ALIGN_RIGHT(INFORMATION_X, pgf_text_width(str)), y, color, str);
}
// Date
@ -1686,8 +1688,8 @@ static int shellMain() {
char string[64];
sprintf(string, "%s %s", date_string, time_string);
float x = ALIGN_RIGHT(SCREEN_WIDTH-SHELL_MARGIN_X, vita2d_pgf_text_width(font, FONT_SIZE, string));
pgf_draw_text(x, y, color, FONT_SIZE, string);
float x = ALIGN_RIGHT(SCREEN_WIDTH-SHELL_MARGIN_X, pgf_text_width(string));
pgf_draw_text(x, y, color, string);
}
// Next

11
main.h
View File

@ -105,12 +105,15 @@
#define FONT_X_SPACE 15.0f
#define FONT_Y_SPACE 23.0f
#define pgf_draw_text(x, y, color, scale, text) \
vita2d_pgf_draw_text(font, x, (y)+20, color, scale, text)
#define pgf_draw_text(x, y, color, text) \
vita2d_pgf_draw_text(font, x, (y)+20, color, FONT_SIZE, text)
#define pgf_draw_textf(x, y, color, scale, ...) \
vita2d_pgf_draw_textf(font, x, (y)+20, color, scale, __VA_ARGS__)
#define pgf_draw_textf(x, y, color, ...) \
vita2d_pgf_draw_textf(font, x, (y)+20, color, FONT_SIZE, __VA_ARGS__)
#define pgf_text_width(text) \
vita2d_pgf_text_width(font, FONT_SIZE, text)
// Screen
#define SCREEN_WIDTH 960
#define SCREEN_HEIGHT 544

View File

@ -176,7 +176,7 @@ void initContextMenuWidth() {
// Home
for (i = 0; i < N_MENU_HOME_ENTRIES; i++) {
context_menu_home.max_width = MAX(context_menu_home.max_width, vita2d_pgf_text_width(font, FONT_SIZE, language_container[menu_home_entries[i].name]));
context_menu_home.max_width = MAX(context_menu_home.max_width, pgf_text_width(language_container[menu_home_entries[i].name]));
}
context_menu_home.max_width += 2.0f * CONTEXT_MENU_MARGIN;
@ -184,7 +184,7 @@ void initContextMenuWidth() {
// Main
for (i = 0; i < N_MENU_MAIN_ENTRIES; i++) {
context_menu_main.max_width = MAX(context_menu_main.max_width, vita2d_pgf_text_width(font, FONT_SIZE, language_container[menu_main_entries[i].name]));
context_menu_main.max_width = MAX(context_menu_main.max_width, pgf_text_width(language_container[menu_main_entries[i].name]));
if (menu_main_entries[i].name == MARK_ALL) {
menu_main_entries[i].name = UNMARK_ALL;
@ -197,7 +197,7 @@ void initContextMenuWidth() {
// Sort
for (i = 0; i < N_MENU_SORT_ENTRIES; i++) {
context_menu_sort.max_width = MAX(context_menu_sort.max_width, vita2d_pgf_text_width(font, FONT_SIZE, language_container[menu_sort_entries[i].name]));
context_menu_sort.max_width = MAX(context_menu_sort.max_width, pgf_text_width(language_container[menu_sort_entries[i].name]));
}
context_menu_sort.max_width += 2.0f * CONTEXT_MENU_MARGIN;
@ -205,7 +205,7 @@ void initContextMenuWidth() {
// More
for (i = 0; i < N_MENU_MORE_ENTRIES; i++) {
context_menu_more.max_width = MAX(context_menu_more.max_width, vita2d_pgf_text_width(font, FONT_SIZE, language_container[menu_more_entries[i].name]));
context_menu_more.max_width = MAX(context_menu_more.max_width, pgf_text_width(language_container[menu_more_entries[i].name]));
}
context_menu_more.max_width += 2.0f * CONTEXT_MENU_MARGIN;

View File

@ -361,7 +361,7 @@ int photoViewer(const char *file, int type, FileList *list, FileListEntry *entry
// Zoom text
if ((sceKernelGetProcessTimeWide() - time) < ZOOM_TEXT_TIME)
pgf_draw_textf(SHELL_MARGIN_X, SCREEN_HEIGHT - 3.0f * SHELL_MARGIN_Y, PHOTO_ZOOM_COLOR, FONT_SIZE, "%.0f%%", zoom * 100.0f);
pgf_draw_textf(SHELL_MARGIN_X, SCREEN_HEIGHT - 3.0f * SHELL_MARGIN_Y, PHOTO_ZOOM_COLOR, "%.0f%%", zoom * 100.0f);
// End drawing
endDrawing();

View File

@ -92,7 +92,7 @@ int getPropertyDialogStatus() {
static float copyStringGetWidth(char *out, char *in) {
strcpy(out, in);
return vita2d_pgf_text_width(font, FONT_SIZE, out);
return pgf_text_width(out);
}
typedef struct {
@ -159,7 +159,7 @@ int initPropertyDialog(char *path, FileListEntry *entry) {
for (i = 0; i < N_PROPERTIES_ENTRIES; i++) {
if (property_entries[i].name != -1) {
float width = vita2d_pgf_text_width(font, FONT_SIZE, language_container[property_entries[i].name]);
float width = pgf_text_width(language_container[property_entries[i].name]);
if (width > property_dialog.info_x)
property_dialog.info_x = width;
@ -433,7 +433,7 @@ void drawPropertyDialog() {
int i;
for (i = 0; i < N_PROPERTIES_ENTRIES; i++) {
if (property_entries[i].visibility == PROPERTY_ENTRY_VISIBLE) {
pgf_draw_text(property_dialog.x + SHELL_MARGIN_X, string_y, DIALOG_COLOR, FONT_SIZE, language_container[property_entries[i].name]);
pgf_draw_text(property_dialog.x + SHELL_MARGIN_X, string_y, DIALOG_COLOR, language_container[property_entries[i].name]);
if (property_entries[i].entry != NULL) {
uint32_t color = DIALOG_COLOR;
@ -445,7 +445,7 @@ void drawPropertyDialog() {
vita2d_set_clip_rectangle(x + 1.0f, string_y, x + 1.0f + max_width, string_y + FONT_Y_SPACE);
if (property_entries[i].name == PROPERTY_NAME) {
int width = (int)vita2d_pgf_text_width(font, FONT_SIZE, property_entries[i].entry);
int width = (int)pgf_text_width(property_entries[i].entry);
if (width >= max_width) {
if (scroll_count < 60) {
scroll_x = x;
@ -464,7 +464,7 @@ void drawPropertyDialog() {
}
}
pgf_draw_text(x, string_y, color, FONT_SIZE, property_entries[i].entry);
pgf_draw_text(x, string_y, color, property_entries[i].entry);
vita2d_disable_clipping();
}
@ -476,6 +476,6 @@ void drawPropertyDialog() {
char button_string[32];
sprintf(button_string, "%s %s", enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE ? CIRCLE : CROSS, language_container[OK]);
pgf_draw_text(ALIGN_CENTER(SCREEN_WIDTH, vita2d_pgf_text_width(font, FONT_SIZE, button_string)), string_y + FONT_Y_SPACE, DIALOG_COLOR, FONT_SIZE, button_string);
pgf_draw_text(ALIGN_CENTER(SCREEN_WIDTH, pgf_text_width(button_string)), string_y + FONT_Y_SPACE, DIALOG_COLOR, button_string);
}
}

6
qr.c
View File

@ -101,7 +101,7 @@ int qr_thread() {
}
int qr_scan_thread(SceSize args, void *argp) {
data = strdup(last_qr);
data = last_qr;
if (last_qr_len > 4) {
if (!(data[0] == 'h' && data[1] == 't' && data[2] == 't' && data[3] == 'p')) {
initMessageDialog(SCE_MSG_DIALOG_BUTTON_TYPE_OK, language_container[QR_SHOW_CONTENTS], data);
@ -126,11 +126,11 @@ int qr_scan_thread(SceSize args, void *argp) {
char sizeString[16];
int ret;
ret = getDownloadFileSize(strdup(data), &fileSize);
ret = getDownloadFileSize(data, &fileSize);
if (ret < 0)
goto NETWORK_FAILURE;
ret = getFieldFromHeader(strdup(data), "Content-Disposition", &headerData, &headerLen);
ret = getFieldFromHeader(data, "Content-Disposition", &headerData, &headerLen);
if (ret < 0)
goto NETWORK_FAILURE;

View File

@ -249,8 +249,8 @@ void drawSettingsMenu() {
int i;
for (i = 0; i < n_settings_entries; i++) {
// Title
float x = vita2d_pgf_text_width(font, FONT_SIZE, language_container[settings_menu_entries[i].name]);
pgf_draw_text(ALIGN_CENTER(SCREEN_WIDTH, x), y, SETTINGS_MENU_TITLE_COLOR, FONT_SIZE, language_container[settings_menu_entries[i].name]);
float x = pgf_text_width(language_container[settings_menu_entries[i].name]);
pgf_draw_text(ALIGN_CENTER(SCREEN_WIDTH, x), y, SETTINGS_MENU_TITLE_COLOR, language_container[settings_menu_entries[i].name]);
y += FONT_Y_SPACE;
@ -264,22 +264,22 @@ void drawSettingsMenu() {
if (options[j].type == SETTINGS_OPTION_TYPE_CALLBACK) {
// Item
float x = vita2d_pgf_text_width(font, FONT_SIZE, language_container[options[j].name]);
pgf_draw_text(ALIGN_CENTER(SCREEN_WIDTH, x), y, SETTINGS_MENU_ITEM_COLOR, FONT_SIZE, language_container[options[j].name]);
float x = pgf_text_width(language_container[options[j].name]);
pgf_draw_text(ALIGN_CENTER(SCREEN_WIDTH, x), y, SETTINGS_MENU_ITEM_COLOR, language_container[options[j].name]);
} else {
// Item
float x = vita2d_pgf_text_width(font, FONT_SIZE, language_container[options[j].name]);
pgf_draw_text(ALIGN_RIGHT(SCREEN_HALF_WIDTH - 10.0f, x), y, SETTINGS_MENU_ITEM_COLOR, FONT_SIZE, language_container[options[j].name]);
float x = pgf_text_width(language_container[options[j].name]);
pgf_draw_text(ALIGN_RIGHT(SCREEN_HALF_WIDTH - 10.0f, x), y, SETTINGS_MENU_ITEM_COLOR, language_container[options[j].name]);
// Option
switch (options[j].type) {
case SETTINGS_OPTION_TYPE_BOOLEAN:
pgf_draw_text(SCREEN_HALF_WIDTH + 10.0f, y, SETTINGS_MENU_OPTION_COLOR, FONT_SIZE,
pgf_draw_text(SCREEN_HALF_WIDTH + 10.0f, y, SETTINGS_MENU_OPTION_COLOR,
(options[j].value && *(options[j].value)) ? language_container[ON] : language_container[OFF]);
break;
case SETTINGS_OPTION_TYPE_STRING:
pgf_draw_text(SCREEN_HALF_WIDTH + 10.0f, y, SETTINGS_MENU_OPTION_COLOR, FONT_SIZE, options[j].string);
pgf_draw_text(SCREEN_HALF_WIDTH + 10.0f, y, SETTINGS_MENU_OPTION_COLOR, options[j].string);
break;
case SETTINGS_OPTION_TYPE_OPTIONS:
@ -287,7 +287,7 @@ void drawSettingsMenu() {
int value = 0;
if (options[j].value)
value = *(options[j].value);
pgf_draw_text(SCREEN_HALF_WIDTH + 10.0f, y, SETTINGS_MENU_OPTION_COLOR, FONT_SIZE, options[j].options ? options[j].options[value] : "");
pgf_draw_text(SCREEN_HALF_WIDTH + 10.0f, y, SETTINGS_MENU_OPTION_COLOR, options[j].options ? options[j].options[value] : "");
break;
}
}

4
sfo.c
View File

@ -176,7 +176,7 @@ int SFOReader(const char *file) {
uint32_t color = (rel_pos == i) ? TEXT_FOCUS_COLOR : TEXT_COLOR;
char *name = (char *)buffer + sfo_header->keyofs + entries->nameofs;
pgf_draw_textf(SHELL_MARGIN_X, START_Y + (FONT_Y_SPACE * i), color, FONT_SIZE, "%s", name);
pgf_draw_textf(SHELL_MARGIN_X, START_Y + (FONT_Y_SPACE * i), color, "%s", name);
char string[128];
@ -194,7 +194,7 @@ int SFOReader(const char *file) {
break;
}
pgf_draw_textf(ALIGN_RIGHT(INFORMATION_X, vita2d_pgf_text_width(font, FONT_SIZE, string)), START_Y + (FONT_Y_SPACE * i), color, FONT_SIZE, string);
pgf_draw_textf(ALIGN_RIGHT(INFORMATION_X, pgf_text_width(string)), START_Y + (FONT_Y_SPACE * i), color, string);
}
// End drawing

8
text.c
View File

@ -104,7 +104,7 @@ typedef struct CountParams {
void initTextContextMenuWidth() {
int i;
for (i = 0; i < N_TEXT_MENU_ENTRIES; i++) {
context_menu_text.max_width = MAX(context_menu_text.max_width, vita2d_pgf_text_width(font, FONT_SIZE, language_container[text_menu_entries[i].name]));
context_menu_text.max_width = MAX(context_menu_text.max_width, pgf_text_width(language_container[text_menu_entries[i].name]));
}
context_menu_text.max_width += 2.0f * CONTEXT_MENU_MARGIN;
@ -961,7 +961,7 @@ int textViewer(const char *file) {
snprintf(line_str, 5, "%04i", entry->line_number);
int color = (s->rel_pos == i) ? TEXT_LINE_NUMBER_COLOR_FOCUS : TEXT_LINE_NUMBER_COLOR;
pgf_draw_text(SHELL_MARGIN_X, START_Y + (i * FONT_Y_SPACE), color, FONT_SIZE, line_str);
pgf_draw_text(SHELL_MARGIN_X, START_Y + (i * FONT_Y_SPACE), color, line_str);
}
float x = TEXT_START_X;
@ -987,7 +987,7 @@ int textViewer(const char *file) {
*search_highlight = '\0';
}
int width = pgf_draw_text(x, START_Y + (i * FONT_Y_SPACE), (s->rel_pos == i) ? TEXT_FOCUS_COLOR : TEXT_COLOR, FONT_SIZE, line);
int width = pgf_draw_text(x, START_Y + (i * FONT_Y_SPACE), (s->rel_pos == i) ? TEXT_FOCUS_COLOR : TEXT_COLOR, line);
line += strlen(line);
@ -1005,7 +1005,7 @@ int textViewer(const char *file) {
search_highlight[search_term_length] = '\0';
x += width;
x += pgf_draw_text(x, START_Y + (i * FONT_Y_SPACE), TEXT_HIGHLIGHT_COLOR, FONT_SIZE, line);
x += pgf_draw_text(x, START_Y + (i * FONT_Y_SPACE), TEXT_HIGHLIGHT_COLOR, line);
search_highlight[search_term_length] = tmp;
line += strlen(s->search_term);

View File

@ -326,6 +326,6 @@ void loadTheme() {
character[0] = i;
character[1] = '\0';
font_size_cache[i] = vita2d_pgf_text_width(font, FONT_SIZE, character);
font_size_cache[i] = pgf_text_width(character);
}
}

View File

@ -56,7 +56,7 @@ static void calculateDialogBoxSize() {
if (uncommon_dialog.msg[i] == '\n') {
uncommon_dialog.msg[i] = '\0';
float width = vita2d_pgf_text_width(font, FONT_SIZE, string);
float width = pgf_text_width(string);
if (width > uncommon_dialog.width)
uncommon_dialog.width = width;
@ -66,14 +66,14 @@ static void calculateDialogBoxSize() {
}
if (uncommon_dialog.msg[i] == '\0') {
float width = vita2d_pgf_text_width(font, FONT_SIZE, string);
float width = pgf_text_width(string);
if (width > uncommon_dialog.width)
uncommon_dialog.width = width;
}
char tmp = uncommon_dialog.msg[i + 1];
uncommon_dialog.msg[i + 1] = '\0';
text_width = vita2d_pgf_text_width(font, FONT_SIZE, uncommon_dialog.msg);
text_width = pgf_text_width(uncommon_dialog.msg);
uncommon_dialog.msg[i + 1] = tmp;
if (text_width > UNCOMMON_DIALOG_MAX_WIDTH) {
@ -308,8 +308,8 @@ int drawUncommonDialog() {
// Draw info
if (uncommon_dialog.info[0] != '\0') {
float x = ALIGN_RIGHT(uncommon_dialog.x+uncommon_dialog.width-SHELL_MARGIN_X, vita2d_pgf_text_width(font, FONT_SIZE, uncommon_dialog.info));
pgf_draw_text(x, string_y, DIALOG_COLOR, FONT_SIZE, uncommon_dialog.info);
float x = ALIGN_RIGHT(uncommon_dialog.x+uncommon_dialog.width-SHELL_MARGIN_X, pgf_text_width(uncommon_dialog.info));
pgf_draw_text(x, string_y, DIALOG_COLOR, uncommon_dialog.info);
}
// Draw message
@ -320,7 +320,7 @@ int drawUncommonDialog() {
for (i = 0; i < len + 1; i++) {
if (uncommon_dialog.msg[i] == '\n') {
uncommon_dialog.msg[i] = '\0';
pgf_draw_text(uncommon_dialog.x + SHELL_MARGIN_X, string_y, DIALOG_COLOR, FONT_SIZE, string);
pgf_draw_text(uncommon_dialog.x + SHELL_MARGIN_X, string_y, DIALOG_COLOR, string);
uncommon_dialog.msg[i] = '\n';
string = uncommon_dialog.msg+i + 1;
@ -328,7 +328,7 @@ int drawUncommonDialog() {
}
if (uncommon_dialog.msg[i] == '\0') {
pgf_draw_text(uncommon_dialog.x + SHELL_MARGIN_X, string_y, DIALOG_COLOR, FONT_SIZE, string);
pgf_draw_text(uncommon_dialog.x + SHELL_MARGIN_X, string_y, DIALOG_COLOR, string);
string_y += FONT_Y_SPACE;
}
}
@ -365,7 +365,7 @@ int drawUncommonDialog() {
char string[8];
sprintf(string, "%d%%", uncommon_dialog.progress);
pgf_draw_text(ALIGN_CENTER(SCREEN_WIDTH, vita2d_pgf_text_width(font, FONT_SIZE, string)), string_y + FONT_Y_SPACE, DIALOG_COLOR, FONT_SIZE, string);
pgf_draw_text(ALIGN_CENTER(SCREEN_WIDTH, pgf_text_width(string)), string_y + FONT_Y_SPACE, DIALOG_COLOR, string);
string_y += 2.0f * FONT_Y_SPACE;
}
@ -380,7 +380,7 @@ int drawUncommonDialog() {
case SCE_MSG_DIALOG_BUTTON_TYPE_YESNO:
case SCE_MSG_DIALOG_BUTTON_TYPE_OK_CANCEL:
case SCE_MSG_DIALOG_BUTTON_TYPE_CANCEL:
pgf_draw_text(ALIGN_CENTER(SCREEN_WIDTH, vita2d_pgf_text_width(font, FONT_SIZE, button_string)), string_y + FONT_Y_SPACE, DIALOG_COLOR, FONT_SIZE, button_string);
pgf_draw_text(ALIGN_CENTER(SCREEN_WIDTH, pgf_text_width(button_string)), string_y + FONT_Y_SPACE, DIALOG_COLOR, button_string);
break;
}
}