diff --git a/.github/ISSUE_TEMPLATE/2-feature_request.yml b/.github/ISSUE_TEMPLATE/2-feature_request.yml index 5f95de01..badcce5d 100644 --- a/.github/ISSUE_TEMPLATE/2-feature_request.yml +++ b/.github/ISSUE_TEMPLATE/2-feature_request.yml @@ -1,11 +1,11 @@ name: Feature Request description: Template for feature request title: "[Feature Request]: " -labels: "Feature Request" +labels: "feature request" body: - type: markdown attributes: - value: Tech support does not belong here. You should only file an issue here if you are requesting a feature you believe would make Vit3K better. + value: Tech support does not belong here. You should only file an issue here if you are requesting a feature you believe would make Vita3K better. - type: checkboxes attributes: label: Is there an existing issue for this? diff --git a/vita3k/gui/src/about_dialog.cpp b/vita3k/gui/src/about_dialog.cpp index 534e0d6f..9c05447d 100644 --- a/vita3k/gui/src/about_dialog.cpp +++ b/vita3k/gui/src/about_dialog.cpp @@ -24,31 +24,32 @@ namespace gui { // Add any new developer/contributor in alphabetic order -static std::vector developers_list = { +static constexpr std::array developers_list = { "1whatleytay", "bookmist", "EXtremeExploit", "frangarcj", "IllusionMan1212", "KorewaWatchful", "Macdu", "pent0", "petmac", "Rinnegatamante", "sunho", "VelocityRa", "Zangetsu38" }; -static std::vector contributors_list = { - "0nza1101", "0x8080", "AtticFinder65536", "BogdanTheGeek", "bsinky", - "bythos14", "cobalt2727", "CoffeeBrewer64", "Cpasjuste", "CreepNT", - "Croden1999", "d3m3vilurr", "Danik2343", "DerRM", "devnoname120", - "dima-xd", "dracc", "edwinr", "Felipefpl", "FlotterCodername", - "Frain-Breeze", "francois-berder", "FromAlaska", "Ghabry", "hobyst", - "HuanJiCanShang", "ichisadashioko", "illusion0001", "isJuhn", - "jdoe0000000", "jlachniet", "Johnnynator", "johnothwolo", "Kaitul", - "kd-11", "KhoraLee", "lephilousophe", "lybxlpsv", "MaddTheSane", - "Margen67", "merryhime", "mirusu400", "mkersey", "mrcmunir", - "muemart", "NabsiYa", "NeveHanter", "ngeojiajun", "Nicba1010", - "nishinji", "nn9dev", "Princess-of-Sleeping", "qurious-pixel", "Ristellise", - "scribam", "sitiom", "smitdylan2001", "SonicMastr", "Talkashie", - "Tarik366", "tcoyvwac", "thp", "TingPing", "TomasKralCZ", - "totlmstr", "wfscans", "xero-lib", "xerpi", "xyzz", - "yousifd", "Yunotchi" +static constexpr std::array contributors_list = { + "0nza1101", "0x8080", "AtticFinder65536", "Avellea", "blackbird806", + "BogdanTheGeek", "bsinky", "bythos14", "cobalt2727", "CoffeeBrewer64", "Cpasjuste", + "Creeot", "CreepNT", "Croden1999", "d3m3vilurr", "Danik2343", "darkash", + "DerRM", "devnoname120", "dima-xd", "dracc", "edwinr", "FantasyGmm", + "Felipefpl", "FlotterCodername", "Frain-Breeze", "francois-berder", "FromAlaska", + "Ghabry", "hobyst", "HuanJiCanShang", "ichisadashioko", "illusion0001", + "isJuhn", "jdoe0000000", "jlachniet", "Johnnynator", "johnothwolo", "Kaitul", + "KaneDbD", "kd-11", "KhoraLee", "Kitakatarashima", "lephilousophe", + "Lupiax", "lybxlpsv", "MaddTheSane", "Margen67", "mavethee", "merryhime", + "mirusu400", "mkersey", "mrcmunir", "muemart", "NeveHanter", "ngeojiajun", + "Nicba1010", "nishinji", "nn9dev", "Nyabsi", "oltolm", "pedrozzz0", + "Princess-of-Sleeping", "qurious-pixel", "redpolline", "Ristellise", + "saturnsky", "scribam", "sitiom", "slipcounter", "smitdylan2001", + "SonicMastr", "Talkashie", "Tarik366", "tcoyvwac", "thp", "TingPing", + "TomasKralCZ", "totlmstr", "Valeriy-Lednikov", "wfscans", "xero-lib", + "xerpi", "xperia64", "xsamueljr", "xyzz", "yousifd", "Yunotchi" }; -static std::vector supporters_list = { +static constexpr std::array supporters_list = { "j0hnnybrav0", "TacoOblivion", "Undeadbob", "uplush" }; diff --git a/vita3k/gui/src/allocations_dialog.cpp b/vita3k/gui/src/allocations_dialog.cpp index 4b2c80e7..ce30ebb5 100644 --- a/vita3k/gui/src/allocations_dialog.cpp +++ b/vita3k/gui/src/allocations_dialog.cpp @@ -24,7 +24,7 @@ namespace gui { -static std::array blacklist = { +static constexpr std::array blacklist = { "NULL", "export_sceGxmDisplayQueueAddEntry" }; @@ -37,7 +37,7 @@ void draw_allocations_dialog(GuiState &gui, EmuEnvState &emuenv) { if (vector_utils::contains(blacklist, generation_name)) continue; - const auto page = emuenv.mem.alloc_table[generation_num]; + const auto &page = emuenv.mem.alloc_table[generation_num]; if (ImGui::TreeNode(fmt::format("{}: {}", generation_num, generation_name).c_str())) { ImGui::Text("Range 0x%08zx - 0x%08zx.", generation_num * KiB(4), (generation_num + page.size) * KiB(4)); ImGui::Text("Size: %i KiB (%i page[s])", page.size * 4, page.size); diff --git a/vita3k/gui/src/app_context_menu.cpp b/vita3k/gui/src/app_context_menu.cpp index 01e5f597..3351dfcc 100644 --- a/vita3k/gui/src/app_context_menu.cpp +++ b/vita3k/gui/src/app_context_menu.cpp @@ -53,9 +53,6 @@ static bool get_update_history(GuiState &gui, EmuEnvState &emuenv, const std::st update_history_infos[info.attribute("app_ver").as_double()] = info.text().as_string(); for (auto &update : update_history_infos) { - const auto startpos = "<"; - const auto endpos = ">"; - if (update.second.find_first_of('\n') != std::string::npos) update.second.erase(update.second.begin() + update.second.find_first_of('\n')); @@ -71,9 +68,9 @@ static bool get_update_history(GuiState &gui, EmuEnvState &emuenv, const std::st while (update.second.find("
  • ") != std::string::npos) if (update.second.find("
  • ") != std::string::npos) update.second.replace(update.second.find("
  • "), 4, reinterpret_cast(u8"\u30FB")); // 00B7 or 2022 or 30FB or FF65 - while (update.second.find(startpos) != std::string::npos) - if (update.second.find(">") + 1 != std::string::npos) - update.second.erase(update.second.find(startpos), update.second.find(endpos) + 1 - update.second.find(startpos)); + while (update.second.find('<') != std::string::npos) + if (update.second.find('>') + 1 != std::string::npos) + update.second.erase(update.second.find('<'), update.second.find('>') + 1 - update.second.find('<')); while (update.second.find(" ") != std::string::npos) if (update.second.find(" ") != std::string::npos) update.second.replace(update.second.find(" "), 6, " "); @@ -106,12 +103,12 @@ std::vector::iterator get_time_app_index(GuiState &gui, EmuEnvState &em } static std::string get_time_app_used(GuiState &gui, const int64_t &time_used) { - static const uint32_t one_min = 60; - static const uint32_t one_hour = one_min * 60; - static const uint32_t twenty_four_hours = 24; - static const uint32_t one_day = one_hour * twenty_four_hours; - static const uint32_t seven_days = 7; - static const uint32_t one_week = one_day * seven_days; + constexpr uint32_t one_min = 60; + constexpr uint32_t one_hour = one_min * 60; + constexpr uint32_t twenty_four_hours = 24; + constexpr uint32_t one_day = one_hour * twenty_four_hours; + constexpr uint32_t seven_days = 7; + constexpr uint32_t one_week = one_day * seven_days; auto &lang = gui.lang.app_context.time_used; @@ -218,7 +215,7 @@ void update_last_time_app_used(GuiState &gui, EmuEnvState &emuenv, const std::st void delete_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path) { const auto APP_INDEX = get_app_index(gui, app_path); - const auto title_id = APP_INDEX->title_id; + const auto &title_id = APP_INDEX->title_id; try { fs::remove_all(emuenv.pref_path / "ux0/app" / app_path); @@ -296,7 +293,7 @@ static std::string context_dialog; void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path) { const auto APP_INDEX = get_app_index(gui, app_path); - const auto title_id = APP_INDEX->title_id; + const auto &title_id = APP_INDEX->title_id; const auto APP_PATH{ emuenv.pref_path / "ux0/app" / app_path }; const auto CUSTOM_CONFIG_PATH{ emuenv.config_path / "config" / fmt::format("config_{}.xml", app_path) }; @@ -326,13 +323,13 @@ void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string const auto is_system_app = title_id.starts_with("NPXS") && (title_id != "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]; - const auto compat_state_str = has_state_report ? lang_compat.states[compat_state] : lang_compat.states[compat::UNKNOWN]; + const auto &compat_state_color = gui.compat.compat_color[compat_state]; + const auto &compat_state_str = has_state_report ? lang_compat.states[compat_state] : lang_compat.states[compat::UNKNOWN]; // App Context Menu if (ImGui::BeginPopupContextItem("##app_context_menu")) { ImGui::SetWindowFontScale(1.1f); - const auto START_STR = app_path == emuenv.io.app_path ? gui.lang.live_area.main["continue"] : gui.lang.live_area.main["start"]; + 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 (!is_system_app) { diff --git a/vita3k/gui/src/archive_install_dialog.cpp b/vita3k/gui/src/archive_install_dialog.cpp index 74e07f4a..0f9a159e 100644 --- a/vita3k/gui/src/archive_install_dialog.cpp +++ b/vita3k/gui/src/archive_install_dialog.cpp @@ -65,9 +65,9 @@ void draw_archive_install_dialog(GuiState &gui, EmuEnvState &emuenv) { }; std::lock_guard lock(install_mutex); - auto lang = gui.lang.install_dialog.archive_install; - auto indicator = gui.lang.indicator; - auto common = emuenv.common_dialog.lang.common; + auto &lang = gui.lang.install_dialog.archive_install; + auto &indicator = gui.lang.indicator; + auto &common = emuenv.common_dialog.lang.common; const ImVec2 display_size(emuenv.viewport_size.x, emuenv.viewport_size.y); const auto RES_SCALE = ImVec2(display_size.x / emuenv.res_width_dpi_scale, display_size.y / emuenv.res_height_dpi_scale); diff --git a/vita3k/gui/src/common_dialog.cpp b/vita3k/gui/src/common_dialog.cpp index 9f47b97b..3c8858b4 100644 --- a/vita3k/gui/src/common_dialog.cpp +++ b/vita3k/gui/src/common_dialog.cpp @@ -337,7 +337,7 @@ static ImTextureID check_and_init_icon_texture(GuiState &gui, EmuEnvState &emuen static void draw_save_info(GuiState &gui, EmuEnvState &emuenv, const ImVec2 WINDOW_SIZE, float FONT_SCALE, ImVec2 SCALE, const ImTextureID icon_texture) { const ImVec2 THUMBNAIL_SIZE = ImVec2(160.f * SCALE.x, 90.f * SCALE.y); - auto lang = emuenv.common_dialog.lang.save_data.info; + auto &lang = emuenv.common_dialog.lang.save_data.info; const ImVec2 ICON_POS(100.f * SCALE.x, 16.f * SCALE.y); if (icon_texture) { @@ -356,7 +356,7 @@ static void draw_save_info(GuiState &gui, EmuEnvState &emuenv, const ImVec2 WIND ImGui::SetCursorPos(ImVec2(ICON_POS.x, ImGui::GetCursorPosY() + (46.f * SCALE.y))); ImGui::Text("%s", lang["details"].c_str()); ImGui::SameLine(INFO_POS_WIDTH); - const auto DETAILS_STR = !emuenv.common_dialog.savedata.details[emuenv.common_dialog.savedata.selected_save].empty() ? emuenv.common_dialog.savedata.details[emuenv.common_dialog.savedata.selected_save] : emuenv.common_dialog.savedata.subtitle[emuenv.common_dialog.savedata.selected_save]; + const auto &DETAILS_STR = !emuenv.common_dialog.savedata.details[emuenv.common_dialog.savedata.selected_save].empty() ? emuenv.common_dialog.savedata.details[emuenv.common_dialog.savedata.selected_save] : emuenv.common_dialog.savedata.subtitle[emuenv.common_dialog.savedata.selected_save]; ImGui::Text("%s", DETAILS_STR.c_str()); const ImVec2 BUTTON_SIZE = ImVec2(64 * SCALE.x, 34 * SCALE.y); const ImVec2 BUTTON_POS = ImVec2(6.f * SCALE.x, WINDOW_SIZE.y - (BUTTON_SIZE.y + 14 * SCALE.y)); diff --git a/vita3k/gui/src/controls_dialog.cpp b/vita3k/gui/src/controls_dialog.cpp index 93f3ab04..031d4220 100644 --- a/vita3k/gui/src/controls_dialog.cpp +++ b/vita3k/gui/src/controls_dialog.cpp @@ -25,7 +25,7 @@ namespace gui { -static char const *SDL_key_to_string[]{ "[unset]", "[unknown]", "[unknown]", "[unknown]", "A", "B", "C", "D", "E", "F", "G", +static constexpr std::array SDL_key_to_string{ "[unset]", "[unknown]", "[unknown]", "[unknown]", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "Return/Enter", "Escape", "Backspace", "Tab", "Space", "-", "=", "[", "]", "\\", "NonUS #", ";", "'", "Grave", ",", ".", "/", "CapsLock", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "PrtScrn", "ScrlLock", "Pause", "Insert", "Home", "PgUp", "Delete", @@ -43,7 +43,7 @@ static char const *SDL_key_to_string[]{ "[unset]", "[unknown]", "[unknown]", "[u "Keypad Mem+", "Keypad Mem-", "Keypad Mem*", "Keypad Mem/", "Keypad +/-", "Keypad Clear", "Keypad ClearEntry", "Keypad Binary", "Keypad Octal", "Keypad Dec", "Keypad HexaDec", "[unset]", "[unset]", "LCtrl", "LShift", "LAlt", "Win/Cmd", "RCtrl", "RShift", "RAlt", "RWin/Cmd" }; -static const short total_key_entries = 28; +static constexpr short total_key_entries = 28; static void prepare_map_array(EmuEnvState &emuenv, std::array &map) { map[0] = emuenv.cfg.keyboard_leftstick_up; diff --git a/vita3k/gui/src/firmware_install_dialog.cpp b/vita3k/gui/src/firmware_install_dialog.cpp index f7fb2ebb..48b98b0f 100644 --- a/vita3k/gui/src/firmware_install_dialog.cpp +++ b/vita3k/gui/src/firmware_install_dialog.cpp @@ -56,8 +56,8 @@ void draw_firmware_install_dialog(GuiState &gui, EmuEnvState &emuenv) { }; std::lock_guard lock(install_mutex); - auto lang = gui.lang.install_dialog.firmware_install; - auto common = emuenv.common_dialog.lang.common; + auto &lang = gui.lang.install_dialog.firmware_install; + auto &common = emuenv.common_dialog.lang.common; const ImVec2 display_size(emuenv.viewport_size.x, emuenv.viewport_size.y); const ImVec2 RES_SCALE(display_size.x / emuenv.res_width_dpi_scale, display_size.y / emuenv.res_height_dpi_scale); diff --git a/vita3k/gui/src/gui.cpp b/vita3k/gui/src/gui.cpp index cc4ab90f..52bf1cd4 100644 --- a/vita3k/gui/src/gui.cpp +++ b/vita3k/gui/src/gui.cpp @@ -62,7 +62,7 @@ void draw_info_message(GuiState &gui, EmuEnvState &emuenv) { ImGui::SetNextWindowPos(ImVec2(emuenv.viewport_pos.x + (display_size.x / 2) - (WINDOW_SIZE.x / 2.f), emuenv.viewport_pos.y + (display_size.y / 2.f) - (WINDOW_SIZE.y / 2.f)), ImGuiCond_Always); ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.f * SCALE.x); ImGui::BeginChild("##info", WINDOW_SIZE, true, ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDecoration); - const auto title = gui.info_message.title; + const auto &title = gui.info_message.title; ImGui::SetWindowFontScale(RES_SCALE.x); ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize(title.c_str()).x) / 2); ImGui::TextColored(GUI_COLOR_TEXT_TITLE, "%s", title.c_str()); @@ -157,21 +157,21 @@ static void init_font(GuiState &gui, EmuEnvState &emuenv) { mono_font_config.SizePixels = 13.f; #ifdef _WIN32 - const auto monospaced_font_path = "C:\\Windows\\Fonts\\consola.ttf"; + constexpr auto monospaced_font_path = "C:\\Windows\\Fonts\\consola.ttf"; gui.monospaced_font = io.Fonts->AddFontFromFileTTF(monospaced_font_path, mono_font_config.SizePixels, &mono_font_config, io.Fonts->GetGlyphRangesJapanese()); #else gui.monospaced_font = io.Fonts->AddFontDefault(&mono_font_config); #endif // Set Large Font - static const ImWchar large_font_chars[] = { L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9', L':', L'A', L'M', L'P', 0 }; + constexpr ImWchar large_font_chars[] = { L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9', L':', L'A', L'M', L'P', 0 }; // Set Fw font paths const auto fw_font_path{ emuenv.pref_path / "sa0/data/font/pvf" }; const auto latin_fw_font_path{ fw_font_path / "ltn0.pvf" }; // clang-format off - static const ImWchar latin_range[] = { + constexpr ImWchar latin_range[] = { 0x0020, 0x017F, // Basic Latin + Latin Supplement 0x0370, 0x03FF, // Greek and Coptic 0x0400, 0x052F, // Cyrillic + Cyrillic Supplement @@ -182,7 +182,7 @@ static void init_font(GuiState &gui, EmuEnvState &emuenv) { 0, }; - static const ImWchar extra_range[] = { + constexpr ImWchar extra_range[] = { 0x0100, 0x017F, // Latin Extended A 0x2000, 0x206F, // General Punctuation 0x2150, 0x218F, // Numeral forms @@ -194,13 +194,13 @@ static void init_font(GuiState &gui, EmuEnvState &emuenv) { 0, }; - static const ImWchar korean_range[] = { + constexpr ImWchar korean_range[] = { 0x3131, 0x3163, // Korean alphabets 0xAC00, 0xD79D, // Korean characters 0, }; - static const ImWchar chinese_range[] = { + constexpr ImWchar chinese_range[] = { 0x2000, 0x206F, // General Punctuation 0x4E00, 0x9FAF, // CJK Ideograms 0, @@ -392,7 +392,7 @@ void init_app_background(GuiState &gui, EmuEnvState &emuenv, const std::string & else vfs::read_app_file(buffer, emuenv.pref_path, app_path, "sce_sys/pic0.png"); - const auto title = APP_INDEX ? APP_INDEX->title : app_path; + const auto &title = APP_INDEX ? APP_INDEX->title : app_path; if (buffer.empty()) { LOG_WARN("Background not found for application {} [{}].", title, app_path); @@ -608,10 +608,10 @@ void get_user_apps_title(GuiState &gui, EmuEnvState &emuenv) { void get_sys_apps_title(GuiState &gui, EmuEnvState &emuenv) { gui.app_selector.sys_apps.clear(); - static constexpr std::array sys_apps_list = { "NPXS10003", "NPXS10008", "NPXS10015", "NPXS10026" }; + constexpr std::array sys_apps_list = { "NPXS10003", "NPXS10008", "NPXS10015", "NPXS10026" }; for (const auto &app : sys_apps_list) { vfs::FileBuffer params; - if (vfs::read_file(VitaIoDevice::vs0, params, emuenv.pref_path, "app/" + app + "/sce_sys/param.sfo")) { + if (vfs::read_file(VitaIoDevice::vs0, params, emuenv.pref_path, fmt::format("app/{}/sce_sys/param.sfo", app))) { SfoFile sfo_handle; sfo::load(sfo_handle, params); sfo::get_data_by_key(emuenv.app_info.app_version, sfo_handle, "APP_VER"); @@ -649,9 +649,9 @@ void get_sys_apps_title(GuiState &gui, EmuEnvState &emuenv) { std::map get_date_time(GuiState &gui, EmuEnvState &emuenv, const tm &date_time) { std::map date_time_str; if (!emuenv.io.user_id.empty()) { - const auto day_str = gui.lang.common.wday[date_time.tm_wday]; - const auto month_str = gui.lang.common.ymonth[date_time.tm_mon]; - const auto days_str = gui.lang.common.mday[date_time.tm_mday]; + const auto &day_str = gui.lang.common.wday[date_time.tm_wday]; + const auto &month_str = gui.lang.common.ymonth[date_time.tm_mon]; + const auto &days_str = gui.lang.common.mday[date_time.tm_mday]; const auto year = date_time.tm_year + 1900; const auto month = date_time.tm_mon + 1; const auto day = date_time.tm_mday; @@ -661,8 +661,8 @@ std::map get_date_time(GuiState &gui, EmuEnvState &emuenv date_time_str[DateTime::DATE_MINI] = fmt::format("{}/{}/{}", year, month, day); break; case SCE_SYSTEM_PARAM_DATE_FORMAT_DDMMYYYY: { - const auto small_month_str = gui.lang.common.small_ymonth[date_time.tm_mon]; - const auto small_days_str = gui.lang.common.small_mday[day]; + const auto &small_month_str = gui.lang.common.small_ymonth[date_time.tm_mon]; + const auto &small_days_str = gui.lang.common.small_mday[day]; date_time_str[DateTime::DATE_DETAIL] = fmt::format("{} {} ({})", small_days_str, small_month_str, day_str); date_time_str[DateTime::DATE_MINI] = fmt::format("{}/{}/{}", day, month, year); break; diff --git a/vita3k/gui/src/home_screen.cpp b/vita3k/gui/src/home_screen.cpp index 5b1fb420..7fc91463 100644 --- a/vita3k/gui/src/home_screen.cpp +++ b/vita3k/gui/src/home_screen.cpp @@ -115,7 +115,7 @@ void update_live_area_current_open_apps_list(GuiState &gui, EmuEnvState &emuenv, gui.live_area_current_open_apps_list.insert(gui.live_area_current_open_apps_list.begin(), app_path); gui.live_area_app_current_open = 0; if (gui.live_area_current_open_apps_list.size() > 6) { - const auto last_app = gui.live_area_current_open_apps_list.back() == emuenv.io.app_path ? gui.live_area_current_open_apps_list[gui.live_area_current_open_apps_list.size() - 2] : gui.live_area_current_open_apps_list.back(); + const auto &last_app = gui.live_area_current_open_apps_list.back() == emuenv.io.app_path ? gui.live_area_current_open_apps_list[gui.live_area_current_open_apps_list.size() - 2] : gui.live_area_current_open_apps_list.back(); gui.live_area_contents.erase(last_app); gui.live_items.erase(last_app); gui.live_area_current_open_apps_list.erase(get_live_area_current_open_apps_list_index(gui, last_app)); @@ -231,7 +231,7 @@ void draw_app_close(GuiState &gui, EmuEnvState &emuenv) { const auto WINDOW_SIZE = ImVec2(756.0f * SCALE.x, 436.0f * SCALE.y); const auto BUTTON_SIZE = ImVec2(320.f * SCALE.x, 46.f * SCALE.y); - auto common = emuenv.common_dialog.lang.common; + auto &common = emuenv.common_dialog.lang.common; ImGui::SetNextWindowPos(ImVec2(emuenv.viewport_pos.x, emuenv.viewport_pos.y), ImGuiCond_Always); ImGui::SetNextWindowSize(display_size, ImGuiCond_Always); @@ -259,7 +259,7 @@ void draw_app_close(GuiState &gui, EmuEnvState &emuenv) { gui.vita_area.app_close = false; ImGui::SameLine(0, 20.f * SCALE.x); if (ImGui::Button(common["ok"].c_str(), BUTTON_SIZE)) { - const auto app_path = gui.vita_area.live_area_screen ? gui.live_area_current_open_apps_list[gui.live_area_app_current_open] : emuenv.app_path; + const auto &app_path = gui.vita_area.live_area_screen ? gui.live_area_current_open_apps_list[gui.live_area_app_current_open] : emuenv.app_path; close_and_run_new_app(gui, emuenv, app_path); } ImGui::PopStyleVar(); @@ -353,6 +353,7 @@ static void sort_app_list(GuiState &gui, EmuEnvState &emuenv, const SortType &ty case DESCENDANT: return lhs.app_ver > rhs.app_ver; } + break; case CATEGORY: switch (sorted) { case ASCENDANT: @@ -360,6 +361,7 @@ static void sort_app_list(GuiState &gui, EmuEnvState &emuenv, const SortType &ty case DESCENDANT: return lhs.category > rhs.category; } + break; case COMPAT: switch (sorted) { case ASCENDANT: @@ -367,6 +369,7 @@ static void sort_app_list(GuiState &gui, EmuEnvState &emuenv, const SortType &ty case DESCENDANT: return lhs.compat > rhs.compat; } + break; case LAST_TIME: switch (sorted) { case ASCENDANT: @@ -374,6 +377,7 @@ static void sort_app_list(GuiState &gui, EmuEnvState &emuenv, const SortType &ty case DESCENDANT: return lhs.last_time < rhs.last_time; } + break; case TITLE: switch (sorted) { case ASCENDANT: @@ -381,6 +385,7 @@ static void sort_app_list(GuiState &gui, EmuEnvState &emuenv, const SortType &ty case DESCENDANT: return string_utils::toupper(lhs.title) > string_utils::toupper(rhs.title); } + break; case TITLE_ID: switch (sorted) { case ASCENDANT: @@ -388,6 +393,7 @@ static void sort_app_list(GuiState &gui, EmuEnvState &emuenv, const SortType &ty case DESCENDANT: return lhs.title_id > rhs.title_id; } + break; } return false; }); @@ -501,7 +507,7 @@ void browse_home_apps_list(GuiState &gui, EmuEnvState &emuenv, const uint32_t bu } } -static const ImU32 ARROW_COLOR = 0xFFFFFFFF; // White +static constexpr ImU32 ARROW_COLOR = 0xFFFFFFFF; // White static float scroll_type, current_scroll_pos, max_scroll_pos; void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) { @@ -679,7 +685,7 @@ void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) { ImGui::SetWindowFontScale(1.1f * VIEWPORT_RES_SCALE.x); if (ImGui::MenuItem(lang["all"].c_str(), nullptr, app_compat_state == ALL_COMPAT_STATE)) app_compat_state = ALL_COMPAT_STATE; - auto lang_compat = gui.lang.compatibility.states; + auto &lang_compat = gui.lang.compatibility.states; for (int32_t i = compat::UNKNOWN; i <= compat::PLAYABLE; i++) { const auto compat_state = static_cast(i); ImGui::PushStyleColor(ImGuiCol_Text, gui.compat.compat_color[compat_state]); @@ -864,7 +870,7 @@ void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) { // Draw the compatibility badge for commercial apps when they are within the visible area. if (element_is_within_visible_area && (app.title_id.starts_with("PCS") || (app.title_id == "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 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)); const auto current_pos = ImGui::GetCursorPos(); const auto grid_compat_padding = 4.f * VIEWPORT_SCALE.x; diff --git a/vita3k/gui/src/ime.cpp b/vita3k/gui/src/ime.cpp index c7f34804..f5b7885a 100644 --- a/vita3k/gui/src/ime.cpp +++ b/vita3k/gui/src/ime.cpp @@ -359,7 +359,7 @@ void draw_ime(Ime &ime, EmuEnvState &emuenv) { ImGui::SetCursorPos(ImVec2(SPACE_BUTTON_POS.x - (PUNCT_BUTTON_SIZE.x * 2.f) - (SPACE * 2.f), SPACE_BUTTON_POS.y)); ImGui::PushStyleColor(ImGuiCol_Button, GUI_COLOR_TEXT); ImGui::PushStyleColor(ImGuiCol_Text, GUI_COLOR_TEXT_BLACK); - const auto ponct_1 = is_shift ? punct[FIRST][YES] : punct[FIRST][NO]; + const auto &ponct_1 = is_shift ? punct[FIRST][YES] : punct[FIRST][NO]; if (ImGui::Button(string_utils::utf16_to_utf8(ponct_1).c_str(), PUNCT_BUTTON_SIZE)) update_ponct(ime, ponct_1); ImGui::PopStyleColor(2); @@ -397,7 +397,7 @@ void draw_ime(Ime &ime, EmuEnvState &emuenv) { ImGui::SameLine(0, SPACE); ImGui::PushStyleColor(ImGuiCol_Button, GUI_COLOR_TEXT); ImGui::PushStyleColor(ImGuiCol_Text, GUI_COLOR_TEXT_BLACK); - const auto ponct_2 = is_shift ? punct[SECOND][YES] : punct[SECOND][NO]; + const auto &ponct_2 = is_shift ? punct[SECOND][YES] : punct[SECOND][NO]; if (ImGui::Button(string_utils::utf16_to_utf8(ponct_2).c_str(), PUNCT_BUTTON_SIZE)) update_ponct(ime, ponct_2); ImGui::PopStyleColor(2); diff --git a/vita3k/gui/src/information_bar.cpp b/vita3k/gui/src/information_bar.cpp index 2eb130d3..16fd6564 100644 --- a/vita3k/gui/src/information_bar.cpp +++ b/vita3k/gui/src/information_bar.cpp @@ -97,7 +97,7 @@ static bool set_notice_info(GuiState &gui, EmuEnvState &emuenv, const NoticeList std::string msg, name; fs::path content_path; - auto lang = gui.lang.indicator; + auto &lang = gui.lang.indicator; if (info.type == "content") { if (info.group.find("gd") != std::string::npos) { content_path = fs::path("app") / info.id; @@ -123,7 +123,7 @@ static bool set_notice_info(GuiState &gui, EmuEnvState &emuenv, const NoticeList } init_notice_icon(gui, emuenv, content_path / "sce_sys/icon0.png", info); } else { - auto common = gui.lang.common.main; + auto &common = gui.lang.common.main; switch (static_cast(string_utils::stoi_def(info.group, 0, "trophy group"))) { case np::trophy::SceNpTrophyGrade::SCE_NP_TROPHY_GRADE_PLATINUM: name = fmt::format("({}) ", common["platinum"]); @@ -279,7 +279,7 @@ void update_notice_info(GuiState &gui, EmuEnvState &emuenv, const std::string &t info.content_id = emuenv.app_info.app_content_id; info.group = emuenv.app_info.app_category; } else { - const auto trophy_data = gui.trophy_unlock_display_requests.back(); + const auto &trophy_data = gui.trophy_unlock_display_requests.back(); info.id = trophy_data.np_com_id; info.content_id = trophy_data.trophy_id; info.group = std::to_string(int(trophy_data.trophy_kind)); @@ -313,9 +313,9 @@ static std::string get_notice_time(GuiState &gui, EmuEnvState &emuenv, const tim std::string date; const auto time_in_second = time / 1000; const auto diff_time = difftime(std::time(nullptr), time_in_second); - static const auto minute = 60; - static const auto hour = minute * 60; - static const auto day = hour * 24; + constexpr auto minute = 60; + constexpr auto hour = minute * 60; + constexpr auto day = hour * 24; if (diff_time >= day) { tm date_tm = {}; SAFE_LOCALTIME(&time_in_second, &date_tm); @@ -324,7 +324,7 @@ static std::string get_notice_time(GuiState &gui, EmuEnvState &emuenv, const tim if (emuenv.cfg.sys_time_format == SCE_SYSTEM_PARAM_TIME_FORMAT_12HOUR) date += fmt::format(" {}", DATE_TIME[DateTime::DAY_MOMENT]); } else { - auto lang = gui.lang.common.main; + auto &lang = gui.lang.common.main; if (diff_time >= (hour * 2)) date = fmt::format(fmt::runtime(lang["hours_ago"]), uint32_t(diff_time / hour)); else if (diff_time >= hour) @@ -395,7 +395,7 @@ static void draw_notice_info(GuiState &gui, EmuEnvState &emuenv) { ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, notice_info.empty() ? 0.f : 8.0f * SCALE.x); ImGui::SetNextWindowPos(POPUP_POS, ImGuiCond_Always); ImGui::BeginChild("##notice_info_child", POPUP_SIZE, true, ImGuiWindowFlags_NoSavedSettings); - auto lang = gui.lang.indicator; + auto &lang = gui.lang.indicator; if (notice_info.empty()) { ImGui::SetWindowFontScale(1.2f * RES_SCALE.x); const auto no_notif = lang["no_notif"].c_str(); @@ -477,7 +477,7 @@ static void draw_notice_info(GuiState &gui, EmuEnvState &emuenv) { if (ImGui::BeginPopupModal("Delete All", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) { ImGui::SetWindowFontScale(1.4f * RES_SCALE.x); const auto notif_deleted = lang["notif_deleted"].c_str(); - auto common = emuenv.common_dialog.lang.common; + auto &common = emuenv.common_dialog.lang.common; ImGui::SetCursorPos(ImVec2((DELETE_POPUP_SIZE.x / 2.f) - (ImGui::CalcTextSize(notif_deleted).x / 2.f), (DELETE_POPUP_SIZE.y / 2.f) - (46.f * SCALE.y))); ImGui::TextColored(GUI_COLOR_TEXT, "%s", notif_deleted); ImGui::SetCursorPos(ImVec2((DELETE_POPUP_SIZE.x / 2) - (BUTTON_SIZE.x + (20.f * SCALE.x)), DELETE_POPUP_SIZE.y - BUTTON_SIZE.y - (24.0f * SCALE.y))); @@ -522,8 +522,8 @@ void draw_information_bar(GuiState &gui, EmuEnvState &emuenv) { const ImVec2 INFO_BAR_SIZE(VIEWPORT_SIZE.x, 32.f * SCALE.y); - const ImU32 DEFAULT_BAR_COLOR = 0xFF000000; // Black - const ImU32 DEFAULT_INDICATOR_COLOR = 0xFFFFFFFF; // White + constexpr ImU32 DEFAULT_BAR_COLOR = 0xFF000000; // Black + constexpr ImU32 DEFAULT_INDICATOR_COLOR = 0xFFFFFFFF; // White const auto is_12_hour_format = emuenv.cfg.sys_time_format == SCE_SYSTEM_PARAM_TIME_FORMAT_12HOUR; const auto is_notif_pos = !gui.vita_area.start_screen && (gui.vita_area.live_area_screen || gui.vita_area.home_screen) ? 78.f * SCALE.x : 0.f; @@ -572,7 +572,7 @@ void draw_information_bar(GuiState &gui, EmuEnvState &emuenv) { const ImVec2 ICON_POS_MIN(VIEWPORT_POS.x + (INFO_BAR_SIZE.x / 2.f) - (14.f * SCALE.x) - (decal_app_icon_pos * SCALE.x) + (a * (34 * SCALE.x)), VIEWPORT_POS.y + (2.f * SCALE.y)); const ImVec2 ICON_POS_MAX(ICON_POS_MIN.x + ICON_SIZE_SCALE, ICON_POS_MIN.y + ICON_SIZE_SCALE); const ImVec2 ICON_CENTER_POS(ICON_POS_MIN.x + (ICON_SIZE_SCALE / 2.f), ICON_POS_MIN.y + (ICON_SIZE_SCALE / 2.f)); - const auto APPS_OPENED = gui.live_area_current_open_apps_list[a]; + const auto &APPS_OPENED = gui.live_area_current_open_apps_list[a]; auto &APP_ICON_TYPE = APPS_OPENED.starts_with("NPXS") && (APPS_OPENED != "NPXS10007") ? gui.app_selector.sys_apps_icon : gui.app_selector.user_apps_icon; // Check if icon exist @@ -587,7 +587,7 @@ void draw_information_bar(GuiState &gui, EmuEnvState &emuenv) { } } - const auto PIX_FONT_SCALE = 19.2f / 24.f; + constexpr auto PIX_FONT_SCALE = 19.2f / 24.f; const auto DEFAULT_FONT_SCALE = ImGui::GetFontSize() / (19.2f * emuenv.dpi_scale); const auto CLOCK_DEFAULT_FONT_SCALE = (24.f * emuenv.dpi_scale) * DEFAULT_FONT_SCALE; const auto DAY_MOMENT_DEFAULT_FONT_SCALE = (18.f * emuenv.dpi_scale) * DEFAULT_FONT_SCALE; diff --git a/vita3k/gui/src/initial_setup.cpp b/vita3k/gui/src/initial_setup.cpp index 5a8c84b5..fcad9f52 100644 --- a/vita3k/gui/src/initial_setup.cpp +++ b/vita3k/gui/src/initial_setup.cpp @@ -36,46 +36,30 @@ static InitialSetup setup = SELECT_LANGUAGE; static std::string title_str; void get_firmware_file(EmuEnvState &emuenv) { - if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_JAPANESE) - open_path("https://www.playstation.com/ja-jp/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_ENGLISH_US) - open_path("https://www.playstation.com/en-us/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_FRENCH) - open_path("https://www.playstation.com/fr-fr/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_SPANISH) - open_path("https://www.playstation.com/es-es/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_GERMAN) - open_path("https://www.playstation.com/de-de/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_ITALIAN) - open_path("https://www.playstation.com/it-it/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_DUTCH) - open_path("https://www.playstation.com/nl-nl/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_PORTUGUESE_PT) - open_path("https://www.playstation.com/pt-pt/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_RUSSIAN) - open_path("https://www.playstation.com/ru-ru/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_KOREAN) - open_path("https://www.playstation.com/ko-kr/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_CHINESE_T) - open_path("https://www.playstation.com/zh-hant-hk/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_CHINESE_S) - open_path("https://www.playstation.com/zh-hans-cn/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_FINNISH) - open_path("https://www.playstation.com/fi-fi/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_SWEDISH) - open_path("https://www.playstation.com/sv-sv/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_DANISH) - open_path("https://www.playstation.com/da-dk/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_NORWEGIAN) - open_path("https://www.playstation.com/no-no/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_POLISH) - open_path("https://www.playstation.com/pl-pl/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_PORTUGUESE_BR) - open_path("https://www.playstation.com/pt-br/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_ENGLISH_GB) - open_path("https://www.playstation.com/en-gb/support/hardware/psvita/system-software"); - else if (emuenv.cfg.sys_lang == SCE_SYSTEM_PARAM_LANG_TURKISH) - open_path("https://www.playstation.com/tr-tr/support/hardware/psvita/system-software"); + const std::map locale_id = { + { SCE_SYSTEM_PARAM_LANG_JAPANESE, "ja-jp" }, + { SCE_SYSTEM_PARAM_LANG_ENGLISH_US, "en-us" }, + { SCE_SYSTEM_PARAM_LANG_FRENCH, "fr-fr" }, + { SCE_SYSTEM_PARAM_LANG_SPANISH, "es-es" }, + { SCE_SYSTEM_PARAM_LANG_GERMAN, "de-de" }, + { SCE_SYSTEM_PARAM_LANG_ITALIAN, "it-it" }, + { SCE_SYSTEM_PARAM_LANG_DUTCH, "nl-nl" }, + { SCE_SYSTEM_PARAM_LANG_PORTUGUESE_PT, "pt-pt" }, + { SCE_SYSTEM_PARAM_LANG_RUSSIAN, "ru-ru" }, + { SCE_SYSTEM_PARAM_LANG_KOREAN, "ko-kr" }, + { SCE_SYSTEM_PARAM_LANG_CHINESE_T, "zh-hant-hk" }, + { SCE_SYSTEM_PARAM_LANG_CHINESE_S, "zh-hans-cn" }, + { SCE_SYSTEM_PARAM_LANG_FINNISH, "fi-fi" }, + { SCE_SYSTEM_PARAM_LANG_SWEDISH, "sv-sv" }, + { SCE_SYSTEM_PARAM_LANG_DANISH, "da-dk" }, + { SCE_SYSTEM_PARAM_LANG_NORWEGIAN, "no-no" }, + { SCE_SYSTEM_PARAM_LANG_POLISH, "pl-PL" }, + { SCE_SYSTEM_PARAM_LANG_PORTUGUESE_BR, "pt-br" }, + { SCE_SYSTEM_PARAM_LANG_ENGLISH_GB, "en-gb" }, + { SCE_SYSTEM_PARAM_LANG_TURKISH, "tr-tr" }, + }; + const auto &locale = locale_id.at(emuenv.cfg.sys_lang); + open_path(fmt::format("https://www.playstation.com/{}/support/hardware/psvita/system-software", locale)); } void draw_initial_setup(GuiState &gui, EmuEnvState &emuenv) { @@ -88,8 +72,8 @@ void draw_initial_setup(GuiState &gui, EmuEnvState &emuenv) { const auto BIG_BUTTON_SIZE = ImVec2(324.f * SCALE.x, 48.f * SCALE.y); const auto BIG_BUTTON_POS = ImVec2((WINDOW_SIZE.x / 2.f) - (BIG_BUTTON_SIZE.x / 2.f), WINDOW_SIZE.y - BIG_BUTTON_SIZE.y - (20.f * SCALE.y)); - auto lang = gui.lang.initial_setup; - auto common = emuenv.common_dialog.lang.common; + auto &lang = gui.lang.initial_setup; + auto &common = emuenv.common_dialog.lang.common; const auto completed_setup = lang["completed_setup"].c_str(); const auto is_default_path = emuenv.cfg.pref_path == emuenv.default_path; diff --git a/vita3k/gui/src/live_area.cpp b/vita3k/gui/src/live_area.cpp index cae9d15d..a5ab5b7f 100644 --- a/vita3k/gui/src/live_area.cpp +++ b/vita3k/gui/src/live_area.cpp @@ -150,7 +150,7 @@ static std::map items_styles = { // clang-format on 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 &live_area_lang = gui.lang.user_lang[LIVE_AREA]; const auto is_sys_app = app_path.starts_with("NPXS") && (app_path != "NPXS10007"); const auto is_ps_app = app_path.starts_with("PCS") || (app_path == "NPXS10007"); const VitaIoDevice app_device = is_sys_app ? VitaIoDevice::vs0 : VitaIoDevice::ux0; @@ -549,7 +549,7 @@ enum LiveAreaType { MANUAL, }; -static const ImU32 ARROW_COLOR = 0xFFFFFFFF; // White +static constexpr ImU32 ARROW_COLOR = 0xFFFFFFFF; // White static LiveAreaType live_area_type_selected = GATE; void browse_live_area_apps_list(GuiState &gui, EmuEnvState &emuenv, const uint32_t button) { @@ -636,7 +636,7 @@ void draw_live_area_screen(GuiState &gui, EmuEnvState &emuenv) { const auto RES_SCALE = ImVec2(VIEWPORT_SIZE.x / emuenv.res_width_dpi_scale, VIEWPORT_SIZE.y / emuenv.res_height_dpi_scale); 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 auto &app_path = gui.live_area_current_open_apps_list[gui.live_area_app_current_open]; const VitaIoDevice app_device = app_path.starts_with("NPXS") ? VitaIoDevice::vs0 : VitaIoDevice::ux0; const auto INFO_BAR_HEIGHT = 32.f * SCALE.y; @@ -667,7 +667,7 @@ void draw_live_area_screen(GuiState &gui, EmuEnvState &emuenv) { else window_draw_list->AddRectFilled(pos_bg, ImVec2(pos_bg.x + background_size.x, pos_bg.y + background_size.y), IM_COL32(148.f, 164.f, 173.f, 255.f), 0.f, ImDrawFlags_RoundCornersAll); - const auto app_type = type[app_path]; + const auto &app_type = type[app_path]; LOG_WARN_IF(!items_styles.contains(app_type), "Type of style {} no found for: {}", app_type, app_path); for (const auto &frame : frames[app_path]) { @@ -1192,14 +1192,14 @@ void draw_live_area_screen(GuiState &gui, EmuEnvState &emuenv) { ImGui::EndTable(); } }; - const std::array help_items_01{ "browse_app", "start_app", "show_hide", "exit_livearea" }; + constexpr std::array help_items_01{ "browse_app", "start_app", "show_hide", "exit_livearea" }; draw_help_table(gui, help_items_01.data(), help_items_01.size()); ImGui::Spacing(); ImGui::Separator(); ImGui::Spacing(); ImGui::TextColored(GUI_COLOR_TEXT_TITLE, "%s", lang["manual_help"].c_str()); ImGui::Spacing(); - const std::array help_items_02{ "browse_page", "hide_show", "exit_manual" }; + constexpr std::array help_items_02{ "browse_page", "hide_show", "exit_manual" }; draw_help_table(gui, help_items_02.data(), help_items_02.size()); ImGui::Spacing(); diff --git a/vita3k/gui/src/main_menubar.cpp b/vita3k/gui/src/main_menubar.cpp index ea748dd7..85584798 100644 --- a/vita3k/gui/src/main_menubar.cpp +++ b/vita3k/gui/src/main_menubar.cpp @@ -83,7 +83,7 @@ static void draw_emulation_menu(GuiState &gui, EmuEnvState &emuenv) { if (ImGui::BeginMenu(lang["last_apps_used"].c_str())) { if (!app_list_is_empty) { for (size_t i = 0; i < std::min(8, gui.time_apps[emuenv.io.user_id].size()); i++) { - const auto time_app = gui.time_apps[emuenv.io.user_id][i]; + const auto &time_app = gui.time_apps[emuenv.io.user_id][i]; const auto app_index = get_app_index(gui, time_app.app); if (app_index) draw_app(*app_index); diff --git a/vita3k/gui/src/settings.cpp b/vita3k/gui/src/settings.cpp index 8223c5e7..707c1f4f 100644 --- a/vita3k/gui/src/settings.cpp +++ b/vita3k/gui/src/settings.cpp @@ -213,7 +213,7 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) { const auto POPUP_SIZE = ImVec2(756.0f * SCALE.x, 436.0f * SCALE.y); const auto is_background = gui.apps_background.contains("NPXS10015"); - auto common = emuenv.common_dialog.lang.common; + auto &common = emuenv.common_dialog.lang.common; ImGui::SetNextWindowPos(WINDOW_POS, ImGuiCond_Always); ImGui::SetNextWindowSize(WINDOW_SIZE, ImGuiCond_Always); @@ -237,11 +237,11 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) { ImGui::TextColored(GUI_COLOR_TEXT, "%s", title.c_str()); ImGui::PopTextWrapPos(); - auto lang = gui.lang.settings; - auto theme_background = lang.theme_background; - auto theme = theme_background.theme; - auto date_time = lang.date_time; - auto language = lang.language; + auto &lang = gui.lang.settings; + auto &theme_background = lang.theme_background; + auto &theme = theme_background.theme; + auto &date_time = lang.date_time; + auto &language = lang.language; if (settings_menu == THEME_BACKGROUND) { // Search Bar @@ -486,7 +486,7 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) { ImGui::Image(gui.themes_preview[selected][LOCK], SIZE_MINI_PREVIEW); } const auto INFO_POS = ImVec2(280.f * SCALE.x, 30.f * SCALE.y); - auto info = theme.information; + auto &info = theme.information; ImGui::SetWindowFontScale(0.94f); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + INFO_POS.y); ImGui::TextColored(GUI_COLOR_TEXT, "%s", info["name"].c_str()); @@ -717,7 +717,7 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) { if (menu == "date_format") { const auto get_date_format_sting = [&](SceSystemParamDateFormat date_format) { std::string date_format_str; - auto lang = gui.lang.settings.date_time.date_format; + auto &lang = gui.lang.settings.date_time.date_format; switch (date_format) { case SCE_SYSTEM_PARAM_DATE_FORMAT_YYYYMMDD: date_format_str = lang["yyyy_mm_dd"]; break; case SCE_SYSTEM_PARAM_DATE_FORMAT_DDMMYYYY: date_format_str = lang["dd_mm_yyyy"]; break; diff --git a/vita3k/gui/src/themes.cpp b/vita3k/gui/src/themes.cpp index 7b07f705..81546bf1 100644 --- a/vita3k/gui/src/themes.cpp +++ b/vita3k/gui/src/themes.cpp @@ -288,7 +288,7 @@ bool init_theme(GuiState &gui, EmuEnvState &emuenv, const std::string &content_i vfs::FileBuffer buffer; const auto type = notice.first; - const auto name = notice.second; + const auto &name = notice.second; vfs::read_file(VitaIoDevice::ux0, buffer, emuenv.pref_path, fs::path("theme") / content_id_path / name); @@ -308,7 +308,7 @@ bool init_theme(GuiState &gui, EmuEnvState &emuenv, const std::string &content_i } else LOG_ERROR("theme.xml not found for Content ID: {}, in path: {}", content_id, THEME_XML_PATH); } else { - const std::vector app_id_bg_list = { + constexpr std::array app_id_bg_list = { "NPXS10002", "NPXS10006", "NPXS10013", @@ -326,8 +326,8 @@ bool init_theme(GuiState &gui, EmuEnvState &emuenv, const std::string &content_i int32_t height = 0; vfs::FileBuffer buffer; - const auto title_id = icon.first; - const auto name = icon.second; + const auto &title_id = icon.first; + const auto &name = icon.second; if (name.empty()) vfs::read_file(VitaIoDevice::vs0, buffer, emuenv.pref_path, "app/" + title_id + "/sce_sys/icon0.png"); else @@ -410,7 +410,7 @@ void draw_background(GuiState &gui, EmuEnvState &emuenv) { std::string user_bg_path; if (is_user_background) { user_bg_path = gui.users[emuenv.io.user_id].backgrounds[gui.current_user_bg]; - const auto user_background_infos = gui.user_backgrounds_infos[user_bg_path]; + const auto &user_background_infos = gui.user_backgrounds_infos[user_bg_path]; background_pos_min = ImVec2(background_pos_min.x + (user_background_infos.pos.x * SCALE.x), background_pos_min.y + (user_background_infos.pos.y * SCALE.y)); background_pos_max = ImVec2(background_pos_min.x + (user_background_infos.size.x * SCALE.x), background_pos_min.y + (user_background_infos.size.y * SCALE.y)); } @@ -466,7 +466,7 @@ void draw_start_screen(GuiState &gui, EmuEnvState &emuenv) { const auto SCAL_DATE_FONT_SIZE = DATE_FONT_SIZE / ImGui::GetFontSize(); auto DATE_TIME = get_date_time(gui, emuenv, local); - const auto DATE_STR = DATE_TIME[DateTime::DATE_DETAIL]; + const auto &DATE_STR = DATE_TIME[DateTime::DATE_DETAIL]; const auto CALC_DATE_SIZE = ImGui::CalcTextSize(DATE_STR.c_str()); const auto DATE_INIT_SCALE = ImVec2(start_param.date_pos.x * SCALE.x, start_param.date_pos.y * SCALE.y); const auto DATE_SIZE = ImVec2(CALC_DATE_SIZE.x * SCAL_DATE_FONT_SIZE, CALC_DATE_SIZE.y * SCAL_DATE_FONT_SIZE * SCAL_PIX_DATE_FONT); @@ -479,11 +479,11 @@ void draw_start_screen(GuiState &gui, EmuEnvState &emuenv) { const auto LARGE_FONT_SIZE = (116.f * SCALE.y) * DEFAULT_FONT_SCALE; const auto PIX_LARGE_FONT_SCALE = (96.f * SCALE.y) / ImGui::GetFontSize(); - const auto CLOCK_STR = DATE_TIME[DateTime::CLOCK]; + const auto &CLOCK_STR = DATE_TIME[DateTime::CLOCK]; const auto CALC_CLOCK_SIZE = ImGui::CalcTextSize(CLOCK_STR.c_str()); const auto CLOCK_SIZE = ImVec2(CALC_CLOCK_SIZE.x * RES_SCALE.x, CALC_CLOCK_SIZE.y * PIX_LARGE_FONT_SCALE); - const auto DAY_MOMENT_STR = DATE_TIME[DateTime::DAY_MOMENT]; + const auto &DAY_MOMENT_STR = DATE_TIME[DateTime::DAY_MOMENT]; const auto CALC_DAY_MOMENT_SIZE = ImGui::CalcTextSize(DAY_MOMENT_STR.c_str()); const auto DAY_MOMENT_LARGE_FONT_SIZE = (56.f * SCALE.x) * DEFAULT_LARGE_FONT_SCALE; const auto LARGE_FONT_DAY_MOMENT_SCALE = DAY_MOMENT_LARGE_FONT_SIZE / ImGui::GetFontSize(); diff --git a/vita3k/gui/src/trophy_collection.cpp b/vita3k/gui/src/trophy_collection.cpp index ccf9f405..128bcfbf 100644 --- a/vita3k/gui/src/trophy_collection.cpp +++ b/vita3k/gui/src/trophy_collection.cpp @@ -335,7 +335,7 @@ static void get_trophy_list(GuiState &gui, EmuEnvState &emuenv, const std::strin gui.trophy_list[trophy_id].init(gui.imgui_state.get(), data, width, height); stbi_image_free(data); - auto common = gui.lang.common.main; + auto &common = gui.lang.common.main; const auto trophy_type = np_com_id_info[np_com_id].context.trophy_kinds[string_utils::stoi_def(trophy_id, 0, "trophy id")]; switch (trophy_type) { case SceNpTrophyGrade::SCE_NP_TROPHY_GRADE_PLATINUM: @@ -430,8 +430,8 @@ void draw_trophy_collection(GuiState &gui, EmuEnvState &emuenv) { else draw_list->AddRectFilled(VIEWPORT_POS, BG_POS_MAX, IM_COL32(31.f, 12.f, 0.f, 255.f), 0.f, ImDrawFlags_RoundCornersAll); - auto lang = gui.lang.trophy_collection; - auto common = emuenv.common_dialog.lang.common; + auto &lang = gui.lang.trophy_collection; + auto &common = emuenv.common_dialog.lang.common; const auto hidden_trophy_str = gui.lang.common.main["hidden_trophy"].c_str(); if (group_id_selected.empty()) { diff --git a/vita3k/gui/src/trophy_unlocked.cpp b/vita3k/gui/src/trophy_unlocked.cpp index 4b9bf0a3..f37c8513 100644 --- a/vita3k/gui/src/trophy_unlocked.cpp +++ b/vita3k/gui/src/trophy_unlocked.cpp @@ -80,7 +80,7 @@ static void draw_trophy_unlocked(GuiState &gui, EmuEnvState &emuenv, NpTrophyUnl ImGui::Image(gui.trophy_window_icon, ImVec2(TROPHY_WINDOW_ICON_SIZE, TROPHY_WINDOW_ICON_SIZE)); ImGui::NextColumn(); - auto common = gui.lang.common.main; + auto &common = gui.lang.common.main; std::string trophy_kind_s = "?"; switch (callback_data.trophy_kind) { diff --git a/vita3k/gui/src/user_management.cpp b/vita3k/gui/src/user_management.cpp index ade49c2b..5c7ef992 100644 --- a/vita3k/gui/src/user_management.cpp +++ b/vita3k/gui/src/user_management.cpp @@ -534,7 +534,7 @@ void draw_user_management(GuiState &gui, EmuEnvState &emuenv) { const auto draw_avatar = [&](const std::string &user_id, const AvatarSize size, const ImVec2 origin_pos) { draw_user_bg(size, origin_pos); if (gui.users_avatar.contains(user_id)) { - const auto user_avatar_infos = users_avatar_infos[user_id][size]; + const auto &user_avatar_infos = users_avatar_infos[user_id][size]; ImVec2 AVATAR_POS = ImVec2(origin_pos.x + (user_avatar_infos.pos.x * SCALE.x), origin_pos.y + (user_avatar_infos.pos.y * SCALE.y)); ImVec2 AVATAR_SIZE = ImVec2(user_avatar_infos.size.x * SCALE.x, user_avatar_infos.size.y * SCALE.y); ImGui::SetCursorPos(AVATAR_POS); @@ -552,8 +552,8 @@ void draw_user_management(GuiState &gui, EmuEnvState &emuenv) { const auto BUTTON_POS = ImVec2((SIZE_USER.x / 2.f) - (BUTTON_SIZE.x / 2.f), SIZE_USER.y - BUTTON_SIZE.y - (28.f * SCALE.y)); const auto TEXT_USER_PADDING = MED_AVATAR_SIZE.x + (5.f * SCALE.x); const auto USER_NAME_PADDING = 10.f * SCALE.x; - auto lang = gui.lang.user_management; - auto common = emuenv.common_dialog.lang.common; + auto &lang = gui.lang.user_management; + auto &common = emuenv.common_dialog.lang.common; switch (menu) { case SELECT: { diff --git a/vita3k/gui/src/vita3k_update.cpp b/vita3k/gui/src/vita3k_update.cpp index d02b8f15..cfbc13c3 100644 --- a/vita3k/gui/src/vita3k_update.cpp +++ b/vita3k/gui/src/vita3k_update.cpp @@ -61,7 +61,7 @@ bool init_vita3k_update(GuiState &gui) { git_commit_desc_list.clear(); git_version = 0; vita_area_state = {}; - const auto latest_link = "https://api.github.com/repos/Vita3K/Vita3K/releases/latest"; + constexpr auto latest_link = "https://api.github.com/repos/Vita3K/Vita3K/releases/latest"; // Get Build number of latest release const auto version = net_utils::get_web_regex_result(latest_link, std::regex("Vita3K Build: (\\d+)")); @@ -221,8 +221,8 @@ void draw_vita3k_update(GuiState &gui, EmuEnvState &emuenv) { const auto BUTTON_SIZE = ImVec2(150.f * SCALE.x, 46.f * SCALE.y); const auto is_background = gui.apps_background.contains("NPXS10015"); - auto common = emuenv.common_dialog.lang.common; - auto lang = gui.lang.vita3k_update; + auto &common = emuenv.common_dialog.lang.common; + auto &lang = gui.lang.vita3k_update; ImGui::SetNextWindowPos(WINDOW_POS, ImGuiCond_Always); ImGui::SetNextWindowSize(display_size, ImGuiCond_Always); @@ -328,7 +328,7 @@ void draw_vita3k_update(GuiState &gui, EmuEnvState &emuenv) { ImGui::SetCursorPos(ImVec2((ImGui::GetWindowWidth() / 2) - (PROGRESS_BAR_WIDTH / 2.f), display_size.y - (186.f * SCALE.y))); ImGui::PushStyleColor(ImGuiCol_PlotHistogram, GUI_PROGRESS_BAR); ImGui::ProgressBar(progress / 100.f, ImVec2(PROGRESS_BAR_WIDTH, 15.f * SCALE.y), ""); - const auto progress_str = std::to_string(uint32_t(progress)).append("%"); + const auto &progress_str = std::to_string(uint32_t(progress)).append("%"); ImGui::SetCursorPos(ImVec2((ImGui::GetWindowWidth() / 2.f) - (ImGui::CalcTextSize(progress_str.c_str()).x / 2.f), ImGui::GetCursorPosY() + 16.f * emuenv.dpi_scale)); ImGui::TextColored(GUI_COLOR_TEXT, "%s", progress_str.c_str()); ImGui::PopStyleColor(); @@ -370,7 +370,7 @@ void draw_vita3k_update(GuiState &gui, EmuEnvState &emuenv) { ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 10.f * SCALE.x); if (ImGui::BeginPopupModal("cancel_update_popup", &progress_state.pause, ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDecoration)) { const auto LARGE_BUTTON_SIZE = ImVec2(310.f * SCALE.x, 46.f * SCALE.y); - auto common = emuenv.common_dialog.lang.common; + auto &common = emuenv.common_dialog.lang.common; const auto str_size = ImGui::CalcTextSize(lang["cancel_update"].c_str(), 0, false, POPUP_SIZE.x - (120.f * SCALE.x)); ImGui::SetCursorPos(ImVec2(60.f * SCALE.x, (ImGui::GetWindowHeight() / 2.f) - (str_size.y / 2.f))); ImGui::TextWrapped("%s", lang["cancel_update"].c_str()); diff --git a/vita3k/kernel/src/load_self.cpp b/vita3k/kernel/src/load_self.cpp index b159301c..aa2a064a 100644 --- a/vita3k/kernel/src/load_self.cpp +++ b/vita3k/kernel/src/load_self.cpp @@ -348,7 +348,7 @@ static bool load_var_exports(const uint32_t *nids, const Ptr *entries, continue; SegmentInfosForReloc seg; - const auto module_info = kernel.loaded_modules[kernel.module_uid_by_nid[var_binding_info.module_nid]]; + const auto &module_info = kernel.loaded_modules[kernel.module_uid_by_nid[var_binding_info.module_nid]]; if (!module_info) { reloc_success = false; LOG_ERROR("Module not found by nid: {} uid: {}", log_hex(var_binding_info.module_nid), kernel.module_uid_by_nid[var_binding_info.module_nid]); @@ -410,7 +410,7 @@ static bool unload_var_exports(const uint32_t *nids, const Ptr *entrie continue; SegmentInfosForReloc seg; - const auto module_info = kernel.loaded_modules[kernel.module_uid_by_nid[var_binding_info.module_nid]]; + const auto &module_info = kernel.loaded_modules[kernel.module_uid_by_nid[var_binding_info.module_nid]]; if (!module_info) { reloc_success = false; LOG_ERROR("Module not found by nid: {} uid: {}", log_hex(var_binding_info.module_nid), kernel.module_uid_by_nid[var_binding_info.module_nid]); diff --git a/vita3k/modules/SceCommonDialog/SceCommonDialog.cpp b/vita3k/modules/SceCommonDialog/SceCommonDialog.cpp index e8ec1a58..3138caae 100644 --- a/vita3k/modules/SceCommonDialog/SceCommonDialog.cpp +++ b/vita3k/modules/SceCommonDialog/SceCommonDialog.cpp @@ -271,9 +271,9 @@ EXPORT(int, sceMsgDialogInit, const Ptr param) { emuenv.common_dialog.msg.mode = p->mode; emuenv.common_dialog.msg.status = SCE_MSG_DIALOG_BUTTON_ID_INVALID; - auto common = emuenv.common_dialog.lang.common; - auto save = emuenv.common_dialog.lang.save_data.save; - const auto CANCEL = common["cancel"]; + auto &common = emuenv.common_dialog.lang.common; + auto &save = emuenv.common_dialog.lang.save_data.save; + const auto &CANCEL = common["cancel"]; switch (p->mode) { case SCE_MSG_DIALOG_MODE_USER_MSG: @@ -860,7 +860,7 @@ static void check_save_file(const uint32_t index, EmuEnvState &emuenv, const cha } static void handle_user_message(SceSaveDataDialogUserMessageParam *user_message, EmuEnvState &emuenv) { - auto common = emuenv.common_dialog.lang.common; + auto &common = emuenv.common_dialog.lang.common; switch (user_message->buttonType) { case SCE_SAVEDATA_DIALOG_BUTTON_TYPE_OK: emuenv.common_dialog.savedata.btn_num = 1; @@ -882,12 +882,12 @@ static void handle_user_message(SceSaveDataDialogUserMessageParam *user_message, } static void handle_sys_message(SceSaveDataDialogSystemMessageParam *sys_message, EmuEnvState &emuenv) { - auto lang = emuenv.common_dialog.lang; - auto common = lang.common; - auto save_data = lang.save_data; - auto deleting = save_data.deleting; - auto load = save_data.load; - auto save = save_data.save; + auto &lang = emuenv.common_dialog.lang; + auto &common = lang.common; + auto &save_data = lang.save_data; + auto &deleting = save_data.deleting; + auto &load = save_data.load; + auto &save = save_data.save; switch (sys_message->sysMsgType) { case SCE_SAVEDATA_DIALOG_SYSMSG_TYPE_NODATA: @@ -1028,7 +1028,7 @@ EXPORT(int, sceSaveDataDialogContinue, const Ptr param) emuenv.common_dialog.savedata.display_type = p->dispType == 0 ? emuenv.common_dialog.savedata.display_type : p->dispType; emuenv.common_dialog.savedata.userdata = p->userdata; - auto common = emuenv.common_dialog.lang.common; + auto &common = emuenv.common_dialog.lang.common; switch (emuenv.common_dialog.savedata.mode) { default: @@ -1089,8 +1089,8 @@ EXPORT(int, sceSaveDataDialogContinue, const Ptr param) if (progress_bar->msg.get(emuenv.mem) != nullptr) { emuenv.common_dialog.savedata.msg = reinterpret_cast(progress_bar->msg.get(emuenv.mem)); } else { - auto lang = emuenv.common_dialog.lang; - auto save_data = lang.save_data; + auto &lang = emuenv.common_dialog.lang; + auto &save_data = lang.save_data; switch (progress_bar->sysMsgParam.sysMsgType) { case SCE_SAVEDATA_DIALOG_SYSMSG_TYPE_PROGRESS: switch (emuenv.common_dialog.savedata.display_type) { @@ -1166,7 +1166,7 @@ EXPORT(SceInt32, sceSaveDataDialogGetResult, SceSaveDataDialogResult *result) { } if (emuenv.common_dialog.status == SCE_COMMON_DIALOG_STATUS_FINISHED || emuenv.common_dialog.substatus == SCE_COMMON_DIALOG_STATUS_FINISHED) { - auto save_dialog = emuenv.common_dialog.savedata; + auto &save_dialog = emuenv.common_dialog.savedata; auto result_slotinfo = result->slotInfo.get(emuenv.mem); result->mode = save_dialog.mode; @@ -1261,8 +1261,8 @@ EXPORT(int, sceSaveDataDialogInit, const Ptr param) { if (list_param->listTitle.get(emuenv.mem)) { emuenv.common_dialog.savedata.list_title = reinterpret_cast(list_param->listTitle.get(emuenv.mem)); } else { - auto lang = emuenv.common_dialog.lang; - auto save_data = lang.save_data; + auto &lang = emuenv.common_dialog.lang; + auto &save_data = lang.save_data; switch (p->dispType) { case SCE_SAVEDATA_DIALOG_TYPE_SAVE: emuenv.common_dialog.savedata.list_title = save_data.save["title"]; @@ -1316,8 +1316,8 @@ EXPORT(int, sceSaveDataDialogInit, const Ptr param) { if (progress_bar->msg.get(emuenv.mem) != nullptr) { emuenv.common_dialog.savedata.msg = reinterpret_cast(progress_bar->msg.get(emuenv.mem)); } else { - auto lang = emuenv.common_dialog.lang; - auto save_data = lang.save_data; + auto &lang = emuenv.common_dialog.lang; + auto &save_data = lang.save_data; switch (progress_bar->sysMsgParam.sysMsgType) { case SCE_SAVEDATA_DIALOG_SYSMSG_TYPE_PROGRESS: switch (emuenv.common_dialog.savedata.display_type) {