コード例 #1
0
        public static void Initialise()
        {
            //ini stuff

            InitializationFile ini = new InitializationFile("Plugins/LSPDFR/British Policing Script.ini");

            ini.Create();
            try
            {
                ToggleMenuKey                   = (Keys)kc.ConvertFromString(ini.ReadString("General", "ToggleMenuKey", "F9"));
                ToggleMenuModifierKey           = (Keys)kc.ConvertFromString(ini.ReadString("General", "ToggleMenuModifierKey", "None"));
                FailtostopEnabled               = ini.ReadBoolean("Callouts", "FailToStopEnabled", true);
                FailtostopFrequency             = ini.ReadInt32("Callouts", "FailToStopFrequency", 2);
                ANPRHitEnabled                  = ini.ReadBoolean("Callouts", "ANPRHitEnabled", true);
                ANPRHitFrequency                = ini.ReadInt32("Callouts", "ANPRHitFrequency", 2);
                TWOCEnabled                     = ini.ReadBoolean("Callouts", "TWOCEnabled", true);
                TWOCFrequency                   = ini.ReadInt32("Callouts", "TWOCFrequency", 2);
                CourtSystem.RealisticCourtDates = ini.ReadBoolean("General", "RealisticCourtDates", true);
            }
            catch (Exception e)
            {
                Game.LogTrivial(e.ToString());
                Game.LogTrivial("Error loading British Policing Script INI file. Loading defaults");
                Game.DisplayNotification("~r~Error loading British Policing Script INI file. Loading defaults");
            }
            BetaCheck();
        }
コード例 #2
0
        private static void SetupUserGeneralSettings()
        {
            KeysConverter kc = new KeysConverter();

            PlayAnimations              = GeneralIni.ReadBoolean("GeneralConfig", "PlayAnimations", true);
            PlayRadioButtonSounds       = GeneralIni.ReadBoolean("GeneralConfig", "PlayRadioButtonSounds", true);
            PoliceSmartRadio.PlayerName = GeneralIni.ReadString("GeneralConfig", "PlayerName", "NoNameSet");
            ResetRadioWhenOpening       = GeneralIni.ReadBoolean("GeneralConfig", "ResetToPageOneOnOpen", false);
            AlwaysDisplayButtons        = GeneralIni.ReadBoolean("GeneralConfig", "AlwaysDisplayButtons", false);

            ToggleRadioKey         = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "ToggleRadioKey", "C"));
            ToggleRadioModifierKey = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "ToggleRadioModifierKey", "None"));
            NextButtonKey          = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "NextButtonKey", "G"));
            PreviousButtonKey      = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "PreviousButtonKey", "T"));
            SelectButtonKey        = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "SelectButtonKey", "Z"));
            NextPageKey            = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "NextPageKey", "Right"));
            PreviousPageKey        = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "PreviousPageKey", "Left"));

            ToggleRadioButton         = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "ToggleRadioButton", ControllerButtons.DPadLeft);
            ToggleRadioModifierButton = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "ToggleRadioModifierButton", ControllerButtons.None);
            NextButtonButton          = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "NextButtonButton", ControllerButtons.DPadDown);
            PreviousButtonButton      = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "PreviousButtonButton", ControllerButtons.DPadUp);
            SelectButtonButton        = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "SelectButtonButton", ControllerButtons.X);
            NextPageButton            = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "NextPageButton", ControllerButtons.None);
            PreviousPageButton        = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "PreviousPageButton", ControllerButtons.None);
        }
コード例 #3
0
ファイル: Settings.cs プロジェクト: HazyTube/OpenAllDoors
        public static void LoadSettings()
        {
            InitializationFile settings = initialiseFile($"{Globals.Application.ConfigPath}{Globals.Application.ConfigFileName}");

            //Makes a new key converter to convert a string to a key
            KeysConverter kc = new KeysConverter();

            string OpenDoorKey, OpenDoorModifier;

            //GENERAL
            //Reads the settings from the general section in the ini file
            Globals.GeneralConfig.DebugLogging = settings.ReadBoolean("General", "DebugLogging", false);
            Globals.GeneralConfig.OpenDoorHelp = settings.ReadBoolean("General", "OpenDoorHelp", true);

            //KEYBINDINGS
            //Reads the keybindings from the ini file
            OpenDoorKey      = settings.ReadString("Keybindings", "OpenDoorKey", "T");
            OpenDoorModifier = settings.ReadString("Keybindings", "OpenDoorModifierKey", "None");

            //KEY CONVERTERS
            //Converts strings to keys
            Globals.Controls.OpenDoorKey      = (Keys)kc.ConvertFromString(OpenDoorKey);
            Globals.Controls.OpenDoorModifier = (Keys)kc.ConvertFromString(OpenDoorModifier);

            Game.LogTrivial($"[KEYBINDINGS] OpenDoorKey is set to {Globals.Controls.OpenDoorKey}");
            Game.LogTrivial("-----------------------------------------------------------------------------------------------------");
        }
コード例 #4
0
 private static void Log(string message, bool debug = false)
 {
     if (!debug || cfg.ReadBoolean("General", "debug", false))
     {
         Game.Console.Print($"[{DateTime.Now.ToString()}] Custom Blips: {message}");
     }
 }
コード例 #5
0
        internal static void RunConfigCheck()
        {
            if (!ini_file.Exists())
            {
                CreateINIFile();
            }

            user = ini_file.ReadString("SETTINGS", "LoginName");
            pass = ini_file.ReadString("SETTINGS", "LoginPass");
            skip = ini_file.ReadBoolean("SETTINGS", "SkipLogin");
            unit = ini_file.ReadString("SETTINGS", "UnitNumber");
            if (String.IsNullOrWhiteSpace(user))
            {
                user = "******";
            }
            if (String.IsNullOrWhiteSpace(pass))
            {
                pass = "******";
            }
            if (String.IsNullOrWhiteSpace(unit))
            {
                unit = "1-A-12";
            }

            foreach (string key in ini_file.GetKeyNames("VEHICLE BACKGROUNDS"))
            {
                bgs.Add(Game.GetHashKey(key), ini_file.ReadString("VEHICLE BACKGROUNDS", key));
            }
        }
コード例 #6
0
ファイル: Config.cs プロジェクト: Aebian/SilencerKI
        public static void LoadConfig()
        {
            InitializationFile settings = initialiseFile(Global.Application.ConfigPath + "SilencerKI.ini");

            Logger.DebugLog("General Config Loading Started.");

            Global.Application.DebugLogging = (settings.ReadBoolean("General", "DebugLogging", false));
            KeysConverter KeyCV = new KeysConverter();

            string AttachKey, AttachKeyModifier, AttachSilencerController, AttachSilencerControllerModifier;


            AttachKey         = settings.ReadString("Keybinds", "AttachSilencer", "F10");
            AttachKeyModifier = settings.ReadString("Keybinds", "AttachSilencerModifier", "LShiftKey");

            AttachSilencerController         = settings.ReadString("Keybinds", "AttachSilencerController", "DPadRight");
            AttachSilencerControllerModifier = settings.ReadString("Keybinds", "AttachSilencerControllerModifier", "LShiftKey");

            Global.Controls.AttachSilencer         = (Keys)KeyCV.ConvertFromString(AttachKey);
            Global.Controls.AttachSilencerModifier = (Keys)KeyCV.ConvertFromString(AttachKeyModifier);


            TypeConverter     typeConverter        = TypeDescriptor.GetConverter(Global.Controls.AttachSilencerController);
            ControllerButtons CVController         = (ControllerButtons)typeConverter.ConvertFromString(AttachSilencerController);
            ControllerButtons CVControllerModifier = (ControllerButtons)typeConverter.ConvertFromString(AttachSilencerControllerModifier);

            Global.Controls.AttachSilencerController         = CVController;
            Global.Controls.AttachSilencerControllerModifier = CVControllerModifier;

            Logger.DebugLog("General Config Loading Finished.");
        }
