internal static List <pSprite> ShowModSprites(Mods mods, Vector2 position, float scale, string tag = "") { List <pSprite> sprites = new List <pSprite>(); int time = 0; float dep = 0; foreach (Mods m in Enum.GetValues(typeof(Mods))) { if (ModManager.CheckActive(mods, m)) { if (m == Mods.DoubleTime && ModManager.CheckActive(mods, Mods.Nightcore)) { continue; } if (m == Mods.SuddenDeath && ModManager.CheckActive(mods, Mods.Perfect)) { continue; } pSprite p = new pSprite(TextureManager.Load(@"selection-mod-" + m.ToString().ToLower()), Fields.TopLeft, Origins.Centre, Clocks.Game, position, 0.975F + dep, true, Color.TransparentWhite); p.Tag = tag; p.Transformations.Add(new Transformation(TransformationType.Scale, 2 * scale, 1 * scale, GameBase.Time + time, GameBase.Time + time + 400) { Easing = EasingTypes.Out }); p.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, GameBase.Time + time, GameBase.Time + time + 400) { Easing = EasingTypes.Out }); sprites.Add(p); time += 200; dep += 0.00001f; position.X += 20 * scale; } } return(sprites); }
private static void databaseDeserialize() { DatabaseHelper.Read(DATABASE_FILENAME, sr => { DatabaseVersion = sr.ReadInt32(); int count = sr.ReadInt32(); for (int i = 0; i < count; i++) { string checksum = sr.ReadString(); int scoreCount = sr.ReadInt32(); List <Score> list = new List <Score>(scoreCount); for (int j = 0; j < scoreCount; j++) { Score s = ScoreFactory.Create((PlayModes)sr.ReadByte(), null); s.ReadHeaderFromStream(sr); if (ModManager.CheckActive(s.EnabledMods, Mods.Target)) { s = new ScoreTarget(s); } s.ReadFromStream(sr); list.Add(s); } if (BeatmapManager.GetBeatmapByChecksum(checksum) != null) { LocalScores.Add(checksum, list); } else { foreach (Score s in list) { s.PurgeReplay(); } } } }); }
public static Score ReadReplayFromFile(string filename, bool handlePickup) { //Make sure the score manager is already initialized. InitializeScoreManager(); Score inScore = null; bool success = false; try { using (Stream stream = File.Open(filename, FileMode.Open)) { SerializationReader sr = new SerializationReader(stream); inScore = ScoreFactory.Create((PlayModes)sr.ReadByte(), null); inScore.ReadHeaderFromStream(sr); if (ModManager.CheckActive(inScore.EnabledMods, Mods.Target)) { inScore = new ScoreTarget(inScore); } inScore.ReadFromStream(sr); if (inScore.Date < DateTime.UtcNow + new TimeSpan(365 * 5, 0, 0, 0)) { success = true; } } } catch { } if (!success) { try { using (Stream stream = File.Open(filename, FileMode.Open)) inScore = (Score)DynamicDeserializer.Deserialize(stream); } catch { NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.ScoreManager_ReplayCorrupt)); return(null); } } if (inScore == null) { NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.ScoreManager_ReplayCorrupt)); return(null); } if (inScore.Date.Year > 2050 || inScore.Date == DateTime.MinValue) { string[] split = filename.Split('-'); if (split.Length > 1) { long outfiletime = 0; if (long.TryParse(split[1].Replace(@".osr", string.Empty), out outfiletime)) { inScore.Date = DateTime.FromFileTimeUtc(outfiletime); } } } if (inScore.Date.Year > 2050) { //this score is TOTALLY f****d. File.Delete(filename); NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.ScoreManager_ReplayCorrupt)); return(null); } if (BeatmapManager.GetBeatmapByChecksum(inScore.FileChecksum) == null) { //attempt pickup. if (handlePickup) { OsuDirect.HandlePickup(inScore.FileChecksum, null, delegate { NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.ScoreManager_DontHaveBeatmap)); }); } return(null); } InsertScore(inScore, false); return(inScore); }