Esempio n. 1
0
        public Option(string key)
        {
            this.Key = key;
            this.Tag = (int)Tags.HUD;

            int maxLineWidth = 1828;

            this.Text = FancyText.Parse(Dialog.Get(this.Key), maxLineWidth, -1);
            foreach (FancyText.Node node in this.Text.Nodes)
            {
                if (!(node is FancyText.Portrait portrait))
                {
                    continue;
                }

                this.Portrait = GFX.PortraitsSpriteBank.Create(portrait.SpriteId);
                this.Portrait.Play(portrait.IdleAnimation);
                this.PortraitSide = (Facings)portrait.Side;
                this.Textbox      = "textbox/" + portrait.Sprite + "_ask";
                XmlElement xml = GFX.PortraitsSpriteBank.SpriteData[portrait.SpriteId].Sources[0].XML;
                if (xml != null)
                {
                    this.PortraitSize = xml.AttrInt("size", 160);
                }

                break;
            }
        }
Esempio n. 2
0
        public CustomTextVignette(Session session, string text, HiresSnow snow = null)
        {
            this.session = session;
            areaMusic    = session.Audio.Music.Event;
            session.Audio.Music.Event = null;
            session.Audio.Apply();

            sfx = Audio.Play(SFX.music_prologue_intro_vignette);

            if (snow == null)
            {
                fade = 1f;
                snow = new HiresSnow();
            }
            Add(renderer  = new HudRenderer());
            Add(this.snow = snow);
            RendererList.UpdateLists();

            this.text     = FancyText.Parse(Dialog.Get(text), 960, 8, 0f);
            textCoroutine = new Coroutine(TextSequence());
        }
Esempio n. 3
0
        public override void Render()
        {
            float ease = selfData.Get <float>("ease");

            if (ease <= 0f)
            {
                return;
            }
            Level level = Scene as Level;

            if (!level.FrozenOrPaused && level.RetryPlayerCorpse == null && !level.SkippingCutscene)
            {
                MTexture       box           = selfData.Get <MTexture>("box");
                Sprite         portrait      = selfData.Get <Sprite>("portrait");
                FancyText.Text text          = selfData.Get <FancyText.Text>("text");
                float          portraitScale = selfData.Get <float>("portraitScale");
                float          portraitSize  = selfData.Get <float>("portraitSize");
                int            index         = selfData.Get <int>("index");

                Vector2 vector = new Vector2(Engine.Width / 2, 72f + (Engine.Width - 1688f) / 4f);
                if (anchor == FancyText.Anchors.Bottom)
                {
                    vector.Y = Engine.Height - vector.Y;
                }
                else if (anchor == FancyText.Anchors.Middle)
                {
                    vector.Y = Engine.Height / 2;
                }
                Vector2 value = vector + new Vector2(-828f, -56f);

                box.DrawCentered(vector, Color.White, new Vector2(1f, ease));
                if (portrait != null)
                {
                    portrait.Scale          = new Vector2(1f, ease) * portraitScale;
                    portrait.RenderPosition = value + new Vector2(portraitSize / 2f, portraitSize / 2f);
                    portrait.Render();
                }
                text.Draw(new Vector2(value.X + portraitSize + 32f, vector.Y), new Vector2(0f, 0.5f), new Vector2(1f, ease) * 0.75f, 1f, 0, index);
            }
        }
Esempio n. 4
0
        void RandomizeTextboxText(On.Celeste.Textbox.orig_ctor_string_Language_Func1Array orig, Textbox self, string dialog, Language language, Func <IEnumerator>[] events)
        {
            if (InRandomizer && RandoLogic.RandomDialogMappings.ContainsKey(dialog.ToLower()))
            {
                DynData <Textbox> selfData = new DynData <Textbox>(self);
                FancyText.Text    origText = FancyText.Parse(Dialog.Get(dialog, language), (int)selfData.Get <float>("maxLineWidth"), selfData.Get <int>("linesPerPage"), 0f, null, language);
                var origTriggers           = new List <FancyText.Trigger>(origText.Nodes.OfType <FancyText.Trigger>());
                orig(self, RandoLogic.RandomDialogMappings[dialog.ToLower()], language, events);

                // Replace triggers from randomized text with triggers from original text
                int origIndex = 0;
                for (int i = 0; i < self.Nodes.Count; i++)
                {
                    if (self.Nodes[i] is FancyText.Trigger trigger)
                    {
                        if (origIndex < origTriggers.Count)
                        {
                            trigger.Index  = origTriggers[origIndex].Index;
                            trigger.Label  = origTriggers[origIndex].Label;
                            trigger.Silent = origTriggers[origIndex].Silent;
                            origIndex++;
                        }
                        else
                        {
                            // This effectively disables the trigger if we've run out of original triggers
                            trigger.Index = -1;
                        }
                    }
                }
                // Add the remaining original triggers on to the end
                if (origIndex < origTriggers.Count)
                {
                    self.Nodes.AddRange(origTriggers.GetRange(origIndex, origTriggers.Count - origIndex));
                }
            }
            else
            {
                orig(self, dialog, language, events);
            }
        }