This commit is contained in:
ALIENJACK\alien 2024-08-30 16:23:27 +08:00
parent fc94396dfa
commit 96d0df5348
16 changed files with 3051 additions and 3970 deletions

View File

@ -298,6 +298,81 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &1813396448589485488
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4467178468921796307}
- component: {fileID: 8568189430970172828}
- component: {fileID: 6941538197753025297}
m_Layer: 5
m_Name: SelectArrow
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4467178468921796307
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1813396448589485488}
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: 331028397738758164}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 63, y: 70}
m_Pivot: {x: 0, y: 0.5}
--- !u!222 &8568189430970172828
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1813396448589485488}
m_CullTransparentMesh: 1
--- !u!114 &6941538197753025297
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1813396448589485488}
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: 1}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: -1023481969782777897, guid: d518d00d4940e854bbe45d9ef891401a, type: 3}
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 &3189920797946144379
GameObject:
m_ObjectHideFlags: 0
@ -354,10 +429,9 @@ MonoBehaviour:
Root: {fileID: 8754483333502849411}
ShadowIcon: {fileID: 2619187604372594158}
InfoNode: {fileID: 5331629140490413834}
SubMenuItemGroup: {fileID: 0}
SubMenuItemGroup: {fileID: 4672405243908051711}
SelectScale: 1
UnSelectScale: 1
RomGroup: {fileID: 6055880809428073973}
RomGroupRoot: {fileID: 3086674949377227884}
--- !u!114 &5700455559359757662
MonoBehaviour:
@ -486,6 +560,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2303118795734916657}
- {fileID: 4467178468921796307}
m_Father: {fileID: 8754483333502849411}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -509,7 +584,7 @@ MonoBehaviour:
m_Content: {fileID: 8865437771338118001}
m_Horizontal: 0
m_Vertical: 1
m_MovementType: 1
m_MovementType: 0
m_Elasticity: 0.1
m_Inertia: 1
m_DecelerationRate: 0.135
@ -536,7 +611,19 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1d1e3e91ac34bc8468f357ee247ffb6a, type: 3}
m_Name:
m_EditorClassIdentifier:
m_menuItemRoot: {fileID: 0}
PulseInvoke_Delay: 0.4
PulseInvoke_Interval: 0.05
SubMenuItemTemplate: {fileID: 0}
alphaGroup: {fileID: 0}
m_selectItemPosition: {x: 50, y: -51}
step: 50
splitStep: 200
m_selectArrow: {fileID: 4467178468921796307}
ArrowOffset: 115
WidthFix: 225
itemGroup: {fileID: 6055880809428073973}
srollRect: {fileID: 3428297980621487917}
--- !u!225 &3086674949377227884
CanvasGroup:
m_ObjectHideFlags: 0
@ -778,7 +865,7 @@ MonoBehaviour:
m_StartCorner: 0
m_StartAxis: 0
m_CellSize: {x: 500, y: 200}
m_Spacing: {x: 0, y: 10}
m_Spacing: {x: 0, y: 20}
m_Constraint: 1
m_ConstraintCount: 1
ItemTemplate: {fileID: 1998281097548910301, guid: e6df0d7c236795247971f0d1e691b068, type: 3}

View File

@ -108,16 +108,16 @@ RectTransform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 734025543935719296}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 2}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 6087025893861054323}
m_Father: {fileID: 8754483333502849411}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_AnchoredPosition: {x: -150, y: 0}
m_SizeDelta: {x: -296, y: 4}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5792146190930927166
CanvasRenderer:
@ -134,7 +134,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 734025543935719296}
m_Enabled: 0
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
@ -148,9 +148,9 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 0
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillCenter: 0
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
@ -250,8 +250,7 @@ RectTransform:
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: 1323634865265500141}
m_Children: []
m_Father: {fileID: 8105925540140519754}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -335,7 +334,7 @@ RectTransform:
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 500, y: 200}
m_Pivot: {x: 0, y: 0.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &8404333486862214380
MonoBehaviour:
m_ObjectHideFlags: 0
@ -356,7 +355,7 @@ MonoBehaviour:
InfoNode: {fileID: 0}
SubMenuItemGroup: {fileID: 0}
SelectScale: 1
UnSelectScale: 1
UnSelectScale: 0.8
m_romImage: {fileID: 67125096702760250}
--- !u!114 &5700455559359757662
MonoBehaviour:
@ -412,7 +411,7 @@ RectTransform:
- {fileID: 6095356919362338847}
- {fileID: 8126322204359135913}
m_Father: {fileID: 8754483333502849411}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -526,7 +525,7 @@ RectTransform:
m_Children:
- {fileID: 6087025893861054323}
m_Father: {fileID: 8754483333502849411}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
@ -677,6 +676,7 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1323634865265500141}
- {fileID: 8105925540140519754}
- {fileID: 8789823129857705082}
m_Father: {fileID: 1998281097548910301}

