Exemple #1
0
void calculateDialogBoxSize() {
	int len = strlen(uncommon_dialog.msg);
	char *string = uncommon_dialog.msg;

	// Get width and height
	uncommon_dialog.width = 0.0f;
	uncommon_dialog.height = 0.0f;

	int i;
	for (i = 0; i < len + 1; i++) {
		if (uncommon_dialog.msg[i] == '\n') {
			uncommon_dialog.msg[i] = '\0';

			float width = vita2d_pgf_text_width(font, FONT_SIZE, string);
			if (width > uncommon_dialog.width)
				uncommon_dialog.width = width;

			uncommon_dialog.msg[i] = '\n';

			string = uncommon_dialog.msg + i;
			uncommon_dialog.height += FONT_Y_SPACE;
		}

		if (uncommon_dialog.msg[i] == '\0') {
			float width = vita2d_pgf_text_width(font, FONT_SIZE, string);
			if (width > uncommon_dialog.width)
				uncommon_dialog.width = width;

			uncommon_dialog.height += FONT_Y_SPACE;
		}
	}

	// Margin
	uncommon_dialog.width += 2.0f * SHELL_MARGIN_X;
	uncommon_dialog.height += 2.0f * SHELL_MARGIN_Y;

	// Progress bar box width
	if (uncommon_dialog.mode == SCE_MSG_DIALOG_MODE_PROGRESS_BAR) {
		uncommon_dialog.width = UNCOMMON_DIALOG_PROGRESS_BAR_BOX_WIDTH;
		uncommon_dialog.height += 2.0f * FONT_Y_SPACE;
	}

	// More space for buttons
	if (uncommon_dialog.buttonType != SCE_MSG_DIALOG_BUTTON_TYPE_NONE)
		uncommon_dialog.height += 2.0f * FONT_Y_SPACE;

	// Position
	uncommon_dialog.x = ALIGN_CENTER(SCREEN_WIDTH, uncommon_dialog.width);
	uncommon_dialog.y = ALIGN_CENTER(SCREEN_HEIGHT, uncommon_dialog.height);

	// Align
	int y_n = (int)((float)(uncommon_dialog.y - 2.0f) / FONT_Y_SPACE);
	uncommon_dialog.y = (float)y_n * FONT_Y_SPACE + 2.0f;

	// Scale
	uncommon_dialog.scale = 0;
}
Exemple #2
0
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;
	}
}
Exemple #3
0
void loadListDialog(List* list) {
	base_pos = 0;
	rel_pos = 0;
	current_list = list;

	list_dialog.height = 0.0f;
	list_dialog.width = 0.0f;

	// Calculate max width
	int z;
	float width;
	for (z = 0;z < current_list->n_list_entries; z++)
	{
		width = vita2d_pgf_text_width(font, FONT_SIZE, language_container[current_list->list_entries[z].name]);
		if (width > list_dialog.width)
				list_dialog.width = width;
	}

	width = vita2d_pgf_text_width(font, FONT_SIZE, language_container[current_list->title]);
	if (width > list_dialog.width)
			list_dialog.width = width;

	// Calculate height
	int list_calc_height = current_list->n_list_entries;
	if (list_calc_height > LIST_MAX_ENTRY)
		list_calc_height = LIST_MAX_ENTRY;

	max_entry_show = list_calc_height;

	list_dialog.height = (SHELL_MARGIN_Y * 3) + (list_calc_height * SHELL_MARGIN_Y);

	// Margin
	list_dialog.width += 2.0f * SHELL_MARGIN_X;
	list_dialog.height += 4.0f * SHELL_MARGIN_Y;

	list_dialog.x = ALIGN_CENTER(SCREEN_WIDTH, list_dialog.width);
	list_dialog.y = ALIGN_CENTER(SCREEN_HEIGHT, list_dialog.height) - 2.0f * FONT_Y_SPACE;
	list_dialog.scale = 0.0f;
	list_dialog.animation_mode = LIST_DIALOG_OPENING;
	list_dialog.status = SCE_COMMON_DIALOG_STATUS_RUNNING;
	list_dialog.enter_pressed = 0;

	is_open = LIST_DIALOG_OPEN;
}
Exemple #4
0
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;
  }
}
Exemple #5
0
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;
}