forked from sin365/AxibugEmuOnline
增加滤镜预览功能
This commit is contained in:
parent
d05b2018eb
commit
84d7112c90
6
.gitignore
vendored
6
.gitignore
vendored
@ -13,7 +13,5 @@
|
||||
/AxibugEmuOnline.Client/ProjectSettings/ProjectVersion.txt
|
||||
/AxibugEmuOnline.Client/ProjectSettings/AutoStreamingSettings.asset
|
||||
/AxibugEmuOnline.Client/Logs
|
||||
/virtuanessrc097-master/save
|
||||
/virtuanessrc097-master/.vs
|
||||
/virtuanessrc097-master/Debug
|
||||
/virtuanessrc097-master/VirtuaNES.ini
|
||||
|
||||
/virtuanessrc097-master
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -39,7 +39,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
#else
|
||||
public static string PersistentDataPath => Application.persistentDataPath;
|
||||
#endif
|
||||
public static void Init(PostProcessVolume filterVolume)
|
||||
public static void Init(Initer initer)
|
||||
{
|
||||
settings = new AppSettings();
|
||||
|
||||
@ -55,7 +55,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
nesRomLib = new RomLib(EnumPlatform.NES);
|
||||
CacheMgr = new CacheManager();
|
||||
roomMgr = new AppRoom();
|
||||
filter = new FilterManager(filterVolume);
|
||||
filter = new FilterManager(initer.m_filterVolume, initer.m_filterPreview,initer.m_xmbBg);
|
||||
var go = new GameObject("[AppAxibugEmuOnline]");
|
||||
GameObject.DontDestroyOnLoad(go);
|
||||
tickLoop = go.AddComponent<TickLoop>();
|
||||
|
@ -13,6 +13,8 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public IReadOnlyCollection<EditableParamerter> EditableParam => m_editableParamList.AsReadOnly();
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public FilterEffect()
|
||||
{
|
||||
GetEditableFilterParamters();
|
||||
|
@ -8,6 +8,8 @@ using UnityEngine.Rendering.PostProcessing;
|
||||
[PostProcess(typeof(FixingPixelArtGrilleRenderer), PostProcessEvent.BeforeStack, "Filter/FixingPixelArtGrille")]
|
||||
public sealed class FixingPixelArtGrille : FilterEffect
|
||||
{
|
||||
public override string Name => nameof(FixingPixelArtGrille);
|
||||
|
||||
public ParameterOverride<EnumMaskStyle> MaskStyle = new ParameterOverride<EnumMaskStyle> { value = EnumMaskStyle.ApertureGrille };
|
||||
|
||||
[Tooltip("Emulated input resolution\nOptimize for resize")]
|
||||
|
@ -6,12 +6,13 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class Initer : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
PostProcessVolume m_filterVolume;
|
||||
public PostProcessVolume m_filterVolume;
|
||||
public CanvasGroup m_filterPreview;
|
||||
public CanvasGroup m_xmbBg;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
App.Init(m_filterVolume);
|
||||
App.Init(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System.Collections;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
using static AxibugEmuOnline.Client.FilterEffect;
|
||||
|
||||
@ -10,27 +12,42 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
private PostProcessProfile m_filterPorfile;
|
||||
private List<Filter> m_filters;
|
||||
|
||||
private Dictionary<EnumPlatform, Filter> m_filterPlatforms = new Dictionary<EnumPlatform, Filter>();
|
||||
private AlphaWraper m_previewFilterWraper;
|
||||
/// <summary>
|
||||
/// 滤镜列表
|
||||
/// </summary>
|
||||
public IReadOnlyList<Filter> Filters => m_filters;
|
||||
|
||||
public FilterManager(PostProcessVolume filterVolume)
|
||||
public FilterManager(PostProcessVolume filterVolume, CanvasGroup filterPreview, CanvasGroup mainBg)
|
||||
{
|
||||
m_filterPorfile = filterVolume.profile;
|
||||
m_filters = m_filterPorfile.settings.Where(setting=>setting is FilterEffect).Select(setting => new Filter(setting as FilterEffect)).ToList();
|
||||
m_filters = m_filterPorfile.settings.Where(setting => setting is FilterEffect).Select(setting => new Filter(setting as FilterEffect)).ToList();
|
||||
|
||||
m_previewFilterWraper = new AlphaWraper(mainBg, filterPreview, false);
|
||||
ShutDownFilterPreview();
|
||||
ShutDownFilter();
|
||||
}
|
||||
|
||||
|
||||
/// <summary> 关闭滤镜预览 </summary>
|
||||
public void ShutDownFilterPreview()
|
||||
{
|
||||
m_previewFilterWraper.On = false;
|
||||
}
|
||||
|
||||
/// <summary> 开启滤镜预览 </summary>
|
||||
public void EnableFilterPreview()
|
||||
{
|
||||
m_previewFilterWraper.On = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开滤镜
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
public void EnableFilter(Filter filter)
|
||||
{
|
||||
foreach(var selfFiler in Filters)
|
||||
foreach (var selfFiler in Filters)
|
||||
{
|
||||
if (selfFiler != filter) selfFiler.m_setting.enabled.Override(false);
|
||||
else selfFiler.m_setting.enabled.Override(true);
|
||||
@ -47,10 +64,9 @@ namespace AxibugEmuOnline.Client
|
||||
setting.enabled.Override(false);
|
||||
}
|
||||
|
||||
public struct Filter
|
||||
public class Filter
|
||||
{
|
||||
public bool Empty => m_setting == null;
|
||||
public readonly string Name => m_setting.name;
|
||||
public string Name => m_setting.Name;
|
||||
|
||||
internal FilterEffect m_setting;
|
||||
|
||||
@ -60,29 +76,6 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
|
||||
internal IReadOnlyCollection<EditableParamerter> Paramerters => m_setting.EditableParam;
|
||||
|
||||
public override readonly int GetHashCode()
|
||||
{
|
||||
return m_setting.GetHashCode();
|
||||
}
|
||||
|
||||
public override readonly bool Equals(object obj)
|
||||
{
|
||||
if(obj == null) return false;
|
||||
if (!(obj is Filter)) return false;
|
||||
|
||||
return ((Filter)obj).GetHashCode() == GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(Filter left, Filter right)
|
||||
{
|
||||
return left.GetHashCode() == right.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator !=(Filter left, Filter right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
93
AxibugEmuOnline.Client/Assets/Script/UI/AlphaWraper.cs
Normal file
93
AxibugEmuOnline.Client/Assets/Script/UI/AlphaWraper.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class AlphaWraper
|
||||
{
|
||||
private bool m_on;
|
||||
private CanvasGroup m_offUI;
|
||||
private CanvasGroup m_onUI;
|
||||
private TweenerCore<float, float, FloatOptions> m_onTween;
|
||||
private TweenerCore<float, float, FloatOptions> m_offTween;
|
||||
|
||||
public bool On
|
||||
{
|
||||
get => m_on;
|
||||
set
|
||||
{
|
||||
if (m_on == value) return;
|
||||
|
||||
m_on = value;
|
||||
|
||||
if (m_onTween != null)
|
||||
{
|
||||
m_onTween.Kill();
|
||||
m_onTween = null;
|
||||
}
|
||||
if (m_offTween != null)
|
||||
{
|
||||
m_offTween.Kill();
|
||||
m_offTween = null;
|
||||
}
|
||||
m_onUI.gameObject.SetActiveEx(true);
|
||||
m_offUI.gameObject.SetActiveEx(true);
|
||||
|
||||
if (On)
|
||||
{
|
||||
float progress = 0f;
|
||||
m_onTween = DOTween.To(() => progress, (x) =>
|
||||
{
|
||||
progress = x;
|
||||
m_onUI.alpha = progress;
|
||||
m_offUI.alpha = 1 - progress;
|
||||
}, 1f, 0.3f);
|
||||
m_onTween.onComplete = () =>
|
||||
{
|
||||
m_offUI.gameObject.SetActiveEx(false);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
float progress = 0f;
|
||||
m_offTween = DOTween.To(() => progress, (x) =>
|
||||
{
|
||||
progress = x;
|
||||
m_onUI.alpha = 1 - progress;
|
||||
m_offUI.alpha = progress;
|
||||
}, 1f, 0.3f);
|
||||
m_offTween.onComplete = () =>
|
||||
{
|
||||
m_onUI.gameObject.SetActiveEx(false);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AlphaWraper(CanvasGroup offUI, CanvasGroup onUI, bool defaultOn)
|
||||
{
|
||||
m_offUI = offUI;
|
||||
m_onUI = onUI;
|
||||
|
||||
m_on = defaultOn;
|
||||
if (On)
|
||||
{
|
||||
onUI.alpha = 1;
|
||||
onUI.gameObject.SetActiveEx(true);
|
||||
offUI.alpha = 0;
|
||||
offUI.gameObject.SetActiveEx(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
onUI.alpha = 0;
|
||||
onUI.gameObject.SetActiveEx(false);
|
||||
offUI.alpha = 1;
|
||||
offUI.gameObject.SetActiveEx(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Script/UI/AlphaWraper.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Script/UI/AlphaWraper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02337cc8c99c47341aa29b3e296b7b13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
|
@ -7,10 +7,24 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class GlobalFilterListMenuItem : VirtualSubMenuItem
|
||||
{
|
||||
public override bool OnEnterItem()
|
||||
{
|
||||
App.filter.EnableFilterPreview();
|
||||
|
||||
return base.OnEnterItem();
|
||||
}
|
||||
|
||||
public override bool OnExitItem()
|
||||
{
|
||||
App.filter.ShutDownFilterPreview();
|
||||
App.filter.ShutDownFilter();
|
||||
|
||||
return base.OnExitItem();
|
||||
}
|
||||
|
||||
protected override void GetVirtualListDatas(Action<object> datas)
|
||||
{
|
||||
List<object> list = new List<object>();
|
||||
list.Add(new FilterManager.Filter());
|
||||
list.AddRange(App.filter.Filters.Select(f => (object)f));
|
||||
datas.Invoke(list);
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.UI;
|
||||
using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
@ -16,30 +11,34 @@ namespace AxibugEmuOnline.Client
|
||||
public int Index { get; set; }
|
||||
public FilterManager.Filter Datacontext { get; private set; }
|
||||
|
||||
|
||||
public void SetData(object data)
|
||||
{
|
||||
Datacontext = (FilterManager.Filter)data;
|
||||
Datacontext = data as FilterManager.Filter;
|
||||
|
||||
UpdateView();
|
||||
}
|
||||
|
||||
private void Setting_OnColorChanged(XMBColor color)
|
||||
{
|
||||
UpdateView();
|
||||
}
|
||||
|
||||
private void UpdateView()
|
||||
{
|
||||
SetBaseInfo(Datacontext.Name, $"参数数量:{Datacontext.Paramerters.Count}", null);
|
||||
}
|
||||
|
||||
public void SetDependencyProperty(object data)
|
||||
{
|
||||
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
|
||||
|
||||
if (m_select)
|
||||
{
|
||||
App.filter.EnableFilterPreview();
|
||||
App.filter.EnableFilter(Datacontext);
|
||||
}
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool OnEnterItem()
|
||||
{
|
||||
return false;
|
||||
|
@ -14,8 +14,7 @@ namespace AxibugEmuOnline.Client
|
||||
RectTransform MainMenuRoot;
|
||||
[SerializeField]
|
||||
MainMenuController MainMenu;
|
||||
[SerializeField]
|
||||
Image BG;
|
||||
public Image BG;
|
||||
|
||||
Vector2 m_mainLayoutPosition;
|
||||
[SerializeField]
|
||||
|
@ -103,9 +103,13 @@ namespace AxibugEmuOnline.Client.UI
|
||||
if (InfoNode != null) InfoNode.alpha = m_progress;
|
||||
if (spline != null) spline.SetAlpha(m_progress);
|
||||
Root.localScale = Vector3.one * Mathf.Lerp(UnSelectScale, SelectScale, m_progress);
|
||||
|
||||
if (m_select) OnSelected(m_progress);
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void OnSelected(float progress) { }
|
||||
|
||||
public virtual bool OnEnterItem() => true;
|
||||
|
||||
public virtual bool OnExitItem() => true;
|
||||
|
Loading…
Reference in New Issue
Block a user