コード例 #7
0
ファイル: Settings.cs プロジェクト: HazyTube/TouchTheRear
        public static void LoadSettings()
        {
            InitializationFile settings = initialiseFile(Globals.Application.ConfigPath + Globals.Application.ConfigFileName);

            //Makes a new key converter to convert a string to a key
            KeysConverter kc = new KeysConverter();

            string TouchRearKey, TouchRearModifier;

            //KEYS
            //Reads the keys from the ini file
            TouchRearKey      = settings.ReadString("Keybindings", "TouchRearKey", "U");
            TouchRearModifier = settings.ReadString("Keybindings", "TouchRearModifier", "None");

            //KEY CONVERTERS
            //Converts a string to a key
            Globals.Keybindings.TouchRearKey      = (Keys)kc.ConvertFromString(TouchRearKey);
            Globals.Keybindings.TouchRearModifier = (Keys)kc.ConvertFromString(TouchRearModifier);

            //GENERAL
            //Reads the values in the General section from the ini file
            Globals.GeneralConfig.DebugLogging = settings.ReadBoolean("General", "DebugLogging", false);

            //LOGGERS
            //Logs the values set in the ini file
            Logger.Log("[GENERAL] DebugLogging is set to " + Globals.GeneralConfig.DebugLogging);
            Logger.Log("[KEYBINDINGS] TouchRearKey is set to " + Globals.Keybindings.TouchRearKey);
            Logger.Log("[KEYBINDINGS] TouchRearModifier is set to " + Globals.Keybindings.TouchRearModifier);
            Game.LogTrivial("-----------------------------------------------------------------------------------------------------");
        }
コード例 #8
0
        public static void ReadIniFile()
        {
            PlayerName        = iniFile.ReadString("DISPLAY", "PlayerName", "Loikas");
            UseBritishPersona = iniFile.ReadBoolean("DISPLAY", "UseBritishPersona", false);
            KeysConverter kc = new KeysConverter();

            PlateCheckKey = (Keys)kc.ConvertFromString(iniFile.ReadString("KEYBINDINGS", "PlateCheck", "C"));
            PedCheckKey   = (Keys)kc.ConvertFromString(iniFile.ReadString("KEYBINDINGS", "PedCheck", "X"));
        }
コード例 #9
0
        public void CheckForUpdates(int versionIndex)
        {
            string temponaryPath = Path.GetTempFileName();

            client.DownloadFile(url, temponaryPath);
            downloadedFile = new InitializationFile(temponaryPath);
            if (downloadedFile.ReadBoolean("Main", "AcquireUpdates", false) || downloadedFile.ReadBoolean("Main", "ReleasedAVersion", false))
            {
                int index = downloadedFile.ReadInt32("Main", "Version", versionIndex);
                if (index != versionIndex)
                {
                    Game.DisplayNotification("Update available for " + Name);
                }
            }
            else
            {
                Game.LogTrivial("The update file is not released.");
            }
        }
コード例 #10
0
        public static void IniSetup()
        {
            minStandardUnits = panicIni.ReadInt32("PanicButtonConfig", "MinStandardUnits", 3);
            maxStandardUnits = panicIni.ReadInt32("PanicButtonConfig", "MaxStandardUnits", 5);

            minSwatUnits  = panicIni.ReadInt32("PanicButtonConfig", "MinSwatUnits", 0);
            maxSwatUnits  = panicIni.ReadInt32("PanicButtonConfig", "MaxSwatUnits", 2);
            soundDuration = panicIni.ReadInt32("PanicButtonConfig", "SoundDuration", 450);
            playSound     = panicIni.ReadBoolean("PanicButtonConfig", "PlaySound", true);
        }
コード例 #11
0
ファイル: Configs.cs プロジェクト: wilson212/ComputerPlus
        internal static void RunConfigCheck()
        {
            if (!ini_file.Exists())
            {
                CreateINIFile();
            }
            user                 = ini_file.ReadString("SETTINGS", "LoginName");
            pass                 = ini_file.ReadString("SETTINGS", "LoginPass");
            skip                 = ini_file.ReadBoolean("SETTINGS", "SkipLogin");
            unit                 = ini_file.ReadString("SETTINGS", "UnitNumber");
            FontSize             = ini_file.ReadInt32("SETTINGS", "FontSize");
            FontName             = ini_file.ReadString("SETTINGS", "FontName");
            randomHistoryRecords = ini_file.ReadBoolean("SETTINGS", "RandomHistoryRecords", true);

            displayPedImage     = ini_file.ReadBoolean("SETTINGS", "DisplayPedImage", true);
            displayVehicleImage = ini_file.ReadBoolean("SETTINGS", "DisplayVehicleImage", true);

            enableLSPDFRPlusIntegration = ini_file.ReadBoolean("SETTINGS", "EnableLSPDFRPlusIntegration", true);

            if (String.IsNullOrWhiteSpace(user))
            {
                user = "******";
            }
            if (String.IsNullOrWhiteSpace(pass))
            {
                pass = "******";
            }
            if (String.IsNullOrWhiteSpace(unit))
            {
                unit = "1-A-12";
            }

            FontSize = FontSize > 0 ? FontSize : 16;
            FontName = !String.IsNullOrWhiteSpace(FontName) ? FontName : "Microsoft Sans Serif";

            foreach (string key in ini_file.GetKeyNames("VEHICLE BACKGROUNDS"))
            {
                bgs.Add(Game.GetHashKey(key), ini_file.ReadString("VEHICLE BACKGROUNDS", key));
            }

            ParseKeybindings();
        }