View File

@ -9,6 +9,7 @@ namespace AxibugEmuOnline.Client
{
public class AppSceneLoader
{
public LoadTask CurrentTask { get; private set; }
Queue<LoadTask> m_tasks = new Queue<LoadTask>();
@ -54,7 +55,7 @@ namespace AxibugEmuOnline.Client
if (State == EnumTaskState.Idle)
{
State = EnumTaskState.Running;
m_loadingOp = SceneManager.LoadSceneAsync(m_scenePath, LoadSceneMode.Additive);
m_loadingOp = SceneManager.LoadSceneAsync(m_scenePath, LoadSceneMode.Single);
return true;
}
else if (State == EnumTaskState.Running)

View File

@ -3,14 +3,13 @@ using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using UnityEngine;
using static Codice.Client.BaseCommands.Import.Commit;
using App = AxibugEmuOnline.Client.ClientCore.AppAxibugEmuOnline;
namespace AxibugEmuOnline.Client
{
public class Game_NES : MenuItem
{
[SerializeField]
ItemPresent RomGroup;
[SerializeField]
CanvasGroup RomGroupRoot;
private TweenerCore<float, float, FloatOptions> m_showTween;
@ -21,6 +20,25 @@ namespace AxibugEmuOnline.Client
RomGroupRoot.alpha = 0;
}
public override void SetSelectState(bool selected)
{
if (m_select == selected) return;
m_select = selected;
if (ShadowIcon != null) ShadowIcon.gameObject.SetActiveEx(selected);
if (progressTween != null) { progressTween.Kill(); progressTween = null; }
progressTween = DOTween.To(() => m_progress, (x) => m_progress = x, m_select ? 1 : 0, 5)
.SetSpeedBased().OnUpdate(() =>
{
if (InfoNode != null) InfoNode.alpha = m_progress;
Root.localScale = Vector3.one * Mathf.Lerp(UnSelectScale, SelectScale, m_progress);
});
}
public override void OnEnterItem()
{
RomGroupRoot.gameObject.SetActive(true);
@ -35,9 +53,14 @@ namespace AxibugEmuOnline.Client
App.nesRomLib.FetchRomCount((roms) =>
{
RomGroup.UpdateDependencyProperty(App.nesRomLib);
RomGroup.SetData(roms);
var thirdMenuGroup = SubMenuItemGroup as ThirdMenuRoot;
thirdMenuGroup.itemGroup.UpdateDependencyProperty(thirdMenuGroup);
thirdMenuGroup.itemGroup.SetData(roms);
thirdMenuGroup.itemGroup.UpdateProxyVisualState();
thirdMenuGroup.SelectIndex = 0;
});
if (SubMenuItemGroup != null) SubMenuItemGroup.SetSelect(true);
}
public override void OnExitItem()
@ -52,6 +75,8 @@ namespace AxibugEmuOnline.Client
{
RomGroupRoot.gameObject.SetActive(false);
});
if (SubMenuItemGroup != null) SubMenuItemGroup.SetSelect(false);
}
}
}

View File

@ -28,6 +28,8 @@ namespace AxibugEmuOnline.Client
private void Awake()
{
Instance = this;
DontDestroyOnLoad(this);
DontDestroyOnLoad(Camera.main.gameObject);
m_mainLayoutPosition = MainMenuRoot.anchoredPosition;
MainMenu.ListenControlAction = true;
}

View File

