Ejemplo n.º 1
0
 void searchInput_OnChange(pTextBox sender, bool newText)
 {
     if (searchInput.Text.Length > CollectionSprites.TEXT_LENGTH_LIMIT && searchInput.Text != LocalisationManager.GetString(OsuString.Collection_EnterName))
     {
         searchInput.Text = searchInput.Text.Substring(0, CollectionSprites.TEXT_LENGTH_LIMIT);
     }
 }
Ejemplo n.º 2
0
        private void Title_OnCommit(pTextBox sender, bool newText)
        {
            if (renaming)
            {
                //Don't allow zero length
                if (title.Text.Length == 0)
                {
                    Name = originalName.Length > TEXT_LENGTH_LIMIT
                        ? originalName.Substring(0, TEXT_LENGTH_LIMIT)
                        : originalName;

                    ChangeCollectionName(originalName, Name);
                    originalName = Name;
                    title.Text   = Name;
                }
                else
                {
                    ChangeCollectionName(originalName, title.Text);
                    originalName = title.Text;
                    Name         = title.Text;
                }
                renaming = false;
                UpdateState();
                CollectionDialog.ChangeSelection(this);
            }
        }
Ejemplo n.º 3
0
        public PasswordInputControl(pTextBox textBox)
            : base(textBox)
        {
            UnderlyingText     = TextBox.Text;
            OnCandidateChange += UpdateUnderlyingText;

            OnKey += keyDown;
        }
Ejemplo n.º 4
0
        void searchInput_OnCommit(pTextBox sender, bool newText)
        {
            if (searchInput.Text.Length <= 0 || !newText)
            {
                return;
            }

            searchInput.Focus(true);
        }
Ejemplo n.º 5
0
        internal override void Display()
        {
            spriteManager.HandleOverlayInput = true;

            pText t = new pText("Game Name:", 16, new Vector2(30, 100), 0.92f, true, Color.White);

            spriteManager.Add(t);

            gameName                 = new pTextBox(ConfigManager.sUsername + "'s game", 16, new Vector2(150, 100), 450, 0.92f);
            gameName.LengthLimit     = 50;
            gameName.OnCommit       += gameName_OnCommit;
            gameName.ResetTextOnEdit = true;
            spriteManager.Add(gameName.SpriteCollection);

            usePassword = new pCheckbox("Require password to join", new Vector2(30, 130), 0.92f, false);
            usePassword.OnCheckChanged += usePassword_OnCheckChanged;
            spriteManager.Add(usePassword.SpriteCollection);

            t = new pText("Password:"******"", 16, new Vector2(150, 160), 450, 0.92f);
            gamePassword.LengthLimit = 50;
            spriteManager.Add(gamePassword.SpriteCollection);
            passwordSprites.AddRange(gamePassword.SpriteCollection);

            t = new pText("Max Players:", 16, new Vector2(30, 190), 0.92f, true, Color.White);
            spriteManager.Add(t);

            currentVerticalSpace = 250;

            AddOption("Start Game", Color.LimeGreen, onClick, false);
            AddOption("Cancel", Color.LightGray, cancel, false);

            playerCount = new pDropdown(null, "", new Vector2(150, 190), 200, 0.96f);
            playerCount.AddOption("2 players", 2);
            playerCount.AddOption("3 players", 3);
            playerCount.AddOption("4 players", 4);
            playerCount.AddOption("5 players", 5);
            playerCount.AddOption("6 players", 6);
            playerCount.AddOption("7 players", 7);
            playerCount.AddOption("8 players", 8);
            if (bMatch.MAX_PLAYERS > 8)
            {
                playerCount.AddOption(bMatch.MAX_PLAYERS + " players", bMatch.MAX_PLAYERS);
            }
            playerCount.SetSelected(8, true);
            playerCount.SpriteManager = spriteManager;

            spriteManager.Add(playerCount.SpriteCollection);

            base.Display();

            Background.InitialColour = new Color(0, 0, 0, 200);
            passwordSprites.ForEach(s => s.FadeOut(0));
        }
Ejemplo n.º 6
0
        void searchBox_OnChange(pTextBox sender, bool newText)
        {
            if (charts == null)
            {
                return;
            }

            charts.ForEach(c => {
                c.Visible = searchBox.IsDefault || c.Search(sender.Text);
            });
            DoLayout();
        }
Ejemplo n.º 7
0
        void gameName_OnCommit(pTextBox sender, bool newText)
        {
            if (gameName.Box.Text.Length == 0)
            {
                gameName.Box.Text = gameName.textBeforeCommit;
            }

            if (newText)
            {
                gameName.ResetTextOnEdit = false;
            }
        }
Ejemplo n.º 8
0
        void textBox_OnGotFocus(pTextBox sender, bool newText)
        {
            if (sender.Text == DEFAULT_MESSAGE)
            {
                sender.Text = string.Empty;
            }

            if (!Player.Paused)
            {
                AudioEngine.TogglePause();
                Player.Paused   = true;
                commitStartTime = AudioEngine.Time;
            }
        }
Ejemplo n.º 9
0
        public OptionTextbox(string title, bool passwordBox = false)
        {
            header = new pText(title, 12, Vector2.Zero, 1, true, Color.White);
            spriteManager.Add(header);

            Textbox           = new pTextBox(string.Empty, 12, new Vector2(0, header.MeasureText().Y + 5), ELEMENT_SIZE - 5, 1, passwordBox);
            Textbox.OnChange += delegate { calculateHeight(); };
            Textbox.OnCommit += delegate { calculateHeight(); };
            spriteManager.Add(Textbox.SpriteCollection);

            addKeyword(title);

            calculateHeight();
        }
Ejemplo n.º 10
0
        internal override void Display()
        {
            string hint = LocalisationManager.GetString(OsuString.Collection_EnterName);

            if (hint.Length > 68)
            {
                hint = hint.Substring(0, 68) + @"...";
            }
            searchInput             = new pTextBox(hint, 15, new Vector2(elementOffsetx + 30 + GameBase.WindowManager.OffsetXScaled, 35), 448, 0.94f);
            searchInput.OnCommit   += searchInput_OnCommit;
            searchInput.OnChange   += searchInput_OnChange;
            searchInput.OnGotFocus += (obj, ev) => { searchInput.Text = string.Empty; };
            spriteManager.Add(searchInput.SpriteCollection);

            base.Display();
        }
