134 lines
No EOL
5.1 KiB
C#
134 lines
No EOL
5.1 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using JD.Adobe.Service.TargetMemories;
|
|
using JD.Asset;
|
|
using Orbit.Module.Actions;
|
|
using Orbit.Module.Actions.PhotoshopActions;
|
|
using Plume.Interfaces.WPF.Actions;
|
|
using Plume.WPF.Mvvm;
|
|
using ShuttleInstaller;
|
|
using Action = Plume.Interfaces.WPF.Actions.Action;
|
|
|
|
namespace Orbit.Module.ViewModel
|
|
{
|
|
public class ActionPanelsViewModel : BindableBase
|
|
{
|
|
private readonly IActionManager _actionManager;
|
|
private readonly ITargetMemory _targetMemory;
|
|
private readonly IShuttleInstaller _shuttleInstaller;
|
|
|
|
private ObservableCollection<Action> _showInActions;
|
|
private ObservableCollection<Action> _installShuttleActions;
|
|
private ObservableCollection<Action> _offlinePhotoshopActions;
|
|
private ObservableCollection<Action> _onlineBackgroundActions;
|
|
private ObservableCollection<Action> _onlineMenuArtActions;
|
|
|
|
public string SelectedTopFolder { get; set; }
|
|
public IMapExplorer MapExplorer { get; }
|
|
public ObservableCollection<Action> Actions { get; set; } = new ObservableCollection<Action>();
|
|
public ObservableCollection<Action> PhotoshopActions { get; set; } = new ObservableCollection<Action>();
|
|
|
|
public ActionPanelsViewModel(IActionManager actionManager, ITargetMemory targetMemory, IShuttleInstaller shuttleInstaller, IMapExplorer mapExplorer)
|
|
{
|
|
_actionManager = actionManager ?? throw new ArgumentNullException(nameof(actionManager));
|
|
_targetMemory = targetMemory ?? throw new ArgumentNullException(nameof(targetMemory));
|
|
_shuttleInstaller = shuttleInstaller ?? throw new ArgumentNullException(nameof(shuttleInstaller));
|
|
MapExplorer = mapExplorer;
|
|
SelectedTopFolder = null;
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
RefreshShowInActions();
|
|
RefreshPhotoshopActions();
|
|
}
|
|
|
|
private void RefreshShowInActions()
|
|
{
|
|
Actions = MapExplorer.SelectedMap != null ? GetShowInActions() : new ObservableCollection<Action>();
|
|
OnPropertyChanged(nameof(Actions));
|
|
}
|
|
|
|
private void RefreshPhotoshopActions()
|
|
{
|
|
if (!_shuttleInstaller.IsProperlyInstalled)
|
|
{
|
|
PhotoshopActions = GetShuttleInstallActions();
|
|
}
|
|
else if (MapExplorer.SelectedMap == null)
|
|
{
|
|
PhotoshopActions = new ObservableCollection<Action>();
|
|
}
|
|
else if (!_targetMemory.HasTarget)
|
|
{
|
|
PhotoshopActions = GetOfflinePhotoshopActions();
|
|
}
|
|
else
|
|
{
|
|
if (IsSameFolder(SelectedTopFolder, MapExplorer.SelectedMap.MenuArtFolder))
|
|
{
|
|
PhotoshopActions = GetMenuArtActions();
|
|
}
|
|
else if (IsSameFolder(SelectedTopFolder, MapExplorer.SelectedMap.BackgroundFolder))
|
|
{
|
|
PhotoshopActions = GetBackgroundActions();
|
|
}
|
|
else
|
|
{
|
|
PhotoshopActions = GetOfflinePhotoshopActions();
|
|
}
|
|
}
|
|
OnPropertyChanged(nameof(PhotoshopActions));
|
|
}
|
|
|
|
private bool IsSameFolder(string folderName, PathInfo mapPathInfo)
|
|
{
|
|
string mapFolderName = mapPathInfo != null ? new DirectoryInfo(mapPathInfo).Name : null;
|
|
|
|
return folderName != null && folderName.Equals(mapFolderName, StringComparison.InvariantCultureIgnoreCase);
|
|
}
|
|
|
|
private ObservableCollection<Action> GetShuttleInstallActions()
|
|
{
|
|
return _installShuttleActions ?? (_installShuttleActions = new ObservableCollection<Action>
|
|
{
|
|
_actionManager.Get<InstallShuttlePluginAction>()
|
|
});
|
|
}
|
|
|
|
private ObservableCollection<Action> GetShowInActions()
|
|
{
|
|
return _showInActions ?? (_showInActions = new ObservableCollection<Action>
|
|
{
|
|
_actionManager.Get<GetLatestArtDataAction>(),
|
|
_actionManager.Get<ShowInGameAction>(),
|
|
_actionManager.Get<ShowExpositionInGameAction>()
|
|
});
|
|
}
|
|
|
|
private ObservableCollection<Action> GetOfflinePhotoshopActions()
|
|
{
|
|
return _offlinePhotoshopActions ?? (_offlinePhotoshopActions = new ObservableCollection<Action>
|
|
{
|
|
_actionManager.Get<OpenPhotoshopAction>()
|
|
});
|
|
}
|
|
|
|
private ObservableCollection<Action> GetBackgroundActions()
|
|
{
|
|
return _onlineBackgroundActions ?? (_onlineBackgroundActions = new ObservableCollection<Action>
|
|
{
|
|
_actionManager.Get<GenerateBackgroundsToNasAction>()
|
|
});
|
|
}
|
|
|
|
private ObservableCollection<Action> GetMenuArtActions()
|
|
{
|
|
return _onlineMenuArtActions ?? (_onlineMenuArtActions = new ObservableCollection<Action>
|
|
{
|
|
_actionManager.Get<GenerateTexturesAction>()
|
|
});
|
|
}
|
|
}
|
|
} |