Reduce mission list font size a little, to fit all missions in. Highlight mission on hover.

This commit is contained in:
Steve 2018-04-29 09:58:16 +01:00
parent 2ad4de22bf
commit 052f39fbad
1 changed files with 43 additions and 39 deletions

View File

@ -67,6 +67,7 @@ static int scrollingMap;
static int campaignComplete = 0; static int campaignComplete = 0;
static PointF cameraMin, cameraMax; static PointF cameraMin, cameraMax;
static Widget *startMissionButton; static Widget *startMissionButton;
static Mission *hoverMission;
static char *MISSIONS_TEXT; static char *MISSIONS_TEXT;
static char *PILOT_TEXT; static char *PILOT_TEXT;
static char *CRAFT_TEXT; static char *CRAFT_TEXT;
@ -115,6 +116,8 @@ void initGalacticMap(void)
updateCampaignProgress(); updateCampaignProgress();
hoverMission = NULL;
app.saveGame = 1; app.saveGame = 1;
pulseTimer = 0; pulseTimer = 0;
@ -321,7 +324,11 @@ static void doStarSystemView(void)
for (mission = selectedStarSystem->missionHead.next ; mission != NULL ; mission = mission->next) for (mission = selectedStarSystem->missionHead.next ; mission != NULL ; mission = mission->next)
{ {
if (mission->available && app.mouse.button[SDL_BUTTON_LEFT] && collision(app.mouse.x - app.mouse.w / 2, app.mouse.y - app.mouse.h / 2, app.mouse.w, app.mouse.h, mission->rect.x, mission->rect.y, mission->rect.w, mission->rect.h)) if (mission->available && collision(app.mouse.x - app.mouse.w / 2, app.mouse.y - app.mouse.h / 2, app.mouse.w, app.mouse.h, mission->rect.x, mission->rect.y, mission->rect.w, mission->rect.h))
{
hoverMission = mission;
if (app.mouse.button[SDL_BUTTON_LEFT])
{ {
if (game.currentMission != mission) if (game.currentMission != mission)
{ {
@ -332,6 +339,7 @@ static void doStarSystemView(void)
return; return;
} }
} }
}
/* allow closing by pressing the right mouse button */ /* allow closing by pressing the right mouse button */
if (app.mouse.button[SDL_BUTTON_RIGHT]) if (app.mouse.button[SDL_BUTTON_RIGHT])
@ -619,7 +627,7 @@ static Mission *nextAvailableMission(StarSystem *starSystem)
static void drawStarSystemDetail(void) static void drawStarSystemDetail(void)
{ {
int y, start, i; int y;
Mission *mission; Mission *mission;
SDL_Rect r; SDL_Rect r;
@ -647,22 +655,21 @@ static void drawStarSystemDetail(void)
y += 80; y += 80;
/*
* this only really counts for Alba, as it has 10 missions and there's only space for 9 to display.
* We need to subtract 1 from the completed missions to get the correct number (mission at the bottom will be the one to select).
*/
start = MAX(selectedStarSystem->availableMissions - MAX_LISTED_MISSIONS, 0);
i = 0;
for (mission = selectedStarSystem->missionHead.next ; mission != NULL ; mission = mission->next) for (mission = selectedStarSystem->missionHead.next ; mission != NULL ; mission = mission->next)
{
if (i >= start)
{ {
mission->rect.x = 200; mission->rect.x = 200;
mission->rect.y = y - 2; mission->rect.y = y - 2;
mission->rect.w = 300; mission->rect.w = 300;
mission->rect.h = 40; mission->rect.h = 38;
if (mission == hoverMission)
{
SDL_SetRenderDrawColor(app.renderer, 16, 32, 64, 255);
SDL_RenderFillRect(app.renderer, &mission->rect);
SDL_SetRenderDrawColor(app.renderer, 32, 64, 128, 255);
SDL_RenderDrawRect(app.renderer, &mission->rect);
}
if (mission == game.currentMission) if (mission == game.currentMission)
{ {
@ -675,15 +682,12 @@ static void drawStarSystemDetail(void)
if (mission->available) if (mission->available)
{ {
drawText(210, y, 24, TA_LEFT, mission->completed ? colors.lightGrey : colors.yellow, mission->name); drawText(210, y, 22, TA_LEFT, mission->completed ? colors.lightGrey : colors.yellow, mission->name);
y += 50; y += 42;
} }
} }
i++;
}
if (game.currentMission->available) if (game.currentMission->available)
{ {
drawText(525, 135, 18, TA_LEFT, colors.lightGrey, PILOT_TEXT, game.currentMission->pilot); drawText(525, 135, 18, TA_LEFT, colors.lightGrey, PILOT_TEXT, game.currentMission->pilot);