Ejemplo n.º 1
0
        private void calculateBaseSizes()
        {
            // compute the max size of a digit and separators in the English font, for the timer part.
            PixelFont     font          = Dialog.Languages["english"].Font;
            float         fontFaceSize  = Dialog.Languages["english"].FontFaceSize;
            PixelFontSize pixelFontSize = font.Get(fontFaceSize);

            for (int i = 0; i < 10; i++)
            {
                float digitWidth = pixelFontSize.Measure(i.ToString()).X;
                if (digitWidth > numberWidth)
                {
                    numberWidth = digitWidth;
                }
            }
            spacerWidth  = pixelFontSize.Measure('.').X;
            numberHeight = pixelFontSize.Measure("0:.").Y;

            // measure the ranks in the font for the current language.
            rankMeasurements = new Dictionary <string, Vector2>()
            {
                { "Gold", ActiveFont.Measure(Dialog.Clean("collabutils2_speedberry_gold") + " ") * targetTimeScale },
                { "Silver", ActiveFont.Measure(Dialog.Clean("collabutils2_speedberry_silver") + " ") * targetTimeScale },
                { "Bronze", ActiveFont.Measure(Dialog.Clean("collabutils2_speedberry_bronze") + " ") * targetTimeScale }
            };
        }
        public override void Render(Vector2 position, bool highlighted)
        {
            float alpha = Container.Alpha;
            Color color = Disabled
                ? Color.Gray * alpha
                : (highlighted ? Container.HighlightColor : Color.White) * alpha;
            Color strokeColor = Color.Black * (alpha * alpha * alpha);

            Vector2 offset = Vector2.Zero;

            foreach (var label in labels)
            {
                float scale        = 1f;
                float measureWidth = ActiveFont.Measure(label.Key).X;
                if (measureWidth > label.Value - Divider)
                {
                    scale = (label.Value - Divider) / measureWidth;
                }

                ActiveFont.DrawOutline(label.Key, position + offset, new Vector2(0.0f, 0.5f), Vector2.One * scale,
                                       color, 2f,
                                       strokeColor);
                offset += new Vector2(label.Value, 0);
            }
        }
        public override void Render()
        {
            float textWidth = ActiveFont.Measure(Text).X + 81f;

            Icon.DrawJustified(renderPosition - new Vector2(textWidth / 2f + 15f, 0f), new Vector2(0f, 0.5f));
            ActiveFont.DrawOutline(Text, renderPosition + new Vector2(81f - textWidth / 2f, 0f), new Vector2(0f, 0.5f), Vector2.One, Color, 2f, Color.Black);
        }
 public override float Width()
 {
     if (forceWidth)
     {
         return(width);
     }
     return(Math.Max(width, ActiveFont.Measure(text).X *scale));
 }
