internal TournamentLobby(Tournament tournament, SpriteManager spriteManager, float depth) { this.tournament = tournament; Vector2 pos = tournament.ControlPanelLocation; pText tmp; spriteManager.Add(tmp = new pText(LocalisationManager.GetString(OsuString.Tournament_MakeAMultiplayerRoomWithFormat), 10, new Vector2(0, pos.Y), depth, true, Color.White)); pos.Y += (int)tmp.MeasureText().Y; spriteManager.Add(tmp = new pText(acronym + @": (team 1 name) vs (team 2 name)", 10, new Vector2(0, pos.Y), depth, true, Color.White) { TextBold = true }); // Splitter between text and matches pos.Y += (int)tmp.MeasureText().Y; spriteManager.Add(new pSprite(GameBase.WhitePixel, Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(0, pos.Y), depth, true, new Color(255, 255, 255, 127)) { VectorScale = new Vector2(300 * 1.6f, 1) }); pos.Y += 3; matchesArea = new pScrollableArea(new Rectangle(0, (int)pos.Y, 300, (int)(480 - pos.Y)), Vector2.Zero, true); matchesArea.SetContentDimensions(new Vector2(300, 0)); requestMatchInfo(); updateMatches(); }
internal void AddMessage(Message m) { if (m.Content.StartsWith("!mp")) { return; } m.FontSize = 9; m.LineWidth = chatArea.ContentDimensions.X; ChatLine line = m.ChatLine; line.Position = new Vector2(0, chatArea.ContentDimensions.Y); chatArea.ContentSpriteManager.Add(line.Sprites); chatArea.SetContentDimensions(chatArea.ContentDimensions + new Vector2(0, line.ExtentY)); chatArea.ScrollToBottom(); }
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 (LobbyUpdatePending) { string lobbyUsers = ""; lock (BanchoClient.Users) { List <User> users = BanchoClient.Users.FindAll(u => u.InLobby); foreach (User user in users) { lobbyUsers += user.Name + "\n"; } } lobbyUserList.Text = lobbyUsers.Trim('\n'); int x = 0; lock (Matches) { Matches.Sort(); if (Matches.Count > 0) { foreach (Match m in Matches) { if (m.DrawAt(new Vector2(0, x))) { gameList.spriteManager.Add(m.SpriteCollection); } x += 27; } noMatches.FadeOut(0); } else { noMatches.FadeIn(500); } } gameList.SetContentDimensions(new Vector2(540, x + 50)); LobbyUpdatePending = false; } gameList.Update(gameTime); base.Update(gameTime); }
private void layout() { clearLayout(); int i = 0; foreach (Beatmap m in maps) { if (items.Count == MAX_ITEMS) { break; } addItemFromBeatmap(m, i); i++; } int area = Math.Min(i, MAX_ITEMS - 1); scrollableView.SetContentDimensions(new Vector2(640 * GameBase.WindowManager.WidthWidescreenRatio, area * JumpToItem.ITEM_HEIGHT)); UpdateSelected(false, true); }
private void refresh() { int i = 0; foreach (CollectionSprites c in Collections) { if (c.DrawAt(new Vector2(elementOffsetx + 30, i))) { channelButtonList.ContentSpriteManager.Add(c.SpriteCollection); } i += 17; } channelButtonList.SetContentDimensions(new Vector2(160, i)); }
private void DoLayout() { int i = 0; foreach (Chart c in charts) { if (c.Visible) { c.spriteManager.ViewOffset.Y = -i * (Chart.HEIGHT + 10); i++; } if (!sa_chartList.Children.Contains(c.spriteManager)) { sa_chartList.AddChild(c.spriteManager); } } sa_chartList.SetContentDimensions(new Vector2(0, (Chart.HEIGHT + 10) * i)); }
void snr_onFinish(pWebRequest r, Exception e) { GameBase.Scheduler.Add(delegate { float currentHeight = startHeight; foreach (string line in r.ResponseString.Split('\n')) { string[] spl = line.Split('\t'); Color col = Color.White; string type = string.Empty; switch (spl[0]) { default: col = Color.OrangeRed; type = LocalisationManager.GetString(OsuString.Update_Misc); break; case "+": col = Color.YellowGreen; type = LocalisationManager.GetString(OsuString.Update_Added); break; case "*": col = Color.Orange; type = LocalisationManager.GetString(OsuString.Update_Fixed); break; } pText t = null; if (spl.Length < 2) { currentHeight += 4; t = new pText(line, 10, new Vector2(Width / 2, currentHeight), new Vector2(0, 0), 0.9f, true, Color.White, false); t.TextAlignment = TextAlignment.Centre; t.Origin = Origins.TopCentre; t.TextBold = true; } else { t = new pText(type, 8, new Vector2(4, currentHeight), new Vector2(30, 0), 0.9f, true, Color.White, false); t.BorderColour = ColourHelper.Lighten2(col, 0.2f); t.BackgroundColour = col; t.TextBorder = true; t.TextAlignment = TextAlignment.Centre; area.ContentSpriteManager.Add(t); t = new pText(spl[2], 10, new Vector2(40, currentHeight), new Vector2(Width - 30, 0), 0.9f, true, Color.White, false); } t.TextBorder = true; t.HandleInput = true; area.ContentSpriteManager.Add(t); currentHeight += t.MeasureText().Y + 2; } pText footer = new pText(LocalisationManager.GetString(OsuString.Update_ViewChangelog), 10, new Vector2(Width / 2, currentHeight), new Vector2(Width, 0), 0.9f, true, Color.LightGoldenrodYellow, false); footer.TextBorder = true; footer.HandleInput = true; footer.TextAlignment = TextAlignment.Centre; footer.Origin = Origins.TopCentre; footer.TextBold = true; footer.OnHover += delegate { footer.InitialColour = Color.White; }; footer.OnHoverLost += delegate { footer.InitialColour = Color.LightGoldenrodYellow; }; footer.OnClick += delegate { GameBase.ProcessStart("https://osu.ppy.sh/p/changelog"); }; area.ContentSpriteManager.Add(footer); currentHeight += 1.5f * footer.MeasureText().Y; area.SetContentDimensions(new Vector2(Width, currentHeight)); }); }
internal void RefreshDisplay() { pa.ClearSprites(false); const int height = 17; int currentHeight = 0; bool editor = false; for (int i = 1; i < BindingManager.BindingNames.Length; i++) { string na = BindingManager.BindingNames[i]; //Check for skip flag if (na.StartsWith(@"__")) { continue; } bool header = na[0] == '_'; if (header) { na = na.Substring(1); } pText naText = new pText(na, header ? 16 : 14, new Vector2(0, currentHeight), new Vector2(402, height), header ? 0.97f : 0.98f, true, Color.White, false); pa.ContentSpriteManager.Add(naText); naText.BackgroundColour = Color.Black; if (header) { naText.TextColour = Color.YellowGreen; naText.TextAlignment = TextAlignment.Centre; } else { naText.BorderWidth = 2; naText.BorderColour = Color.LightGray; naText.HandleInput = true; naText.OnHover += delegate { naText.BackgroundColour = Color.Gray; naText.TextColour = Color.Black; naText.TextChanged = true; }; naText.OnHoverLost += delegate { naText.BackgroundColour = Color.Black; naText.TextColour = Color.White; naText.TextChanged = true; }; string name = na; Bindings b = (Bindings)i; naText.OnClick += delegate { startBinding(b, name); }; naText.ClickRequiresConfirmation = true; naText.TextAlignment = TextAlignment.LeftFixed; pText naText2 = new pText(BindingManager.NiceName((Bindings)i), 12, new Vector2(300, currentHeight + 1), new Vector2(100, height - 2), 1, true, Color.Gold, false); naText2.BackgroundColour = new Color(0, 0, 0, 160); naText2.BorderWidth = 2; naText2.BorderColour = Color.LightGray; naText2.TextAlignment = TextAlignment.Centre; pa.ContentSpriteManager.Add(naText2); } currentHeight += height; } pText reset = new pText(LocalisationManager.GetString(OsuString.Options_ResetAllBindings), 14, new Vector2(0, currentHeight), new Vector2(402, height), 0.98f, true, Color.White, false); reset.BorderColour = Color.LightGray; reset.BackgroundColour = Color.Black; reset.TextColour = Color.White; reset.HandleInput = true; reset.OnHover += delegate { reset.BackgroundColour = Color.Red; reset.TextChanged = true; }; reset.OnHoverLost += delegate { reset.BackgroundColour = Color.Black; reset.TextChanged = true; }; reset.OnClick += delegate { //pDialogConfirmation d = new pDialogConfirmation(LocalisationManager.GetString(OsuString.Options_ResetAllBindings_Confirm), delegate //{ BindingManager.Initialize(true); RefreshDisplay(); pa.ScrollToPosition(0, -0.99f); //}, null); //GameBase.ShowDialog(d); }; reset.TextAlignment = TextAlignment.Centre; currentHeight += height; pa.ContentSpriteManager.Add(reset); pa.SetContentDimensions(new Vector2(510, currentHeight)); }
void spawnChannelListing() { Vector2 pos = new Vector2(elementOffsetX, 0); channels = new List <Channel>(ChatEngine.channels); channels.Sort( delegate(Channel c1, Channel c2) { return(c1.Name.CompareTo(c2.Name)); }); foreach (Channel c in channels) { if (!c.Name.StartsWith(@"#")) { continue; } string description = string.Format(LocalisationManager.GetString(OsuString.ChannelListDialog_TopicAndUserCount), string.IsNullOrEmpty(c.Topic) ? LocalisationManager.GetString(OsuString.ChannelListDialog_NoDescriptionAvailable) : c.Topic, c.UserCount); pText pb = new pText(string.Empty, 12, pos, 0.95f, true, c.Joined ? SkinManager.NEW_SKIN_COLOUR_MAIN : SkinManager.NEW_SKIN_COLOUR_SECONDARY); pb.HandleInput = true; pb.Tag = c.Name; pb.CornerBounds = Vector4.One * 4; pb.ClickRequiresConfirmation = true; pb.TextBounds = new Vector2(445, 30); pb.BackgroundColour = Color.Black; pb.BorderWidth = 2; pb.BorderColour = Color.White; pb.TextAlignment = TextAlignment.LeftFixed; Vector2 posName = pos; posName.Y += 8; posName.X += 10; pText pname = new pText(c.Name, 12, posName, 0.99f, true, c.Joined ? SkinManager.NEW_SKIN_COLOUR_MAIN : SkinManager.NEW_SKIN_COLOUR_SECONDARY); pname.HandleInput = false; pText pdesc = new pText(description, 12, new Vector2(pos.X + 100, pos.Y + 8), 0.99f, true, Color.White); pdesc.TextBounds = new Vector2(345, 30); pdesc.TextAlignment = TextAlignment.LeftFixed; pdesc.HandleInput = false; pb.OnClick += delegate { pb_OnClick(pb, pname); }; pb.OnHover += delegate { if (!pb.IsVisible || pb.Alpha != 1) { return; } pb.BackgroundColour = ColourHelper.Darken(pb.BorderColour, 4f); pname.TextBold = true; pname.TextChanged = true; pdesc.TextChanged = true; }; pb.OnHoverLost += delegate { if (!pb.IsVisible || pb.Alpha != 1) { return; } pb.BackgroundColour = Color.Black; pname.TextBold = false; pname.TextChanged = true; pdesc.TextChanged = true; }; pos.Y += spacing; channelButtonList.ContentSpriteManager.Add(pb); channelButtonList.ContentSpriteManager.Add(pname); channelButtonList.ContentSpriteManager.Add(pdesc); channelSprites[c] = new List <pSprite>() { pb, pname, pdesc }; } channelButtonList.SetContentDimensions(new Vector2(160, pos.Y)); }
public override void Update() { if (!BanchoClient.Connected && GameBase.FadeState == FadeStates.Idle) { GameBase.ChangeMode(OsuModes.Menu); NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.Lobby_Bancho_Fail)); } spriteManager.Blackness = LobbyStatus.Idle != Status ? 0.6f : 0; if (LobbyUpdatePending) { int x = 0; lock (Matches) { Matches.Sort(); int visibleMatches = 0; foreach (LobbyMatch m in Matches) { if (CheckFilter(m)) { visibleMatches++; bool firstDraw = m.DrawAt(new Vector2(3, x)); if (firstDraw || m.Filtered) { m.SpriteCollection.ForEach(s => s.FadeInFromZero(500)); } if (firstDraw) { areaGameList.ContentSpriteManager.Add(m.SpriteCollection); } m.Filtered = false; x += 49; } else { if (!m.Filtered) { if (m.SpriteCollection != null) { m.SpriteCollection.ForEach(s => s.FadeOut(300)); } m.Filtered = true; } } } headerText2.Text = string.Format(LocalisationManager.GetString(OsuString.Lobby_FilteredMatches), visibleMatches, Matches.Count); if (visibleMatches > 0) { noMatches.FadeOut(50); } else { noMatches.Text = BanchoClient.InitializationComplete ? text_noMatchFound : text_loading; noMatches.FadeIn(50); } } areaGameList.SetContentDimensions(new Vector2(640, x + 50)); LobbyUpdatePending = false; } areaGameList.Update(); base.Update(); }
public override void Update() { searchTextBox.MaintainFocus = !ChatEngine.IsVisible; bool searchReady; if (lastSearch == null) { lastSearch = @"Newest"; searching = false; ExecuteSearch(true); searchReady = false; } else { searchReady = nextSearchUpdate >= 0 && nextSearchUpdate <= GameBase.Time; } if (searchReady) { bool newData = searchTextBox.Text != lastSearch; if (searchTextBox.Text.Length == 0) { if (newData && lastSearch != @"Newest" && lastSearch != @"Top Rated" && lastSearch != @"Most Played") { lastSearch = @"Newest"; ExecuteSearch(true); } } else if (!searching && newData) { lastSearch = searchTextBox.Text; ExecuteSearch(true); nextSearchUpdate = -1; } } resultsPane.Update(); if (resultsPane.ScrollPosition.Y > resultsPane.ContentDimensions.Y - resultsPane.DisplayRectangle.Height && canLoadMore && !searching) { pageOffset++; ExecuteSearch(false); } if (newResults) { loadingText.FadeOut(200); int i = 0; lock (Beatmaps) { foreach (OnlineBeatmap b in Beatmaps) { if (b.DrawAt(new Vector2(10, i))) { resultsPane.ContentSpriteManager.Add(b.SpriteCollection); } i += 30; } } resultsPane.SetContentDimensions(new Vector2(640, i + 30)); searching = false; newResults = false; } base.Update(); }
public override void Update() { downloadListPanel.Update(); if (sampleTrack != null) { if (sampleTrack.IsPlaying && !disallowAudioPreview) { sampleTrack.Volume = AudioEngine.VolumeMusicAdjusted / 100f; if (!AudioEngine.Paused) { WasPlayingAudio = true; AudioEngine.TogglePause(); } } else { ResetAudioPreview(); } } if (ResponseQueue.Count > 0) { ShowResponseDialog(ResponseQueue.Dequeue()); } if (GameBase.Mode == OsuModes.Play && !Player.Paused && !InputManager.ReplayMode) //allow showing response dialog only in pause { HideResponseDialog(); } if (ActiveDownloads.Count > 0 || RespondingBeatmap != null) { delayClose = true; } else if (GameBase.Mode == OsuModes.OnlineSelection) { delayClose = false; } alwaysShow = GameBase.Mode == OsuModes.OnlineSelection || RespondingBeatmap != null; mustHide = ActiveDownloads.Count == 0 && !alwaysShow; if (!mustHide && (alwaysShow || (!Player.Playing && (background.drawRectangle.Contains(MouseManager.MousePoint) || MouseManager.MousePosition.X > GameBase.WindowManager.Width)))) { Show(); } else { Hide(); } if (UpdatePending) { int y = 0; int ActiveCount = ActiveDownloads.FindAll(d => d.Status > DownloadStatus.Waiting).Count; UpdatePending = false; for (int i = 0; i < ActiveDownloads.Count; i++) { OsuDirectDownload d = ActiveDownloads[i]; if (d.Status == DownloadStatus.Waiting && ActiveCount < MAX_CONCURRENT_DOWNLOADS) { d.Start(); ActiveCount++; } else if (d.Status == DownloadStatus.Completed) { if (d.SpriteCollection != null) { foreach (pSprite p in d.SpriteCollection) { if (Visible || (Player.Playing && !ConfigManager.sPopupDuringGameplay.Value)) { p.FadeOut(300); } else { downloadListPanel.ContentSpriteManager.Remove(p); GameBase.spriteManagerOverlay.Add(p); p.Field = Fields.TopRight; p.Position = new Vector2(XPOSHIDDEN, p.Position.Y + YPOS + 20); p.FadeOut(2500); p.MoveTo(new Vector2(XPOS, p.Position.Y), 800, EasingTypes.Out); } p.AlwaysDraw = false; } } ActiveDownloads.RemoveAt(i--); //loop from start again UpdatePending = true; continue; } if (d.DrawAt(new Vector2(0, y))) { downloadListPanel.ContentSpriteManager.Add(d.SpriteCollection); Show(true); } y += 20; } downloadListPanel.SetContentDimensions(new Vector2(WIDTH, y)); } base.Update(); }
private void UpdateEventList() { eventList.Update(); if (eventListDragging != null) { eventListDragging.Position = eventListDragging.InitialPosition + (MouseManager.MousePosition - eventListDraggingStart) / GameBase.WindowManager.Ratio; foreach (pSprite p in eventList.ContentSpriteManager.SpriteList.FindAll(t => t.TagNumeric > 0)) { pText pt = p as pText; if (eventListDragging == p || (pt != null && pt.Text == @"Background")) { continue; } if (p.InitialPosition.Y > eventListDragging.Position.Y - eventDrawHeight / 2) { if (p.Position == p.InitialPosition) { p.MoveTo(p.InitialPosition + new Vector2(0, eventDrawHeight), 80); } } else if (p.InitialPosition.Y < eventListDragging.Position.Y) { if (p.Position != p.InitialPosition) { p.MoveTo(p.InitialPosition, 80); } } } } if (EventListUpdateRequired) { eventList.ClearSprites(); eventListDictionary.Clear(); float y = 0; float drawDepth = 0.5f; float scale = DpiHelper.DPI(GameBase.Form) / 96.0f; for (int i = 0; i < eventManager.storyLayerSprites.Length; i++) { bool layerIsEnabled = eventManager.storyLayerEnabled[i]; List <Event> l = eventManager.storyLayerSprites[i]; StoryLayer layer = (StoryLayer)i; pText pt = new pText(layer.ToString(), 8 * scale, new Vector2(0, y), drawDepth, true, layerIsEnabled ? Color.Orange : Color.LightGray); pt.TextRenderSpecific = false; pt.TextAa = false; pt.TextShadow = true; pt.TagNumeric = 1; pt.HandleInput = true; pt.OnHover += delegate { if (selectedEvent != null) { pt.TextBold = true; pt.TextChanged = true; } }; pt.OnHoverLost += delegate { pt.TextBold = false; pt.TextChanged = true; }; pt.OnClick += delegate { if (selectedEvent != null) { moveEventToLayer(selectedEvent, layer); } else { ToggleLayer(layer); } }; eventList.ContentSpriteManager.Add(pt); if (eventDrawHeight == 0) { eventDrawHeight = (pt.MeasureText().Y + 4 * scale) / GameBase.WindowManager.Ratio; } y += eventDrawHeight; drawDepth += 0.0001f; if (!layerIsEnabled) { continue; //don't display the events if this layer is hidden. } foreach (Event e in l) { if (e.Sprite == null) { continue; } pText pt1 = new pText(e.Filename.Length >= 4 ? e.Filename.Remove(e.Filename.Length - 4) : e.Filename + @" ", 8 * scale, new Vector2(2, y), drawDepth, true, Color.White); pt1.TextRenderSpecific = false; pt1.TextAa = false; pt1.HandleInput = true; pt1.TextShadow = true; pt1.Tag = e; pt1.TagNumeric = 2; pt1.OnHover += delegate { pt1.BackgroundColour = new Color(92, 92, 92); pt1.TextChanged = true; }; pt1.OnHoverLost += delegate { pt1.BackgroundColour = Color.TransparentWhite; pt1.TextChanged = true; }; if (e == selectedEvent) { pt1.TextBold = true; pt1.TextUnderline = true; } Event e1 = e; pt1.OnClick += delegate { if (editor.CurrentMode != EditorModes.Design) { return; } if ((!e1.Sprite.IsVisible || MouseManager.DoubleClick) && e1.Sprite.Transformations.Count > 0) { AudioEngine.SeekTo(e1.Sprite.Transformations[0].Time1); } SetSelectedEvent(e1, false); }; eventList.ContentSpriteManager.Add(pt1); y += (pt1.MeasureText().Y + 4 * scale) / GameBase.WindowManager.Ratio; eventListDictionary.Add(e, pt1); drawDepth += 0.0001f; } } eventList.SetContentDimensions(new Vector2(66, y)); EventListUpdateRequired = false; } }
public override void Update() { if (loadingSprites && GameBase.Time - lastLoad > 40) { if (files.Count > 0) { x = 80 + 100 * (count % 6); y = 50 + (count / 6) * 100; count++; string filename = files[0].Replace(Folder + Path.DirectorySeparatorChar, string.Empty); pSprite p = null; int frameDelay = 0; if (files.Count > 1 && filename[filename.Length - 5] == '0') { List <pTexture> textures = new List <pTexture>(); int j = 0; while (true) { string testFilename = filename.Replace("0.", j++ + "."); pTexture test = TextureManager.Load(testFilename, SkinSource.Beatmap); if (test == null) { break; } files.Remove(testFilename); textures.Add(test); } if (textures.Count > 1) { pAnimation a = new pAnimation(textures.ToArray(), Fields.StandardGamefieldScale, Origins.Centre, Clocks.Game, new Vector2(x, y), 0.98f, true, Color.White, null); a.Scale = 98f / Math.Max(a.Width, a.Height); spriteList.ContentSpriteManager.Add(a); p = a; filename = filename.Replace("0.", "."); frameDelay = (int)(AudioEngine.ActiveControlPoint != null ? (AudioEngine.ActiveControlPoint.BeatLength * 2) / textures.Count : 500); a.FrameDelay = frameDelay; } } if (p == null) { p = new pSprite(TextureManager.Load(filename, SkinSource.Beatmap), Fields.StandardGamefieldScale, Origins.Centre, Clocks.Game, new Vector2(x, y), 0.98f, true, Color.White); p.Scale = 98f / Math.Max(p.Width, p.Height); spriteList.ContentSpriteManager.Add(p); } pSprite p2 = new pSprite(GameBase.WhitePixel, Fields.StandardGamefieldScale, Origins.TopLeft, Clocks.Game, new Vector2(x - 39, y - 39), 0.9f, true, new Color(15, 15, 15, 255)); p2.HoverEffect = new Transformation(p2.InitialColour, new Color(50, 50, 50, 255), 0, 100); p2.Tag = p; p2.OnClick += delegate { IsAnimation = p is pAnimation; SelectedFilename = filename; if (IsAnimation) { SelectedFrameDelay = frameDelay; AnimationFrameCount = ((pAnimation)p).TextureCount; } Close(); }; p2.HandleInput = true; p2.VectorScale = new Vector2(100, 100); spriteList.ContentSpriteManager.Add(p2); pText pt = new pText(filename, 8, new Vector2(x - 39, y - 50), new Vector2(100, 100), 1, true, Color.White, true); pt.TextRenderSpecific = false; pt.TextAa = false; pt.TextShadow = true; spriteList.ContentSpriteManager.Add(pt); files.RemoveAt(0); } spriteList.SetContentDimensions(new Vector2(x + 100, y + 100)); lastLoad = GameBase.Time; if (files.Count == 0) { loadingSprites = false; } } spriteList.Update(); base.Update(); }