Exemplo n.º 1
0
        public static bool TryParseUserId(string entry, out UserIdMode userIdMode)
        {
            //check is steam profile url
            Regex steamProfileUrl = new Regex(@"(https|http)://(www.)?steamcommunity.com/profiles/(\w+)",
                                              RegexOptions.Compiled & RegexOptions.IgnoreCase);

            //check is steam64 id
            Regex steamId64 = new Regex(@"\d{17}");

            //check is game profile id
            Regex gameProfileId = new Regex(@"\d{3,}");

            if (steamProfileUrl.IsMatch(entry))
            {
                userIdMode = UserIdMode.SteamProfileURL;
                return(true);
            }

            if (steamId64.IsMatch(entry))
            {
                userIdMode = UserIdMode.SteamId64;
                return(true);
            }

            if (gameProfileId.IsMatch(entry))
            {
                userIdMode = UserIdMode.GameProfileId;
                return(true);
            }

            userIdMode = UserIdMode.Invalid;
            return(false);
        }
Exemplo n.º 2
0
 internal DetectionResult(
     DetectionOperationResult operationResult,
     string userId,
     UserIdMode userIdMode
     )
 {
     OperationResult = operationResult;
     UserId          = userId;
     UserIdMode      = userIdMode;
 }
Exemplo n.º 3
0
        public void UserIdChangedHandler(string entry)
        {
            if (!(UserIdValidator.TryParseUserId(entry, out UserIdMode userIdMode)))
            {
                this.detectedUserIdMode = UserIdMode.Invalid;
                return;
            }

            userId = entry;

            detectedUserIdMode = userIdMode;
            UpdateUserIdDescription();
            UpdateCanContinue();
        }
Exemplo n.º 4
0
        public DetectionResult DetectUserId()
        {
            string userFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            string aoeFolderPath  = Path.Combine(userFolderPath, "Games", "Age of Empires 2 DE");

            if (!Directory.Exists(aoeFolderPath))
            {
                return(new DetectionResult(DetectionOperationResult.UnableToDetectUserId, null, UserIdMode.Invalid));
            }

            string     detectedId   = null;
            int        detectedIds  = 0;
            UserIdMode detectedMode = UserIdMode.Invalid;

            foreach (var dir in Directory.GetDirectories(aoeFolderPath, "*", SearchOption.TopDirectoryOnly))
            {
                var dirToTest = new DirectoryInfo(dir).Name;

                UserIdMode tempMode = UserIdMode.Invalid;

                if (UserIdValidator.TryParseUserId(dirToTest, out tempMode))
                {
                    //todo: add windows store support
                    if (tempMode == UserIdMode.SteamId64)
                    {
                        detectedMode = tempMode;
                        detectedIds++;
                        detectedId = dirToTest;
                    }
                }
            }

            //make sure detect id is in correct format
            //todo: add windows store support
            if (detectedMode != UserIdMode.SteamId64)
            {
                return(new DetectionResult(DetectionOperationResult.UnableToDetectUserId, null, UserIdMode.Invalid));
            }

            //todo: add array support for multiple ids
            if (detectedIds > 1)
            {
                return(new DetectionResult(DetectionOperationResult.MultipleUserIdsDetected, null, UserIdMode.Invalid));
            }

            return(new DetectionResult(DetectionOperationResult.UserSteamIdDetected, detectedId, detectedMode));
        }
Exemplo n.º 5
0
        //IUserIdDetectionService UserIdDetectionService { get; }

        public InitialConfigurationViewModel(
            IEventAggregator eventAggregator,
            IRegionManager regionManager,
            IStorageService storageService,
            IDataService userRankService,
            ILogService logService,
            IApplicationCommands applicationCommands//,
            //IUserIdDetectionService userIdDetectionService
            )
        {
            EventAggregator     = eventAggregator;
            RegionManager       = regionManager;
            StorageService      = storageService;
            UserRankService     = userRankService;
            LogService          = logService;
            ApplicationCommands = applicationCommands;
            //UserIdDetectionService = userIdDetectionService;

            EventAggregator.GetEvent <UserIdChangedEvent>().Subscribe(UserIdChangedHandler);

            ConfigurationMessage = "To setup app ente:\n - Your steam ID 64 (for Steam game version)";
            //ConfigurationMessage = "To setup app enter one of the following:\n - Your steam ID 64 (for Steam game version)\n - Your game profile ID(for Windows Store game version)";

            ContinueCommand = new DelegateCommand(ContinueClicked);

            detectedUserIdMode = UserIdMode.Invalid;

            //TryDetectUserId(); //detection fully moved into InitialConfiguration
            UpdateCanContinue();

            //if auto detected user id then instant navigate to appStateInfo
            //if (detectedUserIdMode == UserIdMode.SteamId64)
            //{
            //    ContinueClicked(); //trigger confirmation
            //}
        }