GetString() public static method

public static GetString ( string key ) : string
key string
return string
        internal void UpdateProperties()
        {
            bool active = CanActivate() && Active;

            m_BackgroundSprites.m_Normal          =
                m_BackgroundSprites.m_Disabled    =
                    m_BackgroundSprites.m_Focused =
                        GetButtonBackgroundTextureId(ButtonName, ButtonMouseState.Base, active);

            m_BackgroundSprites.m_Hovered =
                GetButtonBackgroundTextureId(ButtonName, ButtonMouseState.Hovered, active);

            m_PressedBgSprite =
                GetButtonBackgroundTextureId(ButtonName, ButtonMouseState.MouseDown, active);

            m_ForegroundSprites.m_Normal          =
                m_ForegroundSprites.m_Disabled    =
                    m_ForegroundSprites.m_Focused =
                        GetButtonForegroundTextureId(ButtonName, FunctionName, active);

            m_ForegroundSprites.m_Hovered =
                m_PressedFgSprite         =
                    GetButtonForegroundTextureId(ButtonName, FunctionName, true);

            string shortcutText = GetShortcutTooltip();

            tooltip = Translation.GetString(Tooltip) + shortcutText;

            isVisible = Visible;
            this.Invalidate();
        }
        /// <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 #3
0
        public override void Start()
        {
            base.Start();

            var transportInfoViewPanel = GameObject.Find("(Library) PublicTransportInfoViewPanel").GetComponent <PublicTransportInfoViewPanel>();

            if (transportInfoViewPanel != null)
            {
                Log._Debug($"Public transport info view panel found.");
                transportInfoViewPanel.component.eventVisibilityChanged += new PropertyChangedEventHandler <bool>(this.ParentVisibilityChanged);
            }
            else
            {
                Log.Warning($"Public transport info view panel NOT found.");
            }

            isInteractive = true;
            isVisible     = false;

            backgroundSprite = "GenericPanel";
            color            = new Color32(75, 75, 135, 255);
            width            = 156;
            height           = 48;

            relativePosition = new Vector3(540f, 10f);

            viewModeLabel                  = AddUIComponent <UILabel>();
            viewModeLabel.text             = Translation.GetString("Outgoing_demand");
            viewModeLabel.relativePosition = new Vector3(3f, 33f);
            viewModeLabel.textScale        = 0.75f;

            switchViewModeButton = _createButton(Translation.GetString("Switch_view"), 3, 3, clickSwitchViewMode);
        }
        private void ParentVisibilityChanged(UIComponent component, bool value)
        {
            Log._Debug($"Public transport info view panel changed visibility: {value}");

            if (value && Options.parkingAI)
            {
                TrafficManagerTool.CurrentTransportDemandViewMode =
                    TransportDemandViewMode.Outgoing;
                if (viewModeLabel_ != null)
                {
                    viewModeLabel_.text = Translation.GetString("Outgoing_demand");
                }

                if (switchViewModeButton_ != null)
                {
                    switchViewModeButton_.text = Translation.GetString("Switch_view");
                }

                this.Show();
            }
            else
            {
                this.Hide();
            }
        }
        private static void ClickToggleDespawn(UIComponent component, UIMouseEventParameter eventParam)
        {
            TrafficManagerTool.SetToolMode(ToolMode.None);

            Options.setEnableDespawning(!Options.enableDespawning);

            _buttonToggleDespawn.text = Options.enableDespawning
                                ? Translation.GetString("Disable_despawning")
                                : Translation.GetString("Enable_despawning");
        }
Beispiel #6
0
 private void clickSwitchViewMode(UIComponent component, UIMouseEventParameter eventParam)
 {
     if (TrafficManagerTool.CurrentTransportDemandViewMode == TransportDemandViewMode.Outgoing)
     {
         viewModeLabel.text = Translation.GetString("Incoming_demand");
         TrafficManagerTool.CurrentTransportDemandViewMode = TransportDemandViewMode.Incoming;
     }
     else
     {
         viewModeLabel.text = Translation.GetString("Outgoing_demand");
         TrafficManagerTool.CurrentTransportDemandViewMode = TransportDemandViewMode.Outgoing;
     }
 }
        private static void ClickToggleDespawn(UIComponent component, UIMouseEventParameter eventParam)
        {
            TrafficLightTool.SetToolMode(ToolMode.None);

            Options.setEnableDespawning(!Options.enableDespawning);

            if (LoadingExtension.IsPathManagerCompatible)
            {
                _buttonToggleDespawn.text = Options.enableDespawning
                                        ? Translation.GetString("Disable_despawning")
                                        : Translation.GetString("Enable_despawning");
            }
        }
Beispiel #8
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           = LoadingExtension.IsPathManagerCompatible ? 390 : 230;
#if DEBUG
            height += 160;
#endif
            relativePosition = new Vector3(85f, 80f);

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

            int y = 30;
            _buttonSwitchTraffic = _createButton(Translation.GetString("Switch_traffic_lights"), y, clickSwitchTraffic);
            y += 40;
            _buttonPrioritySigns = _createButton(Translation.GetString("Add_priority_signs"), y, clickAddPrioritySigns);
            y += 40;
            _buttonManualControl = _createButton(Translation.GetString("Manual_traffic_lights"), y, clickManualControl);
            y += 40;
            _buttonTimedMain = _createButton(Translation.GetString("Timed_traffic_lights"), y, clickTimedAdd);
            y += 40;

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

                _buttonSpeedLimits = _createButton(Translation.GetString("Speed_limits"), y, clickSpeedLimits);
                y += 40;

                _buttonVehicleRestrictions = _createButton(Translation.GetString("Vehicle_restrictions"), y, clickVehicleRestrictions);
                y += 40;
            }

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

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

#if DEBUG
            _goToField         = CreateTextField("", y);
            y                 += 40;
            _goToSegmentButton = _createButton("Goto segment", y, clickGoToSegment);
            y                 += 40;
            _goToNodeButton    = _createButton("Goto node", y, clickGoToNode);
            y                 += 40;
            _goToVehicleButton = _createButton("Goto vehicle", y, clickGoToVehicle);
            y                 += 40;
#endif
        }
        /// <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"),
                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();
 }
        public override void Start()
        {
            TrafficLightTool = LoadingExtension.TrafficManagerTool;
            isVisible        = false;

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

            //height = LoadingExtension.IsPathManagerCompatible ? 430 : 230;
            relativePosition = new Vector3(85f, 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;
            _goToPosButton             = _createButton("Clear position", y, clickClearPos);
            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;
            _goToCitizenInstanceButton = _createButton("Goto citizen inst.", y, clickGoToCitizenInstance);
            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;
#endif
#if QUEUEDSTATS
            _togglePathFindStatsButton = _createButton("Toggle PathFind stats", y, clickTogglePathFindStats);
            y      += 40;
            height += 40;
#endif
#if DEBUG
            _removeStuckEntitiesButton = _createButton("Remove stuck entities", y, clickRemoveStuckEntities);
            y      += 40;
            height += 40;
#endif
        }