コード例 #12
0
        private static void ReadCfg()
        {
            Logger.LogTrivial("Reading settings from config file...");

            ToggleKey                 = mCfgFile.ReadEnum <Keys>(ECfgSections.SETTINGS.ToString(), ESettings.ToggleKey.ToString(), Keys.F8);
            ToggleKeyModifier         = mCfgFile.ReadEnum <Keys>(ECfgSections.SETTINGS.ToString(), ESettings.ToggleKeyModifier.ToString(), Keys.None);
            PlayAlertSound            = mCfgFile.ReadBoolean(ECfgSections.SETTINGS.ToString(), ESettings.PlayAlertSound.ToString(), true);
            PlayScanSound             = mCfgFile.ReadBoolean(ECfgSections.SETTINGS.ToString(), ESettings.PlayScanSound.ToString(), true);
            AutoDisableOnTrafficStops = mCfgFile.ReadBoolean(ECfgSections.SETTINGS.ToString(), ESettings.AutoDisableOnTrafficStops.ToString(), true);
            AutoDisableOnPursuits     = mCfgFile.ReadBoolean(ECfgSections.SETTINGS.ToString(), ESettings.AutoDisableOnPursuits.ToString(), true);
            //BetaKey = mCfgFile.ReadString(ECfgSections.SETTINGS.ToString(), ESettings.BetaKey.ToString(), "YourBetaKeyHere");

            Logger.LogTrivial("ToggleKey = " + ToggleKey.ToString());

            CameraDegreesFOV    = mCfgFile.ReadInt32(ECfgSections.CAMERAS.ToString(), ECameras.CameraDegreesFOV.ToString(), cCameraDegreesFOV);
            CameraRange         = (float)mCfgFile.ReadDouble(ECfgSections.CAMERAS.ToString(), ECameras.CameraRange.ToString(), cCameraRange);
            CameraMinimum       = (float)mCfgFile.ReadDouble(ECfgSections.CAMERAS.ToString(), ECameras.CameraMinimum.ToString(), (float)cCameraMinRange);
            DriverFrontAngle    = mCfgFile.ReadInt32(ECfgSections.CAMERAS.ToString(), ECameras.DriverFrontAngle.ToString(), cDriverFrontAngle);
            DriverRearAngle     = mCfgFile.ReadInt32(ECfgSections.CAMERAS.ToString(), ECameras.DriverRearAngle.ToString(), cDriverRearAngle);
            PassengerRearAngle  = mCfgFile.ReadInt32(ECfgSections.CAMERAS.ToString(), ECameras.PassengerRearAngle.ToString(), cPassengerRearAngle);
            PassengerFrontAngle = mCfgFile.ReadInt32(ECfgSections.CAMERAS.ToString(), ECameras.PassengerFrontAngle.ToString(), cPassengerFrontAngle);
            VehicleRescanBuffer = mCfgFile.ReadInt32(ECfgSections.CAMERAS.ToString(), ECameras.VehicleRescanBuffer.ToString(), cVehicleRescanBuffer);

            SecondsBetweenAlerts        = mCfgFile.ReadInt32(ECfgSections.ALERTS.ToString(), EAlerts.SecondsBetweenAlerts.ToString(), cSecondsBetweenAlerts);
            ProbabilityOfAlerts         = mCfgFile.ReadInt32(ECfgSections.ALERTS.ToString(), EAlerts.ProbabilityOfAlerts.ToString(), cProbabilityOfAlerts);
            StolenVehicleWeight         = mCfgFile.ReadInt32(ECfgSections.ALERTS.ToString(), EAlerts.StolenVehicleWeight.ToString(), cDefaultStolenVehicleWeight);
            OwnerWantedWeight           = mCfgFile.ReadInt32(ECfgSections.ALERTS.ToString(), EAlerts.OwnerWantedWeight.ToString(), cDefaultOwnerWantedWeight);
            OwnerLicenseSuspendedWeight = mCfgFile.ReadInt32(ECfgSections.ALERTS.ToString(), EAlerts.OwnerLicenseSuspendedWeight.ToString(), cDefaultOwnerLicenseSuspendedWeight);
            OwnerLicenseExpiredWeight   = mCfgFile.ReadInt32(ECfgSections.ALERTS.ToString(), EAlerts.OwnerLicenseExpiredWeight.ToString(), cDefaultOwnerLicenseExpiredWeight);
            UnregisteredVehicleWeight   = mCfgFile.ReadInt32(ECfgSections.ALERTS.ToString(), EAlerts.UnregisteredVehicleWeight.ToString(), cDefaultUnregisteredVehicleWeight);
            RegisrationExpiredWeight    = mCfgFile.ReadInt32(ECfgSections.ALERTS.ToString(), EAlerts.RegisrationExpiredWeight.ToString(), cDefaultRegisrationExpiredWeight);
            NoInsuranceWeight           = mCfgFile.ReadInt32(ECfgSections.ALERTS.ToString(), EAlerts.NoInsuranceWeight.ToString(), cDefaultNoInsuranceWeight);
            InsuranceExpiredWeight      = mCfgFile.ReadInt32(ECfgSections.ALERTS.ToString(), EAlerts.InsuranceExpiredWeight.ToString(), cDefaultInsuranceExpiredWeight);

            AdjustAlertWeights();
        }
コード例 #13
0
        private static unsafe ConfigurationContainer ReadFromIni(InitializationFile initializationFile)
        {
            KeysConverter kc = new KeysConverter();

            Keys forcePursuitKey;
            Keys forcePursuitModifier;
            bool allowInvestigation;

            try
            {
                Extensions.LogTrivial($"Attempting to read ForcePursuit keybinding");
                forcePursuitKey = (Keys)kc.ConvertFromString(initializationFile.ReadString("Keybindings", "ForcePursuit", "T"));
                Extensions.LogTrivial($"Successfully read ForcePursuit key ({forcePursuitKey})");
            }
            catch
            {
                forcePursuitKey = Keys.T;
                var log = $"Pursuit on the Fly: There was an error reading ForcePursuit keybinding from PursuitsOnTheFly.ini, make sure your preferred key is valid. Applying default key ({forcePursuitKey}).";
                Game.DisplayNotification(log);
                Game.LogTrivial(log);
            }

            try
            {
                forcePursuitModifier = (Keys)kc.ConvertFromString(initializationFile.ReadString("Keybindings", "ForcePursuitModifier", "None"));
            }
            catch
            {
                forcePursuitModifier = Keys.None;
                var log = "Pursuit on the Fly: There was an error reading ForcePursuitModifier keybinding from PursuitOnTheFly.ini, make sure your preferred modifier key is valid. Applying no modifier key.";
                Game.DisplayNotification(log);
                Game.LogTrivial(log);
            }

            try
            {
                allowInvestigation = initializationFile.ReadBoolean("General", "AllowInvestigativeMode", true);
            }
            catch
            {
                allowInvestigation = false;
                var log = "Pursuit on the Fly: There was an error reading the AllowInvestigativeMode setting from PursuitOnTheFly.ini, make sure the value is valid.";
                Game.DisplayNotification(log);
                Game.LogTrivial(log);
            }

            return(new ConfigurationContainer(allowInvestigation, forcePursuitKey, forcePursuitModifier));
        }
コード例 #14
0
ファイル: Config.cs プロジェクト: Aebian/PassengerKI
        public static void LoadConfig()
        {
            InitializationFile settings = initialiseFile(Global.Application.ConfigPath + "PassengerKI.ini");

            Logger.DebugLog("General Config Loading Started.");

            Global.Application.DebugLogging = (settings.ReadBoolean("General", "DebugLogging", false));
            KeysConverter KeyCV = new KeysConverter();

            string EnterPassenger, EnterPassengerModifier, EnterPassengerController, EnterPassengerControllerModifier, DriveToMarker, DriveToMarkerModifier, DriveToMarkerController, DriveToMarkerControllerModifier;

            // Fetch settings from file / set default values
            EnterPassenger         = settings.ReadString("Keybinds", "EnterPassenger", "E");
            EnterPassengerModifier = settings.ReadString("Keybinds", "EnterPassengerModifier", "None");

            EnterPassengerController         = settings.ReadString("Keybinds", "EnterPassengerController", "Y");
            EnterPassengerControllerModifier = settings.ReadString("Keybinds", "EnterPassengerControllerModifier", "DPadDown");

            DriveToMarker         = settings.ReadString("Keybinds", "DriveToMarker", "Space");
            DriveToMarkerModifier = settings.ReadString("Keybinds", "DriveToMarkerModifier", "None");

            DriveToMarkerController         = settings.ReadString("Keybinds", "DriveToMarkerController", "X");
            DriveToMarkerControllerModifier = settings.ReadString("Keybinds", "DriveToMarkerControllerModifier", "DPadLeft");

            // Assign Keyboard Buttons to Global Variable
            Global.Controls.EnterPassenger         = (Keys)KeyCV.ConvertFromString(EnterPassenger);
            Global.Controls.EnterPassengerModifier = (Keys)KeyCV.ConvertFromString(EnterPassengerModifier);

            Global.Controls.DriveToMarker         = (Keys)KeyCV.ConvertFromString(DriveToMarker);
            Global.Controls.DriveToMarkerModifier = (Keys)KeyCV.ConvertFromString(DriveToMarkerModifier);

            // Convert Controller Buttons to the right format
            TypeConverter     typeConverter        = TypeDescriptor.GetConverter(Global.Controls.EnterPassengerController); // get type of variable
            ControllerButtons EPController         = (ControllerButtons)typeConverter.ConvertFromString(EnterPassengerController);
            ControllerButtons EPControllerModifier = (ControllerButtons)typeConverter.ConvertFromString(EnterPassengerControllerModifier);

            ControllerButtons DMController         = (ControllerButtons)typeConverter.ConvertFromString(DriveToMarkerController);
            ControllerButtons DMControllerModifier = (ControllerButtons)typeConverter.ConvertFromString(DriveToMarkerControllerModifier);

            // Assign Controller Buttons to Global Variable
            Global.Controls.EnterPassengerController         = EPController;
            Global.Controls.EnterPassengerControllerModifier = EPControllerModifier;

            Global.Controls.DriveToMarkerController         = DMController;
            Global.Controls.DriveToMarkerControllerModifier = DMControllerModifier;

            Logger.DebugLog("General Config Loading Finished.");
        }
