public YAMLNode ExportYAML(IExportContainer container) { YAMLMappingNode node = new YAMLMappingNode(); node.Add(NameName, Name); node.Add(NormalName, Normal.ExportYAML(container)); node.Add(HoverName, Hover.ExportYAML(container)); node.Add(ActiveName, Active.ExportYAML(container)); node.Add(FocusedName, Focused.ExportYAML(container)); node.Add(OnNormalName, OnNormal.ExportYAML(container)); node.Add(OnHoverName, OnHover.ExportYAML(container)); node.Add(OnActiveName, OnActive.ExportYAML(container)); node.Add(OnFocusedName, OnFocused.ExportYAML(container)); node.Add(BorderName, Border.ExportYAML(container)); node.Add(MarginName, Margin.ExportYAML(container)); node.Add(PaddingName, Padding.ExportYAML(container)); node.Add(OverflowName, Overflow.ExportYAML(container)); node.Add(FontName, Font.ExportYAML(container)); node.Add(FontSizeName, FontSize); node.Add(FontStyleName, (int)FontStyle); node.Add(AlignmentName, (int)Alignment); node.Add(WordWrapName, WordWrap); node.Add(RichTextName, RichText); node.Add(TextClippingName, (int)TextClipping); node.Add(ImagePositionName, (int)ImagePosition); node.Add(ContentOffsetName, ContentOffset.ExportYAML(container)); node.Add(FixedWidthName, FixedWidth); node.Add(FixedHeightName, FixedHeight); node.Add(StretchWidthName, StretchWidth); node.Add(StretchHeightName, StretchHeight); return(node); }
public override void Hover() { if (OnHover != null) { OnHover.Invoke(); } }
public override void onUpdate() { //only handle the update if the button is enabled and the parent screen is visible if (screenVisible && render) { //hovering logic if (isMouseHovering() && selectable && enabled) { Parent.FocusedComponent = this; if (isHovered == false) { isHovered = true; if (OnHover != null) { OnHover.Invoke(this, null); } } if (InputManager.IsPressed("gui.click")) { if (isClicked == false) { isClicked = true; } } if (InputManager.Released("gui.click")) { if (isClicked && Parent.FocusedComponent != null && Parent.FocusedComponent == this) { isClicked = false; if (OnClicked != null) { OnClicked.Invoke(this, null); } } } } //unhover logic else { if (isHovered) { isHovered = false; } if (!InputManager.IsPressed("gui.click")) { if (isClicked == true) { isClicked = false; if (OnReleased != null) { OnReleased.Invoke(this, null); } } } } } }
public YAMLNode ExportYAML(IExportContainer container) { YAMLMappingNode node = new YAMLMappingNode(); node.Add("m_Name", Name); node.Add("m_Normal", Normal.ExportYAML(container)); node.Add("m_Hover", Hover.ExportYAML(container)); node.Add("m_Active", Active.ExportYAML(container)); node.Add("m_Focused", Focused.ExportYAML(container)); node.Add("m_OnNormal", OnNormal.ExportYAML(container)); node.Add("m_OnHover", OnHover.ExportYAML(container)); node.Add("m_OnActive", OnActive.ExportYAML(container)); node.Add("m_OnFocused", OnFocused.ExportYAML(container)); node.Add("m_Border", Border.ExportYAML(container)); node.Add("m_Margin", Margin.ExportYAML(container)); node.Add("m_Padding", Padding.ExportYAML(container)); node.Add("m_Overflow", Overflow.ExportYAML(container)); node.Add("m_Font", Font.ExportYAML(container)); node.Add("m_FontSize", FontSize); node.Add("m_FontStyle", (int)FontStyle); node.Add("m_Alignment", (int)Alignment); node.Add("m_WordWrap", WordWrap); node.Add("m_RichText", RichText); node.Add("m_TextClipping", (int)TextClipping); node.Add("m_ImagePosition", (int)ImagePosition); node.Add("m_ContentOffset", ContentOffset.ExportYAML(container)); node.Add("m_FixedWidth", FixedWidth); node.Add("m_FixedHeight", FixedHeight); node.Add("m_StretchWidth", StretchWidth); node.Add("m_StretchHeight", StretchHeight); return(node); }
private void OnMouseEnter() { if (!MainCanvas.mainCanvas.isUIOverride && beingMoved == false) { OnHover?.Invoke(true, propName, this.transform); } }
public void Read(AssetStream stream) { StyleName = stream.ReadStringAligned(); Normal.Read(stream); Hover.Read(stream); Active.Read(stream); Focused.Read(stream); OnNormal.Read(stream); OnHover.Read(stream); OnActive.Read(stream); OnFocused.Read(stream); Border.Read(stream); Margin.Read(stream); Padding.Read(stream); Overflow.Read(stream); Font.Read(stream); FontSize = stream.ReadInt32(); FontStyle = stream.ReadInt32(); Alignment = stream.ReadInt32(); WordWrap = stream.ReadBoolean(); RichText = stream.ReadBoolean(); stream.AlignStream(AlignType.Align4); TextClipping = stream.ReadInt32(); ImagePosition = stream.ReadInt32(); ContentOffset.Read(stream); FixedWidth = stream.ReadSingle(); FixedHeight = stream.ReadSingle(); StretchWidth = stream.ReadBoolean(); StretchHeight = stream.ReadBoolean(); stream.AlignStream(AlignType.Align4); }
protected override void DrawSelf(SpriteBatch spriteBatch) { base.DrawSelf(spriteBatch); if (IsMouseHovering) { OnHover?.Invoke(spriteBatch); } }
internal void TriggerOnHover(bool value) { if (value == Hovering) { return; } Hovering = value; OnHover?.Invoke(Hovering); }
public override void Update(GameTime time) { if (Entity.AABB.Contains(InputManager.Instance.MousePosition)) { _renderer.Color = OnHover?.Invoke() ?? _hoverColor; } else { _renderer.Color = RegularColorFunc?.Invoke() ?? _origColor; } }
void Start() { _gameManager = FindObjectOfType <GameManager>(); _audioManager = AudioManager.instance; OnHoverTool = this.GetComponent <OnHover>(); _theGSB = FindObjectOfType <GlobalStatsBar>(); _myTargetLocation = this.transform.parent.GetComponentInParent <TargetLocation>(); _myBoxCollider = this.GetComponent <BoxCollider2D>(); _mySpriteRenderer = this.GetComponent <SpriteRenderer> (); BorderRenderer.color = _mySpriteRenderer.color; _ttManager = FindObjectOfType <TutorialToolTipManager>(); }
public override void Update(GameTime time) { IsHover = _input.IsOver(X, Y, Width, Height); if (_input.HasEnterArea(X, Y, Width, Height)) { OnHover?.Invoke( ); } if (IsHover && _input.IsLMBPressedOnce( )) { OnClick?.Invoke( ); } }
/// <summary> /// Switches the current state to the given ClickableState, and calls OnDown/OnHover as needed /// </summary> protected virtual void SwitchState(ClickableState newState) { State = newState; switch (State) { case ClickableState.None: break; case ClickableState.Hover: OnHover?.Invoke(this); break; case ClickableState.Active: OnDown?.Invoke(this); break; } }
public virtual void OnInteract() { bool checkedCanvas = true; if (needsACanvasCheck) { if (MainCanvas.mainCanvas.isUIOverride) { checkedCanvas = false; } } if (checkedCanvas) { for (int i = 0; i < clickEvents.Length; i++) { clickEvents[i].Invoke(); } OnHover?.Invoke(false); } }
public override void Update(Window sender, Event e) { if (Velocity != null) { Position = Position + Velocity; _destinationRectangle.x = (int)Position.X; _destinationRectangle.y = (int)Position.Y; } if (Acceleration != null) { Velocity = Velocity + Acceleration; } if (e == Event.MOUSEBUTTONDOWN && MouseOnMe(sender)) { OnClicked?.Invoke(this); } if (MouseOnMe(sender)) { OnHover?.Invoke(this); } }
public override void Update(GameTime gameTime) { var mouseState = Mouse.GetState(); var wasHovered = Hovered; Hovered = Rectangle.Contains(new Vector2(mouseState.X / ScaleMatrix.Right.X, mouseState.Y / ScaleMatrix.Up.Y)); if (!wasHovered && Hovered) { OnHoverBegins?.Invoke(this, EventArgs.Empty); } else if (wasHovered && !Hovered) { OnHoverEnds?.Invoke(this, EventArgs.Empty); } else if (Hovered) { OnHover?.Invoke(this, EventArgs.Empty); Cursor.IsActive = true; } base.Update(gameTime); }
public void Update() { var mouseState = Mouse.GetState(); var mousePoint = new Point(mouseState.X, mouseState.Y); var rect = new Rectangle((int)Coords.X, (int)Coords.Y, (int)Size.X, (int)Size.Y); if (rect.Contains(mousePoint)) { IsHovered = true; OnHover?.Invoke(this); if (IsClicked && mouseState.LeftButton == ButtonState.Released && OnMouseUp != null) { OnMouseUp(this); } IsClicked = mouseState.LeftButton == ButtonState.Pressed; } else { IsHovered = false; IsClicked = false; } }
public void Update(float deltaTime) { // Residual clicking handling. if (isMouseDown && Parent.Manager.IsClickReleased) { _handle_up(Parent.Manager); } // Hover management. var IsHovered = Parent.Manager.GetHover() == Parent; if (IsHovered == false && WasHoveredLastFrame == true) { OnUnhover?.Invoke(Parent); } else if (IsHovered == true && WasHoveredLastFrame == false) { OnHover?.Invoke(Parent); } WasHoveredLastFrame = IsHovered; if (double_click_timer > 0f) { double_click_timer -= deltaTime; if (double_click_timer <= 0f) { OnClick?.Invoke(Parent); OnEndClicking?.Invoke(Parent); has_clicked = false; } } // Clicking related input. if (Parent.Manager.GetHover() == Parent) { _update(Parent.Manager, deltaTime); } }
private void OnMouseMove(double x, double y, double deltaX, double deltaY) { vec2 mPos = new vec2((float)x, (float)y).ToUISpace(); if (Transform.Orientation % Math.PI > float.Epsilon) { mPos = Transform.Translation + (quat.FromAxisAngle(-Transform.Orientation, vec3.UnitZ) * new vec3(mPos - Transform.Translation, 0)).xy; } var size = Transform.Scale * Quad.Size; var min = Transform.Translation - (size / 2); var max = Transform.Translation + (size / 2); bool hovered = mPos.x >= min.x - 1 && mPos.x <= max.x + 1 && mPos.y >= min.y - 1 && mPos.y <= max.y + 1; if (!Hovered && hovered) { OnHover?.Invoke(this, null); } Hovered = hovered; }
public override void Update(double deltaTime) { base.Update(deltaTime); if (Input.onHover(ActRectangle)) { OnHover?.Invoke(this, new UiEventArgs(Input.getPosition())); } if (Input.onLeave(ActRectangle)) { OnLeave?.Invoke(this, new UiEventArgs(Input.getPosition())); } if (Input.OnMouseDown(Input.LeftButton) && Input.IsHover(ActRectangle)) { OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.LeftButton)); } if (Input.OnMouseDown(Input.MiddleButton) && Input.IsHover(ActRectangle)) { OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.MiddleButton)); } if (Input.OnMouseDown(Input.RightButton) && Input.IsHover(ActRectangle)) { OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.RightButton)); } if (Input.OnMouseUp(Input.LeftButton) && Input.IsHover(ActRectangle)) { OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.LeftButton)); } if (Input.OnMouseUp(Input.MiddleButton) && Input.IsHover(ActRectangle)) { OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.MiddleButton)); } if (Input.OnMouseUp(Input.RightButton) && Input.IsHover(ActRectangle)) { OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.RightButton)); } }
public void Read(AssetReader reader) { StyleName = reader.ReadString(); Normal.Read(reader); Hover.Read(reader); Active.Read(reader); Focused.Read(reader); OnNormal.Read(reader); OnHover.Read(reader); OnActive.Read(reader); OnFocused.Read(reader); Border.Read(reader); if (IsBuiltIn(reader.Version)) { Margin.Read(reader); Padding.Read(reader); } else { Padding.Read(reader); Margin.Read(reader); } Overflow.Read(reader); Font.Read(reader); if (IsBuiltIn(reader.Version)) { FontSize = reader.ReadInt32(); FontStyle = (FontStyle)reader.ReadInt32(); Alignment = (TextAnchor)reader.ReadInt32(); WordWrap = reader.ReadBoolean(); RichText = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); TextClipping = (TextClipping)reader.ReadInt32(); ImagePosition = (ImagePosition)reader.ReadInt32(); ContentOffset.Read(reader); FixedWidth = reader.ReadSingle(); FixedHeight = reader.ReadSingle(); StretchWidth = reader.ReadBoolean(); StretchHeight = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); } else { ImagePosition = (ImagePosition)reader.ReadInt32(); Alignment = (TextAnchor)reader.ReadInt32(); WordWrap = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); TextClipping = (TextClipping)reader.ReadInt32(); ContentOffset.Read(reader); ClipOffset.Read(reader); FixedWidth = reader.ReadSingle(); FixedHeight = reader.ReadSingle(); if (IsReadFontSize(reader.Version)) { FontSize = reader.ReadInt32(); FontStyle = (FontStyle)reader.ReadInt32(); } StretchWidth = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); StretchHeight = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); } }
public void OnMouseOver() { OnHover?.Invoke(this, new EventArgs()); }
public void Hover() { OnHover.Invoke(); }
// Calling these methods invokes the corresponding event public void Hover(RaycastHit hit) { OnHover.Invoke(hit); }
//Not sure if this is really needed? public virtual void Hovering() { Transparency = 0.5f; OnHover?.Invoke(this, new EventArgs()); }
public void TriggerOnHover(Widget widget, bool isHovering, PointerEventData eventData) { OnHover?.Invoke(widget, isHovering, eventData); }
private void OnMouseExit() { OnHover?.Invoke(false); }
public void OnPointerEnter(PointerEventData eventData) { OnHover?.Invoke(this); }
public void Write(AssetWriter writer) { writer.Write(Name); Normal.Write(writer); Hover.Write(writer); Active.Write(writer); Focused.Write(writer); OnNormal.Write(writer); OnHover.Write(writer); OnActive.Write(writer); OnFocused.Write(writer); Border.Write(writer); if (IsBuiltin(writer.Version)) { Margin.Write(writer); Padding.Write(writer); } else { Padding.Write(writer); Margin.Write(writer); } Overflow.Write(writer); Font.Write(writer); if (IsBuiltin(writer.Version)) { writer.Write(FontSize); writer.Write((int)FontStyle); writer.Write((int)Alignment); writer.Write(WordWrap); writer.Write(RichText); writer.AlignStream(); writer.Write((int)TextClipping); writer.Write((int)ImagePosition); ContentOffset.Write(writer); writer.Write(FixedWidth); writer.Write(FixedHeight); writer.Write(StretchWidth); writer.Write(StretchHeight); writer.AlignStream(); } else { writer.Write((int)ImagePosition); writer.Write((int)Alignment); writer.Write(WordWrap); writer.AlignStream(); writer.Write((int)TextClipping); ContentOffset.Write(writer); ClipOffset.Write(writer); writer.Write(FixedWidth); writer.Write(FixedHeight); if (HasFontSize(writer.Version)) { writer.Write(FontSize); writer.Write((int)FontStyle); } writer.Write(StretchWidth); writer.AlignStream(); writer.Write(StretchHeight); writer.AlignStream(); } }
void Start() { this.gameObject.SetActive(false); onhover = FindObjectOfType <OnHover>(); }
public virtual void Hovering() { OnHover?.Invoke(this, new EventArgs()); }