Example #1
0
        private void SetupControls()
        {
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.gameObject.AddComponent <UICustomControl>();

            panel.backgroundSprite = "UnlockingPanel";
            panel.width            = width - 10;
            panel.height           = height - 75;
            panel.relativePosition = new Vector3(5, 0);

            // Max Speed
            UILabel maxSpeedLabel = panel.AddUIComponent <UILabel>();

            maxSpeedLabel.text             = Translations.Translate("AVO_MOD_OP06");
            maxSpeedLabel.textScale        = 0.8f;
            maxSpeedLabel.relativePosition = new Vector3(15, 14);

            m_maxSpeed = UIUtils.CreateTextField(panel);
            m_maxSpeed.numericalOnly    = true;
            m_maxSpeed.width            = 75;
            m_maxSpeed.tooltip          = Translations.Translate("AVO_MOD_OP07");
            m_maxSpeed.relativePosition = new Vector3(15, 33);

            kmhLabel                  = panel.AddUIComponent <UILabel>();
            kmhLabel.text             = "km/h";
            kmhLabel.textScale        = 0.8f;
            kmhLabel.relativePosition = new Vector3(95, 38);

            // Acceleration
            UILabel accelerationLabel = panel.AddUIComponent <UILabel>();

            accelerationLabel.text             = Translations.Translate("AVO_MOD_OP08");
            accelerationLabel.textScale        = 0.8f;
            accelerationLabel.relativePosition = new Vector3(160, 13);

            m_acceleration = UIUtils.CreateTextField(panel);
            m_acceleration.numericalOnly    = true;
            m_acceleration.allowFloats      = true;
            m_acceleration.width            = 60;
            m_acceleration.tooltip          = Translations.Translate("AVO_MOD_OP09");
            m_acceleration.relativePosition = new Vector3(160, 33);

            // Braking
            m_braking = UIUtils.CreateTextField(panel);
            m_braking.numericalOnly    = true;
            m_braking.allowFloats      = true;
            m_braking.width            = 60;
            m_braking.tooltip          = Translations.Translate("AVO_MOD_OP10");
            m_braking.relativePosition = new Vector3(230, 33);

            // Turning
            m_turning = UIUtils.CreateTextField(panel);
            m_turning.numericalOnly    = true;
            m_turning.allowFloats      = true;
            m_turning.width            = 60;
            m_turning.tooltip          = Translations.Translate("AVO_MOD_OP11");
            m_turning.relativePosition = new Vector3(300, 33);

            // Springs
            UILabel springsLabel = panel.AddUIComponent <UILabel>();

            springsLabel.text             = Translations.Translate("AVO_MOD_OP12");
            springsLabel.textScale        = 0.8f;
            springsLabel.relativePosition = new Vector3(15, 66);

            m_springs = UIUtils.CreateTextField(panel);
            m_springs.numericalOnly    = true;
            m_springs.allowFloats      = true;
            m_springs.width            = 60;
            m_springs.tooltip          = Translations.Translate("AVO_MOD_OP13");
            m_springs.relativePosition = new Vector3(15, 85);

            // Dampers
            m_dampers = UIUtils.CreateTextField(panel);
            m_dampers.numericalOnly    = true;
            m_dampers.allowFloats      = true;
            m_dampers.width            = 60;
            m_dampers.tooltip          = Translations.Translate("AVO_MOD_OP14");
            m_dampers.relativePosition = new Vector3(85, 85);

            // LeanMultiplier
            UILabel leanMultiplierLabel = panel.AddUIComponent <UILabel>();

            leanMultiplierLabel.text             = Translations.Translate("AVO_MOD_OP15");
            leanMultiplierLabel.textScale        = 0.8f;
            leanMultiplierLabel.relativePosition = new Vector3(160, 66);

            m_leanMultiplier = UIUtils.CreateTextField(panel);
            m_leanMultiplier.numericalOnly    = true;
            m_leanMultiplier.allowFloats      = true;
            m_leanMultiplier.width            = 60;
            m_leanMultiplier.tooltip          = Translations.Translate("AVO_MOD_OP16");
            m_leanMultiplier.relativePosition = new Vector3(160, 85);

            // NodMultiplier
            m_nodMultiplier = UIUtils.CreateTextField(panel);
            m_nodMultiplier.numericalOnly    = true;
            m_nodMultiplier.allowFloats      = true;
            m_nodMultiplier.width            = 60;
            m_nodMultiplier.tooltip          = Translations.Translate("AVO_MOD_OP17");
            m_nodMultiplier.relativePosition = new Vector3(230, 85);

            // Colors
            m_useColors                  = UIUtils.CreateCheckBox(panel);
            m_useColors.text             = Translations.Translate("AVO_MOD_OP18");
            m_useColors.isChecked        = true;
            m_useColors.width            = width - 40;
            m_useColors.tooltip          = Translations.Translate("AVO_MOD_OP19");
            m_useColors.relativePosition = new Vector3(15, 116);

            m_color0                      = UIUtils.CreateColorField(panel);
            m_color0.name                 = "AVO-color0";
            m_color0.popupTopmostRoot     = false;
            m_color0.relativePosition     = new Vector3(35, 135);
            m_color0_hex                  = UIUtils.CreateTextField(panel);
            m_color0_hex.maxLength        = 6;
            m_color0_hex.relativePosition = new Vector3(80, 137);

            m_color1                      = UIUtils.CreateColorField(panel);
            m_color1.name                 = "AVO-color1";
            m_color1.popupTopmostRoot     = false;
            m_color1.relativePosition     = new Vector3(35, 160);
            m_color1_hex                  = UIUtils.CreateTextField(panel);
            m_color1_hex.maxLength        = 6;
            m_color1_hex.relativePosition = new Vector3(80, 162);

            m_color2                      = UIUtils.CreateColorField(panel);
            m_color2.name                 = "AVO-color2";
            m_color2.popupTopmostRoot     = false;
            m_color2.relativePosition     = new Vector3(182, 135);
            m_color2_hex                  = UIUtils.CreateTextField(panel);
            m_color2_hex.maxLength        = 6;
            m_color2_hex.relativePosition = new Vector3(225, 137);

            m_color3                      = UIUtils.CreateColorField(panel);
            m_color3.name                 = "AVO-color3";
            m_color3.popupTopmostRoot     = false;
            m_color3.relativePosition     = new Vector3(182, 160);
            m_color3_hex                  = UIUtils.CreateTextField(panel);
            m_color3_hex.maxLength        = 6;
            m_color3_hex.relativePosition = new Vector3(225, 162);

            m_useColorsLabel = panel.AddUIComponent <UILabel>();
            m_useColorsLabel.Hide();
            m_useColorsLabel.textScale        = 0.8f;
            m_useColorsLabel.text             = Translations.Translate("AVO_MOD_OP20");
            m_useColorsLabel.relativePosition = new Vector3(15, 116);

            // Enable & BackEngine
            m_enabled                  = UIUtils.CreateCheckBox(panel);
            m_enabled.text             = Translations.Translate("AVO_MOD_OP21");
            m_enabled.isChecked        = true;
            m_enabled.width            = width - 40;
            m_enabled.tooltip          = Translations.Translate("AVO_MOD_OP22");
            m_enabled.relativePosition = new Vector3(15, 195);

            m_addBackEngine                  = UIUtils.CreateCheckBox(panel);
            m_addBackEngine.text             = Translations.Translate("AVO_MOD_OP23");
            m_addBackEngine.isChecked        = false;
            m_addBackEngine.width            = width - 40;
            m_addBackEngine.tooltip          = Translations.Translate("AVO_MOD_OP24");
            m_addBackEngine.relativePosition = new Vector3(15, 215);

            // LargeVehicle Setting for NoBigTruck Delivery Mod
            m_isLargeVehicle                  = UIUtils.CreateCheckBox(panel);
            m_isLargeVehicle.text             = Translations.Translate("AVO_MOD_OP25");
            m_isLargeVehicle.width            = width - 40;
            m_isLargeVehicle.tooltip          = Translations.Translate("AVO_MOD_OP26");
            m_isLargeVehicle.relativePosition = new Vector3(15, 215);

            // Capacity
            UIPanel capacityPanel = panel.AddUIComponent <UIPanel>();

            capacityPanel.size             = Vector2.zero;
            capacityPanel.relativePosition = new Vector3(15, 240);

            capacityLabel                  = capacityPanel.AddUIComponent <UILabel>();
            capacityLabel.text             = Translations.Translate("AVO_MOD_CAPA");
            capacityLabel.textScale        = 0.8f;
            capacityLabel.relativePosition = new Vector3(0, 2);

            m_capacity = UIUtils.CreateTextField(capacityPanel);
            m_capacity.numericalOnly    = true;
            m_capacity.maxLength        = 8;
            m_capacity.width            = 100;
            m_capacity.tooltip          = Translations.Translate("AVO_MOD_OP27");
            m_capacity.relativePosition = new Vector3(0, 21);

            m_planesize                  = capacityPanel.AddUIComponent <UILabel>();
            m_planesize.textScale        = 0.8f;
            m_planesize.relativePosition = new Vector3(170, 2);

            // Special Capacity
            specialcapacityLabel = capacityPanel.AddUIComponent <UILabel>();
            specialcapacityLabel.Hide();
            specialcapacityLabel.text             = Translations.Translate("AVO_MOD_OP28");
            specialcapacityLabel.textScale        = 0.8f;
            specialcapacityLabel.relativePosition = new Vector3(160, 2);

            m_specialcapacity = UIUtils.CreateTextField(capacityPanel);
            m_specialcapacity.Hide();
            m_specialcapacity.numericalOnly    = true;
            m_specialcapacity.maxLength        = 8;
            m_specialcapacity.width            = 100;
            m_specialcapacity.tooltip          = Translations.Translate("AVO_MOD_OP29");
            m_specialcapacity.relativePosition = new Vector3(160, 21);

            // Userguide Special Capacity Button
            m_userguidespecialcapacity = UIUtils.CreateButton(capacityPanel);
            m_userguidespecialcapacity.Hide();
            m_userguidespecialcapacity.normalBgSprite   = "EconomyMoreInfo";
            m_userguidespecialcapacity.hoveredBgSprite  = "EconomyMoreInfoHovered";
            m_userguidespecialcapacity.size             = new Vector2(14f, 14f);
            m_userguidespecialcapacity.tooltip          = Translations.Translate("AVO_MOD_OP30");
            m_userguidespecialcapacity.relativePosition = new Vector3(265, 24);

            // Transport Line Overview Button
            m_lineoverview = UIUtils.CreateButton(panel);
            m_lineoverview.Hide();
            m_lineoverview.textScale             = 0.8f;
            m_lineoverview.height                = 18;
            m_lineoverview.textVerticalAlignment = UIVerticalAlignment.Bottom;
            m_lineoverview.text             = Translations.Translate("AVO_MOD_OP31");
            m_lineoverview.width            = 335;
            m_lineoverview.tooltip          = Translations.Translate("AVO_MOD_OP32");
            m_lineoverview.relativePosition = new Vector3(15, 194);

            // Userguide Spawn Button
            m_userguidespawn = UIUtils.CreateButton(panel);
            m_userguidespawn.Hide();
            m_userguidespawn.normalBgSprite   = "EconomyMoreInfo";
            m_userguidespawn.hoveredBgSprite  = "EconomyMoreInfoHovered";
            m_userguidespawn.size             = new Vector2(14f, 14f);
            m_userguidespawn.tooltip          = Translations.Translate("AVO_MOD_OP33");
            m_userguidespawn.relativePosition = new Vector3(355, 195);

            // Buslabel
            bustrailerLabel                  = panel.AddUIComponent <UILabel>();
            bustrailerLabel.textScale        = 0.8f;
            bustrailerLabel.text             = Translations.Translate("AVO_MOD_OP34");
            bustrailerLabel.relativePosition = new Vector3(15, 194);

            // Restore default
            m_restore                  = UIUtils.CreateButton(panel);
            m_restore.text             = Translations.Translate("AVO_MOD_OP35");
            m_restore.width            = 120;
            m_restore.tooltip          = Translations.Translate("AVO_MOD_OP36");
            m_restore.relativePosition = new Vector3(250, height - 45);

            // Remove Vehicles
            m_removeLabel                  = this.AddUIComponent <UILabel>();
            m_removeLabel.text             = Translations.Translate("AVO_MOD_OP37");
            m_removeLabel.textScale        = 0.8f;
            m_removeLabel.relativePosition = new Vector3(10, height - 65);

            m_clearVehicles                  = UIUtils.CreateButton(this);
            m_clearVehicles.text             = Translations.Translate("AVO_MOD_OP38");
            m_clearVehicles.width            = 120;
            m_clearVehicles.tooltip          = Translations.Translate("AVO_MOD_OP39");
            m_clearVehicles.relativePosition = new Vector3(5, height - 45);

            m_clearParked                  = UIUtils.CreateButton(this);
            m_clearParked.text             = Translations.Translate("AVO_MOD_OP40");
            m_clearParked.width            = 120;
            m_clearParked.tooltip          = Translations.Translate("AVO_MOD_OP41");
            m_clearParked.relativePosition = new Vector3(130, height - 45);

            panel.BringToFront();

            // Event handlers
            m_maxSpeed.eventTextSubmitted       += OnMaxSpeedSubmitted;
            m_acceleration.eventTextSubmitted   += OnAccelerationSubmitted;
            m_braking.eventTextSubmitted        += OnBrakingSubmitted;
            m_turning.eventTextSubmitted        += OnTurningSubmitted;
            m_springs.eventTextSubmitted        += OnSpringsSubmitted;
            m_dampers.eventTextSubmitted        += OnDampersSubmitted;
            m_leanMultiplier.eventTextSubmitted += OnleanMultiplierSubmitted;
            m_nodMultiplier.eventTextSubmitted  += OnnodMultiplierSubmitted;

            m_useColors.eventCheckChanged += OnCheckChanged;

            MouseEventHandler mousehandler = (c, p) => { if (m_initialized)
                                                         {
                                                             (parent as UIMainPanel).ChangePreviewColor((c as UIColorField).selectedColor);
                                                         }
            };

            m_color0.eventMouseEnter += mousehandler;
            m_color1.eventMouseEnter += mousehandler;
            m_color2.eventMouseEnter += mousehandler;
            m_color3.eventMouseEnter += mousehandler;

            m_color0_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color0.selectedColor);
                                                        }
            };
            m_color1_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color1.selectedColor);
                                                        }
            };
            m_color2_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color2.selectedColor);
                                                        }
            };
            m_color3_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color3.selectedColor);
                                                        }
            };

            m_color0.eventSelectedColorChanged += OnColorChanged;
            m_color1.eventSelectedColorChanged += OnColorChanged;
            m_color2.eventSelectedColorChanged += OnColorChanged;
            m_color3.eventSelectedColorChanged += OnColorChanged;

            m_color0_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color1_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color2_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color3_hex.eventTextSubmitted += OnColorHexSubmitted;

            m_enabled.eventCheckChanged        += OnCheckChanged;
            m_addBackEngine.eventCheckChanged  += OnCheckChanged;
            m_isLargeVehicle.eventCheckChanged += OnCheckChanged;

            m_capacity.eventTextSubmitted        += OnCapacitySubmitted;
            m_specialcapacity.eventTextSubmitted += OnSpecialCapacitySubmitted;

            m_restore.eventClick += (c, p) =>
            {
                m_initialized = false;
                bool isEnabled = m_options.enabled;
                DefaultOptions.Restore(m_options.prefab);
                VehicleOptions.UpdateTransfertVehicles();

                VehicleOptions.prefabUpdateEngine = m_options.prefab;
                VehicleOptions.prefabUpdateUnits  = m_options.prefab;
                SimulationManager.instance.AddAction(VehicleOptions.UpdateBackEngines);
                SimulationManager.instance.AddAction(VehicleOptions.UpdateCapacityUnits);

                Show(m_options);

                if (m_options.enabled != isEnabled)
                {
                    eventEnableCheckChanged(this, m_options.enabled);
                }
            };

            m_clearVehicles.eventClick            += OnClearVehicleClicked;
            m_clearParked.eventClick              += OnClearVehicleClicked;
            m_lineoverview.eventClick             += OnlineoverviewClicked;
            m_userguidespawn.eventClick           += OnUserGuideSpawnClicked;
            m_userguidespecialcapacity.eventClick += OnUserGuideSpecialCapacityClicked;
        }