コード例 #15
0
        internal bool IsRealisticWeaponOptionEnabled()
        {
            InitializationFile ini = InitialiseFile();

            try
            {
                return(ini.ReadBoolean("GENERAL", "RealisticWeaponDelivery"));
            }
            catch (Exception exception)
            {
                Game.DisplayNotification("LSPDFR Enhancer had a problem reading the Realistic Weapon Option in the INI, defaulting the boolean");
                Game.LogTrivial(exception.ToString());

                return(true);
            }
        }
コード例 #16
0
        /// <summary>
        /// Loads the values from the .ini file, if there are none it gives them default values
        /// </summary>
        internal static void LoadSettings()
        {
            Globals.General.WhistleProbability = IniFile.ReadInt32("General", "WhistleProbability", 30);
            if (Globals.General.WhistleProbability <= 1 || 100 <= Globals.General.WhistleProbability)
            {
                Logging.Log("Incorrect value given for WhistleProbability defaulting to 30!");
                Globals.General.WhistleProbability = 30;
            }
            Globals.Controls.WhistleKey         = IniFile.ReadEnum("Keys", "WhistleKey", Keys.X);
            Globals.Controls.WhistleModifierKey = IniFile.ReadEnum("Keys", "WhistleModifierKey", Keys.LShiftKey);
            Globals.Debug.DebugMode             = IniFile.ReadBoolean("Debug", "DebugMode", false);
            Globals.Radar.IsTrafficStopped      = false;

            if (Globals.Debug.DebugMode)
            {
                Logging.DebugLog($"Settings loaded, values: WhistleProbability = {Globals.General.WhistleProbability}, WhistleKey = {Globals.Controls.WhistleKey}, WhistleModifierKey = {Globals.Controls.WhistleModifierKey}");
            }
        }
コード例 #17
0
ファイル: Main.cs プロジェクト: iPeer/AlfredoRedux
        public override void Initialize()
        {
            Settings                 = new InitializationFile(@"Plugins\LSPDFR\AlfredoRedux.ini");
            WeaponPool               = Settings.ReadString("WEAPONS", "WeaponList", "WEAPON_PISTOL|COMPONENT_AT_PI_FLSH,WEAPON_CARBINERIFLE|COMPONENT_AT_AR_FLSH|COMPONENT_AT_AR_AFGRIP,WEAPON_STUNGUN,WEAPON_PUMPSHOTGUN,WEAPON_FLASHLIGHT,WEAPON_NIGHTSTICK,WEAPON_FIREEXTINGUISHER");
            ApplyOnGoOnDuty          = Settings.ReadBoolean("WEAPONS", "RunWhenGoingOnDuty", true);
            CleanPlayer              = Settings.ReadBoolean("PLAYER", "CleanPlayer", true);
            FillHealth               = Settings.ReadBoolean("PLAYER", "FillHealth", true);
            FillArmour               = Settings.ReadBoolean("PLAYER", "FillArmour", true);
            InfiniteAmmo             = Settings.ReadBoolean("AMMO", "InfiniteAmmo", false);
            RepairVehicle            = Settings.ReadBoolean("VEHICLES", "RepairVehicle", true);
            CleanVehicle             = Settings.ReadBoolean("VEHICLES", "CleanVehicle", false);
            GiveFlashlight           = Settings.ReadBoolean("WEAPONS", "GiveFlashlight", true);
            OnlyRepairPoliceVehicles = Settings.ReadBoolean("VEHICLES", "OnlyRepairPoliceVehicles", true);
            AmmoCount                = Settings.ReadInt16("AMMO", "AmmoCount", 1000);
            KeysConverter kc = new KeysConverter();

            Keybind = (Keys)kc.ConvertFromString(Settings.ReadString("GENERAL", "Keybind", "F7"));

            Functions.OnOnDutyStateChanged += OnOnDutyStateChanged;

            CheckThread = new GameFiber(DoMagicThread);

            Game.DisplayNotification("~g~AlfredoRedux~w~ loaded!");
        }
コード例 #18
0
        internal static void Initalize()
        {
            string pathToFile = "Plugins/LSPDFR/FireyCallouts.ini";
            var    ini        = new InitializationFile(pathToFile);

            ini.Create();

            // Controls
            endKey      = ini.ReadEnum("Controls", "endKey", Keys.Delete);
            dialogueKey = ini.ReadEnum("Controls", "dialogueKey", Keys.Y);

            // Callouts
            burningTruck    = ini.ReadBoolean("Callouts", "burningTruck", true);
            burningGarbage  = ini.ReadBoolean("Callouts", "burningGarbage", true);
            lostFreight     = ini.ReadBoolean("Callouts", "lostFreight", true);
            heliCrash       = ini.ReadBoolean("Callouts", "heliCrash", true);
            planeLanding    = ini.ReadBoolean("Callouts", "planeLanding", true);
            illegalFirework = ini.ReadBoolean("Callouts", "illegalFirework", true);
            structuralFire  = ini.ReadBoolean("Callouts", "structuralFire", true);
            campfire        = ini.ReadBoolean("Callouts", "campfire", true);
            //smokeDetected = ini.ReadBoolean("Callouts", "smokeDetected", false);

            Game.LogTrivial("[FireyCallouts][Init] successfully initialized");
        }
コード例 #19
0
        internal Settings(string generalSettingsFileName, string vehiclesSettingsFileName, string visualSettingsFileName, bool generateDefaultsIfFileNotFound)
        {
            GeneralSettingsFileName  = generalSettingsFileName;
            VehiclesSettingsFileName = vehiclesSettingsFileName;
            VisualSettingsFileName   = visualSettingsFileName;

            if (generateDefaultsIfFileNotFound)
            {
                if (!File.Exists(generalSettingsFileName))
                {
                    Game.LogTrivial($"'{Path.GetFileName(generalSettingsFileName)}' file doesn't exists, creating default...");
                    CreateDefaultGeneralSettingsIniFile(generalSettingsFileName);
                }

                if (!File.Exists(vehiclesSettingsFileName))
                {
                    Game.LogTrivial($"'{Path.GetFileName(vehiclesSettingsFileName)}' file doesn't exists, creating default...");
                    CreateDefaultVehiclesSettingsFile(vehiclesSettingsFileName, true);
                }

                if (!File.Exists(visualSettingsFileName))
                {
                    Game.LogTrivial($"'{Path.GetFileName(visualSettingsFileName)}' file doesn't exists, creating default...");
                    CreateDefaultVisualSettingsXMLFile(visualSettingsFileName);
                }
            }

            Game.LogTrivial("Reading settings...");
            GeneralSettingsIniFile = new InitializationFile(generalSettingsFileName);
            Vehicles = ReadVehiclesSettings(vehiclesSettingsFileName);
            Visual   = ReadVisualSettingsFromXMLFile(visualSettingsFileName);

            EditorKey = GeneralSettingsIniFile.ReadEnum <Keys>("Misc", "EditorKey", Keys.F11);

            EnableTrackingNotifications = GeneralSettingsIniFile.ReadBoolean("Misc", "TrackingNotificationsEnabled", true);
        }
