/// <summary>Helper to create speed limit sign + label below converted to the opposite unit</summary>
        /// <param name="showMph">Config value from GlobalConfig.I.M.ShowMPH</param>
        /// <param name="speedLimit">The float speed to show</param>
        private void GuiSpeedLimitsWindow_AddButton(bool showMph, SpeedValue speedLimit)
        {
            // The button is wrapped in vertical sub-layout and a label for MPH/KMPH is added
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            float signSize = TrafficManagerTool.AdaptWidth(GUI_SPEED_SIGN_SIZE);

            if (GUILayout.Button(
                    SpeedLimitTextures.GetSpeedLimitTexture(speedLimit),
                    GUILayout.Width(signSize),
                    GUILayout.Height(signSize * GetVerticalTextureScale())))
            {
                currentPaletteSpeedLimit = speedLimit;
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            // For MPH setting display KM/H below, for KM/H setting display MPH
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(
                showMph
                    ? ToKmphPreciseString(speedLimit)
                    : ToMphPreciseString(speedLimit));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
        private void _guiSpeedLimitsWindow(int num)
        {
            GUILayout.BeginHorizontal();

            Color oldColor = GUI.color;

            for (int i = 0; i < SpeedLimitManager.Instance.AvailableSpeedLimits.Count; ++i)
            {
                if (curSpeedLimitIndex != i)
                {
                    GUI.color = Color.gray;
                }
                float signSize = TrafficManagerTool.AdaptWidth(guiSpeedSignSize);
                if (GUILayout.Button(TrafficLightToolTextureResources.SpeedLimitTextures[SpeedLimitManager.Instance.AvailableSpeedLimits[i]], GUILayout.Width(signSize), GUILayout.Height(signSize)))
                {
                    curSpeedLimitIndex = i;
                }
                GUI.color = oldColor;

                if (i == 6)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
            }

            GUILayout.EndHorizontal();

            if (GUILayout.Button(Translation.GetString("Default_speed_limits")))
            {
                defaultsWindowVisible = true;
            }

            DragWindow(ref windowRect);
        }
Example #3
0
        private void GuiSpeedLimitsWindow_AddClearButton()
        {
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            float signSize = TrafficManagerTool.AdaptWidth(GUI_SPEED_SIGN_SIZE);

            if (GUILayout.Button(
                    SpeedLimitTextures.Clear,
                    GUILayout.Width(signSize),
                    GUILayout.Height(signSize * GetVerticalTextureScale())))
            {
                currentPaletteSpeedLimit = null;
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            // For MPH setting display KM/H below, for KM/H setting display MPH
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(Translation.SpeedLimits.Get("Button:Default") + " [del]");

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
        private void _guiSpeedLimitsWindow(int num)
        {
            GUILayout.BeginHorizontal();

            Color oldColor = GUI.color;

            for (int i = 0; i < SpeedLimitManager.AvailableSpeedLimits.Count; ++i)
            {
                if (curSpeedLimitIndex != i)
                {
                    GUI.color = Color.gray;
                }
                float signSize = TrafficManagerTool.AdaptWidth(100);
                if (GUILayout.Button(TrafficLightToolTextureResources.SpeedLimitTextures[SpeedLimitManager.AvailableSpeedLimits[i]], GUILayout.Width(signSize), GUILayout.Height(signSize)))
                {
                    curSpeedLimitIndex = i;
                }
                GUI.color = oldColor;

                if (i == 6)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
            }

            GUILayout.EndHorizontal();
        }
        private void _guiSpeedLimitsWindow(int num)
        {
            GUILayout.BeginHorizontal();

            Color oldColor = GUI.color;

            for (int i = 0; i < SpeedLimitManager.Instance.AvailableSpeedLimits.Count; ++i)
            {
                if (curSpeedLimitIndex != i)
                {
                    GUI.color = Color.gray;
                }
                float signSize = TrafficManagerTool.AdaptWidth(guiSpeedSignSize);
                if (GUILayout.Button(TextureResources.SpeedLimitTextures[SpeedLimitManager.Instance.AvailableSpeedLimits[i]], GUILayout.Width(signSize), GUILayout.Height(signSize)))
                {
                    curSpeedLimitIndex = i;
                }
                GUI.color = oldColor;

                if (i == 6)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
            }

            GUILayout.EndHorizontal();

            if (GUILayout.Button(Translation.GetString("Default_speed_limits")))
            {
                TrafficManagerTool.ShowAdvisor(this.GetType().Name + "_Defaults");
                defaultsWindowVisible = true;
            }

            showLimitsPerLane = GUILayout.Toggle(showLimitsPerLane, Translation.GetString("Show_lane-wise_speed_limits"));

            DragWindow(ref windowRect);
        }