Example #1
0
        public void Add(LComponent comp, int index)
        {
            if (comp.GetContainer() != null)
            {
                throw new InvalidOperationException(comp
                                                    + " already reside in another container!!!");
            }
            comp.SetContainer(this);
            LComponent[] newChilds = new LComponent[this.childs.Length + 1];
            this.childCount++;
            int ctr = 0;

            for (int i = 0; i < this.childCount; i++)
            {
                if (i != index)
                {
                    newChilds[i] = this.childs[ctr];
                    ctr++;
                }
            }
            this.childs        = newChilds;
            this.childs[index] = comp;
            this.desktop.SetDesktop(comp);
            this.SortComponents();
            this.latestInserted = comp;
        }
Example #2
0
		public int Remove(LComponent comp) {
			int removed = this.RemoveComponent(this.contentPane, comp);
			if (removed != -1) {
				this.ProcessTouchMotionEvent();
			}
			return removed;
		}
Example #3
0
 public LContainer(int x, int y, int w, int h) : base(x, y, w, h)
 {
     this.comparator     = LContainer.DEFAULT_COMPARATOR;
     this.childs         = new LComponent[0];
     this.childCount     = 0;
     this.latestInserted = null;
     this.SetFocusable(false);
 }
Example #4
0
 internal void DeselectComponent()
 {
     if (this.selectedComponent == null)
     {
         return;
     }
     this.selectedComponent.SetSelected(false);
     this.selectedComponent = null;
 }
Example #5
0
 public bool Intersects(LComponent comp)
 {
     return((this.visible) &&
            (comp.IsVisible()) &&
            (this.screenX + this.width * scaleX >= comp.screenX &&
             this.screenX <= comp.screenX + comp.width &&
             this.screenY + this.height * scaleY >= comp.screenY && this.screenY <= comp.screenY
             + comp.height));
 }
Example #6
0
 public void SetModal(LComponent comp)
 {
     if (comp != null && !comp.IsVisible())
     {
         throw new Exception(
                   "Can't set invisible component as modal component!");
     }
     this.modal = comp;
 }
Example #7
0
		public void Add(LComponent comp) {
			if (comp == null) {
				return;
			}
			if (comp.isFull) {
				this.input.SetRepaintMode(Screen.SCREEN_NOT_REPAINT);
			}
			this.contentPane.Add(comp);
			this.ProcessTouchMotionEvent();
		}
Example #8
0
        public int Remove(LComponent comp)
        {
            int removed = this.RemoveComponent(this.contentPane, comp);

            if (removed != -1)
            {
                this.ProcessTouchMotionEvent();
            }
            return(removed);
        }
Example #9
0
        public LComponent Remove(int index)
        {
            LComponent comp = this.childs[index];

            this.desktop.SetComponentStat(comp, false);
            comp.SetContainer(null);
            // comp.dispose();
            this.childs = (LComponent[])CollectionUtils.Cut(this.childs, index);
            this.childCount--;

            return(comp);
        }
Example #10
0
        private LComponent FindComponent(int x, int y)
        {
            if (this.modal != null && !this.modal.IsContainer())
            {
                return(null);
            }
            LContainer panel = (this.modal == null) ? this.contentPane
                                        : ((LContainer)this.modal);
            LComponent comp = panel.FindComponent(x, y);

            return(comp);
        }
Example #11
0
 internal void SetDesktop(LComponent comp)
 {
     if (comp.IsContainer())
     {
         LComponent[] child = ((LContainer)comp).GetComponents();
         for (int i = 0; i < child.Length; i++)
         {
             this.SetDesktop(child[i]);
         }
     }
     comp.SetDesktop(this);
 }
Example #12
0
 public int Remove(LComponent comp)
 {
     for (int i = 0; i < this.childCount; i++)
     {
         if (this.childs[i] == comp)
         {
             this.Remove(i);
             return(i);
         }
     }
     return(-1);
 }
Example #13
0
 public void DoClick(LComponent comp)
 {
     if (!action.IsPressed())
     {
         action.Press();
         if (comp.Tag is Screen)
         {
             Screen screen = (Screen)comp.Tag;
             screen.ReplaceScreen(new MyAVGScreen(), MoveMethod.FROM_LEFT);
         }
     }
 }
