滤镜功能迭代

This commit is contained in:
ALIENJACK\alien 2024-11-28 16:33:00 +08:00
parent 490a5584d8
commit fd853f3723
24 changed files with 831 additions and 470 deletions

View File

@ -0,0 +1,429 @@
fileFormatVersion: 2
guid: a8e14774cb9b81d4799116466bc09437
TextureImporter:
internalIDToNameTable:
- first:
213: -4959326954622038618
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_0
- first:
213: -5964753451609424764
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_1
- first:
213: -4801715788788902516
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_2
- first:
213: 4561171062942135429
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_3
- first:
213: -5549305347284123853
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_4
- first:
213: 6860963059624718238
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_5
- first:
213: -4498413793718531433
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_6
- first:
213: -8124222410993000122
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_7
- first:
213: -3950121511746819120
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_8
- first:
213: 5164087282620923207
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_9
- first:
213: 8949408723004945982
second: vv1imdvm00bhsrp2j3evsc0807-dd2b714d32579038cd0e713f482ab243_10
- first:
213: 5770958956045166959
second: misc_0
- first:
213: -9177418277584700315
second: misc_1
- first:
213: 3445910035351170775
second: misc_2
- first:
213: 8671351589016534120
second: misc_3
- first:
213: 173538500886388945
second: misc_4
- first:
213: -4076281113925471536
second: misc_5
- first:
213: 7637870703528583553
second: misc_6
- first:
213: -3818157907930065138
second: misc_7
- first:
213: -3356990613430728209
second: misc_8
- first:
213: 8307504999820893422
second: misc_9
- first:
213: 4452512340041527070
second: misc_10
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: misc_0
rect:
serializedVersion: 2
x: 39
y: 81
width: 92
height: 93
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: f696e6c3890961050800000000000000
internalID: 5770958956045166959
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: misc_1
rect:
serializedVersion: 2
x: 167
y: 74
width: 107
height: 108
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 56cf26953b243a080800000000000000
internalID: -9177418277584700315
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: misc_2
rect:
serializedVersion: 2
x: 310
y: 74
width: 107
height: 108
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 7de6f018be452df20800000000000000
internalID: 3445910035351170775
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: misc_3
rect:
serializedVersion: 2
x: 458
y: 78
width: 73
height: 114
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 86c79d1d354d65870800000000000000
internalID: 8671351589016534120
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: misc_4
rect:
serializedVersion: 2
x: 524
y: 83
width: 76
height: 115
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 1d0ef2cd858886200800000000000000
internalID: 173538500886388945
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: misc_5
rect:
serializedVersion: 2
x: 649
y: 76
width: 109
height: 118
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 0d2b6d78ce32e67c0800000000000000
internalID: -4076281113925471536
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: misc_6
rect:
serializedVersion: 2
x: 803
y: 79
width: 134
height: 113
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 1812f2c00fa2ff960800000000000000
internalID: 7637870703528583553
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: misc_7
rect:
serializedVersion: 2
x: 996
y: 76
width: 116
height: 129
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: e07da79bc9d230bc0800000000000000
internalID: -3818157907930065138
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: misc_8
rect:
serializedVersion: 2
x: 1172
y: 86
width: 126
height: 98
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: fe9042cb2d29961d0800000000000000
internalID: -3356990613430728209
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: misc_9
rect:
serializedVersion: 2
x: 1339
y: 95
width: 103
height: 79
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: eec1b1448cf2a4370800000000000000
internalID: 8307504999820893422
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: misc_10
rect:
serializedVersion: 2
x: 1480
y: 85
width: 70
height: 102
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: e1fe73202608acd30800000000000000
internalID: 4452512340041527070
vertices: []
indices:
edges: []
weights: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,120 +0,0 @@
fileFormatVersion: 2
guid: a8e14774cb9b81d4799116466bc09437
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -22,15 +22,6 @@ AnimationClip:
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
@ -39,7 +30,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 2
time: 1
value: 0
inSlope: 0
outSlope: 0
@ -47,6 +38,15 @@ AnimationClip:
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 2
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
@ -96,15 +96,6 @@ AnimationClip:
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
@ -113,7 +104,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 2
time: 1
value: 0
inSlope: 0
outSlope: 0
@ -121,6 +112,15 @@ AnimationClip:
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 2
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@ -62,6 +62,8 @@ namespace AxibugEmuOnline.Client
}
}
public void ResetToDefault() => m_paramObject.overrideState = false;
public string Serilized()
{
return JsonUtility.ToJson(Value);

View File

@ -67,15 +67,111 @@ namespace AxibugEmuOnline.Client
public class Filter
{
public string Name => m_setting.Name;
public IReadOnlyCollection<EditableParamerter> Paramerters => m_setting.EditableParam;
/// <summary> 滤镜预设 </summary>
public List<FilterPreset> Presets = new List<FilterPreset>();
internal FilterEffect m_setting;
public Filter(FilterEffect setting)
{
m_setting = setting;
loadPresets();
}
internal IReadOnlyCollection<EditableParamerter> Paramerters => m_setting.EditableParam;
private void loadPresets()
{
var json = PlayerPrefs.GetString($"Filter_{Name}_PresetList", string.Empty);
var loadedPresets = JsonUtility.FromJson<FilterPresetList>(json);
if (loadedPresets == null) return;
else Presets = loadedPresets.presets;
}
private void savePresets()
{
var json = JsonUtility.ToJson(new FilterPresetList { presets = Presets });
PlayerPrefs.SetString($"Filter_{Name}_PresetList", json);
}
public MsgBool CreatePreset(string presetName,out FilterPreset newPreset)
{
newPreset = null;
if (Presets.Count(p => p.Name == presetName) != 0) return "名称重复";
newPreset = new FilterPreset(presetName);
Presets.Add(newPreset);
savePresets();
return true;
}
public void ResetPreset()
{
foreach (var param in Paramerters)
{
param.ResetToDefault();
}
}
public void ApplyPreset(FilterPreset preset)
{
foreach (var param in Paramerters)
{
var json = preset.GetParamValueJson(param.Name);
if (string.IsNullOrEmpty(json))
param.ResetToDefault();
else
param.Apply(json);
}
}
}
[Serializable]
private class FilterPresetList
{
public List<FilterPreset> presets;
}
[Serializable]
public class FilterPreset
{
[SerializeField]
public string Name;
[SerializeField]
private List<string> m_paramName = new List<string>();
[SerializeField]
private List<string> m_valueJson = new List<string>();
private bool m_cacheReady = false;
private Dictionary<string, string> m_paramName2ValueJson;
public FilterPreset(string presetName)
{
Name = presetName;
}
public string GetParamValueJson(string paramName)
{
prepareCache();
m_paramName2ValueJson.TryGetValue(paramName, out var value);
return value;
}
private void prepareCache()
{
if (m_cacheReady) return;
m_paramName2ValueJson = new Dictionary<string, string>();
for (int i = 0; i < m_paramName.Count; i++)
{
m_paramName2ValueJson[m_paramName[i]] = m_valueJson[i];
}
m_cacheReady = true;
}
}
}
}

