Deposit, withdraw account money handler
This commit is contained in:
@@ -145,6 +145,11 @@ namespace BrewMonster.Scripts.Managers
|
||||
CECHostPlayer.PopupStorageDialog(true);
|
||||
return;
|
||||
}
|
||||
if (!value && GetHostPlayer() != null && GetHostPlayer().IsUsingAccountBox())
|
||||
{
|
||||
CECHostPlayer.PopupAccountBoxDialog(true);
|
||||
return;
|
||||
}
|
||||
base.Show(value);
|
||||
}
|
||||
|
||||
@@ -155,6 +160,11 @@ namespace BrewMonster.Scripts.Managers
|
||||
CECHostPlayer.PopupStorageDialog(true);
|
||||
return;
|
||||
}
|
||||
if (GetHostPlayer() != null && GetHostPlayer().IsUsingAccountBox())
|
||||
{
|
||||
CECHostPlayer.PopupAccountBoxDialog(true);
|
||||
return;
|
||||
}
|
||||
base.CloseDialogue();
|
||||
}
|
||||
|
||||
|
||||
@@ -1268,6 +1268,16 @@ namespace CSNetwork.C2SCommand
|
||||
return octets;
|
||||
}
|
||||
|
||||
public static Octets CreateNPCSevOpenAccountBoxCmd()
|
||||
{
|
||||
var cmd = new cmd_sevnpc_serve
|
||||
{
|
||||
service_type = NPC_service_type.GP_NPCSEV_OPEN_ACCOUNT_BOX,
|
||||
len = 0
|
||||
};
|
||||
return SerializeCommand(CommandID.SEVNPC_SERVE, cmd);
|
||||
}
|
||||
|
||||
public static Octets CreateGetOtherEquipCmd(ushort _size, int[] _idlist)
|
||||
{
|
||||
var cmd = new cmd_get_other_equip
|
||||
|
||||
@@ -979,6 +979,11 @@ namespace BrewMonster.Network
|
||||
Instance._gameSession.c2s_CmdNPCSevOpenTrash(password);
|
||||
}
|
||||
|
||||
public static void c2s_CmdNPCSevOpenAccountBox()
|
||||
{
|
||||
Instance._gameSession.c2s_CmdNPCSevOpenAccountBox();
|
||||
}
|
||||
|
||||
public static void c2s_CmdGetTrashBoxData(bool detail, bool accountBox = false)
|
||||
{
|
||||
Instance._gameSession.c2s_CmdGetTrashBoxData(detail, accountBox);
|
||||
|
||||
@@ -3788,7 +3788,8 @@ namespace BrewMonster.UI
|
||||
// GetGameUIMan().ShowErrorMsg(10130);
|
||||
// GetGameUIMan().EndNPCService();
|
||||
//}
|
||||
//else g_pGame.GetGameSession().c2s_CmdNPCSevOpenAccountBox();
|
||||
UnityGameSession.c2s_CmdNPCSevOpenAccountBox();
|
||||
GetGameUIMan().EndNPCService();
|
||||
}
|
||||
else if (idFunction == (int)SERVICE_TYPE.NPC_ENGRAVE)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,10 @@ namespace BrewMonster.UI
|
||||
StorageDepositMoney,
|
||||
/// <summary>Rút tiền ra — C++ INPUTNO_STORAGE_TRASH_MONEY (Win_Storage choosemoney).</summary>
|
||||
StorageWithdrawMoney,
|
||||
/// <summary>Gửi tiền vào kho tài khoản — same C2S as storage, with is_accountbox=1.</summary>
|
||||
AccountStorageDepositMoney,
|
||||
/// <summary>Rút tiền ra từ kho tài khoản — same C2S as storage, with is_accountbox=1.</summary>
|
||||
AccountStorageWithdrawMoney,
|
||||
}
|
||||
|
||||
[Header("Amount")]
|
||||
@@ -236,6 +240,12 @@ namespace BrewMonster.UI
|
||||
// C++ INPUTNO_STORAGE_TRASH_MONEY: ExgTrashBoxMoney(iTrash=amount, iIvtr=0)
|
||||
UnityGameSession.c2s_CmdExgTrashBoxMoney(0, amount);
|
||||
break;
|
||||
case QuantityMode.AccountStorageDepositMoney:
|
||||
UnityGameSession.c2s_CmdExgTrashBoxMoney(amount, 0, true);
|
||||
break;
|
||||
case QuantityMode.AccountStorageWithdrawMoney:
|
||||
UnityGameSession.c2s_CmdExgTrashBoxMoney(0, amount, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,15 @@ namespace BrewMonster
|
||||
|
||||
private bool m_bTrashPsw;
|
||||
private bool m_bFirstTBOpen = true;
|
||||
private bool m_bUsingAccountBox;
|
||||
private bool m_bFirstAccountBoxOpen = true;
|
||||
private int m_iTrashBoxMoneyCnt;
|
||||
private int m_iAccountBoxMoneyCnt;
|
||||
|
||||
public bool TrashBoxHasPsw() => m_bTrashPsw;
|
||||
public int GetTrashBoxMoneyCnt() => m_iTrashBoxMoneyCnt;
|
||||
public bool IsUsingAccountBox() => m_bUsingAccountBox;
|
||||
public int GetAccountBoxMoneyCnt() => m_iAccountBoxMoneyCnt;
|
||||
public EC_Inventory GetTrashBox() => m_pTrashBoxPack;
|
||||
public EC_Inventory GetTrashBox2() => m_pTrashBoxPack2;
|
||||
public EC_Inventory GetTrashBox3() => m_pTrashBoxPack3;
|
||||
@@ -54,9 +59,22 @@ namespace BrewMonster
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_trashbox_open>(data);
|
||||
if (pCmd.is_accountbox != 0)
|
||||
break; // PW_TODO: account box UI
|
||||
{
|
||||
m_bUsingAccountBox = true;
|
||||
m_bUsingTrashBox = false;
|
||||
|
||||
if (m_bFirstAccountBoxOpen)
|
||||
{
|
||||
m_bFirstAccountBoxOpen = false;
|
||||
UnityGameSession.c2s_CmdGetTrashBoxData(true, true);
|
||||
}
|
||||
|
||||
PopupAccountBoxDialog();
|
||||
break;
|
||||
}
|
||||
|
||||
m_bUsingTrashBox = true;
|
||||
m_bUsingAccountBox = false;
|
||||
InitTrashBoxPacks();
|
||||
|
||||
if (m_bFirstTBOpen)
|
||||
@@ -80,7 +98,11 @@ namespace BrewMonster
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_trashbox_close>(data);
|
||||
if (pCmd.is_accountbox != 0)
|
||||
{
|
||||
m_bUsingAccountBox = false;
|
||||
PopupAccountBoxDialog(true);
|
||||
break;
|
||||
}
|
||||
m_bUsingTrashBox = false;
|
||||
PopupStorageDialog(true);
|
||||
break;
|
||||
@@ -89,19 +111,31 @@ namespace BrewMonster
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_trashbox_wealth>(data);
|
||||
if (pCmd.is_accountbox == 0)
|
||||
{
|
||||
m_iTrashBoxMoneyCnt = (int)pCmd.money;
|
||||
EC_StorageUI.RefreshMoneyStatic();
|
||||
EC_StorageUI.RefreshMoneyStatic();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iAccountBoxMoneyCnt = (int)pCmd.money;
|
||||
EC_AccountStorageUI.RefreshMoneyStatic();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CommandID.EXG_TRASH_MONEY:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_exg_trash_money>(data);
|
||||
AddMoneyAmount(pCmd.inv_delta);
|
||||
if (pCmd.is_accountbox == 0)
|
||||
{
|
||||
AddMoneyAmount(pCmd.inv_delta);
|
||||
m_iTrashBoxMoneyCnt += pCmd.tra_delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iAccountBoxMoneyCnt += pCmd.tra_delta;
|
||||
}
|
||||
EC_StorageUI.RefreshMoneyStatic();
|
||||
EC_AccountStorageUI.RefreshMoneyStatic();
|
||||
var invUi = UnityEngine.Object.FindFirstObjectByType<EC_InventoryUI>();
|
||||
invUi?.RefreshAll();
|
||||
break;
|
||||
@@ -243,6 +277,32 @@ namespace BrewMonster
|
||||
invDlg?.RefreshAll();
|
||||
}
|
||||
|
||||
/// <summary>C++ CECGameUIMan::PopupAccountBoxDialog — money-only account warehouse.</summary>
|
||||
public static void PopupAccountBoxDialog(bool close = false)
|
||||
{
|
||||
if (close)
|
||||
{
|
||||
var host = EC_Game.GetGameRun()?.GetHostPlayer();
|
||||
if (host != null)
|
||||
host.m_bUsingAccountBox = false;
|
||||
|
||||
EC_StorageUI.ClearSelectionStatic();
|
||||
var invUi = UnityEngine.Object.FindFirstObjectByType<EC_InventoryUI>(FindObjectsInactive.Include);
|
||||
invUi?.DismissItemDetail();
|
||||
|
||||
CECUIManager.Instance?.HideAccountStorageDialogPair();
|
||||
EC_Game.GetGameRun()?.GetUIManager()?.GetInGameUIMan()?.EndNPCService();
|
||||
return;
|
||||
}
|
||||
|
||||
CECUIManager.Instance?.ShowAccountStorageDialogPair();
|
||||
var accountDlg = EC_Game.GetGameRun()?.GetUIManager()?.GetInGameUIMan()?.GetDialog("EC_AccountStorageUI") as EC_AccountStorageUI;
|
||||
accountDlg?.RefreshAll();
|
||||
|
||||
var invDlg = UnityEngine.Object.FindFirstObjectByType<EC_InventoryUI>(FindObjectsInactive.Include);
|
||||
invDlg?.RefreshAll();
|
||||
}
|
||||
|
||||
/// <summary>Transfer between main pack and trash box (C++ CDlgStorage::OnItemDragDrop).</summary>
|
||||
public bool TransferPackAndTrash(byte trashWhere, int trashSlot, int invSlot, int amount = -1)
|
||||
{
|
||||
|
||||
@@ -361,6 +361,58 @@ public class CECUIManager : MonoSingleton<CECUIManager>
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show money-only account warehouse + inventory together. This intentionally uses a
|
||||
/// separate dialog from EC_StorageUI to avoid enabling warehouse item slots.
|
||||
/// </summary>
|
||||
public void ShowAccountStorageDialogPair()
|
||||
{
|
||||
if (canvasDlg == null)
|
||||
return;
|
||||
|
||||
var gui = GetInGameUIMan();
|
||||
if (gui == null)
|
||||
return;
|
||||
|
||||
var accountDlg = gui.GetDialog("EC_AccountStorageUI");
|
||||
var invDlg = gui.GetDialog("Win_Inventory");
|
||||
if (accountDlg == null || invDlg == null)
|
||||
return;
|
||||
|
||||
_uiStack.Remove("Win_Inventory");
|
||||
_uiStack.Remove("EC_AccountStorageUI");
|
||||
|
||||
invDlg.Show(true);
|
||||
accountDlg.Show(true);
|
||||
|
||||
_uiStack.Insert(0, "Win_Inventory");
|
||||
_uiStack.Insert(0, "EC_AccountStorageUI");
|
||||
|
||||
invDlg.transform.SetAsLastSibling();
|
||||
accountDlg.transform.SetAsLastSibling();
|
||||
}
|
||||
|
||||
/// <summary>Hide account warehouse pair and restore previous stack top if any.</summary>
|
||||
public void HideAccountStorageDialogPair()
|
||||
{
|
||||
_uiStack.Remove("EC_AccountStorageUI");
|
||||
_uiStack.Remove("Win_Inventory");
|
||||
|
||||
var gui = GetInGameUIMan();
|
||||
gui?.GetDialog("Win_Inventory")?.Show(false);
|
||||
gui?.GetDialog("EC_AccountStorageUI")?.Show(false);
|
||||
|
||||
if (_uiStack.Count > 0)
|
||||
{
|
||||
var newTop = gui?.GetDialog(_uiStack[0]);
|
||||
if (newTop != null)
|
||||
{
|
||||
newTop.Show(true);
|
||||
newTop.transform.SetAsLastSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pop the top dialog off the stack: hide it and bring the new top (if any) to front. Returns true if something was popped.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user