Inheritance: MonoBehaviour
Exemple #1
0
        private object GetValueFromControl(VisualItem aVisualItem)
        {
            object result = null;

            switch (aVisualItem.Item.type)
            {
            case "text":
                result = aVisualItem.controlsGroup.control.Text;
                break;

            case "number":
                double value;
                if (double.TryParse(aVisualItem.controlsGroup.control.Text, out value))
                {
                    result = value;
                }
                break;

            case "integral":
                int val;
                if (int.TryParse(aVisualItem.controlsGroup.control.Text, out val))
                {
                    result = val;
                }
                break;
            }
            return(result);
        }
Exemple #2
0
        void c_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox   comboBox = sender as ComboBox;
            VisualItem item     = GetItemFromControl(comboBox);

            SetValue(item, comboBox.SelectedItem);
        }
        /// <summary>
        /// apply the text entered from the keyboard onto the visual item located by
        /// the canvas cursor. Handle error where the canvas cursor item is not input
        /// capable.
        /// </summary>
        /// <param name="Cursor"></param>
        /// <param name="Text"></param>
        /// <param name="Reuse"></param>
        /// <returns></returns>
        public Tuple <VisualItem, string> PutKeyboardText(
            CanvasPositionCursor Cursor, string Text, bool Reuse = true)
        {
            string     errmsg     = null;
            VisualItem visualItem = null;

            if (Cursor.IsInputItem( ) == true)
            {
                visualItem = Cursor.PutKeyboardText(Text);

                // send the keyboard input to the master thread. That thread applies input
                // and WTD commands to the master screenContent block.
                if (this.MasterThread != null)
                {
                    var kbInput = new KeyboardInputMessage()
                    {
                        RowCol = Cursor.RowCol as ZeroRowCol,
                        Text   = Text
                    };
                    this.MasterThread.PostInputMessage(kbInput);
                }
            }
            else
            {
                errmsg = "not entry field";
            }

            return(new Tuple <VisualItem, string>(visualItem, errmsg));
        }
Exemple #4
0
        void MenuSettings_TextChanged(object sender, EventArgs e)
        {
            TextBox    textbox = sender as TextBox;
            VisualItem item    = GetItemFromControl(textbox);

            SetValue(item, textbox.Text, ItemChangedMode.OnTheFly);
        }
Exemple #5
0
        private void AddControlRecursivly(VisualItem aRoot)
        {
            VisualItem visualItem = aRoot;
            ItemTree   item       = aRoot.Item;

            if (!visualItem.IsFiltered)
            {
                return;
            }
            Control control = fParams.container;
            Type    type;

            if (fStringToType.TryGetValue(item.type, out type))
            {
                AddControl(aRoot, type);
            }

            //Add children
            if (visualItem.subitems != null)
            {
                foreach (VisualItem subItem in visualItem.subitems)
                {
                    AddControlRecursivly(subItem);
                }
            }
        }
Exemple #6
0
 private void CreateVisualItemTree()
 {
     fRootVisualItem            = new VisualItem();
     fRootVisualItem.IsFiltered = true;
     fRootVisualItem.Item       = fParams.dataProvider.RootTemplate;
     CreateVisualItemTree(fRootVisualItem);
 }
        protected override void OnItemSelect(ListItem item)
        {
            base.OnItemSelect(item);
            VisualItem data = (VisualItem)item.Data;

            base.listTitle.text = data.Name;
        }
Exemple #8
0
        private bool ApplyFilterRecursively(VisualItem root)
        {
            VisualItem visualItem = root;
            ItemTree   item       = root.Item;

            if (fParams.filter == null || String.IsNullOrEmpty(fParams.filter.IncludeName) || String.IsNullOrWhiteSpace(fParams.filter.IncludeName))
            {
                visualItem.IsFiltered = true;
            }
            else
            {
                if (item.type == "menu" || item.type == "root")
                {
                    visualItem.IsFiltered = true;
                }
                else
                if (item.displayname != null)
                {
                    visualItem.IsFiltered = item.displayname.ToLower().Contains(fParams.filter.IncludeName.ToLower());
                }
            }

            if (item.subitems != null)
            {
                bool isFiltered = false;
                foreach (VisualItem subItem in visualItem.subitems)
                {
                    isFiltered |= ApplyFilterRecursively(subItem);
                }

                //if at least one of the childs is visible then the parent is visible as well.
                visualItem.IsFiltered = isFiltered;
            }
            return(visualItem.IsFiltered);
        }
