예제 #1
0
파일: Menu.cs 프로젝트: KHCmaster/PPD
        public override void SceneStackPoped(Dictionary <string, object> param)
        {
            switch (lastPlayState)
            {
            case LastPlayState.Play:
                if (param.ContainsKey("PerfectTrialSucceess") && (bool)param["PerfectTrialSucceess"])
                {
                    var gameUtility = (PPDGameUtility)param["GameUtility"];
                    PerfectTrialCache.Instance.AddPerfectTrial(CryptographyUtility.Getx2Encoding(
                                                                   gameUtility.SongInformation.GetScoreHash(gameUtility.Difficulty)));
                    ssm.SelectedSongInformation.UpdatePerfectTrialInfo();
                }
                allowcommand = true;
                cc.Next();
                mss.DisapperFinish += cc.Show;
                fm.RemoveFocus();
                cc.Vanish();
                menuMovie.Seek(ssm.SelectedSongInformation.SongInfo.ThumbStartTime);
                menuMovie.FadeIn();
                sic.UpdateResult();
                sic.UpdatePerfectTrials();
                goto default;

            default:
                menuMovie.Play();
                break;
            }
            menuMovie.CheckLoopAvailable = true;
            goToPlay    = false;
            black.Alpha = 0;
        }
예제 #2
0
        private bool CheckSameScore()
        {
            var  hashs  = new Dictionary <string, PPDEditor.AvailableDifficulty>();
            var  sha256 = new SHA256Managed();
            bool found  = false;

            foreach (AvailableDifficulty difficulty in EditorForm.DifficultyArray)
            {
                if (difficulty == AvailableDifficulty.None)
                {
                    continue;
                }
                if ((PublishDifficulty & difficulty) == difficulty)
                {
                    var filePath = Path.Combine(WindowUtility.MainForm.CurrentProjectDir, difficulty + ".ppd");
                    var hash     = CryptographyUtility.Getx2Encoding(sha256.ComputeHash(File.ReadAllBytes(filePath)));
                    if (hashs.ContainsKey(hash))
                    {
                        MessageBox.Show(String.Format(Utility.Language["ScoreHashCollision"], hashs[hash], difficulty));
                        found = true;
                    }
                    else
                    {
                        hashs.Add(hash, difficulty);
                    }
                }
            }
            return(!found);
        }
예제 #3
0
        void updateTimerCallBack(int obj)
        {
            var updateExecutor = new UpdateRoomInfoExecutor(ContextManager.WebManager, userList.Count,
                                                            currentSong != null ? CryptographyUtility.Getx2Encoding(currentSong.Hash) : "");

            updateExecutor.Finished += UpdateExecutor_Finished;
            updateExecutor.Start();
        }
예제 #4
0
 /// <summary>
 /// 難易度を取得します。
 /// </summary>
 /// <param name="scoreHash">譜面ハッシュ。</param>
 /// <returns>難易度</returns>
 public Difficulty GetDifficulty(string scoreHash)
 {
     if (EasyHash != null && CryptographyUtility.Getx2Encoding(EasyHash) == scoreHash)
     {
         return(PPDFrameworkCore.Difficulty.Easy);
     }
     if (NormalHash != null && CryptographyUtility.Getx2Encoding(NormalHash) == scoreHash)
     {
         return(PPDFrameworkCore.Difficulty.Normal);
     }
     if (HardHash != null && CryptographyUtility.Getx2Encoding(HardHash) == scoreHash)
     {
         return(PPDFrameworkCore.Difficulty.Hard);
     }
     if (ExtremeHash != null && CryptographyUtility.Getx2Encoding(ExtremeHash) == scoreHash)
     {
         return(PPDFrameworkCore.Difficulty.Extreme);
     }
     return(PPDFrameworkCore.Difficulty.Other);
 }
예제 #5
0
 private void UpdateInfo()
 {
     using (PackReader reader = new PackReader(ModPath))
     {
         DisplayName                     = ReadString(reader, "Mod\\DisplayName");
         AuthorName                      = ReadString(reader, "Mod\\AuthorName");
         Version                         = ReadString(reader, "Mod\\Version");
         FlowScriptVersion               = ReadVersion(reader, "Mod\\FlowScriptVersion");
         FlowScriptBasicVersion          = ReadVersion(reader, "Mod\\FlowScriptBasicVersion");
         FlowScriptPPDVersion            = ReadVersion(reader, "Mod\\FlowScriptPPDVersion");
         FlowScriptSharpDXVersion        = ReadVersion(reader, "Mod\\FlowScriptSharpDXVersion");
         FlowScriptBasicExtensionVersion = ReadVersion(reader, "Mod\\FlowScriptBasicExtensionVersion");
         FlowScriptDataVersion           = ReadVersion(reader, "Mod\\FlowScriptDataVersion");
         AnalyzeMod(reader);
     }
     using (FileStream fs = File.Open(ModPath, FileMode.Open))
     {
         byte[] data = new byte[fs.Length];
         fs.Read(data, 0, data.Length);
         FileHash       = CryptographyUtility.CalcSha256Hash(data);
         FileHashString = CryptographyUtility.Getx2Encoding(FileHash);
     }
 }
