Migrate remaining legacy operator workflows

This commit is contained in:
2026-07-12 05:39:27 +09:00
parent ffb8f43c19
commit a01836a2d7
132 changed files with 20566 additions and 720 deletions

View File

@@ -9,9 +9,6 @@ namespace MBN_STOCK_WEBVIEW;
public sealed partial class MainWindow
{
private static readonly IReadOnlySet<string> OperatorBackgroundExtensions =
new HashSet<string>([".vrv", ".jpg", ".jpeg", ".png"],
StringComparer.OrdinalIgnoreCase);
private int _backgroundSelectionInFlight;
private void HandleBackgroundStatusRequest(JsonElement payload)
@@ -50,9 +47,25 @@ public sealed partial class MainWindow
return;
}
var source = _legacyCompositionOptionsSource ??
throw new InvalidOperationException("Background composition is unavailable.");
// Original btnback_Click assigns 배경\기본.vrv before opening the dialog.
// Keep that behavior only when the default passes all trusted-file checks.
try
{
source.Update(PlayoutSceneCompositionFactory.CreateLegacyDefault(
_playoutOptions!,
source.Current.FadeDuration));
}
catch (PlayoutConfigurationException)
{
// F2 may still select another valid file from the same trusted root.
}
var picker = new FileOpenPicker
{
SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
SuggestedStartLocation = PickerLocationId.PicturesLibrary,
ViewMode = PickerViewMode.List
};
picker.FileTypeFilter.Add(".vrv");
@@ -74,14 +87,14 @@ public sealed partial class MainWindow
}
var composition = CreateOperatorBackgroundComposition(selected.Path);
_legacyCompositionOptionsSource!.Update(composition);
_lastEnabledLegacyComposition = composition;
source.Update(composition);
message = "선택한 배경을 다음 PREPARE부터 사용합니다.";
}
catch (Exception exception) when (
exception is ArgumentException or IOException or UnauthorizedAccessException)
exception is ArgumentException or IOException or UnauthorizedAccessException or
PlayoutConfigurationException)
{
error = "배경 파일은 설정된 컷 루트 안의 vrv/jpg/jpeg/png 파일만 선택할 수 있습니다.";
error = "배경은 신뢰 배경 폴더 안의 일반 vrv/jpg/jpeg/png 파일만 선택할 수 있습니다.";
}
catch
{
@@ -133,18 +146,21 @@ public sealed partial class MainWindow
var current = source.Current;
if (current.BackgroundKind == LegacySceneBackgroundKind.None)
{
if (_lastEnabledLegacyComposition is null)
try
{
error = "켜 둘 배경 파일이 없습니다. 먼저 F2로 배경 파일을 선택하세요.";
source.Update(PlayoutSceneCompositionFactory.CreateLegacyDefault(
_playoutOptions!,
current.FadeDuration));
message = "기본 배경을 켰습니다. 다음 PREPARE부터 반영됩니다.";
}
catch (PlayoutConfigurationException)
{
error = "신뢰 배경 폴더의 기본.vrv를 확인할 수 없습니다. F2로 유효한 배경을 선택하세요.";
return;
}
source.Update(_lastEnabledLegacyComposition);
message = "배경 사용을 켰습니다. 다음 PREPARE부터 반영됩니다.";
}
else
{
_lastEnabledLegacyComposition = current;
source.Update(new LegacySceneCueCompositionOptions(
current.FadeDuration,
LegacySceneBackgroundKind.None));
@@ -178,42 +194,18 @@ public sealed partial class MainWindow
throw new InvalidOperationException("Playout options are unavailable.");
var source = _legacyCompositionOptionsSource ??
throw new InvalidOperationException("Background composition is unavailable.");
var rootText = options.SceneDirectory?.Trim();
if (string.IsNullOrWhiteSpace(rootText) || !Path.IsPathFullyQualified(rootText) ||
string.IsNullOrWhiteSpace(selectedPath) || !Path.IsPathFullyQualified(selectedPath))
{
throw new ArgumentException("A trusted scene root and background are required.");
}
var root = Path.TrimEndingDirectorySeparator(Path.GetFullPath(rootText));
var candidate = Path.GetFullPath(selectedPath);
var rootPrefix = root + Path.DirectorySeparatorChar;
var extension = Path.GetExtension(candidate);
if (!candidate.StartsWith(rootPrefix, StringComparison.OrdinalIgnoreCase) ||
!OperatorBackgroundExtensions.Contains(extension))
{
throw new ArgumentException("The selected background is outside the trusted scene root.");
}
var kind = string.Equals(extension, ".vrv", StringComparison.OrdinalIgnoreCase)
? LegacySceneBackgroundKind.Video
: LegacySceneBackgroundKind.Texture;
var validationOptions = new PlayoutOptions
{
SceneDirectory = root,
LegacySceneFadeDuration = source.Current.FadeDuration,
LegacySceneBackgroundKind = kind,
LegacySceneBackgroundAssetPath = Path.GetRelativePath(root, candidate),
LegacySceneBackgroundVideoLoopCount = options.LegacySceneBackgroundVideoLoopCount,
LegacySceneBackgroundVideoLoopInfinite = options.LegacySceneBackgroundVideoLoopInfinite
};
return PlayoutSceneCompositionFactory.Create(validationOptions);
return PlayoutSceneCompositionFactory.CreateOperatorSelection(
options,
source.Current.FadeDuration,
selectedPath);
}
private bool CanChangeLegacyBackground(bool allowBackgroundOperation = false)
{
if (_playoutOptions is null || _legacyCompositionOptionsSource is null ||
string.IsNullOrWhiteSpace(_playoutOptions.SceneDirectory) ||
!PlayoutSceneCompositionFactory.TryGetTrustedBackgroundDirectory(
_playoutOptions,
out _) ||
IsBrowserCorrelationQuarantined() ||
(!allowBackgroundOperation &&
Volatile.Read(ref _backgroundSelectionInFlight) != 0) ||
@@ -251,6 +243,26 @@ public sealed partial class MainWindow
var current = _legacyCompositionOptionsSource?.Current ??
LegacySceneCueCompositionOptions.Default;
var enabled = current.BackgroundKind != LegacySceneBackgroundKind.None;
var rootAvailable = _playoutOptions is not null &&
PlayoutSceneCompositionFactory.TryGetTrustedBackgroundDirectory(
_playoutOptions,
out _);
var defaultAvailable = false;
if (rootAvailable && _playoutOptions is not null)
{
try
{
_ = PlayoutSceneCompositionFactory.CreateLegacyDefault(
_playoutOptions,
current.FadeDuration);
defaultAvailable = true;
}
catch (PlayoutConfigurationException)
{
// F2 remains available for another valid file in the trusted root.
}
}
PostMessage("background-status", new
{
requestId,
@@ -263,9 +275,13 @@ public sealed partial class MainWindow
},
fileName = enabled ? Path.GetFileName(current.BackgroundAssetPath) : string.Empty,
canChange = CanChangeLegacyBackground(),
message = message ?? (enabled
? "선택한 배경은 다음 PREPARE부터 적용됩니다."
: "배경 사용 안 함")
message = message ?? (!rootAvailable
? "신뢰 배경 폴더를 찾을 수 없어 F2/F3 배경 기능을 잠갔습니다."
: enabled
? "선택한 배경은 다음 PREPARE부터 적용됩니다."
: defaultAvailable
? "배경 사용 안 함"
: "기본.vrv가 없습니다. F2로 신뢰 배경 폴더의 파일을 선택하세요.")
});
}