2011-08-24 14:14:44 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2003 Parallel Realities
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
#include "Starfighter.h"
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
void updateCommsSurface(SDL_Surface *comms)
|
|
|
|
{
|
|
|
|
if (engine.commsSection == 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
char string[255];
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blevelRect(comms, 0, 10, comms->w - 1, 55, 0x00, 0x22, 0x00);
|
|
|
|
blit(shape[FACE_CHRIS], 20, 15, comms);
|
|
|
|
drawString("Chris Bainfield", 80, 15, FONT_WHITE, comms);
|
2011-08-24 14:14:44 +02:00
|
|
|
sprintf(string, "Current Location: %s", systemPlanet[currentGame.stationedPlanet].name);
|
2011-08-26 23:53:46 +02:00
|
|
|
drawString(string, 80, 35, FONT_WHITE, comms);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void createCommsSurface(SDL_Surface *comms)
|
|
|
|
{
|
|
|
|
engine.commsSection = 0;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blevelRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-28 12:28:05 +02:00
|
|
|
drawString("+++ RECEIVED MESSAGES +++", 115, 80, FONT_GREEN, comms);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
int yOffset;
|
|
|
|
|
|
|
|
for (int i = 0 ; i < 10 ; i++)
|
|
|
|
{
|
|
|
|
if ((systemPlanet[i].messageSlot != -1) && (systemPlanet[i].missionCompleted == 0))
|
|
|
|
{
|
|
|
|
yOffset = systemPlanet[i].messageSlot * 60;
|
2011-08-26 23:53:46 +02:00
|
|
|
blevelRect(comms, 0, 105 + yOffset, comms->w - 1, 55, 0x00, 0x00, 0x77);
|
|
|
|
blit(shape[systemPlanet[i].faceImage], 20, 110 + yOffset, comms);
|
|
|
|
drawString(systemPlanet[i].from, 80, 110 + yOffset, FONT_WHITE, comms);
|
|
|
|
drawString(systemPlanet[i].subject, 80, 130 + yOffset, FONT_CYAN, comms);
|
|
|
|
drawString("INCOMPLETE", 350, 110 + yOffset, FONT_RED, comms);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateCommsSurface(comms);
|
|
|
|
}
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
char name[50];
|
|
|
|
char string[2000];
|
|
|
|
int lines = 0;
|
|
|
|
int y = 50;
|
|
|
|
int newY = y;
|
|
|
|
int col = FONT_WHITE;
|
|
|
|
int mission = -1;
|
|
|
|
int faceNumber = -1;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
for (int i = 0 ; i < 10 ; i++)
|
|
|
|
{
|
|
|
|
if ((systemPlanet[i].messageSlot == missionSlot) && (systemPlanet[i].missionCompleted == 0))
|
|
|
|
{
|
|
|
|
mission = systemPlanet[i].messageMission;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mission == -1)
|
|
|
|
return;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blevelRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
sprintf(string, "data/brief%d.txt", mission);
|
|
|
|
|
|
|
|
#if USEPACK
|
|
|
|
int dataLocation = locateDataInPak(string, 1);
|
|
|
|
fp = fopen(PACKLOCATION, "rb");
|
|
|
|
fseek(fp, dataLocation, SEEK_SET);
|
|
|
|
#else
|
|
|
|
fp = fopen(string, "rb");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
fscanf(fp, "%[^\n]%*c", name);
|
|
|
|
sprintf(string, "+++ Communication with %s +++", name);
|
2011-08-26 23:53:46 +02:00
|
|
|
drawString(string, -1, 20, FONT_GREEN, comms);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
fscanf(fp, "%d%*c", &lines);
|
|
|
|
|
|
|
|
for (int i = 0 ; i < lines ; i++)
|
|
|
|
{
|
|
|
|
fscanf(fp, "%[^\n]%*c", string);
|
|
|
|
faceNumber = getFace(string);
|
|
|
|
if (faceNumber > -1)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(shape[faceNumber], 10, y, comms);
|
2011-08-24 14:14:44 +02:00
|
|
|
col = FONT_WHITE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
newY = drawString(string, 80, y, col, 1, comms) + 25;
|
2011-08-24 14:14:44 +02:00
|
|
|
if (newY < y + 60)
|
|
|
|
newY += (60 - (newY - y));
|
|
|
|
y = newY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blevelRect(comms, 5, comms->h - 28, 180, 20, 0x25, 0x00, 0x00);
|
|
|
|
drawString("RETURN TO MESSAGES", 15, comms->h - 25, FONT_WHITE, 1, comms);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
engine.commsSection = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void doComms(SDL_Surface *comms)
|
|
|
|
{
|
|
|
|
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]))
|
|
|
|
{
|
|
|
|
if (engine.commsSection == 0)
|
|
|
|
{
|
|
|
|
for (int i = 0 ; i < 4 ; i++)
|
|
|
|
{
|
2011-08-26 23:27:16 +02:00
|
|
|
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 170, 180 + (i * 60), 430, 50))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
createMissionDetailSurface(comms, i);
|
|
|
|
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-26 23:27:16 +02:00
|
|
|
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 170, 440, 160, 20))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
createCommsSurface(comms);
|
|
|
|
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|