示例#1
0
        protected virtual void HandleMouseOver()
        {
            if (!IsUnderMouse)
            {
                DrawBoxUnderMouse = null;
                return;
            }

            DrawBoxUnderMouse = null;

            foreach (DrawBox child in DrawBoxList)
            {
                if (DialoguesAreHidden && dialogues.Contains(child))
                {
                    continue;
                }

                if (child.CheckMouseOver())
                {
                    if (DrawBoxUnderMouse == null)
                    {
                        DrawBoxUnderMouse = child;
                    }
                    else if (DrawBoxList.IndexOf(child) > DrawBoxList.IndexOf(DrawBoxUnderMouse))
                    {
                        DrawBoxUnderMouse = child;
                    }
                }
            }
        }
示例#2
0
 public void RequestRemoval(DrawBox box)
 {
     if (!removeQue.Contains(box))
     {
         removeQue.Add(box);
     }
 }
示例#3
0
        /// <summary>
        /// Removes the drawbox in the slot of the provided handler.
        /// </summary>
        /// <param name="handler"></param>
        protected void RemoveDrawBoxInSlot(SlotHandler handler)
        {
            DrawBox drawBox = Slots[handler].DrawBox;

            if (drawBox.Container != this)
            {
                Debug.AddExceptionInClass(this.GetType(), "RemoveDrawBoxFromSlot", "DrawBox does not have correct container.");
                return;
            }

            if (!drawBox.IsClosed)
            {
                drawBox.Close();
            }

            drawBox.Container = null;
            drawBox.Handler   = null;

            Slots[handler].DrawBox = null;
            drawBoxList.Remove(drawBox);

            DrawBoxHasBeenRemoved(drawBox, handler);

            UpdateSize();
        }
示例#4
0
        protected override void DrawBoxHasBeenRemoved(DrawBox box, SlotHandler handler)
        {
            RemoveSlot(handler);

            if (DrawBoxRemoved != null)
            {
                DrawBoxRemoved(this, box);
            }
        }
示例#5
0
        public void AddDrawBox(DrawBox drawBox)
        {
            PutDrawBoxInSlot(drawBox, AddNewSlot());

            if (DrawBoxAdded != null)
            {
                DrawBoxAdded(this, drawBox);
            }
        }
示例#6
0
        //TODO: make point GetChildDrawBoundary, something that doesnt affect size.
        protected ViewRect GenerateChildBoundaries(DrawBox drawBox, int newWidth, int newHeight)
        {
            if (drawBox.Container != this)
            {
                Debug.AddExceptionInClass(this.GetType(), "GenerateChildBoundaries", "Tried to get boundaries for point drawbox with point different container");
                return(ViewRect.Empty);
            }

            return(GenerateSlotBoundaries(drawBox.Handler));
        }
示例#7
0
文件: Window.cs 项目: lukastk/TakaGUI
        /// <summary>
        /// Draws the window.
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="viewRect"></param>
        public override void Draw(GameTime gameTime, ViewRect viewRect)
        {
            if (IsClosed || !IsInitialized || !Activated)
            {
                return;
            }

            if (!Hidden)
            {
                ViewRect windowRect = viewRect.AddGet(new ViewRect(RealX, RealY, Width, Height));
                windowRect.Add(GetDefaultBoundaries());
                IRender render = GraphicsManager.GetRender();
                render.SetViewRect(windowRect);
                Project(gameTime, RealX, RealY, render);

                if (!DialoguesAreHidden && DarkenWhenDialogueExists && GetCurrentDialogue() != null)
                {
                    DrawBox currentDialogue = GetCurrentDialogue();

                    foreach (DrawBox d in DrawBoxList)
                    {
                        if (currentDialogue != d)
                        {
                            d.Draw(gameTime, viewRect);
                        }
                    }

                    var r = GraphicsManager.GetRender();
                    r.Begin();
                    r.Clear(DarkeningMask);
                    r.End();

                    currentDialogue.Draw(gameTime, viewRect);
                }
                else
                {
                    foreach (DrawBox d in DrawBoxList)
                    {
                        if (DialoguesAreHidden && dialogues.Contains(d))
                        {
                            continue;
                        }

                        d.Draw(gameTime, viewRect);
                    }
                }

                foreach (var f in drawDelegates)
                {
                    f(gameTime, viewRect);
                }

                drawDelegates.Clear();
            }
        }
