Esempio n. 1
0
 public void OnTriggerDestroyed(IDependable trigger)
 {
     if (trigger == obj)
     {
         Inspect(null);
     }
 }
Esempio n. 2
0
        int activeIndex;         //the index of the child that's "active": the entry or the clickable thingy.

        public TextEditableField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute)
        {
            this.property = property;
            this.obj      = (IDependable)obj;
            this.context  = context;
            editable      = attribute.EditAuthorized(obj);

            if (!context.compact)
            {
                activeIndex = 1;
                Label label = new Label((attribute.overrideLabel ?? UIFactory.ToReadable(property.Name)) + ": ");
                PackStart(label, false, false, 0);
            }

            if (attribute.tooltipText != "")
            {
                HasTooltip    = true;
                TooltipMarkup = attribute.tooltipText;
            }

            rightclickMenu = new Menu();
            MenuItem edit = new MenuItem("Edit");

            edit.Activated += Open;
            rightclickMenu.Append(edit);
            Reload();
        }
Esempio n. 3
0
 private void AddUnique(IDependable <T> dep)
 {
     if (!tree.Contains(dep))
     {
         tree.Add(dep);
     }
 }
Esempio n. 4
0
 public virtual void OnListenerDestroyed(IDependable listener)
 {
     if (listener == parent)
     {
         DependencyManager.Destroy(this);
     }
 }
Esempio n. 5
0
 public void OnTriggerDestroyed(IDependable trigger)
 {
     if (trigger == obj)
     {
         Destroy();
         DependencyManager.Destroy(this);
     }
 }
Esempio n. 6
0
 public void OnTriggerDestroyed(IDependable trigger)
 {
     if (trigger == battle)
     {
         Destroy();
         DependencyManager.DisconnectAll(this);
     }
 }
Esempio n. 7
0
 public void Add(IDependable <T> dep)
 {
     AddUnique(dep);
     foreach (IDependable <T> d in dep.Dependencies)
     {
         AddUnique(d);
     }
 }
Esempio n. 8
0
 public void OnTriggerDestroyed(IDependable trigger)
 {
     if (Contains(trigger))
     {
         Remove(trigger);
         DependencyManager.Flag(this);
     }
 }
 public static void Connect(IDependable trigger, IDependable listener)
 {
     if (trigger.listeners.Contains(listener))
     {
         return;
     }
     trigger.listeners.Add(listener);
     listener.triggers.Add(trigger);
 }
Esempio n. 10
0
        public static MenuItem CreateDeleteButton(IDependable obj)
        {
            MenuItem deleteButton = new MenuItem("Delete");

            deleteButton.Activated += delegate {
                DependencyManager.Destroy(obj);
                DependencyManager.TriggerAllFlags();
            };
            return(deleteButton);
        }
 public static void Flag(IDependable obj)
 {
     if (!flagged.ContainsKey(obj.order))
     {
         flagged.Add(obj.order, new List <IDependable>());
     }
     if (!flagged[obj.order].Contains(obj))
     {
         flagged[obj.order].Add(obj);
     }
 }
Esempio n. 12
0
        public void Add(IDependable <T> dep)
        {
            AddUnique(dep);  //Add A Unique Dependency

            //Add Dependencies of the parameter's dependency.

            foreach (IDependable <T> d in dep.Dependencies)
            {
                AddUnique(d);
            }
        }
 public static void DisconnectAll(IDependable obj)
 {
     foreach (IDependable listener in obj.listeners)
     {
         listener.triggers.RemoveAll((input) => input == obj);
     }
     foreach (IDependable trigger in obj.triggers)
     {
         trigger.listeners.RemoveAll((input) => input == obj);
     }
     obj.listeners.Clear();
     obj.triggers.Clear();
 }