Example #2
0
        internal void SetupControls()
        {
            float offset = 40f;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "InfoIconTrafficCongestion";
            m_title.title      = AVOMod.ModName + " " + AVOMod.Version;

            // Category DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(10f, offset);
            label.text             = Translations.Translate("AVO_MOD_MP56");

            m_category       = UIUtils.CreateDropDown(this);
            m_category.width = 175;

            for (int i = 0; i < categoryList.Length; i++)
            {
                m_category.AddItem(categoryList[i]);
            }

            m_category.selectedIndex    = 0;
            m_category.tooltip          = Translations.Translate("AVO_MOD_MP39");
            m_category.relativePosition = label.relativePosition + new Vector3(75f, 0f);

            m_category.eventSelectedIndexChanged += (c, t) =>
            {
                m_category.enabled = false;
                PopulateList();
                m_category.enabled = true;
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 145f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.tooltip          = Translations.Translate("AVO_MOD_MP40");
            m_search.relativePosition = new Vector3(WIDTHLEFT - m_search.width, offset);

            m_search.eventTextChanged += (c, t) => PopulateList();

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = Translations.Translate("AVO_MOD_MP55");

            // FastList
            m_fastList = UIFastList.Create <UIVehicleItem>(this);
            m_fastList.backgroundSprite = "UnlockingPanel";
            m_fastList.width            = WIDTHLEFT - 5;
            m_fastList.height           = height - offset - 110;
            m_fastList.canSelect        = true;
            m_fastList.relativePosition = new Vector3(5, offset + 35);

            // Configuration file buttons
            UILabel configLabel = this.AddUIComponent <UILabel>();

            configLabel.text             = Translations.Translate("AVO_MOD_MP41");
            configLabel.textScale        = 0.8f;
            configLabel.relativePosition = new Vector3(16, height - 65);

            m_import                  = UIUtils.CreateButton(this);
            m_import.text             = Translations.Translate("AVO_MOD_MP42");
            m_import.width            = 80;
            m_import.tooltip          = Translations.Translate("AVO_MOD_MP43");
            m_import.relativePosition = new Vector3(10, height - 45);

            m_export                  = UIUtils.CreateButton(this);
            m_export.text             = Translations.Translate("AVO_MOD_MP44");
            m_export.width            = 80;
            m_export.tooltip          = Translations.Translate("AVO_MOD_MP45");
            m_export.relativePosition = new Vector3(95, height - 45);

            m_resetall                  = UIUtils.CreateButton(this);
            m_resetall.text             = Translations.Translate("AVO_MOD_MP46");
            m_resetall.width            = 80;
            m_resetall.tooltip          = Translations.Translate("AVO_MOD_MP47");
            m_resetall.relativePosition = new Vector3(180, height - 45);

            m_autosave                  = AddUIComponent <UILabel>();
            m_autosave.textScale        = 0.6f;
            m_autosave.text             = Translations.Translate("AVO_MOD_MP48");
            m_autosave.relativePosition = new Vector3(275, height - 40);
            m_autosave.autoSize         = true;
            m_autosave.textAlignment    = UIHorizontalAlignment.Center;
            m_autosave.textColor        = Color.green;
            m_autosave.tooltip          = Translations.Translate("AVO_MOD_MP49");
            m_autosave.isVisible        = AdvancedVehicleOptions.AutoSaveVehicleConfig;

            // Preview
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.backgroundSprite = "GenericPanel";
            panel.width            = WIDTHRIGHT - 10;
            panel.height           = HEIGHT - 420;
            panel.relativePosition = new Vector3(WIDTHLEFT + 5, offset);

            m_preview                  = panel.AddUIComponent <UITextureSprite>();
            m_preview.size             = panel.size;
            m_preview.relativePosition = Vector3.zero;

            m_previewRenderer      = gameObject.AddComponent <PreviewRenderer>();
            m_previewRenderer.size = m_preview.size * 2; // Twice the size for anti-aliasing

            m_preview.texture = m_previewRenderer.texture;

            // Follow a vehicle
            if (m_cameraController != null)
            {
                m_followVehicle                  = AddUIComponent <UISprite>();
                m_followVehicle.spriteName       = "LocationMarkerFocused";
                m_followVehicle.width            = m_followVehicle.spriteInfo.width;
                m_followVehicle.height           = m_followVehicle.spriteInfo.height;
                m_followVehicle.tooltip          = Translations.Translate("AVO_MOD_MP50");
                m_followVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_followVehicle.width - 5, panel.relativePosition.y + 5);

                m_followVehicle.eventClick += (c, p) => FollowNextVehicle();
            }

            //Remove the followed vehicle
            {
                m_removeVehicle = AddUIComponent <UISprite>();
                m_removeVehicle.Hide();
                m_removeVehicle.spriteName       = "IconPolicyOldTown";
                m_removeVehicle.width            = m_removeVehicle.spriteInfo.width - 12;
                m_removeVehicle.height           = m_removeVehicle.spriteInfo.height - 12;
                m_removeVehicle.tooltip          = Translations.Translate("AVO_MOD_MP51");
                m_removeVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_removeVehicle.width - 33, panel.relativePosition.y + 7);

                m_removeVehicle.eventClick += (c, p) => RemoveThisVehicle();
            }

            // Option panel
            m_optionPanel = AddUIComponent <UIOptionPanel>();
            m_optionPanel.relativePosition = new Vector3(WIDTHLEFT, height - 370);

            // Event handlers
            m_fastList.eventSelectedIndexChanged  += OnSelectedItemChanged;
            m_optionPanel.eventEnableCheckChanged += OnEnableStateChanged;

            m_import.eventClick += (c, t) =>
            {
                DefaultOptions.RestoreAll();
                AdvancedVehicleOptions.ImportVehicleDataConfig();
                optionList = AdvancedVehicleOptions.config.options;
            };

            m_export.eventClick += (c, t) => AdvancedVehicleOptions.ExportVehicleDataConfig(true);

            m_resetall.eventClick += (c, t) =>
            {
                ConfirmPanel.ShowModal(Translations.Translate("AVO_MOD_MP52"), Translations.Translate("AVO_MOD_MP53"), (comp, ret) =>
                {
                    if (ret != 1)
                    {
                        return;
                    }

                    DefaultOptions.RestoreAll();
                    AdvancedVehicleOptions.ResetVehicleDataConfig();
                    optionList = AdvancedVehicleOptions.config.options;

                    ExceptionPanel resetpanel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                    resetpanel.SetMessage("Advanced Vehicle Options", Translations.Translate("AVO_MOD_MP54"), false);
                });
            };

            panel.eventMouseDown += (c, p) =>
            {
                eventMouseMove += RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseUp += (c, p) =>
            {
                eventMouseMove -= RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseWheel += (c, p) =>
            {
                m_previewRenderer.zoom -= Mathf.Sign(p.wheelDelta) * 0.25f;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };
        }
Example #3
0
        private void SetupControls()
        {
            float offset = 40f;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "IconAssetBuilding";
            m_title.title      = "Mesh Info " + MeshInfo.version;

            // Type DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(15f, offset + 5f);
            label.text             = "Type :";

            m_prefabType       = UIUtils.CreateDropDown(this);
            m_prefabType.width = 110;
            m_prefabType.AddItem("Building");
            m_prefabType.AddItem("Prop");
            m_prefabType.AddItem("Tree");
            m_prefabType.AddItem("Vehicle");
            m_prefabType.selectedIndex    = 0;
            m_prefabType.relativePosition = label.relativePosition + new Vector3(60f, 0f);

            m_prefabType.eventSelectedIndexChanged += (c, t) =>
            {
                m_prefabType.enabled = false;
                m_isSorted           = false;
                PopulateList();
                m_prefabType.enabled = true;
            };

            // Sorting DropDown
            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_prefabType.relativePosition + new Vector3(130f, 0f);
            label.text             = "Sort by :";

            m_sorting       = UIUtils.CreateDropDown(this);
            m_sorting.width = 125;
            m_sorting.AddItem("Name");
            m_sorting.AddItem("Triangles");
            m_sorting.AddItem("LOD Triangles");
            m_sorting.AddItem("Weight");
            m_sorting.AddItem("LOD Weight");
            m_sorting.AddItem("Texture");
            m_sorting.AddItem("LOD Texture");
            m_sorting.selectedIndex    = 0;
            m_sorting.relativePosition = label.relativePosition + new Vector3(60f, 0f);

            m_sorting.eventSelectedIndexChanged += (c, t) =>
            {
                m_sorting.enabled = false;
                m_isSorted        = false;
                PopulateList();
                m_sorting.enabled = true;
            };

            // Sorting direction
            m_sortDirection                  = AddUIComponent <UISprite>();
            m_sortDirection.atlas            = UIUtils.GetAtlas("Ingame");
            m_sortDirection.spriteName       = "IconUpArrow";
            m_sortDirection.relativePosition = m_sorting.relativePosition + new Vector3(130f, 0f);

            m_sortDirection.eventClick += (c, t) =>
            {
                m_sortDirection.flip = (m_sortDirection.flip == UISpriteFlip.None) ? UISpriteFlip.FlipVertical : UISpriteFlip.None;
                m_isSorted           = false;
                PopulateList();
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 150f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.relativePosition = new Vector3(width - m_search.width - 15f, offset + 5f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = "Search :";


            m_search.eventTextChanged += (c, t) => PopulateList();

            // Labels
            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = "Name";
            label.relativePosition = new Vector3(15f, offset + 50f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = "Texture";
            label.relativePosition = new Vector3(width - 135f, offset + 50f);

            UILabel label2 = AddUIComponent <UILabel>();

            label2.textScale        = 0.9f;
            label2.text             = "Weight";
            label2.relativePosition = label.relativePosition - new Vector3(125f, 0f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = "Triangles";
            label.relativePosition = label2.relativePosition - new Vector3(115f, 0f);

            // Item List
            m_itemList                  = UIFastList.Create <UIPrefabItem>(this);
            m_itemList.rowHeight        = 40f;
            m_itemList.backgroundSprite = "UnlockingPanel";
            m_itemList.width            = width - 10;
            m_itemList.height           = height - offset - 75;
            m_itemList.relativePosition = new Vector3(5f, offset + 70f);
        }
        private void SetupControls()
        {
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.gameObject.AddComponent <UICustomControl>();

            panel.backgroundSprite = "UnlockingPanel";
            panel.width            = width - 10;
            panel.height           = height - 75;
            panel.relativePosition = new Vector3(5, 0);

            // Max Speed
            UILabel maxSpeedLabel = panel.AddUIComponent <UILabel>();

            maxSpeedLabel.text             = "Maximum speed:";
            maxSpeedLabel.textScale        = 0.8f;
            maxSpeedLabel.relativePosition = new Vector3(15, 15);

            m_maxSpeed = UIUtils.CreateTextField(panel);
            m_maxSpeed.numericalOnly    = true;
            m_maxSpeed.width            = 75;
            m_maxSpeed.tooltip          = "Change the maximum speed of the vehicle\nPlease note that vehicles do not go beyond speed limits";
            m_maxSpeed.relativePosition = new Vector3(15, 35);

            UILabel kmh = panel.AddUIComponent <UILabel>();

            kmh.text             = "km/h";
            kmh.textScale        = 0.8f;
            kmh.relativePosition = new Vector3(95, 40);

            // Acceleration
            UILabel accelerationLabel = panel.AddUIComponent <UILabel>();

            accelerationLabel.text             = "Acceleration/Brake:";
            accelerationLabel.textScale        = 0.8f;
            accelerationLabel.relativePosition = new Vector3(160, 15);

            m_acceleration = UIUtils.CreateTextField(panel);
            m_acceleration.numericalOnly    = true;
            m_acceleration.allowFloats      = true;
            m_acceleration.width            = 60;
            m_acceleration.tooltip          = "Change the vehicle acceleration factor";
            m_acceleration.relativePosition = new Vector3(160, 35);

            // Braking
            m_braking = UIUtils.CreateTextField(panel);
            m_braking.numericalOnly    = true;
            m_braking.allowFloats      = true;
            m_braking.width            = 60;
            m_braking.tooltip          = "Change the vehicle braking factor";
            m_braking.relativePosition = new Vector3(230, 35);

            // Colors
            m_useColors                  = UIUtils.CreateCheckBox(panel);
            m_useColors.text             = "Color variations:";
            m_useColors.isChecked        = true;
            m_useColors.width            = width - 40;
            m_useColors.tooltip          = "Enable color variations\nA random color is chosen between the four following colors";
            m_useColors.relativePosition = new Vector3(15, 70);

            m_color0                      = UIUtils.CreateColorField(panel);
            m_color0.name                 = "AVO-color0";
            m_color0.popupTopmostRoot     = false;
            m_color0.relativePosition     = new Vector3(13, 95 - 2);
            m_color0_hex                  = UIUtils.CreateTextField(panel);
            m_color0_hex.maxLength        = 6;
            m_color0_hex.relativePosition = new Vector3(55, 95);

            m_color1                      = UIUtils.CreateColorField(panel);
            m_color1.name                 = "AVO-color1";
            m_color1.popupTopmostRoot     = false;
            m_color1.relativePosition     = new Vector3(13, 120 - 2);
            m_color1_hex                  = UIUtils.CreateTextField(panel);
            m_color1_hex.maxLength        = 6;
            m_color1_hex.relativePosition = new Vector3(55, 120);

            m_color2                      = UIUtils.CreateColorField(panel);
            m_color2.name                 = "AVO-color2";
            m_color2.popupTopmostRoot     = false;
            m_color2.relativePosition     = new Vector3(158, 95 - 2);
            m_color2_hex                  = UIUtils.CreateTextField(panel);
            m_color2_hex.maxLength        = 6;
            m_color2_hex.relativePosition = new Vector3(200, 95);

            m_color3                      = UIUtils.CreateColorField(panel);
            m_color3.name                 = "AVO-color3";
            m_color3.popupTopmostRoot     = false;
            m_color3.relativePosition     = new Vector3(158, 120 - 2);
            m_color3_hex                  = UIUtils.CreateTextField(panel);
            m_color3_hex.maxLength        = 6;
            m_color3_hex.relativePosition = new Vector3(200, 120);

            // Enable & BackEngine
            m_enabled                  = UIUtils.CreateCheckBox(panel);
            m_enabled.text             = "Allow this vehicle to spawn";
            m_enabled.isChecked        = true;
            m_enabled.width            = width - 40;
            m_enabled.tooltip          = "Make sure you have at least one vehicle allowed to spawn for that category";
            m_enabled.relativePosition = new Vector3(15, 155);;

            m_addBackEngine                  = UIUtils.CreateCheckBox(panel);
            m_addBackEngine.text             = "Replace last car with engine";
            m_addBackEngine.isChecked        = false;
            m_addBackEngine.width            = width - 40;
            m_addBackEngine.tooltip          = "Make the last car of this train be an engine";
            m_addBackEngine.relativePosition = new Vector3(15, 175);

            // Capacity
            UIPanel capacityPanel = panel.AddUIComponent <UIPanel>();

            capacityPanel.size             = Vector2.zero;
            capacityPanel.relativePosition = new Vector3(15, 200);

            UILabel capacityLabel = capacityPanel.AddUIComponent <UILabel>();

            capacityLabel.text             = "Capacity:";
            capacityLabel.textScale        = 0.8f;
            capacityLabel.relativePosition = Vector3.zero;

            m_capacity = UIUtils.CreateTextField(capacityPanel);
            m_capacity.numericalOnly    = true;
            m_capacity.width            = 110;
            m_capacity.tooltip          = "Change the capacity of the vehicle";
            m_capacity.relativePosition = new Vector3(0, 20);

            // Restore default
            m_restore                  = UIUtils.CreateButton(panel);
            m_restore.text             = "Restore default";
            m_restore.width            = 130;
            m_restore.tooltip          = "Restore all values to default";
            m_restore.relativePosition = new Vector3(160, 215);

            // Remove Vehicles
            m_removeLabel                  = this.AddUIComponent <UILabel>();
            m_removeLabel.text             = "Remove vehicles:";
            m_removeLabel.textScale        = 0.8f;
            m_removeLabel.relativePosition = new Vector3(10, height - 60);

            m_clearVehicles                  = UIUtils.CreateButton(this);
            m_clearVehicles.text             = "Driving";
            m_clearVehicles.width            = 90f;
            m_clearVehicles.tooltip          = "Remove all driving vehicles of that type\nHold the SHIFT key to remove all types";
            m_clearVehicles.relativePosition = new Vector3(10, height - 40);

            m_clearParked                  = UIUtils.CreateButton(this);
            m_clearParked.text             = "Parked";
            m_clearParked.width            = 90f;
            m_clearParked.tooltip          = "Remove all parked vehicles of that type\nHold the SHIFT key to remove all types";
            m_clearParked.relativePosition = new Vector3(105, height - 40);

            panel.BringToFront();

            // Event handlers
            m_maxSpeed.eventTextSubmitted     += OnMaxSpeedSubmitted;
            m_acceleration.eventTextSubmitted += OnAccelerationSubmitted;
            m_braking.eventTextSubmitted      += OnBrakingSubmitted;

            m_useColors.eventCheckChanged += OnCheckChanged;

            MouseEventHandler mousehandler = (c, p) => { if (m_initialized)
                                                         {
                                                             (parent as UIMainPanel).ChangePreviewColor((c as UIColorField).selectedColor);
                                                         }
            };

            m_color0.eventMouseEnter += mousehandler;
            m_color1.eventMouseEnter += mousehandler;
            m_color2.eventMouseEnter += mousehandler;
            m_color3.eventMouseEnter += mousehandler;

            m_color0_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color0.selectedColor);
                                                        }
            };
            m_color1_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color1.selectedColor);
                                                        }
            };
            m_color2_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color2.selectedColor);
                                                        }
            };
            m_color3_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color3.selectedColor);
                                                        }
            };

            m_color0.eventSelectedColorChanged += OnColorChanged;
            m_color1.eventSelectedColorChanged += OnColorChanged;
            m_color2.eventSelectedColorChanged += OnColorChanged;
            m_color3.eventSelectedColorChanged += OnColorChanged;

            m_color0_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color1_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color2_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color3_hex.eventTextSubmitted += OnColorHexSubmitted;

            m_enabled.eventCheckChanged       += OnCheckChanged;
            m_addBackEngine.eventCheckChanged += OnCheckChanged;

            m_capacity.eventTextSubmitted += OnCapacitySubmitted;

            m_restore.eventClick += (c, p) =>
            {
                m_initialized = false;
                bool isEnabled = m_options.enabled;
                DefaultOptions.Restore(m_options.prefab);
                VehicleOptions.UpdateTransfertVehicles();

                VehicleOptions.prefabUpdateEngine = m_options.prefab;
                VehicleOptions.prefabUpdateUnits  = m_options.prefab;
                new EnumerableActionThread(VehicleOptions.UpdateBackEngines);
                new EnumerableActionThread(VehicleOptions.UpdateCapacityUnits);

                Show(m_options);

                if (m_options.enabled != isEnabled)
                {
                    eventEnableCheckChanged(this, m_options.enabled);
                }
            };

            m_clearVehicles.eventClick += OnClearVehicleClicked;
            m_clearParked.eventClick   += OnClearVehicleClicked;
        }