@ -10,7 +10,7 @@ using UnityEngine.UI;
namespace AxibugEmuOnline.Client.UI
{
public class MainMenuController : MenuItemController
public class MainMenuController : MenuItemController<MenuData>
{
[SerializeField]
HorizontalLayoutGroup GroupRoot;
@ -34,7 +34,9 @@ namespace AxibugEmuOnline.Client.UI
m_runtimeMenuUICanvas = m_runtimeMenuUI.Select(menu => menu.gameObject.AddComponent<CanvasGroup>()).ToList();
m_runtimeMenuUICanvas.ForEach(canv => canv.gameObject.AddComponent<AutoRaycastCanvasGroup>());
}
public override void Init(List<MenuData> menuDataList)
{
}
public void EnterDetailState()
{

View File

@ -10,28 +10,28 @@ namespace AxibugEmuOnline.Client.UI
public class MenuItem : MonoBehaviour
{
[SerializeField]
Image Icon;
protected Image Icon;
[SerializeField]
Text Txt;
protected Text Txt;
[SerializeField]
Text Descript;
protected Text Descript;
[SerializeField]
Transform Root;
protected Transform Root;
[SerializeField]
Image ShadowIcon;
protected Image ShadowIcon;
[SerializeField]
CanvasGroup InfoNode;
protected CanvasGroup InfoNode;
[SerializeField]
SubMenuItemGroup SubMenuItemGroup;
protected SubMenuItemGroup SubMenuItemGroup;
public float SelectScale = 1f;
public float UnSelectScale = 0.85f;
public RectTransform Rect => transform as RectTransform;
bool m_select;
TweenerCore<float, float, FloatOptions> progressTween;
float m_progress;
protected bool m_select;
protected TweenerCore<float, float, FloatOptions> progressTween;
protected float m_progress;
private void Awake()
{
m_select = false;
@ -65,7 +65,7 @@ namespace AxibugEmuOnline.Client.UI
if (ShadowIcon != null) ShadowIcon.sprite = icon;
}
public void SetSelectState(bool selected)
public virtual void SetSelectState(bool selected)
{
if (m_select == selected) return;

View File

@ -1,5 +1,4 @@
using AxibugEmuOnline.Client.UI;
using System;
using System.Collections.Generic;
using UnityEngine;
@ -7,35 +6,36 @@ namespace AxibugEmuOnline.Client
{
public abstract class MenuItemController : MonoBehaviour
{
[SerializeField]
float PulseInvoke_Delay = 0.4f;
[SerializeField]
float PulseInvoke_Interval = 0.05f;
private bool m_listenControlAction;
public bool ListenControlAction
public enum EnumCommand
{
get => m_listenControlAction;
set
{
m_listenControlAction = value;
if (value)
CommandDispatcher.Instance.RegistController(this);
else
CommandDispatcher.Instance.UnRegistController(this);
}
SelectItemLeft,
SelectItemRight,
SelectItemUp,
SelectItemDown,
Enter,
Back,
OptionMenu
}
[SerializeField]
protected Transform m_menuItemRoot;
protected List<MenuItem> m_runtimeMenuUI = new List<MenuItem>();
private PulseInvoker m_pulsInvoker_Left;
private PulseInvoker m_pulsInvoker_Right;
private PulseInvoker m_pulsInvoker_Up;
private PulseInvoker m_pulsInvoker_Down;
MenuItem m_enteredItem = null;
private int m_selectIndex = -1;
protected List<MenuItem> m_runtimeMenuUI = new List<MenuItem>();
[SerializeField]
float PulseInvoke_Delay = 0.4f;
[SerializeField]
float PulseInvoke_Interval = 0.05f;
public int SelectIndex
protected int m_selectIndex = -1;
public virtual int SelectIndex
{
get => m_selectIndex;
set
@ -48,15 +48,15 @@ namespace AxibugEmuOnline.Client
}
}
[SerializeField]
protected Transform m_menuItemRoot;
protected virtual void Start()
{
for (int i = 0; i < m_menuItemRoot.childCount; i++)
if (m_menuItemRoot != null)
{
Transform child = m_menuItemRoot.GetChild(i);
m_runtimeMenuUI.Add(child.GetComponent<MenuItem>());
for (int i = 0; i < m_menuItemRoot.childCount; i++)
{
Transform child = m_menuItemRoot.GetChild(i);
m_runtimeMenuUI.Add(child.GetComponent<MenuItem>());
}
}
Canvas.ForceUpdateCanvases();
@ -68,11 +68,6 @@ namespace AxibugEmuOnline.Client
m_pulsInvoker_Down = new PulseInvoker(OnCmdSelectItemDown, PulseInvoke_Delay, PulseInvoke_Interval);
}
private void OnDestroy()
{
if (CommandDispatcher.Instance != null)
CommandDispatcher.Instance.UnRegistController(this);
}
protected virtual void Update()
{
@ -82,9 +77,6 @@ namespace AxibugEmuOnline.Client
m_pulsInvoker_Down.Update(Time.deltaTime);
}
protected abstract void OnSelectMenuChanged();
MenuItem m_enteredItem = null;
public void ExecuteCommand(EnumCommand cmd, bool cancel)
{
if (!cancel)
@ -170,15 +162,39 @@ namespace AxibugEmuOnline.Client
protected virtual void OnCmdOptionMenu() { }
protected virtual void OnCmdEnter(MenuItem item) { item.OnEnterItem(); }
protected virtual void OnCmdBack(MenuItem item) { item.OnExitItem(); }
public enum EnumCommand
protected abstract void OnSelectMenuChanged();
}
public abstract class MenuItemController<T> : MenuItemController
{
private bool m_listenControlAction;
public bool ListenControlAction
{
SelectItemLeft,
SelectItemRight,
SelectItemUp,
SelectItemDown,
Enter,
Back,
OptionMenu
get => m_listenControlAction;
set
{
m_listenControlAction = value;
if (value)
CommandDispatcher.Instance.RegistController(this);
else
CommandDispatcher.Instance.UnRegistController(this);
}
}
public abstract void Init(List<T> menuDataList);
private void OnDestroy()
{
if (CommandDispatcher.Instance != null)
CommandDispatcher.Instance.UnRegistController(this);
}
}
}

View File

@ -15,7 +15,7 @@ namespace AxibugEmuOnline.Client
public int Index { get; set; }
private RomLib m_romlib;
private RomLib m_romlib => AppAxibugEmuOnline.nesRomLib;
private RomFile m_romfile;
public void SetData(object data)
@ -34,7 +34,7 @@ namespace AxibugEmuOnline.Client
public void SetDependencyProperty(object data)
{
m_romlib = (RomLib)data;
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
}
public void Release()
@ -74,6 +74,7 @@ namespace AxibugEmuOnline.Client
AppAxibugEmuOnline.SceneLoader.BeginLoad("Scene/EmuTest", () =>
{
var nesEmu = GameObject.FindObjectOfType<NesEmulator>();
nesEmu.StartGame(m_romfile);
});
}
}

View File

@ -9,7 +9,7 @@ using UnityEngine;
namespace AxibugEmuOnline.Client
{
public class SubMenuItemGroup : MenuItemController
public class SubMenuItemGroup : MenuItemController<MenuData>
{
[SerializeField]
MenuItem SubMenuItemTemplate;
@ -28,7 +28,7 @@ namespace AxibugEmuOnline.Client
alphaGroup.alpha = 0;
}
public void Init(List<MenuData> menuDataList)
public override void Init(List<MenuData> menuDataList)
{
#if UNITY_EDITOR
while (transform.childCount > 0)
@ -86,7 +86,7 @@ namespace AxibugEmuOnline.Client
SelectIndex++;
}
public void SetSelect(bool select)
public virtual void SetSelect(bool select)
{
if (m_selected == select) return;
m_selected = select;

View File

@ -1,14 +1,43 @@
using AxibugEmuOnline.Client.UI;
using DG.Tweening;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace AxibugEmuOnline.Client
{
public class ThirdMenuRoot : MonoBehaviour
public class ThirdMenuRoot : SubMenuItemGroup
{
private RectTransform m_rect;
private RectTransform m_parent;
[SerializeField]
private RectTransform m_selectArrow;
[SerializeField]
float ArrowOffset = 50;
[SerializeField]
float WidthFix = 50;
[SerializeField]
public ItemPresent itemGroup;
[SerializeField]
ScrollRect srollRect;
public override int SelectIndex
{
get => m_selectIndex;
set
{
if (itemGroup.DataList == null) return;
value = Mathf.Clamp(value, 0, itemGroup.DataList.Count - 1);
if (m_selectIndex == value) return;
bool useAnim = m_selectIndex != -1;
m_selectIndex = value;
RollToIndex(m_selectIndex, useAnim);
OnSelectMenuChanged();
}
}
private void Awake()
{
@ -21,6 +50,29 @@ namespace AxibugEmuOnline.Client
SyncRectToLaunchUI();
}
protected override void OnSelectMenuChanged()
{
itemGroup.UpdateDependencyProperty(this);
}
void RollToIndex(int index, bool useAnim = false)
{
Vector2 itemPos = itemGroup.GetItemAnchorePos(index);
Vector3[] corners = new Vector3[4];
Vector2 targetPos = itemGroup.transform.InverseTransformPoint(m_selectArrow.position);
itemGroup.RectTransform.GetLocalCorners(corners);
targetPos = targetPos - (Vector2)corners[1];
float gap = targetPos.y - itemPos.y;
srollRect.velocity = Vector2.zero;
if (!useAnim)
srollRect.content.anchoredPosition += new Vector2(0, gap);
else
srollRect.content.anchoredPosition += new Vector2(0, gap);
}
Vector3[] corner = new Vector3[4];
private void SyncRectToLaunchUI()
{
@ -48,6 +100,21 @@ namespace AxibugEmuOnline.Client
var widthGap = parentPosition.x - rootPosition.x;
m_rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, launchUIRect.rect.width - widthGap - WidthFix);
m_selectArrow.position = m_parent.transform.position;
temp = m_selectArrow.anchoredPosition;
temp.x += ArrowOffset;
m_selectArrow.anchoredPosition = temp;
}
protected override void OnCmdSelectItemDown()
{
base.OnCmdSelectItemDown();
}
protected override void OnCmdSelectItemUp()
{
base.OnCmdSelectItemUp();
}
}
}

View File

@ -1,5 +1,6 @@
{
"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.collab-proxy": "1.15.15",
"com.unity.editorcoroutines": "1.0.0",
"com.unity.ide.rider": "3.0.13",

View File

@ -1,5 +1,11 @@
{
"dependencies": {
"com.unity.2d.sprite": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.collab-proxy": {
"version": "1.15.15",
"depth": 0,