Пример #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));
                }
            }
Пример #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)));
                }
            }
        }
Пример #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);
        }
Пример #4
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));
                }
            }
        }
Пример #5
0
        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();
        }