[Add] Map informs you of available services.

This commit is contained in:
Allanis 2013-07-23 20:59:02 +01:00
parent cf1bf0d647
commit cf5f8c8c48

View File

@ -79,6 +79,9 @@ void map_open(void) {
* Planets: * Planets:
* $Planet1, $Planet2, ... * $Planet1, $Planet2, ...
* *
* Services:
* $Services
*
* ... * ...
* *
* [Close] * [Close]
@ -96,17 +99,24 @@ void map_open(void) {
&gl_smallFont, &cBlack, NULL); &gl_smallFont, &cBlack, NULL);
/* Standing. */ /* Standing. */
window_addText(map_wid, -20, -110, 90, 20, 0, "txtSStanding", window_addText(map_wid, -20, -100, 90, 20, 0, "txtSStanding",
&gl_smallFont, &cDConsole, "Standing:"); &gl_smallFont, &cDConsole, "Standing:");
window_addText(map_wid, -20, -110-gl_smallFont.h-5, 80, 100, 0, "txtStanding", window_addText(map_wid, -20, -100-gl_smallFont.h-5, 80, 100, 0, "txtStanding",
&gl_smallFont, &cBlack, NULL); &gl_smallFont, &cBlack, NULL);
/* Planets. */ /* Planets. */
window_addText(map_wid, -20, -150, 90, 20, 0, "txtSPlanets", window_addText(map_wid, -20, -140, 90, 20, 0, "txtSPlanets",
&gl_smallFont, &cDConsole, "Planets:"); &gl_smallFont, &cDConsole, "Planets:");
window_addText(map_wid, -20, -150-gl_smallFont.h-5, 80, 100, 0, "txtPlanets", window_addText(map_wid, -20, -140-gl_smallFont.h-5, 80, 100, 0, "txtPlanets",
&gl_smallFont, &cBlack, NULL);
/* Services. */
window_addText(map_wid, -20, -180, 90, 20, 0, "txtSServices",
&gl_smallFont, &cDConsole, "Services:");
window_addText(map_wid, -20, -180-gl_smallFont.h-5, 80, 100, 0, "txtServices",
&gl_smallFont, &cBlack, NULL); &gl_smallFont, &cBlack, NULL);
/* Close button. */ /* Close button. */
@ -143,16 +153,23 @@ static void map_close(char* str) {
static void map_update(void) { static void map_update(void) {
int i; int i;
StarSystem* sys; StarSystem* sys;
int f, standing, nstanding; int f, y, h, standing, nstanding;
unsigned int services;
char buf[128]; char buf[128];
sys = &systems_stack[map_selected]; sys = &systems_stack[map_selected];
/* Right text. */
if(!sys_isKnown(sys)) { /* System isn't known. Erase all. */ if(!sys_isKnown(sys)) { /* System isn't known. Erase all. */
window_modifyText(map_wid, "txtSysname", "Unknown"); window_modifyText(map_wid, "txtSysname", "Unknown");
window_modifyText(map_wid, "txtFaction", "Unknown"); window_modifyText(map_wid, "txtFaction", "Unknown");
window_modifyText(map_wid, "txtStanding", "Unknown"); window_modifyText(map_wid, "txtStanding", "Unknown");
window_modifyText(map_wid, "txtPlanets", "Unknown"); window_modifyText(map_wid, "txtPlanets", "Unknown");
window_moveWidget(map_wid, "txtSServices", -20, -180);
window_moveWidget(map_wid, "txtServices", -20, -180-gl_smallFont.h-5);
window_modifyText(map_wid, "txtServices", "Unknown");
window_modifyText(map_wid, "txtSystemStatus", NULL);
return; return;
} }
@ -202,6 +219,24 @@ static void map_update(void) {
window_modifyText(map_wid, "txtPlanets", buf); window_modifyText(map_wid, "txtPlanets", buf);
} }
/* Get the services. */
h = gl_printHeight(&gl_smallFont, 90, buf);
y = -180 - (h - gl_smallFont.h);
window_moveWidget(map_wid, "txtSServices", -20, y);
y -= gl_smallFont.h+5;
window_moveWidget(map_wid, "txtServices", -20, y);
services = 0;
for(i = 0; i < sys->nplanets; i++)
services |= sys->planets[i].services;
buf[0] = '\0';
if(services & PLANET_SERVICE_COMMODITY)
strcat(buf, "Commodity\n");
if(services & PLANET_SERVICE_OUTFITS)
strcat(buf, "Outfits\n");
if(services & PLANET_SERVICE_SHIPYARD)
strcat(buf, "Shipyard\n");
window_modifyText(map_wid, "txtServices", buf);
/* System status. */ /* System status. */
buf[0] = '\0'; buf[0] = '\0';
if(sys->nebu_density > 0.) { /* Has nebulae. */ if(sys->nebu_density > 0.) { /* Has nebulae. */