Merge branch 'develop' into feature/Addessable_CDN
This commit is contained in:
@@ -67,3 +67,5 @@ MonoBehaviour:
|
||||
prefab: {fileID: 3837460183159982207, guid: 0986049a141406946b0ed97344b84f78, type: 3}
|
||||
- id: DlgQuantity
|
||||
prefab: {fileID: 8147986291757959694, guid: 11d09ee52b0c5f24fb3ef21e177ebe2d, type: 3}
|
||||
- id: EC_AccountStorageUI
|
||||
prefab: {fileID: 3837460183159982207, guid: 52c6d600a10af6b46a93fdc0ab719198, type: 3}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
using BrewMonster;
|
||||
using BrewMonster.Scripts;
|
||||
using BrewMonster.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace BrewMonster.Scripts.Managers
|
||||
{
|
||||
/// <summary>
|
||||
/// Money-only account warehouse UI. C++ uses Win_Storage3, but this Unity port keeps it
|
||||
/// separate from <see cref="EC_StorageUI"/> so normal warehouse item logic cannot leak in.
|
||||
/// </summary>
|
||||
public class EC_AccountStorageUI : AUIDialog
|
||||
{
|
||||
[SerializeField] private Button closeButton;
|
||||
[SerializeField] private Button depositMoneyButton;
|
||||
[SerializeField] private Button withdrawMoneyButton;
|
||||
[SerializeField] private Text accountMoneyTextLegacy;
|
||||
[SerializeField] private TMPro.TextMeshProUGUI accountMoneyTextTMP;
|
||||
|
||||
private static EC_AccountStorageUI s_instance;
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
s_instance = this;
|
||||
ResolveButtons();
|
||||
WireButtons();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (s_instance == this)
|
||||
s_instance = null;
|
||||
}
|
||||
|
||||
public static void RefreshMoneyStatic()
|
||||
{
|
||||
s_instance?.RefreshMoney();
|
||||
}
|
||||
|
||||
public void RefreshAll()
|
||||
{
|
||||
RefreshMoney();
|
||||
}
|
||||
|
||||
void ResolveButtons()
|
||||
{
|
||||
var buttons = GetComponentsInChildren<Button>(true);
|
||||
for (int i = 0; i < buttons.Length; i++)
|
||||
{
|
||||
var btn = buttons[i];
|
||||
if (btn == null)
|
||||
continue;
|
||||
string n = btn.name.ToLowerInvariant();
|
||||
if (closeButton == null && (n.Contains("close") || n.Contains("cancel") || n == "btn_close"))
|
||||
closeButton = btn;
|
||||
if (depositMoneyButton == null && (n.Contains("deposit") || n.Contains("put_money") || n.Contains("gui_tien")
|
||||
|| n.Contains("send_money") || n == "choosemoney" || n.Contains("btn_put")))
|
||||
depositMoneyButton = btn;
|
||||
if (withdrawMoneyButton == null && (n.Contains("withdraw") || n.Contains("get_money") || n.Contains("rut")
|
||||
|| n.Contains("take_money") || n.Contains("btn_get")))
|
||||
withdrawMoneyButton = btn;
|
||||
}
|
||||
}
|
||||
|
||||
void WireButtons()
|
||||
{
|
||||
if (closeButton != null)
|
||||
{
|
||||
closeButton.onClick.RemoveAllListeners();
|
||||
closeButton.onClick.AddListener(() => CECHostPlayer.PopupAccountBoxDialog(true));
|
||||
}
|
||||
if (depositMoneyButton != null)
|
||||
{
|
||||
depositMoneyButton.onClick.RemoveAllListeners();
|
||||
depositMoneyButton.onClick.AddListener(OnDepositMoneyClicked);
|
||||
}
|
||||
if (withdrawMoneyButton != null)
|
||||
{
|
||||
withdrawMoneyButton.onClick.RemoveAllListeners();
|
||||
withdrawMoneyButton.onClick.AddListener(OnWithdrawMoneyClicked);
|
||||
}
|
||||
}
|
||||
|
||||
void RefreshMoney()
|
||||
{
|
||||
var host = CECGameRun.Instance?.GetHostPlayer();
|
||||
if (host == null)
|
||||
return;
|
||||
|
||||
string accountMoney = host.GetAccountBoxMoneyCnt().ToString();
|
||||
|
||||
if (accountMoneyTextLegacy != null)
|
||||
accountMoneyTextLegacy.text = accountMoney;
|
||||
if (accountMoneyTextTMP != null)
|
||||
accountMoneyTextTMP.text = accountMoney;
|
||||
}
|
||||
|
||||
void OnDepositMoneyClicked()
|
||||
{
|
||||
var host = CECGameRun.Instance?.GetHostPlayer();
|
||||
if (host == null || !host.IsUsingAccountBox())
|
||||
return;
|
||||
|
||||
int max = (int)Mathf.Min(int.MaxValue, host.GetMoneyAmount());
|
||||
if (max <= 0)
|
||||
return;
|
||||
|
||||
DlgQuantity.Show(DlgQuantity.QuantityMode.AccountStorageDepositMoney, max, Mathf.Min(1, max));
|
||||
}
|
||||
|
||||
void OnWithdrawMoneyClicked()
|
||||
{
|
||||
var host = CECGameRun.Instance?.GetHostPlayer();
|
||||
if (host == null || !host.IsUsingAccountBox())
|
||||
return;
|
||||
|
||||
int max = host.GetAccountBoxMoneyCnt();
|
||||
if (max <= 0)
|
||||
return;
|
||||
|
||||
DlgQuantity.Show(DlgQuantity.QuantityMode.AccountStorageWithdrawMoney, max, Mathf.Min(1, max));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f04de4d418987314e84daf47df9e9a9b
|
||||
@@ -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
|
||||
|
||||
@@ -3136,6 +3136,12 @@ namespace CSNetwork
|
||||
SendProtocol(req);
|
||||
}
|
||||
|
||||
public void c2s_CmdNPCSevOpenAccountBox()
|
||||
{
|
||||
var req = new gamedatasend { Data = C2SCommandFactory.CreateNPCSevOpenAccountBoxCmd() };
|
||||
SendProtocol(req);
|
||||
}
|
||||
|
||||
public void c2s_CmdExgTrashBoxItem(byte where, byte index1, byte index2)
|
||||
{
|
||||
var req = new gamedatasend { Data = C2SCommandFactory.CreateCmdExgTrashBoxItem(where, index1, index2) };
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52c6d600a10af6b46a93fdc0ab719198
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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