Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2e032ca1f |
@@ -1,89 +1,89 @@
|
||||
{
|
||||
"Launch": "Запуск",
|
||||
"Options": "Параметры",
|
||||
"Homebrew Options": "Параметры Homebrew",
|
||||
"Homebrew Options": "Варианты домашнего пивоварения",
|
||||
"Sort By": "Сортировать по",
|
||||
"Sort Options": "Параметры сортировки",
|
||||
"Updated": "Обновлено",
|
||||
"Size": "Размер",
|
||||
"Alphabetical": "По наименованию",
|
||||
"Decending": "По убыванию",
|
||||
"Ascending": "По возрастанию",
|
||||
"Alphabetical": "Алфавитный",
|
||||
"Decending": "по убыванию",
|
||||
"Ascending": "восходящий",
|
||||
"Sort": "Сортировать",
|
||||
"Order": "Порядок",
|
||||
"Order": "Заказ",
|
||||
"Info": "Информация",
|
||||
"Delete": "Удалить",
|
||||
"Hide Sphaira": "Скрыть Sphaira",
|
||||
"Hide Sphaira": "Скрыть Сфаиру",
|
||||
"Are you sure you want to delete ": "Вы уверены, что хотите удалить ",
|
||||
"Install Forwarder": "Установить форвардер",
|
||||
"Install Forwarder": "Установить переадресатор",
|
||||
"WARNING: Installing forwarders will lead to a ban!": "ВНИМАНИЕ: Установка форвардеров приведет к бану!",
|
||||
"Back": "Назад",
|
||||
"Install": "Установить",
|
||||
"Fs": "Фс",
|
||||
"App": "Приложение",
|
||||
"Menu": "Меню",
|
||||
"Homebrew": "Homebrew",
|
||||
"FileBrowser": "Файловый менеджер",
|
||||
"Homebrew": "Домашнее пиво",
|
||||
"FileBrowser": "ФайлБраузер",
|
||||
"Open": "Открыть",
|
||||
"Theme Options": "Параметры темы",
|
||||
"Select Theme": "Выберите тему",
|
||||
"Shuffle": "Перетасовать",
|
||||
"Music": "Музыка",
|
||||
"Show Hidden": "Показать скрытые",
|
||||
"Show Hidden": "Показать скрытое",
|
||||
"Folders First": "Папки в первую очередь",
|
||||
"Hidden Last": "Скрытые в последнюю очередь",
|
||||
"Hidden Last": "Скрытый последний",
|
||||
"Yes": "Да",
|
||||
"No": "Нет",
|
||||
"Network Options": "Параметры сети",
|
||||
"Nxlink": "Nxlink",
|
||||
"Nxlink": "Нкслинк",
|
||||
"Check for update": "Проверить наличие обновлений",
|
||||
"File Options": "Параметры файла",
|
||||
"Cut": "Вырезать",
|
||||
"Cut": "Резать",
|
||||
"Copy": "Копировать",
|
||||
"Rename": "Переименовать",
|
||||
"Advanced Options": "Расширенные параметры",
|
||||
"Advanced Options": "Создать файл",
|
||||
"Create File": "Создать файл",
|
||||
"Create Folder": "Создать папку",
|
||||
"View as text": "Посмотреть как текст",
|
||||
"View as text (unfinished)": "Посмотреть как текст (незакончено)",
|
||||
"Set Archive Bit": "Установить Archive Bit",
|
||||
"Set Archive Bit": "Установить бит архива",
|
||||
"AppStore Options": "Параметры магазина приложений",
|
||||
"All": "Все",
|
||||
"Games": "Игры",
|
||||
"Emulators": "Эмуляторы",
|
||||
"Tools": "Инструменты",
|
||||
"Advanced": "Продвинутые",
|
||||
"Advanced": "Передовой",
|
||||
"Themes": "Темы",
|
||||
"Legacy": "Легаси",
|
||||
"Misc": "Прочее",
|
||||
"Legacy": "Наследие",
|
||||
"Misc": "Разное",
|
||||
"Downloads": "Загрузки",
|
||||
"Filter": "Фильтр",
|
||||
"Search": "Поиск",
|
||||
"Menu Options": "Параметры меню",
|
||||
"Menu Options": "Опции меню",
|
||||
"Header": "Заголовок",
|
||||
"Theme": "Тема",
|
||||
"Network": "Сеть",
|
||||
"Logging": "Журналирование",
|
||||
"Logging": "Ведение журнала",
|
||||
"Enabled": "Включено",
|
||||
"Disabled": "Отключено",
|
||||
"Disabled": "Неполноценный",
|
||||
"Replace hbmenu on exit": "Заменить hbmenu при выходе",
|
||||
"Misc Options": "Прочие параметры",
|
||||
"Themezer": "Themezer",
|
||||
"Irs": "Irs",
|
||||
"Misc Options": "Разные параметры",
|
||||
"Themezer": "Темезер",
|
||||
"Irs": "IRS",
|
||||
"Web": "Интернет",
|
||||
"Download": "Скачать",
|
||||
"Next Page": "Следующая страница",
|
||||
"Prev Page": "Предыдущая страница",
|
||||
"Pad ": "Pad ",
|
||||
"Pad ": "Подушка ",
|
||||
" (Unconnected)": " (Не подключено)",
|
||||
"HandHeld": "Портативный",
|
||||
" (Available)": " (Доступно)",
|
||||
"0 (Sideways)": "0 (набок)",
|
||||
"90 (Flat)": "90 (ровно)",
|
||||
"HandHeld": "Ручной",
|
||||
" (Available)": " (Доступный)",
|
||||
"0 (Sideways)": "0 (вбок)",
|
||||
"90 (Flat)": "90 (квартира)",
|
||||
"180 (-Sideways)": "180 (-вбок)",
|
||||
"270 (Upside down)": "270 (перевернуто)",
|
||||
"270 (Upside down)": "270 (перевернутый)",
|
||||
"Grey": "Серый",
|
||||
"Ironbow": "Стальной",
|
||||
"Ironbow": "Железный лук",
|
||||
"Green": "Зеленый",
|
||||
"Red": "Красный",
|
||||
"Blue": "Синий",
|
||||
@@ -92,7 +92,7 @@
|
||||
"Dim group": "Тусклая группа",
|
||||
"None": "Никто",
|
||||
"Normal image": "Обычное изображение",
|
||||
"Negative image": "Негативное изображение",
|
||||
"Negative image": "Негативный имидж",
|
||||
"320x240": "320x240",
|
||||
"160x120": "160x120",
|
||||
"80x60": "80х60",
|
||||
@@ -101,13 +101,13 @@
|
||||
"Controller": "Контроллер",
|
||||
"Rotation": "Вращение",
|
||||
"Colour": "Цвет",
|
||||
"Light Target": "Световая мишень",
|
||||
"Light Target": "Легкая мишень",
|
||||
"Gain": "Прирост",
|
||||
"Negative Image": "Негативное изображение",
|
||||
"Format": "Формат",
|
||||
"Trimming Format": "Формат обрезки",
|
||||
"External Light Filter": "Внешний светофильтр",
|
||||
"Load Default": "Загрузить умолчания",
|
||||
"Load Default": "Загрузить по умолчанию",
|
||||
"No Internet": "Нет Интернета",
|
||||
"[Applet Mode]": "[Режим апплета]",
|
||||
"Language": "Язык"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
set(sphaira_VERSION 0.4.1)
|
||||
set(sphaira_VERSION 0.4.0)
|
||||
|
||||
project(sphaira
|
||||
VERSION ${sphaira_VERSION}
|
||||
|
||||
@@ -1087,14 +1087,21 @@ Menu::Menu(const std::vector<NroEntry>& nro_entries) : MenuBase{"AppStore"}, m_n
|
||||
// check the date, if older than 1day, then fetch new file
|
||||
// this relaxes the spam to their server, don't want to fetch repo
|
||||
// every time the user opens the app!
|
||||
const auto time_file = time_stamp.created;
|
||||
const auto time_cur = current_time;
|
||||
const auto day = 60 * 60 * 24;
|
||||
if (time_file > time_cur || time_cur - time_file >= day) {
|
||||
log_write("repo.json expired, downloading new! time_file: %zu time_cur: %zu\n", time_file, time_cur);
|
||||
const auto time_file = (time_t)time_stamp.created;
|
||||
const auto time_cur = (time_t)current_time;
|
||||
const auto tm_file = *gmtime(&time_file);
|
||||
const auto tm_cur = *gmtime(&time_cur);
|
||||
if (tm_cur.tm_yday > tm_file.tm_yday || tm_cur.tm_year > tm_file.tm_year) {
|
||||
log_write("repo.json expired, downloading new! cur_yday: %d file_yday: %d | cur_year: %d file_year: %d\n", tm_cur.tm_yday, tm_file.tm_yday, tm_cur.tm_year, tm_file.tm_year);
|
||||
download_file = true;
|
||||
} else {
|
||||
log_write("repo.json not expired! time_file: %zu time_cur: %zu\n", time_file, time_cur);
|
||||
log_write("repo.json not expired! cur_yday: %d file_yday: %d | cur_year: %d file_year: %d\n", tm_cur.tm_yday, tm_file.tm_yday, tm_cur.tm_year, tm_file.tm_year);
|
||||
// time_file = (time_t)time_stamp.modified;
|
||||
// tm_file = *gmtime(&time_file);
|
||||
// log_write("repo.json not expired! cur_yday: %d file_yday: %d | cur_year: %d file_year: %d\n", tm_cur.tm_yday, tm_file.tm_yday, tm_cur.tm_year, tm_file.tm_year);
|
||||
// time_file = (time_t)time_stamp.accessed;
|
||||
// tm_file = *gmtime(&time_file);
|
||||
// log_write("repo.json not expired! cur_yday: %d file_yday: %d | cur_year: %d file_year: %d\n", tm_cur.tm_yday, tm_file.tm_yday, tm_cur.tm_year, tm_file.tm_year);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1431,7 +1438,7 @@ void Menu::Sort() {
|
||||
|
||||
|
||||
char subheader[128]{};
|
||||
std::snprintf(subheader, sizeof(subheader), "Sort: %s | Filter: %s | Order: %s", i18n::get(SORT_STR[m_sort]).c_str(), i18n::get(FILTER_STR[m_filter]).c_str(), i18n::get(ORDER_STR[m_order]).c_str());
|
||||
std::snprintf(subheader, sizeof(subheader), "Sort: %s | Filter: %s | Order: %s", i18n::get(SORT_STR[m_sort]), i18n::get(FILTER_STR[m_filter]), i18n::get(ORDER_STR[m_order]));
|
||||
SetTitleSubHeading(subheader);
|
||||
|
||||
std::sort(m_entries_current.begin(), m_entries_current.end(), sorter);
|
||||
|
||||
@@ -791,9 +791,8 @@ void Menu::Draw(NVGcontext* vg, Theme* theme) {
|
||||
}
|
||||
}
|
||||
const auto t = (time_t)(e.time_stamp.modified);
|
||||
struct tm tm{};
|
||||
localtime_r(&t, &tm);
|
||||
gfx::drawTextArgs(vg, x + w - text_xoffset, y + (h / 2.f) + 3, 16.f, NVG_ALIGN_RIGHT | NVG_ALIGN_TOP, theme->elements[text_id].colour, "%02u/%02u/%u", tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900);
|
||||
const auto tm = gmtime(&t);
|
||||
gfx::drawTextArgs(vg, x + w - text_xoffset, y + (h / 2.f) + 3, 16.f, NVG_ALIGN_RIGHT | NVG_ALIGN_TOP, theme->elements[text_id].colour, "%02u/%02u/%u", tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900);
|
||||
if ((double)e.file_size / 1024.0 / 1024.0 <= 0.009) {
|
||||
gfx::drawTextArgs(vg, x + w - text_xoffset, y + (h / 2.f) - 3, 16.f, NVG_ALIGN_RIGHT | NVG_ALIGN_BOTTOM, theme->elements[text_id].colour, "%.2f KiB", (double)e.file_size / 1024.0);
|
||||
} else {
|
||||
|
||||
@@ -17,11 +17,34 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <minizip/unzip.h>
|
||||
#include <yyjson.h>
|
||||
|
||||
namespace sphaira::ui::menu::main {
|
||||
namespace {
|
||||
|
||||
bool parseSearch(const char *parse_string, const char *filter, char* new_string) {
|
||||
char c;
|
||||
u32 offset = 0;
|
||||
const u32 filter_len = std::strlen(filter) - 1;
|
||||
|
||||
while ((c = parse_string[offset++]) != '\0') {
|
||||
if (c == *filter) {
|
||||
for (u32 i = 0; c == filter[i]; i++) {
|
||||
c = parse_string[offset++];
|
||||
if (i == filter_len) {
|
||||
for (u32 j = 0; c != '\"'; j++) {
|
||||
new_string[j] = c;
|
||||
new_string[j+1] = '\0';
|
||||
c = parse_string[offset++];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto InstallUpdate(ProgressBox* pbox, const std::string url, const std::string version) -> bool {
|
||||
static fs::FsPath zip_out{"/switch/sphaira/cache/update.zip"};
|
||||
constexpr auto chunk_size = 1024 * 512; // 512KiB
|
||||
@@ -146,41 +169,33 @@ auto InstallUpdate(ProgressBox* pbox, const std::string url, const std::string v
|
||||
} // namespace
|
||||
|
||||
MainMenu::MainMenu() {
|
||||
// todo: replace below with yyjson, this is old code from ams updater, lol.
|
||||
DownloadMemoryAsync("https://api.github.com/repos/ITotalJustice/sphaira/releases/latest", "", [this](std::vector<u8>& data, bool success){
|
||||
m_update_state = UpdateState::None;
|
||||
auto json = yyjson_read((const char*)data.data(), data.size(), 0);
|
||||
R_UNLESS(json, false);
|
||||
ON_SCOPE_EXIT(yyjson_doc_free(json));
|
||||
data.push_back('\0');
|
||||
auto raw_str = (const char*)data.data();
|
||||
char out_str[0x301];
|
||||
|
||||
auto root = yyjson_doc_get_root(json);
|
||||
R_UNLESS(root, false);
|
||||
if (parseSearch(raw_str, "tag_name\":\"", out_str)) {
|
||||
m_update_version = out_str;
|
||||
if (std::strcmp(APP_VERSION, m_update_version.c_str()) < 0) {
|
||||
m_update_state = UpdateState::Update;
|
||||
App::Notify("Update avaliable: "_i18n + m_update_version);
|
||||
} else {
|
||||
m_update_state = UpdateState::None;
|
||||
}
|
||||
log_write("found update tag : %s vs %s\n", APP_VERSION, out_str);
|
||||
}
|
||||
|
||||
auto tag_key = yyjson_obj_get(root, "tag_name");
|
||||
R_UNLESS(tag_key, false);
|
||||
if (parseSearch(raw_str, "browser_download_url\":\"", out_str)) {
|
||||
m_update_url = out_str;
|
||||
log_write("found download url : %s\n", out_str);
|
||||
}
|
||||
|
||||
const auto version = yyjson_get_str(tag_key);
|
||||
R_UNLESS(version, false);
|
||||
R_UNLESS(std::strcmp(APP_VERSION, version) < 0, false);
|
||||
|
||||
auto assets = yyjson_obj_get(root, "assets");
|
||||
R_UNLESS(assets, false);
|
||||
|
||||
auto idx0 = yyjson_arr_get(assets, 0);
|
||||
R_UNLESS(idx0, false);
|
||||
|
||||
auto url_key = yyjson_obj_get(idx0, "browser_download_url");
|
||||
R_UNLESS(url_key, false);
|
||||
|
||||
const auto url = yyjson_get_str(url_key);
|
||||
R_UNLESS(url, false);
|
||||
|
||||
m_update_version = version;
|
||||
m_update_url = url;
|
||||
m_update_state = UpdateState::Update;
|
||||
log_write("found url: %s\n", url);
|
||||
App::Notify("Update avaliable: "_i18n + m_update_version);
|
||||
|
||||
return true;
|
||||
if (parseSearch(raw_str, "body\":\"", out_str)) {
|
||||
m_update_description = out_str;
|
||||
// m_update_description.replace("\r\n\r\n", "\n");
|
||||
log_write("found description : %s\n", out_str);
|
||||
}
|
||||
});
|
||||
|
||||
AddOnLPress();
|
||||
|
||||
@@ -32,9 +32,12 @@ void MenuBase::Draw(NVGcontext* vg, Theme* theme) {
|
||||
u32 strength{};
|
||||
u32 ip{};
|
||||
|
||||
const auto t = time(NULL);
|
||||
const auto _time = time(NULL);
|
||||
struct tm tm{};
|
||||
localtime_r(&t, &tm);
|
||||
const auto gmt = gmtime(&_time);
|
||||
if (gmt) {
|
||||
tm = *gmt;
|
||||
}
|
||||
|
||||
// todo: app thread poll every 1s and this query the result
|
||||
psmGetBatteryChargePercentage(&battery_percetange);
|
||||
|
||||
Reference in New Issue
Block a user