Beispiel #1
0
        public void OnProgress(Game.ProgressState progress)
        {
            switch (progress)
            {
            case Game.ProgressState.Preparing:
                Model.WaitingStatus = AppStrings.Race_Preparing;
                break;

            case Game.ProgressState.Launching:
                if (AcRootDirectory.CheckDirectory(MainExecutingFile.Directory) &&
                    MainExecutingFile.Name != "AssettoCorsa.exe" &&
                    new IniFile(AcPaths.GetCfgVideoFilename())["CAMERA"].GetNonEmpty("MODE") == "OCULUS" &&
                    MessageDialog.Show(
                        "Oculus Rift might not work properly with Content Manager is in AC root folder. It’s better to move it to avoid potential issues.",
                        "Important note", new MessageDialogButton {
                    [MessageBoxResult.Yes] = "Move it now",
                    [MessageBoxResult.No] = "Ignore"
                }, "oculusRiftWarningMessage") == MessageBoxResult.Yes)
                {
                    try {
                        var newLocation = FilesStorage.Instance.GetFilename(MainExecutingFile.Name);
                        File.Copy(MainExecutingFile.Location, newLocation, true);
                        WindowsHelper.ViewFile(newLocation);
                        ProcessExtension.Start(newLocation, new[] { @"--restart", @"--move-app=" + MainExecutingFile.Location });
                        Environment.Exit(0);
                    } catch (Exception e) {
                        NonfatalError.Notify("Failed to move Content Manager executable", "I’m afraid you’ll have to do it manually.", e);
                    }
                }

                if (SettingsHolder.Drive.SelectedStarterType == SettingsHolder.DriveSettings.DeveloperStarterType)
                {
                    Model.WaitingStatus = "Now, run AC…";
                }
                else
                {
                    Model.WaitingStatus = _mode == GameMode.Race ? AppStrings.Race_LaunchingGame :
                                          _mode == GameMode.Replay ? AppStrings.Race_LaunchingReplay : AppStrings.Race_LaunchingBenchmark;
                }
                break;

            case Game.ProgressState.Waiting:
                Model.WaitingStatus = _mode == GameMode.Race ? AppStrings.Race_Waiting :
                                      _mode == GameMode.Replay ? AppStrings.Race_WaitingReplay : AppStrings.Race_WaitingBenchmark;
                break;

            case Game.ProgressState.Finishing:
                RevertSizeFix().Ignore();
                Model.WaitingStatus = AppStrings.Race_CleaningUp;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(progress), progress, null);
            }
        }
Beispiel #2
0
        public static int Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture   = CultureInfo.InvariantCulture;
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");

            try {
                var options = new Options();
                if (!Parser.Default.ParseArguments(args, options))
                {
                    return(1);
                }

                FilesStorage.Initialize(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AcTools Console Wrapper"));
                ValuesStorage.Initialize(null, null);
                CacheStorage.Initialize(null);
                LimitedSpace.Initialize();
                LimitedStorage.Initialize();
                DataProvider.Initialize();

                AcRootDirectory.Initialize(options.AcRoot);
                if (!AcRootDirectory.Instance.IsReady)
                {
                    Console.Error.WriteLine("Invalid AC root directory");
                    return(3);
                }

                Superintendent.Initialize();

                AsyncContext.Run(() => MainAsync(options));
                return(0);
            } catch (InformativeException e) {
                Console.Error.WriteLine(e.Message);
                return(2);
            } catch (Exception e) {
                Console.Error.WriteLine(e.ToString());
                return(2);
            }
        }
            public ViewModel(bool changeAcRoot, bool changeSteamId)
            {
                ChangeAcRoot  = changeAcRoot;
                ChangeSteamId = changeSteamId;

                FirstRun = ValuesStorage.Get(KeyFirstRun, true);
                if (FirstRun)
                {
                    ValuesStorage.Set(KeyFirstRun, false);
                }

                ReviewMode = !FirstRun && IsReviewNeeded();
                Value      = AcRootDirectory.Instance.IsReady ? AcRootDirectory.Instance.Value : AcRootDirectory.TryToFind();

#if DEBUG
                if (changeAcRoot)
                {
                    // Value = Value?.Replace("D:", "C:");
                }
#endif

                var steamId = SteamIdHelper.Instance.Value;
                SteamProfiles = new BetterObservableCollection <SteamProfile>(SteamIdHelper.TryToFind().Append(SteamProfile.None));
                SteamProfile  = SteamProfiles.GetByIdOrDefault(steamId) ?? SteamProfiles.First();

                if (steamId != null && SteamProfile.SteamId != steamId)
                {
                    SetSteamId(steamId);
                }
            }
Beispiel #4
0
        private static bool IsGameProcess(Process process)
        {
            var filename = process.GetFilenameSafe();

            return(filename == null || AcRootDirectory.CheckDirectory(Path.GetDirectoryName(filename)));
        }
Beispiel #5
0
        public App()
        {
            FilesStorage.Initialize(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AcTools Arcade Corsa"));
            ValuesStorage.Initialize(FilesStorage.Instance.GetFilename("Values.data"), null);
            CacheStorage.Initialize(FilesStorage.Instance.GetFilename("Cache.data"));
            NonfatalError.Initialize();
            LimitedSpace.Initialize();
            LimitedStorage.Initialize();
            DataProvider.Initialize();
            DpiAwareWindow.OptionScale = 2d;

            Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata {
                DefaultValue = 20
            });

            AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;

            Resources.MergedDictionaries.Add(new SharedResourceDictionary {
                Source = new Uri("/FirstFloor.ModernUI;component/Assets/ModernUI.xaml", UriKind.Relative)
            });

            Resources.MergedDictionaries.Add(new SharedResourceDictionary {
                Source = new Uri("/Arcade Corsa;component/Assets/Theme.xaml", UriKind.Relative)
            });

            if (MainExecutingFile.Name.IndexOf("fancy", StringComparison.OrdinalIgnoreCase) != -1)
            {
                Resources["EffectsEnabled"] = true;
                Resources["ShadowEffect"]   = new DropShadowEffect {
                    RenderingBias = RenderingBias.Performance,
                    BlurRadius    = 30,
                    Direction     = -90,
                    Color         = Colors.Black,
                    ShadowDepth   = 4,
                    Opacity       = 0.6
                };
            }
            else
            {
                Resources["EffectsEnabled"] = false;
                Resources["ShadowEffect"]   = null;
            }

            var    config = Path.Combine(MainExecutingFile.Directory, "Config.json");
            string acRoot;

            if (File.Exists(config))
            {
                var options = JsonConvert.DeserializeObject <Options>(File.ReadAllText(config));
                if (options.AcRoot == null)
                {
                    options.AcRoot = AcRootDirectory.TryToFind();
                    File.WriteAllText(config, JsonConvert.SerializeObject(options));
                }

                acRoot = options.AcRoot;
            }
            else
            {
                acRoot = AcRootDirectory.TryToFind();
            }

            AcRootDirectory.Initialize(acRoot);
            if (!AcRootDirectory.Instance.IsReady)
            {
                ModernDialog.ShowMessage("Can’t find AC root directory. Please, specify it using Config.json file.");
                return;
            }

            Superintendent.Initialize();

            StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
        }