示例#8
0
        /// <summary>
        /// Tells the drawbox to put the provided child-drawbox in the back of the drawing and update que.
        /// </summary>
        /// <param name="drawBox"></param>
        public void PutChildInBack(DrawBox drawBox)
        {
            if (!DrawBoxList.Contains(drawBox))
            {
                Debug.AddExceptionInClass(this.GetType(), "ContainerBox.PutChildInBack", "The DrawBox instance is not one of the alignWith-objects.");
                return;
            }

            drawBoxList.Remove(drawBox);
            drawBoxList.Insert(0, drawBox);
        }
示例#9
0
        /// <summary>
        /// Removes the specified drawbox from its slot.
        /// </summary>
        /// <param name="box"></param>
        protected void RemoveDrawBoxFromSlot(DrawBox box)
        {
            var slotList = (from s in Slots.Values where s.DrawBox == box select s);

            if (slotList.Count() != 0)
            {
                RemoveDrawBoxInSlot(slotList.First().Handler);
            }
            else
            {
                Debug.AddExceptionInClass(this.GetType(), "RemoveDrawBoxFromSlot", "Tried to remove non-existing drawbox.");
            }
        }
示例#10
0
        /// <summary>
        /// Inserts the drawbox to the slot with the provided handler.
        /// </summary>
        /// <param name="box">The box to insert into the slot.</param>
        /// <param name="handler">The handler of the slot.</param>
        protected void PutDrawBoxInSlot(DrawBox box, SlotHandler handler)
        {
            if (box == this)
            {
                Debug.AddExceptionInClass(this.GetType(), "PutDrawBoxInSlot", "Can't add this to itself.");
                return;
            }

            if (handler.DrawBox != null)
            {
                Debug.AddExceptionInClass(this.GetType(), "PutDrawBoxInSlot", "Can't add point DrawBox to an occupied slot.");
                return;
            }

            if (DrawBoxList.Contains(box))
            {
                Debug.AddExceptionInClass(this.GetType(), "PutDrawBoxInSlot", "Can't add point DrawBox instance twice to the same container");
                return;
            }

            if (box.Container != null)
            {
                Debug.AddExceptionInClass(this.GetType(), "PutDrawBoxInSlot", "Can't add point DrawBox instance that already has point container.");
                return;
            }

            if (!box.IsInitialized)
            {
                Debug.AddExceptionInClass(this.GetType(), "PutDrawBoxInSlot", "Can't add point DrawBox that is not initialized.");
                return;
            }

            if (!Slots.ContainsKey(handler))
            {
                Debug.AddExceptionInClass(this.GetType(), "PutDrawBoxInSlot", "Tried to put drawbox in non-existing slot.");
                return;
            }

            Slots[handler].DrawBox = box;
            drawBoxList.Add(box);

            box.Parent    = Parent;
            box.Container = this;
            box.Handler   = handler;

            UpdateSize();

            box.ReloadAlignment();
            box.AddedToContainer();
            DrawBoxHasBeenAdded(box, handler);
        }
示例#11
0
        public override void Update(GameTime gameTime)
        {
            SetChildParameters();

            base.Update(gameTime);

            if (IsClosed || !IsInitialized || !Activated)
            {
                return;
            }

            HandleFocus();
            HandleMouseOver();
            while (dialogues.Count != 0 && dialogues.Last().IsClosed)
            {
                dialogues.RemoveAt(dialogues.Count - 1);
            }

            if (!DialoguesAreHidden && dialogues.Count != 0)
            {
                var dialog = dialogues.Last();
                if (dialog != DrawBoxWithFocus)
                {
                    DrawBoxWithFocus = null;
                }
                if (dialog != DrawBoxUnderMouse)
                {
                    DrawBoxUnderMouse = null;
                }
            }

            if (removeQue.Count != 0)
            {
                foreach (DrawBox d in removeQue)
                {
                    RemoveDrawBoxFromSlot(d);
                }

                removeQue.Clear();
            }

            foreach (DrawBox d in new List <DrawBox>(drawBoxList))
            {
                if (DialoguesAreHidden && dialogues.Contains(d))
                {
                    continue;
                }

                d.Update(gameTime);
            }
        }
