Exemplo n.º 1
0
        public string getAbsolutePath(LocationPath parse_me, string user)
        {
            if (parse_me.EV == EnvironmentVariable.AltSavePaths)
            {
                DetectedLocations locs = interpretPath(parse_me.ToString());
                if (locs.Count > 0)
                {
                    parse_me = locs.getMostAccurateLocation();
                }
                else
                {
                    return(null);
                }
            }

            foreach (KeyValuePair <HandlerType, ALocationHandler> handler in handlers)
            {
                string result = handler.Value.getAbsolutePath(parse_me, user);
                if (result != null)
                {
                    return(result);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        public override List <DetectedLocationPathHolder> interpretPath(string interpret_me)
        {
            List <DetectedLocationPathHolder> return_me = new List <DetectedLocationPathHolder>();
            LocationPath new_location;

            if (ready)
            {
                return_me.AddRange(base.interpretPath(interpret_me));
                if (return_me.Count == 0)
                {
                    foreach (string drive in drives)
                    {
                        if (interpret_me.StartsWith(drive))
                        {
                            string path;
                            if (interpret_me.Length == drive.Length)
                            {
                                path = "";
                            }
                            else
                            {
                                path = interpret_me.Substring(drive.Length);
                            }
                            new_location = new LocationPath(EnvironmentVariable.Drive, path);
                            return_me.AddRange(getPaths(new_location));
                        }
                    }
                }
            }
            return(return_me);
        }
Exemplo n.º 3
0
        public CustomGameVersion(GameSaveInfo.Game parent, DirectoryInfo location, string saves, string ignores)
            : base(parent, "Windows", null, "Custom")
        {
            DetectedLocations          locs = Core.locations.interpretPath(location.FullName);
            DetectedLocationPathHolder loc  = locs.getMostAccurateLocation();

            if (loc.EV == EnvironmentVariable.VirtualStore)
            {
                string drive    = Path.GetPathRoot(loc.FullDirPath);
                string new_path = Path.Combine(drive, loc.Path);
                loc = Core.locations.interpretPath(new_path).getMostAccurateLocation();
            }

            switch (loc.EV)
            {
            case EnvironmentVariable.ProgramFiles:
            case EnvironmentVariable.ProgramFilesX86:
            case EnvironmentVariable.Drive:
                loc.EV = EnvironmentVariable.InstallLocation;
                break;
            }


            LocationPath locpath = new LocationPath(this.Locations, loc.EV, loc.Path);

            this.Locations.Paths.Add(locpath);


            FileType type = this.addFileType("Custom");

            string  path, file;
            Include save;

            if (saves != null && ignores != "")
            {
                path = Path.GetDirectoryName(saves);
                file = Path.GetFileName(saves);
                save = type.addSave(path, file);
            }
            else
            {
                save = type.addSave(null, null);
            }

            if (ignores != null && ignores != "")
            {
                path = Path.GetDirectoryName(ignores);
                file = Path.GetFileName(ignores);
                Exclude except = save.addExclusion(path, file);
            }

            if (Core.settings.EmailSender != null)
            {
                this.Contributors.Add(Core.settings.EmailSender);
            }
            else
            {
                this.Contributors.Add("Anonymous");
            }
        }
        /// <summary>
        /// Convert a list of locations to a locationPath directly.
        /// </summary>
        /// <remarks>Object should ideally inherit from <see cref="ILocationPath"/>, but if it doesn't or can't. Then use this when you need location path.</remarks>
        /// <param name="locations">List of locations.</param>
        /// <returns>Location based locationPath.</returns>
        public static LocationPath ToLocationPath(this IEnumerable <Location> locations)
        {
            var document = new LocationPath();

            document.UpdateLocationPath(locations);
            return(document);
        }
Exemplo n.º 5
0
 public DetectedLocationPathHolder(LocationPath path, string absolute_root, string owner)
     : base(path)
 {
     this.language     = path.language;
     this.AbsoluteRoot = absolute_root;
     this.owner        = owner;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the error message for the property with the given name.
        /// </summary>
        /// <param name="columnName">The name of the property whose error message to get.</param>
        /// <returns>The error message for the property. The default is an empty string ("").</returns>
        public string this[string columnName]
        {
            get
            {
                string error = string.Empty;
                switch (columnName)
                {
                case "LocationName":
                    if (LocationName.IsStringMissing())
                    {
                        error = Strings.TroveLocation_Error_LocationNameMissing;
                    }
                    break;

                case "LocationPath":
                    if (LocationPath.IsStringMissing())
                    {
                        error = Strings.TroveLocation_Error_LocationPathMissing;
                    }
                    else if (!File.Exists(Path.Combine(LocationPath, TroveExecutableFileName)))
                    {
                        error = Strings.TroveLocation_Error_LocationPathInvalid;
                    }
                    break;
                }
                return(error);
            }
        }
Exemplo n.º 7
0
        protected override DetectedLocations getPaths(ScummVM get_me)
        {
            DetectedLocations locs = base.getPaths(get_me);

            if (install_path != null)
            {
                LocationPath      loc   = SystemLocationHandler.translateToVirtualStore(install_path);
                DetectedLocations vlocs = Core.locations.getPaths(loc);
                List <string>     keys  = new List <string>(vlocs.Keys);
                foreach (string key in keys)
                {
                    if (!filterLocation(vlocs[key], get_me, vlocs[key].owner))
                    {
                        locs.Remove(key);
                    }
                }


                locs.AddRange(locs);
            }



            return(locs);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 加载查询参数[TRY]
 /// </summary>
 internal void LoadPage()
 {
     //long identity = SocketIdentity;
     //AutoCSer.Net.Http.SocketBase socket = Socket;
     //try
     //{
     if (loadView())
     {
         if (!IsAsynchronous)
         {
             responsePage();
         }
     }
     else
     {
         if (!IsLocationPath)
         {
             LocationPath.Clear();
         }
         responseLocationPath();
     }
     //    return;
     //}
     //catch (Exception error)
     //{
     //    DomainServer.RegisterServer.TcpServer.Log.add(AutoCSer.LogLevel.Error, error);
     //}
     //serverError500(socket, identity);
 }
Exemplo n.º 9
0
        public override string getAbsoluteRoot(LocationPath parse_me, string user)
        {
            switch (parse_me.EV)
            {
            case EnvironmentVariable.Drive:
                if (parse_me is DetectedLocationPathHolder)
                {
                    DetectedLocationPathHolder holder = (DetectedLocationPathHolder)parse_me;
                    return(holder.AbsoluteRoot);
                }
                else
                {
                    foreach (string drive in drives)
                    {
                        if (Directory.Exists(Path.Combine(drive, parse_me.Path)))
                        {
                            return(Path.Combine(drive, parse_me.Path));
                        }
                    }
                    return(null);
                }

            default:
                return(base.getAbsoluteRoot(parse_me, user));
            }
        }
Exemplo n.º 10
0
 public DetectedLocationPathHolder(LocationPath path, string absolute_root, string owner)
     : base(path)
 {
     this.language = path.language;
     this.AbsoluteRoot = absolute_root;
     this.owner = owner;
 }
Exemplo n.º 11
0
        public IEnumerable <DetectedLocationPathHolder> createDetectedLocations(LocationPath loc, string owner)
        {
            List <DetectedLocationPathHolder> return_me = new List <DetectedLocationPathHolder>();

            foreach (string folder in this.Keys)
            {
                DetectedLocationPathHolder add_me = new DetectedLocationPathHolder(loc.EV, this[folder], loc.Path, owner);
                return_me.Add(add_me);
            }
            return(return_me);
        }
Exemplo n.º 12
0
        // Gets the absolute root of the provided location
        public virtual string getAbsolutePath(LocationPath parse_me, string user)
        {
            string return_me = getAbsoluteRoot(parse_me, user);

            if (return_me != null && parse_me.Path != null && parse_me.Path != "")
            {
                return_me = Path.Combine(return_me, parse_me.Path);
            }

            return(return_me);
        }
Exemplo n.º 13
0
    void OnSceneGUI(SceneView sceneView)
    {
        LocationPath locationPath = (LocationPath)target;

        if (locationPath.locations == null)
        {
            return;
        }

        DrawOnSceneGUI();
        DrawPath();
    }
Exemplo n.º 14
0
 protected override DetectedLocations getPaths(LocationPath get_me)
 {
     DetectedLocations return_me = new DetectedLocations();
     DirectoryInfo test;
     DetectedLocationPathHolder add_me;
     switch (get_me.EV) {
         case EnvironmentVariable.InstallLocation:
             LocationPath temp = new LocationPath(get_me);
             string[] chopped = temp.Path.Split(Path.DirectorySeparatorChar);
             for (int i = 0; i < chopped.Length; i++) {
                 temp.ReplacePath(chopped[i]);
                 for (int j = i + 1; j < chopped.Length; j++) {
                     temp.AppendPath(chopped[j]);
                 }
                 temp.EV = EnvironmentVariable.Drive;
                 return_me.AddRange(getPaths(temp));
                 temp.EV = EnvironmentVariable.AltSavePaths;
                 return_me.AddRange(getPaths(temp));
             }
             break;
         case EnvironmentVariable.AltSavePaths:
             foreach (AltPathHolder alt_path in Core.settings.save_paths) {
                 if (PermissionsHelper.isReadable(alt_path.path)) {
                     if (get_me.Path != null && get_me.Path.Length > 0)
                         test = new DirectoryInfo(Path.Combine(alt_path.path, get_me.Path));
                     else
                         test = new DirectoryInfo(alt_path.path);
                     if (test.Exists) {
                         DetectedLocations locs = Core.locations.interpretPath(alt_path.path, get_me.Path);
                         foreach (DetectedLocationPathHolder loc in locs) {
                             return_me.Add(loc);
                         }
                     }
                 }
             }
             break;
         case EnvironmentVariable.Drive:
             foreach (string drive in drives) {
                 if (get_me.Path != null && get_me.Path.Length > 0)
                     test = new DirectoryInfo(Path.Combine(drive, get_me.Path));
                 else
                     test = new DirectoryInfo(drive);
                 if (test.Exists) {
                     add_me = new DetectedLocationPathHolder(get_me, drive, null);
                     return_me.Add(add_me);
                 }
             }
             break;
         default:
             return base.getPaths(get_me);
     }
     return return_me;
 }
Exemplo n.º 15
0
 public string getAbsoluteRoot(LocationPath parse_me, string user)
 {
     foreach (KeyValuePair <HandlerType, ALocationHandler> handler in handlers)
     {
         string result = handler.Value.getAbsoluteRoot(parse_me, user);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
Exemplo n.º 16
0
        public async Task <ActionResult <PutPatientDetailsResponse> > UpdatePatientDetails(string examinationId,
                                                                                           [FromBody][ExaminationValidationModelBinderContext("examinationId")] PutPatientDetailsRequest putPatientDetailsRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequestEnums(new PutPatientDetailsResponse()));
            }

            var examination =
                await _examinationRetrievalService.Handle(new ExaminationRetrievalQuery(examinationId, null));

            if (examination == null)
            {
                return(NotFound(new PutPatientDetailsResponse()));
            }

            // Do they have update permission on the examination being updated
            if (!CanAsync(Permission.UpdateExamination, examination))
            {
                return(Forbid());
            }

            var patientDetails = Mapper.Map <PatientDetails>(putPatientDetailsRequest);

            var locations = (await _locationParentsService.Handle(
                                 new LocationParentsQuery(patientDetails.MedicalExaminerOfficeResponsible))).ToList();

            var locationPath = new LocationPath();

            locationPath.UpdateLocationPath(locations);

            // Do they have permission at this location to update the examination. I.e. they're changing the Medical Examiner Office.
            if (!CanAsync(Permission.UpdateExamination, locationPath))
            {
                return(Forbid());
            }

            var myUser = await CurrentUser();

            var result = await _patientDetailsUpdateService.Handle(new PatientDetailsUpdateQuery(
                                                                       examinationId,
                                                                       patientDetails,
                                                                       myUser,
                                                                       locations));

            var patientCard = Mapper.Map <PatientCardItem>(result);

            return(Ok(new PutPatientDetailsResponse
            {
                Header = patientCard
            }));
        }
Exemplo n.º 17
0
        public void populateUsers(LocationPath location)
        {
            user_candidates.Clear();
            List <string> users = Core.locations.getUsers(location.EV);

            if (users.Count > 0 && location.EV != EnvironmentVariable.FlashShared)
            {
                user_needed = true;
                if (users.Count > 1)
                {
                    multiple_users = true;
                }
                else
                {
                    multiple_users = false;
                    NotifyPropertyChanged("only_user");
                }
                foreach (string user in users)
                {
                    user_candidates.AddWithSort(user);
                }
            }
            else
            {
                switch (location.EV)
                {
                case EnvironmentVariable.AllUsersProfile:
                case EnvironmentVariable.AltSavePaths:
                case EnvironmentVariable.Drive:
                case EnvironmentVariable.InstallLocation:
                case EnvironmentVariable.None:
                case EnvironmentVariable.ProgramFiles:
                case EnvironmentVariable.ProgramFilesX86:
                case EnvironmentVariable.PS3Export:
                case EnvironmentVariable.PS3Save:
                case EnvironmentVariable.PSPSave:
                case EnvironmentVariable.Public:
                case EnvironmentVariable.SteamCommon:
                case EnvironmentVariable.SteamSourceMods:
                case EnvironmentVariable.CommonApplicationData:
                case EnvironmentVariable.UbisoftSaveStorage:
                case EnvironmentVariable.FlashShared:
                    user_needed = false;
                    break;

                default:
                    throw new TranslateableException("NoUsersForEV", location.EV.ToString());
                }
            }
        }
Exemplo n.º 18
0
        protected void filterPathCandidates(LocationPath location)
        {
            //if(location.path==null)
            //continue;
            if (location.OnlyFor != null && location.OnlyFor != Core.locations.platform_version)
            {
                return;
            }

            if (location.EV == EnvironmentVariable.InstallLocation ||
                location.EV == EnvironmentVariable.SteamCommon)
            {
                return;
            }

            // Adds user-friendly menu entries to the root selector
            switch (location.EV)
            {
            case EnvironmentVariable.SteamSourceMods:
                if (Core.locations.steam_detected)
                {
                    addPathCandidate(location);
                }
                break;

            case EnvironmentVariable.SteamUser:
            case EnvironmentVariable.SteamUserData:
                if (Core.locations.steam_detected && Core.locations.getUsers(location.EV).Count > 0)
                {
                    addPathCandidate(location);
                }
                break;

            case EnvironmentVariable.UbisoftSaveStorage:
            case EnvironmentVariable.FlashShared:
                IEnumerable <string> paths = Core.locations.getPaths(location.EV);
                foreach (string path in paths)
                {
                    LocationPath loc = Core.locations.interpretPath(path).getMostAccurateLocation();
                    loc.AppendPath(location.Path);
                    addPathCandidate(loc);
                }
                break;

            default:
                addPathCandidate(location);
                break;
            }
        }
Exemplo n.º 19
0
        public CustomGameVersion(GameSaveInfo.Game parent, DirectoryInfo location, string saves, string ignores)
            : base(parent, "Windows", null, "Custom")
        {
            DetectedLocations locs = Core.locations.interpretPath(location.FullName);
            DetectedLocationPathHolder loc = locs.getMostAccurateLocation();

            if (loc.EV == EnvironmentVariable.VirtualStore) {
                string drive = Path.GetPathRoot(loc.FullDirPath);
                string new_path = Path.Combine(drive, loc.Path);
                loc = Core.locations.interpretPath(new_path).getMostAccurateLocation();
            }

            switch (loc.EV) {
                case EnvironmentVariable.ProgramFiles:
                case EnvironmentVariable.ProgramFilesX86:
                case EnvironmentVariable.Drive:
                    loc.EV = EnvironmentVariable.InstallLocation;
                    break;
            }

            LocationPath locpath = new LocationPath(this.Locations, loc.EV, loc.Path);

            this.Locations.Paths.Add(locpath);

            FileType type = this.addFileType("Custom");

            string path, file;
            Include save;

            if (saves != null && ignores != "") {
                path = Path.GetDirectoryName(saves);
                file = Path.GetFileName(saves);
                save = type.addSave(path, file);
            } else {
                save = type.addSave(null, null);
            }

            if (ignores != null && ignores != "") {
                path = Path.GetDirectoryName(ignores);
                file = Path.GetFileName(ignores);
                Exclude except = save.addExclusion(path, file);
            }

            if (Core.settings.EmailSender != null)
                this.Contributors.Add(Core.settings.EmailSender);
            else
                this.Contributors.Add("Anonymous");
        }
Exemplo n.º 20
0
        protected override void analyzerWork()
        {
            ProgressHandler.max += 3;
            base.analyzerWork();

            if (Core.locations.uac_enabled)
            {
                TranslatingProgressHandler.setTranslatedMessage("DumpingVirtualStore");
                outputLine(Environment.NewLine + "UAC Enabled" + Environment.NewLine);
                outputLine(Environment.NewLine + "VirtualStore Folders: ");
                string virtual_path;

                foreach (string user in Core.locations.getUsers(EnvironmentVariable.LocalAppData))
                {
                    LocationPath parse_me = new LocationPath(EnvironmentVariable.LocalAppData, "VirtualStore");
                    virtual_path = Path.Combine(Core.locations.getAbsoluteRoot(parse_me, user), "VirtualStore");

                    virtual_path = Path.Combine(virtual_path, path.FullDirPath.Substring(3));
                    if (Directory.Exists(virtual_path))
                    {
                        travelFolder(virtual_path);
                    }
                }
            }
            else
            {
                outputLine(Environment.NewLine + "UAC Disabled or not present" + Environment.NewLine);
            }

            try {
                TranslatingProgressHandler.setTranslatedMessage("AnalyzingRegistry");
                ProgressHandler.value++;
                searchRegistry();
            } catch (Exception ex) {
                outputLine("Error while attempting to search the registry:");
                recordException(ex);
            }

            try {
                TranslatingProgressHandler.setTranslatedMessage("AnalyzingStartMenu");
                ProgressHandler.value++;
                searchStartMenu();
            } catch (Exception ex) {
                outputLine("Error while attempting to search the start menu:");
                recordException(ex);
            }
        }
Exemplo n.º 21
0
        public string getAbsolutePath(LocationPath parse_me, string user)
        {
            if (parse_me.EV == EnvironmentVariable.AltSavePaths) {
                DetectedLocations locs = interpretPath(parse_me.ToString());
                if (locs.Count > 0)
                    parse_me = locs.getMostAccurateLocation();
                else
                    return null;
            }

            foreach (KeyValuePair<HandlerType, ALocationHandler> handler in handlers) {
                string result = handler.Value.getAbsolutePath(parse_me, user);
                if (result != null)
                    return result;
            }
            return null;
        }
Exemplo n.º 22
0
 public override string getAbsoluteRoot(LocationPath parse_me, string user)
 {
     switch (parse_me.EV) {
         case EnvironmentVariable.Drive:
             if (parse_me is DetectedLocationPathHolder) {
                 DetectedLocationPathHolder holder = (DetectedLocationPathHolder)parse_me;
                 return holder.AbsoluteRoot;
             } else {
                 foreach (string drive in drives) {
                     if(Directory.Exists(Path.Combine(drive, parse_me.Path)))
                         return Path.Combine(drive, parse_me.Path);
                 }
                 return null;
             }
         default:
             return base.getAbsoluteRoot(parse_me, user);
     }
 }
Exemplo n.º 23
0
        public string getFolder(EnvironmentVariable ev, string user)
        {
            LocationPath  parse_me = new LocationPath(ev, null);
            List <string> users    = this.getUsers(ev);

            if (user == null)
            {
                foreach (string usr in users)
                {
                    return(this.getAbsoluteRoot(parse_me, usr));
                }
                return(this.getAbsoluteRoot(parse_me, null));
            }
            if (users.Contains(user))
            {
                return(this.getAbsoluteRoot(parse_me, user));
            }
            throw new Exception("User " + user + " does not have a folder for EV " + ev.ToString());
        }
Exemplo n.º 24
0
        protected override void analyzerWork()
        {
            ProgressHandler.max += 3;
            base.analyzerWork();

            if (Core.locations.uac_enabled) {
                TranslatingProgressHandler.setTranslatedMessage("DumpingVirtualStore");
                outputLine(Environment.NewLine + "UAC Enabled" + Environment.NewLine);
                outputLine(Environment.NewLine + "VirtualStore Folders: ");
                string virtual_path;

                foreach (string user in Core.locations.getUsers(EnvironmentVariable.LocalAppData)) {
                    LocationPath parse_me = new LocationPath(EnvironmentVariable.LocalAppData, "VirtualStore");
                    virtual_path = Path.Combine(Core.locations.getAbsoluteRoot(parse_me, user), "VirtualStore");

                    virtual_path = Path.Combine(virtual_path, path.FullDirPath.Substring(3));
                    if (Directory.Exists(virtual_path))
                        travelFolder(virtual_path);

                }
            } else {
                outputLine(Environment.NewLine + "UAC Disabled or not present" + Environment.NewLine);
            }

            try {
                TranslatingProgressHandler.setTranslatedMessage("AnalyzingRegistry");
                ProgressHandler.value++;
                searchRegistry();
            } catch (Exception ex) {
                outputLine("Error while attempting to search the registry:");
                recordException(ex);
            }

            try {
                TranslatingProgressHandler.setTranslatedMessage("AnalyzingStartMenu");
                ProgressHandler.value++;
                searchStartMenu();
            } catch (Exception ex) {
                outputLine("Error while attempting to search the start menu:");
                recordException(ex);
            }
        }
Exemplo n.º 25
0
        public void restoreBackup(LocationPath path, string user, RunWorkerCompletedEventHandler when_done)
        {
            string target;

            if (path is ManualLocationPathHolder)
            {
                ManualLocationPathHolder loc = path as ManualLocationPathHolder;
                target = loc.ManualPath;
            }
            else if (path is DetectedLocationPathHolder)
            {
                DetectedLocationPathHolder loc = path as DetectedLocationPathHolder;
                target = loc.FullDirPath;
            }
            else
            {
                target = Core.locations.getAbsolutePath(path, user);
            }
            restoreBackup(target, when_done);
        }
Exemplo n.º 26
0
 public virtual string getAbsoluteRoot(LocationPath parse_me, string user)
 {
     if (user == null)
     {
         if (global.hasFolderFor(parse_me.EV))
         {
             return(global.getFolder(parse_me.EV).BaseFolder);
         }
     }
     else
     {
         foreach (UserData user_data in this)
         {
             if (user_data.name == user && user_data.hasFolderFor(parse_me.EV))
             {
                 return(user_data.getFolder(parse_me.EV).BaseFolder);
             }
         }
     }
     return(null);
 }
Exemplo n.º 27
0
 public override List<DetectedLocationPathHolder> interpretPath(string interpret_me)
 {
     List<DetectedLocationPathHolder> return_me = new List<DetectedLocationPathHolder>();
     LocationPath new_location;
     if (ready) {
         return_me.AddRange(base.interpretPath(interpret_me));
         if (return_me.Count == 0) {
             foreach (string drive in drives) {
                 if (interpret_me.StartsWith(drive)) {
                     string path;
                     if (interpret_me.Length == drive.Length)
                         path = "";
                     else
                         path = interpret_me.Substring(drive.Length);
                     new_location = new LocationPath(EnvironmentVariable.Drive, path);
                     return_me.AddRange(getPaths(new_location));
                 }
             }
         }
     }
     return return_me;
 }
Exemplo n.º 28
0
        protected virtual DetectedLocations getPaths(LocationPath get_me)
        {
            DetectedLocations return_me = new DetectedLocations();

            if (!ready)
            {
                return(return_me);
            }

            foreach (UserData user in this)
            {
                if (!user.hasFolderFor(get_me.EV))
                {
                    continue;
                }

                EvFolder evf = user.getFolder(get_me.EV);
                foreach (DetectedLocationPathHolder add_me in evf.createDetectedLocations(get_me, user.name))
                {
                    if (add_me.Exists)
                    {
                        return_me.Add(add_me);
                    }
                }
            }
            if (global.hasFolderFor(get_me.EV))
            {
                foreach (DetectedLocationPathHolder add_me in global.getFolder(get_me.EV).createDetectedLocations(get_me, null))
                {
                    if (add_me.Exists)
                    {
                        return_me.Add(add_me);
                    }
                }
            }
            return(return_me);
        }
Exemplo n.º 29
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("working");
        TextAsset locationPathData = Resources.Load <TextAsset>("LocationPaths");


        string[] data = locationPathData.text.Split(new char[] { '\n' });

        for (int i = 1; i < data.Length - 1; i++)
        {
            string[]     row = data[i].Split(new char[] { ',' });
            LocationPath lp  = new LocationPath();
            int.TryParse(row[0], out lp.hubNum);
            int.TryParse(row[1], out lp.locationNum);
            lp.locationStr = row[2];
            lp.travelType  = row[3];
            int.TryParse(row[4], out lp.ticketNum);
            lp.travelToStr = row[5];
            int.TryParse(row[6], out lp.hubToNum);
            int.TryParse(row[7], out lp.travelToNum);

            locationPaths.Add(lp);
        }
    }
Exemplo n.º 30
0
        public void addPathCandidate(LocationPath location)
        {
            // Checks if the provided path is the original archive path
            if (location is DetectedLocationPathHolder) {
                DetectedLocationPathHolder loc = location as DetectedLocationPathHolder;
                if (archive.id.OriginalLocation != null && archive.id.OriginalLocation.ToLower() == loc.FullDirPath.ToLower()) {
                    loc.MatchesOriginalPath = true;
                }
            }

            // If path is a manuallly added path, we remove all other manual paths,
            // Then we don't compare further, since it doesn't matter
            if (location is ManualLocationPathHolder) {
                for (int i = 0; i < path_candidates.Count; i++) {
                    if (path_candidates[i] is ManualLocationPathHolder) {
                        path_candidates.RemoveAt(i);
                    }
                }
                path_candidates.Insert(0, location);
                return;
            }

            if (location is DetectedLocationPathHolder) {
                // If the new path is a real, existant path
                DetectedLocationPathHolder loc = location as DetectedLocationPathHolder;
                for (int i = 0; i < path_candidates.Count; i++) {
                    if (path_candidates[i] is DetectedLocationPathHolder) {
                        // If the present path is a real, detected path
                        DetectedLocationPathHolder path = path_candidates[i] as DetectedLocationPathHolder;
                        // We compare the absolute paths
                        if (path.FullDirPath.ToLower() == loc.FullDirPath.ToLower()) {
                            // If it's two real, detected paths that are the same location, we compare EVs
                            if (loc.EV > path.EV) {
                                // If the new EV is better, then we replace the old one
                                path_candidates.RemoveAt(i);
                                path_candidates.AddWithSort(loc);
                            }
                            return;
                        } else {
                            // If the paths don't match, then we compare Ev-relative paths
                            if (path.FullRelativeDirPath.ToLower() == loc.FullRelativeDirPath.ToLower()) {
                                //if they're the same, then we compare for matching
                                if (loc.MatchesOriginalPath) {
                                    path_candidates.RemoveAt(i);
                                    path_candidates.AddWithSort(loc);
                                }
                                return;
                            }
                        }
                    } else {
                        // If the existing path is an theoretical path path
                        LocationPath path = path_candidates[i];
                        if (loc.FullRelativeDirPath.ToLower() == path.FullRelativeDirPath.ToLower()) {
                            // If both paths are based on the same EV/path combo
                            // Then the real path supercedes the fake path
                            path_candidates.RemoveAt(i);
                            path_candidates.AddWithSort(loc);
                            return;
                        } else {
                            // Otherwise we don't do anything
                        }
                    }
                }
            } else {
                switch (location.EV) {
                    case EnvironmentVariable.Drive:
                    case EnvironmentVariable.ProgramFiles:
                    case EnvironmentVariable.ProgramFilesX86:
                        return;
                }
                // If the new path is only a theoretical path
                for (int i = 0; i < path_candidates.Count; i++) {
                    LocationPath path = path_candidates[i];
                    if (path.FullRelativeDirPath.ToLower() == location.FullRelativeDirPath.ToLower()) {
                        // If the relative paths match we compare the EVs for the more accurate one
                        if (location.EV > path.EV) {
                            // If the new path has a more accurate EV, we replace the old one
                            path_candidates.RemoveAt(i);
                            path_candidates.AddWithSort(location);
                        }
                        return;
                    } else {
                        // If the relative paths don't match, then they have nothign to do with eachother
                        // so we'll just let the test continue
                    }
                }
            }
            path_candidates.AddWithSort(location);
            return;
        }
Exemplo n.º 31
0
        private void loadDirectory(XmlElement dir, Game game)
        {
            XmlElement path = null, reg = null;
            string include = null, exclude = null;
            foreach (XmlElement ele in dir.ChildNodes) {
                switch (ele.Name) {
                    case "path":
                        path = ele;
                        break;
                    case "include":
                        include = ele.InnerText;
                        break;
                    case "exclude":
                        exclude = ele.InnerText;
                        break;
                    case "reg":
                        reg = ele;
                        break;
                    default:
                        throw new NotSupportedException(ele.Name);
                }
            }

            string specialpath = path.Attributes["specialpath"].Value;

            ALocation loc = null;
            EnvironmentVariable ev =  EnvironmentVariable.None;

            RegRoot reg_root = RegRoot.none;
            string reg_key = null;
            string reg_value = null;

            string rel_path = path.InnerText;
            bool linkable = false;
            bool needs_file_path = false;
            switch (specialpath) {
                case "%REGISTRY%":
                    reg_root = getRegRoot(reg);
                    reg_key = getRegKey(reg);
                    reg_value = getRegValue(reg);
                    break;
                case "%APPDATA%":
                    ev = EnvironmentVariable.AppData;
                    linkable = true;
                    break;
                case "%DOCUMENTS%":
                    ev = EnvironmentVariable.UserDocuments;
                    linkable = true;
                    break;
                case "%APPDATA_COMMON%":
                    ev = EnvironmentVariable.CommonApplicationData;
                    linkable = true;
                    break;
                case "%APPDATA_LOCAL%":
                    ev = EnvironmentVariable.LocalAppData;
                    linkable = true;
                    break;
                case "%SAVED_GAMES%":
                    ev = EnvironmentVariable.SavedGames;
                    linkable = true;
                    break;
                case "%USER_PROFILE%":
                    ev = EnvironmentVariable.UserProfile;
                    linkable = true;
                    break;
                case "%SHARED_DOCUMENTS%":
                    ev = EnvironmentVariable.Public;
                    rel_path = System.IO.Path.Combine("Documents",rel_path);
                    linkable = true;
                    break;
                case "%STEAM_CLOUD%":
                    ev = EnvironmentVariable.SteamUserData;
                    break;
                case "%STEAM_CACHE%":
                    ev = EnvironmentVariable.SteamUser;
                    linkable = true;
                    break;
                case "%STEAM%":
                    if (rel_path.ToLower().StartsWith(@"steamapps\common\")) {
                        ev = EnvironmentVariable.SteamCommon;
                        rel_path = rel_path.Substring(17).Trim(System.IO.Path.DirectorySeparatorChar);
                    } else if (rel_path.ToLower().StartsWith(@"steamapps\sourcemods\")) {
                        ev = EnvironmentVariable.SteamSourceMods;
                        rel_path = rel_path.Substring(21).Trim(System.IO.Path.DirectorySeparatorChar);
                    } else {
                        throw new NotSupportedException(rel_path);
                    }
                    linkable = true;
                    needs_file_path = true;
                    break;
                case "%UPLAY%":
                    ev = EnvironmentVariable.UbisoftSaveStorage;
                    break;
                case "":
                    ev = EnvironmentVariable.Drive;
                    rel_path = rel_path.Substring(Path.GetPathRoot(rel_path).Length);
                    linkable = true;
                    needs_file_path = true;
                    break;
                default:
                    throw new NotSupportedException(specialpath);
            }
            GameVersion version;
            String path_prepend = null;
            rel_path = correctPath(rel_path);
            if(ev!= EnvironmentVariable.None) {
                switch (ev) {
                    case EnvironmentVariable.AppData:
                    case EnvironmentVariable.UserDocuments:
                    case EnvironmentVariable.CommonApplicationData:
                    case EnvironmentVariable.Public:
                    case EnvironmentVariable.SteamCommon:
                    case EnvironmentVariable.SavedGames:
                    case EnvironmentVariable.LocalAppData:
                    case EnvironmentVariable.UserProfile:
                    case EnvironmentVariable.SteamUser:
                    case EnvironmentVariable.SteamSourceMods:
                        if(!game.hasVersion("Windows",null,null))
                            game.addVersion("Windows",null,null);
                        version = game.getVersion("Windows",null,null);
                        break;
                    case EnvironmentVariable.SteamUserData:
                        if (!game.hasVersion(null, "SteamCloud", null))
                            game.addVersion(null, "SteamCloud", null);
                        version = game.getVersion(null, "SteamCloud", null);
                        break;
                    case EnvironmentVariable.UbisoftSaveStorage:
                        if (!game.hasVersion(null, "UbisoftSaveStorage", null))
                            game.addVersion(null, "UbisoftSaveStorage", null);
                        version = game.getVersion(null, "UbisoftSaveStorage", null);
                        break;
                    default:
                        throw new NotSupportedException(ev.ToString());
                }
                switch (ev) {
                    case EnvironmentVariable.SteamUser:
                    case EnvironmentVariable.SteamCommon:
                    case EnvironmentVariable.SteamSourceMods:
                    case EnvironmentVariable.SteamUserData:
                        if (rel_path.Contains('\\')) {
                            int index = rel_path.IndexOf('\\');
                            path_prepend = rel_path.Substring(index+1);
                            rel_path = rel_path.Substring(0, index);
                        }
                        break;
                }

                loc = new LocationPath(version.Locations,ev, rel_path);
            } else {
                if(!game.hasVersion("Windows",null,null))
                    game.addVersion("Windows",null,null);
                version = game.getVersion("Windows",null,null);

                loc = new LocationRegistry(version.Locations, reg_root.ToString(), correctReg(reg_key), reg_value);
                if (rel_path != null && rel_path != "")
                    path_prepend = correctPath(rel_path);
            }
            version.addLocation(loc);

            FileType type = version.addFileType(null);

            foreach (string inc in include.Split('|')) {
                Include save;
                string add_path = null;
                if (needs_file_path)
                    add_path = "";

                if (path_prepend != null) {
                    add_path = path_prepend;
                }

                string file = correctPath(inc);
                if (file.Contains('\\')) {
                    string[] splits = file.Split('\\');
                    for (int i = 0; i < splits.Length; i++) {
                        if (i < splits.Length - 1) {
                            if (add_path != null)
                                add_path = Path.Combine(add_path, splits[i]);
                            else
                                add_path = splits[i];
                        } else {
                            file = splits[i];
                        }
                    }
                }

                if (file == "*.*"||file=="*") {
                    save = type.addSave(add_path, null);
                } else {
                    save = type.addSave(add_path, file);
                }

                foreach (string exc in exclude.Split('|')) {
                    if (exc != "") {
                        save.addExclusion(add_path, exc);
                    }
                }

            }

            if (linkable) {
                if(path_prepend!=null) {
                    version.addLink(path_prepend);
                }else if (needs_file_path) {
                        version.addLink("");
                } else
                    version.addLink(null);
            }

            version.addContributor("GameSaveManager");
        }
Exemplo n.º 32
0
 public override string ToString()
 {
     return(LocationPath.ToString());
 }
Exemplo n.º 33
0
 public string getFolder(EnvironmentVariable ev, string user)
 {
     LocationPath parse_me = new LocationPath(ev, null);
     List<string> users = this.getUsers(ev);
     if (user == null) {
         foreach (string usr in users) {
             return this.getAbsoluteRoot(parse_me, usr);
         }
         return this.getAbsoluteRoot(parse_me, null);
     }
     if (users.Contains(user)) {
         return this.getAbsoluteRoot(parse_me, user);
     }
     throw new Exception("User " + user + " does not have a folder for EV " + ev.ToString());
 }
Exemplo n.º 34
0
        protected void filterPathCandidates(LocationPath location)
        {
            //if(location.path==null)
            //continue;
            if (location.OnlyFor != null && location.OnlyFor != Core.locations.platform_version)
                return;

            if (location.EV == EnvironmentVariable.InstallLocation ||
                location.EV == EnvironmentVariable.SteamCommon)
                return;

            // Adds user-friendly menu entries to the root selector
            switch (location.EV) {
                case EnvironmentVariable.SteamSourceMods:
                    if (Core.locations.steam_detected)
                        addPathCandidate(location);
                    break;
                case EnvironmentVariable.SteamUser:
                case EnvironmentVariable.SteamUserData:
                    if (Core.locations.steam_detected && Core.locations.getUsers(location.EV).Count > 0)
                        addPathCandidate(location);
                    break;
                case EnvironmentVariable.UbisoftSaveStorage:
                case EnvironmentVariable.FlashShared:
                    IEnumerable<string> paths = Core.locations.getPaths(location.EV);
                    foreach (string path in paths) {
                        LocationPath loc = Core.locations.interpretPath(path).getMostAccurateLocation();
                        loc.AppendPath(location.Path);
                        addPathCandidate(loc);
                    }
                    break;
                default:
                    addPathCandidate(location);
                    break;
            }
        }
Exemplo n.º 35
0
 public bool Equals(Location other)
 {
     return(other != null && LocationPath.Equals(other.LocationPath));
 }
Exemplo n.º 36
0
        // Returns a DetectedLocation that represents the chosen string
        public virtual List <DetectedLocationPathHolder> interpretPath(string interpret_me)
        {
            List <DetectedLocationPathHolder> return_me = new List <DetectedLocationPathHolder>();
            LocationPath new_location;

            if (ready)
            {
                // this needs to be able to interpret user paths too!
                foreach (KeyValuePair <EnvironmentVariable, EvFolder> variable in global.folders)
                {
                    if (variable.Value != null && variable.Value.Matches(interpret_me))
                    {
                        string path;
                        foreach (string folder in variable.Value.Folders)
                        {
                            if (interpret_me.ToLower().StartsWith(folder.ToLower()))
                            {
                                if (interpret_me.Length == folder.Length)
                                {
                                    path = "";
                                }
                                else
                                {
                                    path = interpret_me.Substring(folder.Length + 1);
                                }

                                new_location = new LocationPath(variable.Key, path);
                                return_me.AddRange(getPaths(new_location));
                            }
                        }
                    }
                }
                foreach (UserData user in this)
                {
                    foreach (KeyValuePair <EnvironmentVariable, EvFolder> variable in user.folders)
                    {
                        if (variable.Value != null && variable.Value.Matches(interpret_me))
                        {
                            string path;
                            foreach (string folder in variable.Value.Folders)
                            {
                                if (!interpret_me.StartsWith(folder))
                                {
                                    continue;
                                }

                                if (interpret_me.Length == folder.Length)
                                {
                                    path = "";
                                }
                                else
                                {
                                    path = interpret_me.Substring(folder.Length + 1);
                                }
                                new_location = new LocationPath(variable.Key, path);
                                return_me.AddRange(getPaths(new_location));
                            }
                        }
                    }
                }
            }
            return(return_me);
        }
Exemplo n.º 37
0
        public static LocationPath translateToVirtualStore(string path)
        {
            LocationPath virtualstore_info = new LocationPath(EnvironmentVariable.LocalAppData, Path.Combine("VirtualStore", path.Substring(2).Trim(Path.DirectorySeparatorChar)));

            return virtualstore_info;
        }
Exemplo n.º 38
0
        protected override void doWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            base.doWork(sender, e);

            path_candidates = new SimpleModel<LocationPath>();
            user_candidates = new SimpleModel<string>();

            ProgressHandler.state = ProgressState.Indeterminate;
            try {
                if (archive == null) {
                }
            } catch (Exception ex) {
                TranslatingMessageHandler.SendException(ex);
            }

            if (ArgArchives.Count > 0)
                archive = new Archive(new FileInfo(ArgArchives.Dequeue()));

            if (archive == null)
                throw new TranslateableException("NoRestoreFileSelected");

            TranslatingProgressHandler.setTranslatedMessage("DetectingGameForRestoration");

            if (!archive.Exists)
                throw new TranslateableException("FileNotFound", archive.ArchivePath);

            GameID selected_game = archive.id.Game;
            string backup_owner = archive.id.Owner;
            string archive_type = archive.id.Type;

            try {
                game_data = Games.detectGame(selected_game);
            } catch (Exception ex) {
                TranslatingMessageHandler.SendException(ex);
            }

            NotifyPropertyChanged("GameNotDetected");

            if (game_data != null) {
                // This adds hypothetical locations
                foreach (LocationPath location in game_data.Locations.Paths) {
                    if (game_data.DetectionRequired)
                        break;

                    filterPathCandidates(location);
                }

                // This add already found locations
                foreach (DetectedLocationPathHolder location in game_data.DetectedLocations) {
                    location.IsSelected = true;
                    switch (location.EV) {
                        case EnvironmentVariable.ProgramFiles:
                        case EnvironmentVariable.ProgramFilesX86:
                            // This adds a fake VirtualStore folder, just in case
                            if (Core.locations.uac_enabled) {
                                DetectedLocationPathHolder temp = new DetectedLocationPathHolder(location, Core.locations.getFolder(EnvironmentVariable.LocalAppData, location.owner), location.owner);
                                temp.ReplacePath(Path.Combine("VirtualStore", location.FullDirPath.Substring(3)));
                                temp.EV = EnvironmentVariable.LocalAppData;
                                addPathCandidate(temp);
                            }
                            addPathCandidate(location);
                            break;
                        default:
                            addPathCandidate(location);
                            break;
                    }
                }

                //if (archive.id.Game.OS!=null&&archive.id.Game.OS.StartsWith("PS")) {

                //    foreach (string drive in Core.locations.ps.GetDriveCandidates()) {
                //        DetectedLocationPathHolder loc = new DetectedLocationPathHolder(EnvironmentVariable.Drive, drive, null);
                //            addPathCandidate(loc);
                //    }
                //}
            }

            if (archive.id.OriginalEV != EnvironmentVariable.None &&
                archive.id.OriginalRelativePath != null) {
                LocationPath path = new LocationPath(archive.id.OriginalEV, archive.id.OriginalRelativePath);
                filterPathCandidates(path);
            }

            if (archive.id.OriginalLocation != null) {
                DetectedLocations locs = Core.locations.interpretPath(archive.id.OriginalLocation);
                DetectedLocationPathHolder loc = locs.getMostAccurateLocation();
                if (loc != null) {
                    addPathCandidate(loc);
                }
            }

            if (path_candidates.Count == 1) {
                multiple_paths = false;
                NotifyPropertyChanged("only_path");
            } else if (path_candidates.Count > 1) {
                multiple_paths = true;
            } else {
                throw new TranslateableException("NoRestorePathsDetected", this.archive.id.ToString());
            }
        }
Exemplo n.º 39
0
        protected override DetectedLocations getPaths(LocationPath get_me)
        {
            DetectedLocations          return_me = new DetectedLocations();
            DirectoryInfo              test;
            DetectedLocationPathHolder add_me;

            switch (get_me.EV)
            {
            case EnvironmentVariable.InstallLocation:
                LocationPath temp    = new LocationPath(get_me);
                string[]     chopped = temp.Path.Split(Path.DirectorySeparatorChar);
                for (int i = 0; i < chopped.Length; i++)
                {
                    temp.ReplacePath(chopped[i]);
                    for (int j = i + 1; j < chopped.Length; j++)
                    {
                        temp.AppendPath(chopped[j]);
                    }
                    temp.EV = EnvironmentVariable.Drive;
                    return_me.AddRange(getPaths(temp));
                    temp.EV = EnvironmentVariable.AltSavePaths;
                    return_me.AddRange(getPaths(temp));
                }
                break;

            case EnvironmentVariable.AltSavePaths:
                foreach (AltPathHolder alt_path in Core.settings.save_paths)
                {
                    if (PermissionsHelper.isReadable(alt_path.path))
                    {
                        if (get_me.Path != null && get_me.Path.Length > 0)
                        {
                            test = new DirectoryInfo(Path.Combine(alt_path.path, get_me.Path));
                        }
                        else
                        {
                            test = new DirectoryInfo(alt_path.path);
                        }
                        if (test.Exists)
                        {
                            DetectedLocations locs = Core.locations.interpretPath(test.FullName);
                            foreach (DetectedLocationPathHolder loc in locs)
                            {
                                return_me.Add(loc);
                            }
                        }
                    }
                }
                break;

            case EnvironmentVariable.Drive:
                foreach (string drive in drives)
                {
                    if (get_me.Path != null && get_me.Path.Length > 0)
                    {
                        test = new DirectoryInfo(Path.Combine(drive, get_me.Path));
                    }
                    else
                    {
                        test = new DirectoryInfo(drive);
                    }
                    if (test.Exists)
                    {
                        add_me = new DetectedLocationPathHolder(get_me, drive, null);
                        return_me.Add(add_me);
                    }
                }
                break;

            default:
                return(base.getPaths(get_me));
            }
            return(return_me);
        }
Exemplo n.º 40
0
        public void addPathCandidate(LocationPath location)
        {
            // Checks if the provided path is the original archive path
            if (location is DetectedLocationPathHolder)
            {
                DetectedLocationPathHolder loc = location as DetectedLocationPathHolder;
                if (archive.id.OriginalLocation != null && archive.id.OriginalLocation.ToLower() == loc.FullDirPath.ToLower())
                {
                    loc.MatchesOriginalPath = true;
                }
            }

            // If path is a manuallly added path, we remove all other manual paths,
            // Then we don't compare further, since it doesn't matter
            if (location is ManualLocationPathHolder)
            {
                for (int i = 0; i < path_candidates.Count; i++)
                {
                    if (path_candidates[i] is ManualLocationPathHolder)
                    {
                        path_candidates.RemoveAt(i);
                    }
                }
                path_candidates.Insert(0, location);
                return;
            }


            if (location is DetectedLocationPathHolder)
            {
                // If the new path is a real, existant path
                DetectedLocationPathHolder loc = location as DetectedLocationPathHolder;
                for (int i = 0; i < path_candidates.Count; i++)
                {
                    if (path_candidates[i] is DetectedLocationPathHolder)
                    {
                        // If the present path is a real, detected path
                        DetectedLocationPathHolder path = path_candidates[i] as DetectedLocationPathHolder;
                        // We compare the absolute paths
                        if (path.FullDirPath.ToLower() == loc.FullDirPath.ToLower())
                        {
                            // If it's two real, detected paths that are the same location, we compare EVs
                            if (loc.EV > path.EV)
                            {
                                // If the new EV is better, then we replace the old one
                                path_candidates.RemoveAt(i);
                                path_candidates.AddWithSort(loc);
                            }
                            return;
                        }
                        else
                        {
                            // If the paths don't match, then we compare Ev-relative paths
                            if (path.FullRelativeDirPath.ToLower() == loc.FullRelativeDirPath.ToLower())
                            {
                                //if they're the same, then we compare for matching
                                if (loc.MatchesOriginalPath)
                                {
                                    path_candidates.RemoveAt(i);
                                    path_candidates.AddWithSort(loc);
                                }
                                return;
                            }
                        }
                    }
                    else
                    {
                        // If the existing path is an theoretical path path
                        LocationPath path = path_candidates[i];
                        if (loc.FullRelativeDirPath.ToLower() == path.FullRelativeDirPath.ToLower())
                        {
                            // If both paths are based on the same EV/path combo
                            // Then the real path supercedes the fake path
                            path_candidates.RemoveAt(i);
                            path_candidates.AddWithSort(loc);
                            return;
                        }
                        else
                        {
                            // Otherwise we don't do anything
                        }
                    }
                }
            }
            else
            {
                switch (location.EV)
                {
                case EnvironmentVariable.Drive:
                case EnvironmentVariable.ProgramFiles:
                case EnvironmentVariable.ProgramFilesX86:
                    return;
                }
                // If the new path is only a theoretical path
                for (int i = 0; i < path_candidates.Count; i++)
                {
                    LocationPath path = path_candidates[i];
                    if (path.FullRelativeDirPath.ToLower() == location.FullRelativeDirPath.ToLower())
                    {
                        // If the relative paths match we compare the EVs for the more accurate one
                        if (location.EV > path.EV)
                        {
                            // If the new path has a more accurate EV, we replace the old one
                            path_candidates.RemoveAt(i);
                            path_candidates.AddWithSort(location);
                        }
                        return;
                    }
                    else
                    {
                        // If the relative paths don't match, then they have nothign to do with eachother
                        // so we'll just let the test continue
                    }
                }
            }
            path_candidates.AddWithSort(location);
            return;
        }
Exemplo n.º 41
0
    void DrawPath()
    {
        LocationPath locationPath = (LocationPath)target;
        var          locations    = locationPath.locations;

        if (locations == null || locations.Length < 2)
        {
            return;
        }

        var viewScale = sceneViewScale.floatValue;

        var points = new Vector3[locations.Length];

        for (var i = 0; i < locations.Length; i++)
        {
            var loc = locations[i];
            points[i] = Vector3.Scale(loc.ToVector3(), new Vector3(viewScale, 1, viewScale));
        }


        //var points = curve.SamplePoints(100, p => getVec(p, curve.points[0]));
        var effscale = (1.0f + Mathf.Cos(viewScale * Mathf.PI / 2 - Mathf.PI));
        var s        = new Vector3(effscale, 1.0f, effscale);


        var newCPs = new Vector3[locationPath.locations.Length];

        for (var i = 0; i < locationPath.locations.Length; i++)
        {
            // ps.Add(locationPath.locations[i].ToVector3());

            var loc = locationPath.locations[i];
            var p   = Location.GetGameObjectPositionForLocation(
                new Vector3(),
                // new Transform(),
                locations[0],
                locations[i],
                true
                );
            Handles.color = Color.blue;
            Handles.SphereHandleCap(i, Vector3.Scale(p, s), Quaternion.identity, 0.4f, EventType.Repaint);
            Handles.Label(Vector3.Scale(p, s), loc.label == "" ? ("   Point " + i) : loc.label);
            newCPs[i] = Vector3.Scale(p, s);
        }

        Spline newPath = null;

        // new CatmullRomSpline(newCPs, 100, alpha.floatValue);

        if (((SplineType)splineType.enumValueIndex) == SplineType.CatmullromSpline)
        {
            newPath = new CatmullRomSpline(newCPs, 100, alpha.floatValue);
        }
        else
        {
            newPath = new LinearSpline(newCPs);
        }

        var newSample = newPath.SamplePoints(1000);

        for (var i = 0; i < (newSample.Length - 2); i++)
        {
            Handles.color = Color.green;
            Handles.DrawLine(newSample[i + 1], newSample[i]);
        }
    }
Exemplo n.º 42
0
        public void populateUsers(LocationPath location)
        {
            user_candidates.Clear();
            List<string> users = Core.locations.getUsers(location.EV);
            if (users.Count > 0 && location.EV != EnvironmentVariable.FlashShared) {
                user_needed = true;
                if (users.Count > 1) {
                    multiple_users = true;
                } else {
                    multiple_users = false;
                    NotifyPropertyChanged("only_user");
                }
                foreach (string user in users) {
                    user_candidates.AddWithSort(user);
                }
            } else {
                switch (location.EV) {
                    case EnvironmentVariable.AllUsersProfile:
                    case EnvironmentVariable.AltSavePaths:
                    case EnvironmentVariable.Drive:
                    case EnvironmentVariable.InstallLocation:
                    case EnvironmentVariable.None:
                    case EnvironmentVariable.ProgramFiles:
                    case EnvironmentVariable.ProgramFilesX86:
                    case EnvironmentVariable.PS3Export:
                    case EnvironmentVariable.PS3Save:
                    case EnvironmentVariable.PSPSave:
                    case EnvironmentVariable.Public:
                    case EnvironmentVariable.SteamCommon:
                    case EnvironmentVariable.SteamSourceMods:
                    case EnvironmentVariable.CommonApplicationData:
                    case EnvironmentVariable.UbisoftSaveStorage:
                    case EnvironmentVariable.FlashShared:
                        user_needed = false;
                        break;
                    default:
                        throw new TranslateableException("NoUsersForEV", location.EV.ToString());
                }

            }
        }
Exemplo n.º 43
0
 public string getAbsoluteRoot(LocationPath parse_me, string user)
 {
     foreach (KeyValuePair<HandlerType, ALocationHandler> handler in handlers) {
         string result = handler.Value.getAbsoluteRoot(parse_me, user);
         if (result != null)
             return result;
     }
     return null;
 }
Exemplo n.º 44
0
        protected override DetectedLocations getPaths(LocationPath get_me)
        {
            //if(get_me.rel_root!= EnvironmentVariable.Public)
            // return new List<DetectedLocationPathHolder>();
            DetectedLocations return_me = new DetectedLocations();
            DetectedLocationPathHolder add_me;
            DirectoryInfo test;
            switch (get_me.EV) {
                case EnvironmentVariable.InstallLocation:
                    LocationPath temp = new LocationPath(get_me);
                    string[] chopped = temp.Path.Split(Path.DirectorySeparatorChar);
                    for (int i = 0; i < chopped.Length; i++) {
                        temp.ReplacePath(chopped[i]);
                        for (int j = i + 1; j < chopped.Length; j++) {
                            temp.AppendPath(chopped[j]);
                        }
                        temp.EV = EnvironmentVariable.ProgramFiles;
                        return_me.AddRange(getPaths(temp));
                    }
                    return_me.AddRange(base.getPaths(get_me));
                    break;
                case EnvironmentVariable.ProgramFiles:
                case EnvironmentVariable.ProgramFilesX86:
                    // Always checks both the VirtualStore and the real Program Files,
                    // to make sure nothing is missed, especially in the case of old games
                    // that may or may not use the VirtualStore
                    if (!get_me.override_virtual_store && platform_version == "WindowsVista") {
                        LocationPath virtualstore_info = new LocationPath(get_me);
                        virtualstore_info.EV = EnvironmentVariable.LocalAppData;

                        if (x64) {
                            virtualstore_info.ReplacePath(Path.Combine("VirtualStore", global.getFolder(EnvironmentVariable.ProgramFilesX86).BaseFolder.Substring(3), virtualstore_info.Path));
                            return_me.AddRange(getPaths(virtualstore_info));
                            virtualstore_info = new LocationPath(get_me);
                            virtualstore_info.EV = EnvironmentVariable.LocalAppData;
                        }
                        virtualstore_info.ReplacePath(Path.Combine("VirtualStore", global.getFolder(EnvironmentVariable.ProgramFiles).BaseFolder.Substring(3), virtualstore_info.Path));
                        return_me.AddRange(getPaths(virtualstore_info));
                    }

                    if (x64) {
                        if (get_me.Path != null && get_me.Path.Length > 0)
                            test = new DirectoryInfo(Path.Combine(global.getFolder(EnvironmentVariable.ProgramFilesX86).BaseFolder, get_me.Path));
                        else
                            test = new DirectoryInfo(global.getFolder(EnvironmentVariable.ProgramFilesX86).BaseFolder);
                        if (test.Exists) {
                            add_me = new DetectedLocationPathHolder(get_me, global.getFolder(EnvironmentVariable.ProgramFilesX86).BaseFolder, null);
                            return_me.Add(add_me);
                        }
                    }

                    if (get_me.Path != null && get_me.Path.Length > 0)
                        test = new DirectoryInfo(Path.Combine(global.getFolder(EnvironmentVariable.ProgramFiles).BaseFolder, get_me.Path));
                    else
                        test = new DirectoryInfo(global.getFolder(EnvironmentVariable.ProgramFiles).BaseFolder);

                    if (test.Exists) {
                        add_me = new DetectedLocationPathHolder(get_me, global.getFolder(EnvironmentVariable.ProgramFiles).BaseFolder, null);
                        return_me.Add(add_me);
                    }
                    break;
                default:
                    return base.getPaths(get_me);
            }
            return return_me;
        }
Exemplo n.º 45
0
        protected override void doWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            base.doWork(sender, e);

            path_candidates = new SimpleModel <LocationPath>();
            user_candidates = new SimpleModel <string>();

            ProgressHandler.state = ProgressState.Indeterminate;
            try {
                if (archive == null)
                {
                }
            } catch (Exception ex) {
                TranslatingMessageHandler.SendException(ex);
            }


            if (ArgArchives.Count > 0)
            {
                archive = new Archive(new FileInfo(ArgArchives.Dequeue()));
            }

            if (archive == null)
            {
                throw new TranslateableException("NoRestoreFileSelected");
            }

            TranslatingProgressHandler.setTranslatedMessage("DetectingGameForRestoration");

            if (!archive.Exists)
            {
                throw new TranslateableException("FileNotFound", archive.ArchivePath);
            }

            GameID selected_game = archive.id.Game;
            string backup_owner  = archive.id.Owner;
            string archive_type  = archive.id.Type;


            try {
                game_data = Games.detectGame(selected_game);
            } catch (Exception ex) {
                TranslatingMessageHandler.SendException(ex);
            }

            NotifyPropertyChanged("GameNotDetected");


            if (game_data != null)
            {
                // This adds hypothetical locations
                foreach (LocationPath location in game_data.Locations.Paths)
                {
                    if (game_data.DetectionRequired)
                    {
                        break;
                    }

                    filterPathCandidates(location);
                }


                // This add already found locations
                foreach (DetectedLocationPathHolder location in game_data.DetectedLocations)
                {
                    location.IsSelected = true;
                    switch (location.EV)
                    {
                    case EnvironmentVariable.ProgramFiles:
                    case EnvironmentVariable.ProgramFilesX86:
                        // This adds a fake VirtualStore folder, just in case
                        if (Core.locations.uac_enabled)
                        {
                            DetectedLocationPathHolder temp = new DetectedLocationPathHolder(location, Core.locations.getFolder(EnvironmentVariable.LocalAppData, location.owner), location.owner);
                            temp.ReplacePath(Path.Combine("VirtualStore", location.FullDirPath.Substring(3)));
                            temp.EV = EnvironmentVariable.LocalAppData;
                            addPathCandidate(temp);
                        }
                        addPathCandidate(location);
                        break;

                    default:
                        addPathCandidate(location);
                        break;
                    }
                }

                //if (archive.id.Game.OS!=null&&archive.id.Game.OS.StartsWith("PS")) {

                //    foreach (string drive in Core.locations.ps.GetDriveCandidates()) {
                //        DetectedLocationPathHolder loc = new DetectedLocationPathHolder(EnvironmentVariable.Drive, drive, null);
                //            addPathCandidate(loc);
                //    }
                //}
            }

            if (archive.id.OriginalEV != EnvironmentVariable.None &&
                archive.id.OriginalRelativePath != null)
            {
                LocationPath path = new LocationPath(archive.id.OriginalEV, archive.id.OriginalRelativePath);
                filterPathCandidates(path);
            }

            if (archive.id.OriginalLocation != null)
            {
                DetectedLocations          locs = Core.locations.interpretPath(archive.id.OriginalLocation);
                DetectedLocationPathHolder loc  = locs.getMostAccurateLocation();
                if (loc != null)
                {
                    addPathCandidate(loc);
                }
            }


            if (path_candidates.Count == 1)
            {
                multiple_paths = false;
                NotifyPropertyChanged("only_path");
            }
            else if (path_candidates.Count > 1)
            {
                multiple_paths = true;
            }
            else
            {
                throw new TranslateableException("NoRestorePathsDetected", this.archive.id.ToString());
            }
        }
Exemplo n.º 46
0
 public override int GetHashCode()
 {
     return(LocationPath.GetHashCode());
 }
Exemplo n.º 47
0
 public void restoreBackup(LocationPath path, string user, RunWorkerCompletedEventHandler when_done)
 {
     string target;
     if (path is ManualLocationPathHolder) {
         ManualLocationPathHolder loc = path as ManualLocationPathHolder;
         target = loc.ManualPath;
     } else if (path is DetectedLocationPathHolder) {
         DetectedLocationPathHolder loc = path as DetectedLocationPathHolder;
         target = loc.FullDirPath;
     } else {
         target = Core.locations.getAbsolutePath(path, user);
     }
     restoreBackup(target, when_done);
 }