Example #14
0
 public void Add(LComponent comp)
 {
     if (comp == null)
     {
         return;
     }
     if (comp.isFull)
     {
         this.input.SetRepaintMode(Screen.SCREEN_NOT_REPAINT);
     }
     this.contentPane.Add(comp);
     this.ProcessTouchMotionEvent();
 }
Example #15
0
        internal bool SelectComponent(LComponent comp)
        {
            if (!comp.IsVisible() || !comp.IsEnabled() || !comp.IsFocusable())
            {
                return(false);
            }

            this.DeselectComponent();

            comp.SetSelected(true);
            this.selectedComponent = comp;

            return(true);
        }
Example #16
0
            public void DownClick(LComponent comp, float x, float y)
            {

                if (comp.Tag is AVGScreen)
                {
                    AVGScreen screen = (AVGScreen)comp.Tag;
                    // 解除锁定
                    screen.SetLocked(false);
                    // 触发事件
                    // click();
                    // 删除当前按钮
                    screen.Remove(comp);
                }
            }
Example #17
0
		private int RemoveComponent(LContainer container, LComponent comp) {
			int removed = container.Remove(comp);
			LComponent[] components = container.GetComponents();
			int i = 0;
			while (removed == -1 && i < components.Length - 1) {
				if (components[i].IsContainer()) {
					removed = this
							.RemoveComponent((LContainer) components[i], comp);
				}
				i++;
			}
	
			return removed;
		}
Example #18
0
        /// <summary>
        /// 鼠标运动事件
        /// </summary>
        ///
        private void ProcessTouchMotionEvent()
        {
            if (this.hoverComponent != null && this.hoverComponent.IsEnabled() &&
                input.IsMoving())
            {
                if (this.input.GetTouchDY() != 0 || this.input.GetTouchDY() != 0)
                {
                    this.hoverComponent.ProcessTouchDragged();
                }
            }
            else
            {
                if (Touch.IsDrag() || Touch.IsMove())
                {
                    // 获得当前窗体下鼠标坐标
                    LComponent comp = this.FindComponent(this.input.GetTouchX(),
                                                         this.input.GetTouchY());
                    if (comp != null)
                    {
                        if (this.input.GetTouchDX() != 0 ||
                            this.input.GetTouchDY() != 0)
                        {
                            comp.ProcessTouchMoved();
                        }

                        if (this.hoverComponent == null)
                        {
                            comp.ProcessTouchEntered();
                        }
                        else if (comp != this.hoverComponent)
                        {
                            this.hoverComponent.ProcessTouchExited();
                            comp.ProcessTouchEntered();
                        }
                    }
                    else
                    {
                        if (this.hoverComponent != null)
                        {
                            this.hoverComponent.ProcessTouchExited();
                        }
                    }

                    this.hoverComponent = comp;
                }
            }
        }
Example #19
0
 public LComponent FindComponent(int x1, int y1)
 {
     if (!this.Intersects(x1, y1))
     {
         return(null);
     }
     for (int i = 0; i < this.childCount; i++)
     {
         if (this.childs[i].Intersects(x1, y1))
         {
             LComponent comp = (!this.childs[i].IsContainer()) ? this.childs[i]
                     : ((LContainer)this.childs[i]).FindComponent(x1, y1);
             return(comp);
         }
     }
     return(this);
 }
Example #20
0
        public LLayer GetBottomLayer()
        {
            LComponent[] components = contentPane.GetComponents();
            int          size       = components.Length;
            Type         clazz      = typeof(LLayer);

            for (int i = size; i > 0; i--)
            {
                LComponent comp = components[i - 1];
                Type       cls  = comp.GetType();
                if (clazz == null || clazz == cls || clazz.IsInstanceOfType(comp) ||
                    clazz.Equals(cls))
                {
                    return((LLayer)comp);
                }
            }
            return(null);
        }
Example #21
0
 public void DoClick(int x, int y)
 {
     if (!this.contentPane.IsVisible())
     {
         return;
     }
     LComponent[] components = contentPane.GetComponents();
     for (int i = 0; i < components.Length; i++)
     {
         LComponent component = components[i];
         if (component != null && component.Intersects(x, y))
         {
             component.Update(0);
             component.ProcessTouchPressed();
         }
     }
     isClicked = true;
 }
Example #22
0
 public void Add(LComponent comp)
 {
     if (this.Contains(comp))
     {
         return;
     }
     if (comp.GetContainer() != null)
     {
         comp.SetContainer(null);
     }
     comp.SetContainer(this);
     this.childs = (LComponent[])CollectionUtils.Expand(this.childs, 1,
                                                        false);
     this.childs[0] = comp;
     this.childCount++;
     this.desktop.SetDesktop(comp);
     this.SortComponents();
     this.latestInserted = comp;
 }
Example #23
0
 public bool Contains(LComponent comp)
 {
     if (comp == null)
     {
         return(false);
     }
     if (childs == null)
     {
         return(false);
     }
     for (int i = 0; i < this.childCount; i++)
     {
         if (childs[i] != null && comp.Equals(childs[i]))
         {
             return(true);
         }
     }
     return(false);
 }
Example #24
0
        private int RemoveComponent(LContainer container, LComponent comp)
        {
            int removed = container.Remove(comp);

            LComponent[] components = container.GetComponents();
            int          i          = 0;

            while (removed == -1 && i < components.Length - 1)
            {
                if (components[i].IsContainer())
                {
                    removed = this
                              .RemoveComponent((LContainer)components[i], comp);
                }
                i++;
            }

            return(removed);
        }
Example #25
0
        internal void SetComponentStat(LComponent comp, bool active)
        {
            if (this == Desktop.EMPTY_DESKTOP)
            {
                return;
            }

            if (!active)
            {
                if (this.hoverComponent == comp)
                {
                    this.ProcessTouchMotionEvent();
                }

                if (this.selectedComponent == comp)
                {
                    this.DeselectComponent();
                }

                this.clickComponent[0] = null;

                if (this.modal == comp)
                {
                    this.modal = null;
                }
            }
            else
            {
                this.ProcessTouchMotionEvent();
            }

            if (comp.IsContainer())
            {
                LComponent[] components = ((LContainer)comp).GetComponents();
                int          size       = ((LContainer)comp).GetComponentCount();
                for (int i = 0; i < size; i++)
                {
                    this.SetComponentStat(components[i], active);
                }
            }
        }
Example #26
0
        public List <LComponent> GetComponents(Type clazz)
        {
            if (clazz == null)
            {
                return(null);
            }
            LComponent[]      components = contentPane.GetComponents();
            int               size       = components.Length;
            List <LComponent> l          = new List <LComponent>(size);

            for (int i = size; i > 0; i--)
            {
                LComponent comp = components[i - 1];
                Type       cls  = comp.GetType();
                if (clazz == null || clazz == cls || clazz.IsInstanceOfType(comp) ||
                    clazz.Equals(cls))
                {
                    CollectionUtils.Add(l, comp);
                }
            }
            return(l);
        }
Example #27
0
        public int Remove(Type clazz)
        {
            if (clazz == null)
            {
                return(-1);
            }
            int count = 0;

            for (int i = childCount; i > 0; i--)
            {
                int        index = i - 1;
                LComponent comp  = this.childs[index];
                Type       cls   = comp.GetType();
                if (clazz == null || (object)clazz == (object)cls || clazz.IsInstanceOfType(comp) ||
                    clazz.Equals(cls))
                {
                    this.Remove(index);
                    count++;
                }
            }
            return(count);
        }
Example #28
0
        protected internal void TransferFocusBackward(LComponent component)
        {
            for (int i = 0; i < this.childCount; i++)
            {
                if (component == this.childs[i])
                {
                    int j = i;
                    do
                    {
                        if (++i >= this.childCount)
                        {
                            i = 0;
                        }
                        if (i == j)
                        {
                            return;
                        }
                    } while (!this.childs[i].RequestFocus());

                    break;
                }
            }
        }