コード例 #20
0
        public static void Initialise()
        {
            //ini stuff

            InitializationFile ini = new InitializationFile("Plugins/LSPDFR/LSPDFR+.ini");

            ini.Create();
            try
            {
                EnhancedTrafficStop.BringUpTrafficStopMenuControllerButton = ini.ReadEnum <ControllerButtons>("General", "BringUpTrafficStopMenuControllerButton", ControllerButtons.DPadRight);
                EnhancedTrafficStop.BringUpTrafficStopMenuKey = (Keys)kc.ConvertFromString(ini.ReadString("General", "BringUpTrafficStopMenuKey", "E"));
                CourtSystem.OpenCourtMenuKey                        = (Keys)kc.ConvertFromString(ini.ReadString("OnlyWithoutBritishPolicingScriptInstalled", "OpenCourtMenuKey", "F9"));
                CourtSystem.OpenCourtMenuModifierKey                = (Keys)kc.ConvertFromString(ini.ReadString("OnlyWithoutBritishPolicingScriptInstalled", "OpenCourtMenuModifierKey", "None"));
                EnhancedTrafficStop.EnhancedTrafficStopsEnabled     = ini.ReadBoolean("General", "EnhancedTrafficStopsEnabled", true);
                EnhancedPursuitAI.EnhancedPursuitAIEnabled          = ini.ReadBoolean("General", "EnhancedPursuitAIEnabled", true);
                EnhancedPursuitAI.AutoPursuitBackupEnabled          = ini.ReadBoolean("General", "AutoPursuitBackupEnabled", false);
                EnhancedPursuitAI.OpenPursuitTacticsMenuKey         = (Keys)kc.ConvertFromString(ini.ReadString("General", "OpenPursuitTacticsMenuKey", "Q"));
                EnhancedPursuitAI.OpenPursuitTacticsMenuModifierKey = (Keys)kc.ConvertFromString(ini.ReadString("General", "OpenPursuitTacticsMenuModifierKey", "LShiftKey"));
                EnhancedPursuitAI.DefaultAutomaticAI                = ini.ReadBoolean("General", "DefaultAutomaticAI", true);

                Offence.maxpoints    = ini.ReadInt32("General", "MaxPoints", 12);
                Offence.pointincstep = ini.ReadInt32("General", "PointsIncrementalStep", 1);
                Offence.maxFine      = ini.ReadInt32("General", "MaxFine", 5000);

                Offence.OpenTicketMenuKey         = (Keys)kc.ConvertFromString(ini.ReadString("General", "OpenTicketMenuKey", "Q"));
                Offence.OpenTicketMenuModifierKey = (Keys)kc.ConvertFromString(ini.ReadString("General", "OpenTicketMenuModifierKey", "LShiftKey"));
                Offence.enablePoints = ini.ReadBoolean("General", "EnablePoints", true);

                CourtSystem.RealisticCourtDates = ini.ReadBoolean("OnlyWithoutBritishPolicingScriptInstalled", "RealisticCourtDates", true);
            }
            catch (Exception e)
            {
                Game.LogTrivial(e.ToString());
                Game.LogTrivial("Error loading LSPDFR+ INI file. Loading defaults");
                Game.DisplayNotification("~r~Error loading LSPDFR+ INI file. Loading defaults");
            }
            BetaCheck();
        }
コード例 #21
0
        private static bool IsAutoDoorEnabled()
        {
            InitializationFile ini = InitializeFile();

            return(ini.ReadBoolean("General", "AutoDoorShutEnabled", true));
        }
コード例 #22
0
ファイル: Configs.cs プロジェクト: piergud/DashcamV
        public static void RunConfigCheck()
        {
            InitializationFile iniFile = new InitializationFile(@"Plugins\DashcamV.ini");

            if (!iniFile.Exists())
            {
                iniFile.Create();
                iniFile.Write("SETTINGS", "EnableFilter", false);
                iniFile.Write("SETTINGS", "EnableRemoteView", true);
                iniFile.Write("SETTINGS", "EnableDashcamOnAllViews", false);
                iniFile.Write("SETTINGS", "LayoutStyle", 0);
                iniFile.Write("SETTINGS", "MeasurementSystem", 1);
                iniFile.Write("SETTINGS", "DateFormat", 0);
                iniFile.Write("SETTINGS", "UnitName", "");
                iniFile.Write("CONTROLS", "RemoteViewToggleKey", Keys.E);
                iniFile.Write("CONTROLS", "RemoteViewToggleGamepad", ControllerButtons.LeftThumb);
            }

            Filter            = iniFile.ReadBoolean("SETTINGS", "EnableFilter");
            DashTextOnPOVOnly = iniFile.ReadBoolean("SETTINGS", "EnableDashcamOnAllViews");
            Layout            = iniFile.ReadEnum <LayoutType>("SETTINGS", "LayoutStyle", 0);
            System            = iniFile.ReadEnum <MeasurementType>("SETTINGS", "MeasurementSystem", 0);
            DateFormat        = iniFile.ReadString("SETTINGS", "DateFormat");
            Unit = iniFile.ReadString("SETTINGS", "UnitName");

            _remKeys.Key    = iniFile.ReadEnum <Keys>("CONTROLS", "RemoteViewToggleKey", Keys.E);
            _remBtns.Button = iniFile.ReadEnum <ControllerButtons>("CONTROLS", "RemoteViewToggleGamepad", ControllerButtons.LeftThumb);

            if (!iniFile.ReadBoolean("SETTINGS", "EnableRemoteView", true))
            {
                _remKeys.Key    = Keys.None;
                _remBtns.Button = ControllerButtons.None;
            }

            var sections = iniFile.GetSectionNames();

            foreach (var section in sections)
            {
                if (section.Substring(0, 4).ToLower() == "veh:")
                {
                    var vehName = section.Substring(4).ToLower();

                    var depName  = iniFile.ReadString(section, "Department");
                    var depShort = iniFile.ReadString(section, "Acronym");

                    var arrColour = iniFile.ReadString(section, "Colour").Split(',');
                    var colour    = Color.FromArgb(255, int.Parse(arrColour[0]), int.Parse(arrColour[1]), int.Parse(arrColour[2]));

                    var arrOffset = iniFile.ReadString(section, "Offset").Split(',');
                }
            }
            confVehs = temp.ToArray();

            List <String> temp_confDepName  = new List <String>();
            List <String> temp_confDepAbrv  = new List <String>();
            List <String> temp_confDepNameR = new List <String>();
            List <String> temp_confDepNameG = new List <String>();
            List <String> temp_confDepNameB = new List <String>();
            List <String> temp_confOffset   = new List <String>();

            for (int i = 0; i < confVehs.Length; i++)
            {
                temp_confDepName.Add(iniFile.ReadString("Veh:" + confVehs[i], "Department", "Generic Department"));
                temp_confDepAbrv.Add(iniFile.ReadString("Veh:" + confVehs[i], "Acronym", "GD"));
                String[] rgb = iniFile.ReadString("Veh:" + confVehs[i], "Colour", "255,255,255").Split(',');
                temp_confDepNameR.Add(rgb[0]);
                temp_confDepNameG.Add(rgb[1]);
                temp_confDepNameB.Add(rgb[2]);
                temp_confOffset.Add(iniFile.ReadString("Veh:" + confVehs[i], "Offset", "0,0.75,0.65"));
            }
            confDepName  = temp_confDepName.ToArray();
            confDepAbrv  = temp_confDepAbrv.ToArray();
            confDepNameR = temp_confDepNameR.ToArray();
            confDepNameG = temp_confDepNameG.ToArray();
            confDepNameB = temp_confDepNameB.ToArray();
            confOffset   = temp_confOffset.ToArray();
        }
