Skip to content

Commit

Permalink
gui :add welcome_park as a commercial_app
Browse files Browse the repository at this point in the history
  • Loading branch information
nishinji committed Nov 19, 2023
1 parent d5da999 commit 0cb8457
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
9 changes: 5 additions & 4 deletions vita3k/gui/src/app_context_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string
auto &common = emuenv.common_dialog.lang.common;
auto &lang_compat = gui.lang.compatibility;

const auto is_commercial_app = title_id.find("PCS") != std::string::npos;
const auto is_commercial_app = title_id.starts_with("PCS") || title_id.starts_with("NPXS10007");
const auto is_system_app = title_id.starts_with("NPXS") && !title_id.starts_with("NPXS10007");
const auto has_state_report = gui.compat.compat_db_loaded ? gui.compat.app_compat_db.contains(title_id) : false;
const auto compat_state = has_state_report ? gui.compat.app_compat_db[title_id].state : compat::UNKNOWN;
const auto compat_state_color = gui.compat.compat_color[compat_state];
Expand All @@ -319,7 +320,7 @@ void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string
const auto START_STR = app_path == emuenv.io.app_path ? gui.lang.live_area.main["continue"] : gui.lang.live_area.main["start"];
if (ImGui::MenuItem(START_STR.c_str()))
pre_run_app(gui, emuenv, app_path);
if (title_id.find("NPXS") == std::string::npos) {
if (!is_system_app) {
if (ImGui::BeginMenu(lang_compat.name.c_str())) {
if (!is_commercial_app || !gui.compat.compat_db_loaded) {
if (ImGui::MenuItem(lang.main["check_app_state"].c_str())) {
Expand Down Expand Up @@ -499,7 +500,7 @@ void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string
}
}
if (ImGui::MenuItem(lang.main["information"].c_str(), nullptr, &gui.vita_area.app_information)) {
if (title_id.find("NPXS") == std::string::npos) {
if (!is_system_app) {
get_app_info(gui, emuenv, app_path);
const auto app_size = get_app_size(gui, emuenv, app_path);
gui.app_selector.app_info.size = app_size;
Expand Down Expand Up @@ -610,7 +611,7 @@ void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string
ImGui::PushTextWrapPos(display_size.x - (85.f * SCALE.x));
ImGui::TextColored(GUI_COLOR_TEXT, "%s", APP_INDEX->title.c_str());
ImGui::PopTextWrapPos();
if (title_id.find("NPXS") == std::string::npos) {
if (!is_system_app) {
ImGui::Spacing();
ImGui::SetCursorPosX((display_size.x / 2.f) - ImGui::CalcTextSize((lang.info["trophy_earning"] + " ").c_str()).x);
ImGui::TextColored(GUI_COLOR_TEXT, "%s %s", lang.info["trophy_earning"].c_str(), gui.app_selector.app_info.trophy.c_str());
Expand Down
6 changes: 3 additions & 3 deletions vita3k/gui/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void init_app_background(GuiState &gui, EmuEnvState &emuenv, const std::string &
int32_t height = 0;
vfs::FileBuffer buffer;

const auto is_sys = app_path.find("NPXS") != std::string::npos;
const auto is_sys = app_path.starts_with("NPXS") && !app_path.starts_with("NPXS10007");
if (is_sys)
vfs::read_file(VitaIoDevice::vs0, buffer, emuenv.pref_path.wstring(), "app/" + app_path + "/sce_sys/pic0.png");
else
Expand Down Expand Up @@ -553,7 +553,7 @@ void init_user_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_pa
}

std::map<std::string, ImGui_Texture>::const_iterator get_app_icon(GuiState &gui, const std::string &app_path) {
const auto &app_type = app_path.find("NPXS") != std::string::npos ? gui.app_selector.sys_apps_icon : gui.app_selector.user_apps_icon;
const auto &app_type = app_path.starts_with("NPXS") && !app_path.starts_with("NPXS10007") ? gui.app_selector.sys_apps_icon : gui.app_selector.user_apps_icon;
const auto app_icon = std::find_if(app_type.begin(), app_type.end(), [&](const auto &i) {
return i.first == app_path;
});
Expand All @@ -562,7 +562,7 @@ std::map<std::string, ImGui_Texture>::const_iterator get_app_icon(GuiState &gui,
}

std::vector<App>::iterator get_app_index(GuiState &gui, const std::string &app_path) {
auto &app_type = app_path.find("NPXS") != std::string::npos ? gui.app_selector.sys_apps : gui.app_selector.user_apps;
auto &app_type = app_path.starts_with("NPXS") && !app_path.starts_with("NPXS10007") ? gui.app_selector.sys_apps : gui.app_selector.user_apps;
const auto app_index = std::find_if(app_type.begin(), app_type.end(), [&](const App &a) {
return a.path == app_path;
});
Expand Down
13 changes: 7 additions & 6 deletions vita3k/gui/src/home_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ void pre_load_app(GuiState &gui, EmuEnvState &emuenv, bool live_area, const std:
}

void pre_run_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path) {
if (app_path.find("NPXS") == std::string::npos) {
const auto is_sys = app_path.starts_with("NPXS") && !app_path.starts_with("NPXS10007");
if (!is_sys) {
if (emuenv.io.app_path != app_path) {
if (!emuenv.io.app_path.empty())
gui.vita_area.app_close = true;
Expand Down Expand Up @@ -320,7 +321,7 @@ static bool app_filter(const std::string &app) {
return true;
break;
case HOMEBREW:
if (!filter_app({ "PCS" }))
if (!filter_app({ "PCS", "NPXS10007" }))
return true;
break;
}
Expand Down Expand Up @@ -752,9 +753,9 @@ void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) {
const auto display_app = [&](const std::vector<gui::App> &apps_list, std::map<std::string, ImGui_Texture> &apps_icon) {
for (const auto &app : apps_list) {
bool selected = false;
const auto is_not_sys_app = app.path.find("NPXS") == std::string::npos;
const auto is_sys = app.path.starts_with("NPXS") && !app.path.starts_with("NPXS10007");

if (is_not_sys_app) {
if (!is_sys) {
// Filter app by region and type
if (app_filter(app.title_id))
continue;
Expand All @@ -779,7 +780,7 @@ void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) {

// Get the current app index off the apps list.
const auto app_index = static_cast<int>(&app - &apps_list[0]);
const auto current_app_index = is_not_sys_app ? app_index : app_index - 4;
const auto current_app_index = !is_sys ? app_index : app_index - 4;
apps_list_filtered.push_back(current_app_index);

// Check if the current app is selected.
Expand Down Expand Up @@ -860,7 +861,7 @@ void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) {
ImGui::NextColumn();

// Draw the compatibility badge for commercial apps when they are within the visible area.
if (element_is_within_visible_area && (app.title_id.find("PCS") != std::string::npos)) {
if (element_is_within_visible_area && app.title_id.starts_with("PCS") || app.title_id.starts_with("NPXS10007")) {
const auto compat_state = (gui.compat.compat_db_loaded ? gui.compat.app_compat_db.contains(app.title_id) : false) ? gui.compat.app_compat_db[app.title_id].state : compat::UNKNOWN;
const auto compat_state_vec4 = gui.compat.compat_color[compat_state];
const ImU32 compat_state_color = IM_COL32((int)(compat_state_vec4.x * 255.0f), (int)(compat_state_vec4.y * 255.0f), (int)(compat_state_vec4.z * 255.0f), (int)(compat_state_vec4.w * 255.0f));
Expand Down
8 changes: 4 additions & 4 deletions vita3k/gui/src/live_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ static std::map<std::string, Items> items_styles = {

void init_live_area(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path) {
const auto live_area_lang = gui.lang.user_lang[LIVE_AREA];
const auto is_sys_app = app_path.find("NPXS") != std::string::npos;
const auto is_ps_app = app_path.find("PCS") != std::string::npos;
const auto is_sys_app = app_path.starts_with("NPXS") && !app_path.starts_with("NPXS10007");
const auto is_ps_app = app_path.starts_with("PCS") || app_path.starts_with("NPXS10007");
const VitaIoDevice app_device = is_sys_app ? VitaIoDevice::vs0 : VitaIoDevice::ux0;
const auto APP_INDEX = get_app_index(gui, app_path);

Expand Down Expand Up @@ -639,7 +639,7 @@ void draw_live_area_screen(GuiState &gui, EmuEnvState &emuenv) {
const auto SCALE = ImVec2(RES_SCALE.x * emuenv.dpi_scale, RES_SCALE.y * emuenv.dpi_scale);

const auto app_path = gui.live_area_current_open_apps_list[gui.live_area_app_current_open];
const VitaIoDevice app_device = app_path.find("NPXS") != std::string::npos ? VitaIoDevice::vs0 : VitaIoDevice::ux0;
const VitaIoDevice app_device = app_path.starts_with("NPXS") && !app_path.starts_with("NPXS10007") ? VitaIoDevice::vs0 : VitaIoDevice::ux0;

ImGui::SetNextWindowPos(VIEWPORT_POS, ImGuiCond_Always);
ImGui::SetNextWindowSize(VIEWPORT_SIZE, ImGuiCond_Always);
Expand Down Expand Up @@ -1065,7 +1065,7 @@ void draw_live_area_screen(GuiState &gui, EmuEnvState &emuenv) {
const auto ICON_POS_MAX_SCALE = ImVec2(ICON_POS_MINI_SCALE.x + ICON_SIZE_SCALE, ICON_POS_MINI_SCALE.y + ICON_SIZE_SCALE);

// check if app icon exist
auto &APP_ICON_TYPE = app_path.find("NPXS") != std::string::npos ? gui.app_selector.sys_apps_icon : gui.app_selector.user_apps_icon;
auto &APP_ICON_TYPE = app_path.starts_with("NPXS") && !app_path.starts_with("NPXS10007") ? gui.app_selector.sys_apps_icon : gui.app_selector.user_apps_icon;
if (APP_ICON_TYPE.contains(app_path)) {
window_draw_list->AddImageRounded(APP_ICON_TYPE[app_path], ICON_POS_MINI_SCALE, ICON_POS_MAX_SCALE,
ImVec2(0, 0), ImVec2(1, 1), IM_COL32_WHITE, 75.f * SCALE.x, ImDrawFlags_RoundCornersAll);
Expand Down

0 comments on commit 0cb8457

Please sign in to comment.