Ejemplo n.º 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));
                }
            }
Ejemplo n.º 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)));
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        private static void CalculateDistanceOfSceneManagement()
        {
            InitializationFile ini = InitializeFile();

            SceneManagementSpawnDistance = ini.ReadSingle("Misc", "SceneManagementSpawnDistance", 70f);
            if (SceneManagementSpawnDistance < 50f)
            {
                SceneManagementSpawnDistance = 50f;
            }
            else if (SceneManagementSpawnDistance > 250f)
            {
                SceneManagementSpawnDistance = 250f;
            }
        }
Ejemplo n.º 5
0
        private static void SetupBackgroundSettings()
        {
            RadioBackgroundTexture       = Game.CreateTextureFromFile(PathModifier + "Background" + DisplayExtension);
            MasterScalingFactor          = DisplayIni.ReadSingle("DisplayConfig", "DisplayScalingFactor", 1.0f);
            RadioBackgroundTextureWidth  = RadioBackgroundTexture.Size.Width * MasterScalingFactor;
            RadioBackgroundTextureHeight = RadioBackgroundTexture.Size.Height * MasterScalingFactor;

            UIPositions Position = DisplayIni.ReadEnum <UIPositions>("DisplayConfig", "DisplayPosition", UIPositions.BottomRight);

            if (!string.IsNullOrWhiteSpace(DisplayIni.ReadString("DisplaySpecificPositioning", "X", "")) && !string.IsNullOrWhiteSpace(DisplayIni.ReadString("DisplaySpecificPositioning", "Y", "")))
            {
                BaseX = DisplayIni.ReadInt32("DisplaySpecificPositioning", "X");
                BaseY = DisplayIni.ReadInt32("DisplaySpecificPositioning", "Y");
                Game.LogTrivial("Setting Display position to specifics: " + BaseX + ":" + BaseY);
            }
            else
            {
                switch (Position)
                {
                case UIPositions.BottomRight:
                    BaseX = Game.Resolution.Width - (Int32)RadioBackgroundTextureWidth;
                    BaseY = Game.Resolution.Height - (Int32)RadioBackgroundTextureHeight;
                    break;

                case UIPositions.BottomLeft:
                    BaseX = 0;
                    BaseY = Game.Resolution.Height - (Int32)RadioBackgroundTextureHeight;
                    break;

                case UIPositions.TopLeft:
                    BaseX = 0;
                    BaseY = 0;
                    break;

                case UIPositions.TopRight:
                    BaseX = Game.Resolution.Width - (Int32)RadioBackgroundTextureWidth;
                    BaseY = 0;
                    break;

                case UIPositions.CentreLeft:
                    BaseX = 0;
                    BaseY = Game.Resolution.Height / 2 - (Int32)RadioBackgroundTextureHeight / 2;
                    break;

                case UIPositions.CentreRight:
                    BaseX = Game.Resolution.Width - (Int32)RadioBackgroundTextureWidth;
                    BaseY = Game.Resolution.Height / 2 - (Int32)RadioBackgroundTextureHeight / 2;
                    break;

                case UIPositions.CentreBottom:
                    BaseX = Game.Resolution.Width / 2 - (Int32)RadioBackgroundTextureWidth / 2;
                    BaseY = Game.Resolution.Height - (Int32)RadioBackgroundTextureHeight;
                    break;

                case UIPositions.CentreTop:
                    BaseX = Game.Resolution.Width / 2 - (Int32)RadioBackgroundTextureWidth / 2;
                    BaseY = 0;
                    break;
                }
                Game.LogTrivial("Setting Display position to " + Position.ToString());
                Game.LogTrivial(BaseX + ":" + BaseY);
            }
        }
Ejemplo n.º 6
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));
                }
            }
        }