コード例 #1
0
        public void Update(Gui.Root Gui)
        {
            if (!TutorialHidden && TutorialEnabled && !String.IsNullOrEmpty(PendingTutorial) && Gui != null && !Entries[PendingTutorial].Shown)
            {
                if (TutorialVisible && ExistingTutorial != null)
                {
                    ExistingTutorial.Close();
                    ExistingTutorial = null;
                }

                var entry = Entries[PendingTutorial];
                entry.Shown     = true;
                entry.Name      = PendingTutorial;
                TutorialVisible = true;

                var popup = Gui.ConstructWidget(new Gui.Widgets.TutorialPopup
                {
                    Message = entry,
                    OnClose = (sender) =>
                    {
                        TutorialEnabled = !(sender as Gui.Widgets.TutorialPopup).DisableChecked;
                        TutorialVisible = false;
                        Gui.ClearSpecials();
                        if (!String.IsNullOrEmpty(entry.NextTutorial))
                        {
                            ShowTutorial(entry.NextTutorial);
                        }
                    },
                    OnLayout = (sender) =>
                    {
                        sender.Rect.X = Gui.RenderData.VirtualScreen.Width - sender.Rect.Width;
                        sender.Rect.Y = 64;
                    }
                });

                if (entry.Popup)
                {
                    Gui.ShowMinorPopup(popup);
                    popup.PopupDestructionType = PopupDestructionType.Keep;
                }
                else
                {
                    Gui.RootItem.AddChild(popup);
                }
                ExistingTutorial = popup;
                PendingTutorial  = null;

                Gui.SpecialHiliteWidgetName = entry.GuiHilite;
            }

            if ((HighlightWidget != null) && HighlightWidget.IsAnyParentHidden() && TutorialVisible && (ExistingTutorial != null))
            {
                Gui.ClearSpecials();
                ExistingTutorial.Close();
            }
        }
コード例 #2
0
        public void Update(Gui.Root Gui)
        {
            if (TutorialEnabled && !String.IsNullOrEmpty(PendingTutorial) && Gui != null && !Entries[PendingTutorial].Shown)
            {
                if (TutorialVisible && ExistingTutorial != null)
                {
                    ExistingTutorial.Close();
                    ExistingTutorial = null;
                }

                var entry = Entries[PendingTutorial];
                entry.Shown     = true;
                TutorialVisible = true;

                var popup = Gui.ConstructWidget(new Gui.Widgets.TutorialPopup
                {
                    Message = entry,
                    OnClose = (sender) =>
                    {
                        TutorialEnabled = !(sender as Gui.Widgets.TutorialPopup).DisableChecked;
                        TutorialVisible = false;
                        Gui.ClearSpecials();
                    },
                    OnLayout = (sender) =>
                    {
                        sender.Rect.X = Gui.RenderData.VirtualScreen.Width - sender.Rect.Width;
                        sender.Rect.Y = 64;
                    }
                });

                if (entry.Popup)
                {
                    Gui.ShowMinorPopup(popup);
                    popup.PopupDestructionType = PopupDestructionType.Keep;
                }
                else
                {
                    Gui.RootItem.AddChild(popup);
                }
                ExistingTutorial = popup;
                PendingTutorial  = null;

                if (!String.IsNullOrEmpty(entry.GuiHilite))
                {
                    var widget = Gui.RootItem.EnumerateTree().FirstOrDefault(w =>
                                                                             w.Tag is String && (w.Tag as String) == entry.GuiHilite);
                    HighlightWidget = widget;
                    if (widget != null)
                    {
                        Gui.SpecialHiliteRegion     = widget.Rect;
                        Gui.SpecialHighligtedWidget = widget;
                        Gui.SpecialHiliteSheet      = "border-hilite";

                        if (widget.Rect.Right < Gui.RenderData.VirtualScreen.Width / 2 ||
                            widget.Rect.Left < 64)
                        {
                            Gui.SpecialIndicatorPosition = new Microsoft.Xna.Framework.Point(
                                widget.Rect.Right, widget.Rect.Center.Y - 16);
                            Gui.SpecialIndicator = new Gui.MousePointer("hand", 1, 10);
                        }
                        else
                        {
                            Gui.SpecialIndicatorPosition = new Microsoft.Xna.Framework.Point(
                                widget.Rect.Left - 32, widget.Rect.Center.Y - 16);
                            Gui.SpecialIndicator = new Gui.MousePointer("hand", 4, 14);
                        }
                        widget.OnClick += (sender, args) =>
                        {
                            popup.Close();
                        };
                    }
                    else
                    {
                        Console.Error.WriteLine("GUI highlight {0} does not exist.", entry.GuiHilite);
                    }
                }
            }

            if (HighlightWidget != null && HighlightWidget.IsAnyParentHidden() && TutorialVisible && ExistingTutorial != null)
            {
                Gui.SpecialHiliteRegion = null;
                ExistingTutorial.Close();
            }
        }