Esempio n. 14
0
        internal void ConstructDependencies()
        {
            Dependencies = new Dictionary <string, IDependable <KraftModule> >();

            foreach (KeyValuePair <string, string> dependency in KraftModuleRootConf.Dependencies)
            {
                IDependable <KraftModule> depModule = _ModuleCollection.GetModuleAsDependable(dependency.Key);
                if (depModule == null)
                {
                    throw new Exception($"No module with a key \"{dependency.Key}\" is loaded!");
                }
                Dependencies.Add(depModule.Key, depModule);
            }
        }
Esempio n. 15
0
 private void MoveUpNode(IDependable <T> dp, bool initial)
 {
     if (!initial)
     {
         dp.Depth++;
     }
     foreach (IDependable <T> d in dp.Dependencies)
     {
         if (d.Depth <= dp.Depth)
         {
             MoveUpNode(d, initial: false);
         }
     }
 }
Esempio n. 16
0
        private void MoveUpNode(IDependable <T> dp, bool initial)
        {
            //Increase the value of the Depth
            if (!initial)
            {
                dp.Depth++;
            }

            //Once we move up the Node.  We need move up it all dependencies reciersively
            foreach (IDependable <T> d in dp.Dependencies)
            {
                if (d.Depth <= dp.Depth)
                {
                    MoveUpNode(d, initial: false);
                }
            }
        }
Esempio n. 17
0
 public void OpenDialog(object widget, EventArgs args)
 {
     TextEditingDialog dialog = new TextEditingDialog(
         "Edit " + UIFactory.ToReadable(property.Name),
         (Window)Toplevel,
         () => (string)property.GetValue(obj),
         delegate(string input) {
         try {                                                      // Muahahahaha I'm evil
             property.SetValue(obj, input);
         } catch (Exception e) {
             e = e.InnerException;
             return(false);
         }
         IDependable dependable = obj as IDependable;
         if (dependable != null)
         {
             DependencyManager.Flag(obj);
             DependencyManager.TriggerAllFlags();
         }
         return(true);
     }
         );
 }
        public static void Destroy(IDependable obj)
        {
            if (obj.destroyed)
            {
                return;
            }

            obj.destroyed = true;

            IDependable[] triggers = obj.triggers.ToArray();
            foreach (IDependable trigger in triggers)
            {
                trigger.OnListenerDestroyed(obj);
            }

            IDependable[] listeners = obj.listeners.ToArray();
            foreach (IDependable listener in listeners)
            {
                listener.OnTriggerDestroyed(obj);
            }

            DisconnectAll(obj);
        }
Esempio n. 19
0
        public static Dependency createDependency(
            IDependable master,
            IDependable dependent,
            Relations.Relation relation,
            DependencyTypeEnum dependencyType
            )
        {
            Dependency d = new Dependency();

            d.master         = master;
            d.dependent      = dependent;
            d.relation       = relation;
            d.dependencyType = dependencyType;

            // тут надо проверить, что эти объекты и правда соответствуют этому relation
            string val1 = master.entityType.ToLower();
            string val2 = dependent.entityType.ToLower();

            string val3 = relation.A.targetClassName.ToLower();
            string val4 = relation.B.targetClassName.ToLower();

            bool fit_1 = (val1 == val3) && (val2 == val4);
            bool fit_2 = (val1 == val4) && (val2 == val3);
            bool fit   = fit_1 || fit_2;

            if (fit)
            {
                items.Add(d);
                return(d);
            }
            else
            {
                fn.dp("ERROR creation dependency: objects don't fit relation");
                return(null);
            }
        }