Ejemplo n.º 11
0
        internal TextInputControl(pTextBox textBox)
        {
            InitializeComponent();

            pTextBox = textBox;

            TextBox.Font = new System.Drawing.Font(NativeText.GetFontFace(FontFace.AllerLight), textBox.Box.TextSize * 1.14f);
            SetLocation();

            TextBox.ReadOnly = true;

            TextBox.KeyDown             += TextBox_KeyDown;
            TextBox.KeyUp               += TextBox_KeyUp;
            TextBox.OnNewImeComposition += TextBox_OnNewImeComposition;
            TextBox.OnImeActivity       += new BoolDelegate(TextBox_OnImeActivity);
        }
Ejemplo n.º 12
0
 private void Title_OnChange(pTextBox sender, bool newText)
 {
     if (renaming)
     {
         //Initial trim
         if (Name.Length > TEXT_LENGTH_LIMIT)
         {
             Name       = Name.Substring(0, TEXT_LENGTH_LIMIT);
             title.Text = Name.Substring(0, TEXT_LENGTH_LIMIT);
         }
         //Trim any additional characters
         if (title.Text.Length > TEXT_LENGTH_LIMIT)
         {
             title.Text = title.Text.Substring(0, TEXT_LENGTH_LIMIT);
         }
     }
 }
Ejemplo n.º 13
0
        void searchInput_OnCommit(pTextBox sender, bool newText)
        {
            if (searchInput.Text.Length <= 0 || !newText)
            {
                return;
            }

            string name = searchInput.Text;

            searchInput.Text = LocalisationManager.GetString(OsuString.Collection_EnterName);

            if (!CollectionManager.AddCollection(name))
            {
                return;
            }

            Collections.Add(new CollectionSprites(name));
            GameBase.Scheduler.Add(refresh);
        }
Ejemplo n.º 14
0
        internal override void Display()
        {
            pText searchLabel = new pText(LocalisationManager.GetString(OsuString.Lobby_Search), 15, new Vector2(elementOffsetX, 35), 0.95f, true, Color.White);

            spriteManager.Add(searchLabel);

            Vector2 textLength         = searchLabel.MeasureText();
            float   searchLabelPadding = 2.5f; //distance between label and text box

            searchInput = new pTextBox(string.Empty, 15, new Vector2(searchLabel.Position.X + textLength.X + searchLabelPadding, 35), 100, 0.94f);
            searchInput.CommitOnLeave = false;
            searchInput.OnChange     += new pTextBox.OnCommitHandler(searchInput_OnChange);
            searchInput.OnCommit     += new pTextBox.OnCommitHandler(searchInput_OnCommit);
            spriteManager.Add(searchInput.SpriteCollection);

            spawnChannelListing();
            searchInput.Focus(true);
            base.Display();
        }
Ejemplo n.º 15
0
        void searchInput_OnChange(pTextBox sender, bool newText)
        {
            bool showAll = searchInput.Box.Text.Length == 0;

            if (newText)
            {
                float pos = 0;
                foreach (Channel c in channels)
                {
                    bool show = showAll || c.Name.Contains(searchInput.Text);

                    if (!c.Name.Contains("#"))
                    {
                        continue;
                    }

                    channelSprites[c].ForEach(s =>
                    {
                        clearSpriteEffects(s);
                        if (show)
                        {
                            s.FadeIn(300);
                            s.MoveToY(s.HandleInput ? pos : pos + 8, 300, EasingTypes.Out);
                        }
                        else
                        {
                            s.FadeOut(300);
                        }
                    });

                    if (show)
                    {
                        pos += spacing;
                    }
                }

                channelButtonList.SetContentDimensions(new Vector2(160, pos));
            }
        }
Ejemplo n.º 16
0
        private void InitializeTitle()
        {
            if (title != null)
            {
                return;
            }

            title = new pTextBox(string.Empty, 12, pos, 448, 0.95f);
            title.Box.InitialColour    = new Color(200, 200, 200);
            title.ReadOnly             = true;
            title.Height               = BUTTON_HEIGHT + 2 * OptionsOffset.Y;
            title.BorderFocused        = Color.Yellow;
            title.Box.BackgroundColour = Color.Black;
            title.Box.BorderWidth      = 1;

            title.Box.OnClick += Title_OnClick;
            title.OnChange    += Title_OnChange;
            title.OnCommit    += Title_OnCommit;
            title.Box.OnHover += delegate
            {
                if (!title.Box.IsVisible || title.Box.Alpha != 1)
                {
                    return;
                }

                title.Box.InitialColour = Color.White;
            };

            title.Box.OnHoverLost += delegate
            {
                if (!title.Box.IsVisible || title.Box.Alpha != 1)
                {
                    return;
                }

                title.Box.InitialColour = new Color(200, 200, 200);
            };
            SpriteCollection.AddRange(title.SpriteCollection);
        }
Ejemplo n.º 17
0
        internal override void Display()
        {
            pText t = new pText("Password:"******"", 16, new Vector2(150, 120), 450, 0.92f);
            gamePassword.LengthLimit = 50;

            currentVerticalSpace = 180;

            spriteManager.Add(gamePassword.SpriteCollection);

            AddOption("Join Game", Color.LimeGreen, onClick, false);
            AddOption("Cancel", Color.LightGray, cancel, false);

            base.Display();

            Background.InitialColour = new Color(15, 59, 87, 200);

            gamePassword.Select();
        }