Example #5
0
        public override void Start()
        {
            name             = "MoveIt_SaveWindow";
            atlas            = UIUtils.GetAtlas("Ingame");
            backgroundSprite = "SubcategoriesPanel";
            size             = new Vector2(465, 272); // 180
            canFocus         = true;

            UIDragHandle dragHandle = AddUIComponent <UIDragHandle>();

            dragHandle.target           = parent;
            dragHandle.relativePosition = Vector3.zero;

            close                  = AddUIComponent <UIButton>();
            close.size             = new Vector2(30f, 30f);
            close.text             = "X";
            close.textScale        = 0.9f;
            close.textColor        = new Color32(118, 123, 123, 255);
            close.focusedTextColor = new Color32(118, 123, 123, 255);
            close.hoveredTextColor = new Color32(140, 142, 142, 255);
            close.pressedTextColor = new Color32(99, 102, 102, 102);
            close.textPadding      = new RectOffset(8, 8, 8, 8);
            close.canFocus         = false;
            close.playAudioEvents  = true;
            close.relativePosition = new Vector3(width - close.width, 0);

            close.eventClicked += (c, p) =>
            {
                Close();
            };

            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.9f;
            label.text             = "Export";
            label.relativePosition = new Vector2(8, 8);
            label.SendToBack();

            // Save Panel
            UIPanel savePanel = AddUIComponent <UIPanel>();

            savePanel.atlas            = atlas;
            savePanel.backgroundSprite = "GenericPanel";
            savePanel.color            = new Color32(206, 206, 206, 255);
            savePanel.size             = new Vector2(width - 16, 46);
            savePanel.relativePosition = new Vector2(8, 28);

            // Input
            fileNameInput                     = UIUtils.CreateTextField(savePanel);
            fileNameInput.padding.top         = 7;
            fileNameInput.horizontalAlignment = UIHorizontalAlignment.Left;
            fileNameInput.relativePosition    = new Vector3(8, 8);

            fileNameInput.eventKeyDown += (c, p) =>
            {
                if (p.keycode == KeyCode.Return)
                {
                    saveButton.SimulateClick();
                }
            };

            // Save
            saveButton                  = UIUtils.CreateButton(savePanel);
            saveButton.name             = "MoveIt_SaveButton";
            saveButton.text             = "Export";
            saveButton.size             = new Vector2(100f, 30f);
            saveButton.relativePosition = new Vector3(savePanel.width - saveButton.width - 8, 8);

            fileNameInput.size = new Vector2(saveButton.relativePosition.x - 16f, 30f);

            // FastList
            fastList = AddUIComponent <UIFastList>();
            fastList.backgroundSprite = "UnlockingPanel";
            fastList.width            = width - 16;
            fastList.height           = 46 * 7;
            fastList.canSelect        = true;
            fastList.relativePosition = new Vector3(8, savePanel.relativePosition.y + savePanel.height + 8);

            fastList.rowHeight = 46f;

            saveButton.eventClicked += (c, p) =>
            {
                string filename = fileNameInput.text.Trim();
                filename = String.Concat(filename.Split(Path.GetInvalidFileNameChars()));

                if (!filename.IsNullOrWhiteSpace())
                {
                    Export(filename);
                }
            };

            height           = fastList.relativePosition.y + fastList.height + 8;
            dragHandle.size  = size;
            absolutePosition = new Vector3(saveWindowX.value, saveWindowY.value);
            MakePixelPerfect();

            RefreshFileList();

            UIComponent modalEffect = GetUIView().panelsLibraryModalEffect;

            if (modalEffect != null && !modalEffect.isVisible)
            {
                modalEffect.Show(false);
                ValueAnimator.Animate("ModalEffect", delegate(float val)
                {
                    modalEffect.opacity = val;
                }, new AnimatedFloat(0f, 1f, 0.7f, EasingType.CubicEaseOut));
            }

            BringToFront();
            fileNameInput.Focus();
        }
