forked from sin365/AxibugEmuOnline
触屏虚拟按键 按照平台切换样式布局(包括XMB)
This commit is contained in:
parent
1675628a3e
commit
f044fb6b97
File diff suppressed because it is too large
Load Diff
@ -33,6 +33,14 @@ namespace AxiInputSP.UGUI
|
|||||||
return m_state == AxiButtonState.KeyDown;
|
return m_state == AxiButtonState.KeyDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重设键值(如按钮重新隐藏之后)
|
||||||
|
/// </summary>
|
||||||
|
public void ResetKeyState()
|
||||||
|
{
|
||||||
|
m_state = AxiButtonState.None;
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnPointerDown(PointerEventData eventData)
|
public override void OnPointerDown(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
base.OnPointerDown(eventData);
|
base.OnPointerDown(eventData);
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using AxibugEmuOnline.Client;
|
||||||
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
|
using AxibugEmuOnline.Client.Event;
|
||||||
|
using AxibugProtobuf;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AxiInputSP.UGUI
|
namespace AxiInputSP.UGUI
|
||||||
@ -16,6 +21,16 @@ namespace AxiInputSP.UGUI
|
|||||||
HashSet<AxiInputUGuiBtnType> m_pressBtns = new HashSet<AxiInputUGuiBtnType>();
|
HashSet<AxiInputUGuiBtnType> m_pressBtns = new HashSet<AxiInputUGuiBtnType>();
|
||||||
Vector2 m_joyStickRaw;
|
Vector2 m_joyStickRaw;
|
||||||
|
|
||||||
|
public Transform tfXMB;
|
||||||
|
public Transform tfNES;
|
||||||
|
public Transform tfGLOBAL;
|
||||||
|
public Transform tfMAME;
|
||||||
|
public Transform tfMAME_NEOGEO;
|
||||||
|
public Transform tfGAMEBOYCOLOR;
|
||||||
|
public Transform tfMASTERSYSTEM;
|
||||||
|
List<Transform> mPlatfromList = new List<Transform>();
|
||||||
|
|
||||||
|
|
||||||
public bool GetKey(AxiInputUGuiBtnType btnType)
|
public bool GetKey(AxiInputUGuiBtnType btnType)
|
||||||
{
|
{
|
||||||
return m_pressBtns.Contains(btnType);
|
return m_pressBtns.Contains(btnType);
|
||||||
@ -44,19 +59,97 @@ namespace AxiInputSP.UGUI
|
|||||||
{
|
{
|
||||||
m_buttons = GetComponentsInChildren<AxiIptButton>(true);
|
m_buttons = GetComponentsInChildren<AxiIptButton>(true);
|
||||||
m_joystick = GetComponentInChildren<FloatingJoystick>(true);
|
m_joystick = GetComponentInChildren<FloatingJoystick>(true);
|
||||||
|
|
||||||
|
mPlatfromList.Add(tfXMB);
|
||||||
|
mPlatfromList.Add(tfNES);
|
||||||
|
mPlatfromList.Add(tfGLOBAL);
|
||||||
|
mPlatfromList.Add(tfMAME);
|
||||||
|
mPlatfromList.Add(tfMAME_NEOGEO);
|
||||||
|
mPlatfromList.Add(tfGAMEBOYCOLOR);
|
||||||
|
mPlatfromList.Add(tfMASTERSYSTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
m_joyStickRaw = Vector2.zero;
|
m_joyStickRaw = Vector2.zero;
|
||||||
m_pressBtns.Clear();
|
m_pressBtns.Clear();
|
||||||
|
|
||||||
OnGamepadActive?.Invoke(this);
|
OnGamepadActive?.Invoke(this);
|
||||||
|
ChangePlatfrom();
|
||||||
|
Eventer.Instance.RegisterEvent(EEvent.OnScreenGamepadPlatformTypeChanged, OnRomPlatformTypeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
OnGamepadDisactive?.Invoke(this);
|
OnGamepadDisactive?.Invoke(this);
|
||||||
|
Eventer.Instance.UnregisterEvent(EEvent.OnScreenGamepadPlatformTypeChanged, OnRomPlatformTypeChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRomPlatformTypeChanged()
|
||||||
|
{
|
||||||
|
App.log.Debug(">>OnRomPlatformTypeChanged");
|
||||||
|
ChangePlatfrom();
|
||||||
|
}
|
||||||
|
|
||||||
|
RomPlatformType? _last_platformType = RomPlatformType.Invalid;
|
||||||
|
void ChangePlatfrom()
|
||||||
|
{
|
||||||
|
RomPlatformType? platformType;
|
||||||
|
//XMB
|
||||||
|
if (App.emu.Core == null || CommandDispatcher.Instance.Mode == CommandListener.ScheduleType.Normal)
|
||||||
|
platformType = null;
|
||||||
|
else
|
||||||
|
platformType = App.emu.Core.Platform;
|
||||||
|
|
||||||
|
if (_last_platformType == platformType)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_last_platformType = platformType;
|
||||||
|
|
||||||
|
//先全部关闭
|
||||||
|
foreach (var trans in mPlatfromList)
|
||||||
|
trans.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
//切换时,重置所有键值,避免如按钮隐藏时候 OnPointerUp 未触发等问题
|
||||||
|
foreach (var btn in m_buttons)
|
||||||
|
btn.ResetKeyState();
|
||||||
|
|
||||||
|
//开启指定平台
|
||||||
|
GetPlatfromPanel(platformType).gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform GetPlatfromPanel(RomPlatformType? platformType)
|
||||||
|
{
|
||||||
|
if (!platformType.HasValue)
|
||||||
|
return tfXMB;
|
||||||
|
|
||||||
|
switch (platformType)
|
||||||
|
{
|
||||||
|
case RomPlatformType.Nes:
|
||||||
|
return tfNES;
|
||||||
|
case RomPlatformType.Neogeo:
|
||||||
|
return tfMAME_NEOGEO;
|
||||||
|
case RomPlatformType.Igs:
|
||||||
|
case RomPlatformType.Cps1:
|
||||||
|
case RomPlatformType.Cps2:
|
||||||
|
return tfMAME;
|
||||||
|
case RomPlatformType.MasterSystem:
|
||||||
|
return tfMASTERSYSTEM;
|
||||||
|
case RomPlatformType.GameBoy:
|
||||||
|
case RomPlatformType.GameBoyColor:
|
||||||
|
return tfGAMEBOYCOLOR;
|
||||||
|
case RomPlatformType.GameGear:
|
||||||
|
case RomPlatformType.ColecoVision:
|
||||||
|
case RomPlatformType.Sc3000:
|
||||||
|
case RomPlatformType.Sg1000:
|
||||||
|
case RomPlatformType.ArcadeOld:
|
||||||
|
case RomPlatformType.WonderSwan:
|
||||||
|
case RomPlatformType.WonderSwanColor:
|
||||||
|
case RomPlatformType.Invalid:
|
||||||
|
case RomPlatformType.All:
|
||||||
|
default:
|
||||||
|
return tfGLOBAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,5 +96,10 @@
|
|||||||
/// 核心开始游戏
|
/// 核心开始游戏
|
||||||
/// </summary>
|
/// </summary>
|
||||||
OnEmuBeginGame,
|
OnEmuBeginGame,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 平台切换
|
||||||
|
/// </summary>
|
||||||
|
OnScreenGamepadPlatformTypeChanged
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,6 +131,7 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
LaunchUI.Instance.ShowMainMenu();
|
LaunchUI.Instance.ShowMainMenu();
|
||||||
m_controllerSetuper = null;
|
m_controllerSetuper = null;
|
||||||
Eventer.Instance.UnregisterEvent(EEvent.OnRoomSlotDataChanged, OnSlotDataChanged);
|
Eventer.Instance.UnregisterEvent(EEvent.OnRoomSlotDataChanged, OnSlotDataChanged);
|
||||||
|
Eventer.Instance.PostEvent(EEvent.OnScreenGamepadPlatformTypeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetGame()
|
public void ResetGame()
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using AxibugEmuOnline.Client.Event;
|
||||||
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
@ -76,6 +77,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
if (m_waitMapperSetting != null)
|
if (m_waitMapperSetting != null)
|
||||||
{
|
{
|
||||||
m_listener.Schedule = m_waitMapperSetting.Value;
|
m_listener.Schedule = m_waitMapperSetting.Value;
|
||||||
|
Eventer.Instance.PostEvent(EEvent.OnScreenGamepadPlatformTypeChanged);
|
||||||
m_waitMapperSetting = null;
|
m_waitMapperSetting = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
|
using AxibugEmuOnline.Client.Event;
|
||||||
using AxibugEmuOnline.Client.UI;
|
using AxibugEmuOnline.Client.UI;
|
||||||
using Coffee.UIExtensions;
|
using Coffee.UIExtensions;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
@ -50,8 +51,10 @@ namespace AxibugEmuOnline.Client
|
|||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (CommandDispatcher.Instance.Mode == CommandListener.ScheduleType.Gaming && App.emu.Core == null)
|
if (CommandDispatcher.Instance.Mode == CommandListener.ScheduleType.Gaming && App.emu.Core == null)
|
||||||
|
{
|
||||||
CommandDispatcher.Instance.Mode = CommandListener.ScheduleType.Normal;
|
CommandDispatcher.Instance.Mode = CommandListener.ScheduleType.Normal;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void HideMainMenu()
|
public void HideMainMenu()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
|
using AxibugEmuOnline.Client.Event;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using DG.Tweening.Core;
|
using DG.Tweening.Core;
|
||||||
using DG.Tweening.Plugins.Options;
|
using DG.Tweening.Plugins.Options;
|
||||||
|
|||||||
@ -17,7 +17,6 @@ namespace AxibugEmuOnline.Client
|
|||||||
m_itemTemplate.gameObject.SetActiveEx(false);
|
m_itemTemplate.gameObject.SetActiveEx(false);
|
||||||
m_runtimeItems.Add(m_itemTemplate);
|
m_runtimeItems.Add(m_itemTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Pop(string msg)
|
public void Pop(string msg)
|
||||||
{
|
{
|
||||||
PopTipsItem item = GetPopItem();
|
PopTipsItem item = GetPopItem();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user