예제 #6
0
 public void UpdatePerfectTrialInfo()
 {
     if (SongInfo != null && SongInfo.IsPPDSong)
     {
         int totalCount = 0;
         for (int i = 0; i < 4; i++)
         {
             if (SongInfo.Difficulty.HasFlag((SongInformation.AvailableDifficulty)(1 << i)))
             {
                 var str = CryptographyUtility.Getx2Encoding(SongInfo.GetScoreHash((PPDFrameworkCore.Difficulty)i));
                 perfectTrials[i] = PerfectTrialCache.Instance.IsPerfect(str);
                 totalCount++;
             }
         }
         if (totalCount == 0)
         {
             PerfectRatio = 0;
         }
         else
         {
             PerfectRatio = perfectTrials.Count(p => p) / (float)totalCount;
         }
     }
 }
예제 #7
0
        protected override void OnBeforeInitialize()
        {
            base.OnBeforeInitialize();

            if (gameUtility.RivalGhost)
            {
                var newGameUtility = new PPDGameUtility
                {
                    SongInformation = gameUtility.SongInformation,
                    Difficulty      = gameUtility.Difficulty,
                    DifficultString = gameUtility.DifficultString,
                    Profile         = ProfileManager.Instance.Default,
                    SpeedScale      = 1,
                    GodMode         = true,
                    MuteSE          = true
                };
                using (var disposable = Sound.Disable())
                {
                    var reason = WebManager.Instance.GetGhost(CryptographyUtility.Getx2Encoding(gameUtility.SongInformation.GetScoreHash(gameUtility.Difficulty)),
                                                              gameUtility.RivalGhostCount, out GhostInfo[] ghosts);
                    if (reason == ErrorReason.OK)
                    {
                        var games = new MainGameComponent[ghosts.Length];
                        for (var i = 0; i < games.Length; i++)
                        {
                            games[i] = new MainGameComponent(device, GameHost, ResourceManager, Sound, this, newGameUtility,
                                                             null, (MarkImagePathsBase)Param["MarkImagePath"], null, null, MainGameConfigBase.Default, startTime, mmStartTime);
                            games[i].Initialize(false, true);
                        }
                        userScoreListComponent = new UserScoreListComponent(device, ResourceManager)
                        {
                            Position = new SharpDX.Vector2(680, 45)
                        };

                        var ghostInfo = new Dictionary <GhostInfo, GhostFrame[]>();
                        var actions   = new Action[] {
                            () => {
                                var progresses      = new int[ghosts.Length];
                                var prevAllProgress = 0;
                                Action <int, int> allProgressCallback = (i, p) =>
                                {
                                    progresses[i] = p;
                                    var allProgress = progresses.Sum() / ghosts.Length;
                                    if (prevAllProgress != allProgress)
                                    {
                                        GameHost.SendToLoading(new Dictionary <string, object>
                                        {
                                            { "Progress", allProgress }
                                        });
                                        prevAllProgress = allProgress;
                                    }
                                };
                                Parallel.For(0, ghosts.Length, new ParallelOptions {
                                    MaxDegreeOfParallelism = Environment.ProcessorCount
                                }, i =>
                                {
                                    var ghost = ghosts[i];
                                    var tempMainGameComponent     = games[i];
                                    var prevProgress              = 0;
                                    Action <int> progressCallback = p =>
                                    {
                                        if (prevProgress != p)
                                        {
                                            allProgressCallback(i, p);
                                            prevProgress = p;
                                        }
                                    };
                                    var ghostFrame = tempMainGameComponent.GetGhostFrames(ghost.ReplayData, progressCallback);
                                    lock (ghostInfo)
                                    {
                                        ghostInfo.Add(ghost, ghostFrame);
                                    }
                                });
                            },
                            () => {
                                InitializeUserList(ghosts);
                            }
                        };
                        Parallel.ForEach(actions, new ParallelOptions {
                            MaxDegreeOfParallelism = Environment.ProcessorCount
                        }, a => a());
                        ghostPlayInfos = ghostInfo.Select(p =>
                                                          new GhostPlayInfo(
                                                              userScoreListComponent.Players.FirstOrDefault(pi => !pi.UserPlayState.User.IsSelf && pi.UserPlayState.User.AccountId == p.Key.AccountId).UserPlayState,
                                                              p.Value)).ToArray();
                    }
                }
            }
        }