feat(ui): added menu button to open wishes history in your browser

This commit is contained in:
Observer KRypt0n_ 2023-03-23 15:53:26 +02:00
parent 261adc3b2d
commit 666a3e2976
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
15 changed files with 91 additions and 0 deletions

View file

@ -3,6 +3,9 @@ game-folder-opening-error = Spieleordner konnte nicht geöffnet werden
config-file-opening-error = Konfig-Datei konnte nicht geöffnet werden
debug-file-opening-error = Debug-Datei konnte nicht geöffnet werden
wish-url-search-failed = Kein Wünsche URL gefunden
wish-url-opening-error = Wünsche URL konnte nicht geöffnet werden
game-launching-failed = Spiel konnte nicht gestartet werden
failed-get-selected-wine = Die ausgewählte Wine version konnte nicht abgerufen werden.
downloading-failed = Herunterladen fehlgeschlagen

View file

@ -12,6 +12,7 @@ launcher-folder = Launcher-Ordner
game-folder = Spielordner
config-file = Konfig-Datei
debug-file = Debug-Datei
wish-url = Wünsche öffnen
about = Über

View file

@ -3,6 +3,9 @@ game-folder-opening-error = Failed to open game folder
config-file-opening-error = Failed to open config file
debug-file-opening-error = Failed to open debug file
wish-url-search-failed = No wishes url found
wish-url-opening-error = Could not open wishes url
game-launching-failed = Failed to launch game
failed-get-selected-wine = Failed to get selected wine version
downloading-failed = Downloading failed

View file

@ -12,6 +12,7 @@ launcher-folder = Launcher folder
game-folder = Game folder
config-file = Config file
debug-file = Debug file
wish-url = Open wishes
about = About

View file

@ -3,6 +3,9 @@ game-folder-opening-error = Fallo al abrir la carpeta del juego
config-file-opening-error = Fallo al abrir el archivo de configuración
debug-file-opening-error = Fallo al abrir el archivo de debug
wish-url-search-failed = No wishes url found
wish-url-opening-error = Could not open wishes url
game-launching-failed = Fallo al iniciar el juego
failed-get-selected-wine = Fallo al buscar la versión elegida de Wine
downloading-failed = Descarga fallida

View file

@ -12,6 +12,7 @@ launcher-folder = Carpeta del launcher
game-folder = Carpeta del juego
config-file = Archivo de configuración
debug-file = Archivo de debug
wish-url = Open wishes
about = Acerca de

View file

@ -3,6 +3,9 @@ game-folder-opening-error = Impossible d'ouvrir l'emplacement du jeu
config-file-opening-error = Impossible d'ouvrir le fichier de configuration
debug-file-opening-error = Impossible d'ouvrir le fichier débug
wish-url-search-failed = No wishes url found
wish-url-opening-error = Could not open wishes url
game-launching-failed = Impossible de lancer le jeu
failed-get-selected-wine = Impossible de récupérer la version de wine sélectionnée
downloading-failed = Le téléchargement a échoué

View file

@ -12,6 +12,7 @@ launcher-folder = Dossier du launcher
game-folder = Dossier du jeu
config-file = Fichier de configuration
debug-file = Fichier débug
wish-url = Open wishes
about = À propos

View file

@ -3,6 +3,9 @@ game-folder-opening-error = Не удалось открыть папку игр
config-file-opening-error = Не удалось открыть файл настроек
debug-file-opening-error = Не удалось открыть файл отладки
wish-url-search-failed = Ссылка на историю молитв не найдена
wish-url-opening-error = Не удалось открыть ссылку с историей молитв
game-launching-failed = Не удалось запустить игру
failed-get-selected-wine = Не удалось найти выбранную версию Wine
downloading-failed = Ошибка загрузки

View file

@ -12,6 +12,7 @@ launcher-folder = Папка лаунчера
game-folder = Папка игры
config-file = Файл настроек
debug-file = Журнал отладки
wish-url = Открыть историю молитв
about = О программе

View file