Example #6
0
        private void Initialise()
        {
            Panel                  = UIView.GetAView().AddUIComponent(typeof(UIPanel)) as UIPanel;
            Panel.name             = "MoveIt_MoveToPanel";
            Panel.atlas            = ResourceLoader.GetAtlas("Ingame");
            Panel.backgroundSprite = "MenuPanel2";
            Panel.size             = new Vector2(190, 185);
            Panel.absolutePosition = new Vector3(Panel.GetUIView().GetScreenResolution().x - 220, Panel.GetUIView().GetScreenResolution().y - 600);
            Panel.clipChildren     = true;
            Panel.isVisible        = false;
            Panel.anchor           = UIAnchorStyle.None;

            TitleContainer          = Panel.AddUIComponent <UISlicedSprite>();
            TitleContainer.position = new Vector3(0, 0);
            TitleContainer.size     = new Vector2(Panel.width, 40);

            TitleIcon = TitleContainer.AddUIComponent(typeof(UISprite)) as UISprite;
            TitleIcon.relativePosition = new Vector3(4, 4);
            TitleIcon.size             = new Vector2(32, 32);
            TitleIcon.atlas            = UIMoveItButton.GetAtlas(new string[] { "MoveIt" });
            TitleIcon.spriteName       = "MoveIt";

            TitleCaption        = TitleContainer.AddUIComponent <UILabel>();
            TitleCaption.anchor = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical;
            TitleCaption.size   = new Vector2(Panel.width, 40);
            TitleCaption.text   = Str.setpos_Title;

            TitleDrag = TitleContainer.AddUIComponent(typeof(UIDragHandle)) as UIDragHandle;
            TitleDrag.relativePosition = new Vector3(0, 0);
            TitleDrag.size             = new Vector2(Panel.width, 40);
            TitleDrag.target           = Panel;

            TitleClose                  = TitleContainer.AddUIComponent <UIButton>();
            TitleClose.atlas            = ResourceLoader.GetAtlas("Ingame");
            TitleClose.normalBgSprite   = "buttonclose";
            TitleClose.pressedBgSprite  = "buttonclosepressed";
            TitleClose.hoveredBgSprite  = "buttonclosehover";
            TitleClose.size             = new Vector2(32, 32);
            TitleClose.relativePosition = new Vector3(Panel.width - 36, 4);
            TitleClose.eventClicked    += (UIComponent c, UIMouseEventParameter p) =>
            {
                MoveItTool.instance.DeactivateTool();
            };

            XLabel = Panel.AddUIComponent <UILabel>();
            XLabel.relativePosition = new Vector3(8, 52);
            XLabel.text             = "X:";
            XInput = UIUtils.CreateTextField(Panel);
            XInput.relativePosition    = new Vector3(30, 48);
            XInput.size                = new Vector2(148, 24);
            XInput.horizontalAlignment = UIHorizontalAlignment.Left;
            XInput.tabIndex            = 0;
            XInput.eventLostFocus     += (UIComponent c, UIFocusEventParameter f) => { Validate(XInput); };

            ZLabel = Panel.AddUIComponent <UILabel>();
            ZLabel.relativePosition = new Vector3(8, 86);
            ZLabel.text             = "Y:";
            ZInput = UIUtils.CreateTextField(Panel);
            ZInput.relativePosition    = new Vector3(30, 82);
            ZInput.size                = new Vector2(148, 24);
            ZInput.horizontalAlignment = UIHorizontalAlignment.Left;
            ZInput.tabIndex            = 1;
            ZInput.eventLostFocus     += (UIComponent c, UIFocusEventParameter f) => { Validate(ZInput); };

            YLabel = Panel.AddUIComponent <UILabel>();
            YLabel.relativePosition = new Vector3(8, 120);
            YLabel.text             = "H:";
            YLabel.tooltip          = Str.setpos_H_Tooltip;
            YInput = UIUtils.CreateTextField(Panel);
            YInput.relativePosition    = new Vector3(30, 116);
            YInput.size                = new Vector2(148, 24);
            YInput.horizontalAlignment = UIHorizontalAlignment.Left;
            YInput.tabIndex            = 2;
            YInput.eventLostFocus     += (UIComponent c, UIFocusEventParameter f) => { Validate(YInput); };

            ALabel = Panel.AddUIComponent <UILabel>();
            ALabel.relativePosition = new Vector3(8, 154);
            ALabel.text             = "A:";
            ALabel.tooltip          = Str.setpos_A_Tooltip;
            AInput = UIUtils.CreateTextField(Panel);
            AInput.relativePosition    = new Vector3(30, 150);
            AInput.size                = new Vector2(100, 24);
            AInput.horizontalAlignment = UIHorizontalAlignment.Left;
            AInput.tabIndex            = 3;
            AInput.eventLostFocus     += (UIComponent c, UIFocusEventParameter f) => { Validate(AInput); };

            Submit = UIUtils.CreateButton(Panel);
            Submit.relativePosition = new Vector3(138, 146);
            Submit.size             = new Vector2(40, 30);
            Submit.text             = Str.setpos_Go;
            Submit.tabIndex         = 4;
            Submit.eventClicked    += (UIComponent c, UIMouseEventParameter p) =>
            {
                Go();
            };
        }
Example #7
0
        public override void Awake()
        {
            height = 46;

            focusButton                  = UIUtils.CreateButton(this);
            focusButton.name             = "CCX_FocusButton";
            focusButton.text             = "Point 0";
            focusButton.size             = new Vector2(70f, 30f);
            focusButton.relativePosition = new Vector3(8, 8);
            focusButton.tooltip          = "Click here to place the camera at this point";

            easingDropDown           = UIUtils.CreateDropDown(this);
            easingDropDown.name      = "CCX_EasingDropDown";
            easingDropDown.textScale = 0.9f;
            easingDropDown.AddItem("None");
            easingDropDown.AddItem("Auto");
            easingDropDown.AddItem("In");
            easingDropDown.AddItem("Out");
            easingDropDown.AddItem("InOut");
            easingDropDown.selectedValue        = "Auto";
            easingDropDown.size                 = new Vector2(80f, 30f);
            easingDropDown.textFieldPadding.top = 7;
            easingDropDown.relativePosition     = new Vector3(focusButton.relativePosition.x + focusButton.width + 8, 8);
            easingDropDown.tooltip              = "Camera movement easing";

            durationInput                  = UIUtils.CreateTextField(this);
            durationInput.name             = "CCX_DurationInput";
            durationInput.size             = new Vector2(40f, 26f);
            durationInput.numericalOnly    = true;
            durationInput.allowFloats      = true;
            durationInput.padding.top      = 6;
            durationInput.relativePosition = new Vector3(easingDropDown.relativePosition.x + easingDropDown.width + 8, 10);
            durationInput.tooltip          = "Duration in seconds";

            delayInput                  = UIUtils.CreateTextField(this);
            delayInput.name             = "CCX_DelayInput";
            delayInput.size             = new Vector2(45f, 26f);
            delayInput.numericalOnly    = true;
            delayInput.allowFloats      = true;
            delayInput.padding.top      = 6;
            delayInput.relativePosition = new Vector3(durationInput.relativePosition.x + durationInput.width + 8, 10);
            delayInput.tooltip          = "Delay in seconds";

            fovInput                  = UIUtils.CreateTextField(this);
            fovInput.name             = "CCX_DelayInput";
            fovInput.size             = new Vector2(45f, 26);
            fovInput.numericalOnly    = true;
            fovInput.allowFloats      = true;
            fovInput.padding.top      = 6;
            fovInput.relativePosition = new Vector3(delayInput.relativePosition.x + delayInput.width + 8, 10);
            fovInput.tooltip          = "Field of view in degrees";

            resetButton                  = UIUtils.CreateButton(this);
            resetButton.name             = "CCX_ResetButton";
            resetButton.text             = "O";
            resetButton.size             = new Vector2(45f, 30f);
            resetButton.relativePosition = new Vector3(fovInput.relativePosition.x + fovInput.width + 8, 8);
            resetButton.tooltip          = "Recapture the camera position";

            removeButton                  = UIUtils.CreateButton(this);
            removeButton.name             = "CCX_RemoveButton";
            removeButton.text             = "X";
            removeButton.size             = new Vector2(40f, 30f);
            removeButton.relativePosition = new Vector3(resetButton.relativePosition.x + resetButton.width + 8, 8);
            removeButton.tooltip          = "Remove this point";

            focusButton.eventClicked += (c, p) =>
            {
                CameraPath.SetCitiesCameraTransform(knot);
            };

            easingDropDown.eventSelectedIndexChanged += (c, p) =>
            {
                knot.mode = (EasingMode)p;
            };

            durationInput.eventTextSubmitted += (c, p) =>
            {
                float value;
                if (float.TryParse(p, out value) && value > 0)
                {
                    knot.duration = value;
                }

                durationInput.text = knot.duration.ToString();
            };

            durationInput.eventMouseWheel += (c, p) =>
            {
                float value;
                if (float.TryParse(durationInput.text, out value))
                {
                    knot.duration      = Mathf.Max(0, value + p.wheelDelta);
                    durationInput.text = knot.duration.ToString();
                }
                p.Use();
            };

            delayInput.eventTextSubmitted += (c, p) =>
            {
                float value;
                if (float.TryParse(p, out value))
                {
                    knot.delay = Mathf.Max(0, value);
                }

                delayInput.text = knot.delay.ToString();
            };

            delayInput.eventMouseWheel += (c, p) =>
            {
                float value;
                if (float.TryParse(delayInput.text, out value))
                {
                    knot.delay      = Mathf.Max(0, value + p.wheelDelta);
                    delayInput.text = knot.delay.ToString();
                }
                p.Use();
            };

            fovInput.eventTextSubmitted += (c, p) =>
            {
                float value;
                if (float.TryParse(p, out value))
                {
                    knot.fov = Mathf.Clamp(value, 20f, 179f) / 2f;
                }

                fovInput.text = (2f * knot.fov).ToString();
            };

            fovInput.eventMouseWheel += (c, p) =>
            {
                float value;
                if (float.TryParse(fovInput.text, out value))
                {
                    knot.fov      = Mathf.Clamp(value + p.wheelDelta, 20f, 179f) / 2f;
                    fovInput.text = (2f * knot.fov).ToString();
                }
                p.Use();
            };

            resetButton.eventClicked += (c, p) =>
            {
                knot.CaptureCamera();
                fovInput.text = (2f * knot.fov).ToString();
            };

            removeButton.eventClicked += (c, p) =>
            {
                CameraDirector.cameraPath.knots.RemoveAt(index);
                CameraDirector.mainWindow.RefreshKnotList();
            };
        }
Example #8
0
        public override void Start()
        {
            base.Start();

            isVisible     = true;
            canFocus      = true;
            isInteractive = true;
            width         = 740f;
            height        = 40f;

            m_name                  = AddUIComponent <UILabel>();
            m_name.textScale        = 0.9f;
            m_name.width            = 300f;
            m_name.height           = height;
            m_name.textAlignment    = UIHorizontalAlignment.Left;
            m_name.pivot            = UIPivotPoint.MiddleLeft;
            m_name.relativePosition = new Vector3(10f, 0f);

            m_lodTextureSize               = AddUIComponent <UILabel>();
            m_lodTextureSize.textScale     = 0.9f;
            m_lodTextureSize.width         = 70f;
            m_lodTextureSize.height        = height;
            m_lodTextureSize.textAlignment = UIHorizontalAlignment.Center;
            m_lodTextureSize.pivot         = UIPivotPoint.MiddleCenter;
            m_lodTextureSize.padding       = new RectOffset(0, 10, 0, 0);
            m_lodTextureSize.AlignTo(this, UIAlignAnchor.TopRight);

            m_textureSize                  = AddUIComponent <UILabel>();
            m_textureSize.textScale        = 0.9f;
            m_textureSize.width            = 90f;
            m_textureSize.height           = height;
            m_textureSize.textAlignment    = UIHorizontalAlignment.Center;
            m_textureSize.pivot            = UIPivotPoint.MiddleCenter;
            m_textureSize.padding          = new RectOffset(0, 10, 0, 0);
            m_textureSize.relativePosition = m_lodTextureSize.relativePosition - new Vector3(90f, 0f);

            m_lodWeight                  = AddUIComponent <UILabel>();
            m_lodWeight.textScale        = 0.9f;
            m_lodWeight.width            = 50f;
            m_lodWeight.height           = height;
            m_lodWeight.textAlignment    = UIHorizontalAlignment.Center;
            m_lodWeight.pivot            = UIPivotPoint.MiddleCenter;
            m_lodWeight.relativePosition = m_textureSize.relativePosition - new Vector3(50f, 0f);

            m_weight                  = AddUIComponent <UILabel>();
            m_weight.textScale        = 0.9f;
            m_weight.width            = 50f;
            m_weight.height           = height;
            m_weight.textAlignment    = UIHorizontalAlignment.Center;
            m_weight.pivot            = UIPivotPoint.MiddleCenter;
            m_weight.relativePosition = m_lodWeight.relativePosition - new Vector3(50f, 0f);

            m_lodTriangles                  = AddUIComponent <UILabel>();
            m_lodTriangles.textScale        = 0.9f;
            m_lodTriangles.width            = 50f;
            m_lodTriangles.height           = height;
            m_lodTriangles.textAlignment    = UIHorizontalAlignment.Center;
            m_lodTriangles.pivot            = UIPivotPoint.MiddleCenter;
            m_lodTriangles.relativePosition = m_weight.relativePosition - new Vector3(50f, 0f);

            m_triangles                  = AddUIComponent <UILabel>();
            m_triangles.textScale        = 0.9f;
            m_triangles.width            = 80f;
            m_triangles.height           = height;
            m_triangles.textAlignment    = UIHorizontalAlignment.Center;
            m_triangles.pivot            = UIPivotPoint.MiddleCenter;
            m_triangles.relativePosition = m_lodTriangles.relativePosition - new Vector3(80f, 0f);

            m_steamID = UIUtils.CreateTextField(this);
            m_steamID.normalBgSprite           = null;
            m_steamID.padding                  = new RectOffset(5, 5, 14, 14);
            m_steamID.textScale                = 0.8f;
            m_steamID.height                   = 40;
            m_steamID.textColor                = new Color32(128, 128, 128, 255);
            m_steamID.selectionBackgroundColor = new Color32(0, 0, 0, 128);
            m_steamID.numericalOnly            = true;
            m_steamID.relativePosition         = m_triangles.relativePosition - new Vector3(100f, 0f);

            m_steamID.eventTextChanged += (c, t) =>
            {
                if (m_meshData.name.Contains("."))
                {
                    m_steamID.text = m_meshData.name.Substring(0, m_meshData.name.IndexOf("."));
                }
            };

            m_name.eventDoubleClick += (c, t) =>
            {
                if (PlatformService.IsOverlayEnabled() && !String.IsNullOrEmpty(m_steamID.text))
                {
                    PublishedFileId publishedFileId = new PublishedFileId((ulong)Int32.Parse(m_steamID.text));

                    if (publishedFileId != PublishedFileId.invalid)
                    {
                        PlatformService.ActivateGameOverlayToWorkshopItem(publishedFileId);
                    }
                }
            };
        }