View File

@ -0,0 +1,45 @@
/// <summary>
/// StringºÍBoolµÄ·ìºÏ¹Ö
/// </summary>
public struct MsgBool
{
public string ErrorMsg;
public bool Value;
public override readonly string ToString()
{
if (Value)
{
return true.ToString();
}
else
{
return ErrorMsg;
}
}
public static implicit operator MsgBool(string errorMsg)
{
return new MsgBool { Value = false, ErrorMsg = errorMsg };
}
public static implicit operator MsgBool(bool value)
{
return new MsgBool { Value = value };
}
public static implicit operator bool(MsgBool msgBool)
{
return msgBool.Value;
}
public static implicit operator (bool, string)(MsgBool msgBool)
{
return (msgBool.Value, msgBool.ErrorMsg);
}
public static implicit operator string(MsgBool msgBool)
{
return msgBool.ToString();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 26339d0bd71e1644daa0324182bd2bbf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -96,10 +96,7 @@ namespace AxibugEmuOnline.Client
};
}
public override void OnExcute()
{
}
public override void OnExcute(OptionUI optionUI, ref bool cancelHide) { }
}
}
}

View File

@ -1,5 +1,9 @@
using AxibugEmuOnline.Client.ClientCore;
using AxibugEmuOnline.Client.UI;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static AxibugEmuOnline.Client.FilterManager;
namespace AxibugEmuOnline.Client
{
@ -9,12 +13,11 @@ namespace AxibugEmuOnline.Client
public class UI_FilterItem : MenuItem, IVirtualItem
{
public int Index { get; set; }
public FilterManager.Filter Datacontext { get; private set; }
public Filter Datacontext { get; private set; }
public void SetData(object data)
{
Datacontext = data as FilterManager.Filter;
Datacontext = data as Filter;
UpdateView();
}
@ -35,13 +38,72 @@ namespace AxibugEmuOnline.Client
}
}
public void Release()
{
}
public void Release() { }
public override bool OnEnterItem()
{
var opts = new List<OptionMenu>();
opts.Add(new Opt_CreatePreset(Datacontext));
opts.AddRange(Datacontext.Presets.Select(p => new Opt_Presets(Datacontext, p)));
OptionUI.Instance.Pop(opts, onClose: () =>
{
App.filter.EnableFilterPreview();
Datacontext.ResetPreset();
App.filter.EnableFilter(Datacontext);
});
return false;
}
public class Opt_CreatePreset : ExecuteMenu
{
private Filter m_filter;
public Opt_CreatePreset(Filter filter) : base("创建滤镜预设", Resources.LoadAll<Sprite>("Icons/XMB-Icons/misc")[0])
{
m_filter = filter;
}
public override void OnFocus()
{
m_filter.ResetPreset();
App.filter.EnableFilter(m_filter);
}
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
{
cancelHide = true;
OverlayManager.Input((presetName) =>
{
var result = m_filter.CreatePreset(presetName, out var newPreset);
if (!result) OverlayManager.PopMsg(result);
else optionUI.AddOptionMenuWhenPoping(new Opt_Presets(m_filter, newPreset));
}, "为预设设置一个名称", string.Empty);
}
}
public class Opt_Presets : ExecuteMenu
{
private Filter m_filter;
private FilterPreset m_preset;
public Opt_Presets(Filter filter, FilterPreset preset) : base(preset.Name, null)
{
m_filter = filter;
m_preset = preset;
}
public override void OnFocus()
{
m_filter.ApplyPreset(m_preset);
App.filter.EnableFilter(m_filter);
}
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
{
}
}
}
}

