Example #1
0
        private void CreateCheckboxes()
        {
            foreach (var i in m_checkboxes?.Keys)
            {
                UnityEngine.Object.Destroy(m_checkboxes[i].gameObject);
            }
            m_defaultAssets = extension.GetAllBasicAssets();
            m_checkboxes    = new Dictionary <string, UICheckBox>();

            SVMUtils.doLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0]));
            foreach (var i in m_defaultAssets.Keys)
            {
                var checkbox = (UICheckBox)m_uiHelper.AddCheckbox(m_defaultAssets[i], false, (x) =>
                {
                    int districtIdx = SVMServiceBuildingDetailPanel.Get().getCurrentSelectedDistrictId();
                    if (m_isLoading || districtIdx < 0)
                    {
                        return;
                    }
                    if (x)
                    {
                        extension.AddAssetDistrict((uint)districtIdx, i);
                    }
                    else
                    {
                        extension.RemoveAssetDistrict((uint)districtIdx, i);
                    }
                });
                CreateModelCheckBox(i, checkbox);
                checkbox.label.tooltip              = checkbox.label.text;
                checkbox.label.textScale            = 0.9f;
                checkbox.label.transform.localScale = new Vector3(Math.Min((m_mainPanel.width - 70) / checkbox.label.width, 1), 1);
                m_checkboxes[i] = checkbox;
            }
        }
Example #2
0
        public void Start()
        {
            UITabstrip toolStrip = ToolsModifierControl.mainToolbar.GetComponentInChildren <UITabstrip>();

            openSVMPanelButton                       = toolStrip.AddTab();
            this.openSVMPanelButton.size             = new Vector2(49f, 49f);
            this.openSVMPanelButton.name             = "ServiceVehiclesManagerButton";
            this.openSVMPanelButton.tooltip          = "Service Vehicles Manager (v" + ServiceVehiclesManagerMod.version + ")";
            this.openSVMPanelButton.relativePosition = new Vector3(0f, 5f);
            toolStrip.AddTab("ServiceVehiclesManagerButton", this.openSVMPanelButton.gameObject, null, null);
            openSVMPanelButton.atlas           = taSVM;
            openSVMPanelButton.normalBgSprite  = "ServiceVehiclesManagerIconSmall";
            openSVMPanelButton.focusedFgSprite = "ToolbarIconGroup6Focused";
            openSVMPanelButton.hoveredFgSprite = "ToolbarIconGroup6Hovered";
            this.openSVMPanelButton.eventButtonStateChanged += delegate(UIComponent c, UIButton.ButtonState s)
            {
                if (s == UIButton.ButtonState.Focused)
                {
                    internal_OpenSVMPanel();
                }
                else
                {
                    internal_CloseSVMPanel();
                }
            };
            m_listPanel = SVMServiceBuildingDetailPanel.Get();

            SVMUtils.createUIElement(out buildingInfoParent, FindObjectOfType <UIView>().transform, "SVMBuildingInfoPanel", new Vector4(0, 0, 0, 1));

            buildingInfoParent.gameObject.AddComponent <SVMBuildingInfoPanel>();
            var         typeTarg  = typeof(Redirector <>);
            List <Type> instances = GetSubtypesRecursive(typeTarg);

            foreach (Type t in instances)
            {
                gameObject.AddComponent(t);
            }
        }