Animated roomnames, setroomname command

This commit adds a better system for animated roomnames.

The old system, like many other systems, were very hardcoded, and can be
described as mostly else-if chains, with some fun string comparisons.
The new system uses lists of text for transformations and glitchy names,
making it much easier to add new cases if needeed.

This commit implements the system but does not replace the old system,
where that is done in the next commit.

The settings for special roomnames can be read from level XML, and
`setroomname()` can be used from commands to set a new, static name.
This commit is contained in:
AllyTally authored and Misa Elizabeth Kai committed 2023-03-02 22:58:12 -08:00
1 parent 27da7fe935
commit dd108a035f
6 files changed
+172 -1

No files matched your search

+56
View File
@@ -88,6 +88,8 @@ mapclass::mapclass(void)
hiddenname = "";
roomname_special = false;
specialroomnames.clear();
roomnameset = false;
}
static char roomname_static[SCREEN_WIDTH_CHARS];
@@ -396,6 +398,59 @@ void mapclass::transformname(int t)
}
}
void mapclass::updateroomnames(void)
{
if (roomnameset)
{
return;
}
const int rx = game.roomx - 100;
const int ry = game.roomy - 100;
for (int i = specialroomnames.size() - 1; i >= 0; i--)
{
Roomname &roomname = specialroomnames[i];
if (rx == roomname.x && ry == roomname.y && (roomname.flag == -1 || (INBOUNDS_ARR(roomname.flag, obj.flags) && obj.flags[roomname.flag])))
{
roomname_special = true;
if (roomname.type == STATIC)
{
setroomname(roomname.text[0].c_str());
}
if (roomname.type == GLITCH)
{
roomname.delay--;
if (roomname.delay <= 0)
{
roomname.progress = (roomname.progress + 1) % 2;
roomname.delay = 5;
if (roomname.progress == 0)
{
roomname.delay = 25 + (int) (fRandom() * 10);
}
}
setroomname(roomname.text[roomname.progress].c_str());
}
if (roomname.type == TRANSFORM)
{
roomname.delay--;
if (roomname.delay <= 0)
{
roomname.progress++;
roomname.delay = 2;
if (roomname.progress >= roomname.text.size())
{
roomname.progress = roomname.loop ? 0 : roomname.text.size() - 1;
}
}
setroomname(roomname.text[roomname.progress].c_str());
}
break;
}
}
}
const char* mapclass::getglitchname(int x, int y)
{
//Returns the name in the final area.
@@ -1414,6 +1469,7 @@ void mapclass::loadlevel(int rx, int ry)
roomtexton = false;
roomtext.clear();
roomnameset = false;
obj.platformtile = 0;
obj.customplatformtile=0;