View File

@ -2,6 +2,8 @@ using AxibugEmuOnline.Client.ClientCore;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace AxibugEmuOnline.Client
{
@ -80,9 +82,12 @@ namespace AxibugEmuOnline.Client
readonly List<CommandExecuter> oneFrameRegister = new List<CommandExecuter>();
private void Update()
{
if (!InputUI.IsInputing)
{
peekRegister(oneFrameRegister);
m_listener.Update(oneFrameRegister);
}
//键位映射在按键响应的堆栈结束后处理,防止迭代器修改问题
if (m_waitMapperSetting != null)

View File

@ -74,9 +74,9 @@ namespace AxibugEmuOnline.Client
m_romListUI = romListUI;
}
public override void OnExcute()
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
{
OverlayManager.Input((OnSearchCommit, "ÊäÈëRomÃû³Æ", m_romListUI.SearchKey));
OverlayManager.Input(OnSearchCommit, "ÊäÈëRomÃû³Æ", m_romListUI.SearchKey);
}
private void OnSearchCommit(string text)
@ -97,7 +97,7 @@ namespace AxibugEmuOnline.Client
m_ui = romListUI;
}
public override void OnExcute()
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
{
m_ui.SearchKey = null;
m_ui.RefreshUI();

View File

@ -82,7 +82,6 @@ namespace AxibugEmuOnline.Client
}
Eventer.Instance.RegisterEvent<int>(EEvent.OnRoomWaitStepChange, OnServerStepUpdate);
OptionUI.Instance.OnHide += PopMenu_OnHide;
gameObject.SetActiveEx(true);
}
@ -95,14 +94,12 @@ namespace AxibugEmuOnline.Client
public void Hide()
{
CommandDispatcher.Instance.UnRegistController(this);
OptionUI.Instance.OnHide -= PopMenu_OnHide;
gameObject.SetActiveEx(false);
}
protected override void OnCmdOptionMenu()
{
OptionUI.Instance.Pop(menus);
OptionUI.Instance.Pop(menus, 0, PopMenu_OnHide);
if (!IsNetPlay)//单人模式暂停模拟器
{

View File

@ -13,7 +13,7 @@ namespace AxibugEmuOnline.Client
m_gameUI = gameUI;
}
public override void OnExcute()
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
{
if (m_gameUI.IsNetPlay) return;

View File

@ -10,7 +10,7 @@ namespace AxibugEmuOnline.Client
m_gameUI = gameUI;
}
public override void OnExcute()
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
{
m_gameUI.QuitGame();
}

View File

@ -17,12 +17,13 @@ namespace AxibugEmuOnline.Client
m_gameUI = gameUI;
}
public override void OnExcute()
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
{
if (!m_gameUI.IsNetPlay)
{
App.emu.ResetGame();
}
}
}
}

View File

