protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle dimensions = this.GetDimensions(); Texture2D texture; Point point; if (this._isOn) { texture = this._onTexture.Value; point = this._onTextureOffset; } else { texture = this._offTexture.Value; point = this._offTextureOffset; } Color color = this.IsMouseHovering ? Color.White : Color.Silver; spriteBatch.Draw(texture, new Rectangle((int)dimensions.X, (int)dimensions.Y, this._drawWidth, this._drawHeight), new Rectangle?(new Rectangle(point.X, point.Y, this._drawWidth, this._drawHeight)), color); }
protected override void DrawSelf(SpriteBatch spriteBatch) { base.DrawSelf(spriteBatch); if (HasModIcon && !modIconWanted) { modIconWanted = true; } CalculatedStyle innerDimensions = GetInnerDimensions(); //draw divider Vector2 drawPos = new Vector2(innerDimensions.X + 5f + ModIconAdjust, innerDimensions.Y + 30f); spriteBatch.Draw(this.dividerTexture, drawPos, null, Color.White, 0f, Vector2.Zero, new Vector2((innerDimensions.Width - 10f - ModIconAdjust) / 8f, 1f), SpriteEffects.None, 0f); // change pos for button const int baseWidth = 125; // something like 1 days ago is ~110px, XX minutes ago is ~120 px (longest) drawPos = new Vector2(innerDimensions.X + innerDimensions.Width - baseWidth, innerDimensions.Y + 45); DrawPanel(spriteBatch, drawPos, baseWidth); DrawTimeText(spriteBatch, drawPos + new Vector2(0f, 2f), baseWidth); // x offset (padding) to do in method }
private void DrawPanel(SpriteBatch spriteBatch, Texture2D texture, Color color) { CalculatedStyle dimensions = GetDimensions(); Point dimen = new Point((int)dimensions.X, (int)dimensions.Y); Point center = new Point(dimen.X + (int)dimensions.Width - cornerSize, dimen.Y + (int)dimensions.Height - cornerSize); int width = center.X - dimen.X - cornerSize; int height = center.Y - dimen.Y - cornerSize; spriteBatch.Draw(texture, new Rectangle(dimen.X, dimen.Y, cornerSize, cornerSize), new Rectangle?(new Rectangle(0, 0, cornerSize, cornerSize)), color); spriteBatch.Draw(texture, new Rectangle(center.X, dimen.Y, cornerSize, cornerSize), new Rectangle?(new Rectangle(cornerSize + barSize, 0, cornerSize, cornerSize)), color); spriteBatch.Draw(texture, new Rectangle(dimen.X, center.Y, cornerSize, cornerSize), new Rectangle?(new Rectangle(0, cornerSize + barSize, cornerSize, cornerSize)), color); spriteBatch.Draw(texture, new Rectangle(center.X, center.Y, cornerSize, cornerSize), new Rectangle?(new Rectangle(cornerSize + barSize, cornerSize + barSize, cornerSize, cornerSize)), color); spriteBatch.Draw(texture, new Rectangle(dimen.X + cornerSize, dimen.Y, width, cornerSize), new Rectangle?(new Rectangle(cornerSize, 0, barSize, cornerSize)), color); spriteBatch.Draw(texture, new Rectangle(dimen.X + cornerSize, center.Y, width, cornerSize), new Rectangle?(new Rectangle(cornerSize, cornerSize + barSize, barSize, cornerSize)), color); spriteBatch.Draw(texture, new Rectangle(dimen.X, dimen.Y + cornerSize, cornerSize, height), new Rectangle?(new Rectangle(0, cornerSize, cornerSize, barSize)), color); spriteBatch.Draw(texture, new Rectangle(center.X, dimen.Y + cornerSize, cornerSize, height), new Rectangle?(new Rectangle(cornerSize + barSize, cornerSize, cornerSize, barSize)), color); spriteBatch.Draw(texture, new Rectangle(dimen.X + cornerSize, dimen.Y + cornerSize, width, height), new Rectangle?(new Rectangle(cornerSize, cornerSize, barSize, barSize)), color); }
private void DragStart(UIMouseEvent evt) { CalculatedStyle innerDimensions = GetInnerDimensions(); if (evt.Target == this || additionalDragTargets.Contains(evt.Target)) { if (resizeable && new Rectangle((int)(innerDimensions.X + innerDimensions.Width - 18), (int)(innerDimensions.Y + innerDimensions.Height - 18), 18, 18).Contains(evt.MousePosition.ToPoint())) //if (resizeable && new Rectangle((int)(innerDimensions.X + innerDimensions.Width - 12), (int)(innerDimensions.Y + innerDimensions.Height - 12), 12 + 6, 12 + 6).Contains(evt.MousePosition.ToPoint())) { offset = new Vector2(evt.MousePosition.X - innerDimensions.X - innerDimensions.Width, evt.MousePosition.Y - innerDimensions.Y - innerDimensions.Height); //offset = new Vector2(evt.MousePosition.X - innerDimensions.X - innerDimensions.Width - 6, evt.MousePosition.Y - innerDimensions.Y - innerDimensions.Height - 6); resizeing = true; } else if (dragable) { offset = new Vector2(evt.MousePosition.X - Left.Pixels, evt.MousePosition.Y - Top.Pixels); dragging = true; } } }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle dimensions = GetDimensions(); spriteBatch.Draw(bar, dimensions.Position(), new Rectangle(0, 0, 5, 16), color); spriteBatch.Draw(bar, dimensions.Position() + new Vector2(5, 0), new Rectangle(6, 0, 1, 16), color, 0f, Vector2.Zero, new Vector2(dimensions.Width - 9, 1), SpriteEffects.None, 0f); spriteBatch.Draw(bar, dimensions.Position() + new Vector2(dimensions.Width - 4, 0), new Rectangle(bar.Width - 4, 0, 4, 16), color); if (dragging) { CurrentValue = (int)Utility.Utility.Clamp((Main.mouseX - dimensions.X) * (maxValue / (dimensions.Width - 8f)), 0, maxValue); } spriteBatch.Draw(slider, dimensions.Position() + new Vector2(SliderPos - slider.Width / 2f, dimensions.Height / 2f - slider.Height / 2f), Color.White); if (IsMouseHovering) { Utility.Utility.DrawMouseText(HoverText?.Invoke(CurrentValue) ?? CurrentValue.ToString()); } }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle innerDimensions = base.GetInnerDimensions(); Vector2 drawPosition = new Vector2(innerDimensions.X + 10, innerDimensions.Y + 10); Texture2D slotTexture = disabled ? Main.inventoryBack5Texture : Main.inventoryBack9Texture; Color slotColor = new Color(73, 94, 171); // Draw in the item slot spriteBatch.Draw(slotTexture, drawPosition, null, new Color(), 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); // Draw in texture of item if (CurrentItem != null) { Texture2D itemTexture = Main.itemTexture[CurrentItem.type]; Rectangle innerRectangle = innerDimensions.ToRectangle(); Main.NewText("Slotted item! : " + CurrentItem.Name); //spriteBatch.Draw(itemTexture, drawPosition, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } }
protected override void DrawSelf(SpriteBatch spriteBatch) { base.DrawSelf(spriteBatch); CalculatedStyle innerDimensions = base.GetInnerDimensions(); Vector2 drawPos = new Vector2(innerDimensions.X + 5f, innerDimensions.Y + 30f); spriteBatch.Draw(this.dividerTexture, drawPos, null, Color.White, 0f, Vector2.Zero, new Vector2((innerDimensions.Width - 10f) / 8f, 1f), SpriteEffects.None, 0f); drawPos = new Vector2(innerDimensions.X + 10f, innerDimensions.Y + 45f); this.DrawPanel(spriteBatch, drawPos, 100f); this.DrawEnabledText(spriteBatch, drawPos + new Vector2(15f, 5f)); if (this.enabled != ModLoader.ModLoaded(mod)) { drawPos += new Vector2(120f, 5f); Utils.DrawBorderString(spriteBatch, "Reload Required", drawPos, Color.White, 1f, 0f, 0f, -1); } string text = this.enabled ? "Click to Disable" : "Click to Enable"; drawPos = new Vector2(innerDimensions.X + innerDimensions.Width - 150f, innerDimensions.Y + 50f); Utils.DrawBorderString(spriteBatch, text, drawPos, Color.White, 1f, 0f, 0f, -1); }
public override void MouseDown(UIMouseEvent evt) { base.MouseDown(evt); if (evt.Target != this) { return; } Rectangle handleRectangle = this.GetHandleRectangle(); if (handleRectangle.Contains(new Point((int)evt.MousePosition.X, (int)evt.MousePosition.Y))) { this._isDragging = true; this._dragYOffset = evt.MousePosition.Y - (float)handleRectangle.Y; } else { CalculatedStyle innerDimensions = this.GetInnerDimensions(); this._viewPosition = MathHelper.Clamp((UserInterface.ActiveInstance.MousePosition.Y - innerDimensions.Y - (float)(handleRectangle.Height >> 1)) / innerDimensions.Height * this._maxViewSize, 0.0f, this._maxViewSize - this._viewSize); } }
protected override void DrawSelf(SpriteBatch spriteBatch) { this._visualOverallProgress = this._targetOverallProgress; this._visualCurrentProgress = this._targetCurrentProgress; CalculatedStyle dimensions = this.GetDimensions(); int completedWidth1 = (int)((double)this._visualOverallProgress * 504.0); int completedWidth2 = (int)((double)this._visualCurrentProgress * 504.0); Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y); Color filled = new Color(); filled.PackedValue = WorldGen.crimson ? 4286836223U : 4283888223U; this.DrawFilling2(spriteBatch, vector2 + new Vector2(20f, 40f), 16, completedWidth1, 564, filled, Color.Lerp(filled, Color.Black, 0.5f), new Color(48, 48, 48)); filled.PackedValue = 4290947159U; this.DrawFilling2(spriteBatch, vector2 + new Vector2(50f, 60f), 8, completedWidth2, 504, filled, Color.Lerp(filled, Color.Black, 0.5f), new Color(33, 33, 33)); Rectangle rectangle = this.GetDimensions().ToRectangle(); rectangle.X -= 8; spriteBatch.Draw(WorldGen.crimson ? this._texOuterCrimson : this._texOuterCorrupt, rectangle.TopLeft(), Color.White); spriteBatch.Draw(this._texOuterLower, rectangle.TopLeft() + new Vector2(44f, 60f), Color.White); }
private void DrawPanel(SpriteBatch spriteBatch, Texture2D texture, Color color) { CalculatedStyle dimensions = GetDimensions(); Point point = new Point((int)dimensions.X, (int)dimensions.Y); Point point2 = new Point(point.X + (int)dimensions.Width - CornerSize, point.Y + (int)dimensions.Height - CornerSize); int width = point2.X - point.X - CornerSize; int height = point2.Y - point.Y - CornerSize; spriteBatch.Draw(texture, new Rectangle(point.X, point.Y, CornerSize, CornerSize), new Rectangle(0, 0, CornerSize, CornerSize), color); spriteBatch.Draw(texture, new Rectangle(point2.X, point.Y, CornerSize, CornerSize), new Rectangle(CornerSize + BarSize, 0, CornerSize, CornerSize), color); spriteBatch.Draw(texture, new Rectangle(point.X, point2.Y, CornerSize, CornerSize), new Rectangle(0, CornerSize + BarSize, CornerSize, CornerSize), color); spriteBatch.Draw(texture, new Rectangle(point2.X, point2.Y, CornerSize, CornerSize), new Rectangle(CornerSize + BarSize, CornerSize + BarSize, CornerSize, CornerSize), color); spriteBatch.Draw(texture, new Rectangle(point.X + CornerSize, point.Y, width, CornerSize), new Rectangle(CornerSize, 0, BarSize, CornerSize), color); spriteBatch.Draw(texture, new Rectangle(point.X + CornerSize, point2.Y, width, CornerSize), new Rectangle(CornerSize, CornerSize + BarSize, BarSize, CornerSize), color); spriteBatch.Draw(texture, new Rectangle(point.X, point.Y + CornerSize, CornerSize, height), new Rectangle(0, CornerSize, CornerSize, BarSize), color); spriteBatch.Draw(texture, new Rectangle(point2.X, point.Y + CornerSize, CornerSize, height), new Rectangle(CornerSize + BarSize, CornerSize, CornerSize, BarSize), color); spriteBatch.Draw(texture, new Rectangle(point.X + CornerSize, point.Y + CornerSize, width, height), new Rectangle(CornerSize, CornerSize, BarSize, BarSize), color); }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle innerDimensions = base.GetInnerDimensions(); //Vector2 pos = new Vector2(innerDimensions.X - 20, innerDimensions.Y - 5); Vector2 pos = new Vector2(innerDimensions.X, innerDimensions.Y - 5); spriteBatch.Draw(checkboxTexture, pos, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); if (Selected) { spriteBatch.Draw(checkmarkTexture, pos, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } base.DrawSelf(spriteBatch); if (IsMouseHovering && tooltip.Length > 0) { Main.HoverItem = new Item(); Main.hoverItemName = tooltip; } }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle innerDimensions = base.GetInnerDimensions(); //Vector2 pos = new Vector2(innerDimensions.X - 20, innerDimensions.Y - 5); Vector2 pos = new Vector2(innerDimensions.X, innerDimensions.Y - 5); spriteBatch.Draw(checkboxTexture, pos, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); if (data.Data.HasValue) { if (data.Data.Value) { spriteBatch.Draw(checkmarkTexture, pos, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } else { spriteBatch.Draw(checkXTexture, pos, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } } base.DrawSelf(spriteBatch); }
//////////////// /// <summary> /// Recalculates positions of elements. /// </summary> public override void Recalculate() { base.Recalculate(); CalculatedStyle dim = this.GetDimensions(); float offsetX = this.LeftPixels; float offsetY = this.TopPixels; if (this.LeftCentered) { offsetX -= dim.Width * 0.5f; } if (this.TopCentered) { offsetY -= dim.Height * 0.5f; } this.Left.Set(offsetX, this.LeftPercent); this.Top.Set(offsetY, this.TopPercent); }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle dimensions = GetDimensions(); Texture2D value; Point point; if (_isOn) { value = _onTexture.get_Value(); point = _onTextureOffset; } else { value = _offTexture.get_Value(); point = _offTextureOffset; } Color color = base.IsMouseHovering ? Color.White : Color.Silver; spriteBatch.Draw(value, new Rectangle((int)dimensions.X, (int)dimensions.Y, _drawWidth, _drawHeight), new Rectangle(point.X, point.Y, _drawWidth, _drawHeight), color); }
protected override void DrawSelf(SpriteBatch spriteBatch) { if (this._drawPanel) { CalculatedStyle dimensions = this.GetDimensions(); int num1 = 4; int num2 = 10; int num3 = 10; Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int)dimensions.X, (int)dimensions.Y, (int)dimensions.Width, (int)dimensions.Height, num2, num2, num3, num3, Color.Lerp(Color.Black, this._color, 0.8f) * 0.5f); if (this.IsSelected != null && this.IsSelected(this)) { Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int)dimensions.X + num1, (int)dimensions.Y + num1, (int)dimensions.Width - num1 * 2, (int)dimensions.Height - num1 * 2, num2, num2, num3, num3, Color.Lerp(this._color, Color.White, 0.7f) * 0.5f); } if (this.IsMouseHovering) { Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int)dimensions.X, (int)dimensions.Y, (int)dimensions.Width, (int)dimensions.Height, num2, num2, num3, num3, Color.White); } } this.DrawText(spriteBatch); }
protected override void DrawSelf(SpriteBatch spriteBatch) { frameCounter++; CalculatedStyle dimensions = base.GetInnerDimensions(); spriteBatch.Draw(backgroundTexture, dimensions.Position(), null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); Rectangle rectangle = dimensions.ToRectangle(); int frames = Main.projFrames[type]; Texture2D texture = Main.projectileTexture[type]; int height = texture.Height / frames; int width = texture.Width; int frame = frameCounter % frames; int y = height * frame; float drawScale = 1f; float availableWidth = (float)backgroundTexture.Width * scale; if (width > availableWidth || height > availableWidth) { if (width > height) { drawScale = availableWidth / width; } else { drawScale = availableWidth / height; } } Vector2 drawPosition = dimensions.Position(); drawPosition.X += backgroundTexture.Width * scale / 2f - (float)width * drawScale / 2f; drawPosition.Y += backgroundTexture.Height * scale / 2f - (float)height * drawScale / 2f; Main.spriteBatch.Draw(texture, drawPosition, new Rectangle(0, y, width, height), Color.White, 0, Vector2.Zero, drawScale, SpriteEffects.None, 0); if (IsMouseHovering) { Main.hoverItemName = Lang.GetProjectileName(type).Value; } }
protected override void DrawSelf(SpriteBatch spriteBatch) { try { bool isSelected = SelectedNetID == this.npc.netID; var tex = backTexture; if (isSelected) { backTexture = Main.inventoryBack14Texture; } base.DrawSelf(spriteBatch); if (isSelected) { backTexture = tex; } CalculatedStyle dimensions = base.GetInnerDimensions(); Vector2 pos = dimensions.Position(); SetPosition(frame, slotNPCSize, ref pos); if (ModContent.GetInstance <NPCInfoConfig>().isAnimation) { NextFrame(); } spriteBatch.Draw(texture, pos, new Rectangle?(frame), Color.White, 0, new Vector2(), drawScale, SpriteEffects.None, 0f); if (npc.color != default(Color)) { Main.spriteBatch.Draw(texture, pos, new Rectangle?(frame), npc.color, 0, new Vector2(), drawScale, SpriteEffects.None, 0f); } DrawCount(spriteBatch, count.ToString()); if (IsMouseHovering) { Tool.tooltip = npc.FullName; NPCInfo.instance.npcInfoTool.targetNPC = npc; } } catch (Exception ex) { System.Diagnostics.Debug.Write(ex.Message); } }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle innerDimensions = base.GetInnerDimensions(); Vector2 drawPos = new Vector2(innerDimensions.X + 5f, innerDimensions.Y + 5f); spriteBatch.Draw(Main.inventoryBackTexture, drawPos, null, new Color(73, 94, 171), 0f, Vector2.Zero, 0.75f, SpriteEffects.None, 0f); counter.SetText("", 1f, true); if (currentItemInSlot != null) { Texture2D itemTexture = Main.itemTexture[currentItemInSlot.type]; Rectangle r = itemTexture.Bounds; Rectangle r2 = innerDimensions.ToRectangle(); int width = r.Width; int height = r.Height; float drawScale = 1f; float availableWidth = (float)Main.inventoryBackTexture.Width * scale; if (width > availableWidth || height > availableWidth) { if (width > height) { drawScale = availableWidth / width; } else { drawScale = availableWidth / height; } } drawPos = new Vector2(innerDimensions.X + 10f, innerDimensions.Y + 10f); Vector2 vector = Main.inventoryBackTexture.Size() * scale; Vector2 pos2 = innerDimensions.Position() + vector / 2 - r2.Size() * drawScale / 2f; drawScale *= scale; spriteBatch.Draw(Main.itemTexture[currentItemInSlot.type], drawPos, null, Color.White, 0f, r2.Size() * (1f / 2f - 0.5f), drawScale, SpriteEffects.None, 0f); counter.SetText(currentItemInSlot.stack.ToString(), 0.29f, true); } }
protected override void DrawSelf(SpriteBatch spriteBatch) { Texture2D texture = ModContent.GetTexture("MagicStorage/SearchBar").Value; CalculatedStyle dim = GetDimensions(); int innerWidth = (int)dim.Width - 2 * padding; int innerHeight = (int)dim.Height - 2 * padding; spriteBatch.Draw(texture, dim.Position(), new Rectangle(0, 0, padding, padding), Color.White); spriteBatch.Draw(texture, new Rectangle((int)dim.X + padding, (int)dim.Y, innerWidth, padding), new Rectangle(padding, 0, 1, padding), Color.White); spriteBatch.Draw(texture, new Vector2(dim.X + padding + innerWidth, dim.Y), new Rectangle(padding + 1, 0, padding, padding), Color.White); spriteBatch.Draw(texture, new Rectangle((int)dim.X, (int)dim.Y + padding, padding, innerHeight), new Rectangle(0, padding, padding, 1), Color.White); spriteBatch.Draw(texture, new Rectangle((int)dim.X + padding, (int)dim.Y + padding, innerWidth, innerHeight), new Rectangle(padding, padding, 1, 1), Color.White); spriteBatch.Draw(texture, new Rectangle((int)dim.X + padding + innerWidth, (int)dim.Y + padding, padding, innerHeight), new Rectangle(padding + 1, padding, padding, 1), Color.White); spriteBatch.Draw(texture, new Vector2(dim.X, dim.Y + padding + innerHeight), new Rectangle(0, padding + 1, padding, padding), Color.White); spriteBatch.Draw(texture, new Rectangle((int)dim.X + padding, (int)dim.Y + padding + innerHeight, innerWidth, padding), new Rectangle(padding, padding + 1, 1, padding), Color.White); spriteBatch.Draw(texture, new Vector2(dim.X + padding + innerWidth, dim.Y + padding + innerHeight), new Rectangle(padding + 1, padding + 1, padding, padding), Color.White); bool isEmpty = text.Length == 0; string drawText = isEmpty ? defaultText.Value : text; DynamicSpriteFont font = FontAssets.MouseText.Value; Vector2 size = font.MeasureString(drawText); float scale = innerHeight / size.Y; if (isEmpty && hasFocus) { drawText = string.Empty; isEmpty = false; } Color color = Color.Black; if (isEmpty) { color *= 0.75f; } spriteBatch.DrawString(font, drawText, new Vector2(dim.X + padding, dim.Y + padding), color, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); if (!isEmpty && hasFocus && cursorTimer < 30) { float drawCursor = font.MeasureString(drawText.Substring(0, cursorPosition)).X *scale; spriteBatch.DrawString(font, "|", new Vector2(dim.X + padding + drawCursor, dim.Y + padding), color, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); } }
protected override void DrawSelf(SpriteBatch spriteBatch) { base.DrawSelf(spriteBatch); CalculatedStyle innerDimensions = base.GetInnerDimensions(); Vector2 pos = new Vector2(innerDimensions.X, innerDimensions.Y - 5); //Rectangle hitbox = GetInnerDimensions().ToRectangle(); //Main.spriteBatch.Draw(Main.magicPixel, hitbox, Color.Red * 0.6f); spriteBatch.Draw(checkboxTexture, pos, null, disabled ? Color.Gray : Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); if (Selected) { spriteBatch.Draw(checkmarkTexture, pos, null, disabled ? Color.Gray : Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } if (IsMouseHovering) { Main.hoverItemName = hoverText; } }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle dimensions = GetDimensions(); bool unlockState = _entry.Icon.GetUnlockState(_collectionInfo); bool isHovered = base.IsMouseHovering || ForceHover; if (unlockState) { _entry.Icon.Draw(_collectionInfo, spriteBatch, new EntryIconDrawSettings { iconbox = dimensions.ToRectangle(), IsPortrait = _isPortrait, IsHovered = isHovered }); } else { Texture2D value = _notUnlockedTexture.Value; spriteBatch.Draw(value, dimensions.Center(), null, Color.White * 0.15f, 0f, value.Size() / 2f, 1f, SpriteEffects.None, 0f); } }
protected override void DrawSelf(SpriteBatch spriteBatch) { base.DrawSelf(spriteBatch); if (EventsJournalUIState.SelectedEvent == -1) { return; } if (EventsJournalUIState.SelectedEvent != SelectedEvent) { SelectedEvent = EventsJournalUIState.SelectedEvent; // TODO: wait until end to do hover on snippets, or make ItemTag alternate that doesn't call MouseText messageBox.SetText(EventID.descriptionString[SelectedEvent]); } CalculatedStyle dimensions = base.GetDimensions(); spriteBatch.Draw(Events.Instance.GetTexture("Icons/" + SelectedEvent), dimensions.Position() + new Vector2(6, 6), null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0); Utils.DrawBorderString(spriteBatch, EventID.nameString[SelectedEvent], dimensions.Position() + new Vector2(46, 14), Color.White, 1, 0f, 0f, -1); }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle dimensions = this.GetDimensions(); CalculatedStyle innerDimensions = this.GetInnerDimensions(); if (this._isDragging) { this._viewPosition = MathHelper.Clamp((UserInterface.ActiveInstance.MousePosition.Y - innerDimensions.Y - this._dragYOffset) / innerDimensions.Height * this._maxViewSize, 0.0f, this._maxViewSize - this._viewSize); } Rectangle handleRectangle = this.GetHandleRectangle(); Vector2 mousePosition = UserInterface.ActiveInstance.MousePosition; int num = this._isHoveringOverHandle ? 1 : 0; this._isHoveringOverHandle = handleRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y)); if (num == 0 && this._isHoveringOverHandle && Main.hasFocus) { SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f); } this.DrawBar(spriteBatch, this._texture.get_Value(), dimensions.ToRectangle(), Color.White); this.DrawBar(spriteBatch, this._innerTexture.get_Value(), handleRectangle, Color.White * (this._isDragging || this._isHoveringOverHandle ? 1f : 0.85f)); }
//////////////// /*/// @private * public override void Draw( SpriteBatch spriteBatch ) { * if( !this.IsHidden ) { * float opacity = this.ComputeCurrentOpacity(); * Color oldTextColor = this.TextColor; * * this.TextColor.R = (byte)((float)this.TextColor.R * opacity); * this.TextColor.G = (byte)((float)this.TextColor.G * opacity); * this.TextColor.B = (byte)((float)this.TextColor.B * opacity); * this.TextColor.A = (byte)((float)this.TextColor.A * opacity); * * base.Draw( spriteBatch ); * * this.TextColor = oldTextColor; * } * }*/ /// <summary> /// Draws element. Also handles text input changes. /// </summary> /// <param name="sb">SpriteBatch to draw to. Typically given `Main.spriteBatch`.</param> protected override void DrawSelf(SpriteBatch sb) { /*float opacity = this.ComputeCurrentOpacity(); * Color oldTextColor = this.TextColor; * * this.TextColor.R = (byte)((float)this.TextColor.R * opacity); * this.TextColor.G = (byte)((float)this.TextColor.G * opacity); * this.TextColor.B = (byte)((float)this.TextColor.B * opacity); * this.TextColor.A = (byte)((float)this.TextColor.A * opacity); */ base.DrawSelf(sb); CalculatedStyle dim = this.GetDimensions(); if (this.IsInteractive) { this.UpdateInteractivity(dim); } this.DrawText(dim, sb); }
protected override void DrawSelf(SpriteBatch spriteBatch) { this._cursor = this.Text.Length; base.DrawSelf(spriteBatch); this._frameCount = this._frameCount + 1; if ((this._frameCount = this._frameCount % 40) > 20) { return; } CalculatedStyle innerDimensions = this.GetInnerDimensions(); Vector2 pos = innerDimensions.Position(); Vector2 vector2 = Vector2.op_Multiply(new Vector2((float)(this.IsLarge ? Main.fontDeathText : Main.fontMouseText).MeasureString(this.Text.Substring(0, this._cursor)).X, this.IsLarge ? 32f : 16f), this.TextScale); if (this.IsLarge) { // ISSUE: explicit reference operation // ISSUE: variable of a reference type __Null& local = @pos.Y; // ISSUE: cast to a reference type // ISSUE: explicit reference operation double num = (double) ^ (float&)local - 8.0 * (double)this.TextScale;
public int MouseButton() { if (!IsMouseHovering) { return(-1); } CalculatedStyle dim = GetDimensions(); float x = Main.mouseX - dim.X; float y = Main.mouseY - dim.Y; int column = (int)(x / (size + padding)); // Padding Check if ((column + 1) * (size + padding) - padding < x) { return(-1); } return(column); }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle dimensions = GetDimensions(); Vector2 position = dimensions.Position() + new Vector2(dimensions.Width, dimensions.Height) / 2f; spriteBatch.Draw(_backPanelTexture.Value, position, null, Color.White * (base.IsMouseHovering ? _visibilityActive : _visibilityInactive), 0f, _backPanelTexture.Size() / 2f, 1f, SpriteEffects.None, 0f); _ = Color.White; if (_hovered) { spriteBatch.Draw(_backPanelBorderTexture.Value, position, null, Color.White, 0f, _backPanelBorderTexture.Size() / 2f, 1f, SpriteEffects.None, 0f); } if (_selected) { spriteBatch.Draw(_backPanelHighlightTexture.Value, position, null, Color.White, 0f, _backPanelHighlightTexture.Size() / 2f, 1f, SpriteEffects.None, 0f); } if (_middleTexture != null) { spriteBatch.Draw(_middleTexture.Value, position, null, Color.White, 0f, _middleTexture.Size() / 2f, 1f, SpriteEffects.None, 0f); } spriteBatch.Draw(_texture.Value, position, null, _color, 0f, _texture.Size() / 2f, 1f, SpriteEffects.None, 0f); }
private static void UpdateDepositButton() { CalculatedStyle dim = depositButton.GetDimensions(); if (curMouse.X > dim.X && curMouse.X < dim.X + dim.Width && curMouse.Y > dim.Y && curMouse.Y < dim.Y + dim.Height) { depositButton.BackgroundColor = new Color(73, 94, 171); if (MouseClicked) { if (TryDepositAll()) { RefreshItems(); Main.PlaySound(7, -1, -1, 1); } } } else { depositButton.BackgroundColor = new Color(63, 82, 151) * 0.7f; } }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle dimensions = this.GetDimensions(); int num = this._entry.Icon.GetUnlockState(this._collectionInfo) ? 1 : 0; bool flag = this.IsMouseHovering || this.ForceHover; if (num != 0) { this._entry.Icon.Draw(this._collectionInfo, spriteBatch, new EntryIconDrawSettings() { iconbox = dimensions.ToRectangle(), IsPortrait = this._isPortrait, IsHovered = flag }); } else { Texture2D texture2D = this._notUnlockedTexture.get_Value(); spriteBatch.Draw(texture2D, dimensions.Center(), new Rectangle?(), Color.White * 0.15f, 0.0f, texture2D.Size() / 2f, 1f, SpriteEffects.None, 0.0f); } }
protected override void DrawChildren(SpriteBatch spriteBatch) { // Drawing is done manually so that the panel's opacity can be a thing - there isn't a way to set opacity of a UIImage. // As such, DO NOT make this call base.DrawChildren or it will break! // I'm looking at you, GoodPro. // Lord forgive me for what I'm about to do. CalculatedStyle mainPanelDimensions = mainPanel.GetDimensions(); CalculatedStyle currentImageDimensions = dimensionTransportButton.GetDimensions(); CalculatedStyle textDimensions = selectedDimensionName.GetDimensions(); CalculatedStyle leftArrowDimensions = leftArrow.GetDimensions(); CalculatedStyle rightArrowDimensions = rightArrow.GetDimensions(); CalculatedStyle exitButtonDimensions = exitButton.GetDimensions(); spriteBatch.Draw(mainPanelTexture, new Vector2(mainPanelDimensions.X, mainPanelDimensions.Y), Color.White * opacity); spriteBatch.Draw(currentDimensionImage, new Vector2(currentImageDimensions.X, currentImageDimensions.Y), Color.White * opacity); spriteBatch.Draw(dimensionImageFrame, new Vector2(mainPanelDimensions.X, mainPanelDimensions.Y), Color.White * opacity); spriteBatch.DrawString(Main.fontMouseText, selectedDimensionName.Text, new Vector2(textDimensions.X, textDimensions.Y), Color.White * opacity); spriteBatch.Draw(currentLeftArrowTex, new Vector2(leftArrowDimensions.X, leftArrowDimensions.Y), Color.White * opacity); spriteBatch.Draw(currentRightArrowTex, new Vector2(rightArrowDimensions.X, rightArrowDimensions.Y), Color.White * opacity); spriteBatch.Draw(exitButtonTexture, new Vector2(exitButtonDimensions.X, exitButtonDimensions.Y), Color.White * opacity); }