Beispiel #1
0
        public override void Start()
        {
            isVisible = false;

            backgroundSprite = "GenericPanel";
            color            = new Color32(75, 75, 135, 255);
            width            = Translation.getMenuWidth();
            height           = 30;

            //height = LoadingExtension.IsPathManagerCompatible ? 430 : 230;
            Vector2 resolution = UIView.GetAView().GetScreenResolution();

            relativePosition = new Vector3(resolution.x - Translation.getMenuWidth() - 30f, 65f);

            title                  = AddUIComponent <UILabel>();
            title.text             = "Version " + TrafficManagerMod.Version;
            title.relativePosition = new Vector3(50.0f, 5.0f);

            int y = 30;

            /*_buttonSwitchTraffic = _createButton(Translation.GetString("Switch_traffic_lights"), y, clickSwitchTraffic);
             * y += 40;
             * height += 40;
             *
             * if (Options.prioritySignsEnabled) {
             *      _buttonPrioritySigns = _createButton(Translation.GetString("Add_priority_signs"), y, clickAddPrioritySigns);
             *      y += 40;
             *      height += 40;
             * }
             *
             * _buttonManualControl = _createButton(Translation.GetString("Manual_traffic_lights"), y, clickManualControl);
             * y += 40;
             * height += 40;
             *
             * if (Options.timedLightsEnabled) {
             *      _buttonTimedMain = _createButton(Translation.GetString("Timed_traffic_lights"), y, clickTimedAdd);
             *      y += 40;
             *      height += 40;
             * }
             *
             *
             * _buttonLaneChange = _createButton(Translation.GetString("Change_lane_arrows"), y, clickChangeLanes);
             * y += 40;
             * height += 40;
             *
             * if (Options.laneConnectorEnabled) {
             *      _buttonLaneConnector = _createButton(Translation.GetString("Lane_connector"), y, clickLaneConnector);
             *      y += 40;
             *      height += 40;
             * }
             *
             * if (Options.customSpeedLimitsEnabled) {
             *      _buttonSpeedLimits = _createButton(Translation.GetString("Speed_limits"), y, clickSpeedLimits);
             *      y += 40;
             *      height += 40;
             * }
             *
             * if (Options.vehicleRestrictionsEnabled) {
             *      _buttonVehicleRestrictions = _createButton(Translation.GetString("Vehicle_restrictions"), y, clickVehicleRestrictions);
             *      y += 40;
             *      height += 40;
             * }
             *
             * if (Options.junctionRestrictionsEnabled) {
             *      _buttonJunctionRestrictions = _createButton(Translation.GetString("Junction_restrictions"), y, clickJunctionRestrictions);
             *      y += 40;
             *      height += 40;
             * }
             *
             * _buttonClearTraffic = _createButton(Translation.GetString("Clear_Traffic"), y, clickClearTraffic);
             * y += 40;
             * height += 40;
             *
             *
             * _buttonToggleDespawn = _createButton(Options.enableDespawning ? Translation.GetString("Disable_despawning") : Translation.GetString("Enable_despawning"), y, ClickToggleDespawn);
             * y += 40;
             * height += 40;*/

#if DEBUG
            _goToField                 = CreateTextField("", y);
            y                         += 40;
            height                    += 40;
            _goToPosButton             = _createButton("Goto position", y, clickGoToPos);
            y                         += 40;
            height                    += 40;
            _goToSegmentButton         = _createButton("Goto segment", y, clickGoToSegment);
            y                         += 40;
            height                    += 40;
            _goToNodeButton            = _createButton("Goto node", y, clickGoToNode);
            y                         += 40;
            height                    += 40;
            _goToVehicleButton         = _createButton("Goto vehicle", y, clickGoToVehicle);
            y                         += 40;
            height                    += 40;
            _goToParkedVehicleButton   = _createButton("Goto parked vehicle", y, clickGoToParkedVehicle);
            y                         += 40;
            height                    += 40;
            _goToBuildingButton        = _createButton("Goto building", y, clickGoToBuilding);
            y                         += 40;
            height                    += 40;
            _goToCitizenInstanceButton = _createButton("Goto citizen inst.", y, clickGoToCitizenInstance);
            y                         += 40;
            height                    += 40;
            _printDebugInfoButton      = _createButton("Print debug info", y, clickPrintDebugInfo);
            y                         += 40;
            height                    += 40;
            _reloadConfigButton        = _createButton("Reload configuration", y, clickReloadConfig);
            y                         += 40;
            height                    += 40;
            _recalcLinesButton         = _createButton("Recalculate transport lines", y, clickRecalcLines);
            y                         += 40;
            height                    += 40;
            _checkDetoursButton        = _createButton("Check transport lines", y, clickCheckDetours);
            y                         += 40;
            height                    += 40;

            /*_noneToVehicleButton = _createButton("None -> Vehicle", y, clickNoneToVehicle);
             * y += 40;
             * height += 40;
             * _vehicleToNoneButton = _createButton("Vehicle -> None", y, clickVehicleToNone);
             * y += 40;
             * height += 40;*/
#endif
#if QUEUEDSTATS
            _togglePathFindStatsButton = _createButton("Toggle PathFind stats", y, clickTogglePathFindStats);
            y      += 40;
            height += 40;
#endif
#if DEBUG
            _printFlagsDebugInfoButton = _createButton("Print flags debug info", y, clickPrintFlagsDebugInfo);
            y      += 40;
            height += 40;
            _printBenchmarkReportButton = _createButton("Print benchmark report", y, clickPrintBenchmarkReport);
            y      += 40;
            height += 40;
#endif
        }
