/// <summary>
        /// The window for selecting and applying a speed limit
        /// </summary>
        /// <param name="num"></param>
        private void GuiSpeedLimitsWindow(int num)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            Color             oldColor       = GUI.color;
            List <SpeedValue> allSpeedLimits = EnumerateSpeedLimits(SpeedUnit.CurrentlyConfigured);

            allSpeedLimits.Add(new SpeedValue(0)); // add last item: no limit

            bool showMph     = GlobalConfig.Instance.Main.DisplaySpeedLimitsMph;
            var  column      = 0u; // break palette to a new line at breakColumn
            int  breakColumn = showMph ? BREAK_PALETTE_COLUMN_MPH : BREAK_PALETTE_COLUMN_KMPH;

            foreach (SpeedValue speedLimit in allSpeedLimits)
            {
                // Highlight palette item if it is very close to its float speed
                if (FloatUtil.NearlyEqual(currentPaletteSpeedLimit.GameUnits, speedLimit.GameUnits))
                {
                    GUI.color = Color.gray;
                }

                GuiSpeedLimitsWindow_AddButton(showMph, speedLimit);
                GUI.color = oldColor;

                // TODO: This can be calculated from SpeedLimit MPH or KMPH limit constants
                column++;
                if (column % breakColumn == 0)
                {
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                }
            }

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

            //---------------------
            // UI buttons row
            //---------------------
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

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

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

            //---------------------
            // Checkboxes row
            //---------------------
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            showLimitsPerLane = GUILayout.Toggle(
                showLimitsPerLane,
                Translation.GetString("Show_lane-wise_speed_limits"));

            GUILayout.FlexibleSpace();

            // Display MPH checkbox, if ticked will save global config
            bool displayMph = GlobalConfig.Instance.Main.DisplaySpeedLimitsMph;

            displayMph = GUILayout.Toggle(displayMph, Translation.GetString("Display_speed_limits_mph"));

            if (GlobalConfig.Instance.Main.DisplaySpeedLimitsMph != displayMph)
            {
                OptionsGeneralTab.SetDisplayInMph(displayMph);
            }

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

            DragWindow(ref paletteWindowRect);
        }
示例#2
0
 /// <summary>
 /// Hnadles click of the "Run incompatible check on startup" checkbox and updates game options accordingly.
 /// </summary>
 ///
 /// <param name="value">The new value of the checkbox; <c>true</c> if checked, otherwise <c>false</c>.</param>
 private void RunModsCheckerOnStartup_eventCheckChanged(bool value)
 {
     Log._Debug("Incompatible mods checker run on game launch changed to " + value);
     OptionsGeneralTab.SetScanForKnownIncompatibleMods(value);
 }
