public void Initialize(int _index, GameInput.BindingSet _bindingSet)
 {
     bindingsList = Config.Instance.SlotBindings.Where(x => x.Key != _index).Select(x => x.Value).ToList();
     index        = _index;
     bindingSet   = _bindingSet;
     interactable = uGUI.interactable;
     data         = uGUI_QuickSlots_ConfigTab.dataState;
     currentText  = gameObject.transform.Find("Label").GetComponent <TextMeshProUGUI>();
     value        = Config.Instance.Slots[index.ToString()][(int)bindingSet];
     RefreshValue();
 }
Beispiel #2
0
        public void SetControls()
        {
            var labelTemplate   = Language.main.Get("OptionSlot1").Split(' ');
            var translatedLabel = labelTemplate.Length == 2 ? labelTemplate[0] : "Slot";

            Config.Instance.SlotLabels   = new Dictionary <int, string>();
            Config.Instance.SlotBindings = new Dictionary <int, uGUI_QuickSlots_Bindings>();
            if (index > -1)
            {
                for (int i = Player.quickSlotButtonsCount; i < Mod.config.SlotCount; i++)
                {
                    var label = $"{translatedLabel} {(i + 1)}";
                    if (!Config.Instance.SlotLabels.ContainsKey(i))
                    {
                        Config.Instance.SlotLabels.Add(i, label);
                    }
                    var gameObject = optionsPanel.AddItem(index, optionsPanel.bindingOptionPrefab);

                    var componentInChildren = gameObject.GetComponentInChildren <TextMeshProUGUI>();
                    if (componentInChildren != null)
                    {
                        gameObject.name           = "OptionSlot" + i;
                        componentInChildren.text  = label;
                        componentInChildren.color = uGUI.currentColor;
                    }

                    var originalBindingsComponent = gameObject.GetComponentInChildren <uGUI_Bindings>();
                    var originalBindingComponents = gameObject.GetComponentsInChildren <uGUI_Binding>().Select(x => x.gameObject).ToList();

                    foreach (var ob in gameObject.GetComponentsInChildren <uGUI_Binding>())
                    {
                        dataState = ob.data;
                        Destroy(ob);
                    }


                    var bg = originalBindingsComponent.selectionBackground;
                    bindings.Remove(originalBindingsComponent);
                    Destroy(originalBindingsComponent);
                    var qsBinds = gameObject.transform.Find("Bindings").gameObject.AddComponent <uGUI_QuickSlots_Bindings>();
                    Config.Instance.SlotBindings.Add(i, qsBinds);
                    qsBinds.Setup(i, bg, null);
                }
            }
        }