Files
Chronos/src/Chronos.App/Editor/EditorText.cs
T
Alby96andClaude Opus 5.5 f2b58522b9
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
The owner renamed the product and moved the repository to the self-hosted
Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control,
and asked for Actions and a first automatic release with the server package
and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md).

- Chronos everywhere: a byte-exact rename of contents and paths, then a
  per-language review of the forms the old name's ending had dictated.
- Gitea instead of GitHub: the update check, licence, issue and support
  links read ChronosReleasesUrl; the update check takes the highest stable
  version, offers a pre-release build its final release and reports a
  repository it cannot see as a failed check. EULA, security policy and
  Gitea issue forms live at the repository root.
- Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release,
  nightly image and performance gates in the .NET SDK container with git
  checkout and the system SQLite. The release cross-compiles the Windows
  programs, checks their icon, version and DPI manifest, packs installers
  and zips, publishes the Gitea release and pushes the server image
  (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows
  runner (WINDOWS_RUNNER).
- New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the
  docker-exec script, which Gitea's service containers do not allow; the
  throw-away server runs without durability) and pe-check.
- Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR,
  3 on the shared runner; the weekly performance gates keep theirs).

BREAKING CHANGE: programs, settings, data folders, file types, environment
variables and the Docker image use the new name; nothing is migrated from
Titano, which never had a release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-10-23 12:45:18 +02:00