@ -17,7 +17,7 @@ namespace AxibugEmuOnline.Client
m_gameUI = gameUI;
}
public override void OnExcute()
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
{
if (m_gameUI.IsNetPlay) return;

View File

@ -25,8 +25,6 @@ namespace AxibugEmuOnline.Client
private bool m_bPoped = false;
private List<OptionUI_MenuItem> m_runtimeMenuItems = new List<OptionUI_MenuItem>();
public event Action OnHide;
private int m_selectIndex = -1;
public int SelectIndex
{
@ -44,6 +42,11 @@ namespace AxibugEmuOnline.Client
var itemUIRect = optionUI_MenuItem.transform as RectTransform;
SelectBorder.pivot = itemUIRect.pivot;
SelectBorder.sizeDelta = itemUIRect.rect.size;
//重置选择游标的动画
SelectBorder.gameObject.SetActive(false);
SelectBorder.gameObject.SetActive(true);
DOTween.To(() => SelectBorder.position, (value) => SelectBorder.position = value, itemUIRect.position, 0.125f);
SelectBorder.SetAsLastSibling();
}
@ -128,8 +131,30 @@ namespace AxibugEmuOnline.Client
}
IKeyMapperChanger m_lastCS;
public void Pop<T>(List<T> menus, int defaultIndex = 0) where T : OptionMenu
private Action m_onClose;
/// <summary>
/// 当菜单弹出时,动态添加一个菜单选项
/// </summary>
/// <param name="menu"></param>
public void AddOptionMenuWhenPoping(OptionMenu menu)
{
if (!m_bPoped) return;
CreateRuntimeMenuItem(menu);
Canvas.ForceUpdateCanvases();
OptionUI_MenuItem optionUI_MenuItem = m_runtimeMenuItems[m_selectIndex];
var itemUIRect = optionUI_MenuItem.transform as RectTransform;
SelectBorder.pivot = itemUIRect.pivot;
SelectBorder.position = itemUIRect.position;
SelectBorder.sizeDelta = itemUIRect.rect.size;
SelectBorder.SetAsLastSibling();
}
public void Pop<T>(List<T> menus, int defaultIndex = 0, Action onClose = null) where T : OptionMenu
{
m_onClose = onClose;
ReleaseRuntimeMenus();
foreach (var menu in menus) CreateRuntimeMenuItem(menu);
CommandDispatcher.Instance.RegistController(this);
@ -140,6 +165,7 @@ namespace AxibugEmuOnline.Client
m_selectIndex = defaultIndex;
OptionUI_MenuItem optionUI_MenuItem = m_runtimeMenuItems[defaultIndex];
optionUI_MenuItem.OnFocus();
var itemUIRect = optionUI_MenuItem.transform as RectTransform;
SelectBorder.pivot = itemUIRect.pivot;
SelectBorder.position = itemUIRect.position;
@ -196,7 +222,8 @@ namespace AxibugEmuOnline.Client
CommandDispatcher.Instance.Current = m_lastCS;
OnHide?.Invoke();
m_onClose?.Invoke();
m_onClose = null;
}
}
@ -242,12 +269,46 @@ namespace AxibugEmuOnline.Client
protected override bool OnCmdEnter()
{
var executer = m_runtimeMenuItems[SelectIndex];
Hide();
executer.OnExecute();
return true;
bool cancelHide = false;
executer.OnExecute(this, ref cancelHide);
if (!cancelHide) Hide();
return false;
}
}
/// <summary>
/// 带有执行行为的菜单
/// </summary>
public abstract class ExecuteMenu : OptionMenu
{
public ExecuteMenu(string name, Sprite icon = null) : base(name, icon) { }
public abstract void OnExcute(OptionUI optionUI, ref bool cancelHide);
}
/// <summary>
/// 带有值类型显示和编辑的菜单
/// </summary>
/// <typeparam name="T"></typeparam>
public class ValueSetMenu<T> : ValueSetMenu
{
public sealed override Type ValueType => typeof(T);
public T Value { get; private set; }
public sealed override object ValueRaw => Value;
public sealed override void OnValueChanged(object newValue)
{
Value = (T)newValue;
}
protected ValueSetMenu(string name) : base(name) { }
}
/// <summary> 不要直接继承这个类 </summary>
public abstract class OptionMenu
{
public string Name { get; protected set; }
@ -264,29 +325,7 @@ namespace AxibugEmuOnline.Client
public virtual void OnFocus() { }
public virtual void OnShow(OptionUI_MenuItem ui) { }
}
public abstract class ExecuteMenu : OptionMenu
{
public ExecuteMenu(string name, Sprite icon = null) : base(name, icon) { }
public abstract void OnExcute();
}
public class ValueSetMenu<T> : ValueSetMenu
{
public sealed override Type ValueType => typeof(T);
public T Value { get; private set; }
public sealed override object ValueRaw => Value;
public sealed override void OnValueChanged(object newValue)
{
Value = (T)newValue;
}
protected ValueSetMenu(string name) : base(name) { }
}
/// <summary> 不要直接继承这个类 </summary>
public abstract class ValueSetMenu : OptionMenu
{
public ValueSetMenu(string name) : base(name) { }

View File

@ -2,9 +2,9 @@ namespace AxibugEmuOnline.Client
{
public class OptionUI_ExecuteItem : OptionUI_MenuItem<ExecuteMenu>
{
public override void OnExecute()
public override void OnExecute(OptionUI optionUI, ref bool cancelHide)
{
MenuData.OnExcute();
MenuData.OnExcute(optionUI, ref cancelHide);
}
}
}

View File

@ -1,7 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
@ -35,7 +31,7 @@ namespace AxibugEmuOnline.Client
protected abstract void OnSetData(OptionMenu menuData);
public abstract void OnExecute();
public abstract void OnExecute(OptionUI optionUI, ref bool cancelHide);
public abstract void OnFocus();
}

