Exemplo n.º 1
0
        /// <summary>
        /// Creates a dialogue box.
        /// </summary>
        /// <param name="position">Bounds of the created dialogue box.</param>
        /// <param name="text">The key of the dialogue widget. see Content/strings/dialogue.txt for a list of keys.</param>
        /// <param name="color">the color of the text.</param>
        /// <param name="font">The font to use</param>
        /// <param name="textSpeed"></param>
        /// <param name="colors"></param>
        /// <returns></returns>
        public GuiWidgetDialogue createDialogue(Rectangle position, Tuple <WidgetType, int> id, Color color, SpriteFont font, Color[] colors, string text = "<default>")
        {
            GuiWidgetDialogue widget;

            widget = new GuiWidgetDialogue(position, id, text, color, font, colors);

            widgets.Add(widget);
            return(widget);
        }
Exemplo n.º 2
0
        public override void Update()
        {
            if (active)
            {
                if (firstOpen)
                {   //Create widgets and such
                    CreateWidgets();
                    firstOpen = false;
                }

                if (Game1.priorityGui == this)
                {
                    GuiWidgetDialogue widgetDialogue = null;
                    GuiWidgetButton   widgetButton   = null;

                    for (int i = widgets.Count - 1; i >= 0; i--)
                    {
                        if (widgets[i].id.Item1 == WidgetType.Dialogue)
                        {
                            widgetDialogue = (GuiWidgetDialogue)widgets[i];
                            widgetDialogue.Update();

                            //Can only be 1 dialogue widget, always index of 0
                            if (widgets[i].id.Item2 == 0)
                            {
                                if (widgets[i].currentState == GuiWidget.State.Done)
                                {
                                    if (widgetDialogue.ChangeText(-1))
                                    {
                                        dialogueOpen          = false;
                                        widgetDialogue.active = false;
                                    }
                                }
                            }
                        }

                        if (widgets[i].id.Item1 == WidgetType.Button)
                        {
                            widgetButton = (GuiWidgetButton)widgets[i];
                            widgetButton.Update();
                        }

                        if (!widgets[i].active)
                        {
                            widgets.RemoveAt(i--);
                        }
                    }
                }
            }
        }