示例#1
0
        public static MenuItem CreateInspectInNewWindowButton(IGUIComplete obj)
        {
            MenuItem inspectInWindowButton = new MenuItem("Inspect in New Window");

            inspectInWindowButton.Activated += (o, a) => Inspector.InspectInNewWindow(obj);
            return(inspectInWindowButton);
        }
示例#2
0
 public Context(IGUIComplete UIContext, IAgent requester = null, bool vertical = true, bool compact = false)
 {
     this.UIContext = UIContext;
     this.requester = requester ?? Game.player;
     this.vertical  = vertical;
     this.compact   = compact;
 }
示例#3
0
        public static MenuItem CreateInspectButton(IGUIComplete obj, Widget referenceWidget)
        {
            MenuItem inspectButton = new MenuItem("Inspect");

            inspectButton.Activated += (o, a) => Inspector.InspectInNearestInspector(obj, referenceWidget);
            return(inspectButton);
        }
示例#4
0
        public static Window InspectInNewWindow(IGUIComplete newObj)
        {
            DefocusableWindow win = new DefocusableWindow();

            win.SetPosition(WindowPosition.Center);
            win.Title        = "Inspector";
            win.TransientFor = MainWindow.main;
            win.TypeHint     = Gdk.WindowTypeHint.Utility;
            Inspector inspector = new Inspector(newObj)
            {
                BorderWidth = 2
            };

            inspector.Hidden += delegate { if (inspector.obj == null)
                                           {
                                               win.Destroy();
                                           }
            };
            win.Add(inspector);
            win.DeleteEvent += (o, a) => DependencyManager.DisconnectAll(inspector);
            //Gtk complains if GC hasn't gotten around to us, and obj tries to reload this.
            win.FocusInEvent += (o, a) => win.TransientFor = MainWindow.main;
            win.DefaultHeight = inspector.Child.SizeRequest().Height + 10;
            win.ShowAll();
            return(win);
        }
示例#5
0
 public InspectableMapMarker(IGUIComplete obj, Map map, bool draggable = true) : base(obj, new Context(obj), draggable)
 {
     VisibleWindow     = false;
     this.map          = map;
     node              = Graphics.GetIcon(Threat.C, new Gdk.Color(255, 255, 255), 8);
     EnterNotifyEvent += MouseEnter;
     LeaveNotifyEvent += MouseLeave;
 }
示例#6
0
 public Listing(IGUIComplete obj, bool lazy)
 {
     this.obj  = obj;
     this.lazy = lazy;
     DependencyManager.Connect(obj, this);
     DependencyManager.Connect(Game.UIKey, this);
     Destroyed += (o, a) => DependencyManager.DisconnectAll(this);
     SetSizeRequest(1, 300);
     LabelXalign = 1;
     Reload();
 }
示例#7
0
 public Inspector(IGUIComplete obj)
 {
     HscrollbarPolicy = PolicyType.Never;
     Unhidden         = delegate { };
     Inspect(obj);
     Shown += delegate {
         if (this.obj == null)
         {
             Hide();
         }
     };
 }
示例#8
0
        public static MenuItem CreateMoveButton(IGUIComplete child)
        {
            MenuItem moveButton = new MenuItem("Move");

            moveButton.Activated += (o, a)
                                    => new SelectorDialog("Select new parent for " + child.name,
                                                          (tested) => tested.Accepts(child),
                                                          delegate(GameObject returned) {
                returned.Add(child);
                DependencyManager.TriggerAllFlags();
            });
            return(moveButton);
        }
示例#9
0
        public static void InspectInNearestInspector(IGUIComplete obj, Widget referenceWidget)
        {
            Inspector nearestInspector = FindNearestInspector(referenceWidget);

            if (nearestInspector == null)
            {
                InspectInNewWindow(obj);
            }
            else
            {
                nearestInspector.Inspect(obj);
            }
        }
示例#10
0
 public SmartCell(Context context, IGUIComplete obj, bool lazy) : base(obj, context)
 {
     //Basic setup
     this.obj  = obj;
     this.lazy = lazy;
     frame     = new Frame();
     Child     = frame;
     prelight  = false;
     MyDragDrop.SourceSet(this, obj);
     // "Removing by dragging away to nothing" functionality should be... [see Cell comment]
     DependencyManager.Connect(obj, this);
     DependencyManager.Connect(Game.UIKey, this);
     Destroyed += (o, a) => DependencyManager.DisconnectAll(this);
     Reload();
 }