Ejemplo n.º 5
0
        private static void LevelOnRender(On.Celeste.Level.orig_Render orig, Level self)
        {
            orig(self);
            if (!Settings.Enabled)
            {
                return;
            }

            Draw.SpriteBatch.Begin();

            int viewWidth  = Engine.ViewWidth;
            int viewHeight = Engine.ViewHeight;

            string  text = Variable.Parse(DisplayContent);
            Vector2 size = ActiveFont.Measure(text) * Settings.FontSize;

            float x;
            float y;

            switch (Settings.Position)
            {
            case Position.TopLeft:
                x = Settings.Margin;
                y = Settings.Margin;
                break;

            case Position.TopRight:
                x = viewWidth - size.X - Settings.Margin - Settings.Padding * 2;
                y = Settings.Margin;
                break;

            case Position.BottomLeft:
                x = Settings.Margin;
                y = viewHeight - size.Y - Settings.Margin - Settings.Padding * 2;
                break;

            case Position.BottomRight:
                x = viewWidth - size.X - Settings.Margin - Settings.Padding * 2;
                y = viewHeight - size.Y - Settings.Margin - Settings.Padding * 2;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Vector2 rectPosition = new Vector2(x, y);

            Draw.Rect(rectPosition, size.X + Settings.Padding * 2, size.Y + Settings.Padding * 2, Color.Black * Settings.BackgroundAlpha);

            Vector2 textPosition = new Vector2(x + Settings.Padding, y + Settings.Padding);
            Vector2 scale        = new Vector2(Settings.FontSize);

            ActiveFont.Draw(text, textPosition, Vector2.Zero, scale, Color.White * Settings.FontAlpha);

            Draw.SpriteBatch.End();
        }
Ejemplo n.º 6
0
        public override void Render()
        {
            if (ease > 0f)
            {
                Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * ease * 0.4f);
            }
            base.Render();

            const float spacingX = 48f;
            const float spacingY = 64f;

            Vector2 posCenter = Position + new Vector2(1920f / 2f, 1080f / 2f);
            Vector2 pos;

            // Vector2 posInput = posCenter - new Vector2(spacingX * (digits.Length - 1f) / 2f, spacingY * 0.5f);
            Vector2 posInput = Position + new Vector2(384f, 1080f / 2f);

            pos = posInput;
            for (int i = 0; i < digits.Length; i++)
            {
                DrawOptionText(digits[i].ToString("X1"), pos + new Vector2(0f, wigglerDigits[i].Value * 8f), new Vector2(0f, 0.5f), Vector2.One, selectedDigit == i && !musicParamMenu.Focused, i <= 1);
                pos.X += spacingX;
            }

            // pos = posCenter + new Vector2(0f, spacingY * 0.5f + wigglerPath.Value * 2f);
            pos = posInput + new Vector2(spacingX * 2f, spacingY * 0.8f + wigglerPath.Value * 2f);
            ActiveFont.DrawOutline(selectedPath ?? "", pos, new Vector2(0f, 0.5f), Vector2.One * 0.75f, Color.White * ease, 2f, Color.Black * ease * ease * ease);

            pos = posInput + new Vector2(0f, spacingY * -0.8f + wigglerBankPath.Value * 2f);
            ActiveFont.DrawOutline(selectedBankPath ?? "", pos, new Vector2(0f, 0.5f), Vector2.One * 0.75f, Color.LightSlateGray * ease, 2f, Color.Black * ease * ease * ease);

            if (musicParamMenu.GetItems().Count > 0)
            {
                // Press...
                pos = posInput + new Vector2(0f, spacingY * 2f + wigglerBankPath.Value * 2f);
                ActiveFont.DrawOutline(Dialog.Clean("SOUNDTEST_AUDIOPARAMS_OPEN_1"), pos, new Vector2(0f, 0.5f), Vector2.One * 0.75f, Color.White * ease, 2f, Color.Black * ease * ease * ease);

                // ... [button image] ...
                pos.X += ActiveFont.Measure(Dialog.Clean("SOUNDTEST_AUDIOPARAMS_OPEN_1")).X * 0.75f + 10f;
                MTexture button = Input.GuiButton(Input.MenuJournal);
                button.DrawJustified(pos, new Vector2(0f, 0.5f), Color.White, 0.75f);
                pos.X += button.Width * 0.75f + 10f;

                // ... to edit Audio Params
                ActiveFont.DrawOutline(Dialog.Clean("SOUNDTEST_AUDIOPARAMS_OPEN_2"), pos, new Vector2(0f, 0.5f), Vector2.One * 0.75f, Color.White * ease, 2f, Color.Black * ease * ease * ease);
            }

            ActiveFont.DrawEdgeOutline(Dialog.Clean("soundtest_title"), Position + new Vector2(960f, 256f), new Vector2(0.5f, 0.5f), Vector2.One * 2f, Color.Gray, 4f, Color.DarkSlateBlue, 2f, Color.Black);

            if (musicParamMenuEase > 0f)
            {
                Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * 0.95f * Ease.CubeInOut(musicParamMenuEase));
                musicParamMenu.Alpha = Ease.CubeInOut(musicParamMenuEase);
                musicParamMenu.Render();
            }
        }
        private float GetDefaultValueWidth()
        {
            float width = 0f;

            for (int i = Min; i <= Max; i++)
            {
                width = Math.Max(width, ActiveFont.Measure(ValuesFunc(i)).X);
            }
            return(width);
        }
Ejemplo n.º 8
0
        public void SetDisplayText(string text)
        {
            _text  = text;
            _width = ActiveFont.Measure(_text).X + TextPadLeft + TextPadRight;

            if (DeathTrackerModule.Settings.DisplayVisibility == AfterDeath || DeathTrackerModule.Settings.DisplayVisibility == AfterDeathAndInMenu)
            {
                _timer = 3f;
            }
        }
Ejemplo n.º 9
0
        private Tooltip(string message)
        {
            this.message = message;
            Vector2 messageSize = ActiveFont.Measure(message);

            Position = new(Padding, Engine.Height - messageSize.Y - Padding / 2f);
            Tag      = TagsExt.SubHUD | Tags.Global | Tags.FrozenUpdate | Tags.TransitionUpdate;
            Add(new Coroutine(Show()));
            Add(new IgnoreSaveLoadComponent());
        }