Ejemplo n.º 18
0
        private void initializeSprites()
        {
            SkinManager.CreateUserSkin();

            GameBase.TransitionManager.ClearBackground(false);

            ControlPanelLocation = new Vector2(GameBase.WindowManager.WidthScaled - 200, 380);
            float scale = TournamentLayout.ClientScale * GameBase.WindowManager.Ratio;

            backgroundManager = new BackgroundManager(this, spriteManager, 0.1f);

            ChatManager = new ChatManager(this, spriteManager, 1.005f);

            spriteManager.Add(new pSprite(GameBase.WhitePixel, Vector2.Zero, 1.005f, true, new Color(0, 0, 0, 127))
            {
                Field       = Fields.Native,
                VectorScale = new Vector2(TournamentLayout.WorkingSpace.X, TournamentLayout.ClientPositions[0].Y)
            });

            spriteManager.Add(currentSong = new pText(string.Empty, 10, new Vector2(0, 143f) / scale, 1.01f, true, Color.White)
            {
                Field      = Fields.TopCentre,
                Origin     = Origins.Centre,
                FontFace   = FontFace.ExoMedium,
                TextShadow = false
            });

            spriteManager.Add(playingIcon = new pTextAwesome(FontAwesome.play_circle, 10, new Vector2(0, 143f) / scale)
            {
                Depth      = 1.01f,
                Field      = Fields.TopCentre,
                Origin     = Origins.CentreRight,
                Alpha      = 0,
                TextShadow = false
            });

            Team1 = new Team(spriteManager, new Vector2(912 / scale, 86 / scale), FlowDirection.Left);
            Team2 = new Team(spriteManager, new Vector2(1008 / scale, 86 / scale), FlowDirection.Right);

            updateTeamNameWidths();

            spriteManager.Add(annotationBg = new pSprite(TextureManager.Load(@"warmup-bg", SkinSource.Osu), Origins.Centre, new Vector2(0, 78 / scale), 1.02f, true, Color.White)
            {
                Field = Fields.TopCentre,
                Alpha = 0f
            });

            spriteManager.Add(annotationText = new pText(@"warm up", 20, new Vector2(0, 78 / scale), 1.021f, true, Color.White)
            {
                Field      = Fields.TopCentre,
                Origin     = Origins.Centre,
                FontFace   = FontFace.ExoRegular,
                Alpha      = 0f,
                TextItalic = true,
                TextShadow = false
            });

            annotationTextRatio = annotationText.MeasureText().X;

            Vector2 pos = ControlPanelLocation;

            spriteManager.Add((new pButton(@"Sync music", new Vector2(pos.X, pos.Y), new Vector2(80, 15), 1.01f, Color.YellowGreen, (o, e) =>
            {
                AudioEngine.Play();
            })
            {
                SoundsEnabled = false
            }).SpriteCollection);

            spriteManager.Add(new pText(LocalisationManager.GetString(OsuString.Tournament_AnnotationText), 7.5f, new Vector2(pos.X + 95, pos.Y), 1.01f, true, Color.White));
            spriteManager.Add((headerTb = new pTextBox(@"warm up", 7.5f, new Vector2(pos.X + 95, pos.Y + 7.5f), 52f, 1.01f)).SpriteCollection);
            headerTb.OnChange += (o, e) =>
            {
                annotationText.Text        = headerTb.Box.Text;
                annotationBg.VectorScale.X = annotationText.MeasureText().X / annotationTextRatio;
                updateTeamNameWidths();
            };

            pos.Y += 16;

            spriteManager.Add((new pButton(@"Toggle annotation", new Vector2(pos.X, pos.Y), new Vector2(80, 15), 1.01f, Color.YellowGreen, (o, e) =>
            {
                annotationVisible = !annotationVisible;
                updateTeamNameWidths();
            }, false, false, 10)
            {
                SoundsEnabled = false
            }).SpriteCollection);

            pos.Y += 16;

            spriteManager.Add((new pButton(@"Panic", new Vector2(pos.X, pos.Y), new Vector2(80, 15), 1.01f, Color.Red, (o, e) =>
            {
                clients.Reset();
            })
            {
                SoundsEnabled = false
            }).SpriteCollection);

            spriteManager.Add(new pText(LocalisationManager.GetString(OsuString.Tournament_BestOf), 7.5f, new Vector2(pos.X + 95, pos.Y), 1.01f, true, Color.White));
            spriteManager.Add((bestofTb = new pTextBox(@"1", 7.5f, new Vector2(pos.X + 95, pos.Y + 7.5f), 52f, 1.01f)).SpriteCollection);
            bestofTb.OnChange += (o, e) =>
            {
                int tmp;
                if (int.TryParse(bestofTb.Box.Text, out tmp))
                {
                    Team1.BestOf = Team2.BestOf = tmp;
                }
            };
            bestofTb.Focus(true);

            pos.Y += 16;

            spriteManager.Add((new pButton(@"Exit", new Vector2(pos.X, pos.Y), new Vector2(80, 15), 1.01f, Color.Red, (o, e) =>
            {
                GameBase.BeginExit();
            })
            {
                SoundsEnabled = false
            }).SpriteCollection);

            currentSong.OnRefreshTexture += (o, e) => playingIcon.Position.X = currentSong.Position.X - currentSong.MeasureText().X / 2;
        }
