Clean-up MapName.cpp

This commit is contained in:
Clownacy 2019-11-15 12:56:47 +00:00
parent 02f6972ef8
commit 0c245b995f
2 changed files with 21 additions and 21 deletions

View file

@ -6,6 +6,13 @@
#include "Draw.h" #include "Draw.h"
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
typedef struct MAP_NAME
{
BOOL flag;
int wait;
char name[0x20];
} MAP_NAME;
MAP_NAME gMapName; MAP_NAME gMapName;
RECT rc = { 0, 0, 160, 12 }; RECT rc = { 0, 0, 160, 12 };
@ -67,7 +74,7 @@ void ReadyMapName(const char *str)
}; };
// Reset map name flags // Reset map name flags
gMapName.flag = 0; gMapName.flag = FALSE;
gMapName.wait = 0; gMapName.wait = 0;
if (!strcmp(str, "u")) if (!strcmp(str, "u"))
@ -84,13 +91,13 @@ void ReadyMapName(const char *str)
// Draw the text to the surface // Draw the text to the surface
a = (int)strlen(gMapName.name); a = (int)strlen(gMapName.name);
CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
PutText2((160 - 6 * a) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); PutText2(((160 - (a * 6)) / 2) + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
PutText2((160 - 6 * a) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); PutText2(((160 - (a * 6)) / 2) + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
} }
void PutMapName(BOOL bMini) void PutMapName(BOOL bMini)
{ {
// 'unused_rect' isn't the original name. The Linux port optimised this out, so there's no name for it. // 'unused_rect' isn't the original name. The Linux port optimised this out, so there's no known name for it.
RECT unused_rect = {0, 0, 160, 16}; RECT unused_rect = {0, 0, 160, 16};
if (bMini) if (bMini)
@ -103,28 +110,28 @@ void PutMapName(BOOL bMini)
rcBack.bottom = 24; rcBack.bottom = 24;
CortBox(&rcBack, 0x000000); CortBox(&rcBack, 0x000000);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, 10, &rc, SURFACE_ID_ROOM_NAME); PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 86, 10, &rc, SURFACE_ID_ROOM_NAME);
} }
else if (gMapName.flag) else if (gMapName.flag)
{ {
// MNA // MNA
PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, (WINDOW_HEIGHT - 80) / 2, &rc, SURFACE_ID_ROOM_NAME); PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 86, (WINDOW_HEIGHT / 2) - 40, &rc, SURFACE_ID_ROOM_NAME);
if (++gMapName.wait > 160) if (++gMapName.wait > 160)
gMapName.flag = 0; gMapName.flag = FALSE;
} }
} }
void StartMapName() void StartMapName(void)
{ {
gMapName.flag = 1; gMapName.flag = TRUE;
gMapName.wait = 0; gMapName.wait = 0;
} }
void RestoreMapName() void RestoreMapName(void)
{ {
int len = (int)strlen(gMapName.name); int len = (int)strlen(gMapName.name);
CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
PutText2((160 - 6 * len) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); PutText2(((160 - (len * 6)) / 2) + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
PutText2((160 - 6 * len) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); PutText2(((160 - (len * 6)) / 2) + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
} }

View file

@ -2,14 +2,7 @@
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
struct MAP_NAME
{
int flag;
int wait;
char name[0x20];
};
void ReadyMapName(const char *str); void ReadyMapName(const char *str);
void PutMapName(BOOL bMini); void PutMapName(BOOL bMini);
void StartMapName(); void StartMapName(void);
void RestoreMapName(); void RestoreMapName(void);