Skip to content

Commit

Permalink
persist movie path
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddio0141 committed Aug 2, 2024
1 parent 95de26b commit 84a5a91
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion UniTAS/Patcher/Implementations/GUI/Windows/MoviePlayWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using UniTAS.Patcher.Interfaces.GlobalHotkeyListener;
using UniTAS.Patcher.Interfaces.GUI;
using UniTAS.Patcher.Models.GUI;
using UniTAS.Patcher.Services;
using UniTAS.Patcher.Services.Customization;
using UniTAS.Patcher.Services.GUI;
using UniTAS.Patcher.Services.Logging;
Expand All @@ -29,8 +30,11 @@ public class MoviePlayWindow : Window
private readonly IMovieLogger _movieLogger;
private readonly IMovieRunner _movieRunner;
private readonly IBrowseFileWindowFactory _browseFileWindowFileWindowFactory;
private readonly IConfig _config;
private IBrowseFileWindow _currentBrowseFileWindow;

private const string TAS_PATH_CONFIG_ENTRY = "movie-play-window-tas-path";

public MoviePlayWindow(WindowDependencies windowDependencies, IMovieLogger movieLogger, IMovieRunner movieRunner,
IBinds binds, IBrowseFileWindowFactory browseFileWindowFileWindowFactory, IGlobalHotkey globalHotkey) :
base(windowDependencies,
Expand All @@ -39,10 +43,16 @@ public MoviePlayWindow(WindowDependencies windowDependencies, IMovieLogger movie
_movieLogger = movieLogger;
_movieRunner = movieRunner;
_browseFileWindowFileWindowFactory = browseFileWindowFileWindowFactory;
_config = windowDependencies.Config;
movieLogger.OnLog += OnMovieLog;

var playMovieBind = binds.Create(new("PlayMovie", KeyCode.Slash));
globalHotkey.AddGlobalHotkey(new(playMovieBind, RunMovieWithLogs));

if (_config.TryGetBackendEntry(TAS_PATH_CONFIG_ENTRY, out string path))
{
_tasPath = path;
}
}

protected override void OnGUI()
Expand Down Expand Up @@ -73,7 +83,11 @@ private void OperationButtons()
if (GUILayout.Button("Browse", GUIUtils.EmptyOptions) && _currentBrowseFileWindow == null)
{
_currentBrowseFileWindow = _browseFileWindowFileWindowFactory.Open(new("Browse Movie", Paths.GameRootPath));
_currentBrowseFileWindow.OnFileSelected += path => _tasPath = path;
_currentBrowseFileWindow.OnFileSelected += path =>
{
_tasPath = path;
_config.WriteBackendEntry(TAS_PATH_CONFIG_ENTRY, path);
};
_currentBrowseFileWindow.OnClosed += () => _currentBrowseFileWindow = null;
}

Expand Down

0 comments on commit 84a5a91

Please sign in to comment.