Ejemplo n.º 19
0
        internal override void Display()
        {
            descriptionTexts     = new List <pText>();
            currentVerticalSpace = 300;
            const int width = 450;
            int       horizontalPosition = -width / 2;
            Fields    fields             = Fields.Centre;

            pText reportedUserText = new pText(LocalisationManager.GetString(OsuString.UserReportDialog_ReportedUser), 15, new Vector2(horizontalPosition, -100), 0.92f, true, Color.White);

            reportedUserText.Field  = fields;
            reportedUserText.Origin = Origins.TopLeft;
            descriptionTexts.Add(reportedUserText);
            spriteManager.Add(reportedUserText);

            pText reportReasonText = new pText(LocalisationManager.GetString(OsuString.UserReportDialog_SelectReason), 15, new Vector2(horizontalPosition, -70), 0.92f, true, Color.White);

            reportReasonText.Field  = fields;
            reportReasonText.Origin = Origins.TopLeft;
            descriptionTexts.Add(reportReasonText);
            spriteManager.Add(reportReasonText);

            pText reportReasonInfoText = new pText(LocalisationManager.GetString(OsuString.UserReportDialog_AdditionalInfo), 15, new Vector2(horizontalPosition, -40), 0.92f, true, Color.White);

            reportReasonInfoText.Field  = fields;
            reportReasonInfoText.Origin = Origins.TopLeft;
            descriptionTexts.Add(reportReasonInfoText);
            spriteManager.Add(reportReasonInfoText);

            int biggestText = descriptionTexts.Max(e => (int)e.MeasureText().X);

            descriptionTexts.ForEach(e => e.MoveToX(e.CurrentPositionActual.X + ((float)biggestText - e.MeasureText().X), 0));
            int widthOfBoxes = width - biggestText;
            int horizontalPositionOfBoxes = horizontalPosition + biggestText + 5;

            pText reportedUserName = new pText(reportedUser.Name, 15, new Vector2(horizontalPositionOfBoxes - 1, -100), 0.92f, true, Color.White);

            reportedUserName.TextBold = true;
            reportedUserName.Field    = fields;
            reportedUserName.Origin   = Origins.TopLeft;
            spriteManager.Add(reportedUserName);

            reportReason = new pDropdown(null, string.Empty, new Vector2(horizontalPositionOfBoxes, -70), widthOfBoxes, 0.96f);
            reportReason.AddOption(LocalisationManager.GetString(OsuString.UserReportDialog_ReasonSpamming), Reasons.Spam);
            reportReason.AddOption(LocalisationManager.GetString(OsuString.UserReportDialog_ReasonInsults), Reasons.Insults);
            reportReason.AddOption(LocalisationManager.GetString(OsuString.UserReportDialog_ReasonFoulPlay), Reasons.Cheating);
            reportReason.AddOption(LocalisationManager.GetString(OsuString.UserReportDialog_ReasonUnwantedContent), Reasons.UnwantedContent);
            reportReason.AddOption(LocalisationManager.GetString(OsuString.UserReportDialog_ReasonNonsense), Reasons.Nonsense);
            reportReason.AddOption(LocalisationManager.GetString(OsuString.UserReportDialog_ReasonOther), Reasons.Other);
            reportReason.SetSelected(Reasons.Spam, true);
            reportReason.SpriteManager = spriteManager;
            reportReason.SpriteCollection.ForEach(s => s.Field = fields);
            reportReason.SpriteMainBox.BorderColour            = ColourHelper.Darken(reportReason.HighlightColour, 0.2f);
            reportReason.SpriteMainBox.BorderWidth             = 1;
            spriteManager.Add(reportReason.SpriteCollection);

            reportReasonInfo = new pTextBox(string.Empty, 15, new Vector2(horizontalPositionOfBoxes, -40), widthOfBoxes, 0.92f);
            reportReasonInfo.SpriteCollection.ForEach(s => s.Field = fields);
            reportReasonInfo.Focus(true);
            reportReasonInfo.InputControl.OnKey += InputControl_OnKey;
            spriteManager.Add(reportReasonInfo.SpriteCollection);

            AddOption(LocalisationManager.GetString(OsuString.UserReportDialog_SendReport), Color.Red, OnReportClick, true);
            AddCancel(LocalisationManager.GetString(OsuString.General_Cancel), Color.LightGray, null);
            base.Display();
        }
Ejemplo n.º 20
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string ID   = this.Attributes.InstanceGuid.ToString();
            string name = new GUIDtoAlpha(Convert.ToString(ID + Convert.ToString(this.RunCount)), true).Text;
            int    C    = this.RunCount;

            wObject  WindObject = new wObject();
            pElement Element    = new pElement();
            bool     Active     = Elements.ContainsKey(C);

            var pCtrl = new pTextBox(name);

            if (Elements.ContainsKey(C))
            {
                Active = true;
            }

            //Check if control already exists
            if (Active)
            {
                if (Elements[C] != null)
                {
                    WindObject = Elements[C];
                    Element    = (pElement)WindObject.Element;
                    pCtrl      = (pTextBox)Element.ParrotControl;
                }
            }
            else
            {
                Elements.Add(C, WindObject);
            }

            //Set Unique Control Properties
            string Text    = "";
            bool   HasText = false;
            bool   Wraps   = false;
            double Width   = 0;

            if (!DA.GetData(0, ref Text))
            {
                return;
            }
            if (!DA.GetData(1, ref Wraps))
            {
                return;
            }
            if (!DA.GetData(2, ref Width))
            {
                return;
            }

            if (Text != "")
            {
                HasText = true;
            }

            pCtrl.SetProperties(Text, HasText, Wraps, Width);

            //Set Parrot Element and Wind Object properties
            if (!Active)
            {
                Element = new pElement(pCtrl.Element, pCtrl, pCtrl.Type);
            }
            WindObject          = new wObject(Element, "Parrot", Element.Type);
            WindObject.GUID     = this.InstanceGuid;
            WindObject.Instance = C;

            Elements[this.RunCount] = WindObject;

            DA.SetData(0, WindObject);
        }
Ejemplo n.º 21
0
 void commentInputTextbox_OnChange(pTextBox sender, bool newText)
 {
     UpdateCommentWindowSizing();
 }
