mirror of
https://github.com/storytold/craft-launcher.git
synced 2026-11-02 18:07:04 +00:00
feat(versions): install the chosen version from the Choose version dialog
Choosing a version keeps the dialog open. An Install version {tag} button sits at its
bottom right, enabled once that exact release has been checked (Checking... while a
nightly is looked up, Installed when it is the installed copy). Install from the dialog
may open the folder dialog in its place, which dialogs() now keeps instead of
restoring the old one. The help line keeps only the files warning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,10 @@ impl LauncherUi {
|
||||
Dialog::LauncherUpdate(r) => modal.show(ctx, |ui| close = self.launcher_update_dialog(ui, r)),
|
||||
Dialog::Versions(id) => modal.show(ctx, |ui| close = self.version_dialog(ui, id)),
|
||||
};
|
||||
if self.dialog.as_ref().is_some_and(|active| active.key() != dialog.key()) {
|
||||
// A control inside a dialog opened a different one; don't restore the old dialog.
|
||||
return;
|
||||
}
|
||||
if close || response.should_close() {
|
||||
self.dialog = None;
|
||||
} else {
|
||||
|
||||
@@ -359,5 +359,5 @@ column Author Autor
|
||||
Install version {version} Nainstalovat verzi {version}
|
||||
Download selected version Stáhnout vybranou verzi
|
||||
Older launcher versions require a manual reinstall. Starší verze spouštěče vyžadují ruční přeinstalaci.
|
||||
After choosing a version, Install version appears in place of Open. Your files may not open in older versions. Po výběru verze se na místě Otevřít zobrazí Nainstalovat verzi. Starší verze nemusí vaše soubory otevřít.
|
||||
Your files may not open in older versions. Starší verze nemusí vaše soubory otevřít.
|
||||
Enable automatic installs in Settings to follow new nightly builds. Chcete-li automaticky dostávat nová noční sestavení, zapněte v nastavení automatické instalace.
|
||||
|
||||
|
@@ -391,5 +391,5 @@ column Author Autor
|
||||
Install version {version} Version {version} installieren
|
||||
Download selected version Ausgewählte Version herunterladen
|
||||
Older launcher versions require a manual reinstall. Ältere Launcher-Versionen müssen manuell neu installiert werden.
|
||||
After choosing a version, Install version appears in place of Open. Your files may not open in older versions. Nach der Wahl einer Version erscheint anstelle von Öffnen die Schaltfläche Version installieren. Ältere Versionen können deine Dateien möglicherweise nicht öffnen.
|
||||
Your files may not open in older versions. Ältere Versionen können deine Dateien möglicherweise nicht öffnen.
|
||||
Enable automatic installs in Settings to follow new nightly builds. Aktiviere automatische Installationen in den Einstellungen, um neuen Nightly-Builds zu folgen.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 11 and column 16.
|
@@ -372,5 +372,5 @@ column Author Autor
|
||||
Install version {version} Instalar la versión {version}
|
||||
Download selected version Descargar la versión seleccionada
|
||||
Older launcher versions require a manual reinstall. Las versiones anteriores del iniciador requieren una reinstalación manual.
|
||||
After choosing a version, Install version appears in place of Open. Your files may not open in older versions. Al elegir una versión, Instalar la versión aparece en lugar de Abrir. Es posible que tus archivos no se abran en versiones antiguas.
|
||||
Your files may not open in older versions. Es posible que tus archivos no se abran en versiones antiguas.
|
||||
Enable automatic installs in Settings to follow new nightly builds. Activa las instalaciones automáticas en Ajustes para recibir las nuevas versiones nocturnas.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 48.
|
@@ -389,5 +389,5 @@ column Author Auteur
|
||||
Install version {version} Installer la version {version}
|
||||
Download selected version Télécharger la version choisie
|
||||
Older launcher versions require a manual reinstall. Les anciennes versions du lanceur nécessitent une réinstallation manuelle.
|
||||
After choosing a version, Install version appears in place of Open. Your files may not open in older versions. Après avoir choisi une version, Installer la version apparaît à la place de Ouvrir. Tes fichiers pourraient ne pas s’ouvrir avec une ancienne version.
|
||||
Your files may not open in older versions. Tes fichiers pourraient ne pas s’ouvrir avec une ancienne version.
|
||||
Enable automatic installs in Settings to follow new nightly builds. Active les installations automatiques dans les paramètres pour recevoir les nouvelles versions nocturnes.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 50.
|
@@ -392,5 +392,5 @@ column Author Szerző
|
||||
Install version {version} A(z) {version} verzió telepítése
|
||||
Download selected version Kiválasztott verzió letöltése
|
||||
Older launcher versions require a manual reinstall. Az indító régebbi verzióit kézzel kell újratelepíteni.
|
||||
After choosing a version, Install version appears in place of Open. Your files may not open in older versions. Verzió kiválasztása után a Telepítés gomb jelenik meg a Megnyitás helyén. Előfordulhat, hogy a régebbi verziók nem tudják megnyitni a fájljaidat.
|
||||
Your files may not open in older versions. Előfordulhat, hogy a régebbi verziók nem tudják megnyitni a fájljaidat.
|
||||
Enable automatic installs in Settings to follow new nightly builds. Az új éjszakai kiadások követéséhez kapcsold be az automatikus telepítést a beállításokban.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 11 and column 16.
|
@@ -394,5 +394,5 @@ column Author 作者
|
||||
Install version {version} バージョン {version} をインストール
|
||||
Download selected version 選択したバージョンをダウンロード
|
||||
Older launcher versions require a manual reinstall. 古いランチャーに戻すには手動で再インストールする必要があります。
|
||||
After choosing a version, Install version appears in place of Open. Your files may not open in older versions. バージョンを選ぶと、「開く」の代わりに「バージョンをインストール」が表示されます。古いバージョンではファイルを開けない場合があります。
|
||||
Your files may not open in older versions. 古いバージョンではファイルを開けない場合があります。
|
||||
Enable automatic installs in Settings to follow new nightly builds. 新しいナイトリービルドを自動的に受け取るには、設定で自動インストールを有効にしてください。
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 14 and column 44.
|
@@ -393,5 +393,5 @@ column Author Autor
|
||||
Install version {version} Zainstaluj wersję {version}
|
||||
Download selected version Pobierz wybraną wersję
|
||||
Older launcher versions require a manual reinstall. Starsze wersje programu uruchamiającego wymagają ręcznej ponownej instalacji.
|
||||
After choosing a version, Install version appears in place of Open. Your files may not open in older versions. Po wybraniu wersji na miejscu opcji Otwórz pojawi się Zainstaluj wersję. Starsza wersja może nie otwierać Twoich plików.
|
||||
Your files may not open in older versions. Starsza wersja może nie otwierać Twoich plików.
|
||||
Enable automatic installs in Settings to follow new nightly builds. Włącz automatyczne instalacje w Ustawieniach, aby otrzymywać nowe wersje nocne.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 11 and column 15.
|
@@ -379,5 +379,5 @@ column Author Autor
|
||||
Install version {version} Instalar a versão {version}
|
||||
Download selected version Baixar a versão selecionada
|
||||
Older launcher versions require a manual reinstall. Versões antigas do inicializador exigem reinstalação manual.
|
||||
After choosing a version, Install version appears in place of Open. Your files may not open in older versions. Ao escolher uma versão, Instalar a versão aparece no lugar de Abrir. Seus arquivos podem não abrir em versões antigas.
|
||||
Your files may not open in older versions. Seus arquivos podem não abrir em versões antigas.
|
||||
Enable automatic installs in Settings to follow new nightly builds. Ative as instalações automáticas nas Configurações para receber as novas versões noturnas.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 257 and column 66.
|
@@ -387,5 +387,5 @@ column Author Автор
|
||||
Install version {version} Установить версию {version}
|
||||
Download selected version Скачать выбранную версию
|
||||
Older launcher versions require a manual reinstall. Для возврата к старой версии лаунчера нужна переустановка вручную.
|
||||
After choosing a version, Install version appears in place of Open. Your files may not open in older versions. После выбора версии на месте кнопки «Открыть» появится «Установить версию». В старой версии ваши файлы могут не открыться.
|
||||
Your files may not open in older versions. В старой версии ваши файлы могут не открыться.
|
||||
Enable automatic installs in Settings to follow new nightly builds. Чтобы получать новые ночные сборки, включите автоматическую установку в настройках.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 13 and column 44.
|
@@ -359,5 +359,5 @@ column Version 版本
|
||||
Install version {version} 安装版本 {version}
|
||||
Download selected version 下载所选版本
|
||||
Older launcher versions require a manual reinstall. 旧版启动器需要手动重新安装。
|
||||
After choosing a version, Install version appears in place of Open. Your files may not open in older versions. 选择版本后,「打开」会变为「安装版本」。旧版可能无法打开你的文件。
|
||||
Your files may not open in older versions. 旧版可能无法打开你的文件。
|
||||
Enable automatic installs in Settings to follow new nightly builds. 在设置中启用自动安装,即可跟进新的每日构建版。
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 3.
|
@@ -2,6 +2,7 @@
|
||||
use artcraft_launcher_core::catalog::{CraftApp, LAUNCHER, LAUNCHER_ID};
|
||||
use artcraft_launcher_core::protocol::VersionTrack;
|
||||
use artcraft_launcher_core::release::{Release, is_nightly};
|
||||
use artcraft_launcher_core::version;
|
||||
use egui::{RichText, Ui};
|
||||
|
||||
use crate::app::LauncherUi;
|
||||
@@ -17,15 +18,53 @@ impl LauncherUi {
|
||||
ui.heading(format!("{} · {}", app.name, tl!("Choose version")));
|
||||
ui.add_space(8.0);
|
||||
let label = ui.label(tl!("Version"));
|
||||
let selected = self.version_combo(ui, id, app, 440.0, label.id);
|
||||
// A choice keeps the dialog open: the Install button below follows it.
|
||||
self.version_combo(ui, id, app, 440.0, label.id);
|
||||
ui.add_space(10.0);
|
||||
ui.label(
|
||||
RichText::new(tl!("After choosing a version, Install version appears in place of Open. Your files may not open in older versions."))
|
||||
.color(t.muted),
|
||||
);
|
||||
ui.label(RichText::new(tl!("Your files may not open in older versions.")).color(t.muted));
|
||||
ui.label(RichText::new(tl!("Enable automatic installs in Settings to follow new nightly builds.")).color(t.muted));
|
||||
ui.add_space(12.0);
|
||||
selected || widgets::button(ui, tl!("Close"), Kind::Secondary, 100.0).clicked()
|
||||
let (mut close, mut install) = (false, false);
|
||||
ui.horizontal(|ui| {
|
||||
close = widgets::button(ui, tl!("Close"), Kind::Secondary, 100.0).clicked();
|
||||
if let Some((label, ready)) = self.chosen_install(id) {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
install = ui.add_enabled_ui(ready, |ui| widgets::button(ui, &label, Kind::Primary, 220.0)).inner.clicked();
|
||||
});
|
||||
}
|
||||
});
|
||||
if install {
|
||||
// May open the folder dialog in this one's place; `dialogs` keeps it.
|
||||
self.install_app(id);
|
||||
return true;
|
||||
}
|
||||
close
|
||||
}
|
||||
|
||||
/// The dialog's Install button for the chosen version: its label, and whether that exact release
|
||||
/// has been checked, can be downloaded here and isn't the installed copy. `None` when there is
|
||||
/// nothing to install (no choice the backend can answer, or a job already running).
|
||||
fn chosen_install(&self, id: &str) -> Option<(String, bool)> {
|
||||
let entry = self.entry(id)?;
|
||||
if !self.caps.manage_apps || entry.job.is_some() {
|
||||
return None;
|
||||
}
|
||||
let release = entry.release();
|
||||
let tag = match self.settings.versions.get(id).cloned().unwrap_or_default() {
|
||||
VersionTrack::Pinned(tag) => tag,
|
||||
VersionTrack::Nightly => match release {
|
||||
Some(r) if is_nightly(r) => r.tag.clone(),
|
||||
_ if self.checking => return Some((tl!("Checking…").to_string(), false)),
|
||||
_ => return None,
|
||||
},
|
||||
VersionTrack::Stable => release.filter(|r| !r.prerelease)?.tag.clone(),
|
||||
};
|
||||
let installed = entry.installed.as_ref().and_then(|i| i.version.as_ref());
|
||||
if installed.is_some() && installed == version::parse(&tag).as_ref() {
|
||||
return Some((tl!("Installed").to_string(), false));
|
||||
}
|
||||
let ready = release.is_some_and(|r| r.tag == tag) && entry.has_download(self.platform);
|
||||
Some((crate::fmt(tl!("Install version {version}"), &[("version", &tag)]), ready))
|
||||
}
|
||||
|
||||
pub(crate) fn version_combo(&mut self, ui: &mut Ui, id: &str, app: &CraftApp, width: f32, label: egui::Id) -> bool {
|
||||
|
||||
@@ -495,15 +495,18 @@ fn choosing_an_app_version_turns_its_main_action_into_install() {
|
||||
"selection must refresh the release used by Install"
|
||||
);
|
||||
assert!(!sent.borrow().iter().any(|c| matches!(c, Command::Install { .. })), "selection itself must not install");
|
||||
h.run_steps(2);
|
||||
assert!(h.query_by_label("Version").is_none(), "choosing a version closes the dialog");
|
||||
h.get_by_label("More actions for PhotoCraft").click();
|
||||
h.run_steps(3);
|
||||
assert!(h.query_by_label("Install selected version").is_none(), "no second install action should hide in the menu");
|
||||
h.get_all_by_label("Install version v0.4.0").next().unwrap().click();
|
||||
h.run_steps(2);
|
||||
h.run_steps(4);
|
||||
assert!(h.query_by_label("Version").is_some(), "choosing a version keeps the dialog open");
|
||||
// The dialog's own Install sits on its Close button's row; the card shows the same label.
|
||||
let row = h.get_by_label("Close").rect().center().y;
|
||||
h.get_all_by_label("Install version v0.4.0")
|
||||
.find(|n| (n.rect().center().y - row).abs() < 4.0)
|
||||
.expect("the dialog offers Install for the chosen version")
|
||||
.click();
|
||||
h.run_steps(4);
|
||||
assert!(sent.borrow().iter().any(|c| matches!(c, Command::Install { app } if app == "photocraft")));
|
||||
assert!(!sent.borrow().iter().any(|c| matches!(c, Command::Launch { app } if app == "photocraft")));
|
||||
assert!(h.query_by_label("Version").is_none(), "installing closes the dialog");
|
||||
// Once the pinned version is the installed copy, the card opens it again.
|
||||
let opens = h.query_all_by_label("Open").count();
|
||||
queue.borrow_mut().push(Event::Detected {
|
||||
|
||||
Reference in New Issue
Block a user