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; }
public int Remove(LComponent comp) { int removed = this.RemoveComponent(this.contentPane, comp); if (removed != -1) { this.ProcessTouchMotionEvent(); } return removed; }
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); }
internal void DeselectComponent() { if (this.selectedComponent == null) { return; } this.selectedComponent.SetSelected(false); this.selectedComponent = null; }
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)); }
public void SetModal(LComponent comp) { if (comp != null && !comp.IsVisible()) { throw new Exception( "Can't set invisible component as modal component!"); } this.modal = comp; }
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(); }
public int Remove(LComponent comp) { int removed = this.RemoveComponent(this.contentPane, comp); if (removed != -1) { this.ProcessTouchMotionEvent(); } return(removed); }
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); }
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); }
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); }
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); }
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); } } }
internal bool SelectComponent(LComponent comp) { if (!comp.IsVisible() || !comp.IsEnabled() || !comp.IsFocusable()) { return(false); } this.DeselectComponent(); comp.SetSelected(true); this.selectedComponent = comp; return(true); }
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); } }
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; }
/// <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; } } }
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); }
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); }
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; }
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; }
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); }
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); }
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); } } }
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); }
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); }
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; } } }
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; } } }
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); } } }
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; } }
public override void Add(LComponent c) { if (desktop == null) { InitDesktop(); } desktop.Add(c); }
public void UpClick(LComponent comp, float x, float y) { }
internal bool SelectComponent(LComponent comp) { if (!comp.IsVisible() || !comp.IsEnabled() || !comp.IsFocusable()) { return false; } this.DeselectComponent(); comp.SetSelected(true); this.selectedComponent = comp; return true; }
public abstract void CreateUI(GLEx g, int x, int y, LComponent component, LTexture[] buttonImage);
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; } } }
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); } } } }
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); } }
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); } }
void ClickListener.DragClick(LComponent comp, float x, float y) { }
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); }
public void Replace(LComponent oldComp, LComponent newComp) { int index = this.Remove(oldComp); this.Add(newComp, index); }
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); } }
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); }
public void DoClick(LComponent comp) { }
public void DownClick(LComponent comp, float x, float y) { }
public void DragClick(LComponent comp, float x, float y) { }
public override void Remove(LComponent comp) { desktop.Remove(comp); }
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(); } }
public virtual void Add(LComponent comp) { if (desktop != null) { desktop.Add(comp); } }
public virtual void Remove(LComponent comp) { if (desktop != null) { desktop.Remove(comp); } }
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; }
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; } }