Ejemplo n.º 22
0
        public override void Initialize()
        {
            content = new ResourceContentManager(GameBase.Instance.Services, ResourcesStore.ResourceManager);

            KeyboardHandler.OnKeyPressed += KeyboardHandler_OnKeyPressed;


            if (SongSelection.ForceRefresh)
            {
                BeatmapManager.CheckNewFiles();
                BeatmapManager.ProcessBeatmaps();
                BeatmapManager.GetOnlineBeatmapInfo();
                SongSelection.ForceRefresh = false;
            }

            if (Lobby.Status == LobbyStatus.Play)
            {
                Lobby.Status = LobbyStatus.Setup;
            }

            spriteManager = new SpriteManager();

            pText headerText =
                new pText("Match Setup", 30, new Vector2(0, 0), 0.955F, true, new Color(255, 255, 255, 255));

            headerText.TextShadow = true;
            spriteManager.Add(headerText);

            headerText2 = new pText("You are " + (IsHost ? "the host" : "a player"), 16, new Vector2(4, 26),
                                    0.955F, true, new Color(255, 255, 255, 255));
            spriteManager.Add(headerText2);

            pSprite bg =
                new pSprite(content.Load <Texture2D>("matchsetup-background"), FieldTypes.Window, OriginTypes.TopLeft,
                            ClockTypes.Game, Vector2.Zero, 0, true, Color.White);

            spriteManager.Add(bg);

            buttonStart = new pButton("Ready!", new Vector2(270, 285), new Vector2(350, 30),
                                      0.92f, new Color(99, 139, 228), OnReady);
            spriteManager.Add(buttonStart.SpriteCollection);

            pButton pbut = new pButton("Leave Match", new Vector2(10, 285), new Vector2(250, 30), 0.92f,
                                       new Color(235, 160, 62), OnLeaveGame);

            spriteManager.Add(pbut.SpriteCollection);

            buttonBeatmap = new pButton("Change...", new Vector2(384, 112), new Vector2(80, 18), 0.90f,
                                        Color.YellowGreen, OnSelectBeatmap);
            spriteManager.Add(buttonBeatmap.SpriteCollection);
            buttonMods = new pButton("Change...", new Vector2(352, 210), new Vector2(80, 18), 0.90f,
                                     Color.YellowGreen, OnSelectMods);
            spriteManager.Add(buttonMods.SpriteCollection);

/*            spriteManager.Add(new pText("Current Players:", 18, new Vector2(10, 60), 1, true, Color.White));
 *          spriteManager.Add(new pText("Game Name:", 18, new Vector2(300, 60), 1, true, Color.White));
 *          spriteManager.Add(new pText("Now Playing:", 18, new Vector2(300, 110), 1, true, Color.White));
 *          spriteManager.Add(new pText("Active Mods:", 18, new Vector2(300, 210), 1, true, Color.White));*/

            for (int i = 0; i < 8; i++)
            {
                /*spriteManager.Add(new pText((i + 1).ToString(), 18, new Vector2(10, 85 + i*25), 1, true, Color.White));*/

                slotText[i] = new pText("", 18, new Vector2(57, 85 + i * 25), 1, true, Color.White);
                spriteManager.Add(slotText[i]);

                slotTextInfo[i] = new pText("", 10, new Vector2(210, 85 + i * 25), new Vector2(77, 0), 1, true,
                                            Color.White, false);
                slotTextInfo[i].TextAlignment = Alignment.Right;
                spriteManager.Add(slotTextInfo[i]);

                pSprite status = new pSprite(GameBase.WhitePixel, FieldTypes.Window,
                                             OriginTypes.TopLeft, ClockTypes.Game, new Vector2(50, 85 + i * 25), 0.974F,
                                             true,
                                             new Color(255, 255, 255, 255));
                status.UseVectorScale = true;
                status.IsClickable    = true;
                status.VectorScale    = new Vector2(5, 20);
                status.CurrentScale   = 1.6f;
                spriteManager.Add(status);

                slotStatus[i] = status;

                pSprite slot = new pSprite(GameBase.WhitePixel, FieldTypes.Window,
                                           OriginTypes.TopLeft, ClockTypes.Game, new Vector2(57, 85 + i * 25), 0.974F,
                                           true,
                                           new Color(255, 255, 255, 50));
                slot.UseVectorScale = true;
                slot.IsClickable    = true;
                slot.VectorScale    = new Vector2(230, 20);
                slot.CurrentScale   = 1.6f;
                slot.ToolTip        = "Move to this slot.";
                slot.HoverEffect    = new Transformation(TransformationType.Fade, 0.2f, 0.4f, 0, 60);
                slot.OnClick       += clickSlot;
                slot.TagNumeric     = i;
                slotBackground[i]   = slot;
                spriteManager.Add(slot);

                pSprite lockToggle = new pSprite(content.Load <Texture2D>("lobby-unlock"),
                                                 new Vector2(36, 95 + i * 25), 1, true, Color.LightGray);
                slotLock[i]            = lockToggle;
                lockToggle.OnClick    += lockToggle_OnClick;
                lockToggle.OriginType  = OriginTypes.Centre;
                lockToggle.HoverEffect = new Transformation(TransformationType.Rotation, 0, 0.1f, 0, 100);
                lockToggle.ClickEffect = new Transformation(TransformationType.Scale, 2, 1, 0, 200);
                lockToggle.ToolTip     = "Lock this slot";
                lockToggle.TagNumeric  = i;
                spriteManager.Add(lockToggle);
            }

            if (IsHost)
            {
                changeBeatmap();
            }

            detailsGameName             = new pTextBox(Match.gameName, 16, new Vector2(310, 85), new Vector2(320, 18), 1);
            detailsGameName.OnCommit   += detailsGameName_OnCommit;
            detailsGameName.ReadOnly    = true;
            detailsGameName.LengthLimit = 50;
            spriteManager.Add(detailsGameName.SpriteCollection);

            UpdatePending     = true;
            SongChangePending = true;
            ModChangePending  = true;
            HostChangePending = true;

            if (IsHost && HostChangePending)
            {
                HostChangePending = false;
                SetHost();
            }

            ModManager.ModStatus = Match.activeMods;

            base.Initialize();


            GameBase.LoadComplete();

            if (!ChatEngine.IsVisible)
            {
                ChatEngine.Toggle();
            }

            Transformation t = new Transformation(TransformationType.Scale, 1, 1.2F, 0, 100);

            t.Easing = EasingTypes.In;
            Transformation t2 = new Transformation(TransformationType.Scale, 1.1F, 1.2F, 0, 100);

            t2.Easing = EasingTypes.In;
            pSprite p =
                new pSprite(content.Load <Texture2D>("editor-button-pause"), FieldTypes.Window, OriginTypes.Centre,
                            ClockTypes.Game, new Vector2(460, 15), 0.96F, true, Color.White, "b");

            p.IsClickable    = true;
            p.ClickEffect    = t2;
            p.HoverEffect    = t;
            p.CatchUniversal = true;
            p.OnClick       += pause;
            spriteManager.Add(p);
        }
