diff --git a/Code/RoomNameController.cs b/Code/RoomNameController.cs index 74473e3..6baf674 100644 --- a/Code/RoomNameController.cs +++ b/Code/RoomNameController.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +using static FrostHelper.CustomZipMover; namespace Celeste.Mod.Code.Entities { @@ -18,13 +19,20 @@ public class RoomNameController : Entity public string Name; private string bgColor; private string textColor; + private string lineColor; + private float lineAmt; private float timer; + private float scale; public RoomNameController(EntityData data, Vector2 offset) : base(data.Position + offset) { Name = data.Attr("roomName"); bgColor = data.Attr("backgroundColor", "000000FF"); textColor = data.Attr("textColor", "FFFFFFFF"); + lineColor = data.Attr("outlineColor", "000000FF"); + lineAmt = data.Float("outlineThickness", 0f); + scale = data.Float("scale", 1f); + timer = data.Float("disappearTimer", -1f); } public override void Awake(Scene scene) @@ -32,8 +40,9 @@ public override void Awake(Scene scene) base.Awake(scene); var display = RoomNameDisplay.GetDisplay(scene); display.SetName(Name); - display.SetColor(Calc.HexToColorWithAlpha(textColor), Calc.HexToColorWithAlpha(bgColor)); + display.SetColor(textColor, bgColor, lineColor, lineAmt); display.SetTimer(Math.Max(timer, 0f)); + display.scale = scale; } } } diff --git a/Code/RoomNameDisplay.cs b/Code/RoomNameDisplay.cs index d8cb642..cc4d242 100644 --- a/Code/RoomNameDisplay.cs +++ b/Code/RoomNameDisplay.cs @@ -21,9 +21,15 @@ public class RoomNameDisplay : Entity public Color bgColor; public Color textColor; + private Color lineColor; private float colorLerp; private Color bgColorStart; private Color textColorStart; + private Color lineColorStart; + private float outline; + private float nextOutline; + + public float scale; private float outTimer; public RoomNameDisplay() { @@ -77,6 +83,7 @@ public override void Update() if (textLerp == 0f) { text = nextText; + outline = nextOutline; } } @@ -98,21 +105,28 @@ public override void Update() public override void Render() { base.Render(); - var y = Calc.LerpClamp(1080f, 1032f, Ease.CubeOut(drawLerp)); + var y = Calc.LerpClamp(1080f, 1080f - (48f * scale), Ease.CubeOut(drawLerp)); Color bgC = bgColor; if (colorLerp < 1f) { bgC = Color.Lerp(bgColorStart, bgColor, colorLerp); } - Draw.Rect(-2f, y, 1920f + 4f, 48f + 2f, bgC); + Draw.Rect(-2f, y, 1920f + 4f, (48f * scale) + 2f, bgC); if (text != "") { Color textC = textColor; if (colorLerp < 1f) { textC = Color.Lerp(textColorStart, textColor, colorLerp); } - var texty = Calc.LerpClamp(1080f, 1032f, Ease.CubeOut(Calc.Min(textLerp, drawLerp))); - ActiveFont.Draw(text, new Vector2(960, texty - 6f), new Vector2(0.5f, 0f), new Vector2(1f, 1f), textC); + var texty = Calc.LerpClamp(1080f, 1080f - (48f * scale), Ease.CubeOut(Calc.Min(textLerp, drawLerp))); + if (outline > 0f) + { + ActiveFont.DrawOutline(text, new Vector2(960, texty - 6f), new Vector2(0.5f, 0f), new Vector2(scale, scale), textC, outline, lineColor); + } + else + { + ActiveFont.Draw(text, new Vector2(960, texty - 6f), new Vector2(0.5f, 0f), new Vector2(scale, scale), textC); + } } } @@ -128,17 +142,23 @@ public void SetName(string name) } } - public void SetColor(Color text, Color bg) + public void SetColor(string textHex, string bgHex, string lineHex, float amt) { + Color text = HexToColor(textHex); + Color bg = HexToColor(bgHex); + Color line = HexToColor(lineHex); + if (colorLerp < 1f) { bgColorStart = Color.Lerp(bgColorStart, bgColor, colorLerp); textColorStart = Color.Lerp(textColorStart, textColor, colorLerp); + lineColorStart = Color.Lerp(lineColorStart, lineColor, colorLerp); } else { bgColorStart = bgColor; textColorStart = textColor; + lineColorStart = lineColor; } colorLerp = 0f; if (drawLerp == 0f) @@ -147,6 +167,25 @@ public void SetColor(Color text, Color bg) } bgColor = bg; textColor = text; + lineColor = line; + nextOutline = amt; + } + + // Calc.HexToColorWithAlpha does not work correctly + // need to do it myself + public Color HexToColor(string hex) + { + if (hex[0] == '#') + { + hex = hex.Substring(1); + } + Color color = Calc.HexToColor(hex); + if (hex.Length == 6) + { + return color; + } + float alpha = (Calc.HexToByte(hex[6]) * 16 + Calc.HexToByte(hex[7])) / 255f; + return color * alpha; } public void SetTimer(float timer) diff --git a/Code/RoomNameTrigger.cs b/Code/RoomNameTrigger.cs index 50bc25d..d723e68 100644 --- a/Code/RoomNameTrigger.cs +++ b/Code/RoomNameTrigger.cs @@ -18,15 +18,22 @@ public class RoomNameTrigger : Trigger public string Name; private string bgColor; private string textColor; + private string lineColor; + private float lineAmt; private float timer; private bool oneUse; private bool instant; + private float scale; public RoomNameTrigger(EntityData data, Vector2 offset) : base(data, offset) { Name = data.Attr("roomName"); bgColor = data.Attr("backgroundColor", "000000FF"); textColor = data.Attr("textColor", "FFFFFFFF"); + lineColor = data.Attr("outlineColor", "000000FF"); + lineAmt = data.Float("outlineThickness", 0f); + scale = data.Float("scale", 1f); + timer = data.Float("disappearTimer", -1f); oneUse = data.Bool("oneUse", false); instant = data.Bool("instant", false); @@ -37,8 +44,9 @@ public override void OnEnter(Player player) base.OnEnter(player); var display = RoomNameDisplay.GetDisplay(player.Scene); display.SetName(Name); - display.SetColor(Calc.HexToColorWithAlpha(textColor), Calc.HexToColorWithAlpha(bgColor)); + display.SetColor(textColor, bgColor, lineColor, lineAmt); display.SetTimer(Math.Max(timer, 0f)); + display.scale = scale; if (instant) { display.SetInstant(); diff --git a/Loenn/entities/room_name.lua b/Loenn/entities/room_name.lua index d24994b..5f209a5 100644 --- a/Loenn/entities/room_name.lua +++ b/Loenn/entities/room_name.lua @@ -11,6 +11,9 @@ roomName.placements = { backgroundColor = "000000FF", textColor = "FFFFFFFF", disappearTimer = -1, + outlineColor = "000000FF", + outlineThickness = 0, + scale = 1, } } } @@ -21,6 +24,12 @@ roomName.fieldInformation = { textColor = { fieldType = "color" }, + outlineColor = { + fieldType = "color" + }, + scale = { + minimumValue = 0.01, + }, } roomName.texture = "ahorn_roomname" diff --git a/Loenn/lang/en_gb.lang b/Loenn/lang/en_gb.lang index 154fe67..490f964 100644 --- a/Loenn/lang/en_gb.lang +++ b/Loenn/lang/en_gb.lang @@ -303,6 +303,9 @@ entities.vitellary/cassetteflags.attributes.description.greenFlag=The flag to en entities.vitellary/roomname.attributes.description.roomName=The text to appear at the bottom of the screen. Accepts dialog keys.\nTo make text disappear, leave this as blank. entities.vitellary/roomname.attributes.description.backgroundColor=The color of the rectangle behind the room name. entities.vitellary/roomname.attributes.description.textColor=The color of the room name text. +entities.vitellary/roomname.attributes.description.outlineColor=The color of the text's outline, if it has one. +entities.vitellary/roomname.attributes.description.outlineThickness=The size of the text's outline. 0 means it won't have one. +entities.vitellary/roomname.attributes.description.scale=The scale multiplier of the room name. entities.vitellary/roomname.attributes.description.disappearTimer=The amount of time until the room name goes away. Negative values means the text won't disappear. # Remote Trigger @@ -402,6 +405,9 @@ triggers.vitellary/bombtimer.attributes.description.resetOnDeath=Whether the pla triggers.vitellary/roomnametrigger.attributes.description.roomName=The text to appear at the bottom of the screen. Accepts dialog keys.\nTo make text disappear, leave this as blank. triggers.vitellary/roomnametrigger.attributes.description.backgroundColor=The color of the rectangle behind the room name. triggers.vitellary/roomnametrigger.attributes.description.textColor=The color of the room name text. +triggers.vitellary/roomnametrigger.attributes.description.outlineColor=The color of the text's outline, if it has one. +triggers.vitellary/roomnametrigger.attributes.description.outlineThickness=The size of the text's outline. 0 means it won't have one. +triggers.vitellary/roomnametrigger.attributes.description.scale=The scale multiplier of the room name. triggers.vitellary/roomnametrigger.attributes.description.disappearTimer=The amount of time until the room name goes away. Negative values means the text won't disappear. triggers.vitellary/roomnametrigger.attributes.description.oneUse=Whether the trigger should only apply once. triggers.vitellary/roomnametrigger.attributes.description.instant=Whether the text and colors should instantly appear, rather than easing in. diff --git a/Loenn/triggers/roomnametrigger.lua b/Loenn/triggers/roomnametrigger.lua index 0d75548..abe9040 100644 --- a/Loenn/triggers/roomnametrigger.lua +++ b/Loenn/triggers/roomnametrigger.lua @@ -10,6 +10,9 @@ roomNameTrigger.placements = { backgroundColor = "000000FF", textColor = "FFFFFFFF", disappearTimer = -1, + outlineColor = "000000FF", + outlineThickness = 0, + scale = 1, oneUse = false, instant = false, } @@ -22,6 +25,12 @@ roomNameTrigger.fieldInformation = { textColor = { fieldType = "color" }, + outlineColor = { + fieldType = "color" + }, + scale = { + minimumValue = 0.01, + }, } return roomNameTrigger