diff --git a/i18n/en/Editor.resx b/i18n/en/Editor.resx index 8c4cc113..f6a59fbb 100644 --- a/i18n/en/Editor.resx +++ b/i18n/en/Editor.resx @@ -184,6 +184,15 @@ This frame cannot be read. Vectors original | corrected + Project file applied + The project file’s settings were not applied.long + The sequence of this project file is not in the library.long + Retry + Save project file + Project file saved + Project file folder + Undo + This file is not a Titano project or cannot be read.long Proxies not received Getting the proxies Auto diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx index 71b9d485..7c28df55 100644 --- a/i18n/en/Tooltips.resx +++ b/i18n/en/Tooltips.resx @@ -210,6 +210,10 @@ Show or hide the shot data Overlay the motion to the next frame measured by the engine Drag the line to compare · drag to pan · wheel zooms · double-click 1:1 + Project files are for sequences in an archive on this PC + Apply the project file’s settings again + Save a .titano file that opens this sequence with these settings when double-clicked + Bring back the settings the sequence had before the file was opened · Ctrl+Z Your account can look at this server sequence but not change it Edited with proxies on this PC; changes are saved on {0} and analyses and renders run there Shown from {0}; your account can look at this sequence but not change it diff --git a/i18n/it/Editor.it.resx b/i18n/it/Editor.it.resx index b91e383a..1e8570ad 100644 --- a/i18n/it/Editor.it.resx +++ b/i18n/it/Editor.it.resx @@ -173,6 +173,15 @@ Questo fotogramma non si può leggere. Vettori originale | corretto + File di progetto applicato + Le impostazioni del file di progetto non sono state applicate.long + La sequenza di questo file di progetto non è nella libreria.long + Riprova + Salva file progetto + File di progetto salvato + Cartella file progetto + Annulla + Questo file non è un progetto Titano o non si può leggere.long Proxy non ricevuti Scaricamento dei proxy Auto diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx index acfb90d1..bfa8bc87 100644 --- a/i18n/it/Tooltips.it.resx +++ b/i18n/it/Tooltips.it.resx @@ -210,6 +210,10 @@ Mostra o nasconde i dati di scatto Sovrappone il movimento verso il fotogramma successivo misurato dal motore Trascina la linea per confrontare · trascina per spostare · la rotellina ingrandisce · doppio clic 1:1 + I file di progetto sono per le sequenze di un archivio su questo PC + Applica di nuovo le impostazioni del file di progetto + Salva un file .titano che, con un doppio clic, apre questa sequenza con queste impostazioni + Ripristina le impostazioni che la sequenza aveva prima di aprire il file · Ctrl+Z Il tuo account può vedere questa sequenza del server ma non modificarla Modificata con i proxy su questo PC; le modifiche si salvano su {0} e analisi e render vengono eseguiti lì Mostrata da {0}; il tuo account può vedere questa sequenza ma non modificarla diff --git a/src/Titano.App/App.xaml.cs b/src/Titano.App/App.xaml.cs index e9900ac1..842cc69b 100644 --- a/src/Titano.App/App.xaml.cs +++ b/src/Titano.App/App.xaml.cs @@ -1,6 +1,7 @@ using System.Windows; using System.Windows.Threading; using Titano.App.DesignTime; +using Titano.App.Editor; using Titano.App.Infrastructure; using Titano.App.Shell; using Titano.Core.Diagnostics; @@ -12,11 +13,15 @@ namespace Titano.App; /// /// Titano desktop client. Local mode starts here: settings and language before the first window, then the window, /// then the index and the job engine () off the UI thread. --capture <dir> -/// renders every screen with synthetic data in a throw-away data folder and exits. +/// renders every screen with synthetic data in a throw-away data folder and exits. A file argument is a +/// .titano project file (Explorer passes it on a double-click) opened once the index is open. One Titano runs +/// per data folder: a second launch hands its file to the running one and exits (). /// public partial class App : Application { + private readonly TaskCompletionSource _started = new(TaskCreationOptions.RunContinuationsAsynchronously); private FileLogSink? _log; + private SingleInstance? _instance; public AppEnvironment Environment { get; private set; } = null!; public AppSettings Settings { get; private set; } = null!; @@ -36,6 +41,19 @@ public partial class App : Application Log.SetSink(capture ? new TeeLogSink(_log, new StderrLogSink()) : _log); Log.Info("app", $"Titano {AppServices.VersionText} starting; data at {Environment.DataDirectory}"); + var projectFile = capture ? null : ProjectFileArgument(e.Args); + if (!capture) + { + _instance = SingleInstance.TryAcquire(Environment.DataDirectory); + if (_instance is null) + { + var handed = SingleInstance.HandOver(Environment.DataDirectory, projectFile is null ? [] : [projectFile]); + Log.Info("app", handed ? "Titano already runs on this data folder; arguments handed over" : "Titano already runs on this data folder"); + Shutdown(); + return; + } + } + Settings = capture ? new AppSettings { Language = "en" } : AppSettings.Load(Environment.SettingsPath); UiLanguage.Apply(Settings.Language); ThemeManager.Initialize(this, capture ? AppTheme.Dark : Settings.Theme); @@ -65,11 +83,12 @@ public partial class App : Application return; } window.Show(); - _ = StartAsync(shell); + _instance?.Listen(args => Dispatcher.BeginInvoke(() => OnHandOver(shell, args))); + _ = StartAsync(shell, projectFile); } - /// Opens the index and the job engine after the window is visible, then fills the screens. - private async Task StartAsync(ShellViewModel shell) + /// Opens the index and the job engine after the window is visible, fills the screens, then opens the project file given. + private async Task StartAsync(ShellViewModel shell, string? projectFile) { try { @@ -80,10 +99,58 @@ public partial class App : Application { shell.ReportError(ex); } + finally + { + _started.TrySetResult(); + } + if (projectFile is not null) await OpenProjectFileAsync(shell, projectFile); + } + + /// A later launch: its window comes to the front here, and its project file opens. + private void OnHandOver(ShellViewModel shell, IReadOnlyList args) + { + if (MainWindow is { } window) + { + window.Show(); + if (window.WindowState == WindowState.Minimized) window.WindowState = WindowState.Normal; + window.Activate(); + } + if (ProjectFileArgument(args) is { } projectFile) _ = OpenProjectFileAsync(shell, projectFile); + } + + /// Opens a project file once the index is open; failures become the usual one-sentence toast. + private async Task OpenProjectFileAsync(ShellViewModel shell, string path) + { + await _started.Task; + try + { + await new ProjectFiles(shell).OpenAsync(path); + } + catch (Exception ex) + { + shell.ReportError(ex); + } + } + + /// The first argument that is not an option, as a full path (the hand-over crosses working folders). + private static string? ProjectFileArgument(IReadOnlyList args) + { + if (args.FirstOrDefault(a => !a.StartsWith("--", StringComparison.Ordinal) && a.Length > 0) is not { } file) return null; + try + { + return System.IO.Path.GetFullPath(file); + } + catch (Exception ex) when (ex is ArgumentException or NotSupportedException or System.IO.PathTooLongException) + { + Log.Warning("app", $"Ignoring argument '{file}'", ex); + return null; + } } public void SaveSettings() { + // A launch that handed over to the running Titano exits before loading any settings. + if (Settings is null) return; try { Settings.Save(Environment.SettingsPath); @@ -108,6 +175,7 @@ public partial class App : Application { Log.Warning("app", "Services stopped with an error", ex); } + _instance?.Dispose(); Log.Info("app", "Titano exiting"); _log?.Dispose(); if (Environment.IsCapture) Environment.DeleteCaptureData(); diff --git a/src/Titano.App/Editor/EditorPanels.xaml b/src/Titano.App/Editor/EditorPanels.xaml index f29069e1..bf1d3b5f 100644 --- a/src/Titano.App/Editor/EditorPanels.xaml +++ b/src/Titano.App/Editor/EditorPanels.xaml @@ -293,6 +293,9 @@ + +