Ejemplo n.º 1
0
    private void DoMainButtonOnContext(Item item, int rebuyCount)
    {
        GUIStyle style = GUI.skin.GetStyle("BtnAction");

        style.fontStyle = FontStyle.Bold;
        Rect rc = new Rect(crdInstall);

        if (chatView)
        {
            rc.y -= chatGap;
        }
        Rect rc2 = new Rect(crdDeleteBtn);

        if (chatView)
        {
            rc2.y -= chatGap;
        }
        switch (item.Usage)
        {
        case Item.USAGE.DELETED:
            if (!IsPremiumPCbangTab())
            {
                Good good = ShopManager.Instance.Get(item.Template.code);
                if (good != null)
                {
                    bool enabled = GUI.enabled;
                    GUI.enabled = (enabled && good.IsRebuyable());
                    if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("REBUY"), "BtnAction"))
                    {
                        ((BuyTermDialog)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.BUY_TERM, exclusive: true))?.InitDialog(item.Seq, good);
                    }
                    GUI.enabled = enabled;
                }
                if (GlobalVars.Instance.MyButton(rc2, StringMgr.Instance.Get("DELETE"), "BtnAction"))
                {
                    ((AreYouSure)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.ARE_YOU_SURE, exclusive: true))?.InitDialog(item, AreYouSure.SURE.ERASE_AN_EXPIRED_ITEM);
                }
            }
            break;

        case Item.USAGE.EQUIP:
            if (item.IsTakeoffable && GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("TAKEOFF"), "BtnAction"))
            {
                CSNetManager.Instance.Sock.SendCS_UNEQUIP_REQ(item.Seq);
            }
            break;

        case Item.USAGE.UNEQUIP:
            if (item.IsEquipable && GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("EQUIP"), "BtnAction"))
            {
                if (item.IsLimitedByStarRate)
                {
                    SystemMsgManager.Instance.ShowMessage(StringMgr.Instance.Get("WEAPON_STAR_LIMIT"));
                }
                else
                {
                    GlobalVars.Instance.PlaySoundItemInstall();
                    CSNetManager.Instance.Sock.SendCS_EQUIP_REQ(item.Seq);
                }
            }
            if (item.Template.type == TItem.TYPE.BUNDLE && item.Amount > 0 && GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("INIT_ITEM"), "BtnAction"))
            {
                ((Sure2UnpackDialog)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.SURE2UNPACK, exclusive: true))?.InitDialog(item, (TBundle)item.Template);
            }
            if (item.CanSpecialUse() && GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("INIT_ITEM"), "BtnAction"))
            {
                item.SpecialUse();
            }
            break;

        case Item.USAGE.NOT_USING:
            if (GlobalVars.Instance.MyButton(rc, StringMgr.Instance.Get("EQUIP_IN_INVENTORY"), "BtnAction"))
            {
                if (item.IsLimitedByStarRate)
                {
                    SystemMsgManager.Instance.ShowMessage(StringMgr.Instance.Get("WEAPON_STAR_LIMIT"));
                }
                else
                {
                    ((AreYouSure)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.ARE_YOU_SURE, exclusive: true))?.InitDialog(item, AreYouSure.SURE.INIT_ITEM);
                }
            }
            break;
        }
        style.fontStyle = FontStyle.Normal;
    }