Ejemplo n.º 10
0
        public override void Render()
        {
            base.Render();

            if (Alpha <= 0f || string.IsNullOrWhiteSpace(Name))
            {
                return;
            }

            if (!GhostModule.Settings.ShowNames ||
                Tracking == null)
            {
                return;
            }

            Level level = SceneAs <Level>();

            if (level == null /*|| level.FrozenOrPaused || level.RetryPlayerCorpse != null || level.SkippingCutscene*/)
            {
                return;
            }

            if (Camera == null)
            {
                Camera = level.Camera;
            }
            if (Camera == null)
            {
                return;
            }

            Vector2 pos = Tracking.Position;

            pos.Y -= 16f;

            pos -= level.Camera.Position;
            pos *= 6f; // 1920 / 320

            Vector2 size = ActiveFont.Measure(Name);

            pos = pos.Clamp(
                0f + size.X * 0.5f, 0f + size.Y * 1f,
                1920f - size.X * 0.5f, 1080f
                );

            ActiveFont.DrawOutline(
                Name,
                pos,
                new Vector2(0.5f, 1f),
                Vector2.One * 0.5f,
                Color.White * Alpha,
                2f,
                Color.Black * (Alpha * Alpha * Alpha)
                );
        }
            public override void Render(Vector2 center, float columnWidth)
            {
                float num         = ActiveFont.Measure(text).X *scale;
                float scaleFactor = 1f;

                if (!forceWidth && num > columnWidth)
                {
                    scaleFactor = columnWidth / num;
                }
                ActiveFont.Draw(text, center + new Vector2(-columnWidth / 2f + columnWidth * justify.X, 0f), justify, Vector2.One * scale * scaleFactor, color);
            }
Ejemplo n.º 12
0
        public override IEnumerator Routine()
        {
            string[] text = Presentation.GetCleanDialog("PAGE2_TITLE").Split(new char[]
            {
                '|'
            });
            Vector2 pos = new Vector2(128f, 128f);
            int     num;

            for (int i = 0; i < text.Length; i = num + 1)
            {
                TitleText item = new TitleText(pos, text[i]);
                title.Add(item);
                yield return(item.Stamp());

                pos.X += item.Width + ActiveFont.Measure(' ').X * 1.5f;
                item   = null;
                num    = i;
            }
            text = null;
            pos  = default;
            yield return(PressButton());

            list = FancyText.Parse(Presentation.GetDialog("PAGE2_LIST"), Width, 32, 1f, new Color?(Color.Black * 0.7f), null);
            float delay = 0f;

            while (listIndex < list.Nodes.Count)
            {
                if (list.Nodes[listIndex] is FancyText.NewLine)
                {
                    yield return(PressButton());
                }
                else
                {
                    delay += 0.008f;
                    if (delay >= 0.016f)
                    {
                        delay -= 0.016f;
                        yield return(0.016f);
                    }
                }
                listIndex++;
            }
            yield return(PressButton());

            Audio.Play("event:/new_content/game/10_farewell/ppt_impossible");
            while (impossibleEase < 1f)
            {
                impossibleEase = Calc.Approach(impossibleEase, 1f, Engine.DeltaTime);
                yield return(null);
            }
            yield break;
        }
        /// <summary>
        /// Setter function for display text. Also adjust width accordingly and reset timer.
        /// </summary>
        /// <param name="s">Display text.</param>
        public void SetDisplayText(string s)
        {
            // Don't update values if text doesn't change
            if (text.Equals(s))
            {
                return;
            }

            text  = s;
            width = ActiveFont.Measure(text).X + TEXT_PAD_L + TEXT_PAD_R;
            timer = 3;
        }
Ejemplo n.º 14
0
        /// <summary></summary>
        /// <param name="dialog">Dialog ID, replaces first occurence of "{X}" with the counter.</param>
        /// <param name="target">Target for the counter.</param>
        /// <param name="from">Counter start.</param>
        /// <param name="progressAudio">Whether to increment audio progression.</param>
        /// <param name="displayOnTransition"></param>
        public CustomHeightDisplay(string dialog, int target, int from = 0, bool progressAudio = false, bool displayOnTransition = false)
            : base()
        {
            Text      = dialog;
            leftText  = "";
            rightText = "";

            this.displayOnTransition = displayOnTransition;
            easingCamera             = true;

            // Just pretend audio was already progressed if not needed
            audioProgressed = !progressAudio;

            if (target > from)
            {
                if (Dialog.Has(dialog))
                {
                    Text = Dialog.Get(dialog).ToUpper();
                }

                Target   = target;
                Approach = from;

                int idx = Text.IndexOf("{x}", StringComparison.InvariantCultureIgnoreCase);
                if (idx != -1)
                {
                    hasCount     = true;
                    displaySound = SFX.game_07_altitudecount;

                    leftText = Text.Substring(0, idx);
                    if (idx + 3 < Text.Length)
                    {
                        rightText = Text.Substring(idx + 3);
                    }

                    leftSize   = ActiveFont.Measure(leftText).X;
                    numberSize = ActiveFont.Measure(Target.ToString()).X;

                    size = ActiveFont.Measure(leftText + Target + rightText);
                }
                else
                {
                    displaySound = SFX.game_07_checkpointconfetti;

                    leftText = Text;
                    size     = ActiveFont.Measure(leftText);
                }
            }

            Tag = Tags.HUD | Tags.Persistent | Tags.TransitionUpdate;
            Add(new Coroutine(Routine()));
        }
