private void initializeSprites() { SkinManager.CreateUserSkin(); GameBase.TransitionManager.ClearBackground(false); BeatmapTreeItem.LoadSkinElements(); treeManager = new BeatmapTreeManager(GameBase.Instance); treeManager.SpriteManagerPanels.SetVisibleArea(new RectangleF(0, 0, 1280, 720) / GameBase.WindowManager.Ratio); treeManager.OnEndRandom += endRandom; pTexture backgroundTex = TextureManager.Load(Path.Combine(Tournament.Tournament.SkinDirectory, @"drawings-background.jpg"), SkinSource.Skin); backgroundTex = backgroundTex ?? TextureManager.Load(@"drawings-background", SkinSource.Skin); backgroundTex = backgroundTex ?? TextureManager.Load(@"menu-background", SkinSource.Osu); pSprite p; baseSpriteManager.Add(p = new pSprite(backgroundTex, Fields.TopLeft, Origins.TopLeft, Clocks.Game, Vector2.Zero, 0f, true, Color.White)); p.Scale = Math.Max(1280f / GameBase.WindowManager.Ratio / p.Width, 720f / GameBase.WindowManager.Ratio / p.Height) * 1.6f; int x = GameBase.WindowManager.WidthScaled - 200; int y = 380; baseSpriteManager.Add((randButton = new pButton(@"Begin random", new Vector2(x, y), new Vector2(80, 15), 1f, Color.YellowGreen, delegate { if (treeManager.IsRandomActive) { RandomMultiple = 1.3f; randButton.Text.Text = @"Begin random"; } else { if (!canAddTeam) { return; } if (treeManager.beatmapSetVisibleCount == 0) { return; } startRandom(); if (treeManager.beatmapVisibleCount == 1) { endRandom(); return; } RandomMultiple = 1f; treeManager.StartRandom(); randButton.Text.Text = @"End random"; } })).SpriteCollection); y += 16; baseSpriteManager.Add(new pButton(@"Quick-add current", new Vector2(x, y), new Vector2(80, 15), 1f, Color.YellowGreen, delegate { if (treeManager.beatmapSetVisibleCount == 0) { return; } if (treeManager.IsRandomActive) { return; } if (!firstRandom) { startRandom(); } else { endRandom(); firstRandom = false; startRandom(); } firstRandom = true; }, true, false, 10).SpriteCollection); y += 16; baseSpriteManager.Add(new pButton(@"Reload teams", new Vector2(x, y), new Vector2(80, 15), 1f, Color.YellowGreen, delegate { reload(); }).SpriteCollection); y += 16; baseSpriteManager.Add(new pButton(@"Reset", new Vector2(x, y), new Vector2(80, 15), 1f, Color.Red, delegate { if (TopMostMessageBox.Show("Are you sure you want to reset the teams?", "Reset teams", MessageBoxButtons.OKCancel) == DialogResult.OK) { reset(); } }).SpriteCollection); y += 16; baseSpriteManager.Add(new pButton(@"Exit", new Vector2(x, y), new Vector2(80, 15), 1f, Color.Red, delegate { GameBase.BeginExit(); }).SpriteCollection); for (int i = 0; i < groupCount; i++) { groups.Add(new Group(spriteManagerAbove, i)); } }
public override void Update(GameTime gameTime) { if (!BanchoClient.Connected && GameBase.FadeState == FadeStates.Idle) { GameBase.ChangeMode(Modes.Menu); GameBase.ShowMessage("Multiplayer will not work unless Bancho is connected!"); } if (Match == null) { if (GameBase.FadeState == FadeStates.Idle) { GameBase.ChangeMode(Modes.Menu); } return; } if (GameBase.FadeState == FadeStates.FadeOut) { return; } if (!paused && AudioEngine.AudioState == AudioEngine.AudioStates.Stopped && GameBase.FadeState == FadeStates.Idle && BeatmapManager.Current != null) { AudioEngine.LoadAndPreviewMp3(BeatmapManager.Current.AudioFilename, true); paused = false; } if (UpdatePending) { int uid = Match.findPlayerFromId(GameBase.User.Id); if (uid < 0) { LeaveGame(); return; } detailsGameName.Box.Text = Match.gameName; if (Match.slotReadyCount == Match.slotUsedCount != allReady) { allReady = Match.slotReadyCount == Match.slotUsedCount; if (allReady) { AudioEngine.PlaySample("match-confirm"); } } if (allReady && IsHost && Match.slotReadyCount > 1) { buttonStart.Text.Text = "Start Game!"; } else if (Match.slotStatus[uid] == SlotStatus.NotReady) { if (buttonStart.Text.Text != "Ready!") { buttonStart.Text.Text = "Ready!"; AudioEngine.PlaySample("match-notready"); } } else { if (buttonStart.Text.Text != "Not Ready") { buttonStart.Text.Text = "Not Ready"; AudioEngine.PlaySample("match-ready"); } } for (int i = 0; i < 8; i++) { if ((Match.slotStatus[i] & SlotStatus.CompHasPlayer) > 0) { User u = BanchoClient.GetUserById(Match.slotId[i]); if (u == null) { continue; } slotText[i].Text = u.Name; slotTextInfo[i].Text = string.Format("Acc:{0:0.00}%\nRank:#{1}", u.Accuracy, u.Rank); slotLock[i].ToolTip = ""; slotLock[i].Texture = content.Load <Texture2D>(IsHost ? "lobby-boot" : "lobby-unlock"); slotLock[i].ToolTip = "Kick this player and lock the slot."; } else { slotTextInfo[i].Text = ""; } switch (Match.slotStatus[i]) { case SlotStatus.Open: slotText[i].Text = "Open"; slotLock[i].Texture = content.Load <Texture2D>("lobby-unlock"); slotLock[i].ToolTip = "Lock this slot."; slotStatus[i].StartColour = Color.White; slotBackground[i].StartColour = Color.White; break; case SlotStatus.Locked: slotText[i].Text = "Locked"; slotLock[i].Texture = content.Load <Texture2D>("lobby-lock"); slotLock[i].ToolTip = "Unlock this slot."; slotStatus[i].StartColour = Color.Black; slotBackground[i].StartColour = Color.Black; break; case SlotStatus.NotReady: slotStatus[i].StartColour = Color.White; slotBackground[i].StartColour = Color.White; break; case SlotStatus.Ready: slotStatus[i].StartColour = Color.YellowGreen; slotBackground[i].StartColour = Color.YellowGreen; break; case SlotStatus.NoMap: slotStatus[i].StartColour = Color.OrangeRed; slotBackground[i].StartColour = Color.OrangeRed; slotText[i].Text += " [no map]"; break; } } UpdatePending = false; if (SongChangePending) { Beatmap map = BeatmapManager.GetBeatmapByChecksum(Match.beatmapChecksum); if (map != null) { BeatmapManager.ProcessHeaders(map); } hasSong = map != null && map.BeatmapChecksum == Match.beatmapChecksum; if (treeItem != null) { treeItem.SpriteCollection.ForEach(s => { s.FadeOut(400); s.AlwaysDraw = false; }); } if (!hasSong) { buttonStart.Hide(); BeatmapManager.Current = BeatmapManager.GetBeatmapById(Match.beatmapId); AudioEngine.Stop(); Beatmap bm = new Beatmap(); bm.SortTitle = Match.beatmapName; bm.BeatmapPresent = true; bm.Title = "h"; bm.Creator = BeatmapManager.Current != null ? "Click here to update this map to the latest" : Match.beatmapId > 0 ? "Click to download this map" : "You don't have this map"; treeItem = new BeatmapTreeItem(bm, 0, null); treeItem.SpriteCollection[0].StartColour = Color.OrangeRed; if (Match.beatmapId > 0) { treeItem.SpriteCollection[0].IsClickable = true; treeItem.SpriteCollection[0].OnClick += DownloadMap; treeItem.SpriteCollection[0].HoverEffect = new Transformation(treeItem.SpriteCollection[0].StartColour, Color.YellowGreen, 0, 100); } else { treeItem.SpriteCollection[0].IsClickable = false; } BanchoClient.SendRequest(RequestType.Osu_MatchNoBeatmap, null); ((pText)treeItem.SpriteCollection[2]).TextBold = true; } else { if (Match.slotStatus[uid] == SlotStatus.NoMap) { BanchoClient.SendRequest(RequestType.Osu_MatchHasBeatmap, null); } buttonStart.Show(); BeatmapManager.Current = map; treeItem = new BeatmapTreeItem(BeatmapManager.Current, 0, null); treeItem.SpriteCollection[1].Text = BeatmapManager.Current.DisplayTitle; if (!IsHost) { treeItem.SpriteCollection[0].IsClickable = false; } treeItem.SpriteCollection[0].OnClick += OnSelectBeatmap; treeItem.SpriteCollection[0].HoverEffect = new Transformation(treeItem.SpriteCollection[0].StartColour, Color.Orange, 0, 100); } if (map != null) { AudioEngine.LoadAndPreviewMp3(map.AudioFilename, true); paused = false; } treeItem.SpriteCollection.ForEach( delegate(pSprite s) { s.CurrentPosition = new Vector2(600, 165); s.MoveTo(new Vector2(300, 165), 500, EasingTypes.In); }); spriteManager.Add(treeItem.SpriteCollection); //detailsBeatmap.Text = "Beatmap: " + Match.beatmapName; SongChangePending = false; } if (HostChangePending) { SetHost(); } } if (ModChangePending) { ModChangePending = false; ModManager.ModStatus = Match.activeMods | (ModManager.ModStatus & Mods.NoVideo); modSprites.ForEach( delegate(pSprite s) { s.FadeOut(400); s.MoveToRelative(new Vector2(0, 20), 400, EasingTypes.Out); s.AlwaysDraw = false; }); modSprites.Clear(); int time = 0; float dep = 0; int x = 330; foreach (Mods m in Enum.GetValues(typeof(Mods))) { if (ModManager.CheckActive(ModManager.ModStatus, m)) { Transformation t2 = new Transformation(TransformationType.Scale, 2, 1, GameBase.Time + time, GameBase.Time + time + 400); Transformation t3 = new Transformation(TransformationType.Fade, 0, 1, GameBase.Time + time, GameBase.Time + time + 400); t2.Easing = EasingTypes.In; t3.Easing = EasingTypes.In; pSprite p = new pSprite(SkinManager.Load("selection-mod-" + m.ToString().ToLower()), FieldTypes.Window, OriginTypes.Centre, ClockTypes.Game, new Vector2(x, 250), 0.92F + dep, true, Color.TransparentWhite); p.Transformations.Add(t2); p.Transformations.Add(t3); spriteManager.Add(p); modSprites.Add(p); time += 200; dep += 0.00001f; x += 20; } } //detailsMods.Text = "Mods: " + ModManager.Format(ModManager.ModStatus, true); } base.Update(gameTime); }