Exemple #1
0
            private HeliCamOffsetsDictionary()
            {
                if (!File.Exists(IniFileName))
                {
                    Game.LogTrivial($"The .ini file '{IniFileName}' doesn't exist, creating default...");
                    CreateDefault();
                }

                internalDictionary = new Dictionary <Model, Vector3>();

                InitializationFile iniFile = new InitializationFile(IniFileName);

                foreach (string section in iniFile.GetSectionNames())
                {
                    float x = 0.0f, y = 0.0f, z = 0.0f;

                    bool             success = false;
                    System.Exception exc = null;
                    try
                    {
                        if (iniFile.DoesSectionExist(section))
                        {
                            if (iniFile.DoesKeyExist(section, "X") &&
                                iniFile.DoesKeyExist(section, "Y") &&
                                iniFile.DoesKeyExist(section, "Z"))
                            {
                                x = iniFile.ReadSingle(section, "X", -0.8f);
                                y = iniFile.ReadSingle(section, "Y", 1.17f);
                                z = iniFile.ReadSingle(section, "Z", 0.52f);

                                Game.LogTrivial($"HeliCam - Offset found and loaded for vehicle model: {section}");
                                success = true;
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        exc = ex;
                    }

                    if (!success)
                    {
                        Game.LogTrivial($"  <WARNING> HeliCam - Failed to load offset for vehicle model: {section}");
                        if (exc != null)
                        {
                            Game.LogTrivial($"  <WARNING> {exc}");
                        }
                        Game.LogTrivial("       Using default settings");
                        x = DefaultOffset.X;
                        y = DefaultOffset.Y;
                        z = DefaultOffset.Z;
                    }

                    internalDictionary.Add(section, new Vector3(x, y, z));
                }
            }
Exemple #2
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 = 0.0f, y = 0.0f, z = 0.0f;

                    bool             success = false;
                    System.Exception exc = null;
                    try
                    {
                        if (ini.DoesSectionExist(modelName))
                        {
                            if (ini.DoesKeyExist(modelName, "X") &&
                                ini.DoesKeyExist(modelName, "Y") &&
                                ini.DoesKeyExist(modelName, "Z"))
                            {
                                x = ini.ReadSingle(modelName, "X", -0.8f);
                                y = ini.ReadSingle(modelName, "Y", 1.17f);
                                z = ini.ReadSingle(modelName, "Z", 0.52f);

                                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;
                    }

                    Data.Add(modelName, new VehicleData(new XYZ(x, y, z)));
                }
            }
        }
Exemple #3
0
        private Dictionary <string, Vector3> ReadSpotlightOffsets(InitializationFile iniFile)
        {
            Game.LogTrivial("Loading spotlight offsets...");

            Dictionary <string, Vector3> dict = new Dictionary <string, Vector3>();

            foreach (string modelName in iniFile.GetSectionNames())
            {
                float x = 0.0f, y = 0.0f, z = 0.0f;

                bool             success = false;
                System.Exception exc = null;
                try
                {
                    if (iniFile.DoesSectionExist(modelName))
                    {
                        if (iniFile.DoesKeyExist(modelName, "X") &&
                            iniFile.DoesKeyExist(modelName, "Y") &&
                            iniFile.DoesKeyExist(modelName, "Z"))
                        {
                            x = iniFile.ReadSingle(modelName, "X", -0.8f);
                            y = iniFile.ReadSingle(modelName, "Y", 1.17f);
                            z = iniFile.ReadSingle(modelName, "Z", 0.52f);

                            Game.LogTrivial($"  Spotlight offset position settings found and loaded for vehicle model: {modelName}");
                            success = true;
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    exc = ex;
                }

                if (!success)
                {
                    Game.LogTrivial($"  <WARNING> Failed to load spotlight offset position settings for vehicle model: {modelName}");
                    if (exc != null)
                    {
                        Game.LogTrivial($"  <WARNING> {exc}");
                    }
                    Game.LogTrivial("       Using default settings");
                    x = -0.8f;
                    y = 1.17f;
                    z = 0.52f;
                }

                dict.Add(modelName, new Vector3(x, y, z));
            }

            Game.LogTrivial("Finished loading spotlight offsets");
            return(dict);
        }
Exemple #4
0
        private static void ParseKeybindings()
        {
            if (!ini_file.DoesSectionExist("KEYBINDINGS"))
            {
                Game.DisplayHelp("Your ComputerPlus.ini file is missing the KEYBINDINGS section. Please verify your config");
                Function.Log("Your Computer+ config file is missing the KEYBINDINGS section. Please verify your config");
                OpenComputerPlusKeys.Add(new KeyBinder(GameControl.Context));
            }
            else
            {
                ParseKeybindings(OpenComputerPlusKeys, "OpenComputerPlus");
                ParseKeybindings(CloseComputerPlusKeys, "CloseComputerPlus");
                ParseKeybindings(OpenSimpleNotepadKeys, "OpenSimpleNotepad");
                ParseKeybindings(GiveCitationsToPedKeys, "GiveCitationsToPed");

                if (OpenComputerPlusKeys.Count == 0) //Fail safe for opening computer by holding the context secondary (E / DPadRight)
                {
                    OpenComputerPlusKeys.Add(new KeyBinder(GameControl.Context));
                }
            }
        }