mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2025-02-16 17:59:46 +03:00
settings: added showing of installed game version
This commit is contained in:
parent
14c425ae9b
commit
bf3e58e21c
8 changed files with 96 additions and 17 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -55,6 +55,7 @@ name = "anime-game-launcher"
|
|||
version = "2.0.0-dev"
|
||||
dependencies = [
|
||||
"anime-launcher-sdk",
|
||||
"anyhow",
|
||||
"fluent-templates",
|
||||
"glib-build-tools",
|
||||
"gtk4",
|
||||
|
|
|
@ -29,3 +29,4 @@ fluent-templates = "0.8"
|
|||
unic-langid = "0.9"
|
||||
|
||||
lazy_static = "1.4.0"
|
||||
anyhow = "1.0"
|
||||
|
|
|
@ -12,6 +12,12 @@ repair-game = Repair game
|
|||
status = Status
|
||||
|
||||
game-version = Game version
|
||||
game-not-installed = not installed
|
||||
|
||||
game-predownload-available = Game update pre-downloading available: {$old} -> {$new}
|
||||
game-update-available = Game update available: {$old} -> {$new}
|
||||
game-outdated = Game is too outdated and can't be updated. Latest version: {$latest}
|
||||
|
||||
patch-version = Patch version
|
||||
|
||||
selected-version = Selected version
|
||||
|
|
|
@ -18,8 +18,8 @@ fsr = FSR
|
|||
fsr-description = Для использования установите меньшее разрешение в настройках игры и нажмите Alt+Enter
|
||||
ultra-quality = Ультра
|
||||
quality = Хорошо
|
||||
balanced = Сбалансированно
|
||||
performance = Производительно
|
||||
balanced = Баланс
|
||||
performance = Скорость
|
||||
|
||||
gamemode = Gamemode
|
||||
gamemode-description = Выделять игре приоритет перед остальными процессами
|
||||
|
|
|
@ -12,6 +12,12 @@ repair-game = Починить игру
|
|||
status = Статус
|
||||
|
||||
game-version = Версия игры
|
||||
game-not-installed = не установлена
|
||||
|
||||
game-predownload-available = Доступна предзагрузка обновления игры: {$old} -> {$new}
|
||||
game-update-available = Доступно обновление игры: {$old} -> {$new}
|
||||
game-outdated = Версия игры слишком устаревшая и не может быть обновлена. Последняя версия: {$latest}
|
||||
|
||||
patch-version = Версия патча
|
||||
|
||||
selected-version = Выбранная версия
|
||||
|
|
13
src/i18n.rs
13
src/i18n.rs
|
@ -18,3 +18,16 @@ pub fn tr(id: &str) -> String {
|
|||
.expect(&format!("Failed to find message with a given id: {id}"))
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::expect_fun_call)]
|
||||
pub fn tr_args<I, T>(id: &str, args: I) -> String
|
||||
where
|
||||
I: IntoIterator<Item = (T, fluent_templates::fluent_bundle::FluentValue<'static>)>,
|
||||
T: AsRef<str> + std::hash::Hash + Eq
|
||||
{
|
||||
unsafe {
|
||||
LOCALES
|
||||
.lookup_with_args(&LANG, id, &std::collections::HashMap::from_iter(args.into_iter()))
|
||||
.expect(&format!("Failed to find message with a given id: {id}"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,31 +251,32 @@ impl WidgetTemplate for Enhancements {
|
|||
|
||||
#[wrap(Some)]
|
||||
set_model = >k::StringList::new(&[
|
||||
&tr("custom"),
|
||||
"90",
|
||||
"120",
|
||||
"144",
|
||||
"165",
|
||||
"180",
|
||||
"200",
|
||||
"240"
|
||||
"240",
|
||||
&tr("custom")
|
||||
]),
|
||||
|
||||
set_selected: match Fps::from_num(CONFIG.game.enhancements.fps_unlocker.config.fps) {
|
||||
Fps::Custom(_) => 0,
|
||||
Fps::Ninety => 1,
|
||||
Fps::HundredTwenty => 2,
|
||||
Fps::HundredFourtyFour => 3,
|
||||
Fps::HundredSixtyFive => 4,
|
||||
Fps::HundredEighty => 5,
|
||||
Fps::TwoHundred => 6,
|
||||
Fps::TwoHundredFourty => 7
|
||||
Fps::Ninety => 0,
|
||||
Fps::HundredTwenty => 1,
|
||||
Fps::HundredFourtyFour => 2,
|
||||
Fps::HundredSixtyFive => 3,
|
||||
Fps::HundredEighty => 4,
|
||||
Fps::TwoHundred => 5,
|
||||
Fps::TwoHundredFourty => 6,
|
||||
|
||||
Fps::Custom(_) => 7
|
||||
},
|
||||
|
||||
connect_selected_notify => move |row| {
|
||||
if is_ready() && row.selected() > 0 {
|
||||
if is_ready() && row.selected() < Fps::list().len() as u32 - 1 {
|
||||
if let Ok(mut config) = config::get() {
|
||||
config.game.enhancements.fps_unlocker.config.fps = Fps::list()[row.selected() as usize - 1].to_num();
|
||||
config.game.enhancements.fps_unlocker.config.fps = Fps::list()[row.selected() as usize].to_num();
|
||||
|
||||
config::update(config);
|
||||
}
|
||||
|
|
|
@ -4,12 +4,25 @@ use gtk::prelude::*;
|
|||
use adw::prelude::*;
|
||||
|
||||
use anime_launcher_sdk::config;
|
||||
use anime_launcher_sdk::anime_game_core::prelude::*;
|
||||
use anime_launcher_sdk::anime_game_core::genshin::prelude::*;
|
||||
|
||||
use crate::i18n::tr;
|
||||
use crate::i18n::*;
|
||||
use crate::ui::main::is_ready;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref CONFIG: config::Config = config::get().expect("Failed to load config");
|
||||
|
||||
static ref GAME: Game = Game::new(&CONFIG.game.path.join("fioweiofweuihj"));
|
||||
|
||||
static ref GAME_DIFF: Option<VersionDiff> = match GAME.try_get_diff() {
|
||||
Ok(diff) => Some(diff),
|
||||
Err(err) => {
|
||||
tracing::error!("Failed to get game diff {err}");
|
||||
|
||||
None
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[relm4::widget_template(pub)]
|
||||
|
@ -116,8 +129,46 @@ impl WidgetTemplate for General {
|
|||
set_title: &tr("game-version"),
|
||||
|
||||
add_suffix = >k::Label {
|
||||
set_text: "3.3.0",
|
||||
add_css_class: "success"
|
||||
set_text: &match GAME_DIFF.as_ref() {
|
||||
Some(diff) => match diff {
|
||||
VersionDiff::Latest(current) |
|
||||
VersionDiff::Predownload { current, .. } |
|
||||
VersionDiff::Diff { current, .. } |
|
||||
VersionDiff::Outdated { current, .. } => current.to_string(),
|
||||
|
||||
VersionDiff::NotInstalled { .. } => tr("game-not-installed")
|
||||
}
|
||||
|
||||
None => String::from("?")
|
||||
},
|
||||
|
||||
add_css_class: match GAME_DIFF.as_ref() {
|
||||
Some(diff) => match diff {
|
||||
VersionDiff::Latest(_) => "success",
|
||||
VersionDiff::Predownload { .. } => "accent",
|
||||
VersionDiff::Diff { .. } => "warning",
|
||||
VersionDiff::Outdated { .. } => "error",
|
||||
VersionDiff::NotInstalled { .. } => ""
|
||||
}
|
||||
|
||||
None => "success"
|
||||
},
|
||||
|
||||
set_tooltip_text: Some(&match GAME_DIFF.as_ref().unwrap() {
|
||||
VersionDiff::Latest(_) => String::new(),
|
||||
VersionDiff::Predownload { current, latest, .. } => tr_args("game-predownload-available", [
|
||||
("old", current.to_string().into()),
|
||||
("new", latest.to_string().into())
|
||||
]),
|
||||
VersionDiff::Diff { current, latest, .. } => tr_args("game-update-available", [
|
||||
("old", current.to_string().into()),
|
||||
("new", latest.to_string().into())
|
||||
]),
|
||||
VersionDiff::Outdated { latest, ..} => tr_args("game-outdated", [
|
||||
("latest", latest.to_string().into())
|
||||
]),
|
||||
VersionDiff::NotInstalled { .. } => String::new()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue