diff --git a/AxibugEmuOnline.Client/Assets/Editors.meta b/AxibugEmuOnline.Client/Assets/Editors.meta new file mode 100644 index 0000000..d920b2d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Editors.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fd41663b74cbfcc45a028bc891a8c4fc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Editors/AxibugEmuOnline.Editor.asmdef b/AxibugEmuOnline.Client/Assets/Editors/AxibugEmuOnline.Editor.asmdef new file mode 100644 index 0000000..08a7065 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Editors/AxibugEmuOnline.Editor.asmdef @@ -0,0 +1,18 @@ +{ + "name": "AxibugEmuOnline.Editor", + "rootNamespace": "AxibugEmuOnline.Editors", + "references": [ + "GUID:3fe77f1eed9fc0847a86648f644fe815" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Editors/AxibugEmuOnline.Editor.asmdef.meta b/AxibugEmuOnline.Client/Assets/Editors/AxibugEmuOnline.Editor.asmdef.meta new file mode 100644 index 0000000..3fa942e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Editors/AxibugEmuOnline.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a37804d4d608e1e4bb8204f442ab0e60 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Editors/CommandDispatcherEditor.cs b/AxibugEmuOnline.Client/Assets/Editors/CommandDispatcherEditor.cs new file mode 100644 index 0000000..c8dcbc9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Editors/CommandDispatcherEditor.cs @@ -0,0 +1,45 @@ +using AxibugEmuOnline.Client; +using System; +using UnityEditor; +using UnityEngine; +namespace AxibugEmuOnline.Editors +{ + [CustomEditor(typeof(CommandDispatcher))] + public class CommandDispatcherEditor : Editor + { + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + + var dispacather = target as CommandDispatcher; + + dispacather.GetRegisters(out var normal, out var solo); + + EditorGUILayout.BeginVertical(EditorStyles.helpBox); + EditorGUILayout.LabelField("NORMAL"); + foreach (var item in normal) + { + Draw(item); + } + EditorGUILayout.EndVertical(); + + EditorGUILayout.BeginVertical(EditorStyles.helpBox); + EditorGUILayout.LabelField("SOLO"); + foreach (var item in solo) + { + Draw(item); + } + EditorGUILayout.EndVertical(); + + Repaint(); + } + + private void Draw(CommandExecuter item) + { + EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); + using (new EditorGUI.DisabledGroupScope(!item.Enable)) + EditorGUILayout.ObjectField(item.gameObject, typeof(GameObject), false); + EditorGUILayout.EndHorizontal(); + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/Editors/CommandDispatcherEditor.cs.meta b/AxibugEmuOnline.Client/Assets/Editors/CommandDispatcherEditor.cs.meta new file mode 100644 index 0000000..0742aa8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Editors/CommandDispatcherEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 57378be70cec95341aea522ad2d8e30d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity b/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity index 9561d07..68a56ea 100644 --- a/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity +++ b/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity @@ -182,12 +182,12 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 74796456} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 2 + m_Father: {fileID: 1335662459} + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!224 &246947326 stripped RectTransform: @@ -1107,6 +1107,40 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3} +--- !u!1 &1335662458 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1335662459} + m_Layer: 0 + m_Name: IMPORTENT + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1335662459 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1335662458} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1639312037} + - {fileID: 74796459} + - {fileID: 1427887270} + - {fileID: 1599240741} + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1427887268 GameObject: m_ObjectHideFlags: 0 @@ -1136,25 +1170,20 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4471d8231d16ba3469228e09d4cb3a81, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!224 &1427887270 -RectTransform: +--- !u!4 &1427887270 +Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1427887268} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 3 + m_Father: {fileID: 1335662459} + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 960, y: 540} - m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &1498586261 GameObject: m_ObjectHideFlags: 3 @@ -1196,7 +1225,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1599240737 GameObject: @@ -1291,8 +1320,8 @@ RectTransform: m_Children: - {fileID: 1983793178} - {fileID: 246947326} - m_Father: {fileID: 0} - m_RootOrder: 4 + m_Father: {fileID: 1335662459} + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1375,11 +1404,11 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1639312034} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 1335662459} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!224 &1983793178 stripped @@ -1394,6 +1423,54 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 1599240741} m_Modifications: + - target: {fileID: 1714682891259844147, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1714682891259844147, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1714682891259844147, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1714682891259844147, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1714682891259844147, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1714682891259844147, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2780569438310375802, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2780569438310375802, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2780569438310375802, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2780569438310375802, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2780569438310375802, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2780569438310375802, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 4478785627166277609, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} propertyPath: m_Name value: OptionUI @@ -1486,5 +1563,29 @@ PrefabInstance: propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} + - target: {fileID: 6503369113137645357, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6503369113137645357, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6503369113137645357, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6503369113137645357, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6503369113137645357, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6503369113137645357, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: d3c2508a55398a24db5d68f68d2702ea, type: 3} diff --git a/AxibugEmuOnline.Client/Assets/Script/App.cs b/AxibugEmuOnline.Client/Assets/Script/App.cs index 15dc5cd..3af9f5d 100644 --- a/AxibugEmuOnline.Client/Assets/Script/App.cs +++ b/AxibugEmuOnline.Client/Assets/Script/App.cs @@ -49,6 +49,9 @@ namespace AxibugEmuOnline.Client.ClientCore GameObject.DontDestroyOnLoad(go); coRunner = go.AddComponent(); + var importNode = GameObject.Find("IMPORTENT"); + GameObject.DontDestroyOnLoad(importNode); + StartCoroutine(AppTickFlow()); } diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher/CommandDispatcher.cs b/AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher/CommandDispatcher.cs index ebe7894..487a421 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher/CommandDispatcher.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher/CommandDispatcher.cs @@ -1,5 +1,3 @@ -using AxibugEmuOnline.Client.UI; -using System; using System.Collections.Generic; using UnityEngine; @@ -9,7 +7,11 @@ namespace AxibugEmuOnline.Client { public static CommandDispatcher Instance { get; private set; } + /// 平级注册对象,都会响应指令 List m_register = new List(); + /// 独占注册对象,指令会被列表中最后一个对象独占 + List m_registerHigh = new List(); + Dictionary m_keyMapper = new Dictionary(); private void Awake() @@ -41,14 +43,26 @@ namespace AxibugEmuOnline.Client public void RegistController(CommandExecuter controller) { - if (m_register.Contains(controller)) { return; } + if (!controller.AloneMode) + { + if (m_register.Contains(controller)) { return; } - m_register.Add(controller); + m_register.Add(controller); + } + else + { + if (m_registerHigh.Contains(controller)) { return; } + + m_registerHigh.Add(controller); + } } public void UnRegistController(CommandExecuter menuItemController) { - m_register.Remove(menuItemController); + if (!menuItemController.AloneMode) + m_register.Remove(menuItemController); + else + m_registerHigh.Remove(menuItemController); } readonly List oneFrameRegister = new List(); @@ -56,31 +70,60 @@ namespace AxibugEmuOnline.Client { foreach (var item in m_keyMapper) { + peekRegister(oneFrameRegister); + if (Input.GetKeyDown(item.Key)) { - oneFrameRegister.Clear(); - oneFrameRegister.AddRange(m_register); - - for (int i = 0; i < oneFrameRegister.Count; i++) + foreach (var controller in oneFrameRegister) { - var controller = oneFrameRegister[i]; if (!controller.Enable) continue; controller.ExecuteCommand(item.Value, false); } } if (Input.GetKeyUp(item.Key)) { - oneFrameRegister.Clear(); - oneFrameRegister.AddRange(m_register); - - for (int i = 0; i < oneFrameRegister.Count; i++) + foreach (var controller in oneFrameRegister) { - var controller = oneFrameRegister[i]; if (!controller.Enable) continue; controller.ExecuteCommand(item.Value, true); } } } } + + private List peekRegister(List results) + { + results.Clear(); + + if (m_registerHigh.Count > 0) + { + for (int i = m_registerHigh.Count - 1; i >= 0; i--) + { + var controller = m_registerHigh[i]; + if (controller.Enable) + { + results.Add(controller); + return results; + } + } + } + + foreach (var controller in m_register) + { + if (!controller.Enable) continue; + + results.Add(controller); + } + + return results; + } + +#if UNITY_EDITOR + public void GetRegisters(out IReadOnlyList normal, out IReadOnlyList alone) + { + normal = m_register; + alone = m_registerHigh; + } +#endif } } diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher/CommandExcuter.cs b/AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher/CommandExcuter.cs index 12db380..1462b37 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher/CommandExcuter.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher/CommandExcuter.cs @@ -18,6 +18,7 @@ namespace AxibugEmuOnline.Client float PulseInvoke_Interval = 0.05f; public abstract bool Enable { get; } + public virtual bool AloneMode { get; } protected virtual void Awake() { diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/MenuItemController.cs b/AxibugEmuOnline.Client/Assets/Script/UI/MenuItemController.cs index d09e73e..49c4f04 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/MenuItemController.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/MenuItemController.cs @@ -11,7 +11,7 @@ namespace AxibugEmuOnline.Client protected List m_runtimeMenuUI = new List(); public override bool Enable => enabled; - private MenuItem m_enteredItem = null; + protected MenuItem m_enteredItem = null; protected int m_selectIndex = -1; diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/OptionUI/OptionUI.cs b/AxibugEmuOnline.Client/Assets/Script/UI/OptionUI/OptionUI.cs index 1de156f..8a5da68 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/OptionUI/OptionUI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/OptionUI/OptionUI.cs @@ -17,6 +17,8 @@ namespace AxibugEmuOnline.Client [Header("模板")] [SerializeField] OptionUI_ExecuteItem TEMPLATE_EXECUTEITEM; + public override bool AloneMode => true; + private bool m_bPoped = false; private List m_runtimeMenuItems = new List(); @@ -77,6 +79,7 @@ namespace AxibugEmuOnline.Client { if (m_bPoped) { + CommandDispatcher.Instance.UnRegistController(this); m_bPoped = false; Canvas.ForceUpdateCanvases(); var width = MenuRoot.rect.width; @@ -118,7 +121,7 @@ namespace AxibugEmuOnline.Client protected override void OnSelectMenuChanged() { - + } } diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/SubMenuItemGroup.cs b/AxibugEmuOnline.Client/Assets/Script/UI/SubMenuItemGroup.cs index 4a6b605..b92d2b1 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/SubMenuItemGroup.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/SubMenuItemGroup.cs @@ -66,8 +66,9 @@ namespace AxibugEmuOnline.Client protected override bool OnCmdEnter() { - LaunchUI.Instance.ToDetailMenuLayout(); base.OnCmdEnter(); + + LaunchUI.Instance.ToDetailMenuLayout(); var item = GetItemUIByIndex(SelectIndex); item.SetSelectState(false); @@ -77,6 +78,7 @@ namespace AxibugEmuOnline.Client protected override void OnCmdBack() { base.OnCmdBack(); + LaunchUI.Instance.ToMainMenuLayout(); var item = GetItemUIByIndex(SelectIndex); item.SetSelectState(true); @@ -84,12 +86,14 @@ namespace AxibugEmuOnline.Client protected override void OnCmdSelectItemUp() { - SelectIndex--; + if (m_enteredItem == null) + SelectIndex--; } protected override void OnCmdSelectItemDown() { - SelectIndex++; + if (m_enteredItem == null) + SelectIndex++; } public virtual void SetSelect(bool select)