457 lines
22 KiB
C#
457 lines
22 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.UI;
|
|
using static BrewMonster.PET_EGG_ESSENCE;
|
|
|
|
namespace BrewMonster
|
|
{
|
|
public class CDlgQuickBar : AUIDialog
|
|
{
|
|
//[SerializeField] List<Image> m_aSkillImage = new List<Image>();
|
|
//[SerializeField] List<Button> m_aSkillButton = new List<Button>();
|
|
[SerializeField] List<AUIImagePicture> AUIImagePictureList = new List<AUIImagePicture>();
|
|
public int m_nCurPanel1 = 1;
|
|
public int m_nCurPanel2 = 1;
|
|
|
|
/// <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;
|
|
|
|
|
|
public bool UpdateShortcuts()
|
|
{
|
|
CECShortcut pSC;
|
|
CECSCSkill pSCSkill;
|
|
AUIImagePicture pCell;
|
|
CECSkill pSkill = new CECSkill(-1, -1);
|
|
AUIClockIcon pClock;
|
|
int iIconFile, nMax = 0;
|
|
|
|
int nCurPanel9 = GetCurPanel1();
|
|
int nCurPanel8 = GetCurPanel2();
|
|
|
|
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
|
|
if (pHost == null) return false;
|
|
var a_pSCS = new List<CECShortcutSet>();
|
|
var a_pszPanel = new List<string>();
|
|
GetQuickBarNameAndSC(pHost, a_pszPanel, a_pSCS, nCurPanel9, nCurPanel8);
|
|
if (a_pSCS == null || a_pSCS.Count < 2)
|
|
return false;
|
|
|
|
for (int i = 0; i <= 1/*(int)a_pSCS.Count*/; i++)
|
|
{
|
|
if (a_pSCS[i] == null)
|
|
continue;
|
|
|
|
//*//*CDlgQuickBar* pQuickBar = dynamic_cast<CDlgQuickBar*>(GetGameUIMan()->GetDialog(a_pszPanel[i]));
|
|
//if (!pQuickBar || !pQuickBar->IsShow()) continue;*//*
|
|
#if LICENSE_VERSION
|
|
|
|
int slotIndex = 0;
|
|
#endif
|
|
|
|
#if LICENSE_VERSION
|
|
|
|
for (int j = 0; j < a_pSCS.Count; j++)
|
|
{
|
|
#else
|
|
int nSlots = Mathf.Min(a_pSCS[i].GetShortcutNum(), AUIImagePictureList.Count);
|
|
for (int j = 0; j < nSlots; j++)
|
|
{
|
|
#endif
|
|
#if LICENSE_VERSION
|
|
if (slotIndex >= AUIImagePictureList.Count) break;
|
|
pCell = AUIImagePictureList[slotIndex];
|
|
#else
|
|
pCell = AUIImagePictureList[j];
|
|
#endif
|
|
if (pCell == null || !pCell.gameObject.activeInHierarchy) continue;
|
|
pSC = a_pSCS[i].GetShortcut(j);
|
|
pClock = pCell.GetClockIcon();
|
|
pClock.SetProgressRange(0, 1);
|
|
pClock.SetProgressPos(1);
|
|
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 (pSkill != null && pSkill.ReadyToCast() && pHost.GetPrepSkill() != pSkill)
|
|
{
|
|
if (ElementSkill.IsGoblinSkill((uint)pSkill.GetSkillID()))
|
|
{
|
|
/* if (pHostGoblin && !pHostGoblin->CheckSkillCastCondition(pSkill))
|
|
{
|
|
pCell->SetColor(A3DCOLORRGB(255, 255, 255));
|
|
}
|
|
else
|
|
{
|
|
pCell->SetColor(A3DCOLORRGB(128, 128, 128));
|
|
}*/
|
|
}
|
|
else
|
|
{
|
|
if (pHost.CheckSkillCastCondition(pSkill) == 0)
|
|
{
|
|
//BMLogger.LogError("HoangDev: QuickBar Skill Not Interact: " + (uint)pSkill.GetSkillID() + " : " + ElementSkill.GetIcon((uint)pSkill.GetSkillID()));
|
|
pCell.SetInteract(true);
|
|
}
|
|
else
|
|
{
|
|
//BMLogger.LogError("HoangDev: QuickBar Skill Interact: " + (uint)pSkill.GetSkillID() + " : " + ElementSkill.GetIcon((uint)pSkill.GetSkillID()));
|
|
pCell.SetInteract(false);
|
|
}
|
|
}
|
|
}
|
|
/*else
|
|
pClock.SetColor(A3DCOLORRGBA(0, 0, 0, 128));*/
|
|
if (pSkill != null && (pSkill.GetCoolingTime() > 0 ||
|
|
pHost.GetPrepSkill() == pSkill))
|
|
{
|
|
pClock.SetProgressRange(0, pSkill.GetCoolingTime());
|
|
if (pHost.GetPrepSkill() == pSkill)
|
|
{
|
|
pClock.SetProgressPos(0);
|
|
}
|
|
else
|
|
{
|
|
//BMLogger.LogError("HoangDev: QuickBar Skill CoolTime: " + (uint)pSkill.GetSkillID() + " : " + ElementSkill.GetIcon((uint)pSkill.GetSkillID()) + " CoolTime: " + pSkill.GetCoolingTime() + " CoolCnt: " + pSkill.GetCoolingCnt());
|
|
pClock.SetProgressPos(pSkill.GetCoolingTime() - pSkill.GetCoolingCnt());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/*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)
|
|
{
|
|
iIconFile = (int)EC_GAMEUI_ICONS.ICONS_INVENTORY;
|
|
pCell.SetColor(new Color(1f, 1f, 1f));
|
|
CECSCItem pSCItem = (CECSCItem)pSC;
|
|
EC_Inventory pIvtr = pHost.GetPack(pSCItem.GetInventory());
|
|
EC_IvtrItem pItem = pIvtr?.GetItem(pSCItem.GetIvtrSlot());
|
|
|
|
if (pItem != null)
|
|
{
|
|
int maxNullable = -1;
|
|
int coolTime = pItem.GetCoolTime(out maxNullable);
|
|
nMax = maxNullable > 0 ? maxNullable : 0;
|
|
|
|
if (coolTime > 0)
|
|
{
|
|
pClock.SetProgressRange(0, nMax);
|
|
pClock.SetProgressPos(nMax - coolTime);
|
|
pClock.SetColor(new Color32(0, 0, 0, 128));
|
|
}
|
|
}
|
|
|
|
//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_PET)
|
|
//{
|
|
// // Pet shortcut handling
|
|
// CECSCPet pSCPet = (CECSCPet)pSC;
|
|
// EC_PetCorral pPetCorral = pHost.GetPetCorral();
|
|
// CECPetData pPet = pPetCorral?.GetPetData(pSCPet.GetPetIndex());
|
|
|
|
// iIconFile = (int)EC_GAMEUI_ICONS.ICONS_INVENTORY;
|
|
// //pCell.SetColor(new Color(1f, 1f, 1f)); // RGB(255, 255, 255)
|
|
|
|
// if (pPet != null)
|
|
// {
|
|
// // Dead combat pet - grayscale
|
|
// if ((pPet.GetClass() == (int)PetClass.GP_PET_CLASS_COMBAT ||
|
|
// pPet.GetClass() == (int)PetClass.GP_PET_CLASS_EVOLUTION) &&
|
|
// pPet.GetHPFactor() == 0.0f)
|
|
// {
|
|
// //pCell.SetColor(new Color32(128, 128, 128, 255));
|
|
// }
|
|
// // Current active pet - yellow highlight
|
|
// else if (pSCPet.IsActivePet())
|
|
// {
|
|
// //pCell.SetColor(new Color32(255, 255, 0, 255));
|
|
// }
|
|
// }
|
|
|
|
// // Set pet icon
|
|
// if (pPet != null)
|
|
// {
|
|
// slotIndex++;
|
|
// string petIcon = pSCPet.GetIconFile();
|
|
// GetGameUIMan().SetCover(pCell, petIcon, EC_GAMEUI_ICONS.ICONS_INVENTORY);
|
|
// }
|
|
//}
|
|
else if (pSC.GetType() == (int)CECShortcut.ShortcutType.SCT_AUTOFASHION)
|
|
{
|
|
iIconFile = (int)EC_GAMEUI_ICONS.ICONS_SUITE;
|
|
|
|
int fashionCoolTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_EQUIP_FASHION_ITEM, out int fashionCoolTimeMax);
|
|
pCell.SetColor(new Color(1f, 1f, 1f));
|
|
|
|
if (fashionCoolTimeMax > 0)
|
|
{
|
|
pClock.SetProgressRange(0, fashionCoolTimeMax);
|
|
pClock.SetProgressPos(fashionCoolTimeMax - fashionCoolTime);
|
|
pClock.SetColor(new Color32(0, 0, 0, 175));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
iIconFile = (int)EC_GAMEUI_ICONS.ICONS_ACTION;
|
|
if (pSC.GetType() == (int)CECShortcut.ShortcutType.SCT_COMMAND)
|
|
{
|
|
CECSCCommand pCommandSC = (CECSCCommand)pSC;
|
|
if (pHost.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));
|
|
}
|
|
}
|
|
nMax = 0;
|
|
int cmdCoolTime = pSC.GetCoolTime(ref nMax);
|
|
if (cmdCoolTime > 0)
|
|
{
|
|
pClock.SetProgressRange(0, nMax);
|
|
pClock.SetProgressPos(nMax - cmdCoolTime);
|
|
pClock.SetColor(new Color32(0, 0, 0, 128));
|
|
}
|
|
|
|
string cmdIcon = pSC.GetIconFile();
|
|
GetGameUIMan().SetCover(pCell, cmdIcon, EC_GAMEUI_ICONS.ICONS_ACTION);
|
|
}
|
|
|
|
|
|
if (pSC != null)
|
|
{
|
|
#if LICENSE_VERSION
|
|
slotIndex++;
|
|
#endif
|
|
if (pCell.GetDataPtr() == pSC)
|
|
{
|
|
continue;
|
|
}
|
|
pCell.SetDataPtr(pSC);
|
|
if (pSC.GetType() == (int)CECShortcut.ShortcutType.SCT_SKILLGRP)
|
|
{
|
|
EC_VIDEO_SETTING setting = EC_Game.GetConfigs().GetVideoSettings();
|
|
/* pCell.SetCover(GetGameUIMan()->m_pA2DSpriteIcons[CECGameUIMan::ICONS_SKILLGRP],
|
|
setting.comboSkill[((CECSCSkillGrp)pSC).GetGroupIndex()].nIcon + 1);
|
|
setting.comboSkill[((CECSCSkillGrp)pSC).GetGroupIndex()].nIcon + 1;*/
|
|
// fix later now haven't skill group icon yet
|
|
GetGameUIMan().SetCover(pCell, "unknown", EC_GAMEUI_ICONS.ICONS_SKILL);
|
|
}
|
|
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());
|
|
GetGameUIMan().SetCover(pCell, nameskill, EC_GAMEUI_ICONS.ICONS_SKILL);
|
|
}
|
|
/* af_GetFileTitle(pSC->GetIconFile(), strFile);
|
|
strFile.MakeLower();
|
|
pCell->SetCover(GetGameUIMan()->m_pA2DSpriteIcons[iIconFile],
|
|
GetGameUIMan()->m_IconMap[iIconFile][strFile]); */
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
/* pCell->SetCover(NULL, -1);
|
|
pCell->SetText(_AL(""));
|
|
pCell->SetDataPtr(NULL);
|
|
pCell->SetColor(A3DCOLORRGB(255, 255, 255)); */
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
private void GetQuickBarNameAndSC(CECHostPlayer pHost, List<string> pszPanel, List<CECShortcutSet> pSCS, int panel9, int panel8)
|
|
{
|
|
string dlgName;
|
|
|
|
// ----- Quickbar 1 Horizontal A -----
|
|
dlgName = $"Win_Quickbar{Shortcut.SIZE_HOSTSCSET1}Ha";
|
|
pSCS?.Add(pHost.GetShortcutSet1(panel9 - 1));
|
|
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";
|
|
pSCS?.Add(pHost.GetShortcutSet1(panel9 - 1));
|
|
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";
|
|
pSCS?.Add(pHost.GetShortcutSet2(panel8 - 1));
|
|
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";
|
|
pSCS?.Add(pHost.GetShortcutSet2(panel8 - 1));
|
|
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;
|
|
}
|
|
|
|
}
|
|
}
|