示例#11
0
        public static Widget GetSmartHeader(Context context, IGUIComplete obj)
        {
            DependableShell shell = new DependableShell(obj.order + 1);

            shell.ReloadEvent += delegate {
                if (shell.Child != null)
                {
                    shell.Child.Destroy();
                }
                shell.Add(obj.GetHeader(context));
                shell.ShowAll();
            };
            shell.Reload();
            DependencyManager.Connect(obj, shell);
            return(shell);
        }
示例#12
0
        public ObjectField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(0, 0, 1, 1)
        {
            this.property = property;
            this.obj      = (IGUIComplete)property.GetValue(obj);
            this.context  = context;

            title = attribute.overrideLabel ?? UIFactory.ToReadable(property.Name);

            if (this.obj != null)
            {
                DependencyManager.Connect(this.obj, this);
                Destroyed += (o, a) => DependencyManager.DisconnectAll(this);
                Reload();
            }
            else
            {
                Label label = new Label(title + ": None");
                label.SetAlignment(0, 0);
                Add(label);
            }
        }
示例#13
0
        public Cell(Context context, IGUIComplete obj) : base(obj, context)
        {
            //Basic setup
            this.obj = obj;
            frame    = new Frame();
            Child    = frame;
            prelight = false;
            MyDragDrop.SourceSet(this, obj);
            // "Removing by dragging away to nothing" functionality should be implemented manually when the Cell is created.
            // It should be implemented via MyDragDrop.SourceSetFailAction
            // The object should generally be removed from the parent list ONLY in this case.
            // Rationale for removing only if drag had no target:
            // - If cellObject is dragged from an aggregative list to another aggregative list,
            //   the Add() function on the second automatically removes it from the first, so calling Remove() is unnecessary.
            // - If cellObject is dragged from an associative list to an aggregative list or vice versa,
            //   We reasonably assume that user doesn't want it removed from the first list since the concept of "moving" doesn't apply in this context.
            // - Only if the user has dragged cellObject from any list to *nothing* can it be assumed that they need it manually removed by us.
            frame.Add(obj.GetCellContents(this.context));
            frame.LabelWidget = obj.GetHeader(this.context);
            InspectableBox inspectableBox = frame.LabelWidget as InspectableBox;

            ShowAll();
        }
示例#14
0
        public void Inspect(IGUIComplete obj)
        {
            // Clean up prior attachments
            if (Child != null)
            {
                Child.Destroy();
            }
            DependencyManager.DisconnectAll(this);
            ShowAll();

            // Handle inspection request
            this.obj = obj;
            if (obj == null)
            {
                Hide();
            }
            else
            {
                DependencyManager.Connect(obj, this);
                DependencyManager.Connect(Game.UIKey, this);
                if (Child != null)
                {
                    Child.Destroy();
                }
                VBox mainbox = new VBox(false, 0);
                mainbox.PackStart(obj.GetHeader(new Context(obj)), false, false, 10);
                mainbox.PackStart(new HSeparator(), false, false, 0);
                mainbox.PackStart(UIFactory.GenerateVertical(obj), true, true, 5);
                AddWithViewport(mainbox);
                if (!Visible)
                {
                    Unhidden.Invoke(this, new EventArgs());
                }
                ShowAll();
            }
        }
示例#15
0
 public static VBox GenerateHorizontal(IGUIComplete obj)
 => GenerateHorizontal(new Context(obj, Game.player, false, false), obj);
示例#16
0
 public static VBox GenerateVertical(IGUIComplete obj)
 => GenerateVertical(new Context(obj, Game.player, true, false), obj);
示例#17
0
        public Context context;         // So derived classes can use the more convenient "context" variable name

        public InspectableBox(Widget child, IGUIComplete inspected, Context context, bool draggable = true) : this(inspected, context, draggable)
            => Child = child;
示例#18
0
 public Context butInUIContext(IGUIComplete newUIContext) => new Context(newUIContext, requester, vertical, compact);