Show info point messages.
This commit is contained in:
parent
fb5723d96e
commit
2543d469ac
|
@ -39,8 +39,6 @@ Entity *initInfoPoint(void)
|
||||||
s->flags |= EF_WEIGHTLESS | EF_IGNORE_BULLETS | EF_NO_CLIP | EF_NO_ENVIRONMENT;
|
s->flags |= EF_WEIGHTLESS | EF_IGNORE_BULLETS | EF_NO_CLIP | EF_NO_ENVIRONMENT;
|
||||||
|
|
||||||
s->ty = s->y;
|
s->ty = s->y;
|
||||||
|
|
||||||
s->firstTouch = 1;
|
|
||||||
|
|
||||||
s->init = init;
|
s->init = init;
|
||||||
s->tick = tick;
|
s->tick = tick;
|
||||||
|
@ -69,38 +67,12 @@ static void tick(void)
|
||||||
static void touch(Entity *other)
|
static void touch(Entity *other)
|
||||||
{
|
{
|
||||||
Structure *s;
|
Structure *s;
|
||||||
int showMessage;
|
|
||||||
|
|
||||||
s = (Structure*)self;
|
s = (Structure*)self;
|
||||||
|
|
||||||
if (other == (Entity*)world.bob)
|
if (other == (Entity*)world.bob)
|
||||||
{
|
{
|
||||||
showMessage = 0;
|
showInfoMessage(s->message);
|
||||||
|
|
||||||
if (s->firstTouch)
|
|
||||||
{
|
|
||||||
s->firstTouch = 0;
|
|
||||||
showMessage = 1;
|
|
||||||
s->messageTimer = FPS;
|
|
||||||
}
|
|
||||||
else if (world.bob->dx == 0 && world.bob->dy == 0 && world.bob->isOnGround)
|
|
||||||
{
|
|
||||||
s->messageTimer++;
|
|
||||||
|
|
||||||
if (s->messageTimer == FPS)
|
|
||||||
{
|
|
||||||
showMessage = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
s->messageTimer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showMessage)
|
|
||||||
{
|
|
||||||
showInfoMessage(s->message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,10 +83,6 @@ static void load(cJSON *root)
|
||||||
s = (Structure*)self;
|
s = (Structure*)self;
|
||||||
|
|
||||||
STRNCPY(s->message, cJSON_GetObjectItem(root, "message")->valuestring, MAX_DESCRIPTION_LENGTH);
|
STRNCPY(s->message, cJSON_GetObjectItem(root, "message")->valuestring, MAX_DESCRIPTION_LENGTH);
|
||||||
if (cJSON_GetObjectItem(root, "firstTouch"))
|
|
||||||
{
|
|
||||||
s->firstTouch = cJSON_GetObjectItem(root, "firstTouch")->valueint;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void save(cJSON *root)
|
static void save(cJSON *root)
|
||||||
|
@ -125,5 +93,4 @@ static void save(cJSON *root)
|
||||||
|
|
||||||
cJSON_AddStringToObject(root, "type", "InfoPoint");
|
cJSON_AddStringToObject(root, "type", "InfoPoint");
|
||||||
cJSON_AddStringToObject(root, "message", s->name);
|
cJSON_AddStringToObject(root, "message", s->name);
|
||||||
cJSON_AddNumberToObject(root, "firstTouch", s->firstTouch);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,8 +229,6 @@ struct Structure {
|
||||||
int closedX, closedY;
|
int closedX, closedY;
|
||||||
int isLocked;
|
int isLocked;
|
||||||
int speed;
|
int speed;
|
||||||
int messageTimer;
|
|
||||||
int firstTouch;
|
|
||||||
int requiredPower;
|
int requiredPower;
|
||||||
int isWeighted;
|
int isWeighted;
|
||||||
int weightApplied;
|
int weightApplied;
|
||||||
|
|
|
@ -24,10 +24,10 @@ static void drawHealth(void);
|
||||||
static void drawPower(void);
|
static void drawPower(void);
|
||||||
|
|
||||||
static int messageTime;
|
static int messageTime;
|
||||||
|
static int infoMessageTime;
|
||||||
static char message[MAX_DESCRIPTION_LENGTH];
|
static char message[MAX_DESCRIPTION_LENGTH];
|
||||||
static int messageType;
|
static int messageType;
|
||||||
static SDL_Color messageColor;
|
static SDL_Color messageColor;
|
||||||
|
|
||||||
static char infoMessage[MAX_DESCRIPTION_LENGTH];
|
static char infoMessage[MAX_DESCRIPTION_LENGTH];
|
||||||
|
|
||||||
void initHud(void)
|
void initHud(void)
|
||||||
|
@ -40,19 +40,21 @@ void initHud(void)
|
||||||
|
|
||||||
void doHud(void)
|
void doHud(void)
|
||||||
{
|
{
|
||||||
messageTime--;
|
if (--messageTime <= 0)
|
||||||
|
|
||||||
if (messageTime <= 0)
|
|
||||||
{
|
{
|
||||||
messageType = MSG_STANDARD;
|
messageType = MSG_STANDARD;
|
||||||
|
|
||||||
messageTime = 0;
|
messageTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (--infoMessageTime <= 0)
|
||||||
|
{
|
||||||
|
infoMessageTime = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawHud(void)
|
void drawHud(void)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y, h;
|
||||||
|
|
||||||
drawRect(0, 0, SCREEN_WIDTH, 32, 0, 0, 0, 200);
|
drawRect(0, 0, SCREEN_WIDTH, 32, 0, 0, 0, 200);
|
||||||
|
|
||||||
|
@ -69,6 +71,16 @@ void drawHud(void)
|
||||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 26, 16, TA_CENTER, messageColor, message);
|
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 26, 16, TA_CENTER, messageColor, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (infoMessageTime > 0)
|
||||||
|
{
|
||||||
|
limitTextWidth(500);
|
||||||
|
h = getWrappedTextHeight(infoMessage, 20) + 20;
|
||||||
|
drawRect((SCREEN_WIDTH / 2) - 300, 40, 600, h, 0, 0, 0, 168);
|
||||||
|
drawOutlineRect((SCREEN_WIDTH / 2) - 300, 40, 600, h, 192, 192, 192, 255);
|
||||||
|
drawText(SCREEN_WIDTH / 2, 50, 20, TA_CENTER, colors.white, infoMessage);
|
||||||
|
limitTextWidth(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (dev.debug)
|
if (dev.debug)
|
||||||
{
|
{
|
||||||
x = -camera.x + world.bob->x + (world.bob->w / 2);
|
x = -camera.x + world.bob->x + (world.bob->w / 2);
|
||||||
|
@ -150,6 +162,5 @@ void setGameplayMessage(int newMessageType, const char *format, ...)
|
||||||
void showInfoMessage(char *newInfoMessage)
|
void showInfoMessage(char *newInfoMessage)
|
||||||
{
|
{
|
||||||
STRNCPY(infoMessage, newInfoMessage, MAX_DESCRIPTION_LENGTH);
|
STRNCPY(infoMessage, newInfoMessage, MAX_DESCRIPTION_LENGTH);
|
||||||
|
infoMessageTime = FPS / 4;
|
||||||
showWidgetGroup("ok");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ extern void drawText(int x, int y, int size, int align, SDL_Color c, const char
|
||||||
extern void drawRect(int x, int y, int w, int h, int r, int g, int b, int a);
|
extern void drawRect(int x, int y, int w, int h, int r, int g, int b, int a);
|
||||||
const char *getWeaponName(int i);
|
const char *getWeaponName(int i);
|
||||||
extern void drawOutlineRect(int x, int y, int w, int h, int r, int g, int b, int a);
|
extern void drawOutlineRect(int x, int y, int w, int h, int r, int g, int b, int a);
|
||||||
|
extern void limitTextWidth(int width);
|
||||||
|
extern int getWrappedTextHeight(const char *text, int size);
|
||||||
|
|
||||||
extern Dev dev;
|
extern Dev dev;
|
||||||
extern Camera camera;
|
extern Camera camera;
|
||||||
|
|
|
@ -79,9 +79,6 @@ void initWorld(void)
|
||||||
app.delegate.draw = draw;
|
app.delegate.draw = draw;
|
||||||
|
|
||||||
startMission();
|
startMission();
|
||||||
|
|
||||||
world.bob->x = 90 * MAP_TILE_SIZE;
|
|
||||||
world.bob->y = 98 * MAP_TILE_SIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void logic(void)
|
static void logic(void)
|
||||||
|
|
Loading…
Reference in New Issue