Exemple #9
0
        private void Combo_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ComboBox   comboBox = sender as ComboBox;
            VisualItem item     = GetItemFromControl(comboBox);

            SetValue(item, comboBox.SelectedItem);
        }
Exemple #10
0
        private void ProcessEvents(VisualItem aVisualItem)
        {
            Control  t     = aVisualItem.controlsGroup.control;
            Control  p     = aVisualItem.controlsGroup.parentContainer;
            Control  l     = aVisualItem.controlsGroup.label;
            ItemTree aItem = aVisualItem.Item;

            switch (aItem.type)
            {
            case "menu":
                (l as Control).DoubleClick += Menu_DoubleClick;
                break;

            case "bool":
                (t as CheckBox).MouseClick += CheckBox_MouseClick;
                (p as Control).MouseClick  += CheckBox_MouseClick;
                (l as Control).MouseClick  += CheckBox_MouseClick;
                break;

            case "text":
                (t as TextBox).TextChanged += MenuSettings_TextChanged;
                (t as TextBox).Leave       += TextBox_Leave;
                (t as TextBox).Enter       += TextBox_Enter;
                break;

            case "number":
                (t as TextBox).TextChanged += MenuSettings_NumberChanged;
                (t as TextBox).Leave       += TextBox_Leave;
                (t as TextBox).Enter       += TextBox_Enter;
                break;

            case "integral":
                (t as TextBox).TextChanged += MenuSettings_IntegralChanged;
                (t as TextBox).Leave       += TextBox_Leave;
                (t as TextBox).Enter       += TextBox_Enter;
                break;

            case "combo":
                (t as ComboBox).SelectedIndexChanged += c_SelectedIndexChanged;
                (t as ComboBox).MouseDoubleClick     += Combo_MouseDoubleClick;

                break;

            case "image":
                (t as TextBox).TextChanged      += MenuSettings_TextChanged;
                (t as TextBox).MouseDoubleClick += MenuSettings_MouseDoubleClick;
                (t as TextBox).MouseLeave       += MenuSettings_MouseLeave;
                (t as TextBox).MouseHover       += MenuSettings_MouseHover;
                break;

            case "color":
                (t as ColorControl).KeyDown     += ColorControl_KeyDown;
                (t as ColorControl).TextChanged += ColorControl_TextChanged;
                (t as Control).DoubleClick      += MenuSettings_Click;
                (p as Control).Click            += MenuSettings_Click;
                (l as Control).Click            += MenuSettings_Click;
                break;
            }
        }
Exemple #11
0
        private static void AssertItemOutlineColor(VisualItem item, Color color)
        {
            var visual  = (DrawingVisual)item;
            var drawing = (GeometryDrawing)visual.Drawing.Children[0];
            var outline = (SolidColorBrush)drawing.Pen.Brush;

            Assert.That(outline.Color, Is.EqualTo(color));
        }
 /// <summary>
 /// Copies values from VisualItem to Item, excluding the link
 /// </summary>
 /// <param name="vitem">VisualItem to copy values from</param>
 /// <param name="item">Item to copy values to</param>
 public void CopyValues(VisualItem vitem, Item item)
 {
     item.Name = vitem.niceName;
     item.Description = vitem.description;
     item.Worth = vitem.worth;
     item.Amount = vitem.amount;
     //item.Link = GameObject.Instantiate<VisualItem>(vitem);
 }
Exemple #13
0
        void button_Click(object sender, EventArgs e)
        {
            Control    c    = sender as Control;
            VisualItem item = GetItemFromControl(c);

            if (item != null)
            {
                SetValue(item, item.Item.defaultvalue);
            }
        }
Exemple #14
0
 public void Clear()
 {
     this.target     = null;
     this.skins      = null;
     this.paints     = null;
     this.graffities = null;
     this.ammo       = null;
     this.nextList   = null;
     this.selected   = null;
 }
Exemple #15
0
        void MenuSettings_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string imageName = ChooseFile(true, "", "");

            if (imageName != null)
            {
                TextBox    t    = sender as TextBox;
                VisualItem item = GetItemFromControl(t);
                SetValue(item, t.Text = imageName);
            }
        }
Exemple #16
0
        private void Menu_DoubleClick(object sender, EventArgs e)
        {
            VisualItem item = GetItemFromControl(sender as Control);

            if (item != null)
            {
                item.Expanded = !item.Expanded;
            }

            ReArrange();
        }
Exemple #17
0
 private void RefreshControlValueRecursivly(VisualItem aRoot)
 {
     RefreshControlValue(aRoot);
     if (aRoot.subitems != null)
     {
         foreach (VisualItem subItem in aRoot.subitems)
         {
             RefreshControlValueRecursivly(subItem);
         }
     }
 }
        private void SetNameTo(TextMeshProUGUI tmpName, VisualItem newItem)
        {
            tmpName.text  = newItem.Name;
            tmpName.color = newItem.Rarity.GetRarityColor();
            TooltipShowBehaviour componentInParent = base.GetComponentInParent <TooltipShowBehaviour>();

            if (componentInParent != null)
            {
                componentInParent.TipText = MarketItemNameLocalization.GetFullItemDescription(newItem, false, (string)this._commonString, (string)this._rareString, (string)this._epicString, (string)this._legendaryString);
            }
        }
Exemple #19
0
        private void MenuSettings_IntegralChanged(object sender, EventArgs e)
        {
            TextBox    textbox = sender as TextBox;
            VisualItem item    = GetItemFromControl(textbox);
            int        num;

            if (int.TryParse(textbox.Text, out num))
            {
                SetValue(item, num, ItemChangedMode.OnTheFly);
            }
        }
Exemple #20
0
        private void ReArrange(VisualItem aVisualItem)
        {
            if (!aVisualItem.IsFiltered || aVisualItem.Item.type == "root")
            {
                if (aVisualItem.controlsGroup != null)
                {
                    aVisualItem.controlsGroup.Visible = false;
                }
                return;
            }


            aVisualItem.controlsGroup.Visible = true;

            ItemTree          aItem = aVisualItem.Item;
            DataViewPlacement p     = fParams.placement;
            bool isMenu             = aItem.type == "menu";
            //Create parent container
            ItemControlsGroup group  = aVisualItem.controlsGroup;
            Control           parent = aVisualItem.controlsGroup.parentContainer;

            parent.Width  = p.TitleMaxWidth + p.TitleSpacing + p.ControlMaxWidth + p.ControlSpacing + p.DefaultButtonWidth;
            parent.Height = p.LineSpacing;
            aVisualItem.PanelBackgroundColor = isMenu ? Color.DarkBlue : fCurrentRow % 2 == 0 ? Color.White : Color.LightGray;
            parent.BackColor = aVisualItem.PanelBackgroundColor;

            fCurrentPanelPosition.X  = p.HorizontalMArgin * fNesting;
            parent.Location          = fCurrentPanelPosition;
            fCurrentPanelPosition.Y += p.LineSpacing;
            Point            controlPosition = new Point(0, (p.LineSpacing - p.LineHeight) / 2);
            LabelSingleClick label           = group.label;

            label.Width       = p.TitleMaxWidth;
            label.Height      = p.LineHeight;
            label.Location    = controlPosition;
            controlPosition.X = p.TitleMaxWidth + p.TitleSpacing;
            Control control = group.control;

            control.Location   = controlPosition;
            control.Height     = p.LineHeight;
            control.Width      = p.ControlMaxWidth;
            controlPosition.X += p.ControlMaxWidth + p.ControlSpacing;

            //Add a default button
            if (!isMenu)
            {
                Button button = group.defaultButton;
                button.Width    = p.DefaultButtonWidth;
                button.Height   = p.LineHeight;
                button.Location = controlPosition;
                fCurrentRow++;
            }
        }
Exemple #21
0
 public VisualItem(VisualItem item)
 {
     CaptionId         = item.CaptionId;
     IconId            = item.IconId;
     TooltipId         = item.TooltipId;
     CaptionIdReadOnly = item.CaptionIdReadOnly;
     IconIdReadOnly    = item.IconIdReadOnly;
     TooltipIdReadOnly = item.TooltipIdReadOnly;
     Alignment         = item.Alignment;
     PanelType         = item.PanelType;
     AppType           = item.AppType;
 }
Exemple #22
0
        private Font GetLabelFont(VisualItem aVisualItem)
        {
            if (aVisualItem.Item.type == "menu")
            {
                return(fMenuLabel);
            }

            ItemTree item = aVisualItem.Item;
            object   val  = GetValue(aVisualItem.Item);

            return(item.defaultvalue != null && val != null && !item.defaultvalue.Equals(val)
                ? fLabelBold : fLabelNormal);
        }
Exemple #23
0
        void panel_MouseLeave(object sender, EventArgs e)
        {
            VisualItem item = (sender as Control).Tag as VisualItem;

            if (item != null)
            {
                if (item.Item.type != "menu")
                {
                    Control container = item.controlsGroup.parentContainer;
                    container.BackColor = item.PanelBackgroundColor;
                }
            }
        }
Exemple #24
0
        private void TextBox_Leave(object sender, EventArgs e)
        {
            TextBox    textBox    = sender as TextBox;
            VisualItem visualItem = GetItemFromControl(textBox);
            object     value      = GetValueFromControl(visualItem);

            if (value != null && value.Equals(fValueAtEnter) == false)
            {
                SetValue(visualItem, value, ItemChangedMode.UserConfirmed, true);
            }

            fValueAtEnter = null;
        }
Exemple #25
0
        private void CheckBox_MouseClick(object sender, MouseEventArgs e)
        {
            Control    control  = sender as Control;
            VisualItem item     = control.Tag as VisualItem;
            CheckBox   checkBox = item.controlsGroup.control as CheckBox;

            if (!(control is CheckBox))
            {
                checkBox.Checked = !checkBox.Checked;
            }

            SetValue(item, checkBox.Checked);
        }
Exemple #26
0
        private void AddControl(VisualItem aVisualItem, Type aType)
        {
            ItemTree aItem = aVisualItem.Item;

            bool isMenu = aItem.type == "menu";
            bool isBool = aItem.type == "bool";
            //Create parent container
            ItemControlsGroup group  = new ItemControlsGroup();
            Control           parent = group.parentContainer = new Control();

            fParams.container.Controls.Add(parent);
            parent.Tag = aVisualItem;

            //Add label describing the entry

            LabelSingleClick label = group.label = new LabelSingleClick(!isBool);

            label.Font = GetLabelFont(aVisualItem);
            label.Text = aItem.displayname;
            label.Tag  = aVisualItem;
            parent.Controls.Add(label);

            //Add the  control itself
            Control control = group.control = Activator.CreateInstance(aType) as Control;

            parent.Controls.Add(control);
            control.Tag = aVisualItem;

            //Add reference from the menu item to the control holding the values.
            aVisualItem.controlsGroup = group;

            //Add a default button
            if (!isMenu)
            {
                Button button = group.defaultButton = new Button();
                parent.Controls.Add(button);
                button.Text      = "Default";
                button.Click    += button_Click;
                button.Tag       = aVisualItem;
                button.FlatStyle = FlatStyle.Popup;
                button.BackColor = System.Drawing.SystemColors.Control;
                fCurrentRow++;
            }

            MouseEnterLeave l = new MouseEnterLeave(parent);

            l.MouseEnter += l_MouseEnter;
            l.MouseLeave += panel_MouseLeave;
            ProceeControl(aVisualItem);
        }
Exemple #27
0
 public ActionMetaItem(
     string name,
     ActionTypes type,
     bool extended,
     string related,
     string container,
     Func <DbManagerProxy, IObject, List <object>, ActResult> first_func,
     Func <DbManagerProxy, IObject, List <object>, ActResult> second_func,
     VisualItem visual,
     bool isWebJScript = false,
     string permission = null,
     Func <bool> permissionPredicate = null,
     Func <IObject, IObjectPermissions, bool, bool> enablePredicate           = null,
     Func <IObject, IObjectPermissions, bool, bool> rdonlyPredicate           = null,
     Func <IObject, IObject, IObjectPermissions, bool, bool> visiblePredicate = null,
     bool forceClose   = false,
     bool onRow        = false,
     string methodName = null,
     bool isSingle     = false,
     IEnumerable <ActionMetaItem> childsActions = null,
     Func <IObject, IEnumerable <ActionMetaItem> > childDynamic = null
     )
 {
     Name         = name;
     ActionType   = type;
     IsExtended   = extended;
     RelatedLists = related;
     Container    = container;
     if (first_func != null)
     {
         m_actionFuncs.Add(first_func);
     }
     if (second_func != null)
     {
         m_actionFuncs.Add(second_func);
     }
     m_visual            = visual;
     IsWebJScript        = isWebJScript;
     Permission          = permission;
     PermissionPredicate = permissionPredicate;
     m_enablePredicates.Add(enablePredicate ?? DefaultEnablePredicate);
     m_readonlyPredicates.Add(rdonlyPredicate ?? DefaultReadOnlyPredicate);
     m_visiblePredicates.Add(visiblePredicate ?? DefaultVisiblePredicate);
     ForceClose       = forceClose;
     OnRow            = onRow;
     MethodName       = methodName ?? name;
     ChildrenInternal = childsActions == null ? new List <ActionMetaItem>() : new List <ActionMetaItem>(childsActions);
     ChildrenDynamic  = childDynamic;
     IsSingle         = isSingle;
 }