@ -3,6 +3,9 @@ game-folder-opening-error = Oyun dosyasını açma başarısız oldu
config-file-opening-error = Config dosyasını açma başarısız oldu
debug-file-opening-error = Debug dosyasını açma başarısız oldu
wish-url-search-failed = Dilekler urlsi bulunamadı
wish-url-opening-error = Dilekler urlsi açılamadı
game-launching-failed = Oyunu açma başarısız oldu
failed-get-selected-wine = Seçilen Wine versiyonunu alma başarısız oldu
downloading-failed = İndirme başarısız oldu

View file

@ -12,6 +12,7 @@ launcher-folder = İstemci dosyası
game-folder = Oyun dosyası
config-file = Config dosyaso
debug-file = Debug dosyası
wish-url = Dilekleri aç
about = Hakkında

View file

@ -3,6 +3,9 @@ game-folder-opening-error = 打开游戏文件夹失败
config-file-opening-error = 打开配置文件失败
debug-file-opening-error = 打开调试文件失败
wish-url-search-failed = No wishes url found
wish-url-opening-error = Could not open wishes url
game-launching-failed = 启动游戏失败
failed-get-selected-wine = 选择 Wine 版本失败
downloading-failed = 下载失败

View file

@ -12,6 +12,7 @@ launcher-folder = 启动器文件夹
game-folder = 游戏文件夹
config-file = 配置文件
debug-file = 调试文件
wish-url = Open wishes
about = 关于

View file

@ -34,6 +34,7 @@ relm4::new_stateless_action!(LauncherFolder, WindowActionGroup, "launcher_folder
relm4::new_stateless_action!(GameFolder, WindowActionGroup, "game_folder");
relm4::new_stateless_action!(ConfigFile, WindowActionGroup, "config_file");
relm4::new_stateless_action!(DebugFile, WindowActionGroup, "debug_file");
relm4::new_stateless_action!(WishUrl, WindowActionGroup, "wish_url");
relm4::new_stateless_action!(About, WindowActionGroup, "about");
@ -119,6 +120,10 @@ impl SimpleComponent for App {
&tr("debug-file") => DebugFile,
},
section! {
&tr("wish-url") => WishUrl
},
section! {
&tr("about") => About
}
@ -585,6 +590,64 @@ impl SimpleComponent for App {
}
})));
group.add_action::<WishUrl>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
std::thread::spawn(clone!(@strong sender => move || {
let web_cache = CONFIG.game.path
.join(unsafe { anime_launcher_sdk::anime_game_core::genshin::consts::DATA_FOLDER_NAME })
.join("webCaches/Cache/Cache_Data/data_2");
if !web_cache.exists() {
tracing::error!("Couldn't find wishes URL: cache file doesn't exist");
sender.input(AppMsg::Toast {
title: tr("wish-url-search-failed"),
description: None
});
}
else {
match std::fs::read(&web_cache) {
Ok(web_cache) => {
let web_cache = String::from_utf8_lossy(&web_cache);
// https://webstatic-sea.[ho-yo-ver-se].com/[ge-nsh-in]/event/e20190909gacha-v2/index.html?......
if let Some(url) = web_cache.lines().rev().find(|line| line.contains("gacha-v2/index.html")) {
let url_begin_pos = url.find("https://").unwrap();
let url_end_pos = url_begin_pos + url[url_begin_pos..].find("\0\0\0\0").unwrap();
if let Err(err) = open::that(format!("{}#/log", &url[url_begin_pos..url_end_pos])) {
tracing::error!("Failed to open wishes URL: {err}");
sender.input(AppMsg::Toast {
title: tr("wish-url-opening-error"),
description: Some(err.to_string())
});
}
}
else {
tracing::error!("Couldn't find wishes URL: no url found");
sender.input(AppMsg::Toast {
title: tr("wish-url-search-failed"),
description: None
});
}
}
Err(err) => {
tracing::error!("Couldn't find wishes URL: failed to open cache file: {err}");
sender.input(AppMsg::Toast {
title: tr("wish-url-search-failed"),
description: Some(err.to_string())
});
}
}
}
}));
})));
group.add_action::<About>(&RelmAction::new_stateless(move |_| {
about_dialog_broker.send(AboutDialogMsg::Show);
}));