From 1b4bea7b1f408e24b29990206a5c4c45a02d601c Mon Sep 17 00:00:00 2001 From: Allanis Date: Thu, 7 Mar 2013 14:11:02 +0000 Subject: [PATCH] [Add] Visualization and description of ships in the shipyard. --- dat/ship.xml | 9 +++++++++ src/land.c | 40 ++++++++++++++++++++++++++++++++++------ src/ship.c | 6 ++++++ src/ship.h | 3 +++ src/toolkit.c | 3 +-- 5 files changed, 53 insertions(+), 8 deletions(-) diff --git a/dat/ship.xml b/dat/ship.xml index 05e75b7..2408af9 100644 --- a/dat/ship.xml +++ b/dat/ship.xml @@ -6,6 +6,8 @@ engine 1 120000 + KonoGroup + One of the most widely used ships in the galaxy. Reknown for it's stability and stubborness. The design hasn't been modified much since it's creation many years ago. It was one of the first civilian used spacecrafts, first used by the aristocracy and now used by everyone who cannot afford better. 320 150 @@ -35,6 +37,8 @@ engine 1 180000 + SaraCraft + The star product of SaraCraft, the leapard has quickly become a favourite of pirates far and wide. Not much of a fighter, nor does it pack too much of a punch, but they like to come in swarms to overcome their enemies. While the SaraCraft official stance doesn't sell them to shady characters, it's widely known that they do as it seems there's a countless amount in the hands of pirates. 400 180 @@ -64,6 +68,9 @@ engine 2 600000 + VLSoft + On of VLSoft's prize heavey fighters. Was originally a secret design for the Empire military, but then disclosed. Now a modified version is available for civilians, although it doesn't meet up to the original specifications. + Used by security agencies all over the universe for it's reliability and availability. Proudly enforcing your security since STARDATE. 320 150 @@ -95,6 +102,8 @@ engine 2 900000 + VLSoft + A heavy liner specialized in freighting cargo all over the universe. Also has good accomodations for passengers depending on the model, allowing for enjoyable curises. Was a favourite target of pirates until they added stick turrets to the new models which can now defend themselves effectively. 180 100 diff --git a/src/land.c b/src/land.c index 2ee60d2..054e893 100644 --- a/src/land.c +++ b/src/land.c @@ -52,6 +52,7 @@ static void outfits_close(char* str); static void shipyard(void); static void shipyard_close(char* str); static void shipyard_update(char* str); +static void shipyard_info(char* str); // Spaceport bar. static void spaceport_bar(void); static void spaceport_bar_close(char* str); @@ -115,15 +116,29 @@ static void shipyard(void) { BUTTON_WIDTH, BUTTON_HEIGHT, "btnBuyShip", "Buy", NULL); - window_addText(secondary_wid, 20+200+20, -160, - SHIPYARD_WIDTH-260, 200, 0, "txtDescription", - &gl_defFont, &cConsole, NULL); + window_addButton(secondary_wid, -40-BUTTON_WIDTH, 40+BUTTON_HEIGHT, + BUTTON_WIDTH, BUTTON_HEIGHT, "btnInfoShip", + "Info", shipyard_info); + + window_addRect(secondary_wid, 20+200+60, -50, + 128, 96, "rctTarget", &cBlack, 0); + + window_addImage(secondary_wid, 20+200+60, -50-96, + "imgTarget", NULL); + + + window_addText(secondary_wid, 20+200+40, -160, + SHIPYARD_WIDTH-360, 200, 0, "txtDescription", + &gl_smallFont, NULL, NULL); // Setup the ships to buy/sell. ships = ship_getAll(&nships); window_addList(secondary_wid, 20, 40, 200, SHIPYARD_HEIGHT-120, "lstShipyard", ships, nships, 0, shipyard_update); + + // Write the shipyard stuff. + shipyard_update(NULL); } static void shipyard_close(char* str) { @@ -133,9 +148,22 @@ static void shipyard_close(char* str) { static void shipyard_update(char* str) { (void)str; - char* tship; + char* shipname; + Ship* ship; - tship = toolkit_getList(secondary_wid, "lstShipyard"); + shipname = toolkit_getList(secondary_wid, "lstShipyard"); + ship = ship_get(shipname); + + window_modifyText(secondary_wid, "txtDescription", ship->description); + window_modifyImage(secondary_wid, "imgTarget", ship->gfx_target); +} + +static void shipyard_info(char* str) { + (void)str; + char* shipname; + + shipname = toolkit_getList(secondary_wid, "lstShipyard"); + ship_view(shipname); } // Spaceport bar. @@ -185,7 +213,7 @@ void land(Planet* p) { land_wid = window_create(p->name, -1, -1, LAND_WIDTH, LAND_HEIGHT); // Pretty display. - window_addImage(land_wid, 20, -440, "imgPlanet", p->gfx_exterior); + window_addImage(land_wid, 20, -40, "imgPlanet", p->gfx_exterior); window_addText(land_wid, 440, 80, 200, 460, 0, "txtPlanetDesc", &gl_smallFont, &cBlack, p->description); // Buttons. diff --git a/src/ship.c b/src/ship.c index 2987cfc..486f6a9 100644 --- a/src/ship.c +++ b/src/ship.c @@ -93,6 +93,10 @@ static Ship* ship_parse(xmlNodePtr parent) { tmp->class = xml_getInt(node); else if(xml_isNode(node, "price")) tmp->price = xml_getInt(node); + else if(xml_isNode(node, "fabricator")) + tmp->fabricator = strdup(xml_get(node)); + else if(xml_isNode(node, "description")) + tmp->description = strdup(xml_get(node)); else if(xml_isNode(node, "movement")) { cur = node->children; do { @@ -165,6 +169,8 @@ static Ship* ship_parse(xmlNodePtr parent) { MELEMENT(tmp->gui == NULL, "GUI"); MELEMENT(tmp->class==0, "class"); MELEMENT(tmp->price==0, "price"); + MELEMENT(tmp->fabricator==0, "fabricator"); + MELEMENT(tmp->description==0, "description"); MELEMENT(tmp->thrust==0, "thrust"); MELEMENT(tmp->turn==0, "turn"); MELEMENT(tmp->speed==0, "speed"); diff --git a/src/ship.h b/src/ship.h index 7920e91..374a99f 100644 --- a/src/ship.h +++ b/src/ship.h @@ -27,7 +27,10 @@ typedef struct Ship_ { char* name; // Ship name. ShipClass class; // Ship class. + // Store stuff. unsigned int price; // Price! + char* fabricator; // Manufacturer. + char* description; // Sales pitch. // Movement. double thrust, turn, speed; diff --git a/src/toolkit.c b/src/toolkit.c index 7de1b27..12807c2 100644 --- a/src/toolkit.c +++ b/src/toolkit.c @@ -181,8 +181,7 @@ void window_addImage(const unsigned int wid, const int x, const int y, wgt->h = (image == NULL) ? 0 : wgt->dat.img.image->sh; if(x < 0) wgt->x = wdw->w - wgt->w + x; else wgt->x = (double)x; - if(y < 0) wgt->y = wdw->h + y; - //if(y < 0) wgt->y = wdw->h - wgt->h + y; + if(y < 0) wgt->y = wdw->h - wgt->h + y; else wgt->y = (double)y; }