Exemple #28
0
        private void ReArrangeRecurseivly(VisualItem aRoot)
        {
            VisualItem visualItem = aRoot;
            ItemTree   item       = aRoot.Item;

            ReArrange(visualItem);
            if (visualItem.subitems != null && (visualItem.Expanded == true || (fParams.filter != null && fParams.filter.IsEmpty() == false)))
            {
                foreach (VisualItem subItem in visualItem.subitems)
                {
                    ReArrangeRecurseivly(subItem);
                }
            }
        }
Exemple #29
0
        public ItemCanvasCursor PutText_AdvanceCaret(
            ItemCanvasCursor Cursor, string Text, bool Reuse = true)
        {
            ItemCanvasCursor cursor = Cursor;
            VisualItem       item   = null;
            var vi = cursor.GetVisualItem();

            if (vi?.IsInputItem == true)
            {
                item   = PutTextToVisualItem(cursor, Text, cursor.Position);
                cursor = cursor.AdvanceRight(HowAdvance.NextEntryField, Reuse);
            }
            return(cursor);
        }
Exemple #30
0
        void MenuSettings_Click(object sender, EventArgs e)
        {
            Control      p = sender as Control;
            ColorDialog  dialog;
            VisualItem   item         = GetItemFromControl(p);
            ColorControl colorControl = item.controlsGroup.control as ColorControl;

            if ((dialog = new ColorDialog()
            {
                FullOpen = true, Color = (Color)GetValue(item.Item.FullName)
            }).ShowDialog() == DialogResult.OK)
            {
                SetValue(item, dialog.Color);
            }
        }
Exemple #31
0
        private void HideAllControlsRecursively(VisualItem aRoot)
        {
            if (aRoot.controlsGroup != null)
            {
                aRoot.controlsGroup.Visible = false;
            }

            if (aRoot.subitems != null)
            {
                foreach (VisualItem subItem in aRoot.subitems)
                {
                    HideAllControlsRecursively(subItem);
                }
            }
        }
    /// <summary>
    /// Creates a new item
    /// </summary>
    /// <param name="vitem">VisualItem to create from</param>
    /// <returns>Item</returns>
    public object Create(VisualItem vitem)
    {
        object clone = null;
        //Item clone = (Item)m_itemList.Find(x => x.Type == vitem.Type && x.GetType().Name == vitem.itemName).Clone();
        //CopyValues(vitem, clone);
        //return clone;
        foreach (Item item in m_itemList)
        {
            if (item.Type == vitem.Type && item.GetType().Name == vitem.itemName)
            {
                //Debug.Log(item.GetType().Name);
                clone = item.Clone();
                CopyValues(vitem, (Item)clone);
                break;
            }

        }

        return clone;
    }
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = new VisualItem[8];
     for(int i = 0;i < _Field0.Length;i++)
     {
         _Field0[i] = new VisualItem();
         _Field0[i].Parse(buffer);
     }
 }
Exemple #34
0
 public static ElementTreeItem Construct(object target, ElementTreeItem parent)
 {
     ElementTreeItem item;
     if (target is Visual)
     {
         item = new VisualItem((Visual)target, parent);
     }
     else if (target is ResourceDictionary)
     {
         item = new ResourceDictionaryItem((ResourceDictionary)target, parent);
     }
     else if (target is Application)
     {
         item = new ApplicationTreeItem((Application)target, parent);
     }
     else
     {
         item = new ElementTreeItem(target, parent);
     }
     item.Reload();
     return item;
 }