示例#3
0
        public bool LoadData(byte[] data)
        {
            if (data.Length >= 1)
            {
                OptionsGeneralTab.SetSimulationAccuracy(ConvertToSimulationAccuracy(data[0]));
            }

            if (data.Length >= 2)
            {
                // Options.setLaneChangingRandomization(options[1]);
            }

            if (data.Length >= 3)
            {
                OptionsGameplayTab.SetRecklessDrivers(data[2]);
            }

            if (data.Length >= 4)
            {
                OptionsVehicleRestrictionsTab.SetRelaxedBusses(data[3] == 1);
            }

            if (data.Length >= 5)
            {
                OptionsOverlaysTab.SetNodesOverlay(data[4] == 1);
            }

            if (data.Length >= 6)
            {
                OptionsVehicleRestrictionsTab.SetMayEnterBlockedJunctions(data[5] == 1);
            }

            if (data.Length >= 7)
            {
                OptionsGameplayTab.SetAdvancedAi(data[6] == 1);
            }

            if (data.Length >= 8)
            {
                OptionsVehicleRestrictionsTab.SetHighwayRules(data[7] == 1);
            }

            if (data.Length >= 9)
            {
                OptionsOverlaysTab.SetPrioritySignsOverlay(data[8] == 1);
            }

            if (data.Length >= 10)
            {
                OptionsOverlaysTab.SetTimedLightsOverlay(data[9] == 1);
            }

            if (data.Length >= 11)
            {
                OptionsOverlaysTab.SetSpeedLimitsOverlay(data[10] == 1);
            }

            if (data.Length >= 12)
            {
                OptionsOverlaysTab.SetVehicleRestrictionsOverlay(data[11] == 1);
            }

            if (data.Length >= 13)
            {
                OptionsGameplayTab.SetStrongerRoadConditionEffects(data[12] == 1);
            }

            if (data.Length >= 14)
            {
                OptionsVehicleRestrictionsTab.SetAllowUTurns(data[13] == 1);
            }

            if (data.Length >= 15)
            {
                OptionsVehicleRestrictionsTab.SetAllowLaneChangesWhileGoingStraight(data[14] == 1);
            }

            if (data.Length >= 16)
            {
                OptionsGameplayTab.SetDisableDespawning(data[15] != 1);
            }

            if (data.Length >= 17)
            {
                // Options.setDynamicPathRecalculation(data[16] == (byte)1);
            }

            if (data.Length >= 18)
            {
                OptionsOverlaysTab.SetConnectedLanesOverlay(data[17] == 1);
            }

            if (data.Length >= 19)
            {
                OptionsVehicleRestrictionsTab.SetPrioritySignsEnabled(data[18] == 1);
            }

            if (data.Length >= 20)
            {
                OptionsVehicleRestrictionsTab.SetTimedLightsEnabled(data[19] == 1);
            }

            if (data.Length >= 21)
            {
                OptionsMaintenanceTab.SetCustomSpeedLimitsEnabled(data[20] == 1);
            }

            if (data.Length >= 22)
            {
                OptionsMaintenanceTab.SetVehicleRestrictionsEnabled(data[21] == 1);
            }

            if (data.Length >= 23)
            {
                OptionsMaintenanceTab.SetLaneConnectorEnabled(data[22] == 1);
            }

            if (data.Length >= 24)
            {
                OptionsOverlaysTab.SetJunctionRestrictionsOverlay(data[23] == 1);
            }

            if (data.Length >= 25)
            {
                OptionsMaintenanceTab.SetJunctionRestrictionsEnabled(data[24] == 1);
            }

            if (data.Length >= 26)
            {
                OptionsGameplayTab.SetProhibitPocketCars(data[25] == 1);
            }

            if (data.Length >= 27)
            {
                OptionsVehicleRestrictionsTab.SetPreferOuterLane(data[26] == 1);
            }

            if (data.Length >= 28)
            {
                OptionsGameplayTab.SetIndividualDrivingStyle(data[27] == 1);
            }

            if (data.Length >= 29)
            {
                OptionsVehicleRestrictionsTab.SetEvacBussesMayIgnoreRules(data[28] == 1);
            }

            if (data.Length >= 30)
            {
                OptionsGeneralTab.SetInstantEffects(data[29] == 1);
            }

            if (data.Length >= 31)
            {
                OptionsMaintenanceTab.SetParkingRestrictionsEnabled(data[30] == 1);
            }

            if (data.Length >= 32)
            {
                OptionsOverlaysTab.SetParkingRestrictionsOverlay(data[31] == 1);
            }

            if (data.Length >= 33)
            {
                OptionsVehicleRestrictionsTab.SetBanRegularTrafficOnBusLanes(data[32] == 1);
            }

            if (data.Length >= 34)
            {
                OptionsMaintenanceTab.SetShowPathFindStats(data[33] == 1);
            }

            if (data.Length >= 35)
            {
                OptionsGameplayTab.SetDLSPercentage(data[34]);
            }

            if (data.Length >= 36)
            {
                try {
                    OptionsVehicleRestrictionsTab.SetVehicleRestrictionsAggression(
                        (VehicleRestrictionsAggression)data[35]);
                }
                catch (Exception e) {
                    Log.Warning(
                        $"Skipping invalid value {data[35]} for vehicle restrictions aggression");
                }
            }

            if (data.Length >= 37)
            {
                OptionsVehicleRestrictionsTab.SetTrafficLightPriorityRules(data[36] == 1);
            }

            if (data.Length >= 38)
            {
                OptionsGameplayTab.SetRealisticPublicTransport(data[37] == 1);
            }

            if (data.Length >= 39)
            {
                OptionsMaintenanceTab.SetTurnOnRedEnabled(data[38] == 1);
            }

            if (data.Length >= 40)
            {
                OptionsVehicleRestrictionsTab.SetAllowNearTurnOnRed(data[39] == 1);
            }

            if (data.Length >= 41)
            {
                OptionsVehicleRestrictionsTab.SetAllowFarTurnOnRed(data[40] == 1);
            }

            if (data.Length >= 42)
            {
                OptionsVehicleRestrictionsTab.SetAddTrafficLightsIfApplicable(data[41] == 1);
            }

            int LoadBool(int idx, ILegacySerializableOption opt)
            {
                if (data.Length > idx)
                {
                    opt.Load(data[idx]);
                }
                return(idx + 1);
            };

            int index = 42;

            index = LoadBool(index, OptionsMassEditTab.RoundAboutQuickFix_StayInLaneMainR);
            index = LoadBool(index, OptionsMassEditTab.RoundAboutQuickFix_StayInLaneNearRabout);
            index = LoadBool(index, OptionsMassEditTab.RoundAboutQuickFix_DedicatedExitLanes);
            index = LoadBool(index, OptionsMassEditTab.RoundAboutQuickFix_NoCrossMainR);
            index = LoadBool(index, OptionsMassEditTab.RoundAboutQuickFix_NoCrossYieldR);
            index = LoadBool(index, OptionsMassEditTab.RoundAboutQuickFix_PrioritySigns);

            index = LoadBool(index, OptionsMassEditTab.PriorityRoad_CrossMainR);
            index = LoadBool(index, OptionsMassEditTab.PriorityRoad_AllowLeftTurns);
            index = LoadBool(index, OptionsMassEditTab.PriorityRoad_EnterBlockedYeild);
            index = LoadBool(index, OptionsMassEditTab.PriorityRoad_StopAtEntry);

            index = LoadBool(index, OptionsMassEditTab.RoundAboutQuickFix_KeepClearYieldR);
            index = LoadBool(index, OptionsMassEditTab.RoundAboutQuickFix_RealisticSpeedLimits);
            index = LoadBool(index, OptionsMassEditTab.RoundAboutQuickFix_ParkingBanMainR);
            index = LoadBool(index, OptionsMassEditTab.RoundAboutQuickFix_ParkingBanYieldR);

            index = LoadBool(index, OptionsVehicleRestrictionsTab.NoDoubleCrossings);
            return(true);
        }