Ejemplo n.º 15
0
        public SpeedRingTimerDisplay(SpeedRingChallenge challenge)
        {
            Tag = Tags.HUD | Tags.PauseUpdate;
            CalculateBaseSizes();
            Add(Wiggler.Create(0.5f, 4f, null, false, false));
            TrackedChallenge = challenge;
            fadeTime         = 3f;

            CreateTween(0.1f, t => {
                Position = Vector2.Lerp(OffscreenPos, OnscreenPos, t.Eased);
            });

            Name        = Dialog.Clean(challenge.ChallengeNameID);
            NameMeasure = ActiveFont.Measure(Name);
        }
Ejemplo n.º 16
0
        public override void Render()
        {
            const float scale = 0.75f;
            float       width = ActiveFont.Measure(text).X;

            width *= scale;
            ActiveFont.DrawOutline(
                text,
                new Vector2((1920f - width) / 2f, 980f),
                new Vector2(0f, 0.5f),
                Vector2.One * scale,
                Color.LightGray,
                2f, Color.Black
                );
        }
Ejemplo n.º 17
0
        public void DrawTaskbar()
        {
            Draw.Rect(0f, Height - 80f, Width, 80f, taskbarColor);
            Draw.Rect(0f, Height - 80f, Width, 4f, Color.White * 0.5f);
            MTexture mtexture = Presentation.Gfx["desktop/startberry"];
            float    num      = 64f;
            float    num2     = num / mtexture.Height * 0.7f;
            string   text     = Presentation.GetCleanDialog("DESKTOP_STARTBUTTON");
            float    num3     = 0.6f;
            float    width    = mtexture.Width * num2 + ActiveFont.Measure(text).X *num3 + 32f;
            Vector2  vector   = new Vector2(8f, Height - 80f + 8f);

            Draw.Rect(vector.X, vector.Y, width, num, Color.White * 0.5f);
            mtexture.DrawJustified(vector + new Vector2(8f, num / 2f), new Vector2(0f, 0.5f), Color.White, Vector2.One * num2);
            ActiveFont.Draw(text, vector + new Vector2(mtexture.Width * num2 + 16f, num / 2f), new Vector2(0f, 0.5f), Vector2.One * num3, Color.Black * 0.8f);
            ActiveFont.Draw(time, new Vector2(Width - 24f, Height - 40f), new Vector2(1f, 0.5f), Vector2.One * 0.6f, Color.Black * 0.8f);
        }
        public OuiFileSelectSlotLevelSetPicker(OuiFileSelectSlot selectSlot)
        {
            this.selectSlot = selectSlot;

            Label  = DialogExt.CleanLevelSet(NewGameLevelSet ?? "Celeste");
            Scale  = 0.5f;
            Action = () => changeStartingLevelSet(1);

            // find out what is the width of the biggest level set out there.
            float levelSetNameWidth = 0;

            foreach (AreaData areaData in AreaData.Areas)
            {
                levelSetNameWidth = Math.Max(levelSetNameWidth, ActiveFont.Measure(DialogExt.CleanLevelSet(areaData.GetLevelSet())).X);
            }
            arrowOffset = new Vector2(20f + levelSetNameWidth / 2 * Scale, 0f);
        }
Ejemplo n.º 19
0
        public override void Render(Vector2 position, bool highlighted)
        {
            float alpha       = Container.Alpha;
            Color color       = Color.Gray * alpha;
            Color strokeColor = Color.Black * (alpha * alpha * alpha);

            Vector2 offset = Vector2.Zero;

            foreach (var label in labels)
            {
                ActiveFont.DrawOutline(label.Key, position + offset, new Vector2(0.0f, 0.5f), Vector2.One, color, 2f,
                                       strokeColor);
                ActiveFont.DrawOutline(label.Value, position + offset + ActiveFont.Measure(label.Key).XComp(),
                                       new Vector2(0.0f, 0.5f), Vector2.One, Color.White, 2f, strokeColor);
                offset += new Vector2(FixedWidth / labels.Count, 0);
            }
        }
