private static void OnLanguageChanged(int newLanguageIndex)
        {
            if (newLanguageIndex <= 0)
            {
                GlobalConfig.Instance.LanguageCode = null;
                GlobalConfig.WriteConfig();
                Translation.SetCurrentLanguageToGameLanguage();
                Options.RebuildMenu();
            }
            else if (newLanguageIndex - 1 < Translation.AvailableLanguageCodes.Count)
            {
                string newLang = Translation.AvailableLanguageCodes[newLanguageIndex - 1];
                GlobalConfig.Instance.LanguageCode = newLang;
                GlobalConfig.WriteConfig();
                Translation.SetCurrentLanguageToTMPELanguage();
                Options.RebuildMenu();
            }
            else
            {
                Log.Warning($"Options.onLanguageChanged: Invalid language index: {newLanguageIndex}");
                return;
            }

            Options.RebuildOptions();
        }
        private static void OnShowPathFindStatsChanged(bool newVal)
        {
            if (!Options.IsGameLoaded())
            {
                return;
            }

            Log._Debug($"Show path-find stats changed to {newVal}");
            Options.showPathFindStats = newVal;
            Options.RebuildMenu();
        }
        public static void SetTimedLightsEnabled(bool newValue) {
            Options.RebuildMenu();
            Options.timedLightsEnabled = newValue;

            if (OptionsMaintenanceTab.EnableTimedLightsToggle != null) {
                OptionsMaintenanceTab.EnableTimedLightsToggle.isChecked = newValue;
            }

            if (!newValue) {
                OptionsOverlaysTab.SetTimedLightsOverlay(false);
            }
        }
        public static void SetPrioritySignsEnabled(bool newValue) {
            Options.RebuildMenu();
            Options.prioritySignsEnabled = newValue;

            if (OptionsMaintenanceTab.EnablePrioritySignsToggle != null) {
                OptionsMaintenanceTab.EnablePrioritySignsToggle.isChecked = newValue;
            }

            if (!newValue) {
                OptionsOverlaysTab.SetPrioritySignsOverlay(false);
            }
        }
        private static void OnVehicleRestrictionsEnabledChanged(bool val)
        {
            if (!Options.IsGameLoaded())
            {
                return;
            }

            Options.RebuildMenu();
            Options.vehicleRestrictionsEnabled = val;
            if (!val)
            {
                OptionsOverlaysTab.SetVehicleRestrictionsOverlay(false);
            }
        }
        public static void SetLaneConnectorEnabled(bool newValue)
        {
            Options.laneConnectorEnabled = newValue;
            Options.RebuildMenu();

            if (_enableLaneConnectorToggle != null)
            {
                _enableLaneConnectorToggle.isChecked = newValue;
            }

            if (!newValue)
            {
                OptionsOverlaysTab.SetConnectedLanesOverlay(false);
            }
        }
        public static void SetJunctionRestrictionsEnabled(bool newValue)
        {
            Options.junctionRestrictionsEnabled = newValue;
            Options.RebuildMenu();

            if (_enableJunctionRestrictionsToggle != null)
            {
                _enableJunctionRestrictionsToggle.isChecked = newValue;
            }

            if (!newValue)
            {
                OptionsOverlaysTab.SetJunctionRestrictionsOverlay(false);
            }
        }
        public static void SetCustomSpeedLimitsEnabled(bool newValue)
        {
            Options.customSpeedLimitsEnabled = newValue;
            Options.RebuildMenu();

            if (_enableCustomSpeedLimitsToggle != null)
            {
                _enableCustomSpeedLimitsToggle.isChecked = newValue;
            }

            if (!newValue)
            {
                OptionsOverlaysTab.SetSpeedLimitsOverlay(false);
            }
        }
        private static void OnCustomSpeedLimitsEnabledChanged(bool val)
        {
            if (!Options.IsGameLoaded())
            {
                return;
            }

            Options.customSpeedLimitsEnabled = val;
            Options.RebuildMenu();

            if (!val)
            {
                OptionsOverlaysTab.SetSpeedLimitsOverlay(false);
            }
        }
        private static void OnTimedLightsEnabledChanged(bool val)
        {
            if (!Options.IsGameLoaded())
            {
                return;
            }

            Options.timedLightsEnabled = val;
            Options.RebuildMenu();

            if (!val)
            {
                OptionsOverlaysTab.SetTimedLightsOverlay(false);
                OptionsVehicleRestrictionsTab.SetTrafficLightPriorityRules(false);
            }
        }
        private static void OnJunctionRestrictionsEnabledChanged(bool val)
        {
            if (!Options.IsGameLoaded())
            {
                return;
            }

            Options.junctionRestrictionsEnabled = val;
            Options.RebuildMenu();

            if (!val)
            {
                OptionsVehicleRestrictionsTab.SetAllowUTurns(false);
                OptionsVehicleRestrictionsTab.SetAllowEnterBlockedJunctions(false);
                OptionsVehicleRestrictionsTab.SetAllowLaneChangesWhileGoingStraight(false);
                SetTurnOnRedEnabled(false);
                OptionsOverlaysTab.SetJunctionRestrictionsOverlay(false);
            }
        }
        private static void OnLaneConnectorEnabledChanged(bool val)
        {
            if (!Options.IsGameLoaded())
            {
                return;
            }

            bool changed = val != Options.laneConnectorEnabled;

            if (!changed)
            {
                return;
            }

            Options.RebuildMenu();
            Options.laneConnectorEnabled = val;
            RoutingManager.Instance.RequestFullRecalculation();

            if (!val)
            {
                OptionsOverlaysTab.SetConnectedLanesOverlay(false);
            }
        }