コード例 #1
0
        private void Initialise()
        {
            if (_helper == null)
            {
                width         = 400;
                height        = 500;
                isInteractive = true;
                enabled       = true;

                _helper           = new UIHelper(this);
                _titleBar         = AddUIComponent <UITitleBar>();
                _informationLabel = AddUIComponent <UILabel>();
                _totalPanel       = AddUIComponent <UIPanel>();
                _totalAmountLabel = _totalPanel.AddUIComponent <UILabel>();
                _totalIncomeLabel = _totalPanel.AddUIComponent <UILabel>();
                _costLabel        = _totalPanel.AddUIComponent <UILabel>();
                _incomeLabel      = _totalPanel.AddUIComponent <UILabel>();
                _incentiveList    = UIFastList.Create <UIFastListIncentives>(this);

                _titleBar.Initialise(CimTools.CimToolsHandler.CimToolBase);

                _ticketSlider = _helper.AddSlider("Tickets", 100, 9000, 10, 500, delegate(float value)
                {
                    if (_incentiveList != null)
                    {
                        FastList <object> optionItems = _incentiveList.rowsData;

                        foreach (IncentiveOptionItem optionItemObject in optionItems)
                        {
                            optionItemObject.ticketCount = value;
                            optionItemObject.UpdateTicketSize();
                        }
                    }
                }) as UISlider;

                _startDaySlider = _helper.AddSlider("Days", 0, 7, 1, 0, delegate(float value)
                {
                    CalculateTotal();
                }) as UISlider;

                TimeOfDaySlider startTimeSliderOptions = new TimeOfDaySlider()
                {
                    uniqueName = "Time", value = 12f
                };
                _startTimeSlider = startTimeSliderOptions.Create(_helper) as UISlider;
                _startTimeSlider.eventValueChanged += delegate(UIComponent component, float value)
                {
                    CalculateTotal();
                };

                _createButton = _helper.AddButton("Create", new OnButtonClicked(CreateEvent)) as UIButton;

                CimTools.CimToolsHandler.CimToolBase.Translation.OnLanguageChanged += Translation_OnLanguageChanged;
            }
        }
コード例 #2
0
        private void Initialise()
        {
            if (mainHelper == null)
            {
                isVisible = true;
                canFocus  = true;
                width     = parent.width;
                height    = 76;

                mainHelper     = new UIHelper(this);
                background     = AddUIComponent <UIPanel>();
                totalsPanel    = AddUIComponent <UIPanel>();
                effects        = totalsPanel.AddUIComponent <UILabel>();
                costsLabel     = totalsPanel.AddUIComponent <UILabel>();
                returnsLabel   = totalsPanel.AddUIComponent <UILabel>();
                costsReadout   = totalsPanel.AddUIComponent <UILabel>();
                returnsReadout = totalsPanel.AddUIComponent <UILabel>();
                //title = AddUIComponent<UILabel>();

                amount = mainHelper.AddSlider(" ", 0, 100, 10, 0, delegate(float val)
                {
                    if (currentOption != null)
                    {
                        currentOption.sliderValue = val;

                        UpdateTotals();
                        currentOption.UpdateItemChanged();
                    }
                }) as UISlider;

                CimTools.CimToolsHandler.CimToolBase.Translation.OnLanguageChanged += Translation_OnLanguageChanged;
            }
        }