Ejemplo n.º 20
0
        public override void Render()
        {
            if (Everest.Flags.IsDisabled)
            {
                orig_Render();
                return;
            }

            orig_Render();
            if (maplistEase > 0f)
            {
                Vector2 pos = new Vector2(128f * Ease.CubeOut(maplistEase), 1080f - 128f);
                if (journalEnabled)
                {
                    pos.Y -= 128f;
                }
                GFX.Gui["menu/maplist"].DrawCentered(pos, Color.White * Ease.CubeOut(maplistEase));
                (Input.GuiInputController() ? Input.GuiButton(Input.Pause) : Input.GuiButton(Input.ESC)).Draw(pos, Vector2.Zero, Color.White * Ease.CubeOut(maplistEase));
            }

            if (searchEase > 0f)
            {
                Vector2 pos = new Vector2(128f * Ease.CubeOut(searchEase), 1080f - 128f);
                if (journalEnabled)
                {
                    pos.Y -= 256f;
                }
                else
                {
                    pos.Y -= 128f;
                }
                GFX.Gui["menu/mapsearch"].DrawCentered(pos, Color.White * Ease.CubeOut(searchEase));
                Input.GuiKey(Input.FirstKey(Input.QuickRestart)).Draw(pos, Vector2.Zero, Color.White * Ease.CubeOut(searchEase));
            }

            if (levelsetEase > 0f)
            {
                Vector2 pos  = new Vector2(1920f - 64f * Ease.CubeOut(maplistEase), 1080f - 128f);
                string  line = DialogExt.CleanLevelSet(currentLevelSet);
                ActiveFont.DrawOutline(line, pos, new Vector2(1f, 0.5f), Vector2.One * 0.7f, Color.White * Ease.CubeOut(maplistEase), 2f, Color.Black * Ease.CubeOut(maplistEase));
                Vector2 lineSize = ActiveFont.Measure(line) * 0.7f;
                Input.GuiDirection(new Vector2(0f, -1f)).DrawCentered(pos + new Vector2(-lineSize.X * 0.5f, -lineSize.Y * 0.5f - 16f), Color.White * Ease.CubeOut(maplistEase), 0.5f);
                Input.GuiDirection(new Vector2(0f, +1f)).DrawCentered(pos + new Vector2(-lineSize.X * 0.5f, +lineSize.Y * 0.5f + 16f), Color.White * Ease.CubeOut(maplistEase), 0.5f);
            }
        }
        private void EndlessShowScore2(On.Celeste.AreaComplete.orig_Info orig, float ease, string speedruntimerchapterstring, string speedruntimerfilestring, string chapterspeedruntext, string versiontext)
        {
            var settings     = Engine.Scene is AreaComplete ? this.endingSettings : this.InRandomizerSettings;
            var savedSetting = global::Celeste.Settings.Instance.SpeedrunClock;

            if (savedSetting != SpeedrunType.Off && settings != null && settings.Algorithm == LogicType.Endless)
            {
                global::Celeste.Settings.Instance.SpeedrunClock = SpeedrunType.Chapter;
            }
            orig(ease, speedruntimerchapterstring, speedruntimerfilestring, chapterspeedruntext, versiontext);
            global::Celeste.Settings.Instance.SpeedrunClock = savedSetting;

            if (settings != null && settings.Algorithm == LogicType.Endless)
            {
                Vector2 position          = new Vector2((float)(80.0 - 300.0 * (1.0 - (double)Ease.CubeOut(ease))), 1000f);
                var     scoreSpeedrunText = Dialog.Clean("RANDOENDLESS_SCORE");
                ActiveFont.DrawOutline(scoreSpeedrunText, position + new Vector2(0.0f, 40f), new Vector2(0.0f, 1f), Vector2.One * 0.6f, Color.White, 2f, Color.Black);
                SpeedrunTimerDisplay.DrawTime(position + new Vector2((float)((double)ActiveFont.Measure(scoreSpeedrunText).X * 0.6000000238418579 + 8.0), 40f), this.CurrentScore.ToString(), 0.6f);
            }
        }
Ejemplo n.º 22
0
        private float findMaxWidth()
        {
            if (texts.Count == 0)
            {
                return(0);
            }

            float maxWidth = float.MinValue;

            foreach (string str in texts)
            {
                float width = ActiveFont.Measure(str).X * 0.7f;

                if (width > maxWidth)
                {
                    maxWidth = width;
                }
            }

            return(maxWidth);
        }