Ejemplo n.º 23
0
        public override void Initialize()
        {
            MatchSetup.Match = null;

            StreamingManager.StopSpectating(false);

            text_noMatchFound = LocalisationManager.GetString(OsuString.Lobby_NoMatch);
            text_loading      = LocalisationManager.GetString(OsuString.General_Loading);

            spriteManager = new SpriteManager(true);

            spriteManagerFilters = new SpriteManager(true);
            //spriteManagerFilters.Alpha = 0;
            spriteManagerFilters.SetVisibleArea(new RectangleF(0, content_y - filters_height, 640, filters_height));

            BanchoClient.OnConnect      += BanchoClient_OnConnect;
            KeyboardHandler.OnKeyRepeat += KeyboardHandler_OnKeyRepeat;

            pText headerText =
                new pText(LocalisationManager.GetString(OsuString.Lobby_Header), 24, new Vector2(0, 0), 0.955F, true, new Color(255, 255, 255, 255));

            spriteManager.Add(headerText);

            headerText2 = new pText(text_loading, 12, new Vector2(170, 8), 0.955F, true,
                                    new Color(255, 255, 255, 255));
            spriteManager.Add(headerText2);


            //pSprite bgf =
            //    new pSprite(TextureManager.Load(@"lobby-background"), Fields.TopLeft, Origins.TopLeft,
            //                Clocks.Instance, Vector2.Zero, 0, true, Color.White);
            //spriteManager.Add(bgf);

            pSprite p = new pSprite(GameBase.WhitePixel, Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(0, content_y - filters_height), 0.1f, true, new Color(0, 0, 0, 180));

            p.Scale       = 1.6f;
            p.VectorScale = new Vector2(GameBase.WindowManager.WidthScaled, content_height + filters_height + 30);
            spriteManager.Add(p);

            int button_height = content_y + content_height + 2;

            pButton pbut = new pButton(LocalisationManager.GetString(OsuString.Lobby_NewGame), new Vector2(GameBase.WindowManager.WidthScaled / 2 - 100, button_height), new Vector2(200, 25), 0.92f, new Color(99, 139, 228), OnCreateGame);

            spriteManager.Add(pbut.SpriteCollection);

            pbut = new pButton(LocalisationManager.GetString(OsuString.Lobby_QuickJoin), new Vector2(GameBase.WindowManager.WidthScaled / 2 + 110, button_height), new Vector2(200, 25), 0.92f, Color.YellowGreen, OnQuickJoin);
            spriteManager.Add(pbut.SpriteCollection);

            pbut = new pButton(LocalisationManager.GetString(OsuString.Lobby_BackToMenu), new Vector2(GameBase.WindowManager.WidthScaled / 2 - 310, button_height), new Vector2(200, 25), 0.92f, new Color(235, 160, 62), back_OnClick);
            spriteManager.Add(pbut.SpriteCollection);

            noMatches               = new pText(text_loading, 18, new Vector2(GameBase.WindowManager.WidthScaled / 2, 180), new Vector2(400, 0), 1, true, Color.White, false);
            noMatches.TextBold      = true;
            noMatches.Alpha         = 0;
            noMatches.TextAlignment = TextAlignment.Centre;
            noMatches.Origin        = Origins.Centre;
            spriteManager.Add(noMatches);

            sortingTabs = new pTabCollection(spriteManager, 6, new Vector2(50, 40), 0.98f, false,
                                             Color.Crimson);
            sortingTabs.Add(LocalisationManager.GetString(OsuString.Lobby_All), -1);
            sortingTabs.Add(OsuCommon.PlayModeString(PlayModes.Osu), (int)PlayModes.Osu);
            sortingTabs.Add(OsuCommon.PlayModeString(PlayModes.Taiko), (int)PlayModes.Taiko);
            sortingTabs.Add(OsuCommon.PlayModeString(PlayModes.CatchTheBeat), (int)PlayModes.CatchTheBeat);
            sortingTabs.Add(OsuCommon.PlayModeString(PlayModes.OsuMania), (int)PlayModes.OsuMania);
            sortingTabs.SetSelected(ConfigManager.sLobbyPlayMode.Value, true);
            sortingTabs.OnTabChanged += delegate { ConfigManager.sLobbyPlayMode.Value = (int)sortingTabs.SelectedTab.Tag; LobbyUpdatePending = true; };

            checkExistingMaps = new pCheckbox(LocalisationManager.GetString(OsuString.Lobby_ExistMapOnly), 0.8f, new Vector2(5, 2), 1, ConfigManager.sLobbyShowExistingOnly);
            spriteManagerFilters.Add(checkExistingMaps.SpriteCollection);

            checkExistingMaps.OnCheckChanged +=
                delegate(object sender, bool status)
            {
                ConfigManager.sLobbyShowExistingOnly.Value = status;
                LobbyUpdatePending = true;
            };

            checkFriendsOnly = new pCheckbox(LocalisationManager.GetString(OsuString.Lobby_FriendOnly), 0.8f, new Vector2(5, 19), 1, ConfigManager.sLobbyShowFriendsOnly);
            spriteManagerFilters.Add(checkFriendsOnly.SpriteCollection);

            checkFriendsOnly.OnCheckChanged +=
                delegate(object sender, bool status)
            {
                ConfigManager.sLobbyShowFriendsOnly.Value = status;
                LobbyUpdatePending = true;
            };

            checkInProgress = new pCheckbox(LocalisationManager.GetString(OsuString.Lobby_InProgress), 0.8f, new Vector2(360, 19), 1, ConfigManager.sLobbyShowInProgress);
            spriteManagerFilters.Add(checkInProgress.SpriteCollection);

            checkInProgress.OnCheckChanged +=
                delegate(object sender, bool status)
            {
                ConfigManager.sLobbyShowInProgress.Value = status;
                LobbyUpdatePending = true;
            };

            checkShowFullGames = new pCheckbox(LocalisationManager.GetString(OsuString.Lobby_ShowFull), 0.8f, new Vector2(180, 2), 1, ConfigManager.sLobbyShowFull);
            spriteManagerFilters.Add(checkShowFullGames.SpriteCollection);

            checkShowFullGames.OnCheckChanged += delegate(object sender, bool status)
            {
                ConfigManager.sLobbyShowFull.Value = status;
                LobbyUpdatePending = true;
            };

            checkShowPasswordedGames = new pCheckbox(LocalisationManager.GetString(OsuString.Lobby_ShowLocked), 0.8f, new Vector2(180, 19), 1, ConfigManager.sLobbyShowPassworded);
            spriteManagerFilters.Add(checkShowPasswordedGames.SpriteCollection);

            checkShowPasswordedGames.OnCheckChanged +=
                delegate(object sender, bool status)
            {
                ConfigManager.sLobbyShowPassworded.Value = status;
                LobbyUpdatePending = true;
            };

            pText pt = new pText(LocalisationManager.GetString(OsuString.Lobby_Search), 14, new Vector2(360, 2), 1, true, Color.White);

            spriteManagerFilters.Add(pt);

            filterTextBox             = new pTextBox(string.Empty, 14, new Vector2(360 + pt.MeasureText().X, 2), 134, 1);
            filterTextBox.LengthLimit = 20;
            filterTextBox.OnChange   += delegate
            {
                LobbyUpdatePending = true;

                if (filterTextBox.Text.Length > 0)
                {
                    checkFriendsOnly.Hide();
                    checkShowFullGames.Hide();
                    checkShowPasswordedGames.Hide();
                    checkExistingMaps.Hide();
                    sortingTabs.SetSelected(-1, true);
                }
                else
                {
                    checkFriendsOnly.Show();
                    checkShowFullGames.Show();
                    checkShowPasswordedGames.Show();
                    checkExistingMaps.Show();
                    sortingTabs.SetSelected(ConfigManager.sLobbyPlayMode.Value, true);
                }
            };
            spriteManagerFilters.Add(filterTextBox.SpriteCollection);

            //buttonFilters = new pButton(LocalisationManager.GetString(OsuString.Lobby_Filters), new Vector2(390, 32), new Vector2(100, 20), 1, Color.YellowGreen, toggleFilters);
            //spriteManager.Add(buttonFilters.SpriteCollection);

            base.Initialize();

            if (BeatmapManager.Current == null || string.IsNullOrEmpty(BeatmapManager.Current.ContainingFolder) || !BeatmapManager.Current.BeatmapPresent)
            {
                MusicControl.ChooseRandomSong(true);
            }

            JoinLobby();

            LobbyUpdatePending = true;
        }