236 lines
13 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
using System.Globalization;
using Chronos.App.Infrastructure;
using Chronos.App.Jobs;
using Chronos.Core.Advice;
using Chronos.Core.Export;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Core.Video;
namespace Chronos.App.Editor;
/// <summary>The editor's composed texts (header summary, shot data, preset card lines), in the current UI language.</summary>
public static class EditorText
{
private static string Separator => Loc.Separator;
/// <summary>"3,600 frames · Canon EOS R5 · 2 s interval · 2 h 00 m · 3 warnings".</summary>
public static string Summary(SequenceContent content, int warnings)
{
ArgumentNullException.ThrowIfNull(content);
var s = content.Sequence;
var parts = new List<string> { Loc.Plural("Editor.Summary.Frames", content.Count) };
if (s.CameraModel is { Length: > 0 } camera) parts.Add(camera);
if (content.Light.MedianIntervalSeconds is > 0 and var interval) parts.Add(Loc.L("Editor.Summary.Interval", Number(interval)));
if (content.Light.CaptureSpan > TimeSpan.Zero) parts.Add(Formatting.Duration(content.Light.CaptureSpan));
if (warnings > 0) parts.Add(Loc.Plural("Editor.Summary.Warnings", warnings));
return string.Join(Separator, parts);
}
/// <summary>
/// "Render · 46 %", "Render · queued", "Deep analysis · paused": a job the server runs for a server sequence (the job
/// bar shows this PC's jobs only).
/// </summary>
public static string ServerJob(Job job)
{
ArgumentNullException.ThrowIfNull(job);
return job switch
{
{ State: JobState.Running, ProgressTotal: > 0 } => JobText.Kind(job.Kind) + Separator + Formatting.Percent((double)job.ProgressDone / job.ProgressTotal),
{ State: JobState.Running } => JobText.Kind(job.Kind),
_ => JobText.Kind(job.Kind) + Separator + Loc.L("Jobs.State." + job.State),
};
}
/// <summary>"Render running on Studio NAS · 1,240 / 3,600 · 11.3 fps · 3 min left"; "Render waiting on Studio NAS".</summary>
public static string ServerJobDetail(Job job, string server)
{
ArgumentNullException.ThrowIfNull(job);
var key = job.State switch
{
JobState.Queued => "Tooltips.Editor.ServerJob.Queued",
JobState.Paused => "Tooltips.Editor.ServerJob.Paused",
_ => "Tooltips.Editor.ServerJob",
};
var parts = new List<string> { Loc.L(key, JobText.Kind(job.Kind), server) };
if (JobText.Counter(job.ProgressDone, job.ProgressTotal) is { Length: > 0 } counter) parts.Add(counter);
if (JobText.Speed(job.Kind, job.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed);
if (job.Eta is { } eta) parts.Add(Loc.L("Editor.ServerJob.Left", Formatting.Duration(eta)));
return string.Join(Separator, parts);
}
/// <summary>"3,600 frames · 24 fps · 2 min 30 s · 3840×2160 · source 8192×5464": what the export makes of the sequence (Export.html header).</summary>
public static string OutputSummary(SequenceContent content, ExportPlan plan)
{
ArgumentNullException.ThrowIfNull(content);
ArgumentNullException.ThrowIfNull(plan);
var render = plan.Setup.Plan;
var settings = plan.Setup.Encoder.Settings;
var parts = new List<string>
{
Loc.Plural("Editor.Summary.Frames", content.Count),
Loc.L("Editor.Value.Fps", FrameRate(render.FrameRate)),
Formatting.Duration(TimeSpan.FromSeconds(render.DurationSeconds)),
};
if (settings.Width > 0 && settings.Height > 0) parts.Add(Size(settings.Width, settings.Height));
if (content.SourceWidth > 0 && content.SourceHeight > 0) parts.Add(Loc.L("Editor.Summary.Source", Size(content.SourceWidth, content.SourceHeight)));
return string.Join(Separator, parts);
}
/// <summary>"0413 / 3,600 · 18:02:11 · 1/8 s · f/8 · ISO 400 · 24 mm".</summary>
public static string Shot(Frame frame, int index, int count)
{
ArgumentNullException.ThrowIfNull(frame);
var parts = new List<string> { Position(index, count) };
if (frame.CapturedAt is { } at) parts.Add(at.ToString("T", Loc.Culture));
if (frame.ExposureTime is > 0 and var t) parts.Add(Shutter(t));
if (frame.FNumber is > 0 and var f) parts.Add(Loc.L("Editor.Shot.Aperture", Number(f)));
if (frame.Iso is > 0 and var iso) parts.Add(Loc.L("Editor.Shot.Iso", iso));
if (frame.FocalLength is > 0 and var mm) parts.Add(Loc.L("Editor.Shot.Focal", Number(mm)));
// Shown over the photo, a left-to-right island.
return string.Join(Loc.IslandSeparator, parts);
}
/// <summary>"0413 / 3,600".</summary>
public static string Position(int index, int count) =>
(index + 1).ToString("D4", Loc.Culture) + " / " + count.ToString("N0", Loc.Culture);
/// <summary>"1/250 s", "1/8 s", "2 s".</summary>
public static string Shutter(double seconds) => seconds >= 0.3
? Loc.L("Editor.Shot.Shutter", Number(seconds))
: Loc.L("Editor.Shot.Shutter", "1/" + double.Round(1 / seconds).ToString("0", Loc.Culture));
/// <summary>"MP4 · HEVC Main10 · 3840×2160 · 24 fps".</summary>
public static string Format(ResolvedExport export, int width, int height)
{
ArgumentNullException.ThrowIfNull(export);
var parts = new List<string> { Loc.L("Export.Container." + VideoCodecInfo.DefaultContainer(export.Codec)), CodecName(export.Codec, export.Profile, export.BitDepth) };
if (width > 0 && height > 0) parts.Add(Size(width, height));
parts.Add(Loc.L("Editor.Export.Fps", FrameRate(export.FrameRate)));
return string.Join(Separator, parts);
}
/// <summary>"120 Mb/s · 0.07 bpp · NVENC" for video, "Quality 95 · Chronos" for frames.</summary>
public static string Encoding(ResolvedExport export, long bitRate, string? encoder)
{
ArgumentNullException.ThrowIfNull(export);
var parts = new List<string>();
if (!VideoCodecInfo.IsManaged(export.Codec))
{
parts.Add(BitRate(bitRate));
var bpp = export.BitsPerPixel > 0 ? export.BitsPerPixel : ExportPreset.DefaultBitsPerPixel(export.Codec);
if (export.BitRate == 0 && bpp > 0) parts.Add(Loc.L("Editor.Export.Bpp", bpp.ToString("0.00", Loc.Culture)));
}
else if (export.Codec is VideoCodec.Mjpeg or VideoCodec.JpegSequence or VideoCodec.Gif)
{
parts.Add(Loc.L("Editor.Export.QualityValue", export.Quality));
}
if (encoder is { Length: > 0 }) parts.Add(encoder);
return string.Join(Separator, parts);
}
/// <summary>"2.2 GB · about 5 min".</summary>
public static string Estimate(ExportEstimate estimate)
{
ArgumentNullException.ThrowIfNull(estimate);
return Formatting.Bytes(estimate.Bytes) + Separator + Loc.L("Editor.Export.About", Formatting.Duration(estimate.Time));
}
/// <summary>"120 Mb/s".</summary>
public static string BitRate(long bitsPerSecond) => Loc.L("Editor.Export.Mbps", (bitsPerSecond / 1e6).ToString(bitsPerSecond >= 10_000_000 ? "0" : "0.#", Loc.Culture));
/// <summary>"3840×2160".</summary>
public static string Size(int width, int height) => width.ToString(Loc.Culture) + "×" + height.ToString(Loc.Culture);
/// <summary>"23.976", "24".</summary>
public static string FrameRate(Rational rate) => rate.Denominator == 1 ? rate.Numerator.ToString(Loc.Culture) : rate.Value.ToString("0.###", Loc.Culture);
/// <summary>Technical codec name ("H.264 High", "HEVC Main10", "PNG"…).</summary>
public static string CodecName(VideoCodec codec, CodecProfile profile, int bitDepth) => codec switch
{
VideoCodec.Hevc when profile == CodecProfile.HevcMain10 || bitDepth > 8 => Loc.L("Export.Codec.HevcMain10"),
VideoCodec.Hevc => Loc.L("Export.Codec.Hevc"),
VideoCodec.H264 => Loc.L("Export.Codec.H264"),
_ => Loc.L("Export.Codec." + codec),
};
/// <summary>"+1.0", "−0.7" (EV with a sign).</summary>
public static string Ev(double ev) => ev.ToString("+0.0;−0.0;0.0", Loc.Culture);
/// <summary>"01:17.2" (minutes, seconds and tenths of a video position).</summary>
public static string Clock(double seconds)
{
var t = TimeSpan.FromSeconds(double.Max(0, seconds));
return ((int)t.TotalMinutes).ToString("00", Loc.Culture) + ":" + t.Seconds.ToString("00", Loc.Culture) + Loc.Culture.NumberFormat.NumberDecimalSeparator
+ (t.Milliseconds / 100).ToString(Loc.Culture);
}
/// <summary>"Centred", "+0.25" (crop placement −1…1).</summary>
public static string Placement(double value) => value == 0 ? Loc.L("Editor.Value.Centred") : value.ToString("+0.00;−0.00", Loc.Culture);
/// <summary>The label of an advisor parameter as its control shows it.</summary>
public static string ParameterLabel(string parameter) => parameter switch
{
AdvisorParameters.Hero => Loc.L("Editor.Frames.HeroLabel"),
AdvisorParameters.Excluded => Loc.L("Editor.Frames.ExcludedLabel"),
AdvisorParameters.TimingMode => Loc.L("Editor.Time.Mode"),
AdvisorParameters.FrameRate => Loc.L("Editor.Time.Rate"),
AdvisorParameters.FitToSeconds => Loc.L("Editor.Time.Fit"),
AdvisorParameters.Deflicker => Loc.L("Editor.Exposure.Deflicker"),
AdvisorParameters.DeflickerWindow => Loc.L("Editor.Exposure.Window"),
AdvisorParameters.DeflickerStrength => Loc.L("Editor.Exposure.Strength"),
AdvisorParameters.Regions => Loc.L("Editor.Exposure.Regions"),
AdvisorParameters.HolyGrail => Loc.L("Editor.Exposure.HolyGrail"),
AdvisorParameters.TransitionLength => Loc.L("Editor.Exposure.Transitions"),
AdvisorParameters.WhiteBalanceSmoothing => Loc.L("Editor.Exposure.WhiteBalance"),
AdvisorParameters.MotionBlur => Loc.L("Editor.Motion.Blur"),
AdvisorParameters.TargetShutterAngle => Loc.L("Editor.Motion.Shutter"),
AdvisorParameters.FlowQuality => Loc.L("Editor.Motion.Flow"),
AdvisorParameters.Stabilize => Loc.L("Editor.Motion.Stabilize"),
AdvisorParameters.StabilizeSmoothing => Loc.L("Editor.Motion.Smoothing"),
AdvisorParameters.Aspect => Loc.L("Editor.Camera.Aspect"),
AdvisorParameters.OffsetY => Loc.L("Editor.Camera.OffsetY"),
AdvisorParameters.ExportPreset => Loc.L("Editor.Export.Preset"),
AdvisorParameters.Resolution => Loc.L("Editor.Export.Resolution"),
_ => parameter,
};
/// <summary>
/// "Deflicker window: 21 frames → 41 frames", one line of the Optimise toast. Bidi never mirrors an arrow, so a
/// right-to-left language reads it from its own resource, the arrow pointing from the old value to the new one.
/// </summary>
public static string Change(SettingChange change) =>
Loc.L(Loc.IsRightToLeft ? "Editor.Optimise.ChangeRtl" : "Editor.Optimise.Change", ParameterLabel(change.Parameter), Value(change.Parameter, change.Before),
Value(change.Parameter, change.After));
/// <summary>A value of an advisor parameter as its control shows it (the "what changed" toast of Optimise).</summary>
public static string Value(string parameter, object? value) => (parameter, value) switch
{
(_, null) => Loc.L("Editor.Value.None"),
(AdvisorParameters.Hero, int frame) => Loc.L("Editor.Frames.HeroValue", (frame + 1).ToString("D4", Loc.Culture)),
(AdvisorParameters.Aspect, "source") => Loc.L("Editor.Aspect.Source"),
(AdvisorParameters.FrameRate, string rate) when FrameRateText.TryParse(rate, out var parsed) => Loc.L("Editor.Value.Fps", FrameRate(parsed)),
(AdvisorParameters.FitToSeconds, double seconds) => Formatting.Duration(TimeSpan.FromSeconds(seconds)),
(AdvisorParameters.DeflickerWindow or AdvisorParameters.TransitionLength, int frames) => Loc.Plural("Editor.Value.Frames", frames),
(AdvisorParameters.DeflickerStrength, double strength) => strength.ToString("0.00", Loc.Culture),
(AdvisorParameters.TargetShutterAngle, double degrees) => Loc.L("Editor.Value.Degrees", degrees.ToString("0", Loc.Culture)),
(AdvisorParameters.StabilizeSmoothing, double sigma) => Loc.Plural("Editor.Value.Frames", (long)double.Round(sigma)),
(AdvisorParameters.OffsetY, double offset) => Placement(offset),
(AdvisorParameters.Resolution, string size) => size.Replace('x', '×'),
(_, bool on) => Loc.L(on ? "Editor.Value.On" : "Editor.Value.Off"),
(_, TimingMode mode) => Loc.L("Editor.Timing." + mode),
(_, RegionMode mode) => mode == RegionMode.Off ? Loc.L("Editor.Value.Off") : Loc.L("Editor.Regions." + mode),
(_, FlowQualitySetting quality) => Loc.L("Editor.Flow." + quality),
(_, string id) when ExportPresets.Find(id) is { } preset => Loc.L(preset.NameKey),
(_, string text) => text,
(_, double number) => number.ToString("0.##", Loc.Culture),
(_, IEnumerable list) => Loc.Plural("Editor.Value.Frames", list.Cast<object>().LongCount()),
(_, IFormattable formattable) => formattable.ToString(null, Loc.Culture),
_ => Convert.ToString(value, CultureInfo.InvariantCulture) ?? string.Empty,
};
private static string Number(double value) => value.ToString(value >= 10 ? "0" : "0.#", Loc.Culture);
}