Ejemplo n.º 23
0
        public override void Render(Vector2 position, bool highlighted)
        {
            Vector2 top = new(position.X, position.Y - (Height() / 2));

            float currentAlpha = Container.Alpha * alpha;
            Color color        = Disabled ? Color.DarkSlateGray : ((highlighted ? Container.HighlightColor : Color.White) * currentAlpha);
            Color strokeColor  = Color.Black * (currentAlpha * currentAlpha * currentAlpha);

            bool unCentered = Container.InnerContent == TextMenu.InnerContentMode.TwoColumn && !AlwaysCenter;

            Vector2 titlePosition = top + (Vector2.UnitY * TitleHeight / 2) + (unCentered ? Vector2.Zero : new Vector2(Container.Width * 0.5f, 0f));
            Vector2 justify       = unCentered ? new Vector2(0f, 0.5f) : new Vector2(0.5f, 0.5f);
            Vector2 iconJustify   = unCentered
                ? new Vector2(ActiveFont.Measure(Label).X + icon.Width, 5f)
                : new Vector2(ActiveFont.Measure(Label).X / 2 + icon.Width, 5f);

            DrawIcon(titlePosition, iconJustify, true, Items.Count < 1 ? Color.DarkSlateGray : color, alpha);
            ActiveFont.DrawOutline(Label, titlePosition, justify, Vector2.One, color, 2f, strokeColor);

            if (Focused && ease > 0.9f)
            {
                Vector2 menuPosition = new(top.X + ItemIndent, top.Y + TitleHeight + ItemSpacing);
                RecalculateSize();
                foreach (TextMenu.Item item in Items)
                {
                    if (item.Visible)
                    {
                        float   height       = item.Height();
                        Vector2 itemPosition = menuPosition + new Vector2(0f, height * 0.5f + item.SelectWiggler.Value * 8f);
                        if (itemPosition.Y + height * 0.5f > 0f && itemPosition.Y - height * 0.5f < Engine.Height)
                        {
                            item.Render(itemPosition, Focused && Current == item);
                        }

                        menuPosition.Y += height + ItemSpacing;
                    }
                }
            }
        }
Ejemplo n.º 24
0
        public OuiFileSelectSlotLevelSetPicker(OuiFileSelectSlot selectSlot)
        {
            this.selectSlot = selectSlot;

            // if the default starting level set still exists, set it by default.
            if (AreaData.Areas.Any(area => area.GetLevelSet() == CoreModule.Settings.DefaultStartingLevelSet))
            {
                NewGameLevelSet = CoreModule.Settings.DefaultStartingLevelSet;
            }

            Label  = DialogExt.CleanLevelSet(NewGameLevelSet ?? "Celeste");
            Scale  = 0.5f;
            Action = () => changeStartingLevelSet(1);

            // find out what is the width of the biggest level set out there.
            float levelSetNameWidth = 0;

            foreach (AreaData areaData in AreaData.Areas)
            {
                levelSetNameWidth = Math.Max(levelSetNameWidth, ActiveFont.Measure(DialogExt.CleanLevelSet(areaData.GetLevelSet())).X);
            }
            arrowOffset = new Vector2(20f + levelSetNameWidth / 2 * Scale, 0f);
        }
Ejemplo n.º 25
0
        public CustomMemorialText(CustomMemorial memorial, bool dreamy, string text, float spacing)
            : base()
        {
            Tag         = Tags.HUD | Tags.PauseUpdate;
            Add(textSfx = new SoundSource());

            Dreamy   = dreamy;
            Memorial = memorial;
            Message  = text;
            Spacing  = spacing;

            firstLineLength = CountToNewline(0);

            string[] lines = text.Split('\n');
            lineWidths = new float[lines.Length];

            for (int i = 0; i < lines.Length; i++)
            {
                lineWidths[i] = ActiveFont.Measure(lines[i]).X + spacing * lines[i].Length;
            }

            charChars = ActiveFont.Font.Get(ActiveFont.BaseSize).Characters;
        }
Ejemplo n.º 26
0
        public CustomMemorialText(CustomMemorial memorial, bool dreamy, string text)
            : base()
        {
            AddTag(Tags.HUD);
            AddTag(Tags.PauseUpdate);
            Add(textSfx = new SoundSource());

            Dreamy   = dreamy;
            Memorial = memorial;
            message  = text;

            firstLineLength = CountToNewline(0);

            for (int i = 0; i < message.Length; i++)
            {
                float width = ActiveFont.Measure(message[i]).X;
                if (width > widestCharacter)
                {
                    widestCharacter = width;
                }
            }
            widestCharacter *= 0.9f;
        }
            public override void Render(Vector2 position, bool highlighted)
            {
                Color textColor   = Color.Gray * Ease.CubeOut(Container.Alpha);
                Color strokeColor = Color.Black * Ease.CubeOut(Container.Alpha);
                Color btnColor    = Color.White * Ease.CubeOut(Container.Alpha);

                float taken = 0f;

                for (int i = 0; i < info.Count; i++)
                {
                    if (info[i] is string text)
                    {
                        taken += ActiveFont.Measure(text).X * 0.6f;
                    }
                    else if (info[i] is VirtualButton btn)
                    {
                        taken += Input.GuiButton(btn).Width * 0.6f;
                    }
                }

                Vector2 pos = position + new Vector2(Container.Width - taken, 0f) / 2f;

                for (int i = 0; i < info.Count; i++)
                {
                    if (info[i] is string text)
                    {
                        ActiveFont.DrawOutline(text, pos, new Vector2(0f, 0.5f), Vector2.One * 0.6f, textColor, 2f, strokeColor);
                        pos.X += ActiveFont.Measure(text).X * 0.6f;
                    }
                    else if (info[i] is VirtualButton btn)
                    {
                        MTexture tex = Input.GuiButton(btn);
                        tex.DrawJustified(pos, new Vector2(0f, 0.5f), btnColor, 0.6f);
                        pos.X += tex.Width * 0.6f;
                    }
                }
            }
