private void CheckInput() { if (Input.GetKeyDown(KeyCode.LeftArrow)) // checking for input of specific key { OnLeftPressed.Invoke(MoveSide.Left); } if (Input.GetKeyDown(KeyCode.RightArrow)) { OnRightPressed.Invoke(MoveSide.Right); } if (Input.GetKeyDown(KeyCode.UpArrow)) { OnUpPressed.Invoke(); } if (Input.GetKeyDown(KeyCode.DownArrow)) { OnDownPressed.Invoke(); } }
private void NotifyUpPressed() { OnUpPressed?.Invoke(); SayToLog("Up pressed."); }
protected override void DrawSelf(SpriteBatch spriteBatch) { Rectangle hitbox = GetDimensions().ToRectangle(); Main.spriteBatch.Draw(Main.magicPixel, hitbox, Color.White); if (focused) { Terraria.GameInput.PlayerInput.WritingText = true; Main.instance.HandleIME(); WriteAll(Main.GetInputText(Text)); if (JustPressed(Keys.Tab)) { if (unfocusOnTab) { Unfocus(); } OnTabPressed?.Invoke(); } if (JustPressed(Keys.Enter)) { if (unfocusOnEnter) { Unfocus(); } OnEnterPressed?.Invoke(); } if (JustPressed(Keys.Up)) { OnUpPressed?.Invoke(); } } CalculatedStyle innerDimensions2 = base.GetInnerDimensions(); Vector2 pos2 = innerDimensions2.Position(); if (IsLarge) { pos2.Y -= 10f * TextScale * TextScale; } else { pos2.Y -= 2f * TextScale; } if (IsLarge) { Utils.DrawBorderStringBig(spriteBatch, Text, pos2, TextColor, TextScale, 0f, 0f, -1); return; } Utils.DrawBorderString(spriteBatch, Text, pos2, TextColor, TextScale, 0f, 0f, -1); this._frameCount++; CalculatedStyle innerDimensions = base.GetInnerDimensions(); Vector2 pos = innerDimensions.Position(); DynamicSpriteFont spriteFont = base.IsLarge ? Main.fontDeathText : Main.fontMouseText; Vector2 vector = new Vector2(spriteFont.MeasureString(base.Text.Substring(0, this._cursor)).X, base.IsLarge ? 32f : 16f) * base.TextScale; if (base.IsLarge) { pos.Y -= 8f * base.TextScale; } else { pos.Y -= 1f * base.TextScale; } if (Text.Length == 0) { pos.X += 5; if (base.IsLarge) { Utils.DrawBorderStringBig(spriteBatch, hintText, pos, Color.Gray, base.TextScale, 0f, 0f, -1); return; } Utils.DrawBorderString(spriteBatch, hintText, pos, Color.Gray, base.TextScale, 0f, 0f, -1); pos.X -= 5; } if (!focused) { return; } pos.X += /*(innerDimensions.Width - base.TextSize.X) * 0.5f*/ +vector.X - (base.IsLarge ? 8f : 4f) * base.TextScale + 6f; if ((this._frameCount %= 40) > 20) { return; } if (base.IsLarge) { Utils.DrawBorderStringBig(spriteBatch, "|", pos, base.TextColor, base.TextScale, 0f, 0f, -1); return; } Utils.DrawBorderString(spriteBatch, "|", pos, base.TextColor, base.TextScale, 0f, 0f, -1); }
protected override void DrawSelf(SpriteBatch spriteBatch) { Rectangle hitbox = GetInnerDimensions().ToRectangle(); Main.spriteBatch.Draw(Main.magicPixel, hitbox, Color.LightCyan * 0.6f); if (focused) { Terraria.GameInput.PlayerInput.WritingText = true; Main.instance.HandleIME(); // This might work.....assuming chat isn't open var a = Main.GetInputText(Text); var lines = a.Split('\n'); string lastLine = lines.Last(); if (lastLine.Length > this._maxLineLength + 1) { var orig = a.ToCharArray(); char last = orig[orig.Length - 1]; orig[orig.Length - 1] = '\n'; a = new string(orig) + last; } WriteAll(a); if (JustPressed(Keys.Tab)) { if (unfocusOnTab) { Unfocus(); } // Main.NewText("Tab"); OnTabPressed?.Invoke(); } if (JustPressed(Keys.Enter)) { // Main.NewText("Enter"); if (unfocusOnEnter) { Unfocus(); } OnEnterPressed?.Invoke(); } if (JustPressed(Keys.Up)) { OnUpPressed?.Invoke(); } } CalculatedStyle innerDimensions2 = base.GetInnerDimensions(); Vector2 pos2 = innerDimensions2.Position(); if (IsLarge) { pos2.Y -= 10f * TextScale * TextScale; } else { pos2.Y -= 2f * TextScale; } //pos2.X += (innerDimensions2.Width - TextSize.X) * 0.5f; if (IsLarge) { Utils.DrawBorderStringBig(spriteBatch, Text, pos2, TextColor, TextScale, 0f, 0f, -1); return; } Utils.DrawBorderString(spriteBatch, Text, pos2, TextColor, TextScale, 0f, 0f, -1); this._frameCount++; CalculatedStyle innerDimensions = base.GetInnerDimensions(); Vector2 pos = innerDimensions.Position(); DynamicSpriteFont spriteFont = base.IsLarge ? Main.fontDeathText : Main.fontMouseText; Vector2 vector = new Vector2(spriteFont.MeasureString(base.Text.Substring(0, this._cursor)).X, base.IsLarge ? 32f : 16f) * base.TextScale; if (base.IsLarge) { pos.Y -= 8f * base.TextScale; } else { pos.Y -= 1f * base.TextScale; } if (Text.Length == 0) { Vector2 hintTextSize = new Vector2(spriteFont.MeasureString(hintText.ToString()).X, IsLarge ? 32f : 16f) * TextScale; pos.X += 5; //(hintTextSize.X); if (base.IsLarge) { Utils.DrawBorderStringBig(spriteBatch, hintText, pos, Color.Gray, base.TextScale, 0f, 0f, -1); return; } Utils.DrawBorderString(spriteBatch, hintText, pos, Color.Gray, base.TextScale, 0f, 0f, -1); pos.X -= 5; //pos.X -= (innerDimensions.Width - hintTextSize.X) * 0.5f; } if (!focused) { return; } pos.X += /*(innerDimensions.Width - base.TextSize.X) * 0.5f*/ +vector.X - (base.IsLarge ? 8f : 4f) * base.TextScale + 6f; if ((this._frameCount %= 40) > 20) { return; } if (base.IsLarge) { Utils.DrawBorderStringBig(spriteBatch, "|", pos, base.TextColor, base.TextScale, 0f, 0f, -1); return; } Utils.DrawBorderString(spriteBatch, "|", pos, base.TextColor, base.TextScale, 0f, 0f, -1); }
protected override void DrawSelf(SpriteBatch spriteBatch) { Rectangle hitbox = GetDimensions().ToRectangle(); //hitbox.Inflate(4, 4); Main.spriteBatch.Draw(REPLTool.magicPixel, hitbox, Color.White); // Draw panel -- Panel draws odd when too small // base.DrawSelf(spriteBatch); if (focused) { Terraria.GameInput.PlayerInput.WritingText = true; Main.instance.HandleIME(); // This might work.....assuming chat isn't open WriteAll(Main.GetInputText(Text)); if (JustPressed(Keys.Tab)) { if (unfocusOnTab) { Unfocus(); } // Main.NewText("Tab"); OnTabPressed?.Invoke(); } if (JustPressed(Keys.Enter)) { // Main.NewText("Enter"); if (unfocusOnEnter) { Unfocus(); } OnEnterPressed?.Invoke(); } if (JustPressed(Keys.Up)) { OnUpPressed?.Invoke(); } } CalculatedStyle innerDimensions2 = base.GetInnerDimensions(); Vector2 pos2 = innerDimensions2.Position(); if (IsLarge) { pos2.Y -= 10f * TextScale * TextScale; } else { pos2.Y -= 2f * TextScale; } //pos2.X += (innerDimensions2.Width - TextSize.X) * 0.5f; if (IsLarge) { Utils.DrawBorderStringBig(spriteBatch, Text, pos2, TextColor, TextScale, 0f, 0f, -1); return; } Utils.DrawBorderString(spriteBatch, Text, pos2, TextColor, TextScale, 0f, 0f, -1); this._frameCount++; CalculatedStyle innerDimensions = base.GetInnerDimensions(); Vector2 pos = innerDimensions.Position(); DynamicSpriteFont spriteFont = base.IsLarge ? Terraria.GameContent.FontAssets.DeathText.Value : GameContent.FontAssets.MouseText.Value; Vector2 vector = new Vector2(spriteFont.MeasureString(base.Text.Substring(0, this._cursor)).X, base.IsLarge ? 32f : 16f) * base.TextScale; if (base.IsLarge) { pos.Y -= 8f * base.TextScale; } else { pos.Y -= 1f * base.TextScale; } if (Text.Length == 0) { Vector2 hintTextSize = new Vector2(spriteFont.MeasureString(hintText.ToString()).X, IsLarge ? 32f : 16f) * TextScale; pos.X += 5; //(hintTextSize.X); if (base.IsLarge) { Utils.DrawBorderStringBig(spriteBatch, hintText, pos, Color.Gray, base.TextScale, 0f, 0f, -1); return; } Utils.DrawBorderString(spriteBatch, hintText, pos, Color.Gray, base.TextScale, 0f, 0f, -1); pos.X -= 5; //pos.X -= (innerDimensions.Width - hintTextSize.X) * 0.5f; } if (!focused) { return; } pos.X += /*(innerDimensions.Width - base.TextSize.X) * 0.5f*/ +vector.X - (base.IsLarge ? 8f : 4f) * base.TextScale + 6f; if ((this._frameCount %= 40) > 20) { return; } if (base.IsLarge) { Utils.DrawBorderStringBig(spriteBatch, "|", pos, base.TextColor, base.TextScale, 0f, 0f, -1); return; } Utils.DrawBorderString(spriteBatch, "|", pos, base.TextColor, base.TextScale, 0f, 0f, -1); }