Example #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);
        }
Example #2
0
        private TextDisplayElement MakeTextDisplayElement(string typeName, string section)
        {
            // Find variables for the TDE
            Vector2 position   = Skin.GetConfigStartPosition(Config, section, $"{typeName}StartPos", scorecard);
            int     fontSize   = Skin.GetConfigInt(Config, section, $"{typeName}FontSize");
            Anchor  textAnchor = Skin.GetConfigAnchor(Config, section, $"{typeName}Anchor");
            Color   textColor  = Color.White;

            // This Try Block is for the judgement text, which find their colors
            // from judgements.ini in AddJudgeInfo() instead of result_screen.ini here
            try
            {
                textColor = Skin.GetConfigColor(Config, section, $"{typeName}Color");
            }
            catch { }

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

            // Offset
            Vector2 offset = new Vector2(
                Skin.GetConfigInt(Config, section, $"{typeName}X"),
                Skin.GetConfigInt(Config, section, $"{typeName}Y"));

            text.Move(offset);

            return(text);
        }
Example #3
0
        /// <summary>
        /// Creates a new "Binding" Setting, a setting that keeps track of and
        /// can rebind a key button to a specific action.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="more"></param>
        /// <param name="position"></param>
        /// <param name="startingValue"></param>
        public Binding(string title, string more, Vector2 position, string startingValue) :
            base(title, more, position, Skin.Assets["settings_binding"], Anchor.CenterLeft, startingValue, "string")
        {
            listening = new Drawable(Skin.Assets["settings_binding_focus"], position, anchor: Anchor.CenterLeft);

            key = new TextDisplayElement("", new Vector2(position.X + listening.currentSize.X / 2, position.Y), color: Color.Black, anchor: Anchor.Center);

            key.Update(GetSaveValue());
        }
Example #4
0
 /// <summary>
 /// Initializes a setting that can change different options in Pulsarc.
 /// </summary>
 /// <param name="title">Name of the Setting</param>
 /// <param name="more"></param>
 /// <param name="position">Setting's position.</param>
 /// <param name="texture">The texture for the Setting.</param>
 /// <param name="anchor">The anchor position for this Setting.</param>
 /// <param name="baseValue">The value this setting starts with.</param>
 /// <param name="type">The type of variable this setting changes.</param>
 public Setting(string title, string more, Vector2 position, Texture2D texture, Anchor anchor, dynamic baseValue, string type)
     : base(texture, position, anchor: anchor)
 {
     Value = baseValue;
     Type  = type;
     PulsarcLogger.Important($"{type} set for {title}", LogType.Runtime);
     Text  = title;
     Title = new TextDisplayElement(title, new Vector2(position.X - 50, position.Y), anchor: Anchor.CenterRight);
 }
Example #5
0
        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);
        }
Example #6
0
        public SearchBox(string search, Vector2 position, Anchor anchor = Anchor.TopLeft)
            : base(Skin.Assets["searchbox"], position, anchor: anchor)
        {
            string config  = "song_select";
            string section = "Properties";
            string name    = "SearchBarText";

            Anchor textAnchor = Skin.GetConfigAnchor(config, section, $"{name}Anchor");

            Vector2 startPos = Skin.GetConfigStartPosition(config, section, $"{name}StartPos", this);

            int fontSize = Skin.GetConfigInt(config, section, $"{name}FontSize");

            Color textColor = Skin.GetConfigColor(config, section, $"{name}Color");

            int offsetX = Skin.GetConfigInt(config, section, $"{name}X");
            int offsetY = Skin.GetConfigInt(config, section, $"{name}Y");

            textDisplay = new TextDisplayElement(search, startPos, fontSize, textAnchor, textColor);
            textDisplay.Move(offsetX, offsetY);
            textDisplay.processedPosition = textDisplay.TruePosition;
        }
Example #7
0
        /// <summary>
        /// Add the judgement and the total of that judgement to the Result Screen.
        /// </summary>
        /// <param name="name">The name of the judgement.</param>
        private void AddJudgeInfo(string name)
        {
            string         configName = char.ToUpper(name[0]) + name.Substring(1);
            JudgementValue judgement  = Judgement.GetJudgementValueByName(name);

            // Judge
            Vector2 position = Skin.GetConfigStartPosition(Config, Sections[2], $"{configName}StartPos", scorecard);
            int     offsetX  = GetSkinnableJudgementInt($"{configName}X");
            int     offsetY  = GetSkinnableJudgementInt($"{configName}Y");
            float   scale    = GetSkinnableJudgementFloat($"{configName}Scale") * Pulsarc.HeightScale;

            Judge judge = new Judge(judgement.Score, position, scale);

            judge.Move(offsetX, offsetY);

            // JudgeCount
            TextDisplayElement text = MakeTextDisplayElement($"{configName}Count", Sections[2]);

            text.Name  = name;
            text.Color = judgement.Color;

            judgements.Add(new KeyValuePair <Judge, TextDisplayElement>(judge, text));
        }
Example #8
0
        /// <summary>
        /// Add a TextDisplayElement to the Card, using the config to
        /// determine their positioning and other properties.
        /// </summary>
        /// <param name="typeName">The "typeName" of the button, or the prefix in the config.</param>
        protected virtual void AddTextDisplayElement(string typeName)
        {
            // Find variables for TDE
            Anchor  startAnchor;
            Vector2 position = Skin.GetConfigStartPosition(Config, Section, typeName + "StartPos", out startAnchor, this);
            int     fontSize = GetSkinnableInt(typeName + "FontSize");
            Anchor  anchor   = GetSkinnableAnchor(typeName + "Anchor");
            Color   color    = Skin.GetConfigColor(Config, Section, typeName + "Color");

            // Make TDE
            TextDisplayElement text = new TextDisplayElement("", position, fontSize, anchor, color);

            // Offset
            Vector2 offset = new Vector2(
                GetSkinnableInt(typeName + "X"),
                GetSkinnableInt(typeName + "Y"));

            text.Move(offset);

            //Add TDE
            TextElements.Add(text);
            TextElementOffsets.Add(text.Position - AnchorUtil.FindDrawablePosition(startAnchor, this));
            TextElementStartAnchors.Add(startAnchor);
        }