Beispiel #2
0
        public override void Start()
        {
            if (LoadingExtension.Instance == null)
            {
                Log.Error("UITrafficManager.Start(): LoadingExtension is null.");
                return;
            }
            TrafficLightTool = LoadingExtension.Instance.TrafficManagerTool;

            backgroundSprite = "GenericPanel";
            color            = new Color32(75, 75, 135, 255);
            width            = Translation.getMenuWidth();
            height           = 30;

            //height = LoadingExtension.IsPathManagerCompatible ? 430 : 230;
            relativePosition = new Vector3(85f, 80f);

            title                  = AddUIComponent <UILabel>();
            title.text             = "Version " + TrafficManagerMod.Version;
            title.relativePosition = new Vector3(50.0f, 5.0f);

            int y = 30;

            _buttonSwitchTraffic = _createButton(Translation.GetString("Switch_traffic_lights"), y, clickSwitchTraffic);
            y      += 40;
            height += 40;

            if (Options.prioritySignsEnabled)
            {
                _buttonPrioritySigns = _createButton(Translation.GetString("Add_priority_signs"), y, clickAddPrioritySigns);
                y      += 40;
                height += 40;
            }

            _buttonManualControl = _createButton(Translation.GetString("Manual_traffic_lights"), y, clickManualControl);
            y      += 40;
            height += 40;

            if (Options.timedLightsEnabled)
            {
                _buttonTimedMain = _createButton(Translation.GetString("Timed_traffic_lights"), y, clickTimedAdd);
                y      += 40;
                height += 40;
            }

            if (LoadingExtension.IsPathManagerCompatible)
            {
                _buttonLaneChange = _createButton(Translation.GetString("Change_lane_arrows"), y, clickChangeLanes);
                y      += 40;
                height += 40;

                if (Options.laneConnectorEnabled)
                {
                    _buttonLaneConnector = _createButton(Translation.GetString("Lane_connector"), y, clickLaneConnector);
                    y      += 40;
                    height += 40;
                }

                if (Options.customSpeedLimitsEnabled)
                {
                    _buttonSpeedLimits = _createButton(Translation.GetString("Speed_limits"), y, clickSpeedLimits);
                    y      += 40;
                    height += 40;
                }

                if (Options.vehicleRestrictionsEnabled)
                {
                    _buttonVehicleRestrictions = _createButton(Translation.GetString("Vehicle_restrictions"), y, clickVehicleRestrictions);
                    y      += 40;
                    height += 40;
                }

                if (Options.junctionRestrictionsEnabled)
                {
                    _buttonJunctionRestrictions = _createButton(Translation.GetString("Junction_restrictions"), y, clickJunctionRestrictions);
                    y      += 40;
                    height += 40;
                }
            }

            _buttonClearTraffic = _createButton(Translation.GetString("Clear_Traffic"), y, clickClearTraffic);
            y      += 40;
            height += 40;

            if (LoadingExtension.IsPathManagerCompatible)
            {
                _buttonToggleDespawn = _createButton(Options.enableDespawning ? Translation.GetString("Disable_despawning") : Translation.GetString("Enable_despawning"), y, ClickToggleDespawn);
                y      += 40;
                height += 40;
            }

#if DEBUG
            _goToField                 = CreateTextField("", y);
            y                         += 40;
            height                    += 40;
            _goToSegmentButton         = _createButton("Goto segment", y, clickGoToSegment);
            y                         += 40;
            height                    += 40;
            _goToNodeButton            = _createButton("Goto node", y, clickGoToNode);
            y                         += 40;
            height                    += 40;
            _goToVehicleButton         = _createButton("Goto vehicle", y, clickGoToVehicle);
            y                         += 40;
            height                    += 40;
            _goToBuildingButton        = _createButton("Goto building", y, clickGoToBuilding);
            y                         += 40;
            height                    += 40;
            _printDebugInfoButton      = _createButton("Print debug info", y, clickPrintDebugInfo);
            y                         += 40;
            height                    += 40;
            _noneToVehicleButton       = _createButton("None -> Vehicle", y, clickNoneToVehicle);
            y                         += 40;
            height                    += 40;
            _vehicleToNoneButton       = _createButton("Vehicle -> None", y, clickVehicleToNone);
            y                         += 40;
            height                    += 40;
            _togglePathFindStatsButton = _createButton("Toggle PathFind stats", y, clickTogglePathFindStats);
            y                         += 40;
            height                    += 40;
#endif
        }