Example #9
0
        public override void Start()
        {
            name             = "CCX_SaveLoadWindow";
            atlas            = UIUtils.GetAtlas("Ingame");
            backgroundSprite = "SubcategoriesPanel";
            size             = new Vector2(465, 180);

            UIDragHandle dragHandle = AddUIComponent <UIDragHandle>();

            dragHandle.target           = parent;
            dragHandle.relativePosition = Vector3.zero;

            close                  = AddUIComponent <UIButton>();
            close.size             = new Vector2(30f, 30f);
            close.text             = "X";
            close.textScale        = 0.9f;
            close.textColor        = new Color32(118, 123, 123, 255);
            close.focusedTextColor = new Color32(118, 123, 123, 255);
            close.hoveredTextColor = new Color32(140, 142, 142, 255);
            close.pressedTextColor = new Color32(99, 102, 102, 102);
            close.textPadding      = new RectOffset(8, 8, 8, 8);
            close.canFocus         = false;
            close.playAudioEvents  = true;
            close.relativePosition = new Vector3(width - close.width, 0);

            close.eventClicked += (c, p) =>
            {
                isVisible = false;
                Destroy(gameObject);
            };

            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.9f;
            label.text             = "Save/Load Path";
            label.relativePosition = new Vector2(8, 8);
            label.SendToBack();

            // Save Panel
            UIPanel savePanel = AddUIComponent <UIPanel>();

            savePanel.atlas            = atlas;
            savePanel.backgroundSprite = "GenericPanel";
            savePanel.color            = new Color32(206, 206, 206, 255);
            savePanel.size             = new Vector2(width - 16, 46);
            savePanel.relativePosition = new Vector2(8, 28);

            // Input
            fileNameInput                     = UIUtils.CreateTextField(savePanel);
            fileNameInput.padding.top         = 7;
            fileNameInput.horizontalAlignment = UIHorizontalAlignment.Left;
            fileNameInput.relativePosition    = new Vector3(8, 8);

            // Save
            saveButton                  = UIUtils.CreateButton(savePanel);
            saveButton.name             = "CCX_SaveButton";
            saveButton.text             = "Save";
            saveButton.size             = new Vector2(100f, 30f);
            saveButton.relativePosition = new Vector3(savePanel.width - saveButton.width - 8, 8);

            fileNameInput.size = new Vector2(saveButton.relativePosition.x - 16f, 30f);

            // FastList
            fastList = UIFastList.Create <UISaveLoadFileRow>(this);
            fastList.backgroundSprite = "UnlockingPanel";
            fastList.width            = width - 16;
            fastList.height           = 46 * 5;
            fastList.canSelect        = true;
            fastList.relativePosition = new Vector3(8, savePanel.relativePosition.y + savePanel.height + 8);

            fastList.rowHeight = 46f;

            saveButton.eventClicked += (c, p) =>
            {
                string filename = fileNameInput.text.Trim();
                filename = String.Concat(filename.Split(Path.GetInvalidFileNameChars()));

                if (!fileNameInput.text.IsNullOrWhiteSpace())
                {
                    CameraDirector.cameraPath.Serialize(filename);
                    fileNameInput.text = "";
                    RefreshFileList();
                }
            };

            height           = fastList.relativePosition.y + fastList.height + 8;
            dragHandle.size  = size;
            absolutePosition = new Vector3(savedWindowX.value, savedWindowY.value);
            MakePixelPerfect();

            RefreshFileList();

            fileNameInput.Focus();
        }