コード例 #23
0
ファイル: Main.cs プロジェクト: waynieoaks/RecovFR
        private static void LoadValuesFromIniFile()
        {
            // string path = "Plugins\\RecovFR.ini";
            InitializationFile ini = new InitializationFile(INIpath);

            ini.Create();

            try
            {
                if (ini.DoesKeyExist("Keybindings", "BackupKey"))
                {
                    BackupKey = ini.ReadEnum <Keys>("Keybindings", "BackupKey", Keys.F12);
                }
                else
                {
                    ini.Write("Keybindings", "BackupKey", "F12");
                    BackupKey = Keys.F12;
                }

                if (ini.DoesKeyExist("Keybindings", "BackupModifierKey"))
                {
                    BackupModifierKey = ini.ReadEnum <Keys>("Keybindings", "BackupModifierKey", Keys.ControlKey);
                }
                else
                {
                    ini.Write("Keybindings", "BackupModifierKey", "ControlKey");
                    BackupModifierKey = Keys.ControlKey;
                }

                if (ini.DoesKeyExist("Keybindings", "RestoreKey"))
                {
                    RestoreKey = ini.ReadEnum <Keys>("Keybindings", "RestoreKey", Keys.F12);
                }
                else
                {
                    ini.Write("Keybindings", "RestoreKey", "F12");
                    RestoreKey = Keys.F12;
                }

                if (ini.DoesKeyExist("Keybindings", "RestoreModifierKey"))
                {
                    RestoreModifierKey = ini.ReadEnum <Keys>("Keybindings", "RestoreModifierKey", Keys.Menu);
                }
                else
                {
                    ini.Write("Keybindings", "RestoreModifierKey", "ControlKey");
                    RestoreModifierKey = Keys.Menu;
                }

                if (ini.DoesKeyExist("Keybindings", "MenuKey"))
                {
                    MenuKey = ini.ReadEnum <Keys>("Keybindings", "MenuKey", Keys.F11);
                }
                else
                {
                    ini.Write("Keybindings", "MenuKey", "F11");
                    MenuKey = Keys.F11;
                }

                if (ini.DoesKeyExist("Keybindings", "MenuModifierKey"))
                {
                    MenuModifierKey = ini.ReadEnum <Keys>("Keybindings", "MenuModifierKey", Keys.None);
                }
                else
                {
                    ini.Write("Keybindings", "MenuModifierKey", "None");
                    MenuModifierKey = Keys.None;
                }

                if (ini.DoesKeyExist("Features", "AutoBackups"))
                {
                    AutoBackups = ini.ReadBoolean("Features", "AutoBackups", false);
                }
                else
                {
                    ini.Write("Features", "AutoBackups", "false");
                    AutoBackups = false;
                }

                if (ini.DoesKeyExist("Features", "AutoBackupInt"))
                {
                    AutoBackupInt = ini.ReadByte("Features", "AutoBackupInt", 60);
                }
                else
                {
                    ini.Write("Features", "AutoBackupInt", "60");
                    AutoBackupInt = 60;
                }

                if (ini.DoesKeyExist("Features", "ShowNotifications"))
                {
                    ShowNotifications = ini.ReadBoolean("Features", "ShowNotifications", false);
                }
                else
                {
                    ini.Write("Features", "ShowNotifications", "false");
                    ShowNotifications = false;
                }

                if (ini.DoesKeyExist("RestoreOptions", "PlayerGodMode"))
                {
                    PlayerGodMode = ini.ReadBoolean("RestoreOptions", "PlayerGodMode", false);
                }
                else
                {
                    ini.Write("RestoreOptions", "PlayerGodMode", "False");
                    PlayerGodMode = false;
                }

                if (ini.DoesKeyExist("RestoreOptions", "VehicleGodMode"))
                {
                    VehicleGodMode = ini.ReadBoolean("RestoreOptions", "VehicleGodMode", false);
                }
                else
                {
                    ini.Write("RestoreOptions", "VehicleGodMode", "false");
                    VehicleGodMode = false;
                }

                if (ini.DoesKeyExist("RestoreOptions", "FreezeWeather"))
                {
                    FreezeWeather = ini.ReadBoolean("RestoreOptions", "FreezeWeather", false);
                }
                else
                {
                    ini.Write("RestoreOptions", "FreezeWeather", "false");
                    FreezeWeather = false;
                }

                if (ini.DoesKeyExist("RestoreOptions", "SnowOnGround"))
                {
                    SnowOnGround = ini.ReadBoolean("RestoreOptions", "SnowOnGround", false);
                }
                else
                {
                    ini.Write("RestoreOptions", "SnowOnGround", "false");
                    SnowOnGround = false;
                }

                if (ini.DoesKeyExist("RestoreOptions", "FreezeTime"))
                {
                    FreezeTime = ini.ReadBoolean("RestoreOptions", "FreezeTime", false);
                }
                else
                {
                    ini.Write("RestoreOptions", "FreezeTime", "false");
                    FreezeTime = false;
                }
                Game.LogTrivial("Settings initialisation complete.");
            }
            catch (Exception e)
            {
                ErrorLogger(e, "Initialisation", "Unable to read INI file.");
            }
        }
