Esempio n. 1
0
        public static void RemoveLibrary(Library libraryToRemove)
        {
            if (UtilityBox.IsSteamRunning())
            {
                ErrorHandler.Instance.ShowNotificationMessage("Turn Off Steam removing steam library.");
                return;
            }
            RealSizeOnDiskTask.Instance.Cancel();
            LibraryDetector.Refresh();
            Library refreshedLibraryToRemove = null;

            foreach (Library library in BindingDataContext.Instance.LibraryList)
            {
                if (libraryToRemove.LibraryDirectory.Equals(library.LibraryDirectory, StringComparison.CurrentCultureIgnoreCase))
                {
                    refreshedLibraryToRemove = library;
                }
            }
            if (refreshedLibraryToRemove == null)
            {
                ErrorHandler.Instance.ShowErrorMessage("Library you are trying to remove is already removed.");
                return;
            }
            string newLibraryDirectory = refreshedLibraryToRemove.LibraryDirectory + "_removed";

            newLibraryDirectory = StringOperations.RenamePathWhenExists(newLibraryDirectory, "_removed");
            FileSystem.RenameDirectory(refreshedLibraryToRemove.LibraryDirectory, Path.GetFileName(newLibraryDirectory));
            BindingDataContext.Instance.LibraryList.Remove(refreshedLibraryToRemove);
            RealSizeOnDiskTask.Instance.Start();
            SteamConfigFileWriter.WriteLibraryList();
            ErrorHandler.Instance.ShowNotificationMessage("Library will still exist on harddrive. It is only removed from the list.");
            Process.Start(refreshedLibraryToRemove.LibraryDirectory + "_removed");
        }
Esempio n. 2
0
    public void CalculateBase()
    {
        basePosition = UtilityBox.GetLowerVertex(transform, GetComponent <MeshFilter>().sharedMesh);
        basePosition = basePosition - (transform.position.y - GetComponent <MeshRenderer>().bounds.center.y) * Vector3.up;
        Vector2 medianPoint = UtilityBox.GetMendianPoint(cells.ToArray());

        basePosition.x = -medianPoint.x * gridMap.cellSize;
        basePosition.z = -medianPoint.y * gridMap.cellSize;
    }
Esempio n. 3
0
        public static void AddLibrary()
        {
            if (UtilityBox.IsSteamRunning())
            {
                ErrorHandler.Instance.ShowNotificationMessage("Turn Off Steam removing steam library.");
                return;
            }
            RealSizeOnDiskTask.Instance.Cancel();
            LibraryDetector.Refresh();
            RealSizeOnDiskTask.Instance.Start();
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            folderBrowserDialog.Description = "Create or select new Steam library folder:";
            bool   isSelectedPathValidated = false;
            string selectedPath;

            while (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                selectedPath            = folderBrowserDialog.SelectedPath;
                isSelectedPathValidated = ValidateSelectedPath(selectedPath);
                if (isSelectedPathValidated)
                {
                    break;
                }
            }
            if (!isSelectedPathValidated)
            {
                return;
            }
            selectedPath = folderBrowserDialog.SelectedPath;
            if (selectedPath.EndsWith("_removed"))
            {
                selectedPath = StringOperations.RemoveStringAtEnd(selectedPath, "_removed");
                selectedPath = StringOperations.RenamePathWhenExists(selectedPath);
                FileSystem.RenameDirectory(folderBrowserDialog.SelectedPath, Path.GetFileName(selectedPath));
            }
            Library library = new Library();

            library.GamesList        = new SortableBindingList <Game>();
            library.LibraryDirectory = selectedPath;
            Directory.CreateDirectory(selectedPath + "\\steamapps");
            RealSizeOnDiskTask.Instance.Cancel();
            BindingDataContext.Instance.LibraryList.Add(library);
            SteamConfigFileWriter.WriteLibraryList();
            LibraryDetector.Refresh();
            RealSizeOnDiskTask.Instance.Start();
        }
