From 80fdb2dbbaf4241b90883f82d2a908b981020379 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Thu, 29 Aug 2024 18:31:36 +0800 Subject: [PATCH] =?UTF-8?q?Ui=E8=BF=AD=E4=BB=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIPrefabs/RomItemTemplate.prefab | 44 ++++- .../Assets/Scene/AxibugEmuOnline.Client.unity | 101 +----------- .../Assets/Scene/EmuTest.unity | 151 +----------------- .../Assets/Script/AppAxibugEmuOnline.cs | 2 + .../Assets/Script/Manager/AppSceneLoader.cs | 89 +++++++++++ .../Script/Manager/AppSceneLoader.cs.meta | 11 ++ .../Assets/Script/NesEmulator/NesEmulator.cs | 11 +- .../Assets/Script/UI/RomItem.cs | 17 +- .../VirtualNes.Core/Mapper/Mapper245.cs | 2 +- .../ProjectSettings/EditorBuildSettings.asset | 3 + 10 files changed, 178 insertions(+), 253 deletions(-) create mode 100644 AxibugEmuOnline.Client/Assets/Script/Manager/AppSceneLoader.cs create mode 100644 AxibugEmuOnline.Client/Assets/Script/Manager/AppSceneLoader.cs.meta diff --git a/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/RomItemTemplate.prefab b/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/RomItemTemplate.prefab index 62219036..b16983a3 100644 --- a/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/RomItemTemplate.prefab +++ b/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/RomItemTemplate.prefab @@ -389,6 +389,8 @@ GameObject: - component: {fileID: 8789823129857705082} - component: {fileID: 3252398029444565139} - component: {fileID: 6788248266412682264} + - component: {fileID: 8081109478688381999} + - component: {fileID: 6660646139021869069} m_Layer: 5 m_Name: InfoNode m_TagString: Untagged @@ -414,8 +416,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 100, y: 0} - m_SizeDelta: {x: -200, y: 0} + m_AnchoredPosition: {x: 494.04688, y: 0} + m_SizeDelta: {x: 588.0938, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &3252398029444565139 MonoBehaviour: @@ -455,6 +457,44 @@ CanvasGroup: m_Interactable: 1 m_BlocksRaycasts: 1 m_IgnoreParentGroups: 0 +--- !u!222 &8081109478688381999 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3993825260653792697} + m_CullTransparentMesh: 1 +--- !u!114 &6660646139021869069 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3993825260653792697} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 --- !u!1 &4643603390456494410 GameObject: m_ObjectHideFlags: 0 diff --git a/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity b/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity index 97c57cb7..f56e1a22 100644 --- a/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity +++ b/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -216,106 +216,13 @@ RectTransform: m_Children: - {fileID: 730698712} m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} ---- !u!1 &537454904 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 537454906} - - component: {fileID: 537454905} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &537454905 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 537454904} - m_Enabled: 1 - serializedVersion: 10 - m_Type: 1 - m_Shape: 0 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} - m_Intensity: 1 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.80208 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_UseViewFrustumForShadowCasterCull: 1 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &537454906 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 537454904} - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1 &589359925 GameObject: m_ObjectHideFlags: 0 @@ -380,7 +287,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &730698711 PrefabInstance: @@ -4976,5 +4883,5 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/AxibugEmuOnline.Client/Assets/Scene/EmuTest.unity b/AxibugEmuOnline.Client/Assets/Scene/EmuTest.unity index 9804021f..0d5cca22 100644 --- a/AxibugEmuOnline.Client/Assets/Scene/EmuTest.unity +++ b/AxibugEmuOnline.Client/Assets/Scene/EmuTest.unity @@ -123,155 +123,6 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &1232273651 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1232273654} - - component: {fileID: 1232273653} - - component: {fileID: 1232273652} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &1232273652 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1232273651} - m_Enabled: 1 ---- !u!20 &1232273653 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1232273651} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 0 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &1232273654 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1232273651} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1359344831 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1359344834} - - component: {fileID: 1359344833} - - component: {fileID: 1359344832} - m_Layer: 0 - m_Name: EventSystem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1359344832 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1359344831} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} - m_Name: - m_EditorClassIdentifier: - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 ---- !u!114 &1359344833 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1359344831} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} - m_Name: - m_EditorClassIdentifier: - m_FirstSelected: {fileID: 0} - m_sendNavigationEvents: 1 - m_DragThreshold: 10 ---- !u!4 &1359344834 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1359344831} - 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: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &4232056520998800727 PrefabInstance: m_ObjectHideFlags: 0 @@ -281,7 +132,7 @@ PrefabInstance: m_Modifications: - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_RootOrder - value: 2 + value: 0 objectReference: {fileID: 0} - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalPosition.x diff --git a/AxibugEmuOnline.Client/Assets/Script/AppAxibugEmuOnline.cs b/AxibugEmuOnline.Client/Assets/Script/AppAxibugEmuOnline.cs index 5f8b6568..acd93b4a 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppAxibugEmuOnline.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppAxibugEmuOnline.cs @@ -22,6 +22,7 @@ namespace AxibugEmuOnline.Client.ClientCore public static RomLib nesRomLib; public static HttpAPI httpAPI; public static CacheManager CacheMgr; + public static AppSceneLoader SceneLoader; private static CoroutineRunner coRunner; @@ -41,6 +42,7 @@ namespace AxibugEmuOnline.Client.ClientCore httpAPI = new HttpAPI(); nesRomLib = new RomLib(EnumPlatform.NES); CacheMgr = new CacheManager(); + SceneLoader = new AppSceneLoader(); var go = new GameObject("[AppAxibugEmuOnline]"); GameObject.DontDestroyOnLoad(go); diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/AppSceneLoader.cs b/AxibugEmuOnline.Client/Assets/Script/Manager/AppSceneLoader.cs new file mode 100644 index 00000000..bd609123 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/AppSceneLoader.cs @@ -0,0 +1,89 @@ +using AxibugEmuOnline.Client.ClientCore; +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace AxibugEmuOnline.Client +{ + public class AppSceneLoader + { + public LoadTask CurrentTask { get; private set; } + + Queue m_tasks = new Queue(); + Coroutine m_coroutine; + public void BeginLoad(string scenePath, Action callback) + { + m_tasks.Enqueue(new LoadTask(scenePath, callback)); + if (m_coroutine == null) + m_coroutine = AppAxibugEmuOnline.StartCoroutine(TaskFlow()); + } + + private IEnumerator TaskFlow() + { + while (m_tasks.Count > 0) + { + CurrentTask = m_tasks.Dequeue(); + + while (CurrentTask.MoveNext()) yield return null; + + CurrentTask.Callback(); + } + + CurrentTask = null; + m_coroutine = null; + } + + public class LoadTask + { + public EnumTaskState State { get; private set; } = EnumTaskState.Idle; + public float Progress => m_loadingOp != null ? m_loadingOp.progress : 0; + + private AsyncOperation m_loadingOp; + private string m_scenePath; + private Action m_callback; + public LoadTask(string scenePath, Action callback) + { + m_scenePath = scenePath; + m_callback = callback; + } + + public bool MoveNext() + { + if (State == EnumTaskState.Idle) + { + State = EnumTaskState.Running; + m_loadingOp = SceneManager.LoadSceneAsync(m_scenePath, LoadSceneMode.Additive); + return true; + } + else if (State == EnumTaskState.Running) + { + m_loadingOp.allowSceneActivation = true; + if (m_loadingOp.isDone) + { + State = EnumTaskState.Complete; + } + + return true; + } + else + { + return false; + } + } + + public void Callback() + { + m_callback?.Invoke(); + } + } + + public enum EnumTaskState + { + Idle, + Running, + Complete + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/AppSceneLoader.cs.meta b/AxibugEmuOnline.Client/Assets/Script/Manager/AppSceneLoader.cs.meta new file mode 100644 index 00000000..e9929a3e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/AppSceneLoader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 31fee02299bfd5141aefb2bbfb0555a9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs index 02760be8..f3f88572 100644 --- a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs @@ -62,8 +62,8 @@ namespace AxibugEmuOnline.Client } #if UNITY_EDITOR - [ContextMenu("IMPORT")] - public void TTTA() + [ContextMenu("ImportNesDB")] + public void ImportNesDB() { var db = Resources.Load("NES/ROMDB"); db.Clear(); @@ -85,6 +85,13 @@ namespace AxibugEmuOnline.Client UnityEditor.EditorUtility.SetDirty(db); UnityEditor.AssetDatabase.SaveAssets(); } + + [ContextMenu("GetState")] + public void GetState() + { + var state = NesCore.GetState(); + var bytes = state.ToBytes(); + } #endif } } diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/RomItem.cs b/AxibugEmuOnline.Client/Assets/Script/UI/RomItem.cs index c729ae15..1137adce 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/RomItem.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/RomItem.cs @@ -2,11 +2,13 @@ using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.UI; using System; using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.SceneManagement; using UnityEngine.UI; namespace AxibugEmuOnline.Client { - public class RomItem : MenuItem, IVirtualItem + public class RomItem : MenuItem, IVirtualItem, IPointerClickHandler { [SerializeField] Image m_romImage; @@ -62,5 +64,18 @@ namespace AxibugEmuOnline.Client }); } } + + public void OnPointerClick(PointerEventData eventData) + { + if (!m_romfile.RomReady) + m_romfile.BeginDownload(); + else + { + AppAxibugEmuOnline.SceneLoader.BeginLoad("Scene/EmuTest", () => + { + var nesEmu = GameObject.FindObjectOfType(); + }); + } + } } } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs index 8705ad50..0ee53b9f 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs @@ -248,7 +248,7 @@ namespace VirtualNes.Core chr6 = p[14]; chr7 = p[15]; irq_enable = p[16]; - irq_counter = (INT)p[17]; + irq_counter = p[17]; irq_latch = p[18]; irq_request = p[19]; } diff --git a/AxibugEmuOnline.Client/ProjectSettings/EditorBuildSettings.asset b/AxibugEmuOnline.Client/ProjectSettings/EditorBuildSettings.asset index 65e4435f..bf151126 100644 --- a/AxibugEmuOnline.Client/ProjectSettings/EditorBuildSettings.asset +++ b/AxibugEmuOnline.Client/ProjectSettings/EditorBuildSettings.asset @@ -5,6 +5,9 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 m_Scenes: + - enabled: 1 + path: Assets/Scene/AxibugEmuOnline.Client.unity + guid: eb0c18a619175384d95147898a43054b - enabled: 1 path: Assets/Scene/EmuTest.unity guid: 3dba71db67877594a9b5b77059205ec8