void drawListDialog() { if (is_open == LIST_DIALOG_CLOSE) return; // Dialog background vita2d_draw_texture_scale_rotate_hotspot(dialog_image, list_dialog.x + list_dialog.width / 2.0f, list_dialog.y + list_dialog.height / 2.0f, list_dialog.scale * (list_dialog.width / vita2d_texture_get_width(dialog_image)), list_dialog.scale * (list_dialog.height / vita2d_texture_get_height(dialog_image)), 0.0f, vita2d_texture_get_width(dialog_image) / 2.0f, vita2d_texture_get_height(dialog_image) / 2.0f); // Easing out if (list_dialog.animation_mode == LIST_DIALOG_CLOSING) { if (list_dialog.scale > 0.0f) { list_dialog.scale -= easeOut3(0.0f, list_dialog.scale, 0.25f); } else { list_dialog.animation_mode = LIST_DIALOG_CLOSED; list_dialog.status = SCE_COMMON_DIALOG_STATUS_FINISHED; } } if (list_dialog.animation_mode == LIST_DIALOG_OPENING) { if (list_dialog.scale < 1.0f) { list_dialog.scale += easeOut3(list_dialog.scale, 1.0f, 0.25f); } else { list_dialog.animation_mode = LIST_DIALOG_OPENED; } } if (list_dialog.animation_mode == LIST_DIALOG_OPENED) { pgf_draw_text(list_dialog.x + ALIGN_CENTER(list_dialog.width, vita2d_pgf_text_width(font, FONT_SIZE, language_container[current_list->title])), list_dialog.y + FONT_Y_SPACE, TEXT_COLOR, FONT_SIZE, language_container[current_list->title]); int z; for (z = 0;z < LIST_MAX_ENTRY && (base_pos + z) < current_list->n_list_entries; z++) { uint32_t color = (rel_pos == z) ? TEXT_FOCUS_COLOR : TEXT_COLOR; pgf_draw_text(list_dialog.x + ALIGN_CENTER(list_dialog.width, vita2d_pgf_text_width(font, FONT_SIZE, language_container[current_list->list_entries[(z + base_pos)].name])), list_dialog.y + (FONT_Y_SPACE * 3) + (FONT_Y_SPACE * z), color, FONT_SIZE, language_container[current_list->list_entries[(z + base_pos)].name]); } int max_base_pos = current_list->n_list_entries - LIST_MAX_ENTRY; if (base_pos < max_base_pos && current_list->n_list_entries > LIST_MAX_ENTRY) { pgf_draw_text(list_dialog.x + ALIGN_CENTER(list_dialog.width, vita2d_pgf_text_width(font, FONT_SIZE, DOWN_ARROW)), list_dialog.y + (FONT_Y_SPACE * 3) + (FONT_Y_SPACE * max_entry_show), TEXT_COLOR, FONT_SIZE, DOWN_ARROW); } if (base_pos > 0 && current_list->n_list_entries > LIST_MAX_ENTRY) { pgf_draw_text(list_dialog.x + ALIGN_CENTER(list_dialog.width, vita2d_pgf_text_width(font, FONT_SIZE, UP_ARROW)), list_dialog.y + (FONT_Y_SPACE * 2), TEXT_COLOR, FONT_SIZE, UP_ARROW); } } else if (list_dialog.animation_mode == LIST_DIALOG_CLOSED) { if (list_dialog.enter_pressed) { if (current_list->listSelectCallback) current_list->listSelectCallback(base_pos + rel_pos); } is_open = LIST_DIALOG_CLOSE; } }
void drawContextMenu() { if (!cur_ctx) return; // Closing context menu if (ctx_menu_mode == CONTEXT_MENU_CLOSING) { if (ctx_cur_menu_width > 0.0f) { ctx_cur_menu_width -= easeOut(0.0f, ctx_cur_menu_width, 0.375f, 0.5f); } else { ctx_menu_mode = CONTEXT_MENU_CLOSED; } } // Opening context menu if (ctx_menu_mode == CONTEXT_MENU_OPENING) { if (ctx_cur_menu_width < cur_ctx->max_width) { ctx_cur_menu_width += easeOut(ctx_cur_menu_width, cur_ctx->max_width, 0.375f, 0.5f); } else { ctx_menu_mode = CONTEXT_MENU_OPENED; } } if (cur_ctx->parent) { // Closing context menu 'More' if (ctx_menu_mode == CONTEXT_MENU_MORE_CLOSING) { if (ctx_cur_menu_width > cur_ctx->parent->max_width) { ctx_cur_menu_width -= easeOut(cur_ctx->parent->max_width, ctx_cur_menu_width, 0.375f, 0.5f); } else { cur_ctx = cur_ctx->parent; ctx_menu_mode = CONTEXT_MENU_MORE_CLOSED; } } // Opening context menu 'More' if (ctx_menu_mode == CONTEXT_MENU_MORE_OPENING) { if (ctx_cur_menu_width < cur_ctx->max_width + cur_ctx->parent->max_width) { ctx_cur_menu_width += easeOut(ctx_cur_menu_width, cur_ctx->max_width+cur_ctx->parent->max_width, 0.375f, 0.5f); } else { ctx_menu_mode = CONTEXT_MENU_MORE_OPENED; } } } // Draw context menu if (ctx_menu_mode != CONTEXT_MENU_CLOSED) { if (!cur_ctx->parent) { vita2d_draw_texture_part(context_image, SCREEN_WIDTH - ctx_cur_menu_width, 0.0f, 0.0f, 0.0f, ctx_cur_menu_width, SCREEN_HEIGHT); } else { vita2d_draw_texture_part(context_image, SCREEN_WIDTH - ctx_cur_menu_width, 0.0f, 0.0f, 0.0f, cur_ctx->parent->max_width, SCREEN_HEIGHT); vita2d_draw_texture_part(context_more_image, SCREEN_WIDTH - ctx_cur_menu_width + cur_ctx->parent->max_width, 0.0f, 0.0f, 0.0f, cur_ctx->max_width, SCREEN_HEIGHT); } ContextMenu *ctx = cur_ctx; if (ctx->parent) ctx = ctx->parent; int i; for (i = 0; i < ctx->n_entries; i++) { float y = START_Y + (ctx->entries[i].pos * FONT_Y_SPACE); uint32_t color = CONTEXT_MENU_TEXT_COLOR; if (i == ctx->sel) { if (ctx_menu_mode != CONTEXT_MENU_MORE_OPENED && ctx_menu_mode != CONTEXT_MENU_MORE_OPENING) { color = CONTEXT_MENU_FOCUS_COLOR; } } if (ctx->entries[i].visibility == CTX_INVISIBLE) color = INVISIBLE_COLOR; // Draw entry text 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].flags & CTX_FLAG_MORE) { char *arrow = RIGHT_ARROW; if (ctx->sel == i) { if (ctx_menu_mode == CONTEXT_MENU_MORE_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENING) { arrow = LEFT_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) { for (i = 0; i < cur_ctx->n_entries; i++) { float y = START_Y + (cur_ctx->entries[i].pos * FONT_Y_SPACE); uint32_t color = CONTEXT_MENU_TEXT_COLOR; if (i == cur_ctx->sel) { if (ctx_menu_mode != CONTEXT_MENU_MORE_CLOSING) { color = CONTEXT_MENU_FOCUS_COLOR; } } if (cur_ctx->entries[i].visibility == CTX_INVISIBLE) color = INVISIBLE_COLOR; // Draw entry text pgf_draw_text(SCREEN_WIDTH - ctx_cur_menu_width + ctx->max_width + CONTEXT_MENU_MARGIN, y, color, language_container[cur_ctx->entries[i].name]); } } } }
void drawSettingsMenu() { if (settings_menu.status == SETTINGS_MENU_CLOSED) return; // Closing settings menu if (settings_menu.status == SETTINGS_MENU_CLOSING) { if (settings_menu.cur_pos > 0.0f) { settings_menu.cur_pos -= easeOut(0.0f, settings_menu.cur_pos, 0.25f, 0.01f); } else { settings_menu.status = SETTINGS_MENU_CLOSED; } } // Opening settings menu if (settings_menu.status == SETTINGS_MENU_OPENING) { if (settings_menu.cur_pos < SCREEN_HEIGHT) { settings_menu.cur_pos += easeOut(settings_menu.cur_pos, SCREEN_HEIGHT, 0.25f, 0.01f); } else { settings_menu.status = SETTINGS_MENU_OPENED; } } // Draw settings menu vita2d_draw_texture(settings_image, 0.0f, SCREEN_HEIGHT - settings_menu.cur_pos); float y = SCREEN_HEIGHT - settings_menu.cur_pos + START_Y; int i; for (i = 0; i < n_settings_entries; i++) { // Title 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; SettingsMenuOption *options = settings_menu_entries[i].options; int j; for (j = 0; j < settings_menu_entries[i].n_options; j++) { // Focus if (settings_menu.entry_sel == i && settings_menu.option_sel == j) vita2d_draw_rectangle(SHELL_MARGIN_X, y + 3.0f, MARK_WIDTH, FONT_Y_SPACE, SETTINGS_MENU_FOCUS_COLOR); if (options[j].type == SETTINGS_OPTION_TYPE_CALLBACK) { // Item 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 = 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, (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, options[j].string); break; case SETTINGS_OPTION_TYPE_OPTIONS: { int value = 0; if (options[j].value) value = *(options[j].value); pgf_draw_text(SCREEN_HALF_WIDTH + 10.0f, y, SETTINGS_MENU_OPTION_COLOR, options[j].options ? options[j].options[value] : ""); break; } } } y += FONT_Y_SPACE; } y += FONT_Y_SPACE; } }
int drawUncommonDialog() { if (uncommon_dialog.status == SCE_COMMON_DIALOG_STATUS_NONE) return 0; // Dialog background vita2d_draw_texture_scale_rotate_hotspot(dialog_image, uncommon_dialog.x + uncommon_dialog.width / 2.0f, uncommon_dialog.y + uncommon_dialog.height / 2.0f, uncommon_dialog.scale * (uncommon_dialog.width / vita2d_texture_get_width(dialog_image)), uncommon_dialog.scale * (uncommon_dialog.height / vita2d_texture_get_height(dialog_image)), 0.0f, vita2d_texture_get_width(dialog_image) / 2.0f, vita2d_texture_get_height(dialog_image) / 2.0f); // Easing out if (uncommon_dialog.dialog_status == UNCOMMON_DIALOG_CLOSING) { if (uncommon_dialog.scale > 0.0f) { uncommon_dialog.scale -= easeOut(0.0f, uncommon_dialog.scale, 0.25f); } else { uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSED; uncommon_dialog.status = SCE_COMMON_DIALOG_STATUS_FINISHED; } } if (uncommon_dialog.dialog_status == UNCOMMON_DIALOG_OPENING) { if (uncommon_dialog.scale < 1.0f) { uncommon_dialog.scale += easeOut(uncommon_dialog.scale, 1.0f, 0.25f); } else { uncommon_dialog.dialog_status = UNCOMMON_DIALOG_OPENED; } } if (uncommon_dialog.dialog_status == UNCOMMON_DIALOG_OPENED) { // Draw message float string_y = uncommon_dialog.y + SHELL_MARGIN_Y - 2.0f; int len = strlen(uncommon_dialog.msg); char *string = uncommon_dialog.msg; int i; 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); uncommon_dialog.msg[i] = '\n'; string = uncommon_dialog.msg + i + 1; string_y += FONT_Y_SPACE; } if (uncommon_dialog.msg[i] == '\0') { pgf_draw_text(uncommon_dialog.x + SHELL_MARGIN_X, string_y, DIALOG_COLOR, FONT_SIZE, string); string_y += FONT_Y_SPACE; } } // Dialog type char button_string[32]; switch (uncommon_dialog.buttonType) { case SCE_MSG_DIALOG_BUTTON_TYPE_OK: sprintf(button_string, "%s %s", enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE ? CIRCLE : CROSS, language_container[OK]); break; case SCE_MSG_DIALOG_BUTTON_TYPE_YESNO: sprintf(button_string, "%s %s %s %s", enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE ? CIRCLE : CROSS, language_container[YES], enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE ? CROSS : CIRCLE, language_container[NO]); break; case SCE_MSG_DIALOG_BUTTON_TYPE_OK_CANCEL: sprintf(button_string, "%s %s %s %s", enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE ? CIRCLE : CROSS, language_container[OK], enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE ? CROSS : CIRCLE, language_container[CANCEL]); break; case SCE_MSG_DIALOG_BUTTON_TYPE_CANCEL: sprintf(button_string, "%s %s", enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE ? CROSS : CIRCLE, language_container[CANCEL]); break; } // Progress bar if (uncommon_dialog.mode == SCE_MSG_DIALOG_MODE_PROGRESS_BAR) { float width = uncommon_dialog.width - 2.0f * SHELL_MARGIN_X; vita2d_draw_rectangle(uncommon_dialog.x + SHELL_MARGIN_X, string_y + 10.0f, width, UNCOMMON_DIALOG_PROGRESS_BAR_HEIGHT, PROGRESS_BAR_BG_COLOR); vita2d_draw_rectangle(uncommon_dialog.x + SHELL_MARGIN_X, string_y + 10.0f, uncommon_dialog.progress * width / 100.0f, UNCOMMON_DIALOG_PROGRESS_BAR_HEIGHT, PROGRESS_BAR_COLOR); 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); string_y += 2.0f * FONT_Y_SPACE; } switch (uncommon_dialog.buttonType) { case SCE_MSG_DIALOG_BUTTON_TYPE_OK: 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); break; } } return 0; }