1 Commits
0.4.1 ... 0.4.0

6 changed files with 103 additions and 79 deletions

View File

@@ -1,89 +1,89 @@
{ {
"Launch": "Запуск", "Launch": "Запуск",
"Options": "Параметры", "Options": "Параметры",
"Homebrew Options": "Параметры Homebrew", "Homebrew Options": "Варианты домашнего пивоварения",
"Sort By": "Сортировать по", "Sort By": "Сортировать по",
"Sort Options": "Параметры сортировки", "Sort Options": "Параметры сортировки",
"Updated": "Обновлено", "Updated": "Обновлено",
"Size": "Размер", "Size": "Размер",
"Alphabetical": "По наименованию", "Alphabetical": "Алфавитный",
"Decending": "По убыванию", "Decending": "по убыванию",
"Ascending": "По возрастанию", "Ascending": "восходящий",
"Sort": "Сортировать", "Sort": "Сортировать",
"Order": "Порядок", "Order": "Заказ",
"Info": "Информация", "Info": "Информация",
"Delete": "Удалить", "Delete": "Удалить",
"Hide Sphaira": "Скрыть Sphaira", "Hide Sphaira": "Скрыть Сфаиру",
"Are you sure you want to delete ": "Вы уверены, что хотите удалить ", "Are you sure you want to delete ": "Вы уверены, что хотите удалить ",
"Install Forwarder": "Установить форвардер", "Install Forwarder": "Установить переадресатор",
"WARNING: Installing forwarders will lead to a ban!": "ВНИМАНИЕ: Установка форвардеров приведет к бану!", "WARNING: Installing forwarders will lead to a ban!": "ВНИМАНИЕ: Установка форвардеров приведет к бану!",
"Back": "Назад", "Back": "Назад",
"Install": "Установить", "Install": "Установить",
"Fs": "Фс", "Fs": "Фс",
"App": "Приложение", "App": "Приложение",
"Menu": "Меню", "Menu": "Меню",
"Homebrew": "Homebrew", "Homebrew": "Домашнее пиво",
"FileBrowser": "Файловый менеджер", "FileBrowser": "ФайлБраузер",
"Open": "Открыть", "Open": "Открыть",
"Theme Options": "Параметры темы", "Theme Options": "Параметры темы",
"Select Theme": "Выберите тему", "Select Theme": "Выберите тему",
"Shuffle": "Перетасовать", "Shuffle": "Перетасовать",
"Music": "Музыка", "Music": "Музыка",
"Show Hidden": "Показать скрытые", "Show Hidden": "Показать скрытое",
"Folders First": "Папки в первую очередь", "Folders First": "Папки в первую очередь",
"Hidden Last": "Скрытые в последнюю очередь", "Hidden Last": "Скрытый последний",
"Yes": "Да", "Yes": "Да",
"No": "Нет", "No": "Нет",
"Network Options": "Параметры сети", "Network Options": "Параметры сети",
"Nxlink": "Nxlink", "Nxlink": "Нкслинк",
"Check for update": "Проверить наличие обновлений", "Check for update": "Проверить наличие обновлений",
"File Options": "Параметры файла", "File Options": "Параметры файла",
"Cut": "Вырезать", "Cut": "Резать",
"Copy": "Копировать", "Copy": "Копировать",
"Rename": "Переименовать", "Rename": "Переименовать",
"Advanced Options": "Расширенные параметры", "Advanced Options": "Создать файл",
"Create File": "Создать файл", "Create File": "Создать файл",
"Create Folder": "Создать папку", "Create Folder": "Создать папку",
"View as text": "Посмотреть как текст", "View as text": "Посмотреть как текст",
"View as text (unfinished)": "Посмотреть как текст (незакончено)", "View as text (unfinished)": "Посмотреть как текст (незакончено)",
"Set Archive Bit": "Установить Archive Bit", "Set Archive Bit": "Установить бит архива",
"AppStore Options": "Параметры магазина приложений", "AppStore Options": "Параметры магазина приложений",
"All": "Все", "All": "Все",
"Games": "Игры", "Games": "Игры",
"Emulators": "Эмуляторы", "Emulators": "Эмуляторы",
"Tools": "Инструменты", "Tools": "Инструменты",
"Advanced": родвинутые", "Advanced": ередовой",
"Themes": "Темы", "Themes": "Темы",
"Legacy": "Легаси", "Legacy": "Наследие",
"Misc": "Прочее", "Misc": "Разное",
"Downloads": "Загрузки", "Downloads": "Загрузки",
"Filter": "Фильтр", "Filter": "Фильтр",
"Search": "Поиск", "Search": "Поиск",
"Menu Options": "Параметры меню", "Menu Options": "Опции меню",
"Header": "Заголовок", "Header": "Заголовок",
"Theme": "Тема", "Theme": "Тема",
"Network": "Сеть", "Network": "Сеть",
"Logging": "Журналирование", "Logging": "Ведение журнала",
"Enabled": "Включено", "Enabled": "Включено",
"Disabled": "Отключено", "Disabled": "Неполноценный",
"Replace hbmenu on exit": "Заменить hbmenu при выходе", "Replace hbmenu on exit": "Заменить hbmenu при выходе",
"Misc Options": "Прочие параметры", "Misc Options": "Разные параметры",
"Themezer": "Themezer", "Themezer": "Темезер",
"Irs": "Irs", "Irs": "IRS",
"Web": "Интернет", "Web": "Интернет",
"Download": "Скачать", "Download": "Скачать",
"Next Page": "Следующая страница", "Next Page": "Следующая страница",
"Prev Page": "Предыдущая страница", "Prev Page": "Предыдущая страница",
"Pad ": "Pad ", "Pad ": "Подушка ",
" (Unconnected)": " (Не подключено)", " (Unconnected)": " (Не подключено)",
"HandHeld": "Портативный", "HandHeld": "Ручной",
" (Available)": " (Доступно)", " (Available)": " (Доступный)",
"0 (Sideways)": "0 (набок)", "0 (Sideways)": "0 (вбок)",
"90 (Flat)": "90 (ровно)", "90 (Flat)": "90 (квартира)",
"180 (-Sideways)": "180 (-вбок)", "180 (-Sideways)": "180 (-вбок)",
"270 (Upside down)": "270 (перевернуто)", "270 (Upside down)": "270 (перевернутый)",
"Grey": "Серый", "Grey": "Серый",
"Ironbow": "Стальной", "Ironbow": "Железный лук",
"Green": "Зеленый", "Green": "Зеленый",
"Red": "Красный", "Red": "Красный",
"Blue": "Синий", "Blue": "Синий",
@@ -92,7 +92,7 @@
"Dim group": "Тусклая группа", "Dim group": "Тусклая группа",
"None": "Никто", "None": "Никто",
"Normal image": "Обычное изображение", "Normal image": "Обычное изображение",
"Negative image": "Негативное изображение", "Negative image": "Негативный имидж",
"320x240": "320x240", "320x240": "320x240",
"160x120": "160x120", "160x120": "160x120",
"80x60": "80х60", "80x60": "80х60",
@@ -101,13 +101,13 @@
"Controller": "Контроллер", "Controller": "Контроллер",
"Rotation": "Вращение", "Rotation": "Вращение",
"Colour": "Цвет", "Colour": "Цвет",
"Light Target": "Световая мишень", "Light Target": "Легкая мишень",
"Gain": "Прирост", "Gain": "Прирост",
"Negative Image": "Негативное изображение", "Negative Image": "Негативное изображение",
"Format": "Формат", "Format": "Формат",
"Trimming Format": "Формат обрезки", "Trimming Format": "Формат обрезки",
"External Light Filter": "Внешний светофильтр", "External Light Filter": "Внешний светофильтр",
"Load Default": "Загрузить умолчания", "Load Default": "Загрузить по умолчанию",
"No Internet": "Нет Интернета", "No Internet": "Нет Интернета",
"[Applet Mode]": "[Режим апплета]", "[Applet Mode]": "[Режим апплета]",
"Language": "Язык" "Language": "Язык"

View File

@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
set(sphaira_VERSION 0.4.1) set(sphaira_VERSION 0.4.0)
project(sphaira project(sphaira
VERSION ${sphaira_VERSION} VERSION ${sphaira_VERSION}

View File

@@ -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 // check the date, if older than 1day, then fetch new file
// this relaxes the spam to their server, don't want to fetch repo // this relaxes the spam to their server, don't want to fetch repo
// every time the user opens the app! // every time the user opens the app!
const auto time_file = time_stamp.created; const auto time_file = (time_t)time_stamp.created;
const auto time_cur = current_time; const auto time_cur = (time_t)current_time;
const auto day = 60 * 60 * 24; const auto tm_file = *gmtime(&time_file);
if (time_file > time_cur || time_cur - time_file >= day) { const auto tm_cur = *gmtime(&time_cur);
log_write("repo.json expired, downloading new! time_file: %zu time_cur: %zu\n", time_file, 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; download_file = true;
} else { } 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]{}; 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); SetTitleSubHeading(subheader);
std::sort(m_entries_current.begin(), m_entries_current.end(), sorter); std::sort(m_entries_current.begin(), m_entries_current.end(), sorter);

View File

@@ -791,9 +791,8 @@ void Menu::Draw(NVGcontext* vg, Theme* theme) {
} }
} }
const auto t = (time_t)(e.time_stamp.modified); const auto t = (time_t)(e.time_stamp.modified);
struct tm tm{}; const auto tm = gmtime(&t);
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);
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) { 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); 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 { } else {

View File

@@ -17,11 +17,34 @@
#include <cstring> #include <cstring>
#include <minizip/unzip.h> #include <minizip/unzip.h>
#include <yyjson.h>
namespace sphaira::ui::menu::main { namespace sphaira::ui::menu::main {
namespace { 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 { auto InstallUpdate(ProgressBox* pbox, const std::string url, const std::string version) -> bool {
static fs::FsPath zip_out{"/switch/sphaira/cache/update.zip"}; static fs::FsPath zip_out{"/switch/sphaira/cache/update.zip"};
constexpr auto chunk_size = 1024 * 512; // 512KiB constexpr auto chunk_size = 1024 * 512; // 512KiB
@@ -146,41 +169,33 @@ auto InstallUpdate(ProgressBox* pbox, const std::string url, const std::string v
} // namespace } // namespace
MainMenu::MainMenu() { 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){ DownloadMemoryAsync("https://api.github.com/repos/ITotalJustice/sphaira/releases/latest", "", [this](std::vector<u8>& data, bool success){
m_update_state = UpdateState::None; data.push_back('\0');
auto json = yyjson_read((const char*)data.data(), data.size(), 0); auto raw_str = (const char*)data.data();
R_UNLESS(json, false); char out_str[0x301];
ON_SCOPE_EXIT(yyjson_doc_free(json));
auto root = yyjson_doc_get_root(json); if (parseSearch(raw_str, "tag_name\":\"", out_str)) {
R_UNLESS(root, false); 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"); if (parseSearch(raw_str, "browser_download_url\":\"", out_str)) {
R_UNLESS(tag_key, false); m_update_url = out_str;
log_write("found download url : %s\n", out_str);
}
const auto version = yyjson_get_str(tag_key); if (parseSearch(raw_str, "body\":\"", out_str)) {
R_UNLESS(version, false); m_update_description = out_str;
R_UNLESS(std::strcmp(APP_VERSION, version) < 0, false); // m_update_description.replace("\r\n\r\n", "\n");
log_write("found description : %s\n", out_str);
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;
}); });
AddOnLPress(); AddOnLPress();

View File

@@ -32,9 +32,12 @@ void MenuBase::Draw(NVGcontext* vg, Theme* theme) {
u32 strength{}; u32 strength{};
u32 ip{}; u32 ip{};
const auto t = time(NULL); const auto _time = time(NULL);
struct tm tm{}; 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 // todo: app thread poll every 1s and this query the result
psmGetBatteryChargePercentage(&battery_percetange); psmGetBatteryChargePercentage(&battery_percetange);