Skip to content

Commit bb1baaf

Browse files
authored
Merge pull request #71 from CommunalHelper/room-name
more features / bugfixes for room names
2 parents f1ffe7c + 3a306d2 commit bb1baaf

File tree

6 files changed

+87
-7
lines changed

6 files changed

+87
-7
lines changed

Code/RoomNameController.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Collections.Generic;
99
using System.Collections.ObjectModel;
1010
using System.Linq;
11+
using static FrostHelper.CustomZipMover;
1112

1213
namespace Celeste.Mod.Code.Entities
1314
{
@@ -18,22 +19,30 @@ public class RoomNameController : Entity
1819
public string Name;
1920
private string bgColor;
2021
private string textColor;
22+
private string lineColor;
23+
private float lineAmt;
2124
private float timer;
25+
private float scale;
2226

2327
public RoomNameController(EntityData data, Vector2 offset) : base(data.Position + offset)
2428
{
2529
Name = data.Attr("roomName");
2630
bgColor = data.Attr("backgroundColor", "000000FF");
2731
textColor = data.Attr("textColor", "FFFFFFFF");
32+
lineColor = data.Attr("outlineColor", "000000FF");
33+
lineAmt = data.Float("outlineThickness", 0f);
34+
scale = data.Float("scale", 1f);
35+
2836
timer = data.Float("disappearTimer", -1f);
2937
}
3038
public override void Awake(Scene scene)
3139
{
3240
base.Awake(scene);
3341
var display = RoomNameDisplay.GetDisplay(scene);
3442
display.SetName(Name);
35-
display.SetColor(Calc.HexToColorWithAlpha(textColor), Calc.HexToColorWithAlpha(bgColor));
43+
display.SetColor(textColor, bgColor, lineColor, lineAmt);
3644
display.SetTimer(Math.Max(timer, 0f));
45+
display.scale = scale;
3746
}
3847
}
3948
}

Code/RoomNameDisplay.cs

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ public class RoomNameDisplay : Entity
2121

2222
public Color bgColor;
2323
public Color textColor;
24+
private Color lineColor;
2425
private float colorLerp;
2526
private Color bgColorStart;
2627
private Color textColorStart;
28+
private Color lineColorStart;
29+
private float outline;
30+
private float nextOutline;
31+
32+
public float scale;
2733

2834
private float outTimer;
2935
public RoomNameDisplay() {
@@ -77,6 +83,7 @@ public override void Update()
7783
if (textLerp == 0f)
7884
{
7985
text = nextText;
86+
outline = nextOutline;
8087
}
8188
}
8289

@@ -98,21 +105,28 @@ public override void Update()
98105
public override void Render()
99106
{
100107
base.Render();
101-
var y = Calc.LerpClamp(1080f, 1032f, Ease.CubeOut(drawLerp));
108+
var y = Calc.LerpClamp(1080f, 1080f - (48f * scale), Ease.CubeOut(drawLerp));
102109
Color bgC = bgColor;
103110
if (colorLerp < 1f)
104111
{
105112
bgC = Color.Lerp(bgColorStart, bgColor, colorLerp);
106113
}
107-
Draw.Rect(-2f, y, 1920f + 4f, 48f + 2f, bgC);
114+
Draw.Rect(-2f, y, 1920f + 4f, (48f * scale) + 2f, bgC);
108115
if (text != "")
109116
{
110117
Color textC = textColor;
111118
if (colorLerp < 1f) {
112119
textC = Color.Lerp(textColorStart, textColor, colorLerp);
113120
}
114-
var texty = Calc.LerpClamp(1080f, 1032f, Ease.CubeOut(Calc.Min(textLerp, drawLerp)));
115-
ActiveFont.Draw(text, new Vector2(960, texty - 6f), new Vector2(0.5f, 0f), new Vector2(1f, 1f), textC);
121+
var texty = Calc.LerpClamp(1080f, 1080f - (48f * scale), Ease.CubeOut(Calc.Min(textLerp, drawLerp)));
122+
if (outline > 0f)
123+
{
124+
ActiveFont.DrawOutline(text, new Vector2(960, texty - 6f), new Vector2(0.5f, 0f), new Vector2(scale, scale), textC, outline, lineColor);
125+
}
126+
else
127+
{
128+
ActiveFont.Draw(text, new Vector2(960, texty - 6f), new Vector2(0.5f, 0f), new Vector2(scale, scale), textC);
129+
}
116130
}
117131
}
118132

@@ -128,17 +142,23 @@ public void SetName(string name)
128142
}
129143
}
130144

131-
public void SetColor(Color text, Color bg)
145+
public void SetColor(string textHex, string bgHex, string lineHex, float amt)
132146
{
147+
Color text = HexToColor(textHex);
148+
Color bg = HexToColor(bgHex);
149+
Color line = HexToColor(lineHex);
150+
133151
if (colorLerp < 1f)
134152
{
135153
bgColorStart = Color.Lerp(bgColorStart, bgColor, colorLerp);
136154
textColorStart = Color.Lerp(textColorStart, textColor, colorLerp);
155+
lineColorStart = Color.Lerp(lineColorStart, lineColor, colorLerp);
137156
}
138157
else
139158
{
140159
bgColorStart = bgColor;
141160
textColorStart = textColor;
161+
lineColorStart = lineColor;
142162
}
143163
colorLerp = 0f;
144164
if (drawLerp == 0f)
@@ -147,6 +167,25 @@ public void SetColor(Color text, Color bg)
147167
}
148168
bgColor = bg;
149169
textColor = text;
170+
lineColor = line;
171+
nextOutline = amt;
172+
}
173+
174+
// Calc.HexToColorWithAlpha does not work correctly
175+
// need to do it myself
176+
public Color HexToColor(string hex)
177+
{
178+
if (hex[0] == '#')
179+
{
180+
hex = hex.Substring(1);
181+
}
182+
Color color = Calc.HexToColor(hex);
183+
if (hex.Length == 6)
184+
{
185+
return color;
186+
}
187+
float alpha = (Calc.HexToByte(hex[6]) * 16 + Calc.HexToByte(hex[7])) / 255f;
188+
return color * alpha;
150189
}
151190

