Пример #1
0
        internal override void Show()
        {
            base.Show();
            IsSideChanging = false;
            explorer.Show();
            SetVisible(dpdDecks.transform, true);
            SetVisible(dpdFList.transform, true);
            SetVisible(btnFinishSide.transform, false);
            SetVisible(btnClear.transform, true);
            SetVisible(btnCopy.transform, true);
            SetVisible(btnDelete.transform, true);
            SetVisible(btnExit.transform, true);
            SetVisible(btnRename.transform, true);
            SetVisible(btnSave.transform, true);
            DeckService.ForbiddenLists.ForEach((fl) => dpdFList.options.Add(new TMP_Dropdown.OptionData(fl.Name)));
            dpdFList.value = 0;
            dpdFList.RefreshShownValue();
            CurrentFList = DeckService.ForbiddenLists[0];
            var names = DeckService.GetAllNames();

            if (names.Count == 0)
            {
                File.Create(Config.DeckPath + "new deck.ydk");
                names.Add("new deck.ydk");
            }
            bool found = false;

            for (int i = 0; i < names.Count; ++i)
            {
                dpdDecks.options.Add(new TMP_Dropdown.OptionData(names[i]));
                if (Config.GetString("LastDeck", "") == names[i])
                {
                    found          = i != dpdDecks.value;
                    dpdDecks.value = i;
                }
            }
            dpdDecks.RefreshShownValue();
            if (!found)
            {
                SwitchToDeck(Config.DeckPath + dpdDecks.options[dpdDecks.value].text + ".ydk");
            }
            MainCount.gameObject.SetActive(true);
            ExtraCount.gameObject.SetActive(true);
            SideCount.gameObject.SetActive(true);
            MainGame.Instance.CameraToBuilder();
            MainGame.Instance.Descriptor.Show();
            MainGame.Instance.FrameActions.Add(FocusInput);
        }
Пример #2
0
        private void RefreshDeckList()
        {
            var allnames = DeckService.GetAllNames();

            if (File.Exists(Config.DeckPath + Config.GetString("LastDeck", "") + ".ydk"))
            {
                tMPSelectedDeck.text = Config.GetString("LastDeck");
            }
            else if (allnames.Count > 0)
            {
                tMPSelectedDeck.text = allnames[0];
                Config.Set("LastDeck", tMPSelectedDeck.text);
            }
            var itemstack = new Stack <Transform>(deckItems.Count);

            for (int i = 0; i < deckItems.Count; ++i)
            {
                deckItems[i].SetParent(null);
                itemstack.Push(deckItems[i]);
            }
            deckItems.Clear();
            for (int i = 0; i < allnames.Count; ++i)
            {
                var item    = itemstack.Count > 0 ? itemstack.Pop() : Tools.LoadResource <RectTransform>("Prefabs/DeckItem");
                var tmp     = item.GetChild(2).GetComponent <TextMeshProUGUI>();
                var itemtgl = item.GetComponent <Toggle>();
                tmp.text = allnames[i];
                item.SetParent(decksContent, false);
                itemtgl.group   = decksContent.GetComponent <ToggleGroup>();
                item.localScale = Vector3.one;
                itemtgl.isOn    = false;
                itemtgl.enabled = true;
                itemtgl.onValueChanged.RemoveAllListeners();
                itemtgl.onValueChanged.AddListener((isOn) =>
                {
                    if (isOn)
                    {
                        tMPSelectedDeck.text = tmp.text;
                    }
                });
                deckItems.Add(item);
            }
            while (itemstack.Count > 0)
            {
                UnityEngine.Object.Destroy(itemstack.Pop());
            }
        }