Ejemplo n.º 28
0
        public override IEnumerator Enter(Oui from)
        {
            TextInput.OnInput += OnKeyboardInput;

            Overworld.ShowInputUI = false;

            selectingOptions = false;
            optionsIndex     = 0;
            index            = 0;
            line             = 0;

            // Create the keyboard, and take the measurements for it.
            string letterChars = "7 8 9\n4 5 6\n1 2 3\n- 0 .";

            letters = letterChars.Split('\n');

            foreach (char c in letterChars)
            {
                float width = ActiveFont.Measure(c).X;
                if (width > widestLetter)
                {
                    widestLetter = width;
                }
            }

            widestLineCount = 0;
            foreach (string letter in letters)
            {
                if (letter.Length > widestLineCount)
                {
                    widestLineCount = letter.Length;
                }
            }

            widestLine    = widestLineCount * widestLetter;
            letterChars   = null;
            boxPadding    = widestLetter;
            keyboardWidth = widestLine + boxPadding * 2f;

            lineHeight  = ActiveFont.LineHeight;
            lineSpacing = ActiveFont.LineHeight * 0.1f;

            // take the measurements for options.
            optionsScale   = 0.75f;
            cancel         = Dialog.Clean("name_back");
            backspace      = Dialog.Clean("name_backspace");
            accept         = Dialog.Clean("name_accept");
            cancelWidth    = ActiveFont.Measure(cancel).X *optionsScale;
            backspaceWidth = ActiveFont.Measure(backspace).X *optionsScale;
            acceptWidth    = ActiveFont.Measure(accept).X *optionsScale;
            optionsWidth   = cancelWidth + backspaceWidth + acceptWidth + widestLetter * 3f;

            boxWidth  = Math.Max(widestLine, optionsWidth) + boxPadding * 2f;
            boxHeight = (letters.Length + 1f) * lineHeight + letters.Length * lineSpacing + boxPadding * 3f;

            Visible = true;

            // Ease the keyboard in.
            Vector2 posFrom = Position;
            Vector2 posTo   = Vector2.Zero;

            for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f)
            {
                ease     = Ease.CubeIn(t);
                Position = posFrom + (posTo - posFrom) * Ease.CubeInOut(t);
                yield return(null);
            }
            ease    = 1f;
            posFrom = Vector2.Zero;
            posTo   = Vector2.Zero;

            yield return(0.2f);

            Focused = true;

            yield return(0.2f);

            wiggler.Start();
        }
Ejemplo n.º 29
0
        private float _FixTitleLength(float vanillaValue)
        {
            float mapNameSize = ActiveFont.Measure(Dialog.Clean(AreaData.Get(Area).Name)).X;

            return(vanillaValue - Math.Max(0f, mapNameSize + vanillaValue - 490f));
        }