152191
public void SetTimer(float timer)

Code/RoomNameTrigger.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@ public class RoomNameTrigger : Trigger
1818
public string Name;
1919
private string bgColor;
2020
private string textColor;
21+
private string lineColor;
22+
private float lineAmt;
2123
private float timer;
2224
private bool oneUse;
2325
private bool instant;
26+
private float scale;
2427

2528
public RoomNameTrigger(EntityData data, Vector2 offset) : base(data, offset)
2629
{
2730
Name = data.Attr("roomName");
2831
bgColor = data.Attr("backgroundColor", "000000FF");
2932
textColor = data.Attr("textColor", "FFFFFFFF");
33+
lineColor = data.Attr("outlineColor", "000000FF");
34+
lineAmt = data.Float("outlineThickness", 0f);
35+
scale = data.Float("scale", 1f);
36+
3037
timer = data.Float("disappearTimer", -1f);
3138
oneUse = data.Bool("oneUse", false);
3239
instant = data.Bool("instant", false);
@@ -37,8 +44,9 @@ public override void OnEnter(Player player)
3744
base.OnEnter(player);
3845
var display = RoomNameDisplay.GetDisplay(player.Scene);
3946
display.SetName(Name);
40-
display.SetColor(Calc.HexToColorWithAlpha(textColor), Calc.HexToColorWithAlpha(bgColor));
47+
display.SetColor(textColor, bgColor, lineColor, lineAmt);
4148
display.SetTimer(Math.Max(timer, 0f));
49+
display.scale = scale;
4250
if (instant)
4351
{
4452
display.SetInstant();

Loenn/entities/room_name.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ roomName.placements = {
1111
backgroundColor = "000000FF",
1212
textColor = "FFFFFFFF",
1313
disappearTimer = -1,
14+
outlineColor = "000000FF",
15+
outlineThickness = 0,
16+
scale = 1,
1417
}
1518
}
1619
}
@@ -21,6 +24,12 @@ roomName.fieldInformation = {
2124
textColor = {
2225
fieldType = "color"
2326
},
27+
outlineColor = {
28+
fieldType = "color"
29+
},
30+
scale = {
31+
minimumValue = 0.01,
32+
},
2433
}
2534

2635
roomName.texture = "ahorn_roomname"

Loenn/lang/en_gb.lang

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ entities.vitellary/cassetteflags.attributes.description.greenFlag=The flag to en
303303
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.
304304
entities.vitellary/roomname.attributes.description.backgroundColor=The color of the rectangle behind the room name.
305305
entities.vitellary/roomname.attributes.description.textColor=The color of the room name text.
306+
entities.vitellary/roomname.attributes.description.outlineColor=The color of the text's outline, if it has one.
307+
entities.vitellary/roomname.attributes.description.outlineThickness=The size of the text's outline. 0 means it won't have one.
308+
entities.vitellary/roomname.attributes.description.scale=The scale multiplier of the room name.
306309
entities.vitellary/roomname.attributes.description.disappearTimer=The amount of time until the room name goes away. Negative values means the text won't disappear.
307310

308311
# Remote Trigger
@@ -402,6 +405,9 @@ triggers.vitellary/bombtimer.attributes.description.resetOnDeath=Whether the pla
402405
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.
403406
triggers.vitellary/roomnametrigger.attributes.description.backgroundColor=The color of the rectangle behind the room name.
404407
triggers.vitellary/roomnametrigger.attributes.description.textColor=The color of the room name text.
408+
triggers.vitellary/roomnametrigger.attributes.description.outlineColor=The color of the text's outline, if it has one.
409+
triggers.vitellary/roomnametrigger.attributes.description.outlineThickness=The size of the text's outline. 0 means it won't have one.
410+
triggers.vitellary/roomnametrigger.attributes.description.scale=The scale multiplier of the room name.
405411
triggers.vitellary/roomnametrigger.attributes.description.disappearTimer=The amount of time until the room name goes away. Negative values means the text won't disappear.
406412
triggers.vitellary/roomnametrigger.attributes.description.oneUse=Whether the trigger should only apply once.
407413
triggers.vitellary/roomnametrigger.attributes.description.instant=Whether the text and colors should instantly appear, rather than easing in.

Loenn/triggers/roomnametrigger.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ roomNameTrigger.placements = {
1010
backgroundColor = "000000FF",
1111
textColor = "FFFFFFFF",
1212
disappearTimer = -1,
13+
outlineColor = "000000FF",
14+
outlineThickness = 0,
15+
scale = 1,
1316
oneUse = false,
1417
instant = false,
1518
}
@@ -22,6 +25,12 @@ roomNameTrigger.fieldInformation = {
2225
textColor = {
2326
fieldType = "color"
2427
},
28+
outlineColor = {
29+
fieldType = "color"
30+
},
31+
scale = {
32+
minimumValue = 0.01,
33+
},
2534
}
2635

2736
return roomNameTrigger

0 commit comments

Comments
 (0)