Files
test/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs
T
2026-04-06 13:39:39 +07:00

3985 lines
191 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using BrewMonster.Assets.PerfectWorld.Scripts.UI;
using BrewMonster.Common;
using BrewMonster.Managers;
using BrewMonster.Network;
using BrewMonster.Scripts;
using BrewMonster.Scripts.Task;
using CSNetwork;
using CSNetwork.Common;
using CSNetwork.GPDataType;
using ModelRenderer.Scripts.Common;
using ModelRenderer.Scripts.GameData;
using PerfectWorld.Scripts.Task;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using BrewMonster.Scripts.UI;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using static CSNetwork.Common.ExpTypes;
namespace BrewMonster.UI
{
public class DlgNPC : AUIDialog
{
[SerializeField] private TextMeshProUGUI m_pTxt_npc;
[SerializeField] private TextMeshProUGUI m_pTxt_Content;
[SerializeField] private AUIListBox m_pLst_Main;
[SerializeField] private Button m_btnBack;
[SerializeField] private Button m_btnClose;
[SerializeField] private RectTransform m_rectContent;
[Header("Option Icons (set in Editor)")]
[SerializeField] private Sprite m_iconService;
[SerializeField] private Sprite m_iconTalkOption;
[SerializeField] private Sprite m_iconTask;
[SerializeField] private Sprite m_iconExit;
int m_iTracedTaskID;
int m_iTracedTaskNPCID;
CECTimeSafeChecker m_tracedTaskTimer;
public struct TASK_ITEM
{
public int task_id;
public int service;
public TASK_ITEM(int id, int serv)
{
task_id = id;
service = serv;
}
};
bool HasTracedTask()
{
return m_iTracedTaskID > 0;
}
void ResetTraceTaskInfo()
{
m_iTracedTaskNPCID = 0;
m_iTracedTaskID = 0;
m_tracedTaskTimer.Reset();
}
public static class NPC_DIALOG
{
public const uint NPC_DIALOG_NULL = 0,
NPC_DIALOG_ESSENCE = 1,
NPC_DIALOG_TALK = 2,
NPC_DIALOG_TASK_LIST = 3,
NPC_DIALOG_TASK_TALK = 4,
NPC_DIALOG_TASK_AWARD = 5;
};
public static class CDLGNPC
{
public const uint CDLGNPC_FORGET = 0xFFFFF01,
CDLGNPC_FACTION_CREATE = 0xFFFFF02,
CDLGNPC_FACTION_UPGRADE = 0xFFFFF03,
CDLGNPC_FACTION_DISMISS = 0xFFFFF04,
CDLGNPC_FACE = 0xFFFFF05,
CDLGNPC_MAIL = 0xFFFFF06,
CDLGNPC_AUCTION = 0xFFFFF07,
CDLGNPC_DOUBLEEXP = 0xFFFFF08,
CDLGNPC_PETHATCH = 0xFFFFF09,
CDLGNPC_PETREC = 0xFFFFF0A,
CDLGNPC_BATTLECHALLENGE = 0xFFFFF0B,
CDLGNPC_BATTLEENTER = 0xFFFFF0C,
CDLGNPC_BATTLELEAVE = 0xFFFFF0D,
CDLGNPC_GOLDTRADE = 0xFFFFF0E,
CDLGNPC_EQUIPREFINE = 0xFFFFF10,
CDLGNPC_EQUIPDYE = 0xFFFFF11,
CDLGNPC_REFINETRANS = 0xFFFFF12,
CDLGNPC_EQUIPSLOT = 0xFFFFF13,
CDLGNPC_ELFPRORESET = 0xFFFFF14,
CDLGNPC_ELFGENIUSRESET = 0xFFFFF15,
CDLGNPC_ELFFORGET = 0xFFFFF16,
CDLGNPC_ELFREFINE = 0xFFFFF17,
CDLGNPC_ELFREFINETRANS = 0xFFFFF18,
CDLGNPC_ELFTOPILL = 0xFFFFF19,
CDLGNPC_ELFEQUIPOFF = 0xFFFFF1A,
CDLGNPC_EQUIPREPAIR = 0xFFFFF1B,
CDLGNPC_WEBTRADE = 0xFFFFF1C,
CDLGNPC_GODEVILCONVERT = 0xFFFFF1D,
CDLGNPC_WEDDING_BOOK = 0xFFFFF1E,
CDLGNPC_WEDDING_INVITE = 0xFFFFF1F,
CGLDNPC_FORTRESS_CREATE = 0xFFFFF20,
CGLDNPC_FORTRESS_WAR = 0xFFFFF21,
CGLDNPC_FORTRESS_UPGRADE = 0xFFFFF22,
CGLDNPC_FORTRESS_HANDIN_MATERIAL = 0xFFFFF23,
CGLDNPC_FORTRESS_HANDIN_CONTRIB = 0xFFFFF24,
CGLDNPC_FORTRESS_EXCHANGE_MATERIAL = 0xFFFFF25,
CGLDNPC_FORTRESS_ENTER = 0xFFFFF26,
CGLDNPC_FORTRESS_WARLIST = 0xFFFFF27,
CGLDNPC_FORTRESS_LEAVE = 0xFFFFF28,
CDLGNPC_PETDYE = 0xFFFFF29,
CDLGNPC_VIEW_TRASHBOX = 0xFFFFF30,
CDLGNPC_VIEW_DPS_DPH_RANK = 0xFFFFF31,
CDLGNPC_FORCE_JOIN = 0xFFFFF32,
CDLGNPC_FORCE_QUIT = 0xFFFFF33,
CDLGNPC_JOIN_COUNTRY = 0xFFFFF34,
CDLGNPC_QUIT_COUNTRY = 0xFFFFF35,
CDLGNPC_LEAVE_COUNTRY_WAR = 0xFFFFF36,
CDLGNPC_EQUIP_MARK = 0xFFFFF37,
CDLGNPC_GOTO_SPECIALSERVER = 0xFFFFF38,
CDLGNPC_GOTO_ORIGINALSERVER = 0xFFFFF39,
CDLGNPC_PLAYER_RENAME = 0xFFFFF40,
CDLGNPC_STONE_CHANGE = 0xFFFFF41,
CDLGNPC_KING_SERVICE = 0xFFFFF42,
CDLGNPC_SPLIT_FASHION = 0xFFFFF43,
CDLGNPC_OFFLINESHOP_SETTING = 0xFFFFF44,
CDLGNPC_OFFLINESHOP_SELLBUY = 0xFFFFF45,
CDLGNPC_REINCARNATION = 0xFFFFF46,
CDLGNPC_GIFTCARD = 0xFFFFF47,
CDLGNPC_TRICKBATTLE = 0xFFFFF48, // ¿ç·þ»î¶¯, Õ½³µ
CDLGNPC_CARDRESPAWN = 0xFFFFF49, // ¿¨ÅÆ×ªÉú
CDLGNPC_QUERYCHARIOTAMOUNT = 0xFFFFF50, // Õ½³µÊýÁ¿
CDLGNPC_FLYSWORDIMPROVE = 0xFFFFF51, // ·É½£Ç¿»¯
CDLGNPC_OPEN_FACTION_PVP = 0xFFFFF52, // ¿ªÆô°ïÅÉÂÓ¶á
CDLGNPC_FACTION_RENAME = 0xFFFFF53,
CDLGNPC_GOLD_SHOP = 0xFFFFF54,
CDLGNPC_PLAYER_CHANGE_GENDER = 0xFFFFF55; // ÐÞ¸ÄÐÔ±ð
};
bool PopupTracedTaskDialog(NPC_ESSENCE pEssence)
{
PopupNPCDialog(pEssence);
if (GetData() == NPC_DIALOG.NPC_DIALOG_ESSENCE)
{
for (int i = 0; i < m_pLst_Main.GetCount() - 1; ++i)
{
object pData = m_pLst_Main.GetItemDataPtr(i, 0, "");
uint iService = m_pLst_Main.GetItemData(i, 0, "");
DATA_TYPE DataType = DATA_TYPE.DT_INVALID;
ElementDataManProvider.GetElementDataMan().get_data_ptr(iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE ||
DataType == DATA_TYPE.DT_NPC_TASK_OUT_SERVICE ||
DataType == DATA_TYPE.DT_NPC_TASK_MATTER_SERVICE)
{
SelectListItem(i);
break;
}
}
}
if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_LIST)
{
for (int i = 0; i < m_pLst_Main.GetCount() - 1; ++i)
{
ulong taskid = m_pLst_Main.GetItemData64(i, 0, "TaskID");
if (taskid == (ulong)m_iTracedTaskID)
{
SelectListItem(i);
return GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK;
}
}
}
return false;
}
public void PopupDialog(NPC_ESSENCE pEssence)
{
if (HasTracedTask())
{
if (m_tracedTaskTimer.IsTimeArrived())
{
ResetTraceTaskInfo();
}
}
if (HasTracedTask())
{
CECNPC pNPC = (EC_ManMessageMono.Instance.CECNPCMan.SeekOutNPC(m_iTracedTaskNPCID));
if (pNPC)
{
if (pEssence.id == pNPC.GetNPCID())
{
if (!PopupTracedTaskDialog(pEssence))
{
if (!m_bShow)
{
ResetTraceTaskInfo();
return;
}
PopupNPCDialog(pEssence);
}
}
}
else
{
GetGameUIMan().EndNPCService();
}
ResetTraceTaskInfo();
}
else
{
PopupNPCDialog(pEssence);
}
}
public override void Show(bool value)
{
base.Show(value);
}
void PopupNPCDialog(NPC_ESSENCE pEssence)
{
int i;
object pData;
DATA_TYPE DataType = new DATA_TYPE();
string strText = GetStringFromTable(249);
elementdataman pDataMan = ElementDataManProvider.GetElementDataMan();
Show(true);
//test
// pEssence.id_goblin_skill_service = 1;
uint[] a_uiService =
{
pEssence.id_talk_service, // ½»Ì¸µÄ·þÎñID
pEssence.id_sell_service, // ³öÊÛÉÌÆ·µÄ·þÎñID
pEssence.id_buy_service, // ÊÕ¹ºÆ·µÄ·þÎñID
pEssence.id_install_service, // °²×°ÏâǶƷµÄ·þÎñID
pEssence.id_uninstall_service, // ²ð³ýÏâǶƷµÄ·þÎñID
pEssence.id_skill_service, // ½ÌÊÚ¼¼ÄܵķþÎñID
pEssence.id_heal_service, // ÖÎÁƵķþÎñID
pEssence.id_transmit_service, // ´«Ë͵ķþÎñID
pEssence.id_transport_service, // ÔËÊäµÄ·þÎñID
pEssence.id_proxy_service, // ´úÊ۵ķþÎñID
pEssence.id_storage_service, // ²Ö¿âµÄ·þÎñID
pEssence.id_make_service, // Éú²úµÄ·þÎñID
pEssence.id_decompose_service, // ·Ö½âµÄ·þÎñID
pEssence.id_identify_service, // ¼ø¶¨µÄ·þÎñID
pEssence.id_war_towerbuild_service,// ½¨Ôì¼ýËþµÄ·þÎñID
pEssence.id_resetprop_service, // Ï´µãµÄ·þÎñID
pEssence.id_petname_service, // ³èÎï¸ÄÃû·þÎñ
pEssence.id_petlearnskill_service, // ³èÎïѧϰ¼¼ÄÜ·þÎñ
pEssence.id_petforgetskill_service,// ³èÎïÒÅÍü¼¼ÄÜ·þÎñ
pEssence.id_equipbind_service, // ×°±¸°ó¶¨·þÎñ
pEssence.id_equipdestroy_service, // ×°±¸Ïú»Ù·þÎñ
pEssence.id_equipundestroy_service,// ×°±¸½â³ýÏú»Ù·þÎñ
pEssence.id_goblin_skill_service, // С¾«Áéѧϰ·þÎñ
pEssence.id_engrave_service, // ïÔ¿Ì·þÎñ
pEssence.id_randprop_service, // Ëæ»úÊôÐÔ
pEssence.id_force_service, // ÊÆÁ¦ÊôÐÔ
};
GetGameUIMan().m_pCurNPCEssence = (NPC_ESSENCE)pEssence;
SetData(NPC_DIALOG.NPC_DIALOG_ESSENCE, "");
m_pTxt_npc.SetText(Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pEssence.name)));
m_pTxt_Content.SetText(Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pEssence.hello_msg)));
ResizeContent();
//m_pLst_Main.SetHOver(true);
m_pLst_Main.ResetContent();
m_pLst_Main.SetActionOnClickBtnItem((int value) => { SelectListItem(value); });
//add for test by czx
// int old = pEssence.combined_services | 0xFFFE0000;
// ((NPC_ESSENCE *)pEssence).combined_services = old;
//if ((pEssence.combined_services & 0x01) != 0) // Add "forget" skill.
//{
// CECSkill pSkill;
// for (i = 0; i < GetHostPlayer().GetPassiveSkillNum(); i++)
// {
// pSkill = GetHostPlayer().GetPassiveSkillByIndex(i);
// if (pSkill.GetType() == CECSkill::TYPE_PRODUCE)
// {
// m_pLst_Main.AddString(strText + GetStringFromTable(558));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC_FORGET);
// m_pLst_Main.SetItemDataPtr(m_pLst_Main.GetCount() - 1, (void*)pSkill);
// break;
// }
// }
//}
if ((pEssence.combined_services & 0x02) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(885));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_EQUIPSLOT);
}
if ((pEssence.combined_services & 0x10) != 0) // Add "faction" service.
{
if (GetHostPlayer().GetFactionID() <= 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(592));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_FACTION_CREATE);
}
else if (GetHostPlayer().GetFRoleID() == GNETRoles._R_MASTER)
{
int idFaction = GetHostPlayer().GetFactionID();
CECFactionMan pFMan = EC_Game.GetFactionMan();
Faction_Info pInfo = pFMan.GetFaction((uint)idFaction, false);
if (pInfo != null && pInfo.GetLevel() <= 1)
{
m_pLst_Main.AddString(strText + GetStringFromTable(593));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_FACTION_UPGRADE);
}
m_pLst_Main.AddString(strText + GetStringFromTable(11436));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_FACTION_RENAME);
m_pLst_Main.AddString(strText + GetStringFromTable(594));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_FACTION_DISMISS);
}
}
if ((pEssence.combined_services & 0x20) != 0 &&
!GetHostPlayer().HasEffectType(CECPlayer.Effect_type.EFF_FACEPILL))
{
m_pLst_Main.AddString(strText + GetStringFromTable(595));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_FACE);
}
if ((pEssence.combined_services & 0x40) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(634));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_MAIL);
}
if ((pEssence.combined_services & 0x80) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(644));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_AUCTION);
}
// if( pEssence.combined_services & 0x100 )
// {
// m_pLst_Main.AddString(strText + GetStringFromTable(683));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC_DOUBLEEXP);
// }
if ((pEssence.combined_services & 0x200) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(691));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_PETHATCH);
}
if ((pEssence.combined_services & 0x400) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(692));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_PETREC);
}
if ((pEssence.combined_services & 0x2000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(734));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_GOLDTRADE);
}
if ((pEssence.combined_services & 0x4000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(769));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_EQUIPREFINE);
}
if ((pEssence.combined_services & 0x8000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(874));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_EQUIPDYE);
m_pLst_Main.AddString(strText + GetStringFromTable(9323));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_PETDYE);
}
if ((pEssence.combined_services & 0x10000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(878));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_REFINETRANS);
}
if ((pEssence.combined_services & 0x800000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(7921));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_EQUIPREPAIR);
}
if ((pEssence.combined_services & 0x1000000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(8600));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_WEBTRADE);
}
if ((pEssence.combined_services & 0x2000000) != 0)
{
if (GetHostPlayer().GetBasicProps().iLevel2 >= 20)
{
m_pLst_Main.AddString(strText + GetStringFromTable(8601));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_GODEVILCONVERT);
}
}
if ((pEssence.combined_services & 0x4000000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(8740));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_WEDDING_BOOK);
m_pLst_Main.AddString(strText + GetStringFromTable(8741));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_WEDDING_INVITE);
}
bool bFortressOK = false;
while (true)
{
int idFaction = GetHostPlayer().GetFactionID();
if (idFaction <= 0 ||
EC_Game.GetFactionMan().GetFaction((uint)idFaction, false) == null)
{
// ÎÞ°ïÅÉ¡¢»òÕß°ïÅÉÐÅÏ¢ÉÐδ²éѯµ½
break;
}
if (GetHostPlayer().GetFactionFortressConfig().require_level == int.MinValue) // this replace logic == null
{
// ûÓлùµØÅäÖñí
break;
}
bFortressOK = true;
break;
}
bool bMaster = false, bViceMaster = false, bBodyGuard = false;
CECHostPlayer pHost = GetHostPlayer();
if (pHost.GetFactionID() > 0)
{
switch (pHost.GetFRoleID())
{
case GNETRoles._R_MASTER:
bMaster = true;
break;
case GNETRoles._R_VICEMASTER:
bViceMaster = true;
break;
case GNETRoles._R_BODYGUARD:
bBodyGuard = true;
break;
}
}
bool bInFortressNow = pHost.IsInFortress();
if (bFortressOK)
{
// °ïÅÉ»ùµØÏà¹Ø
if ((pEssence.combined_services & 0x8000000) != 0)
{
if (bMaster)
{
// °ïÖ÷¿ÉÒÔ´´½¨»ùµØ
m_pLst_Main.AddString(strText + GetStringFromTable(9101));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_CREATE);
}
// if (bMaster || bViceMaster)
// {
// // °ïÖ÷¡¢¸±°ïÖ÷¿ÉÒÔ´¦ÀíÕ½¶·ÊÂÒË
// m_pLst_Main.AddString(strText + GetStringFromTable(9102));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CGLDNPC_FORTRESS_WAR);
// }
if (!bInFortressNow)
{
// °ïÖÚËæÊ±¿É½øÈëÎÒ·½»ùµØ
m_pLst_Main.AddString(strText + GetStringFromTable(9107));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_ENTER);
}
// °ïÖÚËæÊ±¿É²é¿´¶ÔÕ½±í
// m_pLst_Main.AddString(strText + GetStringFromTable(9108));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CGLDNPC_FORTRESS_WARLIST);
}
if ((pEssence.combined_services & 0x10000000) != 0)
{
if (bMaster)
{
if (!GetHostPlayer().IsInFortressWar())
{
// °ïÖ÷·Çսʱ¿ÉÒÔÉý¼¶»ùµØÉèÊ©
m_pLst_Main.AddString(strText + GetStringFromTable(9103));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_UPGRADE);
}
}
// °ïÖÚ¿ÉÒÔ½ÉÄɲÄÁÏ
m_pLst_Main.AddString(strText + GetStringFromTable(9104));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_HANDIN_MATERIAL);
// °ïÖÚ¿ÉÒÔ½ÉÄɹ±Ï×¶È
m_pLst_Main.AddString(strText + GetStringFromTable(9105));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_HANDIN_CONTRIB);
if (bInFortressNow)
{
// °ïÖÚ¿ÉÒÔÀ뿪»ùµØ
m_pLst_Main.AddString(strText + GetStringFromTable(9109));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_LEAVE);
}
}
if ((pEssence.combined_services & 0x20000000) != 0)
{
if (bMaster)
{
// °ïÖ÷¿ÉÒÔ¶Ò»»²ÄÁÏ
m_pLst_Main.AddString(strText + GetStringFromTable(9106));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_EXCHANGE_MATERIAL);
}
}
}
if ((pEssence.combined_services & 0x8000000) != 0)
{
if (EC_Game.g_bEnableFortressDeclareWar)
{
m_pLst_Main.AddString(strText + GetStringFromTable(9102));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CGLDNPC_FORTRESS_WAR);
}
}
// check the storage without password
if ((pEssence.combined_services & 0x40000000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(9299));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_VIEW_TRASHBOX);
}
if ((pEssence.combined_services & 0x80000000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(9340));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_VIEW_DPS_DPH_RANK);
}
if ((pEssence.combined_services2 & 0x00000001) != 0)
{
bool bHasCountry = GetHostPlayer().GetCountry() > 0;
m_pLst_Main.AddString(strText + GetStringFromTable(bHasCountry ? 9763 : 9762));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, bHasCountry ? CDLGNPC.CDLGNPC_QUIT_COUNTRY : CDLGNPC.CDLGNPC_JOIN_COUNTRY);
}
if ((pEssence.combined_services2 & 0x00000002) != 0)
{
//if (GetHostPlayer().IsInCountryWar())
//{
// m_pLst_Main.AddString(strText + GetStringFromTable(9914));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_LEAVE_COUNTRY_WAR);
//}
}
if ((pEssence.combined_services2 & 0x00000004) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(9994));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_EQUIP_MARK);
}
if ((pEssence.combined_services2 & 0x00000008) != 0)
{
//if (!CECCrossServer.Instance().IsOnSpecialServer())
//{
// m_pLst_Main.AddString(strText + GetStringFromTable(10132));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_GOTO_SPECIALSERVER);
//}
}
if ((pEssence.combined_services2 & 0x00000010) != 0)
{
//if (CECCrossServer.Instance().IsOnSpecialServer())
//{
// m_pLst_Main.AddString(strText + GetStringFromTable(10133));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_GOTO_ORIGINALSERVER);
//}
}
// ¸ÄÃû·þÎñ
if ((pEssence.combined_services2 & 0x00000020) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(10150));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_PLAYER_RENAME);
}
// ±¦Ê¯×ª»»
bool bHasStoneChange = (pEssence.combined_services2 & 0x00000040) != 0;
if (bHasStoneChange)
{
m_pLst_Main.AddString(strText + GetStringFromTable(10172));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_STONE_CHANGE);
}
// ¹úÍõÏà¹Ø
if ((pEssence.combined_services2 & 0x00000080) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(10304));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_KING_SERVICE);
}
// ¼ÄÂô·þÎñ
if ((pEssence.combined_services2 & 0x00000100) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(10508));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_OFFLINESHOP_SETTING);
m_pLst_Main.AddString(strText + GetStringFromTable(10513));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_OFFLINESHOP_SELLBUY);
}
// ʱװ²ð·Ö
if ((pEssence.combined_services2 & 0x00000200) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(10430));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_SPLIT_FASHION);
}
if ((pEssence.combined_services2 & 0x00000400) != 0)
{
// תÉú°æ±¾ÉÏÏÞ
if (GetHostPlayer().GetReincarnationCount() < CECPlayer.MAX_REINCARNATION)
{
m_pLst_Main.AddString(strText + GetStringFromTable(10800));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_REINCARNATION);
}
}
if ((pEssence.combined_services2 & 0x00000800) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(10820));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_GIFTCARD);
}
if ((pEssence.combined_services2 & 0x00001000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(10890));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_TRICKBATTLE);
}
if ((pEssence.combined_services2 & 0x00002000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(11000));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_CARDRESPAWN);
}
if ((pEssence.combined_services2 & 0x00001000) != 0) // Õ½³µ¿ªÆônpc ×Ô¶¯´øÓиķþÎñÆ÷£¬£¨´¿¿Í»§¶Ë£©
{
m_pLst_Main.AddString(strText + GetStringFromTable(10912));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_QUERYCHARIOTAMOUNT);
}
if ((pEssence.combined_services2 & 0x00004000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(11193));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_FLYSWORDIMPROVE);
}
if ((pEssence.combined_services2 & 0x00008000) != 0)
{
if (!pHost.IsInFactionPVP() && (bMaster || bViceMaster || bBodyGuard))
{
m_pLst_Main.AddString(strText + GetStringFromTable(11270));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_OPEN_FACTION_PVP);
}
}
if ((pEssence.combined_services2 & 0x00010000) != 0 ||
(pEssence.combined_services2 & 0x00020000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(11437));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_GOLD_SHOP);
}
if ((pEssence.combined_services2 & 0x00040000) != 0)
{
//if (CECProfConfig::Instance().IsExist(GetHostPlayer().GetProfession(), CECProfConfig::Instance().GetCounterpartGender(GetHostPlayer().GetGender())))
//{
// m_pLst_Main.AddString(strText + GetStringFromTable(11438));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_PLAYER_CHANGE_GENDER);
//}
}
for (i = 0; i < a_uiService.Length; i++)
{
if (a_uiService[i] == 0) continue;
pData = ElementDataManProvider.GetElementDataMan().get_data_ptr(a_uiService[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
if (DataType == DATA_TYPE.DT_NPC_TALK_SERVICE)
{
NPC_TALK_SERVICE pService = (NPC_TALK_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_SELL_SERVICE)
{
NPC_SELL_SERVICE pService = (NPC_SELL_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_BUY_SERVICE)
{
continue;
}
else if (DataType == DATA_TYPE.DT_NPC_REPAIR_SERVICE)
{
NPC_REPAIR_SERVICE pService = (NPC_REPAIR_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_INSTALL_SERVICE)
{
NPC_INSTALL_SERVICE pService = (NPC_INSTALL_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_UNINSTALL_SERVICE)
{
NPC_UNINSTALL_SERVICE pService = (NPC_UNINSTALL_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_SKILL_SERVICE)
{
NPC_SKILL_SERVICE pService = (NPC_SKILL_SERVICE)pData;
if (i >= 18)
{
m_pLst_Main.AddString(strText + GetStringFromTable(7107));
}
else
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_HEAL_SERVICE)
{
NPC_HEAL_SERVICE pService = (NPC_HEAL_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_TRANSMIT_SERVICE)
{
NPC_TRANSMIT_SERVICE pService = (NPC_TRANSMIT_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_TRANSPORT_SERVICE)
{
NPC_TRANSPORT_SERVICE pService = (NPC_TRANSPORT_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_PROXY_SERVICE)
{
NPC_PROXY_SERVICE pService = (NPC_PROXY_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_STORAGE_SERVICE)
{
NPC_STORAGE_SERVICE pService = (NPC_STORAGE_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, a_uiService[i]);
m_pLst_Main.AddString(strText + GetStringFromTable(253));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, a_uiService[i]);
m_pLst_Main.AddString(strText + GetStringFromTable(8080));
}
else if (DataType == DATA_TYPE.DT_NPC_MAKE_SERVICE)
{
NPC_MAKE_SERVICE pService = (NPC_MAKE_SERVICE)pData;
string serviceName = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name));
m_pLst_Main.AddString(strText + serviceName);
// Log NPC_MAKE_SERVICE data
BMLogger.Log($"NPC_MAKE_SERVICE detected - ServiceID: {a_uiService[i]}, MakeServiceID: {pService.id}, Name: {serviceName}, MakeSkillID: {pService.id_make_skill}, ProduceType: {pService.produce_type}");
// Log pages data
if (pService.pages != null)
{
for (int pageIdx = 0; pageIdx < pService.pages.Length; pageIdx++)
{
var page = pService.pages[pageIdx];
string pageTitle = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(page.page_title));
// Trim null characters and whitespace from page title
pageTitle = pageTitle?.TrimEnd('\0', ' ', '\t', '\r', '\n') ?? "";
// Collect all non-zero goods IDs with their names
// Note: id_goods contains RECIPE IDs, not item IDs
List<string> goodsInfo = new List<string>();
if (page.id_goods != null)
{
for (int goodsIdx = 0; goodsIdx < page.id_goods.Length; goodsIdx++)
{
uint recipeId = page.id_goods[goodsIdx];
if (recipeId != 0)
{
// Get recipe data, output item, and materials
string outputItemInfo = "";
List<string> materialInfo = new List<string>();
try
{
var edm = ElementDataManProvider.GetElementDataMan();
if (edm == null)
{
// ElementDataMan is null, skip
}
else
{
// Try recipe space first
DATA_TYPE dt = DATA_TYPE.DT_INVALID;
object recipeData = edm.get_data_ptr(recipeId, ID_SPACE.ID_SPACE_RECIPE, ref dt);
// Check if we got recipe data - sometimes dt is DT_INVALID but data is still RECIPE_ESSENCE
RECIPE_ESSENCE? recipe = null;
if (recipeData != null && recipeData is RECIPE_ESSENCE)
{
recipe = (RECIPE_ESSENCE)recipeData;
}
else if (recipeData != null && dt == DATA_TYPE.DT_RECIPE_ESSENCE)
{
recipe = (RECIPE_ESSENCE)recipeData;
}
if (recipe.HasValue)
{
RECIPE_ESSENCE recipeValue = recipe.Value;
// Get output item from first target (main output)
if (recipeValue.targets != null && recipeValue.targets.Length > 0)
{
if (recipeValue.targets[0].id_to_make != 0)
{
uint outputItemId = recipeValue.targets[0].id_to_make;
try
{
EC_IvtrItem pItem = EC_IvtrItem.CreateItem((int)outputItemId, 0, 1);
if (pItem != null)
{
string outputName = pItem.GetName();
outputItemInfo = $"{outputItemId} ({outputName})";
}
else
{
outputItemInfo = $"{outputItemId} (unknown)";
}
}
catch (Exception ex2)
{
outputItemInfo = $"{outputItemId} (error: {ex2.Message})";
}
}
else
{
BMLogger.LogWarning($" Recipe {recipeId}: First target id_to_make is 0");
}
}
else
{
BMLogger.LogWarning($" Recipe {recipeId}: targets is null or empty");
}
// Get all materials
if (recipeValue.materials != null)
{
for (int matIdx = 0; matIdx < recipeValue.materials.Length; matIdx++)
{
var material = recipeValue.materials[matIdx];
if (material.id != 0 && material.num > 0)
{
string materialName = "";
try
{
EC_IvtrItem matItem = EC_IvtrItem.CreateItem((int)material.id, 0, 1);
if (matItem != null)
{
materialName = matItem.GetName();
}
}
catch (Exception ex2)
{
materialName = $"error: {ex2.Message}";
}
string matEntry = !string.IsNullOrEmpty(materialName)
? $"{material.id} ({materialName}) x{material.num}"
: $"{material.id} (unknown) x{material.num}";
materialInfo.Add(matEntry);
}
}
}
else
{
BMLogger.LogWarning($" Recipe {recipeId}: materials is null");
}
}
}
}
catch (Exception ex)
{
BMLogger.LogWarning($" Failed to get data for recipe ID {recipeId}: {ex.Message}\n{ex.StackTrace}");
}
// Format: "RecipeID -> Output: ID (Name) | Materials: ID (Name) xCount, ..."
string goodsEntry = $"Recipe {recipeId}";
if (!string.IsNullOrEmpty(outputItemInfo))
{
goodsEntry += $" -> Output: {outputItemInfo}";
}
else
{
goodsEntry += " -> Output: (none)";
}
if (materialInfo.Count > 0)
{
goodsEntry += $" | Materials: {string.Join(", ", materialInfo)}";
}
else
{
goodsEntry += " | Materials: (none)";
}
goodsInfo.Add(goodsEntry);
}
}
}
// Log page if it has a title or has goods
if (!string.IsNullOrEmpty(pageTitle) || goodsInfo.Count > 0)
{
string goodsList = goodsInfo.Count > 0 ? string.Join(", ", goodsInfo) : "";
BMLogger.Log($" Page[{pageIdx}]: Title=\"{pageTitle}\", Goods=[{goodsList}], GoodsCount={goodsInfo.Count}");
}
}
}
}
else if (DataType == DATA_TYPE.DT_NPC_DECOMPOSE_SERVICE)
{
NPC_DECOMPOSE_SERVICE pService = (NPC_DECOMPOSE_SERVICE)pData;
string serviceName = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name));
// Log NPC_DECOMPOSE_SERVICE data
BMLogger.Log($"NPC_DECOMPOSE_SERVICE detected - ServiceID: {a_uiService[i]}, DecomposeServiceID: {pService.id}, Name: {serviceName}, DecomposeSkillID: {pService.id_decompose_skill}");
CECHostPlayer hostPlayer = GetHostPlayer();
bool hasRequiredSkill = false;
// TODO: Implement proper skill check when GetPassiveSkillNum() and GetPassiveSkillByIndex() are available
// For now, we'll use reflection to access private GetPassiveSkillByID method or implement a workaround
// The C++ code checks if player has the required decompose skill (TYPE_LIVE or TYPE_PRODUCE)
try
{
// Try using reflection to access private GetPassiveSkillByID method
var method = typeof(CECHostPlayer).GetMethod("GetPassiveSkillByID",
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (method != null)
{
var pSkill = method.Invoke(hostPlayer, new object[] { (int)pService.id_decompose_skill, false }) as CECSkill;
if (pSkill != null)
{
int skillType = pSkill.GetType();
int skillID = pSkill.GetSkillID();
BMLogger.Log($" Found skill by ID (via reflection): ID={skillID}, Type={skillType}");
// Check if this is the required decompose skill with correct type
if ((skillType == (int)CECSkill.SkillType.TYPE_LIVE ||
skillType == (int)CECSkill.SkillType.TYPE_PRODUCE) &&
(int)pService.id_decompose_skill == skillID)
{
hasRequiredSkill = true;
BMLogger.Log($" Skill check PASSED - Player has required decompose skill (ID: {pService.id_decompose_skill}, Type: {skillType})");
m_pLst_Main.AddString(strText + serviceName);
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, a_uiService[i]);
m_pLst_Main.SetItemDataPtr(m_pLst_Main.GetCount() - 1, pData);
}
else
{
BMLogger.Log($" Skill found but type mismatch - Expected TYPE_LIVE or TYPE_PRODUCE, got {skillType}");
}
}
else
{
BMLogger.Log($" Skill check FAILED - Player does not have required decompose skill (ID: {pService.id_decompose_skill})");
}
}
else
{
BMLogger.LogWarning($" GetPassiveSkillByID method not found via reflection - skill check cannot be performed");
// For now, show the service anyway for logging/debugging purposes
// TODO: Remove this when proper skill check is implemented
hasRequiredSkill = true;
m_pLst_Main.AddString(strText + serviceName);
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, a_uiService[i]);
m_pLst_Main.SetItemDataPtr(m_pLst_Main.GetCount() - 1, pData);
}
}
catch (Exception ex)
{
BMLogger.LogError($"Error checking decompose skill: {ex.Message}");
BMLogger.LogError($"Stack trace: {ex.StackTrace}");
// For debugging: show service anyway
hasRequiredSkill = true;
m_pLst_Main.AddString(strText + serviceName);
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, a_uiService[i]);
m_pLst_Main.SetItemDataPtr(m_pLst_Main.GetCount() - 1, pData);
}
if (!hasRequiredSkill)
continue;
}
else if (DataType == DATA_TYPE.DT_NPC_IDENTIFY_SERVICE)
{
NPC_IDENTIFY_SERVICE pService = (NPC_IDENTIFY_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_WAR_TOWERBUILD_SERVICE)
{
NPC_WAR_TOWERBUILD_SERVICE pService = (NPC_WAR_TOWERBUILD_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_RESETPROP_SERVICE)
{
NPC_RESETPROP_SERVICE pService = (NPC_RESETPROP_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_PETNAME_SERVICE)
{
NPC_PETNAME_SERVICE pService = (NPC_PETNAME_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_PETLEARNSKILL_SERVICE)
{
NPC_PETLEARNSKILL_SERVICE pService = (NPC_PETLEARNSKILL_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_PETFORGETSKILL_SERVICE)
{
NPC_PETFORGETSKILL_SERVICE pService = (NPC_PETFORGETSKILL_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_EQUIPBIND_SERVICE)
{
NPC_EQUIPBIND_SERVICE pService = (NPC_EQUIPBIND_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_EQUIPDESTROY_SERVICE)
{
NPC_EQUIPDESTROY_SERVICE pService = (NPC_EQUIPDESTROY_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_EQUIPUNDESTROY_SERVICE)
{
NPC_EQUIPUNDESTROY_SERVICE pService = (NPC_EQUIPUNDESTROY_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_ENGRAVE_SERVICE)
{
NPC_ENGRAVE_SERVICE pService = (NPC_ENGRAVE_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_RANDPROP_SERVICE)
{
NPC_RANDPROP_SERVICE pService = (NPC_RANDPROP_SERVICE)pData;
m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name)));
}
else if (DataType == DATA_TYPE.DT_NPC_FORCE_SERVICE)
{
//NPC_FORCE_SERVICE pService = (NPC_FORCE_SERVICE)pData;
//uint npcForce = pService.force_id;
//int playerForce = GetHostPlayer().GetForce();
//FORCE_CONFIG pConfig = CECForceMgr::GetForceData(npcForce);
//if (pConfig && (npcForce == playerForce || !playerForce))
//{
// string strForce;
// strForce.Format(GetStringFromTable(playerForce ? 9401 : 9400), pConfig.name);
// m_pLst_Main.AddString(strText + strForce);
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, playerForce ? CDLGNPC_FORCE_QUIT : CDLGNPC_FORCE_JOIN);
// m_pLst_Main.SetItemDataPtr(m_pLst_Main.GetCount() - 1, (void*)pData);
//}
// hide the invalid force option
continue;
}
else
{
// δʶ±ðµÄ·þÎñ
continue;
}
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, a_uiService[i]);
m_pLst_Main.SetItemDataPtr(m_pLst_Main.GetCount() - 1, pData);
}
//add for goblin by czx
if ((pEssence.combined_services & 0x400000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(7106));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_ELFEQUIPOFF);
}
if ((pEssence.combined_services & 0x200000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(7100));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_ELFPRORESET);
}
if ((pEssence.combined_services & 0x40000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(7101));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_ELFGENIUSRESET);
}
if ((pEssence.combined_services & 0x80000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(7102));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_ELFFORGET);
}
if ((pEssence.combined_services & 0x200000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(7105));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_ELFTOPILL);
}
if ((pEssence.combined_services & 0x100000) != 0)
{
m_pLst_Main.AddString(strText + GetStringFromTable(7103));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_ELFREFINE);
m_pLst_Main.AddString(strText + GetStringFromTable(7104));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC.CDLGNPC_ELFREFINETRANS);
}
//if (UnityGameSession.GetServerAttr().battle == 1)
//{
// if (GetGameUIMan().m_pDlgGuildMap.IsBattleOpen() &&
// (pEssence.combined_services & 0x800))
// {
// long stime = GetGame().GetServerGMTTime();
// stime -= GetGame().GetTimeZoneBias() * 60; // localtime = UTC - bias, in which bias is minute
// tm* gtime = gmtime(&stime);
// // if( gtime.tm_wday == 1 && gtime.tm_hour >= 19 )
// if (GetGameUIMan().m_pDlgGuildMap.IsBattleChallengeOpen())
// // && GetHostPlayer().GetFRoleID() == GNETRoles._R_MASTER )
// {
// m_pLst_Main.AddString(strText + GetStringFromTable(699));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC_BATTLECHALLENGE);
// }
// // if( gtime.tm_wday == 5 && gtime.tm_hour >= 18 ||
// // gtime.tm_wday == 6 ||
// // gtime.tm_wday == 0 )
// if (GetHostPlayer().GetFRoleID() != GNETRoles._R_UNMEMBER)
// {
// m_pLst_Main.AddString(strText + GetStringFromTable(722));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC_BATTLEENTER);
// }
// }
// if (pEssence.combined_services & 0x1000)
// {
// m_pLst_Main.AddString(strText + GetStringFromTable(724));
// m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, CDLGNPC_BATTLELEAVE);
// }
//}
// ÈÎÎñÏà¹ØÄ©Î²Ìí¼Ó£¬ÒÔÅжÏÊÇÒÔ¡°ÈÎÎñÏà¹Ø¡±ÏÔʾÔÚÁбíÀ»¹ÊÇÖ±½ÓÏÔʾÈÎÎñÁбí
CheckTaskService(pEssence);
if (pEssence.domain_related == 1)
{
if (GetHostPlayer().GetFRoleID() == GNETRoles._R_UNMEMBER)
m_pLst_Main.ResetContent();
//else
//{
// CECNPCMan pNPCMan = GetWorld().GetNPCMan();
// CECNPC pNPC = pNPCMan.GetNPC(GetHostPlayer().GetCurServiceNPC());
// if (pNPC)
// {
// A3DVECTOR3 pos = pNPC.GetServerPos();
// CECWorld pWorld = GetWorld();
// CELPrecinct pPrecinct = pWorld.GetPrecinctSet().IsPointIn(
// pos.x, pos.z, pWorld.GetInstanceID());
// if (pPrecinct)
// {
// int idDomain = pPrecinct.GetDomainID();
// DOMAIN_INFO* pInfo = CECDomainGuildInfo::Instance().Find(idDomain);
// int idFaction = pInfo ? pInfo.id_owner : -1;
// if (GetHostPlayer().GetFactionID() != idFaction)
// m_pLst_Main.ResetContent();
// }
// }
//}
}
// Add "EXIT" choice.
AddExitChoice();
// Icons for the essence menu (services + exit).
ApplyListIcons(m_iconService);
// Update list height for diffent service count
//if (pEssence.id != m_lastNPCID)
//{
// m_lastNPCID = pEssence.id;
// // Compute new list height
// const float fScale = GetGameUIMan().GetWindowScale();
// const int c_heightPerItem = int(18 * fScale);
// const int c_minListHeight = int(101 * fScale);
// const int c_minTextHeight = int(135 * fScale);
// int itemCount = m_pLst_Main.GetCount();
// int newListHeight = itemCount * c_heightPerItem + 1;
// newListHeight = max(newListHeight, c_minListHeight);
// SIZE sizeText = m_pTxt_Content.GetSize();
// SIZE sizeList = m_pLst_Main.GetSize();
// if (sizeText.cy - (newListHeight - sizeList.cy) < c_minTextHeight)
// newListHeight = sizeText.cy - c_minTextHeight + sizeList.cy;
// // Compute list height change
// int deltaListHeight = newListHeight - sizeList.cy;
// // Adjust controls according to height change
// if (deltaListHeight)
// {
// POINT pos = m_pLst_Main.GetPos(true);
// m_pLst_Main.SetPos(pos.x, pos.y - deltaListHeight);
// m_pLst_Main.SetSize(sizeList.cx, sizeList.cy + deltaListHeight);
// m_pTxt_Content.SetSize(sizeText.cx, sizeText.cy - deltaListHeight);
// }
//}
//GetGameUIMan().m_bShowAllPanels = true;
}
void CheckTaskService(NPC_ESSENCE pEssence)
{
uint[] a_uiService2 =
{
pEssence.id_task_out_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñ·þÎñ
pEssence.id_task_in_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ÑéÖ¤Íê³ÉÈÎÎñ·þÎñ
pEssence.id_task_matter_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñÎïÆ··þÎñ
};
object pData;
DATA_TYPE DataType = new DATA_TYPE();
string strText = GetStringFromTable(249);
elementdataman pDataMan = ElementDataManProvider.GetElementDataMan();
// flag if this NPC contains task related service
uint validTaskService = 0;
// flag if we only got storage task service
bool isStorageTaskOnly = true;
// flag if storage task exists
NPC_TASK_OUT_SERVICE pStorageService = new NPC_TASK_OUT_SERVICE();
pStorageService.storage_deliver_per_day = int.MinValue;
//
// this loop will set values to these flags by checking current NPC data
//
for (int i = 0; i < a_uiService2.Length; i++)
{
if (a_uiService2[i] == 0) continue;
pData = ElementDataManProvider.GetElementDataMan().get_data_ptr(a_uiService2[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
// ignore other service
if (DataType != DATA_TYPE.DT_NPC_TASK_IN_SERVICE &&
DataType != DATA_TYPE.DT_NPC_TASK_OUT_SERVICE &&
DataType != DATA_TYPE.DT_NPC_TASK_MATTER_SERVICE)
{
continue;
}
if (DataType != DATA_TYPE.DT_NPC_TASK_OUT_SERVICE)
{
validTaskService = a_uiService2[i];
isStorageTaskOnly = false;
}
else
{
// do not update if we got other task service already
if (validTaskService == 0) validTaskService = a_uiService2[i];
// check whether this is a task storage
NPC_TASK_OUT_SERVICE pService = (NPC_TASK_OUT_SERVICE)pData;
if (pService.storage_id == 0 || pService.storage_open_item == 0)
{
isStorageTaskOnly = false;
}
else
{
pStorageService = pService;
}
}
}
// make sure this flag is not conflicted with others
isStorageTaskOnly = isStorageTaskOnly && validTaskService != 0 && pStorageService.storage_deliver_per_day != int.MinValue;
// setup the menu item based on these flags
if (validTaskService != 0)
{
bool isEmptyMenu = (m_pLst_Main.GetCount() <= 0);
if (isEmptyMenu && pStorageService.storage_deliver_per_day == int.MinValue)
{
// ûÓзÇÈÎÎñÑ¡Ïֱ½Óµ¯³öÈÎÎñÄÚÈÝ
PopupTaskDialog(true);
}
else
{
if (pStorageService.storage_deliver_per_day != int.MinValue)
{
// add a menu item for task storage
m_pLst_Main.AddString(strText + ("<color=#FF0000>") + pStorageService.name + "</color>");
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, pEssence.id_task_out_service);
m_pLst_Main.SetItemDataPtr(m_pLst_Main.GetCount() - 1, pStorageService);
}
isEmptyMenu = (m_pLst_Main.GetCount() <= 0);
if (!isEmptyMenu && !isStorageTaskOnly)
{
pData = pDataMan.get_data_ptr(validTaskService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
// ÓÐÆäËü·ÇÈÎÎñÄÚÈÝ£¬°ÑËùÓÐÈÎÎñÏà¹Ø¼¯ÖзÅÔÚ¡°ÈÎÎñÏà¹Ø¡±À¸Àï
m_pLst_Main.AddString(strText + GetStringFromTable(244));
m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, validTaskService);
m_pLst_Main.SetItemDataPtr(m_pLst_Main.GetCount() - 1, pData);
}
}
}
}
void PopupTaskDialog(bool bTaskNPC)
{
NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence;
NPC_ESSENCE pEssence = pCurNPCEssence.Value;
//if (!pEssence) return;
int i, j, idTask;
object pData;
DATA_TYPE DataType = new DATA_TYPE();
uint[] a_idTask = new uint[0];
uint[] a_uiService =
{
pEssence.id_task_out_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñ·þÎñ
pEssence.id_task_in_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ÑéÖ¤Íê³ÉÈÎÎñ·þÎñ
pEssence.id_task_matter_service // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñÎïÆ··þÎñ
};
int idLastTask = 0, nLastTaskTime = 0, nFinishTime;
elementdataman pDataMan = ElementDataManProvider.GetElementDataMan();
List<TASK_ITEM> taskIn = new List<TASK_ITEM>(),
taskOut = new List<TASK_ITEM>(),
taskMatter = new List<TASK_ITEM>();
CECTaskInterface pTask = GetHostPlayer().GetTaskInterface();
for (i = 0; i < a_uiService.Length; i++)
{
pData = pDataMan.get_data_ptr(a_uiService[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE ||
DataType == DATA_TYPE.DT_NPC_TASK_OUT_SERVICE)
{
int total_count = 0;
if(pData != null)
{
if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE)
{
NPC_TASK_IN_SERVICE pService = (NPC_TASK_IN_SERVICE)pData;
a_idTask = pService.id_tasks;
total_count = pService.id_tasks.Length;
}
else
{
NPC_TASK_OUT_SERVICE pService = (NPC_TASK_OUT_SERVICE)pData;
// if storage task not exists
if (pService.storage_id == 0 || pService.storage_open_item == 0)
{
a_idTask = pService.id_tasks;
total_count = pService.id_tasks.Length;
}
}
}
for (j = 0; j < total_count; j++)
{
idTask = (int)a_idTask[j];
if (idTask <= 0) continue;
if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE)
taskIn.Add(new TASK_ITEM(idTask, (int)a_uiService[i]));
else
taskOut.Add(new TASK_ITEM(idTask, (int)a_uiService[i]));
nFinishTime = (int)pTask.GetTaskFinishedTime((uint)idTask);
if (nFinishTime > nLastTaskTime)
{
idLastTask = idTask;
nLastTaskTime = nFinishTime;
}
}
}
else if (DataType == DATA_TYPE.DT_NPC_TASK_MATTER_SERVICE)
{
NPC_TASK_MATTER_SERVICE pService = (NPC_TASK_MATTER_SERVICE)pData;
for (j = 0; j < 16; j++)
{
idTask = (int)pService.tasks[j].id_task;
if (idTask > 0)
{
taskMatter.Add(new TASK_ITEM(idTask, (int)a_uiService[i]));
}
}
}
}
//A3DCOLOR color;
string strText = "";
talk_proc? pTalk;
ATaskTempl pTemp, pTempRoot;
int nIndex, nNumTasks = 0;
int nHostLevel = GetHostPlayer().GetBasicProps().iLevel;
ATaskTemplMan pTempMan = EC_Game.GetTaskTemplateMan();
m_pLst_Main.ResetContent();
List<TASK_ITEM>[] a_uiTasks = { taskIn, taskOut, taskMatter };
for (int idx = 0; idx < a_uiTasks.Length; idx++)
{
foreach (var it in a_uiTasks[idx])
{
idTask = it.task_id;
//color = 0;
bool bNeedSetSpecialColor = false;
pTemp = null;
pTalk = null;
//color = m_pLst_Main.GetColor();
strText = GetStringFromTable(249);
if (idx == 1)
{
if (pTask.HasTask((uint)idTask))
{
if (!pTask.CanFinishTask((uint)idTask))
{
pTemp = pTempMan.GetTaskTemplByID((uint)idTask);
pTalk = pTemp.GetUnfinishedTalk();
}
}
else if (pTask.CanShowTask((uint)idTask))
{
pTemp = pTempMan.GetTaskTemplByID((uint)idTask);
if (0 == pTask.CanDeliverTask((uint)idTask))
pTalk = pTemp.GetDeliverTaskTalk();
else
{
pTalk = pTemp.GetUnqualifiedTalk();
//color = A3DCOLORRGB(128, 128, 128);
bNeedSetSpecialColor = true;
}
}
}
if (idx == 0 && pTask.HasTask((uint)idTask)
&& pTask.CanFinishTask((uint)idTask) && pTalk == null)
{
pTemp = pTempMan.GetTaskTemplByID((uint)idTask);
pTalk = pTemp.GetAwardTalk();
strText = GetStringFromTable(302);
}
if (pTemp != null && pTalk != null && (pTalk?.num_window > 1 || pTalk?.num_window == 1 && (pTalk?.windows[0].talk_text).Length > 0))
{
if (pTemp.IsKeyTask())
{
//color = A3DCOLORRGB(255, 162, 0);
bNeedSetSpecialColor = true;
}
//else if (color != 0)
//{
// // È¥µô¸ù¾ÝÈËÎïºÍÈÎÎñ¼¶±ð²îÀ´¸Ä±äÑÕÉ«µÄÂß¼­
// /*
// nLevel = pTemp.GetSuitableLevel();
// if( nHostLevel <= nLevel - 2 )
// color = A3DCOLORRGB(255, 54, 0);
// else if( nHostLevel >= nLevel + 3 )
// color = A3DCOLORRGB(22, 142, 54);
// */
//}
pTempRoot = (ATaskTempl)pTemp.GetTopTask();
if (pTemp != pTempRoot)
{
if (bNeedSetSpecialColor)
{
strText += GetTaskNameWithOutColor(pTempRoot);
}
else
{
strText += GetTaskNameWithColor(pTempRoot);
}
strText += (" - ");
}
if (bNeedSetSpecialColor)
{
strText += GetTaskNameWithOutColor(pTemp);
}
else
{
strText += GetTaskNameWithColor(pTemp);
}
m_pLst_Main.AddString(strText);
nIndex = m_pLst_Main.GetCount() - 1;
m_pLst_Main.SetItemData(nIndex, (uint)it.service); // Service ID.
m_pLst_Main.SetItemDataPtr(nIndex, (object)pTalk); // Talk data.
m_pLst_Main.SetItemData64(nIndex, pTemp.GetID(), 0, "TaskID");
//if (bNeedSetSpecialColor)
//{
// m_pLst_Main.SetItemTextColor(nIndex, color);
//}
nNumTasks++;
}
}
}
if (idLastTask > 0)
{
pTemp = pTempMan.GetTaskTemplByID((uint)idLastTask);
if ((pTemp.GetTribute().Length) > 0)
{
string text = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pTemp.GetTribute()));
m_pTxt_Content.SetText(text);
ResizeContent();
}
else
{
if (nNumTasks > 0)
{
m_pTxt_Content.SetText(GetStringFromTable(502));
ResizeContent();
}
else
{
m_pTxt_Content.SetText(GetStringFromTable(501));
ResizeContent();
}
}
}
else if (bTaskNPC)
{
if (pCurNPCEssence != null)
{
string text = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pCurNPCEssence.Value.hello_msg));
m_pTxt_Content.SetText(text);
ResizeContent();
}
}
else
{
if (nNumTasks > 0)
{
m_pTxt_Content.SetText(GetStringFromTable(502));
ResizeContent();
}
else
{
m_pTxt_Content.SetText(GetStringFromTable(501));
ResizeContent();
}
}
SetData(NPC_DIALOG.NPC_DIALOG_TASK_LIST, "");
}
string GetTaskNameWithOutColor(ATaskTempl pTempl)
{
string text = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pTempl.m_FixedData.m_szName));
return TrimColorPrefix(text);
}
string GetTaskNameWithColor(ATaskTempl pTempl)
{
string text = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pTempl.m_FixedData.m_szName));
if (pTempl.GetType() == (uint)ENUM_TASK_TYPE.enumTTQiShaList && text[0] == '^')
{
// Èç¹ûÊÇÆßɱ°ñÈÎÎñÇÒÒѾ­¼ÓÁËÑÕÉ«£¬ÔòÑÕÉ«²»±ä
return text;
}
string strTaskName = GetTaskNameWithOutColor(pTempl);
//string strColorPreFix = A3DCOLOR_TO_STRING(GetTaskColor(pTempl));
//strTaskName = strColorPreFix + strTaskName;
return strTaskName;
}
string TrimColorPrefix(string szName)
{
const int COLOR_PREFIX_LENGTH = 7; // "^ffffff"
if (!string.IsNullOrEmpty(szName) && szName.Length >= COLOR_PREFIX_LENGTH && szName[0] == '^')
{
bool bColorPrefix = true;
for (int i = 1; i < COLOR_PREFIX_LENGTH; i++)
{
char c = szName[i];
bool isHexDigit =
(c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'f') ||
(c >= 'A' && c <= 'F');
if (!isHexDigit)
{
bColorPrefix = false;
break;
}
}
if (bColorPrefix)
{
// Lấy phần sau prefix
return szName.Substring(COLOR_PREFIX_LENGTH);
}
}
return szName;
}
public void PopupNPCDialog(talk_proc pTalk)
{
if (pTalk.num_window == 0) return;
int i, nIndex;
string strText = "";
CECTaskInterface pTask = GetHostPlayer().GetTaskInterface();
string talkText = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pTalk.windows[0].talk_text));
m_pTxt_Content.SetText(pTask.FormatTaskTalk(talkText));
ResizeContent();
m_pTxt_npc.SetText("");
m_pLst_Main.ResetContent();
for (i = 0; i < pTalk.windows[0].num_option; i++)
{
strText = GetStringFromTable(249);
strText += Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pTalk.windows[0].options[i].text));
m_pLst_Main.AddString(strText);
nIndex = m_pLst_Main.GetCount() - 1;
m_pLst_Main.SetItemData(nIndex, pTalk.windows[0].options[i].id);
m_pLst_Main.SetItemDataPtr(nIndex, pTalk.windows[0].options[i]);
m_pLst_Main.SetItemIcon(nIndex, m_iconTalkOption);
}
SetDataPtr(pTalk, "ptr_talk_proc");
if (!IsShow()) Show(true);
}
// bool c(int idFunction, int iService, object pData)
// {
// AUIDialog pShow1 = null, pShow2 = null;
// NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence;
//
// if (idFunction == (int)SERVICE_TYPE.NPC_SELL || idFunction == (int)SERVICE_TYPE.NPC_BUY)
// {
// //Button pButton;
//
// //pShow1 = m_pAUIManager.GetDialog("Win_Shop");
// //pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
//
// //GetHostPlayer().PrepareNPCService(iService);
// //GetGameUIMan().m_pDlgShop.UpdateShop(1);
//
// //if (pCurNPCEssence && pCurNPCEssence.id_repair_service)
// //{
// // pShow1.GetDlgItem("Btn_Repair").Show(true);
// // pShow1.GetDlgItem("Btn_RepairAll").Show(true);
// //}
// //else
// //{
// // pShow1.GetDlgItem("Btn_Repair").Show(false);
// // pShow1.GetDlgItem("Btn_RepairAll").Show(false);
// //}
//
// //pButton = (Button)pShow2.GetDlgItem("Btn_NormalItem");
// //pButton.SetPushed(true);
// //pButton = (Button)pShow2.GetDlgItem("Btn_QuestItem");
// //pButton.SetPushed(false);
// //GetGameUIMan().m_pDlgInventory.SetShowItem(CDlgInventory::INVENTORY_ITEM_NORMAL);
// if (pCurNPCEssence.HasValue)
// {
// uint npcID = pCurNPCEssence.Value.id;
// var dlg = CECUIManager.Instance.ShowUI("DialogNPCShop");
// if (dlg != null && dlg is NPCShopUIManager shopManager)
// {
// shopManager.OpenNPCShop(npcID);
// }
// }
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_INSTALL)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_Enchase");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_UNINSTALL)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_Disenchase");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_HEAL)
// {
// UnityGameSession.c2s_CmdNPCSevHeal();
// GetGameUIMan().EndNPCService();
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_TRANSMIT)
// {
// //pShow1 = m_pAUIManager.GetDialog("Win_WorldMapTravel");
// //((CDlgWorldMap)pShow1).BuildTravelMap(DATA_TYPE.DT_NPC_TRANSMIT_SERVICE, pData);
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_SKILL)
// {
// //string strText = m_pLst_Main.GetText(m_pLst_Main.GetCurSel());
// //string strHead = GetStringFromTable(249);
// //string strComp = (strHead + GetStringFromTable(7107));
// //if (0 == a_stricmp(strText, strComp))
// //{
// // pShow1 = m_pAUIManager.GetDialog("Win_ELFLearn");
// // ((CDlgELFLearn*)pShow1).SetNPCName(pCurNPCEssence.name);
// // pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// // GetHostPlayer().PrepareNPCService(iService);
// // pShow1.SetData(DATA_TYPE.DT_NPC_SKILL_SERVICE);
// //}
// //else
// //{
// // pShow1 = m_pAUIManager.GetDialog("Win_Teach");
// // GetHostPlayer().PrepareNPCService(iService);
// // pShow1.SetData((uint)DATA_TYPE.DT_NPC_SKILL_SERVICE, "");
// // GetGameUIMan().UpdateTeach(0);
// //}
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_MAKE)
// {
// //NPC_MAKE_SERVICE pMake = (NPC_MAKE_SERVICE)pData;
// //if (pMake.produce_type == 2)
// // pShow1 = m_pAUIManager.GetDialog("Win_Produce1");
// //else
// // pShow1 = m_pAUIManager.GetDialog("Win_Produce");
// //GetGameUIMan().m_pDlgProduce = (CDlgProduce*)pShow1;
// //GetHostPlayer().PrepareNPCService(iService);
// //pShow1.SetDataPtr(pMake, "ptr_NPC_MAKE_SERVICE");
// //if (pMake.produce_type == 1 ||
// // pMake.produce_type == 3 ||
// // pMake.produce_type == 4 ||
// // pMake.produce_type == 5)
// // GetGameUIMan().m_pDlgProduce.ClearMaterial();
// //pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// //GetGameUIMan().m_pDlgProduce.UpdateProduce(1, 0);
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_DECOMPOSE)
// {
// //pShow1 = m_pAUIManager.GetDialog("Win_Split");
// //pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// //pShow1.SetDataPtr(pData, "ptr_NPC_DECOMPOSE_SERVICE");
//
// //PAUIPROGRESS pProgress;
// //PAUIIMAGEPICTURE pImage;
//
// //pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_a");
// //pImage.ClearCover();
// //pImage.SetDataPtr(NULL);
//
// //pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_b");
// //pImage.ClearCover();
// //pImage.SetDataPtr(NULL);
//
// //pProgress = (PAUIPROGRESS)pShow1.GetDlgItem("Prgs_1");
// //pProgress.SetProgress(0);
//
// //pShow1.GetDlgItem("Btn_Start").Enable(false);
// //pShow1.GetDlgItem("Btn_Cancel").Enable(true);
// //pShow1.GetDlgItem("Txt_no1").SetText(_AL(""));
// //pShow1.GetDlgItem("Txt_no2").SetText(_AL(""));
// //pShow1.GetDlgItem("Txt_Gold").SetText(_AL(""));
// //pShow1.GetDlgItem("Txt_SkillName").SetText(_AL(""));
// //pShow1.GetDlgItem("Txt_SkillLevel").SetText(_AL(""));
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_WAR_TOWERBUILD)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_WarTower");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_RESETPROP)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_ResetProp");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_PETNAME)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_PetRename");
// pShow2 = m_pAUIManager.GetDialog("Win_PetList");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_PETLEARNSKILL)
// {
// //CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral();
// //CECPetData* pPet = pPetCorral.GetActivePet();
// //if (!pPet)
// //{
// // GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255));
// // GetGameUIMan().EndNPCService();
// //}
// //else
// //{
// // pShow1 = m_pAUIManager.GetDialog("Win_Teach");
// // GetHostPlayer().PrepareNPCService(iService);
// // pShow1.SetData(DT_NPC_PETLEARNSKILL_SERVICE);
// // GetGameUIMan().UpdateTeach(0);
// //}
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_PETFORGETSKILL)
// {
// //CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral();
// //CECPetData* pPet = pPetCorral.GetActivePet();
// //if (!pPet)
// //{
// // GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255));
// // GetGameUIMan().EndNPCService();
// //}
// //else
// // pShow1 = m_pAUIManager.GetDialog("Win_PetRetrain");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPBIND)
// {
// //pShow1 = m_pAUIManager.GetDialog("Win_EquipBind");
// //pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// //pShow1.SetData((DWORD)pData, "ptr_NPC_EQUIPBIND_SERVICE");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPDESTROY)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_EquipDestroy");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPUNDESTROY)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_EquipUndestroy");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_IDENTIFY)
// {
// //PAUIIMAGEPICTURE pImage;
//
// //pShow1 = m_pAUIManager.GetDialog("Win_Identify");
// //pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// //pShow1.SetDataPtr(pData, "ptr_NPC_IDENTIFY_SERVICE");
//
// //pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item");
// //pImage.ClearCover();
// //pImage.SetDataPtr(NULL);
//
// //pShow1.GetDlgItem("Txt").SetText(_AL(""));
// //pShow1.GetDlgItem("Txt_Gold").SetText(_AL(""));
// //pShow1.GetDlgItem("Btn_Confirm").Enable(false);
// //pShow1.GetDlgItem("Btn_Cancel").Enable(true);
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_GIVE_TASK)
// {
// talk_proc.option opt = new talk_proc.option();
// opt = (talk_proc.option)pData;
// int idTask = (int)opt.param;
// //if (EC_Game.GetConfigs().IsMiniClient() && CECUIConfig.Instance().GetGameUI().IsTaskDisabledInMiniClient(idTask))
// //{
// // GetGameUIMan().MessageBox("", GetStringFromTable(10714), MB_OK, A3DCOLORRGBA(255, 255, 255, 160));
// //}
// //else
// {
// UnityGameSession.c2s_CmdNPCSevAcceptTask(idTask, 0, 0);
// }
// GetGameUIMan().EndNPCService();
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_COMPLETE_TASK)
// {
// AWARD_DATA ad = new AWARD_DATA();
// talk_proc.option opt = (talk_proc.option)pData;
// CECTaskInterface pTask = GetHostPlayer().GetTaskInterface();
//
// pTask.GetAwardCandidates(opt.param, ref ad);
// if (ad.m_ulCandItems > 1)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_Award");
// //CDlgAward pAward = (pShow1) as CDlgAward;
// //if (pAward) pAward.UpdateAwardItem(opt.param, true);
// }
// else
// {
// UnityGameSession.c2s_CmdNPCSevReturnTask((int)opt.param, 0);
// GetGameUIMan().EndNPCService();
// }
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_GIVE_TASK_MATTER)
// {
// talk_proc.option opt = (talk_proc.option)pData;
// UnityGameSession.c2s_CmdNPCSevTaskMatter((int)opt.param);
// GetGameUIMan().EndNPCService();
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_STORAGE)
// {
// //if (GetHostPlayer().TrashBoxHasPsw())
// //{
// // pShow1 = m_pAUIManager.GetDialog("Win_InputString");
// // pShow1.GetDlgItem("DEFAULT_Txt_Input").SetText(_AL(""));
// //}
// //else
// // g_pGame.GetGameSession().c2s_CmdNPCSevOpenTrash("");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_STORAGE_PASSWORD)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_InputString3");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_ACCOUNT_STORAGE)
// {
// //if (CECCrossServer::Instance().IsOnSpecialServer())
// //{
// // GetGameUIMan().ShowErrorMsg(10130);
// // GetGameUIMan().EndNPCService();
// //}
// //else g_pGame.GetGameSession().c2s_CmdNPCSevOpenAccountBox();
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_ENGRAVE)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_Engrave");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// }
// else if (idFunction == (int)SERVICE_TYPE.NPC_RANDPROP)
// {
// pShow1 = m_pAUIManager.GetDialog("Win_RandProp");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// GetHostPlayer().PrepareNPCService(iService);
// pShow1.SetDataPtr(pData, "ptr_NPC_RANDPROP_SERVICE");
// }
// else if (idFunction == (int)SERVICE_TYPE.TALK_RETURN)
// {
// OnCommand_back("back");
// return true; // To avoid to close NPC dialog.
// }
// else if (idFunction == (int)SERVICE_TYPE.TALK_EXIT)
// {
// GetGameUIMan().EndNPCService();
//
// int idCurFinishTask = GetGameUIMan().m_idCurFinishTask;
// if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK && idCurFinishTask > 0)
// {
// GetHostPlayer().GetTaskInterface().OnUIDialogEnd((uint)idCurFinishTask);
// GetGameUIMan().m_idCurFinishTask = -1;
// }
// }
// else if (idFunction == (int)SERVICE_TYPE.TALK_GIVEUP_TASK)
// {
// talk_proc.option opt = (talk_proc.option)pData;
// GetHostPlayer().GetTaskInterface().GiveUpTask(opt.param);
// GetGameUIMan().EndNPCService();
// }
// else
// {
// //GetHostPlayer().GetPack(IVTRTYPE_PACK).UnfreezeAllItems();
// GetGameUIMan().EndNPCService();
// }
//
// if (pShow1)
// {
// DATA_TYPE DataType = new DATA_TYPE();
// elementdataman pDataMan = ElementDataManProvider.GetElementDataMan();
//
// pDataMan.get_data_ptr((uint)iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
//
// //dat update uimanager stack commented
// // pShow1.Show(true);
//
// if (pShow2)
// {
// //POINT ptPos = pShow1.GetPos();
// //if (ptPos.x == 0 && ptPos.y == 0)
// //{
// // SIZE s1 = pShow1.GetSize();
// // SIZE s2 = pShow2.GetSize();
// // A3DVIEWPORTPARAM* p = m_pA3DEngine.GetActiveViewport().GetParam();
// // int x, y = (p.Height - max(s1.cy, s2.cy)) / 2;
//
// // x = (p.Width - s1.cx - s2.cx) / 2;
//
// // // old : pShow1.SetPos(x, y);
// // pShow1.SetPosEx(x, y);
//
// // x += s1.cx;
//
// // // old : pShow2.SetPos(x, y);
// // pShow2.SetPosEx(x, y);
// //}
//
// //dat update uimanager stack commented
// // pShow2.Show(true);
// }
// }
// //CloseDialogue();
//
// return true;
// }
// C++ port note:
// The original UI adds an "EXIT" line, but it still needs a valid TALKPROC function id
// (TALK_EXIT) so the click can be dispatched.
private void AddExitChoice()
{
// Add "EXIT" choice.
m_pLst_Main.AddString(GetStringFromTable(503));
int nIndex = m_pLst_Main.GetCount() - 1;
uint idExit = unchecked((uint)(int)SERVICE_TYPE.TALK_EXIT); // 0x80000012
m_pLst_Main.SetItemData(nIndex, idExit);
m_pLst_Main.SetItemDataPtr(nIndex, null);
m_pLst_Main.SetItemIcon(nIndex, m_iconExit);
}
private void ApplyListIcons(Sprite defaultIcon)
{
int count = m_pLst_Main.GetCount();
if (count <= 0) return;
for (int i = 0; i < count - 1; i++)
m_pLst_Main.SetItemIcon(i, defaultIcon);
// Exit is always last.
m_pLst_Main.SetItemIcon(count - 1, m_iconExit);
}
public void OnCommand_back(string szCommand)
{
NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence;
if (GetData() == NPC_DIALOG.NPC_DIALOG_TALK ||
GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK)
{
int i, j, nIndex;
string strText;
talk_proc pTalk = (talk_proc)GetDataPtr("ptr_talk_proc");
uint id = 0;//(uint)m_pTxt_Content.GetData();
CECTaskInterface pTask = GetHostPlayer().GetTaskInterface();
if (0xFFFFFFFF == id) // No any more parent window.
{
if (GetData() == NPC_DIALOG.NPC_DIALOG_TALK)
PopupNPCDialog(pCurNPCEssence.Value);
else if (pCurNPCEssence != null)
{
// ̸صб
// ȵӭӭǷб
PopupNPCDialog(pCurNPCEssence.Value);
if (GetData() != NPC_DIALOG.NPC_DIALOG_TASK_LIST)
{
// ӭб
// µб
PopupTaskDialog(false);
AddExitChoice();
ApplyListIcons(m_iconTask);
}
}
}
else
{
for (i = 0; i < pTalk.num_window; i++)
{
if (id != pTalk.windows[i].id) continue;
string text = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pTalk.windows[i].talk_text));
m_pTxt_Content.SetText(pTask.FormatTaskTalk(text));
ResizeContent();
//m_pTxt_Content.SetData(pTalk.windows[i].id_parent);
m_pLst_Main.ResetContent();
for (j = 0; j < pTalk.windows[i].num_option; j++)
{
strText = GetStringFromTable(249);
strText += pTalk.windows[i].options[j].text;
m_pLst_Main.AddString(strText);
nIndex = m_pLst_Main.GetCount() - 1;
m_pLst_Main.SetItemData(nIndex, pTalk.windows[i].options[j].id);
m_pLst_Main.SetItemDataPtr(nIndex, pTalk.windows[i].options[j]);
}
break;
}
}
}
else if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_LIST)
{
PopupNPCDialog(pCurNPCEssence.Value);
if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_LIST)
{
// ǰNPCֻط򷵻صͬ˳NPC
CloseDialogue();
GetGameUIMan().EndNPCService();
}
}
else if (GetData() == NPC_DIALOG.NPC_DIALOG_ESSENCE)
{
CloseDialogue();
GetGameUIMan().EndNPCService();
}
}
void SelectListItem(int index)
{
m_pLst_Main.SetCurSel(index);
int nCurSel = m_pLst_Main.GetCurSel();
if (nCurSel < 0 || nCurSel >= m_pLst_Main.GetCount())
return;
int i, j, nIndex;
string strText;
DATA_TYPE DataType = new DATA_TYPE();
CECTaskInterface pTask = GetHostPlayer().GetTaskInterface();
if (GetData() == NPC_DIALOG.NPC_DIALOG_TALK ||
GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK)
{
uint id = m_pLst_Main.GetItemData(nCurSel, 0, "");
talk_proc pTalk = (talk_proc)GetDataPtr("ptr_talk_proc");
if (CECGameUIMan.TALKPROC_IS_TERMINAL(id)) // Ternimal.
{
for (i = 0; i < pTalk.num_window; i++)
{
if (id != pTalk.windows[i].id) continue;
// TO DO: fix later
// TO DO: show popup with content is talk_text and 1 btn OK
//GetGameUIMan().MessageBox("", pTask.FormatTaskTalk(pTalk.windows[i].talk_text),
// MB_OK, A3DCOLORRGBA(255, 255, 255, 160));
GetGameUIMan().EndNPCService();
//CloseDialogue();
break;
}
}
else if (CECGameUIMan.TALKPROC_IS_FUNCTION(id)) // Function.
{
if (GetGameUIMan().m_pCurNPCEssence != null)
{
NPC_ESSENCE pEssence = GetGameUIMan().m_pCurNPCEssence.Value;
int nIndex1 = (int)CECGameUIMan.TALKPROC_GET_FUNCTION_ID(id);
uint[] a_uiService =
{
pEssence.id_talk_service, // ½»Ì¸µÄ·þÎñID
pEssence.id_sell_service, // ³öÊÛÉÌÆ·µÄ·þÎñID
pEssence.id_buy_service, // ÊÕ¹ºÆ·µÄ·þÎñID
pEssence.id_repair_service, // ÐÞÀíÉÌÆ·µÄ·þÎñID
pEssence.id_install_service, // °²×°ÏâǶƷµÄ·þÎñID
pEssence.id_uninstall_service, // ²ð³ýÏâǶƷµÄ·þÎñID
pEssence.id_task_out_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñ·þÎñ
pEssence.id_task_in_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ÑéÖ¤Íê³ÉÈÎÎñ·þÎñ
pEssence.id_task_matter_service, // ÈÎÎñÏà¹ØµÄ·þÎñID: ·¢·ÅÈÎÎñÎïÆ··þÎñ
pEssence.id_skill_service, // ½ÌÊÚ¼¼ÄܵķþÎñID
pEssence.id_heal_service, // ÖÎÁƵķþÎñID
pEssence.id_transmit_service, // ´«Ë͵ķþÎñID
pEssence.id_transport_service, // ÔËÊäµÄ·þÎñID
pEssence.id_proxy_service, // ´úÊ۵ķþÎñID
pEssence.id_storage_service, // ²Ö¿âµÄ·þÎñID
pEssence.id_make_service, // Éú²úµÄ·þÎñID
pEssence.id_decompose_service, // ·Ö½âµÄ·þÎñID
pEssence.id_identify_service, // ¼ø¶¨µÄ·þÎñID
0, // Talk return.
0, // Talk exit.
0 // Storage password.
};
//TO DO: fix later
// This show popup service NPC
PopupCorrespondingServiceDialog((int)id,
(int)a_uiService[nIndex1], m_pLst_Main.GetItemDataPtr(nCurSel, 0, ""));
}
else
{
//TO DO: fix later
// This show popup service NPC
PopupCorrespondingServiceDialog(
(int)id, 0, m_pLst_Main.GetItemDataPtr(nCurSel, 0, ""));
}
}
else // Window.
{
for (i = 0; i < pTalk.num_window; i++)
{
if (id != pTalk.windows[i].id) continue;
string talkText = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pTalk.windows[i].talk_text));
m_pTxt_Content.SetText(pTask.FormatTaskTalk(talkText));
ResizeContent();
//m_pTxt_Content.SetData(pTalk.windows[i].id_parent);
m_pLst_Main.ResetContent();
for (j = 0; j < pTalk.windows[i].num_option; j++)
{
strText = GetStringFromTable(249);
strText += pTalk.windows[i].options[j].text;
m_pLst_Main.AddString(strText);
nIndex = m_pLst_Main.GetCount() - 1;
m_pLst_Main.SetItemData(nIndex, pTalk.windows[i].options[j].id);
m_pLst_Main.SetItemDataPtr(nIndex, pTalk.windows[i].options[j]);
}
break;
}
}
}
else if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_LIST)
{
if (nCurSel == m_pLst_Main.GetCount() - 1)
{
CloseDialogue();
GetGameUIMan().EndNPCService();
}
else
{
//if (CDlgAutoHelp::IsAutoHelp())
//{
// UINT64 taskid = m_pLst_Main.GetItemData64(nCurSel, 0, "TaskID");
// CDlgWikiShortcut::PopQuestWiki(GetGameUIMan(), (int)taskid);
//}
//else
{
talk_proc pTalk = (talk_proc)m_pLst_Main.GetItemDataPtr(nCurSel, 0, "");
GetGameUIMan().PopupNPCDialog(pTalk);
//m_pTxt_Content.SetData(0xFFFFFFFF);
SetData(NPC_DIALOG.NPC_DIALOG_TASK_TALK, "");
}
}
}
else if (GetData() == NPC_DIALOG.NPC_DIALOG_ESSENCE)
{
if (nCurSel == m_pLst_Main.GetCount() - 1)
{
CloseDialogue();
GetGameUIMan().EndNPCService();
return;
}
int iService = (int)m_pLst_Main.GetItemData(nCurSel, 0, "");
NPC_ESSENCE? pEssence = GetGameUIMan().m_pCurNPCEssence;
if (pEssence != null)
{
if (iService == CDLGNPC.CDLGNPC_FORGET && (pEssence?.combined_services & 0x01) != 0)
{
// TO DO: fix later
//PAUIDIALOG pMsgBox;
//GetGameUIMan().MessageBox("Game_ForgetSkill", GetStringFromTable(559),
// MB_OKCANCEL, A3DCOLORRGBA(255, 255, 255, 160), &pMsgBox);
//pMsgBox.SetDataPtr(m_pLst_Main.GetItemDataPtr(nCurSel));
GetGameUIMan().EndNPCService();
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CDLGNPC_EQUIPSLOT && (pEssence?.combined_services & 0x02) != 0)
{
//CloseDialogue();
// TO DO: fix later
//GetGameUIMan().m_pDlgInventory.Show(true);
//GetGameUIMan().m_pDlgEquipSlot.Show(true);
return;
}
else if ((pEssence?.combined_services & 0x10) != 0
&& (iService == CDLGNPC.CDLGNPC_FACTION_CREATE
|| iService == CDLGNPC.CDLGNPC_FACTION_UPGRADE
|| iService == CDLGNPC.CDLGNPC_FACTION_RENAME
|| iService == CDLGNPC.CDLGNPC_FACTION_DISMISS))
{
// TO DO: fix later
//if (CECCrossServer::Instance().IsOnSpecialServer())
//{
// GetGameUIMan().ShowErrorMsg(10130);
//}
//else if (iService == CDLGNPC.CDLGNPC_FACTION_CREATE)
//{
// if (GetHostPlayer().GetBasicProps().iLevel < 20 ||
// GetHostPlayer().GetMoneyAmount() < 100000)
// {
// GetGameUIMan().MessageBox("", GetStringFromTable(607),
// MB_OK, A3DCOLORRGBA(255, 255, 255, 160));
// }
// else
// GetGameUIMan().m_pDlgGuildCreate.Show(true);
//}
//else if (iService == CDLGNPC.CDLGNPC_FACTION_UPGRADE)
//{
// int idFaction = GetHostPlayer().GetFactionID();
// CECFactionMan pFMan = EC_Game.GetFactionMan();
// Faction_Info pInfo = pFMan.GetFaction(idFaction);
// if (pInfo)
// {
// if (pInfo.GetLevel() == 0)
// {
// GetGameUIMan().MessageBox(
// "Faction_Upgrade", GetStringFromTable(608),
// MB_OKCANCEL, A3DCOLORRGBA(255, 255, 255, 160));
// }
// else if (pInfo.GetLevel() == 1)
// {
// GetGameUIMan().MessageBox(
// "Faction_Upgrade", GetStringFromTable(690),
// MB_OKCANCEL, A3DCOLORRGBA(255, 255, 255, 160));
// }
// else if (pInfo.GetLevel() == 2)
// {
// GetGameUIMan().MessageBox("", GetStringFromTable(609),
// MB_OK, A3DCOLORRGBA(255, 255, 255, 160));
// }
// else
// {
// GetGameUIMan().MessageBox("", GetStringFromTable(610),
// MB_OK, A3DCOLORRGBA(255, 255, 255, 160));
// }
// }
//}
//else if (iService == CDLGNPC_FACTION_RENAME)
//{
// CDlgModifyName* pDlgModifyName = GetGameUIMan().m_pDlgModifyName;
// if (!pDlgModifyName.IsShow())
// {
// pDlgModifyName.SetPolicy(new CDlgFactionRenamePolicy());
// pDlgModifyName.Show(true);
// }
//}
//else if (iService == CDLGNPC_FACTION_DISMISS)
//{
// GetGameUIMan().MessageBox("Faction_Dismiss", GetStringFromTable(596),
// MB_OKCANCEL, A3DCOLORRGBA(255, 255, 255, 160));
//}
//GetGameUIMan().EndNPCService();
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CDLGNPC_FACE && (pEssence?.combined_services & 0x20) != 0)
{
// TO DO: fix later
//if (GetHostPlayer().IsFlying() ||
// GetHostPlayer().IsSitting() ||
// GetHostPlayer().IsShapeChanged())
//{
// GetGameUIMan().MessageBox("", GetStringFromTable(603),
// MB_OK, A3DCOLORRGBA(255, 255, 255, 160));
//}
//else
//{
// GetGameUIMan().m_pDlgInventory.Show(true);
// GetGameUIMan().m_pDlgFaceLift.Show(true);
// GetGameUIMan().EndNPCService();
// CloseDialogue();
//}
return;
}
else if (iService == CDLGNPC.CDLGNPC_MAIL && (pEssence?.combined_services & 0x40) != 0)
{
// TO DO: fix later
//CloseDialogue();
//GetGameUIMan().m_pDlgMailList.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_AUCTION && (pEssence?.combined_services & 0x80) != 0)
{
//CloseDialogue();
// TO DO: fix later
//if (CECCrossServer::Instance().IsOnSpecialServer())
//{
// GetGameUIMan().ShowErrorMsg(10130);
// GetGameUIMan().EndNPCService();
//}
//else
//{
// GetGameSession().auction_AttendList();
// GetGameUIMan().m_pDlgAuctionBuyList.Show(true);
// GetGameUIMan().m_pDlgAuctionBuyList.m_nIDNext = 0;
// GetGameUIMan().m_pDlgAuctionBuyList.m_nPageNext = 0;
// string szText;
// szText.Format(GetStringFromTable(3501), GetStringFromTable(3509));
// GetGameUIMan().m_pDlgAuctionBuyList.m_pTxt_RefreshStatus.SetText(szText);
// GetGameUIMan().m_pDlgAuctionBuyList.m_pTxt_Search.
// SetText(GetStringFromTable(3509));
//}
return;
}
else if (iService == CDLGNPC.CDLGNPC_DOUBLEEXP && (pEssence?.combined_services & 0x100) != 0)
{
//CloseDialogue();
// TO DO: fix later
//GetGameUIMan().m_pDlgDoubleExp.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_PETHATCH && (pEssence?.combined_services & 0x200) != 0)
{
//CloseDialogue();
// TO DO: fix later
//GetGameUIMan().m_pDlgInventory.Show(true);
//GetGameUIMan().m_pDlgPetHatch.Show(true);
//var dlgPetHatch = GetGameUIMan().GetDialog("DlgPetHatch");
//dlgPetHatch.Show(true);
CECUIManager.Instance.ShowUI("DlgPetHatch");
return;
}
else if (iService == CDLGNPC.CDLGNPC_PETREC && (pEssence?.combined_services & 0x400) != 0)
{
//CloseDialogue();
// TO DO: fix later
//GetGameUIMan().m_pDlgPetList.Show(true);
//GetGameUIMan().m_pDlgPetRec.Show(true);
//var dlgPetRec = GetGameUIMan().GetDialog("DlgPetRec");
//dlgPetRec.Show(true);
CECUIManager.Instance.ShowUI("DlgPetRec");
return;
}
else if (iService == CDLGNPC.CDLGNPC_BATTLECHALLENGE && (pEssence?.combined_services & 0x800) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgGuildMap.SetType(CDlgGuildMap::FACTIONMAP_TYPE_CHALLENGE);
//GetGameUIMan().m_pDlgGuildMap.Show(true);
//GetGameUIMan().m_pDlgGMapStatus2.Show(true);
//GetGameUIMan().m_pDlgGMapStatus2.SetCanMove(false);
return;
}
else if (iService == CDLGNPC.CDLGNPC_BATTLEENTER && (pEssence?.combined_services & 0x800) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgGuildMap.SetType(CDlgGuildMap::FACTIONMAP_TYPE_ENTER);
//GetGameUIMan().m_pDlgGuildMap.Show(true);
//GetGameUIMan().m_pDlgGMapStatus1.Show(true);
//GetGameUIMan().m_pDlgGMapStatus1.SetCanMove(false);
return;
}
else if (iService == CDLGNPC.CDLGNPC_BATTLELEAVE && (pEssence?.combined_services & 0x1000) != 0)
{
//CloseDialogue();
//GetGameUIMan().MessageBox("Game_BattleLeave", GetStringFromTable(725),
// MB_OKCANCEL, A3DCOLORRGBA(255, 255, 255, 160));
return;
}
else if (iService == CDLGNPC.CDLGNPC_GOLDTRADE && (pEssence?.combined_services & 0x2000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgGoldTrade.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_EQUIPREFINE && (pEssence?.combined_services & 0x4000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgEquipRefine.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_EQUIPDYE && (pEssence?.combined_services & 0x8000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgEquipDye.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
//GetGameUIMan().m_pDlgFittingRoom.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_PETDYE && (pEssence?.combined_services & 0x8000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgPetDye.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
//GetGameUIMan().m_pDlgPetList.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_REFINETRANS && (pEssence?.combined_services & 0x10000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgRefineTrans.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_ELFPRORESET && (pEssence?.combined_services & 0x20000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgELFXiDian.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_ELFGENIUSRESET && (pEssence?.combined_services & 0x40000) != 0)
{
//еĶԻ°¿ò
//CloseDialogue();
//GetGameUIMan().m_pDlgELFGeniusReset.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_ELFFORGET && (pEssence?.combined_services & 0x80000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgELFRetrain.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_ELFREFINE && (pEssence?.combined_services & 0x100000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgELFRefine.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_ELFREFINETRANS && (pEssence?.combined_services & 0x100000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgELFRefineTrans.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_ELFTOPILL && (pEssence?.combined_services & 0x200000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgELFToPill.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_ELFEQUIPOFF && (pEssence?.combined_services & 0x400000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgELFEquipRemove.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_EQUIPREPAIR && (pEssence?.combined_services & 0x800000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgDamageRep.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_WEBTRADE && (pEssence?.combined_services & 0x1000000) != 0)
{
//CloseDialogue();
//if (GetGameUIMan().m_pDlgAutoLock.IsLocked())
//{
// GetGameUIMan().AddChatMessage(GetStringFromTable(5520), GP_CHAT_MISC);
// GetGameUIMan().EndNPCService();
//}
//else if (CECCrossServer::Instance().IsOnSpecialServer())
//{
// GetGameUIMan().ShowErrorMsg(10130);
// GetGameUIMan().EndNPCService();
//}
//else
//{
// GetGameUIMan().m_pDlgWebViewProduct.Show(true);
//}
return;
}
else if (iService == CDLGNPC.CDLGNPC_GODEVILCONVERT && (pEssence?.combined_services & 0x2000000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgGodEvilConvert.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_WEDDING_BOOK && (pEssence?.combined_services & 0x4000000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgWedding.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_WEDDING_INVITE && (pEssence?.combined_services & 0x4000000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgWeddingInvite.Show(true);
return;
}
else if (iService == CDLGNPC.CGLDNPC_FORTRESS_CREATE && (pEssence?.combined_services & 0x8000000) != 0)
{
// ´´½¨»ùµØ
//CECHostPlayer pHost = GetHostPlayer();
//int idFaction = pHost.GetFactionID();
//CECFactionMan pFMan = EC_Game.GetFactionMan();
//Faction_Info pInfo = pFMan.GetFaction(idFaction);
//FACTION_FORTRESS_CONFIG pConfig = pHost.GetFactionFortressConfig();
//if (pInfo && pConfig)
//{
// string strMsg = GetStringFromTable(9114);
// string strTemp;
// string strColorRed = _AL("^FF0000");
// string strColorWhite = _AL("^FFFFFF");
// string strNextLine = _AL("\r");
// bool bOK = true;
// // °ïÅɵȼ¶
// if (pInfo.GetLevel() < pConfig.require_level)
// bOK = false;
// strTemp.Format(GetStringFromTable(9112)
// , (pInfo.GetLevel() < pConfig.require_level) ? strColorRed : strColorWhite
// , pConfig.require_level + 1);
// strMsg += strNextLine;
// strMsg += strTemp;
// // µÀ¾ßÐèÇó
// CECInventory* pPack = pHost.GetPack();
// int nItems = sizeof(pConfig.require_item) / sizeof(pConfig.require_item[0]);
// for (int i = 0; i < nItems; ++i)
// {
// if (pConfig.require_item[i].id && pConfig.require_item[i].count > 0)
// {
// int count = pPack.GetItemTotalNum(pConfig.require_item[i].id);
// if (count < pConfig.require_item[i].count)
// bOK = false;
// CECIvtrItem* pItem = CECIvtrItem::CreateItem(pConfig.require_item[i].id, 0, 1);
// strTemp.Format(GetStringFromTable(9113)
// , (count < pConfig.require_item[i].count) ? strColorRed : strColorWhite
// , pItem.GetName()
// , pConfig.require_item[i].count);
// delete pItem;
// strMsg += strNextLine;
// strMsg += strTemp;
// }
// }
// strMsg += strNextLine;
// strMsg += GetStringFromTable(bOK ? 9110 : 9111);
// if (!bOK)
// {
// // Ìõ¼þ²»Âú×㣬ÏÔʾ¾ßÌåÐÅÏ¢
// GetGameUIMan().MessageBox("", strMsg, MB_OK, A3DCOLORRGB(255, 255, 255));
// GetGameUIMan().EndNPCService();
// }
// else
// {
// // Ìõ¼þÂú×㣬µ¯³ö¶Ô»°¿òÈ·ÈÏ
// GetGameUIMan().MessageBox("Fortress_Create", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160));
// }
//}
//else
//{
// GetGameUIMan().EndNPCService();
//}
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CGLDNPC_FORTRESS_WAR && (pEssence?.combined_services & 0x8000000) != 0)
{
// »ùµØÕ½
//PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressWar");
//if (pDlg1)
//{
// pDlg1.Show(true);
//}
//else
//{
// GetGameUIMan().EndNPCService();
//}
////CloseDialogue();
return;
}
else if (iService == CDLGNPC.CGLDNPC_FORTRESS_ENTER && (pEssence?.combined_services & 0x8000000) != 0)
{
// ½øÈë»ùµØ
//GetGameSession().factionFortress_Enter(GetHostPlayer().GetFactionID());
//GetGameUIMan().EndNPCService();
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CGLDNPC_FORTRESS_WARLIST && (pEssence?.combined_services & 0x8000000) != 0)
{
// »ùµØ¶ÔÕ½±í
//PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressWarList");
//if (pDlg1)
//{
// pDlg1.Show(true);
//}
//else
//{
// GetGameUIMan().EndNPCService();
//}
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CGLDNPC_FORTRESS_UPGRADE && (pEssence?.combined_services & 0x10000000) != 0)
{
// »ùµØÉý¼¶
//PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressInfo");
//PAUIDIALOG pDlg2 = GetGameUIMan().GetDialog("Win_FortressBuild");
//if (pDlg1 && pDlg2)
//{
// pDlg1.Show(true);
// pDlg2.Show(true);
//}
//else
//{
// GetGameUIMan().EndNPCService();
//}
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CGLDNPC_FORTRESS_HANDIN_MATERIAL && (pEssence?.combined_services & 0x10000000) != 0)
{
// ½ÉÄɲÄÁÏ
//PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressInfo");
//PAUIDIALOG pDlg2 = GetGameUIMan().GetDialog("Win_FortressMaterial");
//if (pDlg1 && pDlg2)
//{
// pDlg1.Show(true);
// pDlg2.Show(true);
//}
//else
//{
// GetGameUIMan().EndNPCService();
//}
////CloseDialogue();
return;
}
else if (iService == CDLGNPC.CGLDNPC_FORTRESS_HANDIN_CONTRIB && (pEssence?.combined_services & 0x10000000) != 0)
{
// ½ÉÄɹ±Ï×¶È
//PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressInfo");
//PAUIDIALOG pDlg2 = GetGameUIMan().GetDialog("Win_FortressContrib");
//if (pDlg1 && pDlg2)
//{
// pDlg1.Show(true);
// pDlg2.Show(true);
//}
//else
//{
// GetGameUIMan().EndNPCService();
//}
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CGLDNPC_FORTRESS_LEAVE && (pEssence?.combined_services & 0x10000000) != 0)
{
// À뿪»ùµØ
//GetGameSession().c2s_CmdNPCSevFactionFortressLeave();
GetGameUIMan().EndNPCService();
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CGLDNPC_FORTRESS_EXCHANGE_MATERIAL && (pEssence?.combined_services & 0x200000000) != 0)
{
// ¶Ò»»²ÄÁÏ
//PAUIDIALOG pDlg1 = GetGameUIMan().GetDialog("Win_FortressInfo");
//PAUIDIALOG pDlg2 = GetGameUIMan().GetDialog("Win_FortressExchange");
//if (pDlg1 && pDlg2)
//{
// pDlg1.Show(true);
// pDlg2.Show(true);
//}
//else
//{
// GetGameUIMan().EndNPCService();
//}
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CDLGNPC_VIEW_TRASHBOX && (pEssence?.combined_services & 0x40000000) != 0)
{
//GetGameSession().c2s_CmdNPCSevViewTrash();
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CDLGNPC_VIEW_DPS_DPH_RANK && (pEssence?.combined_services & 0x80000000) != 0)
{
//GetGameUIMan().m_pDlgEarthBagRank.Show(true);
//CloseDialogue();
return;
}
else if ((iService == CDLGNPC.CDLGNPC_FORCE_QUIT || iService == CDLGNPC.CDLGNPC_FORCE_JOIN) && pEssence?.id_force_service > 0)
{
//void* pData = m_pLst_Main.GetItemDataPtr(nCurSel);
//NPC_FORCE_SERVICE* pService = (NPC_FORCE_SERVICE*)pData;
//int npcForce = pService.force_id;
//PAUIDIALOG pDlg = NULL;
//if (iService == CDLGNPC_FORCE_QUIT) pDlg = GetGameUIMan().GetDialog("Win_ForceQuit");
//else if (iService == CDLGNPC_FORCE_JOIN) pDlg = GetGameUIMan().GetDialog("Win_ForceJoin");
//if (CECCrossServer::Instance().IsOnSpecialServer())
//{
// GetGameUIMan().ShowErrorMsg(10130);
// GetGameUIMan().EndNPCService();
//}
//else if (pDlg)
//{
// pDlg.SetData(npcForce);
// pDlg.Show(true);
//}
//CloseDialogue();
return;
}
else if ((iService == CDLGNPC.CDLGNPC_JOIN_COUNTRY || iService == CDLGNPC.CDLGNPC_QUIT_COUNTRY)
&& (pEssence?.combined_services2 & 0x00000001) != 0)
{
//if (iService == CDLGNPC.CDLGNPC_JOIN_COUNTRY)
//{
// CECHostPlayer* pHost = GetHostPlayer();
// string strMsg = GetStringFromTable(9765);
// string strTemp;
// string strColorRed = _AL("^FF0000");
// string strColorWhite = _AL("^FFFFFF");
// string strNextLine = _AL("\r");
// bool bOK(true);
// // Íæ¼ÒµÈ¼¶
// const int REQUIRE_LEVEL = CECUIConfig::Instance().GetGameUI().nCountryWarEnterLevel;
// int iLevel = GetHostPlayer().GetMaxLevelSofar();
// if (iLevel < REQUIRE_LEVEL) bOK = false;
// strTemp.Format(GetStringFromTable(9766)
// , (iLevel < REQUIRE_LEVEL) ? strColorRed : strColorWhite
// , REQUIRE_LEVEL);
// strMsg += strNextLine;
// strMsg += strTemp;
// // µÀ¾ßÐèÇó
// const int REQUIRE_ITEM = CECUIConfig::Instance().GetGameUI().nCountryWarEnterItem;
// const int REQUIRE_COUNT = CECUIConfig::Instance().GetGameUI().nCountryWarEnterItemCount;
// CECInventory* pPack = pHost.GetPack();
// int count = pPack.GetItemTotalNum(REQUIRE_ITEM);
// if (count < REQUIRE_COUNT) bOK = false;
// CECIvtrItem* pItem = CECIvtrItem::CreateItem(REQUIRE_ITEM, 0, 1);
// strTemp.Format(GetStringFromTable(9767)
// , (count < REQUIRE_COUNT) ? strColorRed : strColorWhite
// , pItem.GetName()
// , REQUIRE_COUNT);
// delete pItem;
// strMsg += strNextLine;
// strMsg += strTemp;
// // ×é¶ÓÒªÇóÊǶӳ¤
// CECTeam* pTeam = pHost.GetTeam();
// if (pTeam != NULL)
// {
// bool bLeader = (pTeam.GetLeaderID() == pHost.GetCharacterID());
// if (!bLeader) bOK = false;
// strTemp.Format(GetStringFromTable(9771)
// , (!bLeader) ? strColorRed : strColorWhite
// , GetStringFromTable(bLeader ? 9772 : 9773));
// strMsg += strNextLine;
// strMsg += strTemp;
// }
// // ÀäÈ´¼ì²é
// bool bCoolDown = pHost.GetCoolTime(GP_CT_COUNTRY_BATTLE_APPLY) > 0;
// if (bCoolDown) bOK = false;
// strTemp.Format(GetStringFromTable(9774)
// , bCoolDown ? strColorRed : strColorWhite
// , GetStringFromTable(bCoolDown ? 9772 : 9773));
// strMsg += strNextLine;
// strMsg += strTemp;
// strMsg += strNextLine;
// strMsg += GetStringFromTable(bOK ? 9768 : 9769);
// if (!bOK)
// {
// // Ìõ¼þ²»Âú×㣬ÏÔʾ¾ßÌåÐÅÏ¢
// GetGameUIMan().MessageBox("", strMsg, MB_OK, A3DCOLORRGB(255, 255, 255));
// GetGameUIMan().EndNPCService();
// }
// else
// {
// // Ìõ¼þÂú×㣬µ¯³ö¶Ô»°¿òÈ·ÈÏ
// PAUIDIALOG pDlgMsgBox = NULL;
// GetGameUIMan().MessageBox("Country_JoinLeave", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160), &pDlgMsgBox);
// pDlgMsgBox.SetData(1);
// }
//}
//else
//{
// // À뿪ȷ¶¨
// PAUIDIALOG pDlgMsgBox = NULL;
// string strMsg = GetStringFromTable(9770);
// GetGameUIMan().MessageBox("Country_JoinLeave", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160), &pDlgMsgBox);
// pDlgMsgBox.SetData(2);
//}
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CDLGNPC_LEAVE_COUNTRY_WAR && (pEssence?.combined_services2 & 0x00000002) != 0)
{
// À뿪ȷ¶¨
string strMsg = GetStringFromTable(9915);
//GetGameUIMan().MessageBox("Country_LeaveWar", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160));
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CDLGNPC_EQUIP_MARK && (pEssence?.combined_services2 & 0x00000004) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgEquipMark.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_GOTO_SPECIALSERVER && (pEssence?.combined_services2 & 0x00000008) != 0)
{
//if (!CECCrossServer::Instance().IsOnSpecialServer())
//{
// CECHostPlayer* pHost = GetHostPlayer();
// string strMsg = GetStringFromTable(10134);
// string strTemp;
// string strColorRed = _AL("^FF0000");
// string strColorWhite = _AL("^FFFFFF");
// string strNextLine = _AL("\r");
// bool bOK(true);
// // Íæ¼ÒµÈ¼¶
// const int REQUIRE_LEVEL = CECUIConfig::Instance().GetGameUI().nCrossServerEnterLevel;
// int iLevel = GetHostPlayer().GetMaxLevelSofar();
// if (iLevel < REQUIRE_LEVEL) bOK = false;
// strTemp.Format(GetStringFromTable(9766)
// , (iLevel < REQUIRE_LEVEL) ? strColorRed : strColorWhite
// , REQUIRE_LEVEL);
// strMsg += strNextLine;
// strMsg += strTemp;
// // ÐÞÕæÒªÇó
// const int REQUIRE_LEVEL2 = CECUIConfig::Instance().GetGameUI().nCrossServerEnterLevel2;
// int iLevel2 = GetHostPlayer().GetBasicProps().iLevel2;
// if (iLevel2 < REQUIRE_LEVEL2) bOK = false;
// strTemp.Format(GetStringFromTable(10135)
// , (iLevel2 < REQUIRE_LEVEL2) ? strColorRed : strColorWhite
// , GetGameRun().GetLevel2NameForCondition(REQUIRE_LEVEL2));
// strMsg += strNextLine;
// strMsg += strTemp;
// // ÀäÈ´¼ì²é
// bool bCoolDown = pHost.GetCoolTime(GP_CT_CROSS_SERVER_APPLY) > 0;
// if (bCoolDown) bOK = false;
// strTemp.Format(GetStringFromTable(9774)
// , bCoolDown ? strColorRed : strColorWhite
// , GetStringFromTable(bCoolDown ? 9772 : 9773));
// strMsg += strNextLine;
// strMsg += strTemp;
// strMsg += strNextLine;
// strMsg += GetStringFromTable(bOK ? 10136 : 10137);
// if (!bOK)
// {
// // Ìõ¼þ²»Âú×㣬ÏÔʾ¾ßÌåÐÅÏ¢
// GetGameUIMan().MessageBox("", strMsg, MB_OK, A3DCOLORRGB(255, 255, 255));
// GetGameUIMan().EndNPCService();
// }
// else
// {
// // Ìõ¼þÂú×㣬µ¯³ö¶Ô»°¿òÈ·ÈÏ
// GetGameUIMan().MessageBox("CrossServer_GetIn", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160));
// }
//}
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CDLGNPC_GOTO_ORIGINALSERVER && (pEssence?.combined_services2 & 0x00000010) != 0)
{
//if (CECCrossServer::Instance().IsOnSpecialServer())
//{
// string strMsg = GetStringFromTable(10138);
// GetGameUIMan().MessageBox("CrossServer_GetOut", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160));
//}
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CDLGNPC_PLAYER_RENAME && (pEssence?.combined_services2 & 0x00000020) != 0)
{// ¸ÄÃû·þÎñ
//if (CECCrossServer::Instance().IsOnSpecialServer())
//{
// GetGameUIMan().ShowErrorMsg(10130);
// GetGameUIMan().EndNPCService();
//}
//else if (!CECUIConfig::Instance().GetGameUI().bEnablePlayerRename)
//{
// // 먦Æô¸ÄÃû·þÎñÔò²»ÏÔʾ¸Ã¶Ô»°¿ò
// GetGameUIMan().ShowErrorMsg(10152);
// GetGameUIMan().EndNPCService();
//}
//else
//{
// CDlgModifyName* pDlgModifyName = GetGameUIMan().m_pDlgModifyName;
// if (!pDlgModifyName.IsShow())
// {
// pDlgModifyName.SetPolicy(new CDlgPlayerRenamePolicy());
// pDlgModifyName.Show(true);
// }
//}
//CloseDialogue();
return;
}
else if (iService == CDLGNPC.CDLGNPC_STONE_CHANGE && (pEssence?.combined_services2 & 0x00000040) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgStoneChange.SetType(CDlgStoneChange::EM_ALL);
//GetGameUIMan().m_pDlgStoneChange.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_KING_SERVICE && (pEssence?.combined_services2 & 0x00000080) != 0)
{
//CloseDialogue();
//GetGameSession().king_GetCandidateStatus();
//GetHostPlayer().SetInKingService(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_OFFLINESHOP_SETTING && (pEssence?.combined_services2 & 0x00000100) != 0)
{
//CloseDialogue();
//if (g_pGame.GetConfigs().IsMiniClient() || glb_IsInMapForMiniClient())
//{
// GetGameUIMan().MessageBox("", GetStringFromTable(10713), MB_OK, A3DCOLORRGBA(255, 255, 255, 160));
// return;
//}
//// Get shop info
//GetGameSession().OffShop_GetMyShopInfo();
//GetHostPlayer().GetOfflineShopCtrl().SetNPCSevFlag(COfflineShopCtrl::NPCSEV_SETTING);
return;
}
else if (iService == CDLGNPC.CDLGNPC_OFFLINESHOP_SELLBUY && (pEssence?.combined_services2 & 0x00000100) != 0)
{
//CloseDialogue();
GetGameUIMan().EndNPCService();
//if (g_pGame.GetConfigs().IsMiniClient() || glb_IsInMapForMiniClient())
//{
// GetGameUIMan().MessageBox("", GetStringFromTable(10713), MB_OK, A3DCOLORRGBA(255, 255, 255, 160));
// return;
//}
//if (GetGameUIMan().m_pDlgAutoLock.IsLocked())
//{
// GetGameUIMan().AddChatMessage(GetStringFromTable(10524), GP_CHAT_MISC);
//}
//else
//{
// // Get shop info
// GetGameSession().OffShop_QueryShops(COfflineShopCtrl::OSTM_ALL);
// GetHostPlayer().GetOfflineShopCtrl().SetNPCSevFlag(COfflineShopCtrl::NPCSEV_SELLBUY);
//}
return;
}
else if (iService == CDLGNPC.CDLGNPC_SPLIT_FASHION && (pEssence?.combined_services2 & 0x00000200) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgFashionSplit.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_REINCARNATION && (pEssence?.combined_services2 & 0x00000400) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgReincarnation.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_GIFTCARD && (pEssence?.combined_services2 & 0x00000800) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgGiftCard.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_TRICKBATTLE && (pEssence?.combined_services2 & 0x00001000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgChariotWarApply.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_CARDRESPAWN && (pEssence?.combined_services2 & 0x00002000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgGenCardRespawn.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_QUERYCHARIOTAMOUNT && (pEssence?.combined_services2 & 0x00001000) != 0)
{
//CloseDialogue();
//GetGameSession().tankBattle_GetRank();
//GetGameUIMan().m_pDlgChariotRankList.SetNPCSevFlag(true);
//if (!GetGameUIMan().m_pDlgChariotRankList.IsShow())
// GetGameUIMan().m_pDlgChariotRankList.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_FLYSWORDIMPROVE && (pEssence?.combined_services2 & 0x00004000) != 0)
{
//CloseDialogue();
//GetGameUIMan().m_pDlgFlySwordImprove.Show(true);
//GetGameUIMan().m_pDlgInventory.Show(true);
return;
}
else if (iService == CDLGNPC.CDLGNPC_OPEN_FACTION_PVP && (pEssence?.combined_services2 & 0x00008000) != 0)
{
//CloseDialogue();
string strMsg = GetStringFromTable(11271);
//GetGameUIMan().MessageBox("Faction_PVP_Open", strMsg, MB_YESNO, A3DCOLORRGBA(255, 255, 255, 160));
return;
}
else if (iService == CDLGNPC.CDLGNPC_GOLD_SHOP
&& ((pEssence?.combined_services2 & 0x00010000) != 0 || (pEssence?.combined_services2 & 0x00020000) != 0))
{
//CloseDialogue();
//bool bEnableQShop = (pEssence.combined_services2 & 0x00010000);
//bool bEnableBackShop = (pEssence.combined_services2 & 0x00020000);
//if (bEnableQShop)
//{
// CECUIHelper::ShowQShop(pEssence.id, bEnableBackShop);
//}
//else if (bEnableBackShop)
//{
// CECUIHelper::ShowBackShop(pEssence.id, bEnableQShop);
//}
return;
}
else if (iService == CDLGNPC.CDLGNPC_PLAYER_CHANGE_GENDER && (pEssence?.combined_services2 & 0x00040000) != 0)
{
//if (GetGameUIMan().m_pDlgAutoLock.IsLocked())
//{
// GetGameUIMan().AddChatMessage(GetGameUIMan().GetStringFromTable(10524), GP_CHAT_MISC);
// GetGameUIMan().EndNPCService();
//}
//else if (CECCrossServer::Instance().IsOnSpecialServer())
//{
// GetGameUIMan().ShowErrorMsg(10130);
// GetGameUIMan().EndNPCService();
//}
//else if (!CECUIConfig::Instance().GetGameUI().bEnablePlayerChangeGender)
//{
// GetGameUIMan().ShowErrorMsg(10152);
// GetGameUIMan().EndNPCService();
//}
//else
//{
// CDlgSimpleCostItemService* pDlgSimpleCostItemService = GetGameUIMan().m_pDlgSimpleCostItemService;
// if (!pDlgSimpleCostItemService.IsShow())
// {
// GetHostPlayer().StopAutoFashion();
// pDlgSimpleCostItemService.SetPolicy(new CDlgChangeGenderPolicy());
// pDlgSimpleCostItemService.Show(true);
// }
//}
//CloseDialogue();
return;
}
}
int idFunction = 0, id_dialog = 0;
object pData = m_pLst_Main.GetItemDataPtr(nCurSel, 0, "");
ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE ||
DataType == DATA_TYPE.DT_NPC_TASK_OUT_SERVICE ||
DataType == DATA_TYPE.DT_NPC_TASK_MATTER_SERVICE)
{
// pop-up storage task dialog
if (DataType == DATA_TYPE.DT_NPC_TASK_OUT_SERVICE)
{
NPC_TASK_OUT_SERVICE pService = (NPC_TASK_OUT_SERVICE)pData;
if (!(pService.storage_id == 0 || pService.storage_open_item == 0))
{
PopupStorageTaskDialog(pService, false);
return;
}
}
PopupTaskDialog(false);
AddExitChoice();
ApplyListIcons(m_iconTask);
return;
}
else if (DataType == DATA_TYPE.DT_NPC_TALK_SERVICE)
{
NPC_TALK_SERVICE pService = (NPC_TALK_SERVICE)pData;
id_dialog = (int)pService.id_dialog;
idFunction = (int)SERVICE_TYPE.NPC_TALK;
}
else if (DataType == DATA_TYPE.DT_NPC_SELL_SERVICE)
{
NPC_SELL_SERVICE pService = (NPC_SELL_SERVICE)pData;
id_dialog = (int)pService.id_dialog;
idFunction = (int)SERVICE_TYPE.NPC_SELL;
}
else if (DataType == DATA_TYPE.DT_NPC_BUY_SERVICE)
{
NPC_BUY_SERVICE pService = (NPC_BUY_SERVICE)pData;
id_dialog = (int)pService.id_dialog;
idFunction = (int)SERVICE_TYPE.NPC_BUY;
}
else if (DataType == DATA_TYPE.DT_NPC_REPAIR_SERVICE)
{
NPC_REPAIR_SERVICE pService = (NPC_REPAIR_SERVICE)pData;
id_dialog = (int)pService.id_dialog;
idFunction = (int)SERVICE_TYPE.NPC_REPAIR;
}
else if (DataType == DATA_TYPE.DT_NPC_INSTALL_SERVICE)
{
NPC_INSTALL_SERVICE pService = (NPC_INSTALL_SERVICE)pData;
id_dialog = (int)pService.id_dialog;
idFunction = (int)SERVICE_TYPE.NPC_INSTALL;
}
else if (DataType == DATA_TYPE.DT_NPC_UNINSTALL_SERVICE)
{
NPC_UNINSTALL_SERVICE pService = (NPC_UNINSTALL_SERVICE)pData;
id_dialog = (int)pService.id_dialog;
idFunction = (int)SERVICE_TYPE.NPC_UNINSTALL;
}
else if (DataType == DATA_TYPE.DT_NPC_SKILL_SERVICE)
{
NPC_SKILL_SERVICE pService = (NPC_SKILL_SERVICE)pData;
id_dialog = (int)pService.id_dialog;
idFunction = (int)SERVICE_TYPE.NPC_SKILL;
}
else if (DataType == DATA_TYPE.DT_NPC_HEAL_SERVICE)
{
NPC_HEAL_SERVICE pService = (NPC_HEAL_SERVICE)pData;
id_dialog = (int)pService.id_dialog;
idFunction = (int)SERVICE_TYPE.NPC_HEAL;
}
else if (DataType == DATA_TYPE.DT_NPC_TRANSMIT_SERVICE)
{
NPC_TRANSMIT_SERVICE pService = (NPC_TRANSMIT_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_TRANSMIT;
}
else if (DataType == DATA_TYPE.DT_NPC_TRANSPORT_SERVICE)
{
NPC_TRANSPORT_SERVICE pService = (NPC_TRANSPORT_SERVICE)pData;
id_dialog = (int)pService.id_dialog;
idFunction = (int)SERVICE_TYPE.NPC_TRANSPORT;
}
else if (DataType == DATA_TYPE.DT_NPC_PROXY_SERVICE)
{
NPC_PROXY_SERVICE pService = (NPC_PROXY_SERVICE)pData;
id_dialog = (int)pService.id_dialog;
idFunction = (int)SERVICE_TYPE.NPC_PROXY;
}
else if (DataType == DATA_TYPE.DT_NPC_STORAGE_SERVICE)
{
NPC_STORAGE_SERVICE pService = (NPC_STORAGE_SERVICE)pData;
string strText1 = m_pLst_Main.GetText(nCurSel);
string strComp1 = (GetStringFromTable(249)) + (GetStringFromTable(253));
string strComp2 = (GetStringFromTable(249)) + (GetStringFromTable(8080));
if (string.Equals(strText1, strComp1, StringComparison.OrdinalIgnoreCase))
idFunction = (int)SERVICE_TYPE.NPC_STORAGE_PASSWORD;
else if (string.Equals(strText1, strComp2, StringComparison.OrdinalIgnoreCase))
idFunction = (int)SERVICE_TYPE.NPC_ACCOUNT_STORAGE;
else
idFunction = (int)SERVICE_TYPE.NPC_STORAGE;
}
else if (DataType == DATA_TYPE.DT_NPC_MAKE_SERVICE)
{
NPC_MAKE_SERVICE pService = (NPC_MAKE_SERVICE)pData;
string serviceName = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name));
// Log NPC_MAKE_SERVICE data when selected
BMLogger.Log($"SelectListItem - NPC_MAKE_SERVICE selected - ServiceID: {iService}, MakeServiceID: {pService.id}, Name: {serviceName}, MakeSkillID: {pService.id_make_skill}, ProduceType: {pService.produce_type}");
idFunction = (int)SERVICE_TYPE.NPC_MAKE;
}
else if (DataType == DATA_TYPE.DT_NPC_DECOMPOSE_SERVICE)
{
NPC_DECOMPOSE_SERVICE pService = (NPC_DECOMPOSE_SERVICE)pData;
string serviceName = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pService.name));
// Log NPC_DECOMPOSE_SERVICE data when selected
BMLogger.Log($"SelectListItem - NPC_DECOMPOSE_SERVICE selected - ServiceID: {iService}, DecomposeServiceID: {pService.id}, Name: {serviceName}, DecomposeSkillID: {pService.id_decompose_skill}");
BMLogger.Log($" Note: This decompose service is being treated as idFunction={SERVICE_TYPE.NPC_DECOMPOSE}");
idFunction = (int)SERVICE_TYPE.NPC_DECOMPOSE;
}
else if (DataType == DATA_TYPE.DT_NPC_IDENTIFY_SERVICE)
{
NPC_IDENTIFY_SERVICE pService = (NPC_IDENTIFY_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_IDENTIFY;
}
else if (DataType == DATA_TYPE.DT_NPC_WAR_TOWERBUILD_SERVICE)
{
NPC_WAR_TOWERBUILD_SERVICE pService = (NPC_WAR_TOWERBUILD_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_WAR_TOWERBUILD;
}
else if (DataType == DATA_TYPE.DT_NPC_RESETPROP_SERVICE)
{
NPC_RESETPROP_SERVICE pService = (NPC_RESETPROP_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_RESETPROP;
}
else if (DataType == DATA_TYPE.DT_NPC_PETNAME_SERVICE)
{
NPC_PETNAME_SERVICE pService = (NPC_PETNAME_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_PETNAME;
}
else if (DataType == DATA_TYPE.DT_NPC_PETLEARNSKILL_SERVICE)
{
NPC_PETLEARNSKILL_SERVICE pService = (NPC_PETLEARNSKILL_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_PETLEARNSKILL;
}
else if (DataType == DATA_TYPE.DT_NPC_PETFORGETSKILL_SERVICE)
{
NPC_PETFORGETSKILL_SERVICE pService = (NPC_PETFORGETSKILL_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_PETFORGETSKILL;
}
else if (DataType == DATA_TYPE.DT_NPC_EQUIPBIND_SERVICE)
{
NPC_EQUIPBIND_SERVICE pService = (NPC_EQUIPBIND_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_EQUIPBIND;
}
else if (DataType == DATA_TYPE.DT_NPC_EQUIPDESTROY_SERVICE)
{
NPC_EQUIPDESTROY_SERVICE pService = (NPC_EQUIPDESTROY_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_EQUIPDESTROY;
}
else if (DataType == DATA_TYPE.DT_NPC_EQUIPUNDESTROY_SERVICE)
{
NPC_EQUIPUNDESTROY_SERVICE pService = (NPC_EQUIPUNDESTROY_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_EQUIPUNDESTROY;
}
else if (DataType == DATA_TYPE.DT_NPC_ENGRAVE_SERVICE)
{
NPC_ENGRAVE_SERVICE pService = (NPC_ENGRAVE_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_ENGRAVE;
}
else if (DataType == DATA_TYPE.DT_NPC_RANDPROP_SERVICE)
{
NPC_RANDPROP_SERVICE pService = (NPC_RANDPROP_SERVICE)pData;
idFunction = (int)SERVICE_TYPE.NPC_RANDPROP;
}
if (id_dialog > 0)
{
object result = ElementDataManProvider.GetElementDataMan()
.get_data_ptr((uint)id_dialog, ID_SPACE.ID_SPACE_TALK, ref DataType);
if (result != null)
{
talk_proc pTalk = (talk_proc)result;
GetGameUIMan().PopupNPCDialog(pTalk);
//m_pTxt_Content.SetData(0xFFFFFFFF);
SetData(NPC_DIALOG.NPC_DIALOG_TALK, "");
}
}
//Show Mua item id = 0
else
{
object pData1 = m_pLst_Main.GetItemDataPtr(nCurSel, 0, "");
PopupCorrespondingServiceDialog(idFunction, iService, pData1);
}
}
}
bool PopupCorrespondingServiceDialog(int idFunction, int iService, object pData)
{
// AUIDialog pShow1 = null, pShow2 = null;
string dialogue1 = String.Empty, dialogue2 = String.Empty;
NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence;
uint npcID = pCurNPCEssence.HasValue ? pCurNPCEssence.Value.id : 0;
SERVICE_TYPE serviceNeedSetUpDialogue = SERVICE_TYPE.NPC_TALK;
AWARD_DATA ad;
talk_proc.option opt;
CECTaskInterface pTask;
ad.m_ulCandItems = 0;
opt.param = 0;
// Check if the integer matches any enum value
if (Enum.IsDefined(typeof(SERVICE_TYPE), idFunction))
{
SERVICE_TYPE k = (SERVICE_TYPE)idFunction;
}
if (idFunction == (int)SERVICE_TYPE.NPC_SELL || idFunction == (int)SERVICE_TYPE.NPC_BUY)
{
//Button pButton;
//pShow1 = m_pAUIManager.GetDialog("Win_Shop");
//pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
//GetHostPlayer().PrepareNPCService(iService);
//GetGameUIMan().m_pDlgShop.UpdateShop(1);
//if (pCurNPCEssence && pCurNPCEssence.id_repair_service)
//{
// pShow1.GetDlgItem("Btn_Repair").Show(true);
// pShow1.GetDlgItem("Btn_RepairAll").Show(true);
//}
//else
//{
// pShow1.GetDlgItem("Btn_Repair").Show(false);
// pShow1.GetDlgItem("Btn_RepairAll").Show(false);
//}
//pButton = (PAUISTILLIMAGEBUTTON)pShow2.GetDlgItem("Btn_NormalItem");
//pButton.SetPushed(true);
//pButton = (PAUISTILLIMAGEBUTTON)pShow2.GetDlgItem("Btn_QuestItem");
//pButton.SetPushed(false);
//GetGameUIMan().m_pDlgInventory.SetShowItem(CDlgInventory::INVENTORY_ITEM_NORMAL);
//CloseDialogue();
if (pCurNPCEssence.HasValue)
{
dialogue1 = "DialogNPCShop";
serviceNeedSetUpDialogue = (SERVICE_TYPE)idFunction;
/*
// old: handled locally (do NOT delete)
uint npcID = pCurNPCEssence.Value.id;
var dlg = CECUIManager.Instance.ShowUI("DialogNPCShop");
if (dlg != null && dlg is NPCShopUIManager shopManager)
{
shopManager.OpenNPCShop(npcID);
}
*/
}
}
else if (idFunction == (int)SERVICE_TYPE.NPC_INSTALL)
{
if (pCurNPCEssence.HasValue)
{
dialogue1 = "Win_Enchase";
// var dlgInstall =GetGameUIMan().GetDialog("Win_Enchase");
// dlgInstall.Show(true);
// CECUIManager.Instance.ShowUI("Win_Enchase"); // old: handled locally (do NOT delete)
}
//pShow1 = m_pAUIManager.GetDialog("Win_Enchase");
//pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_UNINSTALL)
{
if (pCurNPCEssence.HasValue)
{
dialogue1 = "Win_Disenchase";
// CECUIManager.Instance.ShowUI("Win_Disenchase"); // old: handled locally (do NOT delete)
// var dlgInstall = GetGameUIMan().GetDialog("Win_Disenchase");
// dlgInstall.Show(true);
}
//pShow1 = m_pAUIManager.GetDialog("Win_Disenchase");
//pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_HEAL)
{
UnityGameSession.c2s_CmdNPCSevHeal();
GetGameUIMan().EndNPCService();
}
else if (idFunction == (int)SERVICE_TYPE.NPC_TRANSMIT)
{
dialogue1 = "Win_WorldMapTravel";
// pShow1 = m_pAUIManager.GetDialog("Win_WorldMapTravel");
//((CDlgWorldMap*)pShow1).BuildTravelMap(DT_NPC_TRANSMIT_SERVICE, pData);
}
else if (idFunction == (int)SERVICE_TYPE.NPC_SKILL)
{
//string strText = m_pLst_Main.GetText(m_pLst_Main.GetCurSel());
//string strHead = GetStringFromTable(249);
//string strComp = (strHead + GetStringFromTable(7107));
//if (0 == a_stricmp(strText, strComp))
//{
// pShow1 = m_pAUIManager.GetDialog("Win_ELFLearn");
// ((CDlgELFLearn*)pShow1).SetNPCName(pCurNPCEssence.name);
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// GetHostPlayer().PrepareNPCService(iService);
// pShow1.SetData(DT_NPC_SKILL_SERVICE);
//}
//else
//{
// pShow1 = m_pAUIManager.GetDialog("Win_Teach");
// GetHostPlayer().PrepareNPCService(iService);
// pShow1.SetData(DT_NPC_SKILL_SERVICE);
// GetGameUIMan().UpdateTeach(0);
//}
}
else if (idFunction == (int)SERVICE_TYPE.NPC_MAKE)
{
NPC_MAKE_SERVICE pMake = (NPC_MAKE_SERVICE)pData;
BMLogger.Log($"PopupCorrespondingServiceDialog - NPC_MAKE: produce_type={pMake.produce_type}, MakeSkillID={pMake.id_make_skill}");
if (pCurNPCEssence.HasValue)
{
dialogue1 = "Win_Produce";
serviceNeedSetUpDialogue = SERVICE_TYPE.NPC_MAKE;
}
// Dialog loading commented out - Win_Produce dialog not yet implemented
// Determine which dialog to use based on produce_type
//string dialogName = (pMake.produce_type == 2) ? "Win_Produce1" : "Win_Produce";
//pShow1 = m_pAUIManager.GetDialog(dialogName);
//if (pShow1 == null)
//{
// BMLogger.LogError($"NPC_MAKE: Dialog '{dialogName}' not found! Service may not work correctly.");
// // Try alternative dialog name or create placeholder
// // For now, just log the error and continue
//}
//else
//{
// // Get or set DlgProduce reference (if it exists)
// // GetGameUIMan().m_pDlgProduce = (CDlgProduce*)pShow1;
//
// // Prepare NPC service
// try
// {
// GetHostPlayer().PrepareNPCService(iService);
// }
// catch (Exception ex)
// {
// BMLogger.LogError($"NPC_MAKE: Error calling PrepareNPCService: {ex.Message}");
// }
//
// // Set data pointer
// try
// {
// pShow1.SetDataPtr(pMake, "ptr_NPC_MAKE_SERVICE");
// }
// catch (Exception ex)
// {
// BMLogger.LogError($"NPC_MAKE: Error setting data pointer: {ex.Message}");
// }
//
// // Clear material for certain produce types
// if (pMake.produce_type == 1 ||
// pMake.produce_type == 3 ||
// pMake.produce_type == 4 ||
// pMake.produce_type == 5)
// {
// try
// {
// // GetGameUIMan().m_pDlgProduce.ClearMaterial();
// // Note: ClearMaterial() will be called when DlgProduce is implemented
// BMLogger.Log($"NPC_MAKE: Should clear material for produce_type={pMake.produce_type}");
// }
// catch (Exception ex)
// {
// BMLogger.LogError($"NPC_MAKE: Error clearing material: {ex.Message}");
// }
// }
//
// // Get inventory dialog
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
//
// // Update produce dialog
// try
// {
// // GetGameUIMan().m_pDlgProduce.UpdateProduce(1, 0);
// // Note: UpdateProduce() will be called when DlgProduce is implemented
// BMLogger.Log($"NPC_MAKE: Should call UpdateProduce(1, 0)");
// }
// catch (Exception ex)
// {
// BMLogger.LogError($"NPC_MAKE: Error updating produce: {ex.Message}");
// }
//}
/*
// old: handled locally (do NOT delete)
uint npcID = pCurNPCEssence.HasValue ? pCurNPCEssence.Value.id : 0;
AUIDialog dlg = CECUIManager.Instance.ShowUI("Win_Produce");
DlgProduce dlgProduce = dlg as DlgProduce;
// if (dlgProduce == null)
// {
// CECGameUIMan gameUIMan = GetGameUIMan();
// DialogScriptTableObject dialogResource = gameUIMan.GetDialogResource();
// Canvas canvas = gameUIMan.GetCanvas();
//
// if(dlgProduce != null && canvas != null)
// {
// GameObject ob = dialogResource.GetPrefabDialog("Win_Produce");
// if (ob != null)
// {
// dlgProduce = GameObject.Instantiate(ob, canvas.transform).GetComponent<DlgProduce>();
// }
// }
// }
if(dlgProduce != null)
{
dlgProduce.Show(true);
dlgProduce.OpenProduce(npcID);
}
*/
}
else if (idFunction == (int)SERVICE_TYPE.NPC_DECOMPOSE)
{
//pShow1 = m_pAUIManager.GetDialog("Win_Split");
//pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
//pShow1.SetDataPtr(pData, "ptr_NPC_DECOMPOSE_SERVICE");
//PAUIPROGRESS pProgress;
//PAUIIMAGEPICTURE pImage;
//pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_a");
//pImage.ClearCover();
//pImage.SetDataPtr(NULL);
//pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_b");
//pImage.ClearCover();
//pImage.SetDataPtr(NULL);
//pProgress = (PAUIPROGRESS)pShow1.GetDlgItem("Prgs_1");
//pProgress.SetProgress(0);
//pShow1.GetDlgItem("Btn_Start").Enable(false);
//pShow1.GetDlgItem("Btn_Cancel").Enable(true);
//pShow1.GetDlgItem("Txt_no1").SetText(_AL(""));
//pShow1.GetDlgItem("Txt_no2").SetText(_AL(""));
//pShow1.GetDlgItem("Txt_Gold").SetText(_AL(""));
//pShow1.GetDlgItem("Txt_SkillName").SetText(_AL(""));
//pShow1.GetDlgItem("Txt_SkillLevel").SetText(_AL(""));
}
else if (idFunction == (int)SERVICE_TYPE.NPC_WAR_TOWERBUILD)
{
// pShow1 = m_pAUIManager.GetDialog("Win_WarTower");
dialogue1 = "Win_WarTower";
}
else if (idFunction == (int)SERVICE_TYPE.NPC_RESETPROP)
{
dialogue1 = "Win_ResetProp";
dialogue2 = "Win_Inventory";
// pShow1 = m_pAUIManager.GetDialog("Win_ResetProp");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_PETNAME)
{
dialogue1 = "Win_PetRename";
dialogue2 = "Win_PetList";
// pShow1 = m_pAUIManager.GetDialog("Win_PetRename");
// pShow2 = m_pAUIManager.GetDialog("Win_PetList");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_PETLEARNSKILL)
{
//CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral();
//CECPetData* pPet = pPetCorral.GetActivePet();
//if (!pPet)
//{
// GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255));
// GetGameUIMan().EndNPCService();
//}
//else
//{
// pShow1 = m_pAUIManager.GetDialog("Win_Teach");
// GetHostPlayer().PrepareNPCService(iService);
// pShow1.SetData(DT_NPC_PETLEARNSKILL_SERVICE);
// GetGameUIMan().UpdateTeach(0);
//}
}
else if (idFunction == (int)SERVICE_TYPE.NPC_PETFORGETSKILL)
{
//CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral();
//CECPetData* pPet = pPetCorral.GetActivePet();
//if (!pPet)
//{
// GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255));
// GetGameUIMan().EndNPCService();
//}
//else
// pShow1 = m_pAUIManager.GetDialog("Win_PetRetrain");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPBIND)
{
serviceNeedSetUpDialogue = SERVICE_TYPE.NPC_EQUIPBIND;
dialogue1 = "Win_EquipBind";
dialogue2 = "Win_Inventory";
// pShow1 = m_pAUIManager.GetDialog("Win_EquipBind");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// pShow1.SetData((uint)pData, "ptr_NPC_EQUIPBIND_SERVICE");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPDESTROY)
{
dialogue1 = "Win_EquipDestroy";
dialogue2 = "Win_Inventory";
// pShow1 = m_pAUIManager.GetDialog("Win_EquipDestroy");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_EQUIPUNDESTROY)
{
dialogue1 = "Win_EquipUndestroy";
dialogue2 = "Win_Inventory";
// pShow1 = m_pAUIManager.GetDialog("Win_EquipUndestroy");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_IDENTIFY)
{
//PAUIIMAGEPICTURE pImage;
//pShow1 = m_pAUIManager.GetDialog("Win_Identify");
//pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
//pShow1.SetDataPtr(pData, "ptr_NPC_IDENTIFY_SERVICE");
//pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item");
//pImage.ClearCover();
//pImage.SetDataPtr(NULL);
//pShow1.GetDlgItem("Txt").SetText(_AL(""));
//pShow1.GetDlgItem("Txt_Gold").SetText(_AL(""));
//pShow1.GetDlgItem("Btn_Confirm").Enable(false);
//pShow1.GetDlgItem("Btn_Cancel").Enable(true);
}
else if (idFunction == (int)SERVICE_TYPE.NPC_GIVE_TASK)
{
opt = (talk_proc.option)pData;
int idTask = (int)opt.param;
//if (g_pGame.GetConfigs().IsMiniClient() && CECUIConfig::Instance().GetGameUI().IsTaskDisabledInMiniClient(idTask))
//{
// GetGameUIMan().MessageBox("", GetStringFromTable(10714), MB_OK, A3DCOLORRGBA(255, 255, 255, 160));
//}
//else
{
UnityGameSession.c2s_CmdNPCSevAcceptTask(idTask, 0, 0);
}
GetGameUIMan().EndNPCService();
}
else if (idFunction == (int)SERVICE_TYPE.NPC_COMPLETE_TASK)
{
ad = new AWARD_DATA();
opt = (talk_proc.option)pData;
pTask = GetHostPlayer().GetTaskInterface();
pTask.GetAwardCandidates(opt.param, ref ad);
if (ad.m_ulCandItems > 1)
{
dialogue1 = "Win_Award";
serviceNeedSetUpDialogue = SERVICE_TYPE.NPC_COMPLETE_TASK;
// pShow1 = m_pAUIManager.GetDialog("Win_Award");
// CDlgAward pAward = (pShow1) as CDlgAward;
// if (pAward) pAward.UpdateAwardItem((ushort)opt.param, true);
}
else
{
UnityGameSession.c2s_CmdNPCSevReturnTask((int)opt.param, 0);
GetGameUIMan().EndNPCService();
}
}
else if (idFunction == (int)SERVICE_TYPE.NPC_GIVE_TASK_MATTER)
{
opt = (talk_proc.option)pData;
UnityGameSession.c2s_CmdNPCSevTaskMatter((int)opt.param);
GetGameUIMan().EndNPCService();
}
else if (idFunction == (int)SERVICE_TYPE.NPC_STORAGE)
{
//if (GetHostPlayer().TrashBoxHasPsw())
//{
// pShow1 = m_pAUIManager.GetDialog("Win_InputString");
// pShow1.GetDlgItem("DEFAULT_Txt_Input").SetText(_AL(""));
//}
//else
// g_pGame.GetGameSession().c2s_CmdNPCSevOpenTrash("");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_STORAGE_PASSWORD)
{
dialogue1 = "Win_InputString3";
// pShow1 = m_pAUIManager.GetDialog("Win_InputString3");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_ACCOUNT_STORAGE)
{
//if (CECCrossServer::Instance().IsOnSpecialServer())
//{
// GetGameUIMan().ShowErrorMsg(10130);
// GetGameUIMan().EndNPCService();
//}
//else g_pGame.GetGameSession().c2s_CmdNPCSevOpenAccountBox();
}
else if (idFunction == (int)SERVICE_TYPE.NPC_ENGRAVE)
{
dialogue1 = "Win_Engrave";
dialogue2 = "Win_Inventory";
// pShow1 = m_pAUIManager.GetDialog("Win_Engrave");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
}
else if (idFunction == (int)SERVICE_TYPE.NPC_RANDPROP)
{
dialogue1 = "Win_RandProp";
dialogue2 = "Win_Inventory";
// pShow1 = m_pAUIManager.GetDialog("Win_RandProp");
// pShow2 = m_pAUIManager.GetDialog("Win_Inventory");
// GetHostPlayer().PrepareNPCService(iService);
// pShow1.SetDataPtr(pData, "ptr_NPC_RANDPROP_SERVICE");
serviceNeedSetUpDialogue = SERVICE_TYPE.NPC_RANDPROP;
}
else if (idFunction == (int)SERVICE_TYPE.TALK_RETURN)
{
OnCommand_back("back");
return true; // To avoid to close NPC dialog.
}
else if (idFunction == (int)SERVICE_TYPE.TALK_EXIT)
{
CloseDialogue();
GetGameUIMan().EndNPCService();
int idCurFinishTask = GetGameUIMan().m_idCurFinishTask;
if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK && idCurFinishTask > 0)
{
GetHostPlayer().GetTaskInterface().OnUIDialogEnd((uint)idCurFinishTask);
GetGameUIMan().m_idCurFinishTask = -1;
}
}
else if (idFunction == (int)SERVICE_TYPE.TALK_GIVEUP_TASK)
{
opt = (talk_proc.option)pData;
GetHostPlayer().GetTaskInterface().GiveUpTask(opt.param);
GetGameUIMan().EndNPCService();
}
else
{
//GetHostPlayer().GetPack(IVTRTYPE_PACK).UnfreezeAllItems();
GetGameUIMan().EndNPCService();
}
if (!string.IsNullOrEmpty(dialogue1))
{
DATA_TYPE DataType = new DATA_TYPE();
elementdataman pDataMan = ElementDataManProvider.GetElementDataMan();
pDataMan.get_data_ptr((uint)iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
var dlg1 = CECUIManager.Instance.ShowUI(dialogue1);
if (dlg1 != null)
{
switch (serviceNeedSetUpDialogue)
{
case SERVICE_TYPE.NPC_EQUIPBIND:
dlg1.SetData((uint)pData, "ptr_NPC_EQUIPBIND_SERVICE");
break;
case SERVICE_TYPE.NPC_COMPLETE_TASK when ad.m_ulCandItems > 1:
{
CDlgAward pAward = dlg1 as CDlgAward;
if (pAward != null)
{
pAward.UpdateAwardItem((ushort)opt.param, true);
}
break;
}
case SERVICE_TYPE.NPC_RANDPROP:
GetHostPlayer().PrepareNPCService(iService);
dlg1.SetDataPtr(pData, "ptr_NPC_RANDPROP_SERVICE");
break;
// Shop / Produce: post-process after ShowUI
case SERVICE_TYPE.NPC_SELL:
case SERVICE_TYPE.NPC_BUY:
{
NPCShopUIManager shopManager = dlg1 as NPCShopUIManager;
if (shopManager != null)
{
shopManager.OpenNPCShop(npcID);
}
break;
}
case SERVICE_TYPE.NPC_MAKE:
{
GetHostPlayer().PrepareNPCService(iService);
dlg1.SetDataPtr(pData, "ptr_NPC_MAKE_SERVICE");
DlgProduce dlgProduce = dlg1 as DlgProduce;
if (dlgProduce != null)
{
dlgProduce.OpenProduce(npcID);
}
break;
}
}
}
// pShow1.Show(true);
if (!string.IsNullOrEmpty(dialogue2))
{
//POINT ptPos = pShow1.GetPos();
//if (ptPos.x == 0 && ptPos.y == 0)
//{
// SIZE s1 = pShow1.GetSize();
// SIZE s2 = pShow2.GetSize();
// A3DVIEWPORTPARAM* p = m_pA3DEngine.GetActiveViewport().GetParam();
// int x, y = (p.Height - max(s1.cy, s2.cy)) / 2;
// x = (p.Width - s1.cx - s2.cx) / 2;
// // old : pShow1.SetPos(x, y);
// pShow1.SetPosEx(x, y);
// x += s1.cx;
// // old : pShow2.SetPos(x, y);
// pShow2.SetPosEx(x, y);
//}
var dlg2 = CECUIManager.Instance.ShowUI(dialogue2);
}
return true;
}
CloseDialogue();
return true;
}
public void OnCommand_CANCEL(string szCommand)
{
int idCurFinishTask = GetGameUIMan().m_idCurFinishTask;
if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_TALK && idCurFinishTask > 0)
{
GetHostPlayer().GetTaskInterface().OnUIDialogEnd((uint)idCurFinishTask);
GetGameUIMan().m_idCurFinishTask = -1;
}
CloseDialogue();
GetGameUIMan().EndNPCService();
}
public override void Awake()
{
base.Awake();
m_btnBack.onClick.AddListener(()=> { OnCommand_back("back"); });
m_btnClose.onClick.AddListener(()=> { OnCommand_CANCEL("cancel"); });
}
void PopupStorageTaskDialog(NPC_TASK_OUT_SERVICE pService, bool bTaskNPC)
{
NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence;
if (GetHostPlayer().GetPack().GetItemTotalNum((int)pService.storage_open_item) > 0)
{
//CloseDialogue();
//var pDlg = GetGameUIMan().GetDialog("Win_QuestList");
//if (pDlg)
//{
// pDlg.Show(true);
//}
//else // in case the dialog is missing or name changed...
//{
// GetGameUIMan().EndNPCService();
//}
var dlg = CECUIManager.Instance;
if(dlg != null)
{
dlg.ShowUI("Win_QuestList");
}
else
{
GetGameUIMan().EndNPCService();
}
}
else
{
EC_IvtrItem pItem = EC_IvtrItem.CreateItem((int)pService.storage_open_item, 0, 1);
// cannot open storage task
m_pLst_Main.ResetContent();
//string szMsg = string.Format(GetStringFromTable(984), pItem.GetName());
//m_pTxt_Content.SetText(bTaskNPC ? Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(pCurNPCEssence.Value.hello_msg)) : szMsg);
//SetData(NPC_DIALOG.NPC_DIALOG_TASK_LIST, "");
}
}
void ResizeContent()
{
var size = m_rectContent.sizeDelta;
size.y = m_pTxt_Content.preferredHeight + 10f; // delta = 10f
m_rectContent.sizeDelta = size;
LayoutRebuilder.ForceRebuildLayoutImmediate(m_rectContent);
}
}
}