Пример #1
0
        private DialogueBox(Font font, float width, float height)
            : base("", Anchor.TopMiddle, -0.5f * width, 16.0f, width, height)
        {
            m_font  = font;
            m_modal = false;

            PauseWorld       = false;
            BlockInput       = m_modal;
            FadeWorld        = false;
            AllowUserClose   = false;
            ShowAcceptPrompt = false;

            m_state                = State.Finished;
            m_characterName        = "";
            m_visibleCharacterName = 0;
            m_fullDialogue         = "";
            m_dialogueLines        = new string[0];
            m_visibleDialogueLines = 0;
            m_visibleDialogueChars = 0;
            m_typeTimer            = 0.0f;
            m_firstLine            = 0;

            // Create elements
            // Populate dialog
            // Image
            var imageWidth  = height - BOTTOM_MARGIN_SIZE - BOTTOM_MARGIN_SIZE;
            var imageBorder = new Box(Core.Render.Texture.Get("gui/inset_border.png", true), imageWidth, imageWidth);

            imageBorder.Anchor        = Anchor;
            imageBorder.LocalPosition = new Vector2(LocalPosition.X + width - RIGHT_MARGIN_SIZE - 6.0f - imageBorder.Width, LocalPosition.Y + BOTTOM_MARGIN_SIZE);

            m_image               = new Image(Core.Render.Texture.Black, imageBorder.Width - 6.0f, imageBorder.Height - 6.0f);
            m_image.Anchor        = imageBorder.Anchor;
            m_image.LocalPosition = imageBorder.LocalPosition + new Vector2(3.0f, 3.0f);

            var titleCover = new Image(Core.Render.Texture.Get("gui/dialog_title_cover.png", true), new Quad(0.0f, 0.0f, 0.5f, 1.0f), 32.0f, 32.0f);

            titleCover.Anchor        = Anchor;
            titleCover.LocalPosition = new Vector2(imageBorder.LocalPosition.X - 3.0f - 27.0f, LocalPosition.Y);

            var titleCover2 = new Image(Core.Render.Texture.Get("gui/dialog_title_cover.png", true), new Quad(0.5f, 0.0f, 0.5f, 1.0f), 32.0f, 32.0f);

            titleCover2.Anchor        = Anchor;
            titleCover2.LocalPosition = new Vector2(titleCover.LocalPosition.X + titleCover.Width, titleCover.LocalPosition.Y);
            titleCover2.Width         = (LocalPosition.X + Width - 16.0f) - titleCover2.LocalPosition.X;
            titleCover2.Stretch       = true;

            Elements.Add(titleCover);
            Elements.Add(titleCover2);
            Elements.Add(imageBorder);
            Elements.Add(m_image);

            // Text
            float xPos = LocalPosition.X + LEFT_MARGIN_SIZE + 8.0f;
            float yPos = LocalPosition.Y + TOP_MARGIN_SIZE;

            m_lines = new Text[NUM_LINES];
            for (int i = 0; i < m_lines.Length; ++i)
            {
                var line = new Text(font, "", UIColours.Text, TextAlignment.Left);
                line.Anchor        = Anchor;
                line.LocalPosition = new Vector2(xPos, yPos);
                m_lines[i]         = line;
                Elements.Add(line);
                yPos += line.Height;
            }

            // Prompts
            m_continuePrompt                       = new InputPrompt(UIFonts.Smaller, "", TextAlignment.Right);
            m_continuePrompt.Anchor                = Anchor;
            m_continuePrompt.LocalPosition         = LocalPosition + new Vector2(Width, Height + 0.5f * BOTTOM_MARGIN_SIZE);
            m_continuePrompt.Key                   = Key.Return;
            m_continuePrompt.GamepadButton         = GamepadButton.A;
            m_continuePrompt.SteamControllerButton = SteamControllerButton.MenuSelect;
            m_continuePrompt.MouseButton           = MouseButton.Left;
            m_continuePrompt.OnClick              += delegate
            {
                TryContinue();
            };
            Elements.Add(m_continuePrompt);
        }