Esempio n. 20
0
        public DialogTextEditableField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(false, 2)
        {
            this.property = property;
            this.obj      = (IDependable)obj;
            this.context  = context;
            editable      = attribute.EditAuthorized(obj);
            // Create the label
            if (!context.compact)
            {
                Label label = new Label(attribute.overrideLabel ?? UIFactory.ToReadable(property.Name) + ": ");
                label.SetAlignment(0, 1);
                if (attribute.tooltipText != null)
                {
                    label.HasTooltip    = true;
                    label.TooltipMarkup = attribute.tooltipText;
                }
                PackStart(label, false, false, 0);
            }
            // Create the text body
            Label val = new Label((string)property.GetValue(obj));

            if (val.Text == "")
            {
                val.Text = "-";
            }
            val.SetAlignment(0, 0);
            if (!context.compact)
            {
                val.LineWrap = true;
                val.Justify  = Justification.Fill;
                val.SetSizeRequest(0, -1);
                val.SizeAllocated += (o, a) => val.SetSizeRequest(a.Allocation.Width, -1);
                val.LineWrapMode   = Pango.WrapMode.WordChar;
            }
            //Create the "clickable" functionality
            ClickableEventBox eventBox = new ClickableEventBox();

            eventBox.DoubleClicked += OpenDialog;
            eventBox.RightClicked  += delegate {
                rightclickMenu.Popup();
                rightclickMenu.ShowAll();
            };

            if (context.compact)
            {
                Gtk.Alignment alignment = UIFactory.Align(val, 0, 0, 1, 1);
                alignment.BorderWidth = 5;
                if (editable)
                {
                    eventBox.Add(alignment);
                    PackStart(eventBox);
                }
                else
                {
                    PackStart(alignment);
                }
            }
            else
            {
                Gtk.Alignment alignment = new Gtk.Alignment(0, 0, 1, 1);
                if (editable)
                {
                    eventBox.Add(val);
                    alignment.Add(eventBox);
                }
                else
                {
                    alignment.Add(val);
                }
                alignment.LeftPadding = 10;
                PackStart(alignment, true, true, 0);
            }

            rightclickMenu = new Menu();
            MenuItem edit = new MenuItem("Edit");

            edit.Activated += OpenDialog;
            rightclickMenu.Append(edit);
        }
Esempio n. 21
0
 public void OnListenerDestroyed(IDependable listener)
 {
 }