示例#12
0
文件: Push.cs 项目: lukastk/TakaGUI
        public static void HorizontallyAlignWith(DrawBox box, DrawBox alignWith, HorizontalAlign align)
        {
            switch (align)
            {
            case HorizontalAlign.Top:
                box.Y = alignWith.Y;
                break;

            case HorizontalAlign.Center:
                box.Y = alignWith.Y + (alignWith.Height / 2) - (box.Height / 2);
                break;

            case HorizontalAlign.Bottom:
                box.Y = alignWith.Y + alignWith.Height - box.Height;
                break;
            }
        }
示例#13
0
文件: Push.cs 项目: lukastk/TakaGUI
        public static void VerticallyAlignWith(DrawBox box, DrawBox alignWith, VerticalAlign align)
        {
            switch (align)
            {
            case VerticalAlign.Left:
                box.X = alignWith.X;
                break;

            case VerticalAlign.Center:
                box.X = alignWith.X + (alignWith.Width / 2) - (box.Width / 2);
                break;

            case VerticalAlign.Right:
                box.X = alignWith.X + alignWith.Width - box.Width;
                break;
            }
        }
示例#14
0
        public override void Draw(GameTime gameTime, ViewRect viewRect)
        {
            base.Draw(gameTime, viewRect);

            if (!IsInitialized || !Activated || Hidden)
            {
                return;
            }

            viewRect.Add(Boundaries);
            viewRect.Add(GetMasterBoundaries());

            if (!DialoguesAreHidden && DarkenWhenDialogueExists && GetCurrentDialogue() != null)
            {
                DrawBox currentDialogue = GetCurrentDialogue();

                foreach (DrawBox d in DrawBoxList)
                {
                    if (currentDialogue != d)
                    {
                        d.Draw(gameTime, viewRect);
                    }
                }

                var render = GraphicsManager.GetRender();
                render.Begin();
                render.Clear(DarkeningMask);
                render.End();

                currentDialogue.Draw(gameTime, viewRect);
            }
            else
            {
                foreach (DrawBox d in DrawBoxList)
                {
                    if (DialoguesAreHidden && dialogues.Contains(d))
                    {
                        continue;
                    }

                    d.Draw(gameTime, viewRect);
                }
            }
        }
示例#15
0
        protected virtual void HandleFocus()
        {
            if (DrawBoxWithFocus != null && DrawBoxWithFocus.Suspended)
            {
                DrawBoxWithFocus = null;
            }

            if (!HasFocus)
            {
                DrawBoxWithFocus = null;
                return;
            }

            DrawBox oldDrawBoxWithFocus = DrawBoxWithFocus;

            DrawBoxWithFocus = null;

            foreach (DrawBox d in DrawBoxList)
            {
                if (DialoguesAreHidden && dialogues.Contains(d))
                {
                    continue;
                }

                if (d.CheckFocus())
                {
                    if (DrawBoxWithFocus == null)
                    {
                        DrawBoxWithFocus = d;
                    }
                    else if (DrawBoxList.IndexOf(d) > DrawBoxList.IndexOf(DrawBoxWithFocus))
                    {
                        DrawBoxWithFocus = d;
                    }
                }
            }

            if (DrawBoxWithFocus == null)
            {
                DrawBoxWithFocus = oldDrawBoxWithFocus;
            }
        }