Example #29
0
 public void SendToBack(LComponent comp)
 {
     if (this.childCount <= 1 || this.childs[this.childCount - 1] == comp)
     {
         return;
     }
     if (childs[this.childCount - 1] == comp)
     {
         return;
     }
     for (int i = 0; i < this.childCount; i++)
     {
         if (this.childs[i] == comp)
         {
             this.childs = (LComponent[])CollectionUtils
                           .Cut(this.childs, i);
             this.childs = (LComponent[])CollectionUtils.Expand(
                 this.childs, 1, true);
             this.childs[this.childCount - 1] = comp;
             this.SortComponents();
             break;
         }
     }
 }
Example #30
0
		internal void SetComponentStat(LComponent comp, bool active) {
			if (this == Desktop.EMPTY_DESKTOP) {
				return;
			}
	
			if (!active) {
				if (this.hoverComponent == comp) {
					this.ProcessTouchMotionEvent();
				}
	
				if (this.selectedComponent == comp) {
					this.DeselectComponent();
				}
	
				this.clickComponent[0] = null;
	
				if (this.modal == comp) {
					this.modal = null;
				}
	
			} else {
				this.ProcessTouchMotionEvent();
			}
	
			if (comp.IsContainer()) {
				LComponent[] components = ((LContainer) comp).GetComponents();
				int size = ((LContainer) comp).GetComponentCount();
				for (int i = 0; i < size; i++) {
					this.SetComponentStat(components[i], active);
				}
			}
		}
Example #31
0
		internal void DeselectComponent() {
			if (this.selectedComponent == null) {
				return;
			}
			this.selectedComponent.SetSelected(false);
			this.selectedComponent = null;
		}
Example #32
0
 public Bind(Object o)
 {
     if (o is Actor)
     {
         type = 1;
         actorObject = (Actor)o;
         this.isBindPos = true;
         this.isBindGetPos = true;
         this.isBindRotation = true;
         this.isBindGetRotation = true;
         this.isBindUpdate = true;
         this.isBindScale = true;
         this.isBindSize = true;
     }
     else if (o is Shape)
     {
         type = 2;
         shapeObject = (Shape)o;
         this.isBindPos = true;
         this.isBindGetPos = true;
         this.isBindRotation = true;
         this.isBindGetRotation = true;
         this.isBindUpdate = false;
         this.isBindScale = true;
         this.isBindSize = true;
     }
     else if (o is LComponent)
     {
         type = 3;
         compObject = (LComponent)o;
         this.isBindPos = true;
         this.isBindGetPos = true;
         this.isBindRotation = false;
         this.isBindGetRotation = false;
         this.isBindUpdate = true;
         this.isBindScale = false;
         this.isBindSize = true;
     }
     else if (o is LObject)
     {
         type = 4;
         lObject = (LObject)o;
         this.isBindPos = true;
         this.isBindGetPos = true;
         this.isBindRotation = true;
         this.isBindGetRotation = true;
         this.isBindUpdate = true;
         this.isBindScale = false;
         this.isBindSize = true;
     }
     else
     {
         type = 0;
         Bind.BindObject obj0 = BindClass(this.obj = o);
         this.methods = obj0.methods;
         this.isBindPos = obj0.bindPos;
         this.isBindGetPos = obj0.bindGetPos;
         this.isBindRotation = obj0.bindRotation;
         this.isBindGetRotation = obj0.bindGetRotation;
         this.isBindUpdate = obj0.bindUpdate;
         this.isBindScale = obj0.bindScale;
         this.isBindSize = obj0.bindSize;
     }
 }
Example #33
0
 public override void Add(LComponent c)
 {
     if (desktop == null)
     {
         InitDesktop();
     }
     desktop.Add(c);
 }
Example #34
0
            public void UpClick(LComponent comp, float x, float y)
            {

            }
Example #35
0
		internal bool SelectComponent(LComponent comp) {
			if (!comp.IsVisible() || !comp.IsEnabled() || !comp.IsFocusable()) {
				return false;
			}
	
			this.DeselectComponent();
	
			comp.SetSelected(true);
			this.selectedComponent = comp;
	
			return true;
		}
Example #36
0
 public abstract void CreateUI(GLEx g, int x, int y, LComponent component,
         LTexture[] buttonImage);