View File

@ -12,6 +12,9 @@ namespace AxibugEmuOnline.Client
Action<string> OnCommit;
public static bool IsInputing { get; private set; }
protected override void OnShow(object param)
{
@ -22,6 +25,24 @@ namespace AxibugEmuOnline.Client
m_input.text = t.defaultText;
}
protected override void Update()
{
base.Update();
IsInputing = m_input.isFocused;
if (IsInputing && Input.GetButtonDown("Submit"))
{
OnCmdEnter();
}
}
protected override void OnDisable()
{
base.OnDisable();
IsInputing = false;
}
protected override void OnEnable()
{
base.OnEnable();

View File

@ -17,11 +17,16 @@ namespace AxibugEmuOnline.Client
m_InputUI.gameObject.SetActive(false);
}
public static InputUI Input((Action<string> callback, string placeHolder, string defaultText) param)
public static InputUI Input(Action<string> callback, string placeHolder, string defaultText)
{
s_ins.m_InputUI.Show(param);
s_ins.m_InputUI.Show((callback, placeHolder, defaultText));
return s_ins.m_InputUI;
}
public static void PopMsg(string msg)
{
}
}
}

View File

@ -5,246 +5,6 @@ InputManager:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Axes:
- serializedVersion: 3
m_Name: Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton: left
positiveButton: right
altNegativeButton: a
altPositiveButton: d
gravity: 3
dead: 0.001
sensitivity: 3
snap: 1
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton: down
positiveButton: up
altNegativeButton: s
altPositiveButton: w
gravity: 3
dead: 0.001
sensitivity: 3
snap: 1
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire1
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left ctrl
altNegativeButton:
altPositiveButton: mouse 0
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire2
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left alt
altNegativeButton:
altPositiveButton: mouse 1
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire3
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left shift
altNegativeButton:
altPositiveButton: mouse 2
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Jump
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: space
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Mouse X
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0.1
snap: 0
invert: 0
type: 1
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Mouse Y
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0.1
snap: 0
invert: 0
type: 1
axis: 1
joyNum: 0
- serializedVersion: 3
m_Name: Mouse ScrollWheel
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0.1
snap: 0
invert: 0
type: 1
axis: 2
joyNum: 0
- serializedVersion: 3
m_Name: Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0.19
sensitivity: 1
snap: 0
invert: 0
type: 2
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0.19
sensitivity: 1
snap: 0
invert: 1
type: 2
axis: 1
joyNum: 0
- serializedVersion: 3
m_Name: Fire1
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 0
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire2
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 1
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire3
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 2
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Jump
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: joystick button 3
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Submit
descriptiveName:
@ -252,26 +12,10 @@ InputManager:
negativeButton:
positiveButton: return
altNegativeButton:
altPositiveButton: joystick button 0
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Submit
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: enter
altNegativeButton:
altPositiveButton: space
gravity: 1000
dead: 0.001
sensitivity: 1000
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
@ -284,13 +28,44 @@ InputManager:
negativeButton:
positiveButton: escape
altNegativeButton:
altPositiveButton: joystick button 1
gravity: 1000
dead: 0.001
sensitivity: 1000
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton:
altNegativeButton:
altPositiveButton:
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
m_UsePhysicalKeys: 1