Esempio n. 4
0
        public static void MoveSteamGame(Library source, Library destination, Game selectedGame)
        {
            if (UtilityBox.IsSteamRunning())
            {
                ErrorHandler.Instance.ShowNotificationMessage("Turn Off Steam before moving any games.");
                return;
            }
            if (Directory.Exists(destination.SteamAppsDirectory + "\\common\\" + selectedGame.GameFolder))
            {
                bool response = ErrorHandler.Instance.ShowQuestion("Game installation of " + selectedGame.GameName + "already exists in destination library. Do you want to overwrite?");
                if (!response)
                {
                    return;
                }
            }
            RealSizeOnDiskTask.Instance.Cancel();
            if (!MoveGameFolder(source, destination, selectedGame.GameFolder))
            {
                ErrorHandler.Instance.ShowNotificationMessage("Game moving was aborted. There might be some inconsistencies in game folder. It is advised to finish game move operation.");
                return;
            }
            SortableBindingList <Game> gamesToRemove = new SortableBindingList <Game>();

            foreach (Game game in source.GamesList)
            {
                if (selectedGame.GameFolder.Equals(game.GameFolder, StringComparison.CurrentCultureIgnoreCase))
                {
                    if (!MoveAcfFile(source, destination, game.AppID))
                    {
                        ErrorHandler.Instance.ShowNotificationMessage("Game moving was aborted. Some games might now show up in steam library.");
                        return;
                    }
                    gamesToRemove.Add(game);
                }
            }
            foreach (Game game in gamesToRemove)
            {
                destination.GamesList.Add(game);
                source.GamesList.Remove(game);
            }
            RealSizeOnDiskTask.Instance.Start();
            destination.OnPropertyChanged("LibrarySizeOnDisk");
            source.OnPropertyChanged("LibrarySizeOnDisk");
            destination.OnPropertyChanged("FreeSpaceOnDisk");
            source.OnPropertyChanged("FreeSpaceOnDisk");
        }
Esempio n. 5
0
 private void WorkThreadRealSizeOnDisk()
 {
     _blockMainThread.Reset();
     if (_lastFinishedGameAppId != 0)
     {
         foreach (Library library in BindingDataContext.Instance.LibraryList)
         {
             foreach (Game game in library.GamesList)
             {
                 if (_lastFinishedGameAppId == game.AppID)
                 {
                     game.RealSizeOnDisk          = _lastFinishedRealSizeOnDisk;
                     game.RealSizeOnDiskIsChecked = true;
                     library.OnPropertyChanged("LibrarySizeOnDisk");
                     SteamConfigFileWriter.WriteRealSizeOnDisk(library.SteamAppsDirectory + "\\appmanifest_" + _lastFinishedGameAppId + ".acf", _lastFinishedRealSizeOnDisk);
                     _lastFinishedGameAppId      = 0;
                     _lastFinishedRealSizeOnDisk = 0;
                 }
             }
         }
     }
     foreach (Library library in BindingDataContext.Instance.LibraryList)
     {
         foreach (Game game in library.GamesList)
         {
             if (!game.RealSizeOnDiskIsChecked)
             {
                 _blockMainThread.Set();
                 long realSizeOnDisk = UtilityBox.GetWshFolderSize(library.SteamAppsDirectory + "\\common\\" + game.GameFolder);
                 if (_realSizeOnDiskCt.IsCancellationRequested)
                 {
                     _lastFinishedGameAppId      = game.AppID;
                     _lastFinishedRealSizeOnDisk = realSizeOnDisk;
                     return;
                 }
                 _blockMainThread.Reset();
                 game.RealSizeOnDisk          = realSizeOnDisk;
                 game.RealSizeOnDiskIsChecked = true;
                 library.OnPropertyChanged("LibrarySizeOnDisk");
                 SteamConfigFileWriter.WriteRealSizeOnDisk(library.SteamAppsDirectory + "\\appmanifest_" + game.AppID + ".acf", realSizeOnDisk);
             }
         }
     }
     _blockMainThread.Set();
 }