Example #37
0
            public void DoClick(LComponent comp)
            {
                if (comp.Tag is Screen)
                {
                    LLKScreen screen = (LLKScreen)comp.Tag;
                    LSelect select = (LSelect)comp;

                    switch (select.GetResultIndex())
                    {
                        case 0:
                            screen.mes.SetVisible(true);
                            if (screen.refreshcount > 0)
                            {
                                screen.mes.SetMessage(EASY_MES);
                                screen.Refreshs();
                            }
                            else
                            {
                                screen.mes.SetMessage(SORRY1_MES);
                            }
                            screen.Remove(select);
                            break;
                        case 1:
                            screen.mes.SetVisible(true);
                            if (screen.tipcount > 0)
                            {
                                screen.mes.SetMessage(EASY_MES);
                                screen.ShowNext();
                            }
                            else
                            {
                                screen.mes.SetMessage(SORRY2_MES);
                            }
                            screen.Remove(select);
                            break;
                        case 2:
                            screen.mes.SetVisible(true);
                            if (screen.bombcount > 0)
                            {
                                screen.mes.SetMessage(EASY_MES);
                                screen.UseBomb();
                            }
                            else
                            {
                                screen.mes.SetMessage(SORRY3_MES);
                            }
                            screen.Remove(select);
                            break;
                        case 3:
                            screen.mes.SetVisible(true);
                            screen.Remove(select);
                            screen.mes.SetVisible(false);
                            screen.role.SetVisible(false);
                            screen.helpRole.SetVisible(true);
                            if (screen.stage != null)
                            {
                                screen.stage.SetVisible(true);
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
Example #38
0
            public void DoClick(LComponent comp)
            {
                if (comp.Tag is LLKScreen)
                {
                    LMessage message = (LMessage)comp;
                    LLKScreen screen = (LLKScreen)comp.Tag;
                    if (!screen.init)
                    {
                        if (screen.count == 0)
                        {
                            screen.role.SetImage(screen.GetImage(12));
                            message.SetMessage(START_MES);
                        }
                        else if (message.IsComplete())
                        {

                            screen.CallEvent(new _Runnable(screen, message));

                        }
                        screen.count++;
                    }

                    if (HELP_MES.Equals(message.GetMessage(), StringComparison.InvariantCultureIgnoreCase) && message.IsComplete())
                    {
                        message.SetVisible(false);
                        screen.select = new LSelect(screen.GetImage(14), (screen
                                .GetWidth() - 460) / 2,
                                screen.GetHeight() - 126 - 10);
                        screen.select.Tag = screen;
                        screen.select.SetFontColor(LColor.black);
                        screen.select.SetAlpha(0.8f);
                        screen.select.SetTopOffset(-5);
                        screen.select.SetMessage(new String[] { "1.刷新", "2.提示", "3.炸弹",
							"4.取消" });
                        screen.select.Click = new SelectClick();
                        screen.Add(screen.select);
                        return;

                    }
                    else if ((EASY_MES.Equals(message.GetMessage(), StringComparison.InvariantCultureIgnoreCase) || message.GetMessage()
                          .StartsWith(SORRY))
                          && message.IsComplete())
                    {

                        screen.mes.SetVisible(false);
                        screen.role.SetVisible(false);
                        screen.helpRole.SetVisible(true);
                        if (screen.stage != null)
                        {
                            screen.stage.SetVisible(true);
                        }
                    }
                }
        
            }
Example #39
0
 void ClickListener.DoClick(LComponent comp)
 {
     LLKScreen s = (LLKScreen)StaticCurrentSceen;
     if (comp.GetAlpha() >= 1.0 && s.overFlag)
     {
         s.over = null;
         s.RemoveAll();
         s.Stage(s.stageNo);
         s.GetSprites().SetVisible(true);
     }
 }
Example #40
0
 public override void CreateUI(GLEx g, int x, int y, LComponent component,
         LTexture[] buttonImage)
 {
     if (this.visible)
     {
         g.SetAlpha(0.5f);
         g.DrawTexture(controlBase, x, y, baseWidth, baseHeight);
         g.DrawTexture(controlDot, x + centerX, y + centerY, dotWidth, dotHeight);
         g.SetAlpha(1f);
     }
 }
Example #41
0
 void ClickListener.DragClick(LComponent comp, float x, float y)
 {
     
 }
Example #42
0
		internal void SetDesktop(LComponent comp) {
			if (comp.IsContainer()) {
				LComponent[] child = ((LContainer) comp).GetComponents();
				for (int i = 0; i < child.Length; i++) {
					this.SetDesktop(child[i]);
				}
			}
			comp.SetDesktop(this);
		}
Example #43
0
        public void Replace(LComponent oldComp, LComponent newComp)
        {
            int index = this.Remove(oldComp);

            this.Add(newComp, index);
        }
Example #44
0
 public void DownClick(LComponent comp, float x, float y)
 {
     if (comp.Tag is AVGScreen)
     {
         AVGScreen screen = (AVGScreen)comp.Tag;
         // �������
         screen.SetLocked(false);
         // �����¼�
         // click();
         // ɾ����ǰ��ť
         screen.Remove(comp);
     }
 }
Example #45
0
 public bool Intersects(LComponent comp)
 {
     return (this.visible)
         && (comp.IsVisible())
         && (this.screenX + this.width * scaleX >= comp.screenX
                 && this.screenX <= comp.screenX + comp.width
                 && this.screenY + this.height * scaleY >= comp.screenY && this.screenY <= comp.screenY
                 + comp.height);
 }
Example #46
0
 public void DoClick(LComponent comp)
 {
 }
Example #47
0
 public void DownClick(LComponent comp, float x, float y)
 {
  
 }
Example #48
0
 public abstract void CreateUI(GLEx g, int x, int y, LComponent component,
                               LTexture[] buttonImage);
Example #49
0
            public void DragClick(LComponent comp, float x, float y)
            {

            }
Example #50
0
		public void SetModal(LComponent comp) {
			if (comp != null && !comp.IsVisible()) {
				throw new Exception(
						"Can't set invisible component as modal component!");
			}
			this.modal = comp;
		}
Example #51
0
 public override void Remove(LComponent comp)
 {
     desktop.Remove(comp);
 }
Example #52
0
		internal void ClearComponentsStat(LComponent[] comp) {
			if (this == Desktop.EMPTY_DESKTOP) {
				return;
			}
	
			bool checkTouchMotion = false;
			for (int i = 0; i < comp.Length; i++) {
				if (this.hoverComponent == comp[i]) {
					checkTouchMotion = true;
				}
	
				if (this.selectedComponent == comp[i]) {
					this.DeselectComponent();
				}
	
				this.clickComponent[0] = null;
	
			}
	
			if (checkTouchMotion) {
				this.ProcessTouchMotionEvent();
			}
		}
Example #53
0
 public virtual void Add(LComponent comp)
 {
     if (desktop != null)
     {
         desktop.Add(comp);
     }
 }
Example #54
0
 public virtual void Remove(LComponent comp)
 {
     if (desktop != null)
     {
         desktop.Remove(comp);
     }
 }
Example #55
0
 public virtual bool OnClick(LComponent component)
 {
     if (component == null)
     {
         return false;
     }
     if (component.IsVisible())
     {
         RectBox rect = component.GetCollisionBox();
         if (rect.Contains(touchX, touchY) || rect.Intersects(touchX, touchY))
         {
             return true;
         }
     }
     return false;
 }
Example #56
0
		private void ProcessTouchMotionEvent() {
	
			if (this.hoverComponent != null && this.hoverComponent.IsEnabled()
					&& this.input.IsMoving()) {
				if (this.input.GetTouchDY() != 0 || this.input.GetTouchDY() != 0) {
					this.hoverComponent.ProcessTouchDragged();
				}
			} else {		
                LComponent comp = this.FindComponent(this.input.GetTouchX(),
						this.input.GetTouchY());
				if (comp != null) {
					if (this.input.GetTouchDX() != 0
							|| this.input.GetTouchDY() != 0) {
						comp.ProcessTouchMoved();
					}
	
					if (this.hoverComponent == null) {
						comp.ProcessTouchEntered();
	
					} else if (comp != this.hoverComponent) {
						this.hoverComponent.ProcessTouchExited();
						comp.ProcessTouchEntered();
					}
	
				} else {
					if (this.hoverComponent != null) {
						this.hoverComponent.ProcessTouchExited();
					}
				}
				this.hoverComponent = comp;
			}
		}