示例#1
0
        private void AddDistrictOptionsButton(DistrictWorldInfoPanel infoPanel, out UIButton button, Vector3 offset)
        {
            button = UIUtils.CreateToggleButton(infoPanel.component, offset, UIAlignAnchor.BottomLeft, (component, e) =>
            {
                InstanceID instanceID = (InstanceID)infoPanel.GetType()
                                        .GetField("m_InstanceID", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(infoPanel);

                var district = DistrictManager.instance.m_districts.m_buffer[instanceID.District];

                try
                {
                    if (CustomDistrictOptionsPanelWrapper == null || instanceID.District != SelectedDistrictID)
                    {
                        CustomDistrictOptionsPanelWrapper = district.GenerateDistrictOptions(instanceID.District);
                    }
                    else
                    {
                        CustomDistrictOptionsPanelWrapper.isVisible = false;
                        UIUtils.DeepDestroy(CustomDistrictOptionsPanelWrapper);
                    }
                }
                catch (Exception ex)
                {
                    DebugHelper.Log(
                        $"Couldn't Generate District Options for {DistrictManager.instance.GetDistrictName(instanceID.District)}. {ex.Message} - {ex.StackTrace}");
                }

                if (component.hasFocus)
                {
                    component.Unfocus();
                }
            });
        }
示例#2
0
        public static DistrictOptionsPanelWrapper GenerateDistrictOptions(this District district, byte id)
        {
            try
            {
                AdvancedDistrictOptionsTool.instance.SelectedDistrictID = id;

                if (AdvancedDistrictOptionsTool.instance.CustomDistrictOptionsPanelWrapper != null)
                {
                    UIUtils.DeepDestroy(AdvancedDistrictOptionsTool.instance.CustomDistrictOptionsPanelWrapper);
                }

                return(UIView.GetAView().AddUIComponent(typeof(DistrictOptionsPanelWrapper)) as
                       DistrictOptionsPanelWrapper);
            }
            catch (Exception e)
            {
                DebugHelper.Log($"Couldn't Generate District Options for {DistrictManager.instance.GetDistrictName(id)}. {e.Message} - {e.StackTrace}");
                return(null);
            }
        }