Esempio n. 22
0
        public RatingsListField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(0, 0, 1, 1)
        {
            RatingsProfile profile = ((Func <Context, RatingsProfile>)property.GetValue(obj))(context);

            float[,] values = profile.values;
            int[,] o_vals   = profile.o_vals;

            Gtk.Alignment alignment = new Gtk.Alignment(0, 0, 1, 0);

            if (context.vertical && !context.compact)
            {
                Frame frame = new Frame(UIFactory.ToReadable(property.Name));
                VBox  box   = new VBox(false, 4)
                {
                    BorderWidth = 5
                };
                frame.Add(box);
                alignment.Add(frame);

                for (int i = 1; i <= 8; i++)
                {
                    if (o_vals[0, i] != Ratings.O_NULL)
                    {
                        Label ratingLabel = new Label(Ratings.PrintSingle(i, values[0, i]));
                        ratingLabel.SetAlignment(0, 0);
                        box.PackStart(ratingLabel);
                    }
                }

                for (int k = 1; k <= 3; k++)
                {
                    if (o_vals[k, 0] != Ratings.O_NULL)
                    {
                        Label wrapperLabel = new Label(Ratings.PrintSingle(k + 8, values[k, 0]));
                        wrapperLabel.SetAlignment(0, 0);

                        VBox ratingBox = new VBox(false, 5)
                        {
                            BorderWidth = 5
                        };
                        Frame ratingFrame = new Frame {
                            LabelWidget = wrapperLabel, Child = ratingBox
                        };

                        for (int i = 1; i <= 8; i++)
                        {
                            if (o_vals[k, i] != Ratings.O_NULL)
                            {
                                Label ratingLabel = new Label(Ratings.PrintSingle(i, values[k, i]));
                                ratingLabel.SetAlignment(0, 0);
                                ratingBox.PackStart(ratingLabel, false, false, 0);
                            }
                        }

                        box.PackStart(ratingFrame);
                    }
                }
            }
            else
            {
                Box box;
                if (context.compact)
                {
                    box = new VBox(false, 0)
                    {
                        BorderWidth = 5
                    };
                }
                else
                {
                    box = new HBox(false, 0)
                    {
                        BorderWidth = 5
                    };
                }
                alignment.Add(box);
                for (int i = 1; i <= 8; i++)
                {
                    if (o_vals[0, i] != Ratings.O_NULL)
                    {
                        bool  comma       = !context.compact && box.Children.Length > 0;
                        Label ratingLabel = new Label((comma ? ", " : "")                         //Commas to delimit ratings
                                                      + Ratings.PrintSingle(i, values[0, i]));
                        ratingLabel.SetAlignment(0, 0);
                        box.PackStart(ratingLabel, false, false, 0);
                    }
                }
                for (int k = 1; k <= 3; k++)
                {
                    if (o_vals[k, 0] != Ratings.O_NULL)
                    {
                        bool  comma       = !context.compact && box.Children.Length > 0;
                        Label ratingLabel = new Label((comma ? ", " : "")                         //Commas to delimit ratings
                                                      + Ratings.PrintSingle(k + 8, values[k, 0], true));
                        ratingLabel.SetAlignment(0, 0);
                        List <String> subratings = new List <String>();
                        for (int i = 1; i <= 8; i++)
                        {
                            if (o_vals[k, i] != Ratings.O_NULL)
                            {
                                subratings.Add(Ratings.PrintSingle(i, values[k, i]));
                            }
                        }
                        ratingLabel.TooltipText = String.Join("\n", subratings);
                        box.PackStart(ratingLabel, false, false, 0);
                    }
                }
            }
            if (attribute.EditAuthorized(obj))
            {
                ClickableEventBox clickableEventBox = new ClickableEventBox {
                    Child = alignment
                };
                clickableEventBox.DoubleClicked += delegate {
                    // The property this is attached to gets the *current ratings*, not the *base ratings*, which are
                    // what we logically want to let the user manipulate. Hence, the optional arg supplied is the name
                    // of the base profile.
                    PropertyInfo      baseProfileProperty = obj.GetType().GetProperty((string)attribute.arg);
                    TextEditingDialog dialog = new TextEditingDialog(
                        "Edit ratings",
                        (Window)Toplevel,
                        delegate {
                        RatingsProfile baseProfile = (RatingsProfile)baseProfileProperty.GetValue(obj);
                        return(Ratings.Print(baseProfile.values, baseProfile.o_vals));
                    },
                        delegate(string input) {
                        if (Ratings.TryParse(input, out RatingsProfile? newRatings))
                        {
                            baseProfileProperty.SetValue(obj, (RatingsProfile)newRatings);
                            IDependable dependable = obj as IDependable;
                            if (dependable != null)
                            {
                                DependencyManager.Flag(dependable);
                                DependencyManager.TriggerAllFlags();
                            }
                            return(true);
                        }
                        return(false);
                    }
                        );
                };
                Add(clickableEventBox);
            }
            else
            {
                Add(alignment);
            }
        }
Esempio n. 23
0
 public static List <Dependency> getMyActualMasters(IDependable me)
 {
     return(items.Where(f => (f.dependent == me && f.dependencyType == DependencyTypeEnum.setFilter)).ToList());
 }
Esempio n. 24
0
 public static List <Dependency> getMyDependecies(IDependable master)
 {
     return(items.Where(f => f.master == master).ToList());
 }
Esempio n. 25
0
 public void OnTriggerDestroyed(IDependable trigger)
 {
 }
Esempio n. 26
0
 public abstract void OnTriggerDestroyed(IDependable trigger);
 public static void Disconnect(IDependable trigger, IDependable listener)            //Unnecessary unless Gtk decides to throw warnings
 {
     trigger.listeners.RemoveAll((input) => input == listener);
     listener.triggers.RemoveAll((input) => input == trigger);
 }
Esempio n. 28
0
 public DependencyManagerClient(IDependable _parent)
 {
     parent = _parent;
 }
Esempio n. 29
0
 public abstract void OnListenerDestroyed(IDependable listener);