Example #10
0
        /*public override void OnDestroy()
         * {
         *  base.OnDestroy();
         *
         *  DebugUtils.Log("Destroying UIMainPanel");
         *
         *  if (m_button != null) GameObject.Destroy(m_button.gameObject);
         *  GameObject.Destroy(m_optionPanel.gameObject);
         * }*/

        private void SetupControls()
        {
            float offset = 40f;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "InfoIconTrafficCongestion";
            m_title.title      = "Advanced Vehicle Options " + ModInfo.version;

            // Category DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(10f, offset);
            label.text             = "Category :";

            m_category       = UIUtils.CreateDropDown(this);
            m_category.width = 150;

            for (int i = 0; i < categoryList.Length; i++)
            {
                m_category.AddItem(categoryList[i]);
            }

            m_category.selectedIndex    = 0;
            m_category.tooltip          = "Select a category to display\nTip: Use the mouse wheel to switch between categories faster";
            m_category.relativePosition = label.relativePosition + new Vector3(75f, 0f);

            m_category.eventSelectedIndexChanged += (c, t) =>
            {
                m_category.enabled = false;
                PopulateList();
                m_category.enabled = true;
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 145f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.tooltip          = "Type the name of a vehicle type";
            m_search.relativePosition = new Vector3(WIDTHLEFT - m_search.width, offset);

            m_search.eventTextChanged += (c, t) => PopulateList();

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = "Search :";

            // FastList
            m_fastList = UIFastList.Create <UIVehicleItem>(this);
            m_fastList.backgroundSprite = "UnlockingPanel";
            m_fastList.width            = WIDTHLEFT - 5;
            m_fastList.height           = height - offset - 110;
            m_fastList.canSelect        = true;
            m_fastList.relativePosition = new Vector3(5, offset + 35);

            // Configuration file buttons
            UILabel configLabel = this.AddUIComponent <UILabel>();

            configLabel.text             = "Configuration file:";
            configLabel.textScale        = 0.8f;
            configLabel.relativePosition = new Vector3(10, height - 60);

            m_import                  = UIUtils.CreateButton(this);
            m_import.text             = "Import";
            m_import.tooltip          = "Import the configuration";
            m_import.relativePosition = new Vector3(10, height - 40);

            m_export                  = UIUtils.CreateButton(this);
            m_export.text             = "Export";
            m_export.tooltip          = "Export the configuration";
            m_export.relativePosition = new Vector3(105, height - 40);

            // Preview
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.backgroundSprite = "GenericPanel";
            panel.width            = WIDTHRIGHT - 10;
            panel.height           = HEIGHT - 420;
            panel.relativePosition = new Vector3(WIDTHLEFT + 5, offset);

            m_preview                  = panel.AddUIComponent <UITextureSprite>();
            m_preview.size             = panel.size;
            m_preview.relativePosition = Vector3.zero;

            m_previewRenderer      = gameObject.AddComponent <PreviewRenderer>();
            m_previewRenderer.size = m_preview.size * 2; // Twice the size for anti-aliasing

            m_preview.texture = m_previewRenderer.texture;

            // Follow
            if (m_cameraController != null)
            {
                m_followVehicle                  = AddUIComponent <UISprite>();
                m_followVehicle.spriteName       = "LocationMarkerFocused";
                m_followVehicle.width            = m_followVehicle.spriteInfo.width;
                m_followVehicle.height           = m_followVehicle.spriteInfo.height;
                m_followVehicle.tooltip          = "Click here to cycle through the existing vehicles of that type";
                m_followVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_followVehicle.width - 5, panel.relativePosition.y + 5);

                m_followVehicle.eventClick += (c, p) => FollowNextVehicle();
            }

            // Option panel
            m_optionPanel = AddUIComponent <UIOptionPanel>();
            m_optionPanel.relativePosition = new Vector3(WIDTHLEFT, height - 370);

            // Event handlers
            m_fastList.eventSelectedIndexChanged  += OnSelectedItemChanged;
            m_optionPanel.eventEnableCheckChanged += OnEnableStateChanged;
            m_import.eventClick += (c, t) =>
            {
                DefaultOptions.RestoreAll();
                AdvancedVehicleOptions.ImportConfig();
                optionList = AdvancedVehicleOptions.config.options;
            };
            m_export.eventClick += (c, t) => AdvancedVehicleOptions.ExportConfig();

            panel.eventMouseDown += (c, p) =>
            {
                eventMouseMove += RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseUp += (c, p) =>
            {
                eventMouseMove -= RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseWheel += (c, p) =>
            {
                m_previewRenderer.zoom -= Mathf.Sign(p.wheelDelta) * 0.25f;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };
        }
        private void SetupControls()
        {
            float offset = 40f;

            //Beta Testing Timestamp
            //DateTime now = DateTime.Now;
            //m_title.title = "Advanced Vehicle Options " + ModInfo.version + " " + now;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "InfoIconTrafficCongestion";
            m_title.title      = "Advanced Vehicle Options " + ModInfo.version;

            // Category DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(10f, offset);
            label.text             = "Category :";

            m_category       = UIUtils.CreateDropDown(this);
            m_category.width = 175;

            for (int i = 0; i < categoryList.Length; i++)
            {
                m_category.AddItem(categoryList[i]);
            }

            m_category.selectedIndex    = 0;
            m_category.tooltip          = "Select a category to display\nTip: Use the mouse wheel to switch between categories faster";
            m_category.relativePosition = label.relativePosition + new Vector3(75f, 0f);

            m_category.eventSelectedIndexChanged += (c, t) =>
            {
                m_category.enabled = false;
                PopulateList();
                m_category.enabled = true;
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 145f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.tooltip          = "Type the name of a vehicle type";
            m_search.relativePosition = new Vector3(WIDTHLEFT - m_search.width, offset);

            m_search.eventTextChanged += (c, t) => PopulateList();

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = "Search :";

            // FastList
            m_fastList = UIFastList.Create <UIVehicleItem>(this);
            m_fastList.backgroundSprite = "UnlockingPanel";
            m_fastList.width            = WIDTHLEFT - 5;
            m_fastList.height           = height - offset - 110;
            m_fastList.canSelect        = true;
            m_fastList.relativePosition = new Vector3(5, offset + 35);

            // Configuration file buttons
            UILabel configLabel = this.AddUIComponent <UILabel>();

            configLabel.text             = "Actions for Vehicle Configuration:";
            configLabel.textScale        = 0.8f;
            configLabel.relativePosition = new Vector3(16, height - 65);

            m_import                  = UIUtils.CreateButton(this);
            m_import.text             = "Import";
            m_import.width            = 80;
            m_import.tooltip          = "Import the configuration";
            m_import.relativePosition = new Vector3(10, height - 45);

            m_export                  = UIUtils.CreateButton(this);
            m_export.text             = "Export";
            m_export.width            = 80;
            m_export.tooltip          = "Export the configuration";
            m_export.relativePosition = new Vector3(95, height - 45);

            m_resetall                  = UIUtils.CreateButton(this);
            m_resetall.text             = "Reset all";
            m_resetall.width            = 80;
            m_resetall.tooltip          = "Reset full configuration";
            m_resetall.relativePosition = new Vector3(180, height - 45);

            // Preview
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.backgroundSprite = "GenericPanel";
            panel.width            = WIDTHRIGHT - 10;
            panel.height           = HEIGHT - 420;
            panel.relativePosition = new Vector3(WIDTHLEFT + 5, offset);

            m_preview                  = panel.AddUIComponent <UITextureSprite>();
            m_preview.size             = panel.size;
            m_preview.relativePosition = Vector3.zero;

            m_previewRenderer      = gameObject.AddComponent <PreviewRenderer>();
            m_previewRenderer.size = m_preview.size * 2; // Twice the size for anti-aliasing

            m_preview.texture = m_previewRenderer.texture;

            // Follow a vehicle
            if (m_cameraController != null)
            {
                m_followVehicle                  = AddUIComponent <UISprite>();
                m_followVehicle.spriteName       = "LocationMarkerFocused";
                m_followVehicle.width            = m_followVehicle.spriteInfo.width;
                m_followVehicle.height           = m_followVehicle.spriteInfo.height;
                m_followVehicle.tooltip          = "Click here to cycle through the existing vehicles of that type.\nHold Shift Key down for zooming directly to vehicle.";
                m_followVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_followVehicle.width - 5, panel.relativePosition.y + 5);

                m_followVehicle.eventClick += (c, p) => FollowNextVehicle();
            }

            //Remove the followed vehicle
            {
                m_removeVehicle = AddUIComponent <UISprite>();
                m_removeVehicle.Hide();
                m_removeVehicle.spriteName       = "IconPolicyOldTown";
                m_removeVehicle.width            = m_removeVehicle.spriteInfo.width - 12;
                m_removeVehicle.height           = m_removeVehicle.spriteInfo.height - 12;
                m_removeVehicle.tooltip          = "Click here to remove the selected vehicle.";
                m_removeVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_removeVehicle.width - 33, panel.relativePosition.y + 7);

                m_removeVehicle.eventClick += (c, p) => RemoveThisVehicle();
            }

            // Option panel
            m_optionPanel = AddUIComponent <UIOptionPanel>();
            m_optionPanel.relativePosition = new Vector3(WIDTHLEFT, height - 370);

            // Event handlers
            m_fastList.eventSelectedIndexChanged  += OnSelectedItemChanged;
            m_optionPanel.eventEnableCheckChanged += OnEnableStateChanged;
            m_import.eventClick += (c, t) =>
            {
                DefaultOptions.RestoreAll();
                AdvancedVehicleOptionsUID.ImportConfig();
                optionList = AdvancedVehicleOptionsUID.config.options;
            };
            m_export.eventClick += (c, t) => AdvancedVehicleOptionsUID.ExportConfig();

            m_resetall.eventClick += (c, t) =>
            {
                ConfirmPanel.ShowModal("Confirm Reset Configuration", "Customized settings for all vehicles will be reset.\n\n" +
                                       "Proceed with Configuration reset ?", (comp, ret) =>
                {
                    if (ret != 1)
                    {
                        return;
                    }

                    DefaultOptions.RestoreAll();
                    AdvancedVehicleOptionsUID.ResetConfig();
                    optionList = AdvancedVehicleOptionsUID.config.options;

                    ExceptionPanel resetpanel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                    resetpanel.SetMessage("Advanced Vehicle Options", "All vehicle configuration and customized settings\n" +
                                          "have been reset to the Game Defaults.", false);
                });
            };

            panel.eventMouseDown += (c, p) =>
            {
                eventMouseMove += RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseUp += (c, p) =>
            {
                eventMouseMove -= RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseWheel += (c, p) =>
            {
                m_previewRenderer.zoom -= Mathf.Sign(p.wheelDelta) * 0.25f;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };
        }
        private void SetupControls()
        {
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.gameObject.AddComponent <UICustomControl>();

            panel.backgroundSprite = "UnlockingPanel";
            panel.width            = width - 10;
            panel.height           = height - 75;
            panel.relativePosition = new Vector3(5, 0);

            // Max Speed
            UILabel maxSpeedLabel = panel.AddUIComponent <UILabel>();

            maxSpeedLabel.text             = "Maximum speed:";
            maxSpeedLabel.textScale        = 0.8f;
            maxSpeedLabel.relativePosition = new Vector3(15, 14);

            m_maxSpeed = UIUtils.CreateTextField(panel);
            m_maxSpeed.numericalOnly    = true;
            m_maxSpeed.width            = 75;
            m_maxSpeed.tooltip          = "Change the maximum speed of the vehicle\nPlease note that vehicles do not go beyond speed limits";
            m_maxSpeed.relativePosition = new Vector3(15, 33);

            kmhLabel                  = panel.AddUIComponent <UILabel>();
            kmhLabel.text             = "km/h";
            kmhLabel.textScale        = 0.8f;
            kmhLabel.relativePosition = new Vector3(95, 38);

            // Acceleration
            UILabel accelerationLabel = panel.AddUIComponent <UILabel>();

            accelerationLabel.text             = "Acceleration/Brake/Turning:";
            accelerationLabel.textScale        = 0.8f;
            accelerationLabel.relativePosition = new Vector3(160, 13);

            m_acceleration = UIUtils.CreateTextField(panel);
            m_acceleration.numericalOnly    = true;
            m_acceleration.allowFloats      = true;
            m_acceleration.width            = 60;
            m_acceleration.tooltip          = "Change the vehicle acceleration factor";
            m_acceleration.relativePosition = new Vector3(160, 33);

            // Braking
            m_braking = UIUtils.CreateTextField(panel);
            m_braking.numericalOnly    = true;
            m_braking.allowFloats      = true;
            m_braking.width            = 60;
            m_braking.tooltip          = "Change the vehicle braking factor";
            m_braking.relativePosition = new Vector3(230, 33);

            // Turning
            m_turning = UIUtils.CreateTextField(panel);
            m_turning.numericalOnly    = true;
            m_turning.allowFloats      = true;
            m_turning.width            = 60;
            m_turning.tooltip          = "Change the vehicle turning factor;\nDefines how well the car corners";
            m_turning.relativePosition = new Vector3(300, 33);

            // Springs
            UILabel springsLabel = panel.AddUIComponent <UILabel>();

            springsLabel.text             = "Springs/Dampers:";
            springsLabel.textScale        = 0.8f;
            springsLabel.relativePosition = new Vector3(15, 66);

            m_springs = UIUtils.CreateTextField(panel);
            m_springs.numericalOnly    = true;
            m_springs.allowFloats      = true;
            m_springs.width            = 60;
            m_springs.tooltip          = "Change the vehicle spring factor;\nDefines how much the suspension moves";
            m_springs.relativePosition = new Vector3(15, 85);

            // Dampers
            m_dampers = UIUtils.CreateTextField(panel);
            m_dampers.numericalOnly    = true;
            m_dampers.allowFloats      = true;
            m_dampers.width            = 60;
            m_dampers.tooltip          = "Change the vehicle damper factor;\nDefines how quickly the suspension returns to the default state";
            m_dampers.relativePosition = new Vector3(85, 85);

            // LeanMultiplier
            UILabel leanMultiplierLabel = panel.AddUIComponent <UILabel>();

            leanMultiplierLabel.text             = "Lean/Nod Multiplier:";
            leanMultiplierLabel.textScale        = 0.8f;
            leanMultiplierLabel.relativePosition = new Vector3(160, 66);

            m_leanMultiplier = UIUtils.CreateTextField(panel);
            m_leanMultiplier.numericalOnly    = true;
            m_leanMultiplier.allowFloats      = true;
            m_leanMultiplier.width            = 60;
            m_leanMultiplier.tooltip          = "Change the vehicle lean multiplication factor;\nDefines how much the vehicle leans to the sides when turning";
            m_leanMultiplier.relativePosition = new Vector3(160, 85);

            // NodMultiplier
            m_nodMultiplier = UIUtils.CreateTextField(panel);
            m_nodMultiplier.numericalOnly    = true;
            m_nodMultiplier.allowFloats      = true;
            m_nodMultiplier.width            = 60;
            m_nodMultiplier.tooltip          = "Change the vehicle nod multiplication factor;\nDefines how much the vehicle nods forward/backward when braking or accelerating";
            m_nodMultiplier.relativePosition = new Vector3(230, 85);

            // Colors
            m_useColors                  = UIUtils.CreateCheckBox(panel);
            m_useColors.text             = "Enable Color variations:";
            m_useColors.isChecked        = true;
            m_useColors.width            = width - 40;
            m_useColors.tooltip          = "Enable color variations\nA random color is chosen between the four following colors";
            m_useColors.relativePosition = new Vector3(15, 116);

            m_color0                      = UIUtils.CreateColorField(panel);
            m_color0.name                 = "AVO-color0";
            m_color0.popupTopmostRoot     = false;
            m_color0.relativePosition     = new Vector3(35, 135);
            m_color0_hex                  = UIUtils.CreateTextField(panel);
            m_color0_hex.maxLength        = 6;
            m_color0_hex.relativePosition = new Vector3(80, 137);

            m_color1                      = UIUtils.CreateColorField(panel);
            m_color1.name                 = "AVO-color1";
            m_color1.popupTopmostRoot     = false;
            m_color1.relativePosition     = new Vector3(35, 160);
            m_color1_hex                  = UIUtils.CreateTextField(panel);
            m_color1_hex.maxLength        = 6;
            m_color1_hex.relativePosition = new Vector3(80, 162);

            m_color2                      = UIUtils.CreateColorField(panel);
            m_color2.name                 = "AVO-color2";
            m_color2.popupTopmostRoot     = false;
            m_color2.relativePosition     = new Vector3(182, 135);
            m_color2_hex                  = UIUtils.CreateTextField(panel);
            m_color2_hex.maxLength        = 6;
            m_color2_hex.relativePosition = new Vector3(225, 137);

            m_color3                      = UIUtils.CreateColorField(panel);
            m_color3.name                 = "AVO-color3";
            m_color3.popupTopmostRoot     = false;
            m_color3.relativePosition     = new Vector3(182, 160);
            m_color3_hex                  = UIUtils.CreateTextField(panel);
            m_color3_hex.maxLength        = 6;
            m_color3_hex.relativePosition = new Vector3(225, 162);

            m_useColorsLabel = panel.AddUIComponent <UILabel>();
            m_useColorsLabel.Hide();
            m_useColorsLabel.textScale        = 0.8f;
            m_useColorsLabel.text             = "Colors are managed by Vehicle Color Expander";
            m_useColorsLabel.relativePosition = new Vector3(15, 116);

            // Enable & BackEngine
            m_enabled                  = UIUtils.CreateCheckBox(panel);
            m_enabled.text             = "Allow this vehicle to spawn";
            m_enabled.isChecked        = true;
            m_enabled.width            = width - 40;
            m_enabled.tooltip          = "Make sure you have at least one vehicle allowed to spawn for that category";
            m_enabled.relativePosition = new Vector3(15, 195);;

            m_addBackEngine                  = UIUtils.CreateCheckBox(panel);
            m_addBackEngine.text             = "Replace last car with engine";
            m_addBackEngine.isChecked        = false;
            m_addBackEngine.width            = width - 40;
            m_addBackEngine.tooltip          = "Make the last car of this train be an engine";
            m_addBackEngine.relativePosition = new Vector3(15, 215);

            // LargeVehicle Setting for NoBigTruck Delivery Mod
            m_isLargeVehicle                  = UIUtils.CreateCheckBox(panel);
            m_isLargeVehicle.text             = "Flag as Large Vehicle";
            m_isLargeVehicle.width            = width - 40;
            m_isLargeVehicle.tooltip          = "Prevent vehicles with trailer to deliver to small buildings\n\nNeeds No Big Trucks mod to work";
            m_isLargeVehicle.relativePosition = new Vector3(15, 215);

            // Capacity
            UIPanel capacityPanel = panel.AddUIComponent <UIPanel>();

            capacityPanel.size             = Vector2.zero;
            capacityPanel.relativePosition = new Vector3(15, 240);

            capacityLabel                  = capacityPanel.AddUIComponent <UILabel>();
            capacityLabel.text             = "Capacity: ";
            capacityLabel.textScale        = 0.8f;
            capacityLabel.relativePosition = new Vector3(0, 2);

            m_capacity = UIUtils.CreateTextField(capacityPanel);
            m_capacity.numericalOnly    = true;
            m_capacity.maxLength        = 8;
            m_capacity.width            = 100;
            m_capacity.tooltip          = "Change the capacity of the vehicle";
            m_capacity.relativePosition = new Vector3(0, 21);

            // Special Capacity
            specialcapacityLabel = capacityPanel.AddUIComponent <UILabel>();
            specialcapacityLabel.Hide();
            specialcapacityLabel.text             = "Special Capacity: ";
            specialcapacityLabel.textScale        = 0.8f;
            specialcapacityLabel.relativePosition = new Vector3(160, 2);

            m_specialcapacity = UIUtils.CreateTextField(capacityPanel);
            m_specialcapacity.Hide();
            m_specialcapacity.numericalOnly    = true;
            m_specialcapacity.maxLength        = 8;
            m_specialcapacity.width            = 100;
            m_specialcapacity.tooltip          = "Change special parameters of the vehicle";
            m_specialcapacity.relativePosition = new Vector3(160, 21);

            // Userguide Special Capacity Button
            m_userguidespecialcapacity = UIUtils.CreateButton(capacityPanel);
            m_userguidespecialcapacity.Hide();
            m_userguidespecialcapacity.normalBgSprite   = "EconomyMoreInfo";
            m_userguidespecialcapacity.hoveredBgSprite  = "EconomyMoreInfoHovered";
            m_userguidespecialcapacity.size             = new Vector2(14f, 14f);
            m_userguidespecialcapacity.tooltip          = "If you do not know, what this value is:\nDo not touch it!\n\nClick for User Guide: Special Capacity";
            m_userguidespecialcapacity.relativePosition = new Vector3(265, 24);

            // Transport Line Overview Button
            m_lineoverview = UIUtils.CreateButton(panel);
            m_lineoverview.Hide();
            m_lineoverview.textScale             = 0.8f;
            m_lineoverview.height                = 18;
            m_lineoverview.textVerticalAlignment = UIVerticalAlignment.Bottom;
            m_lineoverview.text             = "Manage Spawning in Transport Line Overview";
            m_lineoverview.width            = 335;
            m_lineoverview.tooltip          = "Open the Transport Line Overview and manage the vehicle spawning";
            m_lineoverview.relativePosition = new Vector3(15, 194);

            // Userguide Spawn Button
            m_userguidespawn = UIUtils.CreateButton(panel);
            m_userguidespawn.Hide();
            m_userguidespawn.normalBgSprite   = "EconomyMoreInfo";
            m_userguidespawn.hoveredBgSprite  = "EconomyMoreInfoHovered";
            m_userguidespawn.size             = new Vector2(14f, 14f);
            m_userguidespawn.tooltip          = "Click for User Guide: Spawn Control";
            m_userguidespawn.relativePosition = new Vector3(355, 195);

            // Buslabel
            bustrailerLabel           = panel.AddUIComponent <UILabel>();
            bustrailerLabel.textScale = 0.8f;
            bustrailerLabel.text      = "Bus trailers spawning is controlled by the main\n" +
                                        "Bus vehicle. Settings must be configured from\n" +
                                        "the Transport Line Overview panel.";
            bustrailerLabel.relativePosition = new Vector3(15, 194);

            // Restore default
            m_restore                  = UIUtils.CreateButton(panel);
            m_restore.text             = "Default Values";
            m_restore.width            = 120;
            m_restore.tooltip          = "Restore all values to default";
            m_restore.relativePosition = new Vector3(250, height - 45);

            // Remove Vehicles
            m_removeLabel                  = this.AddUIComponent <UILabel>();
            m_removeLabel.text             = "Global Actions for: ";
            m_removeLabel.textScale        = 0.8f;
            m_removeLabel.relativePosition = new Vector3(10, height - 65);

            m_clearVehicles                  = UIUtils.CreateButton(this);
            m_clearVehicles.text             = "Remove Driving";
            m_clearVehicles.width            = 120;
            m_clearVehicles.tooltip          = "Remove all driving vehicles of that type\nHold the SHIFT key to remove all types";
            m_clearVehicles.relativePosition = new Vector3(5, height - 45);

            m_clearParked                  = UIUtils.CreateButton(this);
            m_clearParked.text             = "Remove Parked";
            m_clearParked.width            = 120;
            m_clearParked.tooltip          = "Remove all parked vehicles of that type\nHold the SHIFT key to remove all types";
            m_clearParked.relativePosition = new Vector3(130, height - 45);

            panel.BringToFront();

            // Event handlers
            m_maxSpeed.eventTextSubmitted       += OnMaxSpeedSubmitted;
            m_acceleration.eventTextSubmitted   += OnAccelerationSubmitted;
            m_braking.eventTextSubmitted        += OnBrakingSubmitted;
            m_turning.eventTextSubmitted        += OnTurningSubmitted;
            m_springs.eventTextSubmitted        += OnSpringsSubmitted;
            m_dampers.eventTextSubmitted        += OnDampersSubmitted;
            m_leanMultiplier.eventTextSubmitted += OnleanMultiplierSubmitted;
            m_nodMultiplier.eventTextSubmitted  += OnnodMultiplierSubmitted;

            m_useColors.eventCheckChanged += OnCheckChanged;

            MouseEventHandler mousehandler = (c, p) => { if (m_initialized)
                                                         {
                                                             (parent as UIMainPanel).ChangePreviewColor((c as UIColorField).selectedColor);
                                                         }
            };

            m_color0.eventMouseEnter += mousehandler;
            m_color1.eventMouseEnter += mousehandler;
            m_color2.eventMouseEnter += mousehandler;
            m_color3.eventMouseEnter += mousehandler;

            m_color0_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color0.selectedColor);
                                                        }
            };
            m_color1_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color1.selectedColor);
                                                        }
            };
            m_color2_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color2.selectedColor);
                                                        }
            };
            m_color3_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color3.selectedColor);
                                                        }
            };

            m_color0.eventSelectedColorChanged += OnColorChanged;
            m_color1.eventSelectedColorChanged += OnColorChanged;
            m_color2.eventSelectedColorChanged += OnColorChanged;
            m_color3.eventSelectedColorChanged += OnColorChanged;

            m_color0_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color1_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color2_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color3_hex.eventTextSubmitted += OnColorHexSubmitted;

            m_enabled.eventCheckChanged        += OnCheckChanged;
            m_addBackEngine.eventCheckChanged  += OnCheckChanged;
            m_isLargeVehicle.eventCheckChanged += OnCheckChanged;

            m_capacity.eventTextSubmitted        += OnCapacitySubmitted;
            m_specialcapacity.eventTextSubmitted += OnSpecialCapacitySubmitted;

            m_restore.eventClick += (c, p) =>
            {
                m_initialized = false;
                bool isEnabled = m_options.enabled;
                DefaultOptions.Restore(m_options.prefab);
                VehicleOptions.UpdateTransfertVehicles();

                VehicleOptions.prefabUpdateEngine = m_options.prefab;
                VehicleOptions.prefabUpdateUnits  = m_options.prefab;
                new EnumerableActionThread(VehicleOptions.UpdateBackEngines);
                new EnumerableActionThread(VehicleOptions.UpdateCapacityUnits);

                Show(m_options);

                if (m_options.enabled != isEnabled)
                {
                    eventEnableCheckChanged(this, m_options.enabled);
                }
            };

            m_clearVehicles.eventClick            += OnClearVehicleClicked;
            m_clearParked.eventClick              += OnClearVehicleClicked;
            m_lineoverview.eventClick             += OnlineoverviewClicked;
            m_userguidespawn.eventClick           += OnUserGuideSpawnClicked;
            m_userguidespecialcapacity.eventClick += OnUserGuideSpecialCapacityClicked;
        }
        public override void Start()
        {
            base.Start();

            atlas            = UIUtils.GetAtlas("Ingame");
            backgroundSprite = "MenuPanel";
            color            = new Color32(58, 88, 104, 255);
            isVisible        = false;
            canFocus         = true;
            isInteractive    = true;
            clipChildren     = true;
            width            = 400;
            height           = 380;
            relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2));

            // Title Bar
            m_title         = AddUIComponent <UITitleBar>();
            m_title.title   = "New Shortcut";
            m_title.isModal = true;

            // Name
            UILabel label = AddUIComponent <UILabel>();

            label.text             = "Shortcut name:";
            label.autoHeight       = true;
            label.relativePosition = new Vector2(20, 60);

            m_name                  = UIUtils.CreateTextField(this);
            m_name.size             = new Vector2(width - 40, 30);
            m_name.relativePosition = label.relativePosition + new Vector3(0, label.height + 5);
            m_name.textScale        = 1.1f;
            m_name.padding.top      = 6;
            m_name.useDropShadow    = true;

            m_name.eventTextChanged += (c, s) =>
            {
                m_ok.isEnabled = !s.IsNullOrWhiteSpace();
            };

            // Component Name
            label                  = AddUIComponent <UILabel>();
            label.text             = "Button name:";
            label.autoHeight       = true;
            label.relativePosition = m_name.relativePosition + new Vector3(0, m_name.height + 15);

            m_componentName                  = UIUtils.CreateTextField(this);
            m_componentName.size             = new Vector2(width - 40, 30);
            m_componentName.relativePosition = label.relativePosition + new Vector3(0, label.height + 5);
            m_componentName.textScale        = 1.1f;
            m_componentName.padding.top      = 6;
            m_componentName.useDropShadow    = true;

            m_componentName.isEnabled = false;

            // Binding
            label                  = AddUIComponent <UILabel>();
            label.text             = "Key binding:";
            label.autoHeight       = true;
            label.relativePosition = m_componentName.relativePosition + new Vector3(0, m_componentName.height + 15);

            m_binding                  = OptionsKeymapping.GetKeymapping(this, null);
            m_binding.width            = width - 40;
            m_binding.relativePosition = label.relativePosition + new Vector3(0, label.height + 5);

            // Use Path
            m_usePath                  = UIUtils.CreateCheckBox(this);
            m_usePath.label.text       = "Use button's full path";
            m_usePath.tooltip          = "If checked, the full path to the button is used rather than the name alone.\nThis ensure the button is unique.";
            m_usePath.relativePosition = m_binding.relativePosition + new Vector3(0, m_binding.height + 15);

            m_usePath.eventCheckChanged += (c, state) =>
            {
                shortcut.usePath = state;
            };

            // Only visible
            m_onlyVisible                  = UIUtils.CreateCheckBox(this);
            m_onlyVisible.label.text       = "Trigger only if visible";
            m_onlyVisible.tooltip          = "If checked, the button is only triggered if visible.\nUseful for buttons with the same name but only one visible at a time.";
            m_onlyVisible.relativePosition = m_usePath.relativePosition + new Vector3(0, m_usePath.height + 10);

            m_onlyVisible.eventCheckChanged += (c, state) =>
            {
                shortcut.onlyVisible = state;
            };

            // Ok
            m_ok                  = UIUtils.CreateButton(this);
            m_ok.text             = "OK";
            m_ok.relativePosition = new Vector2(20, height - m_ok.height - 20);
            m_ok.isEnabled        = false;

            m_ok.eventClick += (c, p) =>
            {
                if (isVisible)
                {
                    if (m_name.text != shortcut.name)
                    {
                        shortcut.name = Shortcut.GetUniqueName(m_name.text);
                    }
                    shortcut.usePath     = m_usePath.isChecked;
                    shortcut.onlyVisible = m_onlyVisible.isChecked;
                    shortcut.inputKey    = ((Shortcut)m_binding.objectUserData).inputKey;

                    Shortcut.AddShortcut(shortcut);
                    Shortcut.SaveShorcuts();
                    OptionsKeymapping.RefreshShortcutsList();

                    UIView.PopModal();
                    Hide();
                }
            };

            // Cancel
            m_cancel                  = UIUtils.CreateButton(this);
            m_cancel.text             = "Cancel";
            m_cancel.relativePosition = new Vector2(width - m_cancel.width - 20, height - m_cancel.height - 20);

            m_cancel.eventClick += (c, p) =>
            {
                if (isVisible)
                {
                    UIView.PopModal();
                    Hide();
                }
            };

            isVisible = false;
        }
