730 lines
31 KiB
C#
730 lines
31 KiB
C#
//#define Applyforalicense
|
|
|
|
using BrewMonster.Assets.PerfectWorld.Scripts.UI.GamePlay;
|
|
using BrewMonster.Network;
|
|
using BrewMonster.Scripts;
|
|
using BrewMonster.Scripts.Managers;
|
|
using BrewMonster.Scripts.Skills;
|
|
using BrewMonster.UI;
|
|
using CSNetwork.GPDataType;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
using UnityEngine.UI;
|
|
using static BrewMonster.PET_EGG_ESSENCE;
|
|
|
|
namespace BrewMonster
|
|
{
|
|
public class DlgAssignSlots : AUIDialog
|
|
{
|
|
//[SerializeField] List<Image> m_aSkillImage = new List<Image>();
|
|
//[SerializeField] List<Button> m_aSkillButton = new List<Button>();
|
|
public const int MAX_SKILL_GROUP = 4;
|
|
[SerializeField] List<AUIToggleAssignSlot> _actionSlots = new List<AUIToggleAssignSlot>();
|
|
[SerializeField] Toggle[] toggleGroup = new Toggle[MAX_SKILL_GROUP];
|
|
[SerializeField] Button acceptButton;
|
|
public int m_nCurPanel1 = 1;
|
|
public int m_nCurPanel2 = 1;
|
|
|
|
int currentListIndex = 0;
|
|
int currentOffsetIndex = 0;
|
|
int currentSelectedSlotIndex = -1;
|
|
CECSkill assignedSkill = null;
|
|
private int _pendingComboGroupIndex = -1;
|
|
private int _pendingActionSetIndex = -1;
|
|
private int _pendingActionShortcutIndex = -1;
|
|
private bool _subscribed;
|
|
/// <summary>
|
|
/// Apply for a license remove later
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
|
|
// public int m_nCurPanel1 = 1;
|
|
// public int m_nCurPanel2 = 1;
|
|
public bool m_bShowAll1 = false;
|
|
public bool m_bShowAll2 = false;
|
|
public int m_nDisplayPanels1 = 0;
|
|
public int m_nDisplayPanels2 = 0;
|
|
|
|
|
|
[ContextMenu("SwitchShowSkillShortcut")]
|
|
public void SwitchShowSkillShortcut(int panelIndex)
|
|
{
|
|
currentListIndex = panelIndex;
|
|
UpdateShortcuts();
|
|
}
|
|
|
|
public override void Awake()
|
|
{
|
|
SwitchShowSkillShortcut(0);
|
|
}
|
|
public override void OnEnable()
|
|
{
|
|
UnSubscribeEvents();
|
|
SubscribeEvents();
|
|
currentListIndex = 0;
|
|
CreateCacheData();
|
|
UpdateShortcuts();
|
|
}
|
|
public override void OnDisable()
|
|
{
|
|
UnSubscribeEvents();
|
|
}
|
|
public void OnDestroy()
|
|
{
|
|
UnSubscribeEvents();
|
|
}
|
|
private List<CECShortcutSet> a_pSCS = new List<CECShortcutSet>();
|
|
public bool CreateCacheData()
|
|
{
|
|
int nCurPanel9 = GetCurPanel1();
|
|
int nCurPanel8 = GetCurPanel2();
|
|
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
|
|
if (pHost == null)
|
|
return false;
|
|
a_pSCS = new List<CECShortcutSet>();
|
|
var a_pSCSTemp = new List<CECShortcutSet>();
|
|
var a_pszPanel = new List<string>();
|
|
GetQuickBarNameAndSC(pHost, a_pszPanel, a_pSCSTemp, nCurPanel9, nCurPanel8);
|
|
foreach (var item in a_pSCSTemp)
|
|
{
|
|
var temp = item.Clone();
|
|
a_pSCS.Add(temp);
|
|
}
|
|
return true;
|
|
}
|
|
public void CreateSkillShortcut()
|
|
{
|
|
ClearPendingActionAssign();
|
|
_pendingComboGroupIndex = -1;
|
|
// Debug.Log("HoangDev: CreateSkillShortcut: " + currentSelectedSlotIndex + " : " + assignedSkill.GetSkillID());
|
|
// CECShortcutSet pSCS = CECGameRun.Instance.GetHostPlayer().GetShortcutSet1(0);
|
|
|
|
a_pSCS[currentListIndex].CreateSkillShortcut(currentSelectedSlotIndex, assignedSkill);
|
|
EventBus.Publish(new OnAssignSkillEvent(assignedSkill.GetSkillID(), currentSelectedSlotIndex));
|
|
currentSelectedSlotIndex = -1;
|
|
assignedSkill = null;
|
|
}
|
|
|
|
private bool IsPendingComboAssign()
|
|
{
|
|
return _pendingComboGroupIndex >= 0;
|
|
}
|
|
|
|
private void ClearPendingComboAssign()
|
|
{
|
|
_pendingComboGroupIndex = -1;
|
|
}
|
|
|
|
private void CreateSkillGroupShortcut()
|
|
{
|
|
if (!IsPendingComboAssign() || currentSelectedSlotIndex < 0)
|
|
return;
|
|
if (a_pSCS == null || currentListIndex < 0 || currentListIndex >= a_pSCS.Count)
|
|
return;
|
|
|
|
if (!a_pSCS[currentListIndex].CreateSkillGroupShortcut(currentSelectedSlotIndex, _pendingComboGroupIndex))
|
|
{
|
|
BMLogger.LogError($"DlgAssignSlots::CreateSkillGroupShortcut failed groupIndex={_pendingComboGroupIndex} slot={currentSelectedSlotIndex}");
|
|
return;
|
|
}
|
|
|
|
int comboGroupIndex = _pendingComboGroupIndex;
|
|
EventBus.Publish(new OnAssignSkillEvent(-(comboGroupIndex + 1), currentSelectedSlotIndex));
|
|
currentSelectedSlotIndex = -1;
|
|
ClearPendingComboAssign();
|
|
assignedSkill = null;
|
|
ClearPendingActionAssign();
|
|
UpdateShortcuts();
|
|
}
|
|
|
|
private bool IsPendingActionAssign()
|
|
{
|
|
return _pendingActionSetIndex >= 0 && _pendingActionShortcutIndex >= 0;
|
|
}
|
|
|
|
private void ClearPendingActionAssign()
|
|
{
|
|
_pendingActionSetIndex = -1;
|
|
_pendingActionShortcutIndex = -1;
|
|
}
|
|
|
|
/// <summary>Resolves shortcut from CECGameRun command sets (same order as CDlgSkillSubAction).</summary>
|
|
public static CECShortcut GetActionPaletteShortcut(int setIndex, int indexInSet)
|
|
{
|
|
var run = CECGameRun.Instance;
|
|
if (run == null) return null;
|
|
CECShortcutSet set = setIndex switch
|
|
{
|
|
0 => run.GetGenCmdShortcuts(),
|
|
1 => run.GetTeamCmdShortcuts(),
|
|
2 => run.GetTradeCmdShortcuts(),
|
|
3 => run.GetPoseCmdShortcuts(),
|
|
_ => null
|
|
};
|
|
if (set == null || indexInSet < 0 || indexInSet >= set.GetShortcutNum())
|
|
return null;
|
|
return set.GetShortcut(indexInSet);
|
|
}
|
|
|
|
private void CreateActionShortcut()
|
|
{
|
|
if (!IsPendingActionAssign() || currentSelectedSlotIndex < 0)
|
|
return;
|
|
if (a_pSCS == null || currentListIndex < 0 || currentListIndex >= a_pSCS.Count)
|
|
return;
|
|
|
|
var src = GetActionPaletteShortcut(_pendingActionSetIndex, _pendingActionShortcutIndex);
|
|
if (src == null)
|
|
{
|
|
BMLogger.LogError("DlgAssignSlots::CreateActionShortcut: source shortcut null");
|
|
return;
|
|
}
|
|
var clone = src.Clone();
|
|
if (clone == null)
|
|
{
|
|
BMLogger.LogError("DlgAssignSlots::CreateActionShortcut: Clone() returned null");
|
|
return;
|
|
}
|
|
|
|
a_pSCS[currentListIndex].SetShortcut(currentSelectedSlotIndex, clone);
|
|
int slotIdx = currentSelectedSlotIndex;
|
|
int setIdx = _pendingActionSetIndex;
|
|
int scIdx = _pendingActionShortcutIndex;
|
|
EventBus.Publish(new OnAssignActionEvent(setIdx, scIdx, slotIdx));
|
|
currentSelectedSlotIndex = -1;
|
|
ClearPendingActionAssign();
|
|
ClearPendingComboAssign();
|
|
UpdateShortcuts();
|
|
}
|
|
public bool UpdateShortcuts()
|
|
{
|
|
CECShortcut pSC;
|
|
CECSCSkill pSCSkill;
|
|
AUIImagePictureBase pCell;
|
|
CECSkill pSkill = new CECSkill(-1, -1);
|
|
|
|
if (a_pSCS == null || a_pSCS.Count < 2)
|
|
return false;
|
|
|
|
if(currentListIndex >= a_pSCS.Count )
|
|
{
|
|
currentListIndex = 0;
|
|
}
|
|
|
|
// currentOffsetIndex = 0;
|
|
// for(int i = 0; i < currentListIndex; i++)
|
|
// {
|
|
// if(i == currentListIndex)
|
|
// {
|
|
// break;
|
|
// }
|
|
// currentOffsetIndex += a_pSCS[i].GetShortcutNum();
|
|
// }
|
|
int nSlots = Mathf.Min(a_pSCS[currentListIndex].GetShortcutNum(), _actionSlots.Count);
|
|
for (int j = 0; j < nSlots; j++)
|
|
{
|
|
pCell = _actionSlots[j];
|
|
pSkill = null;
|
|
pCell.SetSlotIndex(j);
|
|
if (pCell == null || !pCell.gameObject.activeInHierarchy)
|
|
continue;
|
|
pSC = a_pSCS[currentListIndex].GetShortcut(j);
|
|
if (pSC != null)
|
|
{
|
|
if (pSC.GetType() == (int)CECShortcut.ShortcutType.SCT_SKILL)
|
|
{
|
|
pSCSkill = (CECSCSkill)pSC;
|
|
pSkill = pSCSkill.GetSkill();
|
|
if (false/*m_bDelGoblinSkillSC && GNET::ElementSkill::IsGoblinSkill(pSkill->GetSkillID())*/)
|
|
{
|
|
/* a_pSCS[i]->SetShortcut(j, NULL);
|
|
pSC = NULL;*/
|
|
}
|
|
}
|
|
|
|
/*else if (pSC->GetType() == CECShortcut::SCT_ITEM)
|
|
{
|
|
iIconFile = CECGameUIMan::ICONS_INVENTORY;
|
|
pCell->SetColor(A3DCOLORRGB(255, 255, 255));
|
|
pSCItem = (CECSCItem*)pSC;
|
|
pIvtr = GetHostPlayer()->GetPack(pSCItem->GetInventory());
|
|
pItem = pIvtr->GetItem(pSCItem->GetIvtrSlot());
|
|
if (pItem && pItem->GetCoolTime(&nMax) > 0)
|
|
{
|
|
pClock->SetProgressRange(0, nMax);
|
|
pClock->SetProgressPos(nMax - pItem->GetCoolTime());
|
|
pClock->SetColor(A3DCOLORRGBA(0, 0, 0, 128));
|
|
}
|
|
if (pSCItem->GetInventory() == IVTRTYPE_EQUIPPACK)
|
|
pCell->SetColor(A3DCOLORRGBA(128, 128, 255, 128));
|
|
}
|
|
else if (pSC->GetType() == CECShortcut::SCT_PET)
|
|
{
|
|
pSCPet = (CECSCPet*)pSC;
|
|
CECPetData* pPet = pPetCorral->GetPetData(pSCPet->GetPetIndex());
|
|
iIconFile = CECGameUIMan::ICONS_INVENTORY;
|
|
pCell->SetColor(A3DCOLORRGB(255, 255, 255));
|
|
if (pPet)
|
|
{
|
|
// dead combat pet
|
|
if ((pPet->GetClass() == GP_PET_CLASS_COMBAT || pPet->GetClass() == GP_PET_CLASS_EVOLUTION) && pPet->GetHPFactor() == 0.0f)
|
|
{
|
|
pCell->SetColor(A3DCOLORRGB(128, 128, 128));
|
|
}
|
|
// current active pet
|
|
else if (pSCPet->IsActivePet())
|
|
{
|
|
pCell->SetColor(A3DCOLORRGB(255, 255, 0));
|
|
}
|
|
}
|
|
}
|
|
else if (pSC->GetType() == CECShortcut::SCT_AUTOFASHION)
|
|
{
|
|
iIconFile = CECGameUIMan::ICONS_SUITE;
|
|
fashionCoolTime = pHost->GetCoolTime(GP_CT_EQUIP_FASHION_ITEM, &fashionCoolTimeMax);
|
|
pCell->SetColor(A3DCOLORRGB(255, 255, 255));
|
|
if (fashionCoolTimeMax > 0)
|
|
{
|
|
pClock->SetProgressRange(0, fashionCoolTimeMax);
|
|
pClock->SetProgressPos(fashionCoolTimeMax - fashionCoolTime);
|
|
pClock->SetColor(A3DCOLORRGBA(0, 0, 0, 175));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
iIconFile = CECGameUIMan::ICONS_ACTION;
|
|
if (pSC->GetType() == CECShortcut::SCT_COMMAND)
|
|
{
|
|
CECSCCommand* pCommandSC = (CECSCCommand*)pSC;
|
|
if (GetHostPlayer()->IsInvisible())
|
|
{
|
|
if (pCommandSC->GetCommandID() == CECSCCommand::CMD_STARTTRADE ||
|
|
pCommandSC->GetCommandID() == CECSCCommand::CMD_SELLBOOTH ||
|
|
pCommandSC->GetCommandID() == CECSCCommand::CMD_BINDBUDDY)
|
|
{
|
|
pCell->SetColor(A3DCOLORRGB(128, 128, 128));
|
|
}
|
|
else
|
|
{
|
|
pCell->SetColor(A3DCOLORRGB(255, 255, 255));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pCell->SetColor(A3DCOLORRGB(255, 255, 255));
|
|
}
|
|
}
|
|
|
|
if (pSC->GetCoolTime(&nMax) > 0)
|
|
{
|
|
pClock->SetProgressRange(0, nMax);
|
|
pClock->SetProgressPos(nMax - pSC->GetCoolTime());
|
|
pClock->SetColor(A3DCOLORRGBA(0, 0, 0, 128));
|
|
}
|
|
}*/
|
|
else if (pSC.GetType() == (int)CECShortcut.ShortcutType.SCT_ITEM)
|
|
{
|
|
pCell.SetColor(new Color(1f, 1f, 1f));
|
|
CECSCItem pSCItem = (CECSCItem)pSC;
|
|
EC_Inventory pIvtr = EC_Game.GetGameRun().GetHostPlayer().GetPack(pSCItem.GetInventory());
|
|
EC_IvtrItem pItem = pIvtr?.GetItem(pSCItem.GetIvtrSlot());
|
|
|
|
//if (pSCItem.GetInventory == InventoryConst.IVTRTYPE_EQUIPPACK)
|
|
//{
|
|
// pCell.SetColor(new Color(128, 128, 255, 128));
|
|
//}
|
|
|
|
if (pItem != null)
|
|
{
|
|
string itemIcon = pItem.GetIconFile();
|
|
GetGameUIMan().SetCover(pCell, itemIcon, EC_GAMEUI_ICONS.ICONS_INVENTORY);
|
|
}
|
|
}
|
|
else if (pSC.GetType() == (int)CECShortcut.ShortcutType.SCT_AUTOFASHION)
|
|
{
|
|
pCell.SetColor(new Color(1f, 1f, 1f));
|
|
}
|
|
else
|
|
{
|
|
if (pSC.GetType() == (int)CECShortcut.ShortcutType.SCT_COMMAND)
|
|
{
|
|
CECSCCommand pCommandSC = (CECSCCommand)pSC;
|
|
if (EC_Game.GetGameRun().GetHostPlayer().IsInvisible())
|
|
{
|
|
if (pCommandSC.GetCommandID() == (int)CECSCCommand.CommandID.CMD_STARTTRADE ||
|
|
pCommandSC.GetCommandID() == (int)CECSCCommand.CommandID.CMD_SELLBOOTH ||
|
|
pCommandSC.GetCommandID() == (int)CECSCCommand.CommandID.CMD_BINDBUDDY)
|
|
{
|
|
pCell.SetColor(new Color(128, 128, 128, 255));
|
|
}
|
|
else
|
|
{
|
|
pCell.SetColor(new Color(1f, 1f, 1f));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pCell.SetColor(new Color(1f, 1f, 1f));
|
|
}
|
|
}
|
|
|
|
string cmdIcon = pSC.GetIconFile();
|
|
GetGameUIMan().SetCover(pCell, cmdIcon, EC_GAMEUI_ICONS.ICONS_ACTION);
|
|
}
|
|
|
|
|
|
if (pSC != null)
|
|
{
|
|
int scType = pSC.GetType();
|
|
bool isSkillGroupShortcut = scType == (int)CECShortcut.ShortcutType.SCT_SKILLGRP;
|
|
if (pCell.GetDataPtr() == pSC && !isSkillGroupShortcut)
|
|
{
|
|
continue;
|
|
}
|
|
pCell.SetDataPtr(pSC);
|
|
if (isSkillGroupShortcut)
|
|
{
|
|
EC_VIDEO_SETTING setting = EC_Game.GetConfigs().GetVideoSettings();
|
|
int groupIndex = ((CECSCSkillGrp)pSC).GetGroupIndex();
|
|
var groupIndexes = new List<int>();
|
|
if (setting.comboSkill != null)
|
|
{
|
|
if (groupIndex >= 0 && groupIndex < setting.comboSkill.Length)
|
|
{
|
|
groupIndexes.Add(groupIndex);
|
|
}
|
|
for (int idx = 0; idx < setting.comboSkill.Length; idx++)
|
|
{
|
|
if (setting.comboSkill[idx].nIcon > 0 && !groupIndexes.Contains(idx))
|
|
{
|
|
groupIndexes.Add(idx);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pCell is AUIToggleAssignSlot assignSlot)
|
|
{
|
|
assignSlot.SetSkillGroupIconsForAssign(groupIndexes, groupIndex);
|
|
}
|
|
else
|
|
{
|
|
if (groupIndexes.Count > 0)
|
|
{
|
|
GetGameUIMan().SetCover(pCell, AUIToggleAssignSlot.DefaultComboIcon, EC_GAMEUI_ICONS.ICONS_SKILLGRP);
|
|
}
|
|
else
|
|
{
|
|
pCell.Clear();
|
|
}
|
|
}
|
|
}
|
|
else if (pSC.GetType() == (int)CECShortcut.ShortcutType.SCT_COMMAND)
|
|
{
|
|
GetGameUIMan().SetCover(pCell, ((CECSCCommand)pSC).GetIconFile(), EC_GAMEUI_ICONS.ICONS_ACTION);
|
|
}
|
|
else
|
|
{
|
|
if (pSkill != null)
|
|
{
|
|
pCell.gameObject.SetActive(true);
|
|
//BMLogger.Log("HoangDev: QuickBar Set Skill Icon: " + (uint)pSkill.GetSkillID() + " : " + ElementSkill.GetIcon((uint)pSkill.GetSkillID()));
|
|
var nameskill = ElementSkill.GetIcon((uint)pSkill.GetSkillID());
|
|
var slot = GetGameUIMan().SetCover(pCell, nameskill, EC_GAMEUI_ICONS.ICONS_SKILL);
|
|
if (slot is AUIImagePicture picture)
|
|
{
|
|
picture.SetSkillId(pSkill.GetSkillID());
|
|
}
|
|
}
|
|
/* af_GetFileTitle(pSC->GetIconFile(), strFile);
|
|
strFile.MakeLower();
|
|
pCell->SetCover(GetGameUIMan()->m_pA2DSpriteIcons[iIconFile],
|
|
GetGameUIMan()->m_IconMap[iIconFile][strFile]); */
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pCell.Clear();
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
private void GetQuickBarNameAndSC(CECHostPlayer pHost, List<string> pszPanel, List<CECShortcutSet> pSCS, int panel9, int panel8)
|
|
{
|
|
string dlgName;
|
|
|
|
dlgName = $"Win_Quickbar{Shortcut.SIZE_HOSTSCSET1}Ha";
|
|
pszPanel.Add(dlgName);
|
|
|
|
for (int i = 0; i < (int)Shortcut.NUM_HOSTSCSETS1; i++)
|
|
{
|
|
dlgName = $"Win_Quickbar{(int)Shortcut.SIZE_HOSTSCSET1}Hb_{i + 1}";
|
|
pSCS?.Add(pHost.GetShortcutSet1(i));
|
|
pszPanel.Add(dlgName);
|
|
}
|
|
|
|
/*// ----- Quickbar 1 Vertical A -----
|
|
dlgName = $"Win_Quickbar{(int)Shortcut.SIZE_HOSTSCSET1}Va";
|
|
pszPanel.Add(dlgName);
|
|
|
|
for (int i = 0; i < (int)Shortcut.NUM_HOSTSCSETS1; i++)
|
|
{
|
|
dlgName = $"Win_Quickbar{(int)Shortcut.SIZE_HOSTSCSET1}Vb_{i + 1}";
|
|
pSCS?.Add(pHost.GetShortcutSet1(i));
|
|
pszPanel.Add(dlgName);
|
|
}*/
|
|
|
|
// ----- Quickbar 2 Horizontal A -----
|
|
dlgName = $"Win_Quickbar{(int)Shortcut.SIZE_HOSTSCSET2}Ha";
|
|
pszPanel.Add(dlgName);
|
|
|
|
for (int i = 0; i < (int)Shortcut.NUM_HOSTSCSETS2; i++)
|
|
{
|
|
dlgName = $"Win_Quickbar{(int)Shortcut.SIZE_HOSTSCSET2}Hb_{i + 1}";
|
|
pSCS?.Add(pHost.GetShortcutSet2(i));
|
|
pszPanel.Add(dlgName);
|
|
}
|
|
|
|
/* // ----- Quickbar 2 Vertical A -----
|
|
dlgName = $"Win_Quickbar{(int)Shortcut.SIZE_HOSTSCSET2}Va";
|
|
pszPanel.Add(dlgName);
|
|
|
|
for (int i = 0; i < (int)Shortcut.NUM_HOSTSCSETS2; i++)
|
|
{
|
|
dlgName = $"Win_Quickbar{(int)Shortcut.SIZE_HOSTSCSET2}Vb_{i + 1}";
|
|
pSCS?.Add(pHost.GetShortcutSet2(i));
|
|
pszPanel.Add(dlgName);
|
|
}*/
|
|
}
|
|
|
|
public int GetCurPanel1()
|
|
{
|
|
return m_nCurPanel1;
|
|
}
|
|
public int GetCurPanel2()
|
|
{
|
|
return m_nCurPanel2;
|
|
}
|
|
|
|
public void OnAssignSkillSelectionChanged(AssignSkillSelectionChangedEvent obj)
|
|
{
|
|
if (obj.selected)
|
|
{
|
|
if (obj.skillID < 0)
|
|
{
|
|
// Combo group is encoded as -(groupIndex + 1).
|
|
_pendingComboGroupIndex = -obj.skillID - 1;
|
|
assignedSkill = null;
|
|
ClearPendingActionAssign();
|
|
if (currentSelectedSlotIndex != -1)
|
|
{
|
|
CreateSkillGroupShortcut();
|
|
}
|
|
return;
|
|
}
|
|
|
|
ClearPendingComboAssign();
|
|
ClearPendingActionAssign();
|
|
assignedSkill = CECGameRun.Instance.GetHostPlayer().GetPositiveSkillByID(obj.skillID);
|
|
if (currentSelectedSlotIndex != -1)
|
|
{
|
|
CreateSkillShortcut();
|
|
Debug.Log($"HoangDev: OnAssignSkillSelectionChanged: AfterCreateSkillShortcut: assignedSkillIsNull={(assignedSkill == null)} slotIndex={currentSelectedSlotIndex}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
assignedSkill = null;
|
|
ClearPendingComboAssign();
|
|
}
|
|
}
|
|
|
|
public void OnAssignActionSelectionChanged(AssignActionSelectionChangedEvent obj)
|
|
{
|
|
if (obj.selected)
|
|
{
|
|
assignedSkill = null;
|
|
ClearPendingComboAssign();
|
|
_pendingActionSetIndex = obj.actionSetIndex;
|
|
_pendingActionShortcutIndex = obj.shortcutIndexInSet;
|
|
if (currentSelectedSlotIndex != -1)
|
|
CreateActionShortcut();
|
|
}
|
|
else
|
|
{
|
|
ClearPendingActionAssign();
|
|
}
|
|
}
|
|
|
|
private void OnAssignSkillCommitted(OnAssignSkillEvent e)
|
|
{
|
|
foreach (var slot in _actionSlots)
|
|
{
|
|
if (slot == null) continue;
|
|
if (slot.GetSlotIndexForAssign() != e.slotIndex) continue;
|
|
if (e.skillID < 0)
|
|
{
|
|
int comboGroupIndex = -e.skillID - 1;
|
|
EC_VIDEO_SETTING? setting = EC_Game.GetConfigs()?.GetVideoSettings();
|
|
int nIcon = 0;
|
|
if (setting.HasValue && setting.Value.comboSkill != null &&
|
|
comboGroupIndex >= 0 && comboGroupIndex < setting.Value.comboSkill.Length)
|
|
{
|
|
nIcon = setting.Value.comboSkill[comboGroupIndex].nIcon;
|
|
}
|
|
slot.SetSkillGroupIconForAssign(comboGroupIndex, nIcon);
|
|
slot.UncheckAfterAssign();
|
|
return;
|
|
}
|
|
var host = CECGameRun.Instance.GetHostPlayer();
|
|
if (host == null) return;
|
|
var processSkill = host.GetPositiveSkillByID(e.skillID);
|
|
if (processSkill == null) return;
|
|
var slotSkill = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan().SetCover(slot, processSkill.GetIconFile(), EC_GAMEUI_ICONS.ICONS_SKILL);
|
|
if (slotSkill is AUIImagePicture picture)
|
|
{
|
|
picture.SetSkillId(e.skillID);
|
|
}
|
|
slot.UncheckAfterAssign();
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void OnAssignActionCommitted(OnAssignActionEvent e)
|
|
{
|
|
if (a_pSCS == null || currentListIndex < 0 || currentListIndex >= a_pSCS.Count)
|
|
return;
|
|
var sc = a_pSCS[currentListIndex].GetShortcut(e.quickbarSlotIndex);
|
|
foreach (var slot in _actionSlots)
|
|
{
|
|
if (slot == null) continue;
|
|
if (slot.GetSlotIndexForAssign() != e.quickbarSlotIndex) continue;
|
|
if (sc != null)
|
|
EC_Game.GetGameRun().GetUIManager().GetInGameUIMan().SetCover(slot, sc.GetIconFile(), EC_GAMEUI_ICONS.ICONS_ACTION);
|
|
slot.UncheckAfterAssign();
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void UnSubscribeEvents()
|
|
{
|
|
acceptButton.onClick.RemoveListener(AcceptSkillChange);
|
|
EventBus.Unsubscribe<AssignSkillSelectionChangedEvent>(OnAssignSkillSelectionChanged);
|
|
EventBus.Unsubscribe<AssignActionSelectionChangedEvent>(OnAssignActionSelectionChanged);
|
|
EventBus.Unsubscribe<OnAssignSkillEvent>(OnAssignSkillCommitted);
|
|
EventBus.Unsubscribe<OnAssignActionEvent>(OnAssignActionCommitted);
|
|
for(int i = 0; i < MAX_SKILL_GROUP; i++)
|
|
{
|
|
toggleGroup[i].onValueChanged.RemoveAllListeners();
|
|
}
|
|
foreach (var auiToggle in _actionSlots)
|
|
{
|
|
auiToggle.OnSetSlot -= OnClickedAssignSlot;
|
|
}
|
|
}
|
|
private void SubscribeEvents()
|
|
{
|
|
acceptButton.onClick.AddListener(AcceptSkillChange);
|
|
EventBus.Subscribe<AssignSkillSelectionChangedEvent>(OnAssignSkillSelectionChanged);
|
|
EventBus.Subscribe<AssignActionSelectionChangedEvent>(OnAssignActionSelectionChanged);
|
|
EventBus.Subscribe<OnAssignSkillEvent>(OnAssignSkillCommitted);
|
|
EventBus.Subscribe<OnAssignActionEvent>(OnAssignActionCommitted);
|
|
for(int i = 0; i < MAX_SKILL_GROUP; i++)
|
|
{
|
|
int capturedIndex = i; // avoid closure capturing loop variable
|
|
if (toggleGroup[capturedIndex] == null) continue;
|
|
toggleGroup[capturedIndex].onValueChanged.AddListener((bool value) => OnToggleSkillGroupChanged(capturedIndex, value));
|
|
}
|
|
|
|
foreach (var auiToggle in _actionSlots)
|
|
{
|
|
auiToggle.OnSetSlot += OnClickedAssignSlot;
|
|
}
|
|
}
|
|
|
|
private void OnClickedAssignSlot(bool isActive, int slotIndex)
|
|
{
|
|
if (isActive)
|
|
{
|
|
currentSelectedSlotIndex = slotIndex;
|
|
if (assignedSkill != null)
|
|
{
|
|
CreateSkillShortcut();
|
|
}
|
|
else if (IsPendingComboAssign())
|
|
{
|
|
CreateSkillGroupShortcut();
|
|
}
|
|
else if (IsPendingActionAssign())
|
|
{
|
|
CreateActionShortcut();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
currentSelectedSlotIndex = -1;
|
|
}
|
|
}
|
|
|
|
private void OnToggleSkillGroupChanged(int index, bool value)
|
|
{
|
|
if (index < 0 || index >= MAX_SKILL_GROUP) return;
|
|
if(value)
|
|
{
|
|
SwitchShowSkillShortcut(index);
|
|
}
|
|
}
|
|
public void AcceptSkillChange()
|
|
{
|
|
int nCurPanel9 = GetCurPanel1();
|
|
int nCurPanel8 = GetCurPanel2();
|
|
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
|
|
if (pHost == null) return;
|
|
var real_pSCS = new List<CECShortcutSet>();
|
|
var a_pszPanel = new List<string>();
|
|
GetQuickBarNameAndSC(pHost, a_pszPanel, real_pSCS, nCurPanel9, nCurPanel8);
|
|
if (a_pSCS == null || a_pSCS.Count == 0 || real_pSCS == null || real_pSCS.Count == 0)
|
|
return;
|
|
|
|
int setCount = Mathf.Min(a_pSCS.Count, real_pSCS.Count);
|
|
for (int i = 0; i < setCount; i++)
|
|
{
|
|
CECShortcutSet cachedSet = a_pSCS[i];
|
|
CECShortcutSet realSet = real_pSCS[i];
|
|
if (cachedSet == null || realSet == null)
|
|
continue;
|
|
|
|
int slotCount = Mathf.Min(cachedSet.GetShortcutNum(), realSet.GetShortcutNum());
|
|
for (int j = 0; j < slotCount; j++)
|
|
{
|
|
CECShortcut cachedSC = cachedSet.GetShortcut(j);
|
|
if (cachedSC == null)
|
|
{
|
|
realSet.SetShortcut(j, null);
|
|
continue;
|
|
}
|
|
|
|
if (cachedSC.GetType() == (int)CECShortcut.ShortcutType.SCT_SKILL)
|
|
{
|
|
CECSkill skill = (cachedSC as CECSCSkill)?.GetSkill();
|
|
if (skill != null)
|
|
realSet.CreateSkillShortcut(j, skill);
|
|
else
|
|
realSet.SetShortcut(j, null);
|
|
}
|
|
else
|
|
{
|
|
// Mirror cached shortcut as-is (including null), for non-skill types.
|
|
realSet.SetShortcut(j, cachedSC);
|
|
}
|
|
}
|
|
}
|
|
|
|
EC_Game.GetGameRun().SaveConfigsToServer();
|
|
CECUIManager.Instance?.UpdateSkillRelatedUI();
|
|
}
|
|
}
|
|
}
|