Exemple #35
0
        protected override void OnFocusedItemChanged(VisualItem previousFocus)
        {
            if (this.FocusedItem == _DayInput && _DayInput is NumericDayInput)
            {
                UpdateDayMaxValue();
            }
            else if (previousFocus == _YearInput || previousFocus == _DayInput)
            {
                UpdateDayMaxValue();
            }
            else
            {
                SyncValues(previousFocus);
            }

            base.OnFocusedItemChanged(previousFocus);
        }
Exemple #36
0
        //private bool _Validating = false;
        //protected override bool ValidateInput(VisualItem inputItem)
        //{
        //    if (!_Validating && inputItem is IDateTimePartInput && !this.IsEmpty)
        //    {
        //        IDateTimePartInput input = (IDateTimePartInput)inputItem;
        //        System.DateTime v = GetCurrentInputValue();
        //        if (v < _MinDate || v > _MaxDate)
        //        {
        //            try
        //            {
        //                _Validating = true;
        //                input.UndoInput();
        //            }
        //            finally
        //            {
        //                _Validating = false;
        //            }
        //            return false;
        //        }
        //    }
        //    return base.ValidateInput(inputItem);
        //}

        private void SyncValues(VisualItem visualItem)
        {
            IDateTimePartInput inputPart = visualItem as IDateTimePartInput;
            if (inputPart == null)
                return;
            for (int i = 0; i < this.Items.Count; i++)
            {
                IDateTimePartInput part = this.Items[i] as IDateTimePartInput;
                if (part == null) continue;

                if (part.Part == inputPart.Part && part != inputPart)
                    part.Value = inputPart.Value;
                else if (part != inputPart && inputPart.Part == eDateTimePart.DayOfYear && (part.Part == eDateTimePart.Day || part.Part == eDateTimePart.Month))
                {
                    if (_YearInput != null && !_YearInput.IsEmpty)
                    {
                        System.DateTime d = CreateDateTime(_YearInput.Value, inputPart.Value);
                        if (part.Part == eDateTimePart.Day)
                            part.Value = d.Day;
                        else if (part.Part == eDateTimePart.Month)
                            part.Value = d.Month;
                    }
                }
                else if (part.Part == eDateTimePart.DayName)
                {
                    if (_YearInput != null && !_YearInput.IsEmpty &&
                        (_MonthInput != null && !_MonthInput.IsEmpty && _DayInput != null && !_DayInput.IsEmpty ||
                        _DayOfYearInput != null && !_DayOfYearInput.IsEmpty))
                    {
                        try
                        {
                            System.DateTime date;
                            if (_DayOfYearInput != null)
                                date = CreateDateTime(_YearInput.Value, _DayOfYearInput.Value);
                            else
                                date = new System.DateTime(_YearInput.Value, _MonthInput.Value, _DayInput.Value);
                            part.Value = (int)date.DayOfWeek;
                        }
                        catch
                        {
                            part.IsEmpty = true;
                        }
                    }
                    else
                        part.IsEmpty = true;
                }
            }


        }
 /// <summary>
 /// Gives the item but doesn't add to the inventory. Perfectly fine for NPC's and one-item characters
 /// </summary>
 public Item Give(VisualItem item)
 {
     //if (item == null)
     VisualItem clone = GameObject.Instantiate(item);
     clone.Link = (Item)m_factory.Create(item);
     clone.gameObject.SetActive(false);
     return clone.Link;
 }
    /// <summary>
    /// Add an item to the inventory.
    /// If the item already exists, we add more items to that stack. Unless it's unique
    /// </summary>
    /// <param name="item">The item to add</param>
    public bool Add(VisualItem item)
    {
        // Lets not add anything we can't add
        if (item == null)
            return false;

        if (item.Link == null)
            item.Link = (Item)m_factory.Create(item);

        // Inventory is full, refuse to add any more
        if (m_items.Count == m_items.Capacity)
            return false;

        // Try to find the item from the inventory
        Item match = m_items.Find(x => x.Type == item.Link.Type && x.Name == item.niceName);

        // If the item is 'unique' (weapon, armor), it will not be stacked

        // Not found; lets add it
        if (match == null || item.Link.Type != Item.ItemType.Generic)
        {
            m_items.Add(item.Link);
        }
        // Match found; Lets increase the amount of the match
        else
        {
            //FIXME: references?
            match.Amount += item.Link.Amount;
            GameObject.Destroy(item.gameObject);
        }

        // Raise events that we added some items
        if (onAdd != null)
            onAdd();

        if (onChange != null)
            onChange();

        return true;
    }