public override void Draw(SpriteBatch spriteBatch) { if (Focused) { PlayerInput.WritingText = true; Main.instance.HandleIME(); string updatedString = Main.GetInputText(Value); if (Filter != null) { updatedString = Filter(updatedString); } if (updatedString != Value) { Value = updatedString; Main.PlaySound(SoundID.MenuTick); } if (++textBlinkerCount >= 20) { textBlinkerState = !textBlinkerState; textBlinkerCount = 0; } } else { textBlinkerState = false; } Rect dimensions = new Rect(GetInnerDimensions()); InputTexture.Draw(spriteBatch, dimensions, Focused ? Color.White : Color.White * 0.7f); Vector2 StringPosition = dimensions.Position; StringPosition.X += 8; StringPosition.Y += (dimensions.Height - LineHeight) / 2; if (Value.Length == 0 && !Focused && Placeholder != null) { Utils.DrawBorderString(spriteBatch, Placeholder.Value, StringPosition, Color.Gray); } else { string displayString = (Sensitive ? Regex.Replace(Value, ".", "*") : Value) + (textBlinkerState ? "|" : ""); Utils.DrawBorderString(spriteBatch, displayString, StringPosition, Color.White); } }
public override void Draw(SpriteBatch spriteBatch) { if (!Readonly && Focused && Main.keyState.IsKeyDown(Keys.Space) && !Main.oldKeyState.IsKeyDown(Keys.Space)) { Checked = !Checked; } bool isActive = !Readonly && (Focused || IsMouseHovering); Rect checkboxRect = new Rect(GetInnerDimensions()); CheckboxTexture.Draw(spriteBatch, checkboxRect, isActive ? ActiveCheckboxColor : InactiveCheckboxColor); if (Checked) { Vector2 checkmarkPosition = checkboxRect.Center(); checkmarkPosition.X += 2; checkmarkPosition.Y += 4; Utils.DrawBorderString(spriteBatch, CHECKMARK, checkmarkPosition, Readonly ? ReadonlyCheckmarkColor : CheckmarkColor, 1, 0.5f, 0.5f); } }
public static void DrawPanel(SpriteBatch spriteBatch, Rect rect, float detailScale = 1) { texture.Draw(spriteBatch, rect, Main.inventoryBack, detailScale); }