Beispiel #1
0
        /// <summary>
        /// Add a navigation button to the main menu, using the config to
        /// determine their positioning and other properties.
        /// </summary>
        /// <param name="screen">The Screen the nav button will move to.</param>
        /// <param name="typeName">The "typeName" of the button, or the prefix in the config.</param>
        private void AddNavButton(PulsarcScreen screen, string typeName)
        {
            // Find variables for TDE
            string  textStr    = GetSkinnablePropertyString($"{typeName}Text");                                 // string text
            Vector2 position   = Skin.GetConfigStartPosition("main_menu", "Properties", $"{typeName}StartPos"); // Vector2 position;
            int     fontSize   = GetSkinnablePropertyInt($"{typeName}TextFontSize");
            Anchor  textAnchor = GetSkinnablePropertyAnchor($"{typeName}TextAnchor");                           // Anchor textAnchor;
            Color   textColor  = Skin.GetConfigColor("main_menu", "Properties", $"{typeName}TextColor");        // Color textColor;

            // Make TDE
            TextDisplayElement text = new TextDisplayElement(textStr, position, fontSize, textAnchor, textColor);

            // Make NavButton that uses the TDE
            NavigationButton navButton = new NavigationButton(screen, GetSkinnablePropertyInt($"{typeName}Type"), position, text);

            // Offset the button
            Vector2 offset = new Vector2(
                GetSkinnablePropertyInt($"{typeName}X"),
                GetSkinnablePropertyInt($"{typeName}Y"));

            navButton.Move(offset);

            // Add the button
            navButtons.Add(navButton);
        }
Beispiel #2
0
        private void CheckScreen()
        {
            if (ScreenManager.Screens.Peek() != lastScreen)
            {
                PulsarcScreen currentScreen = (PulsarcScreen)ScreenManager.Screens.Peek();
                lastScreen = currentScreen;

                currentScreen.EnteredScreen();
            }
        }
        public NavigationButton(PulsarcScreen screen, int type, Vector2 position, TextDisplayElement text, Anchor anchor = Anchor.Center, bool removeFirst = false)
            : base(Skin.Assets["button_back_" + type], position, anchor: anchor)
        {
            this.text = text;
            // TODO: Change positioniong depending on textAnchor
            // TODO: Position text properly, without using hacky workarounds
            this.text.Move(new Vector2((1 - Scale) * -10, (1 - Scale) * -10));

            this.screen      = screen;
            this.removeFirst = removeFirst;

            Hover = new Drawable(Skin.Assets["button_hover_" + type], position, anchor: anchor);
        }
 /// <summary>
 /// A button that allows the user to navigate to a new Screen.
 /// </summary>
 /// <param name="screen">The screen this button will navigate to.</param>
 /// <param name="type">The button type this navigation button is.</param>
 /// <param name="text">The text this button will display.</param>
 /// <param name="position">The position of this button.</param>
 /// <param name="anchor">The anchor for this button, defaults to Anchor.Center.</param>
 /// <param name="removeFirst">Whether or not the current screen should be removed
 /// <param name="textAnchor"/>The anchor for the text on this button.</param>
 /// <param name="textColor"/>The color of the text.</param>
 /// <param name="fontSize"The font size of the text.</param>
 /// before moving to the navigation screen. True = Remove Current screen before navigating.</param>
 public NavigationButton(PulsarcScreen screen, int type, string text, Vector2 position, Anchor anchor = Anchor.Center, bool removeFirst = false, Anchor textAnchor = Anchor.Center, Color?textColor = null, int fontSize = 18)
     : this(screen, type, position, new TextDisplayElement(text, new Vector2(position.X, position.Y), fontSize, textAnchor, textColor))
 {
 }