コード例 #3
0
        public void SettingsUi(UIHelperBase helper)
        {
            var actualHelper = (UIHelper)helper;
            var container    = (UIComponent)actualHelper.self;

            actualHelper.AddButton("Save", Save);

            var tabStrip = container.AddUIComponent <UITabstrip>();

            tabStrip.relativePosition = new Vector3(0, 0);
            tabStrip.size             = new Vector2(container.width - 20, 40);

            var tabContainer = container.AddUIComponent <UITabContainer>();

            tabContainer.relativePosition = new Vector3(0, 40);
            tabContainer.size             = new Vector2(container.width - 20, container.height - tabStrip.height - 20);
            tabStrip.tabPages             = tabContainer;
            addTab(tabStrip, "General");
            addTab(tabStrip, "Services");
            addTab(tabStrip, "Transportation");

            var currentUiPanel = new List <UIPanel>();

            for (var i = 0; i < tabStrip.tabCount; i++)
            {
                currentUiPanel.Add((UIPanel)tabStrip.tabContainer.components[i]);
                currentUiPanel[i].autoLayout              = true;
                currentUiPanel[i].autoLayoutDirection     = LayoutDirection.Vertical;
                currentUiPanel[i].autoLayoutPadding.top   = 7;
                currentUiPanel[i].autoLayoutPadding.left  = 5;
                currentUiPanel[i].autoLayoutPadding.right = 5;
            }
            var panelHelper = new UIHelper(currentUiPanel[0]);


            Sliders.Education =
                (UISlider)
                panelHelper.AddSlider("Education:", 0, 1, 0.05f, Vars.Datam.Education, val => Vars.Datam.Education = val);
            Sliders.Education.eventTooltipHover        +=
                (component, param) => component.tooltip = $"{Vars.Datam.Education*100}%";
            Sliders.Electricity =
                (UISlider)
                panelHelper.AddSlider("Electricity:", 0, 1, 0.05f, Vars.Datam.Electricity,
                                      val => Vars.Datam.Electricity = val);
            Sliders.Electricity.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Electricity*100}%";

            Sliders.Garbage =
                (UISlider)
                panelHelper.AddSlider("Garbage:", 0, 1, 0.05f, Vars.Datam.Garbage, val => Vars.Datam.Garbage = val);
            Sliders.Garbage.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Garbage * 100}%";

            Sliders.Monuments =
                (UISlider)
                panelHelper.AddSlider("Monuments:", 0, 1, 0.05f, Vars.Datam.Monument, val => Vars.Datam.Monument = val);
            Sliders.Monuments.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Monument * 100}%";
            Sliders.Beauty =
                (UISlider)
                panelHelper.AddSlider("Parks:", 0, 1, 0.05f, Vars.Datam.Beauty, val => Vars.Datam.Beauty = val);
            Sliders.Beauty.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Beauty * 100}%";

            Sliders.Roads =
                (UISlider)
                panelHelper.AddSlider("Roads:", 0, 1, 0.05f, Vars.Datam.Road, val => Vars.Datam.Road = val);
            Sliders.Roads.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Road * 100}%";
            Sliders.Water =
                (UISlider)
                panelHelper.AddSlider("Water Service:", 0, 1, 0.05f, Vars.Datam.Water, val => Vars.Datam.Water = val);
            Sliders.Water.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Water * 100}%";

            panelHelper      = new UIHelper(currentUiPanel[1]);
            Sliders.Disaster =
                (UISlider)
                panelHelper.AddSlider("Disaster:", 0, 1, 0.05f, Vars.Datam.Disaster, val => Vars.Datam.Disaster = val);
            Sliders.Disaster.eventTooltipHover         +=
                (component, param) => component.tooltip = $"{Vars.Datam.Disaster * 100}%";
            Sliders.Fire =
                (UISlider)
                panelHelper.AddSlider("Fire Department:", 0, 1, 0.05f, Vars.Datam.Fire, val => Vars.Datam.Fire = val);
            Sliders.Fire.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Fire * 100}%";
            Sliders.Healthcare              =
                (UISlider)
                panelHelper.AddSlider("Healthcare:", 0, 1, 0.05f, Vars.Datam.Health, val => Vars.Datam.Health = val);
            Sliders.Healthcare.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Health * 100}%";
            Sliders.Police =
                (UISlider)
                panelHelper.AddSlider("Police Department:", 0, 1, 0.05f, Vars.Datam.Police, val => Vars.Datam.Police = val);
            Sliders.Police.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Police * 100}%";


            panelHelper = new UIHelper(currentUiPanel[2]);
            Sliders.Bus =
                (UISlider)panelHelper.AddSlider("Bus:", 0, 1, 0.05f, Vars.Datam.Bus, val => Vars.Datam.Bus = val);
            Sliders.Bus.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Bus * 100}%";

            Sliders.Tram =
                (UISlider)panelHelper.AddSlider("Tram:", 0, 1, 0.05f, Vars.Datam.Tram, val => Vars.Datam.Tram = val);
            Sliders.Tram.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Tram * 100}%";

            Sliders.Metro =
                (UISlider)panelHelper.AddSlider("Metro:", 0, 1, 0.05f, Vars.Datam.Metro, val => Vars.Datam.Metro = val);
            Sliders.Metro.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Metro * 100}%";

            Sliders.Train =
                (UISlider)panelHelper.AddSlider("Train:", 0, 1, 0.05f, Vars.Datam.Train, val => Vars.Datam.Train = val);
            Sliders.Train.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Train * 100}%";

            Sliders.Ship =
                (UISlider)panelHelper.AddSlider("Ship:", 0, 1, 0.05f, Vars.Datam.Ship, val => Vars.Datam.Ship = val);
            Sliders.Ship.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Ship*100}%";

            Sliders.Plane =
                (UISlider)panelHelper.AddSlider("Plane:", 0, 1, 0.05f, Vars.Datam.Plane, val => Vars.Datam.Plane = val);
            Sliders.Plane.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Plane * 100}%";

            Sliders.Taxi =
                (UISlider)panelHelper.AddSlider("Taxi:", 0, 1, 0.05f, Vars.Datam.Taxi, val => Vars.Datam.Taxi = val);
            Sliders.Taxi.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Taxi * 100}%";

            Sliders.MonoRail =
                (UISlider)panelHelper.AddSlider("Monorail:", 0, 1, 0.05f, Vars.Datam.MonoRail, val => Vars.Datam.MonoRail = val);
            Sliders.MonoRail.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.MonoRail * 100}%";

            Sliders.Cablecar =
                (UISlider)panelHelper.AddSlider("Cablecar:", 0, 1, 0.05f, Vars.Datam.Cablecar, val => Vars.Datam.Cablecar = val);
            Sliders.Cablecar.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Cablecar * 100}%";

            Sliders.Tours =
                (UISlider)panelHelper.AddSlider("Sightseeing:", 0, 1, 0.05f, Vars.Datam.Tours, val => Vars.Datam.Tours = val);
            Sliders.Tours.eventTooltipHover += (component, param) => component.tooltip = $"{Vars.Datam.Tours * 100}%";

            tabContainer.selectedIndex = 1;
            tabContainer.selectedIndex = 0;
        }