Ejemplo n.º 24
0
        private void InitializeCommentSystem()
        {
            commentBackgroundTop = new pSprite(TextureManager.Load(@"commentbox", SkinSource.Osu), Fields.TopRight,
                                               Origins.TopRight,
                                               Clocks.Game,
                                               new Vector2(70, buttonComments.Position.Y - 24), 0.95f, true, Color.TransparentWhite, "play");
            commentBackgroundTop.DrawHeight = 52;
            commentBoxSprites.Add(commentBackgroundTop);
            spriteManager.Add(commentBackgroundTop);

            commentBackgroundMiddle = new pSprite(TextureManager.Load(@"commentbox", SkinSource.Osu), Fields.TopRight,
                                                  Origins.TopRight,
                                                  Clocks.Game,
                                                  new Vector2(70, buttonComments.Position.Y - 24), 0.95f, true, Color.TransparentWhite, "play");
            commentBackgroundMiddle.DrawHeight  = 1;
            commentBackgroundMiddle.DrawTop     = 52;
            commentBackgroundMiddle.VectorScale = new Vector2(1, 0);
            commentBackgroundMiddle.Position.Y += 52 * 0.625f;
            commentBoxSprites.Add(commentBackgroundMiddle);
            spriteManager.Add(commentBackgroundMiddle);

            commentBackgroundBottom = new pSprite(TextureManager.Load(@"commentbox", SkinSource.Osu), Fields.TopRight,
                                                  Origins.TopRight,
                                                  Clocks.Game,
                                                  new Vector2(70, buttonComments.Position.Y - 24 + 52 * 0.625f), 0.95f, true, Color.TransparentWhite, "play");
            commentBackgroundBottom.DrawHeight = 49;
            commentBackgroundBottom.DrawTop    = 53;
            commentBoxSprites.Add(commentBackgroundBottom);
            spriteManager.Add(commentBackgroundBottom);

            float     width   = commentBackgroundTop.DrawWidth * 0.625f;
            const int padding = 6;

            commentInputTextbox = new pTextBox(DEFAULT_MESSAGE, 12, new Vector2(commentBackgroundTop.CurrentPositionActual.X - width + padding, commentBackgroundTop.Position.Y + 17 + padding), width - padding * 4, 1);

            commentInputTextbox.BackgroundUnfocused = new Color(51, 197, 234, 150);
            commentInputTextbox.Box.Alpha           = 0;
            commentInputTextbox.Box.BorderWidth     = 0;
            commentInputTextbox.OnGotFocus         += textBox_OnGotFocus;
            commentInputTextbox.CommitOnLeave       = false;
            commentInputTextbox.OnCommit           += textBox_OnCommit;
            commentInputTextbox.LengthLimit         = 80;
            commentInputTextbox.OnChange           += new pTextBox.OnCommitHandler(commentInputTextbox_OnChange);
            commentBoxSprites.AddRange(commentInputTextbox.SpriteCollection);
            spriteManager.Add(commentInputTextbox.SpriteCollection);

            cMap = new pCheckbox("Difficulty", 0.7f, new Vector2(commentBackgroundTop.CurrentPositionActual.X - 250, commentBackgroundTop.CurrentPositionActual.Y + 5), 1, false);
            spriteManager.Add(cMap.SpriteCollection);

            cMap.OnCheckChanged += new CheckboxCallbackDelegate(choice_OnCheckChanged);
            cMap.Hide(true);
            cMap.Tooltip = "Comment on this particular difficulty";
            commentBoxSprites.AddRange(cMap.SpriteCollection);
            spriteManager.Add(cMap.SpriteCollection);

            cSong = new pCheckbox("Song", 0.7f, new Vector2(commentBackgroundTop.CurrentPositionActual.X - 170, commentBackgroundTop.CurrentPositionActual.Y + 5), 1, false);
            spriteManager.Add(cSong.SpriteCollection);

            cSong.OnCheckChanged += new CheckboxCallbackDelegate(choice_OnCheckChanged);
            cSong.Tooltip         = "Comment on this collection of beatmaps or the song";
            cSong.Hide(true);
            commentBoxSprites.AddRange(cSong.SpriteCollection);
            spriteManager.Add(cSong.SpriteCollection);

            cReplay = new pCheckbox("Player", 0.7f, new Vector2(commentBackgroundTop.CurrentPositionActual.X - 90, commentBackgroundTop.CurrentPositionActual.Y + 5), 1, false);
            spriteManager.Add(cReplay.SpriteCollection);

            cReplay.Tooltip         = "Comment on the current replay (the specific person playing)";
            cReplay.OnCheckChanged += new CheckboxCallbackDelegate(choice_OnCheckChanged);
            cReplay.Hide(true);

            if (InputManager.ReplayScore.IsOnline)
            {
                commentBoxSprites.AddRange(cReplay.SpriteCollection);
                spriteManager.Add(cReplay.SpriteCollection);
            }

            originalCheckboxPosition = new Vector2(commentBackgroundBottom.CurrentPositionActual.X - 250, commentBackgroundBottom.CurrentPositionActual.Y + 5);
            showCommentsCheckbox     = new pCheckbox("Show Comments", 0.7f, originalCheckboxPosition, 1, ConfigManager.sShowReplayComments);
            spriteManager.Add(showCommentsCheckbox.SpriteCollection);

            showCommentsCheckbox.OnCheckChanged += showComments_OnCheckChanged;
            showCommentsCheckbox.Hide(true);
            commentBoxSprites.AddRange(showCommentsCheckbox.SpriteCollection);
            spriteManager.Add(showCommentsCheckbox.SpriteCollection);

            commentColourPicker             = new pSprite(GameBase.WhitePixel, Fields.TopLeft, Origins.TopLeft, Clocks.Game, originalCheckboxPosition + new Vector2(124, 1), 0.96f, true, Color.TransparentWhite);
            commentColourPicker.Alpha       = 0;
            commentColourPicker.VectorScale = new Vector2(20, 20);
            commentColourPicker.HandleInput = true;
            commentColourPicker.OnClick    += (obj, ev) =>
            {
                if (GameBase.IsFullscreen)
                {
                    NotificationManager.ShowMessage("Exit fullscreen mode to use the colour pick feature.", Color.Red, 2000);
                    return;
                }

                if (!Player.Paused && !InputManager.ReplayStreaming)
                {
                    AudioEngine.TogglePause();
                    Player.Paused   = true;
                    commitStartTime = AudioEngine.Time;
                }

                ColorDialog cd = new ColorDialog();
                if (cd.ShowDialog(GameBase.Form) == DialogResult.OK)
                {
                    commentColourPicker.InitialColour = new Color(cd.Color.R, cd.Color.G, cd.Color.B);
                }
                if (!InputManager.ReplayStreaming)
                {
                    AudioEngine.TogglePause();
                    Player.Paused = false;
                }
            };

            if (GameBase.User != null && (GameBase.User.Permission & Permissions.Supporter) > 0)
            {
                commentBoxSprites.Add(commentColourPicker);
                spriteManager.Add(commentColourPicker);
                pText pt = new pText("Colour", 15 * 0.7f, originalCheckboxPosition + new Vector2(94, 2), 0.96f, true, Color.TransparentWhite);
                commentBoxSprites.Add(pt);
                spriteManager.Add(pt);
            }
            if (ConfigManager.sShowReplayComments)
            {
                RequestComments();
            }
        }