Ejemplo n.º 30
0
        public override void Render()
        {
            base.Render();

            string[] emotes = GhostNetModule.Settings.EmoteFavs;

            // Update can halt in the pause menu.

            if (Shown)
            {
                Angle = GhostNetModule.Instance.JoystickEmoteWheel.Value.Angle();
                float angle = (float)((Angle + Math.PI * 2f) % (Math.PI * 2f));
                float start = (-0.5f / emotes.Length) * 2f * (float)Math.PI;
                if (2f * (float)Math.PI + start < angle)
                {
                    // Angle should be start < angle < 0, but is (TAU + start) < angle < TAU
                    angle -= 2f * (float)Math.PI;
                }
                for (int i = 0; i < emotes.Length; i++)
                {
                    float min = ((i - 0.5f) / emotes.Length) * 2f * (float)Math.PI;
                    float max = ((i + 0.5f) / emotes.Length) * 2f * (float)Math.PI;
                    if (min <= angle && angle <= max)
                    {
                        Selected = i;
                        break;
                    }
                }
            }

            time += Engine.RawDeltaTime;

            if (!Shown)
            {
                Selected = -1;
            }
            selectedTime += Engine.RawDeltaTime;
            if (PrevSelected != Selected)
            {
                selectedTime = 0f;
                PrevSelected = Selected;
            }

            float popupAlpha;
            float popupScale;

            popupTime += Engine.RawDeltaTime;
            if (Shown && !popupShown)
            {
                popupTime = 0f;
            }
            else if ((Shown && popupTime > 1f) ||
                     (!Shown && popupTime < 1f))
            {
                popupTime = 1f;
            }
            popupShown = Shown;

            if (popupTime < 0.1f)
            {
                float t = popupTime / 0.1f;
                // Pop in.
                popupAlpha = Ease.CubeOut(t);
                popupScale = Ease.ElasticOut(t);
            }
            else if (popupTime < 1f)
            {
                // Stay.
                popupAlpha = 1f;
                popupScale = 1f;
            }
            else
            {
                float t = (popupTime - 1f) / 0.2f;
                // Fade out.
                popupAlpha = 1f - Ease.CubeIn(t);
                popupScale = 1f - 0.2f * Ease.CubeIn(t);
            }

            float alpha = Alpha * popupAlpha;

            if (alpha <= 0f)
            {
                return;
            }

            if (Tracking == null)
            {
                return;
            }

            Level level = SceneAs <Level>();

            if (level == null)
            {
                return;
            }

            if (Camera == null)
            {
                Camera = level.Camera;
            }
            if (Camera == null)
            {
                return;
            }

            Vector2 pos = Tracking.Position;

            pos.Y -= 8f;

            pos -= level.Camera.Position;
            pos *= 6f; // 1920 / 320

            float radius = BG.Width * 0.5f * 0.75f * popupScale;

            pos = pos.Clamp(
                0f + radius, 0f + radius,
                1920f - radius, 1080f - radius
                );

            // Draw.Circle(pos, radius, Color.Black * 0.8f * alpha * alpha, radius * 0.6f * (1f + 0.2f * (float) Math.Sin(time)), 8);
            BG.DrawCentered(
                pos,
                Color.White * alpha * alpha * alpha,
                Vector2.One * popupScale
                );

            Indicator.DrawCentered(
                pos,
                Color.White * alpha * alpha * alpha,
                Vector2.One * popupScale,
                Angle
                );

            float selectedScale = 1.2f - 0.2f * Calc.Clamp(Ease.CubeOut(selectedTime / 0.1f), 0f, 1f) + (float)Math.Sin(time * 1.8f) * 0.05f;

            for (int i = 0; i < emotes.Length; i++)
            {
                Line.DrawCentered(
                    pos,
                    Color.White * alpha * alpha * alpha,
                    Vector2.One * popupScale,
                    ((i + 0.5f) / emotes.Length) * 2f * (float)Math.PI
                    );

                string emote = emotes[i];
                if (string.IsNullOrEmpty(emote))
                {
                    continue;
                }

                float   a        = (i / (float)emotes.Length) * 2f * (float)Math.PI;
                Vector2 emotePos = pos + new Vector2(
                    (float)Math.Cos(a),
                    (float)Math.Sin(a)
                    ) * radius;

                if (GhostNetEmote.IsIcon(emote))
                {
                    MTexture icon = GhostNetEmote.GetIcon(emote, Selected == i ? selectedTime : 0f);
                    if (icon == null)
                    {
                        continue;
                    }

                    Vector2 iconSize  = new Vector2(icon.Width, icon.Height);
                    float   iconScale = (GhostNetEmote.Size / Math.Max(iconSize.X, iconSize.Y)) * 0.24f * popupScale;

                    icon.DrawCentered(
                        emotePos,
                        Color.White * (Selected == i ? (Calc.BetweenInterval(selectedTime, 0.1f) ? 0.9f : 1f) : 0.7f) * alpha,
                        Vector2.One * (Selected == i ? selectedScale : 1f) * iconScale
                        );
                }
                else
                {
                    Vector2 textSize  = ActiveFont.Measure(emote);
                    float   textScale = (GhostNetEmote.Size / Math.Max(textSize.X, textSize.Y)) * 0.24f * popupScale;

                    ActiveFont.DrawOutline(
                        emote,
                        emotePos,
                        new Vector2(0.5f, 0.5f),
                        Vector2.One * (Selected == i ? selectedScale : 1f) * textScale,
                        (Selected == i ? (Calc.BetweenInterval(selectedTime, 0.1f) ? TextSelectColorA : TextSelectColorB) : Color.LightSlateGray) * alpha,
                        2f,
                        Color.Black * alpha * alpha * alpha
                        );
                }
            }
        }