示例#1
0
        protected override void AwakeActions()
        {
            CreateTopButton(MainPanel, "ExportAsDefault", "K45_ZM_EXPORT_DEFAULT_BTN", CommonsSpriteNames.K45_Save.ToString(), new Vector2(10, 50), (x, y) => CustomZoneData.Instance.SaveAsDefault());
            CreateTopButton(MainPanel, "ImportDefault", "K45_ZM_IMPORT_DEFAULT_BTN", CommonsSpriteNames.K45_Load.ToString(), new Vector2(95, 50), (x, y) => CustomZoneData.Instance.LoadDefaults());
            CreateTopButton(MainPanel, "Reset", "K45_ZM_RESET_BTN", CommonsSpriteNames.K45_Reload.ToString(), new Vector2(180, 50), (x, y) => CustomZoneData.Instance.Reset());

            KlyteMonoUtils.CreateUIElement(out UIPanel listPanel, MainPanel.transform, "ZoneList", new Vector4(0, 100, PanelWidth, PanelHeight - 105));
            listPanel.autoLayout          = true;
            listPanel.autoLayoutDirection = LayoutDirection.Vertical;
            listPanel.autoLayoutPadding   = new RectOffset(0, 0, 5, 5);
            listPanel.padding             = new RectOffset(5, 5, 5, 5);

            for (int i = 1; i <= 7; i++)
            {
                int idx = i;

                KlyteMonoUtils.CreateUIElement(out UIPanel zonePanel, listPanel.transform, "ConfigZ" + i);
                zonePanel.autoLayout                  = true;
                zonePanel.autoLayoutDirection         = LayoutDirection.Horizontal;
                zonePanel.autoLayoutPadding           = new RectOffset(5, 5, 0, 0);
                zonePanel.wrapLayout                  = false;
                zonePanel.autoFitChildrenHorizontally = true;
                zonePanel.autoFitChildrenVertically   = true;

                var uiHelperExt = new UIHelperExtension(zonePanel);
                uiHelperExt.AddUiSprite("ZoningZ" + idx, UIView.GetAView().defaultAtlas).size = new Vector2(40, 32);
                UITextField nameInput;
                nameInput = CreateMiniTextField(zonePanel, CustomZoneData.Instance[idx].ZoneName, "ConfigZ" + idx);
                nameInput.eventTextSubmitted += (x, y) =>
                {
                    if (!m_loading)
                    {
                        CustomZoneData.Instance[idx].ZoneName = y;
                        nameInput.text = CustomZoneData.Instance[idx].ZoneName;
                    }
                };
                CustomZoneData.EventOneChanged += (x) =>
                {
                    if (x == idx)
                    {
                        nameInput.text = CustomZoneData.Instance[idx].ZoneName;
                    }
                };
                CustomZoneData.EventAllChanged += () => nameInput.text = CustomZoneData.Instance[idx].ZoneName;


                foreach (ItemClass.Zone zone in ZoneMixerOverrides.ZONES_TO_CHECK)
                {
                    AddCheckboxZone(idx, uiHelperExt, zone);
                }
            }


            CustomZoneData.EventAllChanged += () =>
            {
                FindObjectOfType <ZoningPanel>()?.RefreshPanel();
            };
            CustomZoneData.EventOneChanged += (x) =>
            {
                FindObjectOfType <ZoningPanel>()?.RefreshPanel();
            };
        }