Example #14
0
        private void SetupControls()
        {
            float offset = 40f;

            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "IconAssetBuilding";
            m_title.title      = "Mayoral City Service Info " + MCSI.version;

            _tabstrip          = UIUtils.CreateTabStrip(this);
            _tabstrip.tabPages = UIUtils.CreateTabContainer(this);
            _templateButton    = UIUtils.CreateTabButton(this);
            for (int i = 0; i < kServices.Length; i++)
            {
                SpawnSubEntry(_tabstrip, kServices[i]);
            }
            _tabstrip.relativePosition           = new Vector3(15f, offset);
            _tabstrip.eventSelectedIndexChanged += (c, t) => PopulateList();
            Destroy(_templateButton);

            /*
             * // Sorting DropDown
             * label = AddUIComponent<UILabel>();
             * label.textScale = 0.8f;
             * label.padding = new RectOffset(0, 0, 8, 0);
             * label.relativePosition = m_prefabType.relativePosition + new Vector3(130f, 0f);
             * label.text = "Sort by :";
             *
             * m_sorting = UIUtils.CreateDropDown(this);
             * m_sorting.width = 125;
             * m_sorting.AddItem("Name");
             * m_sorting.AddItem("Triangles");
             * m_sorting.AddItem("LOD Triangles");
             * m_sorting.AddItem("Weight");
             * m_sorting.AddItem("LOD Weight");
             * m_sorting.AddItem("Texture");
             * m_sorting.AddItem("LOD Texture");
             * m_sorting.selectedIndex = 0;
             * m_sorting.relativePosition = label.relativePosition + new Vector3(60f, 0f);
             *
             * m_sorting.eventSelectedIndexChanged += (c, t) =>
             * {
             *  m_sorting.enabled = false;
             *  m_isSorted = false;
             *  PopulateList();
             *  m_sorting.enabled = true;
             * };
             *
             * // Sorting direction
             * m_sortDirection = AddUIComponent<UISprite>();
             * m_sortDirection.atlas = GetUIView().defaultAtlas;
             * m_sortDirection.spriteName = "IconUpArrow";
             * m_sortDirection.relativePosition = m_sorting.relativePosition + new Vector3(130f, 0f);
             *
             * m_sortDirection.eventClick += (c, t) =>
             * {
             *  m_sortDirection.flip = (m_sortDirection.flip == UISpriteFlip.None) ? UISpriteFlip.FlipVertical : UISpriteFlip.None;
             *  m_isSorted = false;
             *  PopulateList();
             * };
             */
            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 150f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.relativePosition = new Vector3(width - m_search.width - 15f, offset + 5f);

            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = "Search :";

            m_search.eventTextChanged += (c, t) => PopulateList();

            // Labels
            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = Locale.Get("EXTENDED_PUBLIC_TRANSPORT_UI_ITEM_1");
            label.relativePosition = new Vector3(15f, offset + 45f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = Locale.Get("TUTORIAL_ADVISER_TITLE", "District");
            label.relativePosition = new Vector3(550f, offset + 45f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = Locale.Get("CAMPUSPANEL_VARSITYSPORTS_UPKEEP");
            label.relativePosition = new Vector3(675f, offset + 45f);

            // Item List
            m_itemList                  = UIFastList.Create <UIPrefabItem>(this);
            m_itemList.RowHeight        = 40f;
            m_itemList.CanSelect        = true;
            m_itemList.BackgroundSprite = "UnlockingPanel";
            m_itemList.width            = width - 10;
            m_itemList.height           = height - offset - 75;
            m_itemList.relativePosition = new Vector3(5f, offset + 70f);
        }
        public override void Start()
        {
            name             = "CCX_MainWindow";
            atlas            = UIUtils.GetAtlas("Ingame");
            backgroundSprite = "SubcategoriesPanel";
            size             = new Vector2(465, 180);
            isVisible        = false;

            UIDragHandle dragHandle = AddUIComponent <UIDragHandle>();

            dragHandle.target           = parent;
            dragHandle.relativePosition = Vector3.zero;

            UIButton close = AddUIComponent <UIButton>();

            close.size             = new Vector2(30f, 30f);
            close.text             = "X";
            close.textScale        = 0.9f;
            close.textColor        = new Color32(118, 123, 123, 255);
            close.focusedTextColor = new Color32(118, 123, 123, 255);
            close.hoveredTextColor = new Color32(140, 142, 142, 255);
            close.pressedTextColor = new Color32(99, 102, 102, 102);
            close.textPadding      = new RectOffset(8, 8, 8, 8);
            close.canFocus         = false;
            close.playAudioEvents  = true;
            close.relativePosition = new Vector3(width - close.width, 0);

            close.eventClicked += (c, p) =>
            {
                if (isVisible)
                {
                    CameraDirector.ToggleUI();
                }
            };

            // Control panel
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.9f;
            label.text             = "Cinematic Camera Extended";
            label.relativePosition = new Vector2(8, 8);
            label.SendToBack();

            UIPanel controlPanel = AddUIComponent <UIPanel>();

            controlPanel.atlas            = atlas;
            controlPanel.backgroundSprite = "GenericPanel";
            controlPanel.color            = new Color32(206, 206, 206, 255);
            controlPanel.size             = new Vector2(width - 16, 46);
            controlPanel.relativePosition = new Vector2(8, 28);

            addKnotButton                  = UIUtils.CreateButton(controlPanel);
            addKnotButton.name             = "CCX_AddKnot";
            addKnotButton.textScale        = 1.5f;
            addKnotButton.text             = "+";
            addKnotButton.size             = new Vector2(40f, 30f);
            addKnotButton.relativePosition = new Vector3(8, 8);
            addKnotButton.tooltip          = "Add a new point to the path";

            playButton                  = UIUtils.CreateButton(controlPanel);
            playButton.name             = "CCX_Play";
            playButton.textScale        = 1.5f;
            playButton.text             = ">";
            playButton.size             = new Vector2(40f, 30f);
            playButton.playAudioEvents  = false;
            playButton.relativePosition = new Vector3(controlPanel.width - playButton.width - 8, 8);
            playButton.tooltip          = "Play the current path";

            playSpeedDropDown       = UIUtils.CreateDropDown(controlPanel);
            playSpeedDropDown.width = 75;
            playSpeedDropDown.items = new string[]
            {
                "x 1/16",
                "x 1/8",
                "x 1/4",
                "x 1/2",
                "x 1",
                "x 2",
                "x 4",
                "x 8",
                "x 16"
            };
            playSpeedDropDown.selectedValue    = "x 1";
            playSpeedDropDown.relativePosition = new Vector3(playButton.relativePosition.x - playSpeedDropDown.width - 8, 8);
            playSpeedDropDown.tooltip          = "Playback speed";

            timelineSlider                  = controlPanel.AddUIComponent <UISlider>();
            timelineSlider.name             = "CCX_TimelineSlider";
            timelineSlider.size             = new Vector2(playSpeedDropDown.relativePosition.x - addKnotButton.relativePosition.x - addKnotButton.width - 20, 18);
            timelineSlider.relativePosition = new Vector2(addKnotButton.relativePosition.x + addKnotButton.width + 10, 14);

            UISlicedSprite bgSlider = timelineSlider.AddUIComponent <UISlicedSprite>();

            bgSlider.atlas            = atlas;
            bgSlider.spriteName       = "BudgetSlider";
            bgSlider.size             = new Vector2(timelineSlider.width, 9);
            bgSlider.relativePosition = new Vector2(0, 4);
            bgSlider.tooltip          = "Drag the slider to preview the animation";

            UISlicedSprite thumb = timelineSlider.AddUIComponent <UISlicedSprite>();

            thumb.atlas                = atlas;
            thumb.spriteName           = "SliderBudget";
            timelineSlider.thumbObject = thumb;

            timelineSlider.minValue = 0f;
            timelineSlider.maxValue = 1f;
            timelineSlider.stepSize = 0;
            timelineSlider.value    = 0;

            // FOV panel
            UIPanel fovPanel = AddUIComponent <UIPanel>();

            fovPanel.atlas            = atlas;
            fovPanel.backgroundSprite = "GenericPanel";
            fovPanel.color            = new Color32(206, 206, 206, 255);
            fovPanel.size             = new Vector2(width - 120 - 8 * 3, 46);
            fovPanel.relativePosition = new Vector2(8, controlPanel.relativePosition.y + controlPanel.height + 8);

            label                   = fovPanel.AddUIComponent <UILabel>();
            label.textScale         = 0.9f;
            label.text              = "Fov:";
            label.autoSize          = false;
            label.height            = 30;
            label.verticalAlignment = UIVerticalAlignment.Middle;
            label.relativePosition  = new Vector2(8, 8);

            fovInput                  = UIUtils.CreateTextField(fovPanel);
            fovInput.name             = "CCX_MainFovInput";
            fovInput.size             = new Vector2(45f, 26);
            fovInput.text             = (2f * CameraDirector.camera.fieldOfView).ToString();
            fovInput.numericalOnly    = true;
            fovInput.allowFloats      = true;
            fovInput.padding.top      = 6;
            fovInput.relativePosition = new Vector3(fovPanel.width - fovInput.width - 8, 10);
            fovInput.tooltip          = "Field of view in degrees";

            fovSlider                  = fovPanel.AddUIComponent <UISlider>();
            fovSlider.name             = "CCX_TimelineSlider";
            fovSlider.size             = new Vector2(fovInput.relativePosition.x - label.relativePosition.x - label.width - 20, 18);
            fovSlider.relativePosition = new Vector2(label.relativePosition.x + label.width + 10, 14);

            bgSlider                  = fovSlider.AddUIComponent <UISlicedSprite>();
            bgSlider.atlas            = atlas;
            bgSlider.spriteName       = "BudgetSlider";
            bgSlider.size             = new Vector2(fovSlider.width, 9);
            bgSlider.relativePosition = new Vector2(0, 4);
            bgSlider.tooltip          = "Drag the slider to change the field of view";

            thumb                 = fovSlider.AddUIComponent <UISlicedSprite>();
            thumb.atlas           = atlas;
            thumb.spriteName      = "SliderBudget";
            fovSlider.thumbObject = thumb;

            fovSlider.minValue = 20f;
            fovSlider.maxValue = 179f;
            fovSlider.stepSize = 1f;
            fovSlider.value    = CameraDirector.camera.fieldOfView * 2f;

            // FPS panel
            UIPanel fpsPanel = AddUIComponent <UIPanel>();

            fpsPanel.atlas            = atlas;
            fpsPanel.backgroundSprite = "GenericPanel";
            fpsPanel.color            = new Color32(206, 206, 206, 255);
            fpsPanel.size             = new Vector2(120, 46);
            fpsPanel.relativePosition = new Vector2(fovPanel.relativePosition.x + fovPanel.width + 8, fovPanel.relativePosition.y);

            fpsInput                  = UIUtils.CreateTextField(fpsPanel);
            fpsInput.name             = "CCX_FpsInput";
            fpsInput.size             = new Vector2(45f, 26);
            fpsInput.text             = CameraDirector.fps.ToString();
            fpsInput.numericalOnly    = true;
            fpsInput.allowFloats      = true;
            fpsInput.padding.top      = 6;
            fpsInput.relativePosition = new Vector3(fpsPanel.width - fpsInput.width - 8, 10);
            fpsInput.tooltip          = "Fps";
            fpsInput.tooltip          = "Sync the camera and the simulation at a set frame rate";

            fpsCheckBox                  = UIUtils.CreateCheckBox(fpsPanel);
            fpsCheckBox.text             = "Fps:";
            fpsCheckBox.isChecked        = false;
            fpsCheckBox.width            = fpsPanel.width - fpsInput.width - 24;
            fpsCheckBox.relativePosition = new Vector2(8, 16);
            fpsCheckBox.tooltip          = "Sync the camera and the simulation at a set frame rate";

            // Hide UI checkbox
            hideUICheckBox                  = UIUtils.CreateCheckBox(this);
            hideUICheckBox.name             = "CCX_HideUICheckBox";
            hideUICheckBox.text             = "Hide UI during playback";
            hideUICheckBox.isChecked        = true;
            hideUICheckBox.width            = width - 16;
            hideUICheckBox.relativePosition = new Vector2(8, fovPanel.relativePosition.y + fovPanel.height + 8);

            // Start simulation checkbox
            startSimCheckBox                  = UIUtils.CreateCheckBox(this);
            startSimCheckBox.name             = "CCX_StartSimCheckBox";
            startSimCheckBox.text             = "Unpause simulation";
            startSimCheckBox.isChecked        = false;
            startSimCheckBox.width            = (width - 16) / 2;
            startSimCheckBox.relativePosition = new Vector2(8, hideUICheckBox.relativePosition.y + hideUICheckBox.height + 8);

            // FastList
            fastList = UIFastList.Create <UIKnotsListRow>(this);
            fastList.backgroundSprite = "UnlockingPanel";
            fastList.width            = width - 16;
            fastList.height           = 46 * 5;
            fastList.canSelect        = true;
            fastList.relativePosition = new Vector3(8, startSimCheckBox.relativePosition.y + startSimCheckBox.height + 8);

            fastList.rowHeight = 46f;
            fastList.rowsData  = CameraDirector.cameraPath.knots;

            // Load/Save
            saveLoadButton                  = UIUtils.CreateButton(this);
            saveLoadButton.name             = "CCX_SaveLoadButton";
            saveLoadButton.text             = "Save/Load";
            saveLoadButton.size             = new Vector2(100f, 30f);
            saveLoadButton.relativePosition = new Vector3(width - saveLoadButton.width - 8, fastList.relativePosition.y + fastList.height + 8);
            saveLoadButton.tooltip          = "Work in progress";

            height           = saveLoadButton.relativePosition.y + saveLoadButton.height + 8;
            dragHandle.size  = size;
            absolutePosition = new Vector3(savedWindowX.value, savedWindowY.value);
            MakePixelPerfect();

            addKnotButton.eventClicked += (c, p) =>
            {
                int i = CameraDirector.cameraPath.AddKnot();
                fastList.DisplayAt(i);

                timelineSlider.minValue = 0f;
                float duration = CameraDirector.cameraPath.CalculateTotalDuraction();
                if (duration <= 0f)
                {
                    duration = 1f;
                }
                timelineSlider.maxValue = duration;
            };

            playButton.eventClicked += (c, p) =>
            {
                CameraDirector.cameraPath.Play();
            };

            timelineSlider.eventMouseDown += (c, p) =>
            {
                CameraPath.currentTransfrom = new Knot();
            };

            timelineSlider.eventValueChanged += (c, p) =>
            {
                CameraDirector.cameraPath.SetToTime(p);
            };

            hideUICheckBox.eventCheckChanged += (c, p) =>
            {
                CameraDirector.freeCamera = p;
            };

            startSimCheckBox.eventCheckChanged += (c, p) =>
            {
                CameraDirector.startSimulation = p;
            };

            fovSlider.eventValueChanged += (c, p) =>
            {
                CameraDirector.camera.fieldOfView = p / 2f;
                fovInput.text = p.ToString();
            };

            fovInput.eventTextSubmitted += (c, p) =>
            {
                float value;
                if (float.TryParse(p, out value))
                {
                    CameraDirector.camera.fieldOfView = Mathf.Clamp(value, 20f, 179f) / 2f;

                    if (fovSlider.value != value)
                    {
                        fovSlider.value = value;
                    }
                }

                fovInput.text = (2f * CameraDirector.camera.fieldOfView).ToString();
            };

            fovInput.eventMouseWheel += (c, p) =>
            {
                if (!p.used)
                {
                    fovSlider.value += p.wheelDelta;
                    p.Use();
                }
            };

            fpsCheckBox.eventCheckChanged += (c, p) =>
            {
                CameraDirector.useFps = p;
            };

            fpsInput.eventTextSubmitted += (c, p) =>
            {
                float value;
                if (float.TryParse(p, out value))
                {
                    CameraDirector.fps = Mathf.Max(0, value);
                }

                fpsInput.text = CameraDirector.fps.ToString();
            };

            fpsInput.eventMouseWheel += (c, p) =>
            {
                if (!p.used)
                {
                    CameraDirector.fps = Mathf.Max(0, CameraDirector.fps + p.wheelDelta);
                    fpsInput.text      = CameraDirector.fps.ToString();
                    p.Use();
                }
            };

            saveLoadButton.eventClicked += (c, p) =>
            {
                if (saveLoadWindow == null)
                {
                    saveLoadWindow = (UISaveLoadWindow)GetUIView().AddUIComponent(typeof(UISaveLoadWindow));
                }
                else
                {
                    Destroy(saveLoadWindow);
                }
            };

            DebugUtils.Log("UIMainWindow created");
        }