Example #1
0
		/// <summary>
		/// Copies the state from another instance
		/// </summary>
		/// <param name="other">The GUIItem to copy from</param>
		public override void CopyFrom (GUIItem other)
		{
			base.CopyFrom (other);
			
			GUIButton button = other as GUIButton;
			if (button == null)
			{
				return;
			}
						
			OnClick = button.OnClick;			
		}
		/// <summary>
		/// Copies the state from another instance
		/// </summary>
		/// <param name="other">The GUIItem to copy from</param>
		public override void CopyFrom (GUIItem other)
		{
			base.CopyFrom (other);
			
			WorkItemProgressBar bar = other as WorkItemProgressBar;
			if (bar == null)
			{
				return;
			}
			
			WorkInProgress = bar.WorkInProgress; 
		}
Example #3
0
		/// <summary>
		/// Copies the state from another instance
		/// </summary>
		/// <param name="other">The GUIItem to copy from</param>
		public override void CopyFrom (GUIItem other)
		{
			base.CopyFrom (other);
			
			GUIProgressBar bar = other as GUIProgressBar;
			if (bar == null)
			{
				return;
			}
			
			BarInner = bar.BarInner;			
			MinValue = bar.MinValue;			
			MaxValue = bar.MaxValue;			
			Value = bar.Value;	
			Rect rectangle = TexCoords;
			rectangle.x = bar.TexCoords.x;
			rectangle.y = bar.TexCoords.y;
			rectangle.width = bar.TexCoords.width;
			rectangle.height = bar.TexCoords.height;
			TexCoords = rectangle;
		}
Example #4
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="item"></param>
		/// <param name="current"></param>
		/// <returns></returns>
		public static bool AnyItem(GUIItem item, GUIItem other)
		{
			return true;
		}
Example #5
0
		/// <summary>
		/// Handles the begin of a drag event
		/// </summary>
		/// <param name="x">The x coordinate.</param>
		/// <param name="y">The y coordinate.</param>
		public void HandleDragBegin(float x, float y)
		{
			currentlyGrabbedItem = GrabItem(x, y);

			if (currentlyGrabbedItem == null)
			{
				HandleGameWorldDragBegin(x, Screen.height - y);			
			}
		}
Example #6
0
		/// <summary>
		/// Releases the currently grabbed item if there is one
		/// </summary>
		public bool ReleaseItem(GUIItem grabbedItem)
		{
			if (grabbedItem == null)
			{
				return false;
			}
			
			GUIItem dropper = 
				GetItemAt(grabbedItem.Rectangle.x, grabbedItem.Rectangle.y, 
				          grabbedItem.Rectangle.width, grabbedItem.Rectangle.height, 
				          grabbedItem, AcceptsDraggable);
								
			if (dropper != null)
			{
				dropper.OnDrop(dropper, grabbedItem);
			}
			
			if (currentlyGrabbedItem.DuplicateOnDrag)
			{
				grabbedItem.Destroy();
				RemoveChild(GUIElementEnum.CurrentDraggable);
			}
			grabbedItem = null;

			return true;
		}
Example #7
0
        /// <summary>
        /// Drags an item to the absolute screen position specified
        /// </summary>
        public void DragItem(GUIItem item, float x, float y)
        {
			Rect currentRect = item.Rectangle;
			currentRect.x = (x - item.Offset.x) - item.DragHandle.x;
			currentRect.y = (y - item.Offset.y) - item.DragHandle.y;
			item.Rectangle = currentRect;
        }
Example #8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="item"></param>
 /// <param name="current"></param>
 /// <returns></returns>
 public static bool AcceptsDraggable(GUIItem item, GUIItem other)
 {
     return (item.Droppable == other.Draggable);
 }
Example #9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="item"></param>
 /// <param name="current"></param>
 /// <returns></returns>
 public static bool IsDraggable(GUIItem item, GUIItem other)
 {
     return (item.Draggable != DraggableEnum.NONE);
 }
Example #10
0
		/// <summary>
		/// Copies the state from another instance
		/// </summary>
		/// <param name="other">The GUIItem to copy from</param>
		public virtual void CopyFrom(GUIItem other)
        {
        	Children.Clear();
        	foreach(GUIItem item in other.Children.Values)
        	{
				Children.Add(item.Element, item);
        	}		
			Animated = other.Animated;
			IsWorld = other.IsWorld;
			Vector2 world = WorldCoords;
			world.x = other.WorldCoords.x;
			world.y = other.WorldCoords.y;
			WorldCoords = world;						
        	Parent = other.Parent;	
			BuildableItem = other.BuildableItem;
			Vector2 off = Offset;
			off.x = other.Offset.x;
			off.y = other.Offset.y;
			Offset = off;
			Draggable = other.Draggable;
			Droppable = other.Droppable;
			Vector2 drag = DragHandle;
			drag.x = other.DragHandle.x;
			drag.y = other.DragHandle.y;
			DragHandle = drag;
			DuplicateOnDrag = other.DuplicateOnDrag;
            OnDrop = other.OnDrop;
			Element = other.Element;
			Rect rectangle = Rectangle;
			rectangle.x = other.Rectangle.x;
			rectangle.y = other.Rectangle.y;
			rectangle.width = other.Rectangle.width;
			rectangle.height = other.Rectangle.height;
			Rectangle = rectangle;
			Style = other.Style;
			Content.image = other.Content.image;
			Content.text = other.Content.text;			
			Available = other.Available;
			Visible = other.Visible;
			Enabled = other.Enabled;
			if (AvailableCheck != null)
			{
				AvailableCheck.CopyFrom(other.AvailableCheck);
			}
			if (EnabledCheck != null) 
			{				
				EnabledCheck.CopyFrom(other.EnabledCheck);
			}
			Scale = other.Scale;
        }
Example #11
0
        /// <summary>
        /// Returns the child at the specified position looking recursively
        /// through child items
        /// </summary>
        /// <param name="element"></param>
        public GUIItem GetItemAt(float x, float y, float w, float h,
        	GUIItem other, Func<GUIItem, GUIItem, bool> condition)
        {
            foreach (GUIItem item in Children.Values)
            {
				if (!item.Traversed)
                {
                    continue;
                }

                if (x + w > item.Rectangle.x && x < item.Rectangle.x + item.Rectangle.width &&
                       y  + h > item.Rectangle.y && y < item.Rectangle.y + item.Rectangle.height)
                {
                    if (condition(item, other))
                    {
                        return item;
                    }

                    GUIItem found = item
						.GetItemAt(x - item.Rectangle.x, y - item.Rectangle.y, w, h, 
                        	other, condition);

                    if (found != null)
                    {
                        return found;
                    }
                }
            }

            return null;
        }
Example #12
0
        /// <summary>
        /// Adds a child to an item
        /// </summary>
        public ErrorCode AddChild(GUIItem item)
        {
            if (Children.ContainsKey(item.Element))
            {
                return ErrorCode.ITEM_ALREADY_EXISTS;
            }
            
            item.Parent = this;

            Vector2 offset = item.Offset;
            offset.x = Offset.x + Rectangle.x;
            offset.y = Offset.y + Rectangle.y;
            item.Offset = offset;

            Children[item.Element] = item;

			ChildrenModified = true;
			
            return ErrorCode.ERROR_OK;
        }