示例#16
0
文件: Push.cs 项目: lukastk/TakaGUI
        public static void FromSide(DrawBox box, int distance, Side edge)
        {
            ViewRect bounds = box.Boundaries;

            switch (edge)
            {
            case Side.Top:
                box.Y = distance;
                break;

            case Side.Bottom:
                box.Y = bounds.Height - box.Height - distance;
                break;

            case Side.Left:
                box.X = distance;
                break;

            case Side.Right:
                box.X = bounds.Width - box.Width - distance;
                break;
            }
        }
示例#17
0
 /// <summary>
 /// Queries the slotbox whether the child-drawbox is the drawbox with focus.
 /// </summary>
 /// <param name="box"></param>
 /// <returns></returns>
 public bool TestDrawBoxWithFocus(DrawBox box)
 {
     return(DrawBoxWithFocus == box);
 }
示例#18
0
文件: Push.cs 项目: lukastk/TakaGUI
 public static void ToHorizontalCenter(DrawBox box)
 {
     box.X = (box.Boundaries.Width / 2) - box.Width / 2;
 }
示例#19
0
文件: Push.cs 项目: lukastk/TakaGUI
 public static void ToVerticalCenter(DrawBox box)
 {
     box.Y = (box.Boundaries.Height / 2) - box.Height / 2;
 }
示例#20
0
 protected Origin GenerateChildOrigin(DrawBox box)
 {
     return(GenerateChildOrigin(box.Handler));
 }
示例#21
0
 /// <summary>
 /// Queries the slotbox whether the child-drawbox is inside the slotbox.
 /// </summary>
 /// <param name="box"></param>
 /// <returns></returns>
 public bool TestIsDrawBoxInContainer(DrawBox box)
 {
     return(DrawBoxList.Contains(box));
 }
示例#22
0
文件: Push.cs 项目: lukastk/TakaGUI
        public static void ToTheBottomSideOf(DrawBox box, DrawBox alignWith, int margin, VerticalAlign align)
        {
            VerticallyAlignWith(box, alignWith, align);

            box.Y = alignWith.Y + alignWith.Height + margin;
        }
示例#23
0
文件: Push.cs 项目: lukastk/TakaGUI
        public static void ToTheRightSideOf(DrawBox box, DrawBox alignWith, int margin, HorizontalAlign align)
        {
            HorizontallyAlignWith(box, alignWith, align);

            box.X = alignWith.X + alignWith.Width + margin;
        }
示例#24
0
 protected ViewRect GenerateChildBoundaries(DrawBox drawBox)
 {
     return(GenerateChildBoundaries(drawBox, Width, Height));
 }
示例#25
0
文件: Push.cs 项目: lukastk/TakaGUI
        public static void ToTheTopSideOf(DrawBox box, DrawBox alignWith, int margin, VerticalAlign align)
        {
            VerticallyAlignWith(box, alignWith, align);

            box.Y = alignWith.Y - box.Height - margin;
        }
示例#26
0
 /// <summary>
 /// Is called whenever a drawbox has been removed.
 /// </summary>
 /// <param name="box"></param>
 /// <param name="handler"></param>
 protected virtual void DrawBoxHasBeenRemoved(DrawBox box, SlotHandler handler)
 {
 }
示例#27
0
 public void PutDialogOnStack(DrawBox drawBox)
 {
     dialogues.Add(drawBox);
 }
示例#28
0
 /// <summary>
 /// Queries the slotbox whether the child-drawbox is the last to draw.
 /// </summary>
 /// <param name="child"></param>
 /// <returns></returns>
 public bool IsChildLastToDraw(DrawBox child)
 {
     return(child == DrawBoxList.Last());
 }
示例#29
0
 /// <summary>
 /// Queries the slotbox whether the child-drawbox is the drawbox under the mouse.
 /// </summary>
 /// <param name="box"></param>
 /// <returns></returns>
 public bool TestDrawBoxUnderMouse(DrawBox box)
 {
     return(DrawBoxUnderMouse == box);
 }
示例#30
0
 public void RemoveDialogFromStack(DrawBox drawBox)
 {
     dialogues.Remove(drawBox);
 }