Ejemplo n.º 25
0
        void textBox_OnCommit(pTextBox sender, bool newText)
        {
            if (commentTarget == CommentTargets.None && newText)
            {
                NotificationManager.ShowMessageMassive("Select a target for your comment first!", 1500);
                commentInputTextbox.Select();
                return;
            }

            if (newText && commentInputTextbox.Text.Length > 0)
            {
                pWebRequest fnr = new pWebRequest(General.WEB_ROOT + "/web/osu-comment.php");
                fnr.AddParameter("u", ConfigManager.sUsername);
                fnr.AddParameter("p", ConfigManager.sPassword);

                fnr.AddParameter("s", BeatmapManager.Current.BeatmapSetId.ToString());
                fnr.AddParameter("b", BeatmapManager.Current.BeatmapId.ToString(GameBase.nfi));
                fnr.AddParameter("m", ((int)InputManager.ReplayScore.PlayMode).ToString(GameBase.nfi));
                fnr.AddParameter("r", InputManager.ReplayScore.OnlineId.ToString(GameBase.nfi));
                fnr.AddParameter("target", commentTarget.ToString().ToLower());
                //append colour here
                if (commentColourPicker.InitialColour != Color.White && commentColourPicker.InitialColour != Color.TransparentWhite)
                {
                    string colour = ColourHelper.Color2Hex(commentColourPicker.InitialColour);
                    fnr.AddParameter("f", colour);
                }


                fnr.AddParameter("a", "post");
                fnr.AddParameter("starttime", commitStartTime.ToString());
                fnr.AddParameter("comment", commentInputTextbox.Text);

                fnr.Finished += delegate
                {
                    GameBase.Scheduler.Add(delegate
                    {
                        increaseCount(commentTarget);
                        updateCounts();

                        commentInputTextbox.Text = "Please wait before commenting again...";
                        NotificationManager.ShowMessage("Your comment has been submitted!", Color.Orange, 3000);
                    });
                };

                fnr.Perform();

                commentInputTextbox.Enabled = false;
                commentInputTextbox.Text    = "Sending...";
            }

            if (commentInputTextbox.Text.Length == 0)
            {
                commentInputTextbox.Text = DEFAULT_MESSAGE;
            }

            UpdateCommentWindowSizing();

            if (Player.Paused)
            {
                AudioEngine.TogglePause();
                Player.Paused = false;
            }
        }