示例#4
0
        public bool LoadData(byte[] data)
        {
            if (data.Length >= 1)
            {
                // Options.setSimAccuracy(data[0]);
            }

            if (data.Length >= 2)
            {
                // Options.setLaneChangingRandomization(options[1]);
            }

            if (data.Length >= 3)
            {
                OptionsGameplayTab.SetRecklessDrivers(data[2]);
            }

            if (data.Length >= 4)
            {
                OptionsVehicleRestrictionsTab.SetRelaxedBusses(data[3] == 1);
            }

            if (data.Length >= 5)
            {
                OptionsOverlaysTab.SetNodesOverlay(data[4] == 1);
            }

            if (data.Length >= 6)
            {
                OptionsVehicleRestrictionsTab.SetMayEnterBlockedJunctions(data[5] == 1);
            }

            if (data.Length >= 7)
            {
                OptionsGameplayTab.SetAdvancedAi(data[6] == 1);
            }

            if (data.Length >= 8)
            {
                OptionsVehicleRestrictionsTab.SetHighwayRules(data[7] == 1);
            }

            if (data.Length >= 9)
            {
                OptionsOverlaysTab.SetPrioritySignsOverlay(data[8] == 1);
            }

            if (data.Length >= 10)
            {
                OptionsOverlaysTab.SetTimedLightsOverlay(data[9] == 1);
            }

            if (data.Length >= 11)
            {
                OptionsOverlaysTab.SetSpeedLimitsOverlay(data[10] == 1);
            }

            if (data.Length >= 12)
            {
                OptionsOverlaysTab.SetVehicleRestrictionsOverlay(data[11] == 1);
            }

            if (data.Length >= 13)
            {
                OptionsGameplayTab.SetStrongerRoadConditionEffects(data[12] == 1);
            }

            if (data.Length >= 14)
            {
                OptionsVehicleRestrictionsTab.SetAllowUTurns(data[13] == 1);
            }

            if (data.Length >= 15)
            {
                OptionsVehicleRestrictionsTab.SetAllowLaneChangesWhileGoingStraight(data[14] == 1);
            }

            if (data.Length >= 16)
            {
                OptionsGameplayTab.SetDisableDespawning(data[15] != 1);
            }

            if (data.Length >= 17)
            {
                // Options.setDynamicPathRecalculation(data[16] == (byte)1);
            }

            if (data.Length >= 18)
            {
                OptionsOverlaysTab.SetConnectedLanesOverlay(data[17] == 1);
            }

            if (data.Length >= 19)
            {
                OptionsVehicleRestrictionsTab.SetPrioritySignsEnabled(data[18] == 1);
            }

            if (data.Length >= 20)
            {
                OptionsVehicleRestrictionsTab.SetTimedLightsEnabled(data[19] == 1);
            }

            if (data.Length >= 21)
            {
                OptionsMaintenanceTab.SetCustomSpeedLimitsEnabled(data[20] == 1);
            }

            if (data.Length >= 22)
            {
                OptionsMaintenanceTab.SetVehicleRestrictionsEnabled(data[21] == 1);
            }

            if (data.Length >= 23)
            {
                OptionsMaintenanceTab.SetLaneConnectorEnabled(data[22] == 1);
            }

            if (data.Length >= 24)
            {
                OptionsOverlaysTab.SetJunctionRestrictionsOverlay(data[23] == 1);
            }

            if (data.Length >= 25)
            {
                OptionsMaintenanceTab.SetJunctionRestrictionsEnabled(data[24] == 1);
            }

            if (data.Length >= 26)
            {
                OptionsGameplayTab.SetProhibitPocketCars(data[25] == 1);
            }

            if (data.Length >= 27)
            {
                OptionsVehicleRestrictionsTab.SetPreferOuterLane(data[26] == 1);
            }

            if (data.Length >= 28)
            {
                OptionsGameplayTab.SetIndividualDrivingStyle(data[27] == 1);
            }

            if (data.Length >= 29)
            {
                OptionsVehicleRestrictionsTab.SetEvacBussesMayIgnoreRules(data[28] == 1);
            }

            if (data.Length >= 30)
            {
                OptionsGeneralTab.SetInstantEffects(data[29] == 1);
            }

            if (data.Length >= 31)
            {
                OptionsMaintenanceTab.SetParkingRestrictionsEnabled(data[30] == 1);
            }

            if (data.Length >= 32)
            {
                OptionsOverlaysTab.SetParkingRestrictionsOverlay(data[31] == 1);
            }

            if (data.Length >= 33)
            {
                OptionsVehicleRestrictionsTab.SetBanRegularTrafficOnBusLanes(data[32] == 1);
            }

            if (data.Length >= 34)
            {
                OptionsMaintenanceTab.SetShowPathFindStats(data[33] == 1);
            }

            if (data.Length >= 35)
            {
                OptionsGameplayTab.SetDLSPercentage(data[34]);
            }

            if (data.Length >= 36)
            {
                try {
                    OptionsVehicleRestrictionsTab.SetVehicleRestrictionsAggression(
                        (VehicleRestrictionsAggression)data[35]);
                }
                catch (Exception e) {
                    Log.Warning(
                        $"Skipping invalid value {data[35]} for vehicle restrictions aggression");
                }
            }

            if (data.Length >= 37)
            {
                OptionsVehicleRestrictionsTab.SetTrafficLightPriorityRules(data[36] == 1);
            }

            if (data.Length >= 38)
            {
                OptionsGameplayTab.SetRealisticPublicTransport(data[37] == 1);
            }

            if (data.Length >= 39)
            {
                OptionsMaintenanceTab.SetTurnOnRedEnabled(data[38] == 1);
            }

            if (data.Length >= 40)
            {
                OptionsVehicleRestrictionsTab.SetAllowNearTurnOnRed(data[39] == 1);
            }

            if (data.Length >= 41)
            {
                OptionsVehicleRestrictionsTab.SetAllowFarTurnOnRed(data[40] == 1);
            }

            if (data.Length >= 42)
            {
                OptionsVehicleRestrictionsTab.SetAddTrafficLightsIfApplicable(data[41] == 1);
            }

            return(true);
        }