mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Unify drawing room name on map menus into one function
Previously, it was copy-pasted and slightly different, when really, they ought to both be the exact same code. It kind of pains me that the room name, glitch name, and hidden name don't own their own memory, but, that's to be addressed later. What's a bit annoying is that the `temp` variable used in `teleporterrender` also ends up being reused later in the function. In this case, I opted to just redeclare them when they are used anyway, to make it clearer. Apart from `teleporterrender` no longer calling `map.area` or caring about `map.custommode`, it also no longer cares about `graphics.fademode` being 0. I could never actually get this condition to be false in practice, and I have absolutely no idea why it's there. I'm guessing it could be some weird edge case rendering issue if the screen is fully black? But I wouldn't know how to trigger that, and anyway it should probably be fixed elsewhere. So I'm just going to remove that conditional.
This commit is contained in:
parent
e16c1557fa
commit
af1cebf7a1
1 changed files with 27 additions and 29 deletions
|
@ -2013,6 +2013,26 @@ void gamerender(void)
|
|||
graphics.renderwithscreeneffects();
|
||||
}
|
||||
|
||||
static void draw_roomname_menu(void)
|
||||
{
|
||||
const char* name;
|
||||
|
||||
if (map.hiddenname[0] != '\0')
|
||||
{
|
||||
name = map.hiddenname;
|
||||
}
|
||||
else if (map.finalmode)
|
||||
{
|
||||
name = map.glitchname;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = map.roomname;
|
||||
}
|
||||
|
||||
graphics.Print(5, 2, name, 196, 196, 255 - help.glow, true);
|
||||
}
|
||||
|
||||
/* Used to keep some graphics positions on the map screen
|
||||
* the same in Flip Mode. */
|
||||
#define FLIP(y, h) (graphics.flipmode ? 220 - (y) - (h) : (y))
|
||||
|
@ -2021,20 +2041,7 @@ void maprender(void)
|
|||
{
|
||||
ClearSurface(graphics.backBuffer);
|
||||
|
||||
//draw screen alliteration
|
||||
//Roomname:
|
||||
if (map.hiddenname[0] != '\0')
|
||||
{
|
||||
graphics.Print(5, 2, map.hiddenname, 196, 196, 255 - help.glow, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (map.finalmode){
|
||||
graphics.Print(5, 2, map.glitchname, 196, 196, 255 - help.glow, true);
|
||||
}else{
|
||||
graphics.Print(5, 2, map.roomname, 196, 196, 255 - help.glow, true);
|
||||
}
|
||||
}
|
||||
draw_roomname_menu();
|
||||
|
||||
//Background color
|
||||
FillRect(graphics.backBuffer,0, 12, 320, 240, 10, 24, 26 );
|
||||
|
@ -2721,17 +2728,8 @@ void teleporterrender(void)
|
|||
ClearSurface(graphics.backBuffer);
|
||||
int tempx;
|
||||
int tempy;
|
||||
//draw screen alliteration
|
||||
//Roomname:
|
||||
int temp = map.area(game.roomx, game.roomy);
|
||||
if (temp < 2 && !map.custommode && graphics.fademode==0)
|
||||
{
|
||||
graphics.Print(5, 2, map.hiddenname, 196, 196, 255 - help.glow, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.Print(5, 2, map.roomname, 196, 196, 255 - help.glow, true);
|
||||
}
|
||||
|
||||
draw_roomname_menu();
|
||||
|
||||
//Background color
|
||||
FillRect(graphics.backBuffer, 0, 12, 320, 240, 10, 24, 26);
|
||||
|
@ -2778,13 +2776,13 @@ void teleporterrender(void)
|
|||
{
|
||||
if (map.showteleporters && map.isexplored(map.teleporters[i].x, map.teleporters[i].y))
|
||||
{
|
||||
temp = 1126 + (int) map.isexplored(map.teleporters[i].x, map.teleporters[i].y);
|
||||
int temp = 1126 + (int) map.isexplored(map.teleporters[i].x, map.teleporters[i].y);
|
||||
if (graphics.flipmode) temp += 3;
|
||||
graphics.drawtile(40 + 3 + (map.teleporters[i].x * 12), 22 + (map.teleporters[i].y * 9), temp);
|
||||
}
|
||||
else if(map.showtargets && !map.isexplored(map.teleporters[i].x, map.teleporters[i].y))
|
||||
{
|
||||
temp = 1126 + (int) map.isexplored(map.teleporters[i].x, map.teleporters[i].y);
|
||||
int temp = 1126 + (int) map.isexplored(map.teleporters[i].x, map.teleporters[i].y);
|
||||
if (graphics.flipmode) temp += 3;
|
||||
graphics.drawtile(40 + 3 + (map.teleporters[i].x * 12), 22 + (map.teleporters[i].y * 9), temp);
|
||||
}
|
||||
|
@ -2796,7 +2794,7 @@ void teleporterrender(void)
|
|||
{
|
||||
if (!obj.collect[i])
|
||||
{
|
||||
temp = 1086;
|
||||
int temp = 1086;
|
||||
if (graphics.flipmode) temp += 3;
|
||||
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
|
||||
}
|
||||
|
@ -2808,7 +2806,7 @@ void teleporterrender(void)
|
|||
if (game.useteleporter && ((help.slowsine%16)>8))
|
||||
{
|
||||
//colour in the legend
|
||||
temp = 1128;
|
||||
int temp = 1128;
|
||||
if (graphics.flipmode) temp += 3;
|
||||
graphics.drawtile(40 + 3 + (tempx * 12), 22 + (tempy * 9), temp);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue