public void LoadVideo(string systemName, string gameName)
        {
            try
            {
                var settingsFilePath = Global.BuildFilePathInHyperspinDir("Settings\\{0}.ini", systemName);
                string customVideoPath = null;

                if (File.Exists(settingsFilePath))
                {
                    try
                    {
                        WheelSettings wheelSettings = new WheelSettings();

                        wheelSettings.InitFromIniFile(settingsFilePath);

                        customVideoPath = wheelSettings.VideoDefaultsSection.CustomVideoPath;

                        if (!string.IsNullOrEmpty(customVideoPath))
                        {

                            Uri uriTester;

                            if (Uri.TryCreate(customVideoPath, UriKind.RelativeOrAbsolute, out uriTester))
                            {
                                // relative path
                                if (!uriTester.IsAbsoluteUri)
                                {
                                    customVideoPath = new Uri(new Uri(HyperSearchSettings.Instance().General.HyperSpinPathAbsolute, UriKind.Absolute), uriTester.ToString()).LocalPath;
                                }
                            }

                            if (!string.IsNullOrEmpty(customVideoPath) && !Directory.Exists(customVideoPath))
                            {
                                MainWindow.LogStatic("{0} has a custom video path defined ({1}) but that path does not exist, so reverting back to default.", systemName, customVideoPath);
                                customVideoPath = null;
                            }
                        }
                    }
                    catch(Exception ex)
                    {
                        MainWindow.LogStatic("Failed to read settings file: {0}", settingsFilePath);
                        ErrorHandler.HandleException(ex);
                    }
                }

                var baseVideoPath = Global.BuildFilePathInHyperspinDir("Media\\{0}\\Video", systemName);

                if (!string.IsNullOrEmpty(customVideoPath))
                {
                    baseVideoPath = customVideoPath.TrimEnd('\\');

                }

                MainWindow.LogStaticVerbose("Base video path={0}", baseVideoPath);

                var mp4Path = string.Format("{0}\\{1}.mp4", baseVideoPath, gameName);
                var flvPath = string.Format("{0}\\{1}.flv", baseVideoPath, gameName);
                var pngPath = string.Format("{0}\\{1}.png", baseVideoPath, gameName);

                if (File.Exists(mp4Path))
                {
                    MainWindow.LogStaticVerbose("Video.Source={0}", mp4Path);
                    video.Source = new Uri(mp4Path, UriKind.Absolute);
                }
                else if (File.Exists(flvPath))
                {
                    MainWindow.LogStaticVerbose("Video.Source={0}", flvPath);
                    video.Source = new Uri(flvPath, UriKind.Absolute);
                }
                else if (File.Exists(pngPath))
                {
                    MainWindow.LogStaticVerbose("Video.Source={0}", pngPath);
                    video.Source = new Uri(pngPath, UriKind.Absolute);
                }
                else
                {
                    MainWindow.LogStaticVerbose("No video found for {0}/{1} @ {2}. Looking for placeholder.",systemName, gameName, mp4Path);

                    var mp4NoVideo = Global.BuildFilePathInHyperspinDir("Media\\Frontend\\Video\\No Video.mp4");
                    var flvNoVideo = Global.BuildFilePathInHyperspinDir("Media\\Frontend\\Video\\No Video.flv");

                    if (File.Exists(mp4NoVideo))
                    {
                        MainWindow.LogStaticVerbose("Video.Source={0}", mp4NoVideo);
                        video.Source = new Uri(mp4NoVideo, UriKind.Absolute);
                    }
                    else if (File.Exists(flvNoVideo))
                    {
                        MainWindow.LogStaticVerbose("Video.Source={0}", flvNoVideo);
                        video.Source = new Uri(flvNoVideo, UriKind.Absolute);
                    }
                    else
                    {
                        MainWindow.LogStaticVerbose("No placeholder video found! 'No Video.mp4/flv' expected at: {0}", Global.BuildFilePathInHyperspinDir("Media\\Frontend\\Video\\"));
                    }
                }

                if (video.Source != null && this.CurrentViewState == ViewState.Results) video.Play();
            }
            catch (Exception ex)
            {
                ErrorHandler.HandleException(ex);
            }
        }
Example #2
0
 public void Reset(WheelSettings other)
 {
     slipForce             = new AnimationCurve(other.slipForce.keys);
     slipForceScale        = other.slipForceScale;
     forwardSlipForce      = new AnimationCurve(other.forwardSlipForce.keys);
     forwardSlipForceScale = other.forwardSlipForceScale;
     brakingTorque         = other.brakingTorque;
 }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     _wheelSettings         = this.GetComponent <WheelSettings>();
     _carBody               = this.GetComponent <Rigidbody>();
     _carBody.centerOfMass += _driveSettings.centerOfGravityOffset;
     foreach (var wheel in _wheelSettings.wheels)
     {
         wheel.collider.ConfigureVehicleSubsteps(1.0f, 12, 12);
     }
 }
Example #4
0
    public void Setup(WheelJoint2D wheel, WheelSettings wheelSettings)
    {
        _wheelSettings = wheelSettings;

        _getOnRoad   = GetComponent <GetOnRoad>();
        _rigidbody2D = GetComponent <Rigidbody2D>();

        _wheelJoint           = wheel;
        _motor.maxMotorTorque = wheelSettings.motorToque;
        SetMotorSpeed(0);

        _emission = _particles.emission;
        _particles.transform.parent = null;
    }
