From 2c388ea1b0679131be33f9b487b0d50e3a15289e Mon Sep 17 00:00:00 2001 From: Allanis Date: Tue, 19 Feb 2013 19:13:24 +0000 Subject: [PATCH] [Add] News window and the concept of fuel. --- src/land.c | 42 +++++++++++++++++++++++++++++++++--------- src/pilot.h | 1 + 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/land.c b/src/land.c index 845f28a..a6013e1 100644 --- a/src/land.c +++ b/src/land.c @@ -2,14 +2,20 @@ #include "pause.h" #include "land.h" +// Global/main window. #define LAND_WIDTH 700 #define LAND_HEIGHT 600 #define BUTTON_WIDTH 200 #define BUTTON_HEIGHT 40 +// News window. +#define NEWS_WIDTH 400 +#define NEWS_HEIGHT 400 + int landed = 0; -static int land_wid = 0; +static int land_wid = 0; // Primary land window. +static int secondary_wid = 0; // For the second opened land window (We can only have 2 max). static Planet* planet = NULL; static void commodity_exchange(coid); @@ -17,6 +23,7 @@ static void outfits(void); static void shipyard(void); static void spaceport_bar(void); static void news(void); +static void news_close(char* str); static void commodity_exchange(void) { @@ -35,7 +42,24 @@ static void spaceport_bar(void) { } static void news(void) { + secondary_wid = window_create(-1, -1, NEWS_WIDTH, NEWS_HEIGHT); + // Window title. + window_addText(secondary_wid, 0, -20, NEWS_WIDTH, 0, 1, + "txtTitle", NULL, &cBlack, "News Reports"); + + window_addText(secondary_wid, 20, 20 + BUTTON_HEIGHT + 20, + NEWS_WIDTH-40, NEWS_HEIGHT - 20 - BUTTON_HEIGHT - 20 - 20 -20, + 0, "txtNews", &gl_smallFont, &cBlack, + "News reporters report that they are on strike right now! D:"); + + window_addButton(secondary_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, + "btnCloseNews", "Close", news_close); +} + +static void news_close(char* str) { + if(strcmp(str, "btnCloseNews")==0) + window_destroy(secondary_wid); } // Land the player. @@ -45,34 +69,34 @@ void land(Planet* p) { land_wid = window_create(-1, -1, LAND_WIDTH, LAND_HEIGHT); // Pretty display. - window_addText(land_wid, 0., -20., LAND_WIDTH, 0, 1, "txtPlanet", NULL, &cBlack, p->name); - window_addImage(land_wid, 20., -440, "imgPlanet", p->gfx_exterior); - window_addText(land_wid, 440., 80., 200., 460., 0, + window_addText(land_wid, 0., -20, LAND_WIDTH, 0, 1, "txtPlanet", NULL, &cBlack, p->name); + window_addImage(land_wid, 20, -440, "imgPlanet", p->gfx_exterior); + window_addText(land_wid, 440, 80, 200, 460, 0, "txtPlanetDesc", &gl_smallFont, &cBlack, p->description); // Buttons. window_addButton(land_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnTakeoff", "Takeoff", (void(*)(char*))takeoff); if(planet_hasService(planet, PLANET_SERVICE_COMMODITY)) - window_addButton(land_wid, -20., 20. + BUTTON_HEIGHT + 20., + window_addButton(land_wid, -20, 20 + BUTTON_HEIGHT + 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnCommodity", "Commodity Exchange", (void(*)(char*))commodity_exchange); if(planet_hasService(planet, PLANET_SERVICE_SHIPYARD)) - window_addButton(land_wid, -20. - BUTTON_WIDTH - 20., 20., + window_addButton(land_wid, -20 - BUTTON_WIDTH - 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnShipyard", "Shipyard", (void(*)(char*))shipyard); if(planet_hasService(planet, PLANET_SERVICE_OUTFITS)) - window_addButton(land_wid, -20. - BUTTON_WIDTH - 20., 20. + BUTTON_HEIGHT + 20., + window_addButton(land_wid, -20 - BUTTON_WIDTH - 20, 20 + BUTTON_HEIGHT + 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnOutfits", "Outfits", (void(*)(char*))outfits); if(planet_hasService(planet, PLANET_SERVICE_BASIC)) - window_addButton(land_wid, 20., 20., + window_addButton(land_wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnNews", "News", (void(*)(char*))news); - window_addButton(land_wid, 20., 20. + BUTTON_HEIGHT + 20., + window_addButton(land_wid, 20, 20 + BUTTON_HEIGHT + 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnBar", "SpaceBar", (void(*)(char*))spaceport_bar); diff --git a/src/pilot.h b/src/pilot.h index 2e75bf1..b80517c 100644 --- a/src/pilot.h +++ b/src/pilot.h @@ -47,6 +47,7 @@ typedef struct Pilot { // Current health. double armour, shield, energy; double armour_max, shield_max, energy_max; + double fuel; // Used only for jumps. TODO: make it do something. void (*think)(struct Pilot*); // AI thinking for the pilot. void (*update)(struct Pilot*, const double); // Update the pilot.