Beispiel #3
0
        /// <summary>
        /// Creates a panel representing the mod and adds it to the <paramref name="parent"/> UI component.
        /// </summary>
        ///
        /// <param name="parent">The parent UI component that the panel will be added to.</param>
        /// <param name="modName">The name of the mod, which is displayed to user.</param>
        /// <param name="mod">The <see cref="PluginInfo"/> instance of the incompatible mod.</param>
        private void CreateEntry(ref UIScrollablePanel parent, string modName, PluginInfo mod)
        {
            string caption = mod.publishedFileID.AsUInt64 == LOCAL_MOD?Translation.GetString("Delete") : Translation.GetString("Unsubscribe");

            UIPanel panel = parent.AddUIComponent <UIPanel>();

            panel.size             = new Vector2(560, 50);
            panel.backgroundSprite = "ContentManagerItemBackground";

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

            label.text             = modName;
            label.textAlignment    = UIHorizontalAlignment.Left;
            label.relativePosition = new Vector2(10, 15);

            CreateButton(panel, caption, (int)panel.width - 170, 10, delegate(UIComponent component, UIMouseEventParameter param) { UnsubscribeClick(component, param, mod); });
        }
Beispiel #4
0
        /// <summary>
        /// Initialises the dialog, populates it with list of incompatible mods, and adds it to the modal stack.
        ///
        /// If the modal stack was previously empty, a blur effect is added over the screen background.
        /// </summary>
        public void Initialize()
        {
            Log._Debug("IncompatibleModsPanel initialize");
            if (mainPanel != null)
            {
                mainPanel.OnDestroy();
            }

            isVisible = true;

            mainPanel = AddUIComponent <UIPanel>();
            mainPanel.backgroundSprite = "UnlockingPanel2";
            mainPanel.color            = new Color32(75, 75, 135, 255);
            width            = 600;
            height           = 440;
            mainPanel.width  = 600;
            mainPanel.height = 440;

            Vector2 resolution = UIView.GetAView().GetScreenResolution();

            relativePosition           = new Vector3((resolution.x / 2) - 300, resolution.y / 3);
            mainPanel.relativePosition = Vector3.zero;

            warningIcon                  = mainPanel.AddUIComponent <UISprite>();
            warningIcon.size             = new Vector2(40f, 40f);
            warningIcon.spriteName       = "IconWarning";
            warningIcon.relativePosition = new Vector3(15, 15);
            warningIcon.zOrder           = 0;

            title                  = mainPanel.AddUIComponent <UILabel>();
            title.autoSize         = true;
            title.padding          = new RectOffset(10, 10, 15, 15);
            title.relativePosition = new Vector2(60, 12);

            title.text = TrafficManagerMod.ModName + " " + Translation.GetString("Traffic_Manager_detected_incompatible_mods");

            closeButton                  = mainPanel.AddUIComponent <UIButton>();
            closeButton.eventClick      += CloseButtonClick;
            closeButton.relativePosition = new Vector3(width - closeButton.width - 45, 15f);
            closeButton.normalBgSprite   = "buttonclose";
            closeButton.hoveredBgSprite  = "buttonclosehover";
            closeButton.pressedBgSprite  = "buttonclosepressed";

            UIPanel panel = mainPanel.AddUIComponent <UIPanel>();

            panel.relativePosition = new Vector2(20, 70);
            panel.size             = new Vector2(565, 320);

            UIHelper helper = new UIHelper(mainPanel);

            runModsCheckerOnStartup = helper.AddCheckbox(Translation.GetString("Scan_for_known_incompatible_mods_on_startup"), State.GlobalConfig.Instance.Main.ScanForKnownIncompatibleModsAtStartup, RunModsCheckerOnStartup_eventCheckChanged) as UICheckBox;
            runModsCheckerOnStartup.relativePosition = new Vector3(20, height - 30f);

            UIScrollablePanel scrollablePanel = panel.AddUIComponent <UIScrollablePanel>();

            scrollablePanel.backgroundSprite    = string.Empty;
            scrollablePanel.size                = new Vector2(550, 340);
            scrollablePanel.relativePosition    = new Vector3(0, 0);
            scrollablePanel.clipChildren        = true;
            scrollablePanel.autoLayoutStart     = LayoutStart.TopLeft;
            scrollablePanel.autoLayoutDirection = LayoutDirection.Vertical;
            scrollablePanel.autoLayout          = true;

            // Populate list of incompatible mods
            if (IncompatibleMods.Count != 0)
            {
                IncompatibleMods.ForEach((pair) =>
                {
                    CreateEntry(ref scrollablePanel, pair.Value, pair.Key);
                });
            }

            scrollablePanel.FitTo(panel);
            scrollablePanel.scrollWheelDirection = UIOrientation.Vertical;
            scrollablePanel.builtinKeyNavigation = true;

            UIScrollbar verticalScroll = panel.AddUIComponent <UIScrollbar>();

            verticalScroll.stepSize         = 1;
            verticalScroll.relativePosition = new Vector2(panel.width - 15, 0);
            verticalScroll.orientation      = UIOrientation.Vertical;
            verticalScroll.size             = new Vector2(20, 320);
            verticalScroll.incrementAmount  = 25;
            verticalScroll.scrollEasingType = EasingType.BackEaseOut;

            scrollablePanel.verticalScrollbar = verticalScroll;

            UISlicedSprite track = verticalScroll.AddUIComponent <UISlicedSprite>();

            track.spriteName       = "ScrollbarTrack";
            track.relativePosition = Vector3.zero;
            track.size             = new Vector2(16, 320);

            verticalScroll.trackObject = track;

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

            thumb.spriteName           = "ScrollbarThumb";
            thumb.autoSize             = true;
            thumb.relativePosition     = Vector3.zero;
            verticalScroll.thumbObject = thumb;

            // Add blur effect if applicable
            blurEffect = GameObject.Find("ModalEffect").GetComponent <UIComponent>();
            AttachUIComponent(blurEffect.gameObject);
            blurEffect.size             = new Vector2(resolution.x, resolution.y);
            blurEffect.absolutePosition = new Vector3(0, 0);
            blurEffect.SendToBack();
            blurEffect.eventPositionChanged += OnBlurEffectPositionChange;
            blurEffect.eventZOrderChanged   += OnBlurEffectZOrderChange;
            blurEffect.opacity   = 0;
            blurEffect.isVisible = true;
            ValueAnimator.Animate("ModalEffect", delegate(float val) { blurEffect.opacity = val; }, new AnimatedFloat(0f, 1f, 0.7f, EasingType.CubicEaseOut));

            // Make sure modal dialog is in front of all other UI
            BringToFront();
        }
 /// <summary>
 /// Reset the tooltip (or set for the first time), or if keybinding has changed
 /// </summary>
 public void UpdateTooltip()
 {
     tooltip = Translation.GetString("Keybind_toggle_TMPE_main_menu")
               + GetTooltip();
 }