Example #5
0
    public void Reset()
    {
        var allwheels          = GetComponentsInChildren <Wheel>().ToList();
        var frontWheelSettings = new WheelSettings();

        frontWheelSettings.Reset(allwheels.First());

        var wheelassignment = new WheelAssignment();

        wheelassignment.settings = frontWheelSettings;
        wheelassignment.wheels.AddRange(allwheels);

        wheelAssignments = new List <WheelAssignment>();
        wheelAssignments.Add(wheelassignment);
    }
            public static int LoadFullGameList()
            {
                lock (_allGamesList)
                {
                    // TODO: Consider caching DB List and loading that from a single file on startup. But then we have need some way of clearing the cache again and on my machine and config that will only save 2 seconds on intial startup.
                    List<MenuXmlDatabase> dbList = new List<MenuXmlDatabase>();

                    var preloadAllXmlDbsPerf = PerformanceTracker.Begin("GAME SEARCH: PRELOAD");

                    List<GameXmlDatabase> gameList = null;

                    if (MainWindow.HqSettings != null && MainWindow.HqSettings.MainSection != null && MainWindow.HqSettings.MainSection.MenuMode.EqualsCI("single"))
                    {
                        MainWindow.LogStatic("Single mode: {0}", MainWindow.HqSettings.MainSection.SingleModeName);
                        gameList = new List<GameXmlDatabase>() { new GameXmlDatabase() { name = MainWindow.HqSettings.MainSection.SingleModeName } };
                    }
                    else
                    {
                        var mainMenuDbPath = Global.BuildFilePathInHyperspinDir("Databases\\Main Menu\\Main Menu.xml");

                        MainWindow.LogStatic("\tSearchDB: Parsing {0}...", mainMenuDbPath);

                        if (!File.Exists(mainMenuDbPath))
                        {
                            MainWindow.LogStatic("\tWARNING! [Main Menu.xml] not found at: {0}\r\nMake sure your HyperSpin path is setup correctly.", mainMenuDbPath);
                            return 0;
                        }

                        var mainMenuDb = MenuXmlDatabase.LoadFromFile(mainMenuDbPath);

                        MainWindow.LogStatic("\tSearchDB: Found {0} entries in [Main Menu.xml]", mainMenuDb.GameList.Count);

                        gameList = mainMenuDb.GameList;
                    }

                    var loadXmlDbsPerf = PerformanceTracker.Begin("Load ALL xml databases");

                    foreach (var system in gameList)
                    {
                        try
                        {
                            var dbFilePath = Global.BuildFilePathInHyperspinDir("Databases\\{0}\\{0}.xml", system.name);
                            MainWindow.LogStatic("\tSearchDB: Processing {0}", dbFilePath);

                            Console.WriteLine("----------- Loading: {0}", dbFilePath);
                            var db = MenuXmlDatabase.LoadFromFile(dbFilePath);

                            MainWindow.LogStatic("\t\tFound {0} entries", db.GameList.Count);

                            var settingsFilePath = Global.BuildFilePathInHyperspinDir("Settings\\{0}.ini", system.name);

                            if (File.Exists(settingsFilePath))
                            {
                                WheelSettings wheelSettings = new WheelSettings();

                                wheelSettings.InitFromIniFile(settingsFilePath);

                                if (wheelSettings.FilterSection.ParentsOnly)
                                {// remove all clones
                                    db.GameList.RemoveAll(g => !string.IsNullOrEmpty(g.cloneof));
                                }

                                int wheelRemoveCount = 0;
                                int themeRemoveCount = 0;

                                if (wheelSettings.FilterSection.WheelsOnly)
                                {
                                    for (int i = 0 ;i< db.GameList.Count;i++)
                                    {
                                        var expectedWheelImagePath = Global.BuildFilePathInHyperspinDir("Media\\{0}\\Images\\Wheel\\{1}.png", system.name, db.GameList[i].name);
                                        if (!File.Exists(expectedWheelImagePath))
                                        {
                                            db.GameList.Remove(db.GameList[i]);
                                            i--;
                                            wheelRemoveCount++;
                                        }
                                    }
                                }

                                if (wheelSettings.FilterSection.ThemesOnly)
                                {
                                    for (int i = 0; i < db.GameList.Count; i++)
                                    {
                                        var expectedThemePath = Global.BuildFilePathInHyperspinDir("Media\\{0}\\Themes\\{1}.zip", system.name, db.GameList[i].name);
                                        if (!File.Exists(expectedThemePath))
                                        {
                                            db.GameList.Remove(db.GameList[i]);
                                            i--;
                                            themeRemoveCount++;
                                        }
                                    }
                                }

                                MainWindow.LogStatic("\t\tRemoved: {0} (wheel filter), {1} (theme filter)", wheelRemoveCount, themeRemoveCount);
                            }

                            dbList.Add(db);
                        }
                        catch (Exception ex)
                        {
                            ErrorHandler.LogException(ex);
                        }
                    }

                    loadXmlDbsPerf.End();

                    var allGamesArray = (from d in dbList
                                         select d.GameList).ToArray();

                    List<GameXmlDatabase> fullGameList = new List<GameXmlDatabase>();

                    foreach (var a in allGamesArray)
                    {
                        fullGameList.AddRange(a);
                    }

                    _allGamesList = (from game in fullGameList
                                     where !string.IsNullOrEmpty(game.description)
                                     select game).ToList();

                    var p2 = PerformanceTracker.Begin("Game search: Initialise ALL urls");

                    foreach (var g in _allGamesList)
                    {
                        g.InitUris();
                    }

                    p2.End();

                    preloadAllXmlDbsPerf.End();
                }

                return _allGamesList.Count;
            }