コード例 #24
0
        public void ReadLegacy(string iniFile)
        {
            IsLegacy = true;

            InitializationFile ini = new InitializationFile(iniFile);

            Data = new Dictionary <string, VehicleData>();

            string[] sections = ini.GetSectionNames();
            if (sections != null)
            {
                foreach (string modelName in sections)
                {
                    float x = VehicleData.DefaultOffsetX, y = VehicleData.DefaultOffsetY, z = VehicleData.DefaultOffsetZ;
                    bool  disableTurret       = VehicleData.DefaultDisableTurret;
                    int   spotlightExtraLight = VehicleData.DefaultSpotlightExtraLight;

                    bool             success = false;
                    System.Exception exc     = null;
                    try
                    {
                        if (ini.DoesKeyExist(modelName, VehicleData.IniKeyX) &&
                            ini.DoesKeyExist(modelName, VehicleData.IniKeyY) &&
                            ini.DoesKeyExist(modelName, VehicleData.IniKeyZ))
                        {
                            x = ini.ReadSingle(modelName, VehicleData.IniKeyX, VehicleData.DefaultOffsetX);
                            y = ini.ReadSingle(modelName, VehicleData.IniKeyY, VehicleData.DefaultOffsetY);
                            z = ini.ReadSingle(modelName, VehicleData.IniKeyZ, VehicleData.DefaultOffsetZ);
                            if (ini.DoesKeyExist(modelName, VehicleData.IniKeyDisableTurret))
                            {
                                disableTurret = ini.ReadBoolean(modelName, VehicleData.IniKeyDisableTurret, VehicleData.DefaultDisableTurret);
                            }
                            if (ini.DoesKeyExist(modelName, VehicleData.IniKeySpotlightExtraLight))
                            {
                                spotlightExtraLight = ini.ReadInt32(modelName, VehicleData.IniKeySpotlightExtraLight, VehicleData.DefaultSpotlightExtraLight);
                                if (spotlightExtraLight <= VehicleData.DefaultSpotlightExtraLight || spotlightExtraLight > 4) // there's only four possible extralight_* bones
                                {
                                    spotlightExtraLight = VehicleData.DefaultSpotlightExtraLight;
                                }
                            }

                            success = true;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        exc = ex;
                    }

                    if (!success)
                    {
                        if (exc != null)
                        {
                            Game.LogTrivial($"  <WARNING> Failed to load spotlight offset position settings for vehicle model: {modelName}");
                            Game.LogTrivial($"  <WARNING> {exc}");
                        }

                        x                   = VehicleData.DefaultOffsetX;
                        y                   = VehicleData.DefaultOffsetY;
                        z                   = VehicleData.DefaultOffsetZ;
                        disableTurret       = VehicleData.DefaultDisableTurret;
                        spotlightExtraLight = VehicleData.DefaultSpotlightExtraLight;
                    }

                    Data.Add(modelName, new VehicleData(new XYZ(x, y, z), disableTurret, spotlightExtraLight));
                }
            }
        }
コード例 #25
0
        public static void Initialise()
        {
            //ini stuff

            InitializationFile ini = new InitializationFile("Plugins/LSPDFR/LSPDFR+.ini");

            ini.Create();
            try
            {
                EnhancedTrafficStop.BringUpTrafficStopMenuControllerButton = ini.ReadEnum <ControllerButtons>("General", "BringUpTrafficStopMenuControllerButton", ControllerButtons.DPadRight);
                EnhancedTrafficStop.BringUpTrafficStopMenuKey = (Keys)kc.ConvertFromString(ini.ReadString("General", "BringUpTrafficStopMenuKey", "D7"));

                try
                {
                    stockLSPDFRIni = new InitializationFile(LSPDFRKeyIniPath);
                    string[] stockinicontents = File.ReadAllLines(LSPDFRKeyIniPath);
                    //Alternative INI reading implementation, RPH doesn't work with sectionless INIs.
                    foreach (string line in stockinicontents)
                    {
                        if (line.StartsWith("TRAFFICSTOP_INTERACT_Key="))
                        {
                            stockTrafficStopInteractKey = (Keys)kc.ConvertFromString(line.Substring(line.IndexOf('=') + 1));
                        }
                        else if (line.StartsWith("TRAFFICSTOP_INTERACT_ModifierKey"))
                        {
                            stockTrafficStopInteractModifierKey = (Keys)kc.ConvertFromString(line.Substring(line.IndexOf('=') + 1));
                        }
                        else if (line.StartsWith("TRAFFICSTOP_INTERACT_ControllerKey"))
                        {
                            stockTrafficStopInteractControllerButton = (ControllerButtons)Enum.Parse(typeof(ControllerButtons), line.Substring(line.IndexOf('=') + 1));
                        }
                        else if (line.StartsWith("TRAFFICSTOP_INTERACT_ControllerModifierKey"))
                        {
                            stockTrafficStopInteractModifierControllerButton = (ControllerButtons)Enum.Parse(typeof(ControllerButtons), line.Substring(line.IndexOf('=') + 1));
                        }
                    }
                    if ((EnhancedTrafficStop.BringUpTrafficStopMenuKey == stockTrafficStopInteractKey && stockTrafficStopInteractModifierKey == Keys.None) || (EnhancedTrafficStop.BringUpTrafficStopMenuControllerButton == stockTrafficStopInteractControllerButton && stockTrafficStopInteractModifierControllerButton == ControllerButtons.None))
                    {
                        TrafficStopMenuPopup = new Popup("LSPDFR+: Traffic Stop Menu Conflict", "Your LSPDFR+ traffic stop menu keys (plugins/lspdfr/lspdfr+.ini) are the same as the default LSPDFR traffic stop keys (lspdfr/keys.ini TRAFFICSTOP_INTERACT_Key and TRAFFICSTOP_INTERACT_ControllerKey). How would you like to solve this?",
                                                         new List <string>()
                        {
                            "Recommended: Automatically disable the default LSPDFR traffic stop menu keys (this will edit keys.ini TRAFFICSTOP_INTERACT_Key and TRAFFICSTOP_INTERACT_ControllerKey to None)", "I know what I'm doing, I will change the keys in the INIs myself!"
                        }, false, true, TrafficStopMenuCb);
                        TrafficStopMenuPopup.Display();
                    }
                }
                catch (Exception e)
                {
                    Game.LogTrivial($"Failed to determine stock LSPDFR key bind/controller button for traffic stop keys: {e}");
                }

                CourtSystem.OpenCourtMenuKey                        = (Keys)kc.ConvertFromString(ini.ReadString("OnlyWithoutBritishPolicingScriptInstalled", "OpenCourtMenuKey", "F9"));
                CourtSystem.OpenCourtMenuModifierKey                = (Keys)kc.ConvertFromString(ini.ReadString("OnlyWithoutBritishPolicingScriptInstalled", "OpenCourtMenuModifierKey", "None"));
                EnhancedTrafficStop.EnhancedTrafficStopsEnabled     = ini.ReadBoolean("General", "EnhancedTrafficStopsEnabled", true);
                EnhancedPursuitAI.EnhancedPursuitAIEnabled          = ini.ReadBoolean("General", "EnhancedPursuitAIEnabled", true);
                EnhancedPursuitAI.AutoPursuitBackupEnabled          = ini.ReadBoolean("General", "AutoPursuitBackupEnabled", false);
                EnhancedPursuitAI.OpenPursuitTacticsMenuKey         = (Keys)kc.ConvertFromString(ini.ReadString("General", "OpenPursuitTacticsMenuKey", "Q"));
                EnhancedPursuitAI.OpenPursuitTacticsMenuModifierKey = (Keys)kc.ConvertFromString(ini.ReadString("General", "OpenPursuitTacticsMenuModifierKey", "LShiftKey"));
                EnhancedPursuitAI.DefaultAutomaticAI                = ini.ReadBoolean("General", "DefaultAutomaticAI", true);

                Offence.maxpoints    = ini.ReadInt32("General", "MaxPoints", 12);
                Offence.pointincstep = ini.ReadInt32("General", "PointsIncrementalStep", 1);
                Offence.maxFine      = ini.ReadInt32("General", "MaxFine", 5000);

                Offence.OpenTicketMenuKey         = (Keys)kc.ConvertFromString(ini.ReadString("General", "OpenTicketMenuKey", "Q"));
                Offence.OpenTicketMenuModifierKey = (Keys)kc.ConvertFromString(ini.ReadString("General", "OpenTicketMenuModifierKey", "LShiftKey"));
                Offence.enablePoints = ini.ReadBoolean("General", "EnablePoints", true);

                CourtSystem.RealisticCourtDates = ini.ReadBoolean("OnlyWithoutBritishPolicingScriptInstalled", "RealisticCourtDates", true);
            }
            catch (Exception e)
            {
                Game.LogTrivial(e.ToString());
                Game.LogTrivial("Error loading LSPDFR+ INI file. Loading defaults");
                Game.DisplayNotification("~r~Error loading LSPDFR+ INI file. Loading defaults");
            }
            BetaCheck();
        }
コード例 #26
0
 public static void Main()
 {
     Log("Loading...");
     Game.TerminateAllScripts("selector");
     (new FileInfo(ini)).Directory.Create();
     cfg = new InitializationFile(ini);
     if (!File.Exists(ini))
     {
         Log($"File {ini} doesn't exist, creating new one.");
         cfg.Write("General", "debug", "false");
         cfg.Write("General", "addBlipsOnStartup", "true");
         cfg.Write("General", "revealMapOnStartup", "false");
         cfg.Write("General", "customBlipsXML", $"{folder}customBlips.xml");
     }
     else
     {
         if (!cfg.DoesKeyExist("General", "debug"))
         {
             cfg.Write("General", "debug", "false");
         }
         if (!cfg.DoesKeyExist("General", "addBlipsOnStartup"))
         {
             cfg.Write("General", "addBlipsOnStartup", "true");
         }
         if (!cfg.DoesKeyExist("General", "revealMapOnStartup"))
         {
             cfg.Write("General", "revealMapOnStartup", "false");
         }
         if (cfg.ReadString("General", "customBlipsXML", "") == "")
         {
             cfg.Write("General", "customBlipsXML", $"{folder}customBlips.xml");
         }
     }
     if (cfg.ReadBoolean("General", "revealMapOnStartup", false))
     {
         Log("revealMapOnStartup set, revealing map...");
     }
     Game.IsFullMapRevealForced = true;
     file = cfg.ReadString("General", "customBlipsXML");
     if (bool.Parse(cfg.ReadString("General", "addBlipsOnStartUP")))
     {
         DirectoryInfo d = new DirectoryInfo(folder);
         foreach (var file in d.GetFiles("*.xml"))
         {
             try
             {
                 XDocument xDocument = XDocument.Load(file.FullName);
                 XElement  root      = xDocument.Element("CustomBlips");
                 foreach (XElement el in root.Descendants())
                 {
                     var blip = XmlToBlip(el);
                     Log($"Added new Blip {blip.Name} from {file.Name} at {blip.Position.X},{blip.Position.Y},{blip.Position.Z}", true);
                 }
                 Log($"Added all Blips from {file.Name}");
             }
             catch
             {
                 Log($"Cannot load {file.FullName}\nMake sure it exists and check it's validaty with http://codebeautify.org/xmlvalidator");
             }
         }
     }
     Log("Loaded successfully.");
     GameFiber.Hibernate();
 }
コード例 #27
0
        public static Dictionary <string, object> GetIniValues()
        {
            Game.LogTrivial("Loading Configuration...");
            Dictionary <string, object> iniValues = new Dictionary <string, object> {
            };
            InitializationFile ini = InitializeFile();

            string[]    acceptedWeaponStrings = ini.ReadString("Main", "AcceptedWeapons", "WEAPON_CARBINERIFLE_MK2,WEAPON_SMG").Split(',');
            List <uint> acceptedWeaponHashes  = new List <uint> {
            };

            foreach (var acceptedWeapon in acceptedWeaponStrings)
            {
                try
                {
                    acceptedWeaponHashes.Add(Game.GetHashKey(acceptedWeapon.Trim(' ')));
                }
                catch
                {
                    Game.LogTrivial($"{acceptedWeapon} is not a valid weapon");
                }
            }
            iniValues.Add("AcceptedWeapons", acceptedWeaponHashes);

            Vector3 offsetPosition = ini.ReadVector3("Main", "OffsetPosition", new Vector3(0.0f, -0.19f, -0.02f));

            iniValues.Add("OffsetPosition", offsetPosition);

            Rotator Rotation = ini.ReadRotator("Main", "Rotation", new Rotator(0.0f, 165f, 0.0f));

            iniValues.Add("Rotation", Rotation);

            bool hideWhileInVehicle = ini.ReadBoolean("Main", "HideWhileInVehicle", true);

            iniValues.Add("HideWhileInVehicle", hideWhileInVehicle);

            bool disableFlashlight = ini.ReadBoolean("Main", "DisableFlashlight", false);

            iniValues.Add("DisableFlashlight", disableFlashlight);

            string deleteWeaponKeyString = ini.ReadString("Main", "DeleteWeaponKey", "Decimal");
            Keys   deleteWeaponKey       = (Keys)Enum.Parse(typeof(Keys), deleteWeaponKeyString);

            iniValues.Add("DeleteWeaponKey", deleteWeaponKey);

            bool enableAI = ini.ReadBoolean("AI", "EnableAI", false);

            iniValues.Add("EnableAI", enableAI);

            bool copsOnly = ini.ReadBoolean("AI", "CopsOnly", true);

            iniValues.Add("CopsOnly", copsOnly);

            string[]    aiAcceptedWeaponStrings = ini.ReadString("AI", "AcceptedWeapons", "WEAPON_CARBINERIFLE_MK2,WEAPON_SMG").Split(',');
            List <uint> aiAcceptedWeaponHashes  = new List <uint> {
            };

            foreach (var acceptedWeapon in aiAcceptedWeaponStrings)
            {
                try
                {
                    aiAcceptedWeaponHashes.Add(Game.GetHashKey(acceptedWeapon.Trim(' ')));
                }
                catch
                {
                    Game.LogTrivial($"{acceptedWeapon} is not a valid weapon");
                }
            }
            iniValues.Add("AIAcceptedWeapons", aiAcceptedWeaponHashes);

            Vector3 aiOffsetPosition = ini.ReadVector3("AI", "OffsetPosition", new Vector3(0.0f, -0.19f, -0.02f));

            iniValues.Add("AIOffsetPosition", aiOffsetPosition);

            Rotator aiRotation = ini.ReadRotator("AI", "Rotation", new Rotator(0.0f, 165f, 0.0f));

            iniValues.Add("AIRotation", aiRotation);

            bool aiHideWhileInVehicle = ini.ReadBoolean("AI", "HideWhileInVehicle", true);

            iniValues.Add("AIHideWhileInVehicle", aiHideWhileInVehicle);

            bool enableBestWeapon = ini.ReadBoolean("AI", "EnableBestWeapon");

            iniValues.Add("EnableBestWeapon", enableBestWeapon);

            string config = null;

            foreach (string key in iniValues.Keys.ToArray <string>())
            {
                config += $"{key}: {iniValues[key]}; ";
            }

            Game.LogTrivial($"Loaded configuration: {config}");

            return(iniValues);
        }
コード例 #28
0
ファイル: Main.cs プロジェクト: waynieoaks/ELS-Cinematic
        private static void LoadValuesFromIniFile()
        {
            InitializationFile ini = new InitializationFile(INIpath);

            ini.Create();

            try
            {
                //Keyboard ini

                if (ini.DoesKeyExist("Keyboard", "CinematicKey"))
                {
                    CinematicKey = ini.ReadEnum <Keys>("Keyboard", "CinematicKey", Keys.R);
                }
                else
                {
                    ini.Write("Keyboard", "CinematicKey", "R");
                    CinematicKey = Keys.R;
                }

                if (ini.DoesKeyExist("Keyboard", "CinematicModifierKey"))
                {
                    CinematicModifierKey = ini.ReadEnum <Keys>("Keyboard", "CinematicModifierKey", Keys.ControlKey);
                }
                else
                {
                    ini.Write("Keyboard", "CinematicModifierKey", "ControlKey");
                    CinematicModifierKey = Keys.ControlKey;
                }

                // Controller ini

                if (ini.DoesKeyExist("Controller", "CinematicButton"))
                {
                    CinematicButton = ini.ReadEnum <ControllerButtons>("Controller", "CinematicButton", ControllerButtons.None);
                }
                else
                {
                    ini.Write("Controller", "CinematicButton", "None");
                    CinematicButton = ControllerButtons.None;
                }

                if (ini.DoesKeyExist("Controller", "CinematicModifierButton"))
                {
                    CinematicModifierButton = ini.ReadEnum <ControllerButtons>("Controller", "CinematicModifierButton", ControllerButtons.None);
                }
                else
                {
                    ini.Write("Controller", "CinematicModifierButton", "None");
                    CinematicModifierButton = ControllerButtons.None;
                }

                // Other ini

                if (ini.DoesKeyExist("Other", "ShowDebug"))
                {
                    ShowDebug = ini.ReadBoolean("Other", "ShowDebug", false);
                }
                else
                {
                    ini.Write("Other", "ShowDebug", "false");
                    ShowDebug = false;
                }

                Game.LogTrivial("Settings initialisation complete.");
            }
            catch (Exception e)
            {
                ErrorLogger(e, "Initialisation", "Unable to read INI file.");
            }
        }
コード例 #29
0
        internal static void LoadSettings()
        {
            Game.LogTrivial("Loading Config file from UnitedCallouts by sEbi3");
            var path = "Plugins/LSPDFR/UnitedCallouts.ini";
            var ini  = new InitializationFile(path);

            ini.Create();
            Burglary                = ini.ReadBoolean("Settings", "Burglary", true);
            ArrestWarrant           = ini.ReadBoolean("Settings", "ArrestWarrant", true);
            RobberyHL               = ini.ReadBoolean("Settings", "RobberyHL", true);
            StolenEmergencyVehicle  = ini.ReadBoolean("Settings", "StolenEmergencyVehicle", true);
            StolenEmergencyVehicle2 = ini.ReadBoolean("Settings", "StolenEmergencyVehicle2", true);
            DrugDealer              = ini.ReadBoolean("Settings", "DrugDealer", true);
            DrugDeal                = ini.ReadBoolean("Settings", "DrugDeal", true);
            KillerClownWasSeen      = ini.ReadBoolean("Settings", "KillerClownWasSeen", true);
            Fighting                = ini.ReadBoolean("Settings", "Fighting", true);
            PersonWithKnife         = ini.ReadBoolean("Settings", "PersonWithKnife", true);
            StolenBus               = ini.ReadBoolean("Settings", "StolenBus", true);
            StolenTruck             = ini.ReadBoolean("Settings", "StolenTruck", true);
            MoneyTruckIsRobbed      = ini.ReadBoolean("Settings", "MoneyTruckIsRobbed", true);
            troublemaker            = ini.ReadBoolean("Settings", "troublemaker", true);
            CarTrade                = ini.ReadBoolean("Settings", "CarTrade", true);
            ArmoredPerson           = ini.ReadBoolean("Settings", "ArmoredPerson", true);
            ShotsFired              = ini.ReadBoolean("Settings", "ShotsFired", true);
            Bicycle       = ini.ReadBoolean("Settings", "Bicycle", true);
            WelfareCheck  = ini.ReadBoolean("Settings", "WelfareCheck", true);
            K9Backup      = ini.ReadBoolean("Settings", "K9Backup", true);
            store         = ini.ReadBoolean("Settings", "store", true);
            TrafficBackup = ini.ReadBoolean("Settings", "TrafficBackup", true);
            Hostages      = ini.ReadBoolean("Settings", "Hostages", true);
            EndCall       = ini.ReadEnum("Keys", "EndCall", Keys.End);
            Dialog        = ini.ReadEnum("Keys", "Dialog", Keys.Y);
        }