Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/Deiz/naev into slots
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Apr 8, 2012
2 parents d4676e4 + 54769da commit d6e2818
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 32 deletions.
2 changes: 1 addition & 1 deletion dat/outfits/launchers/teracom_imperator_launcher.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<license>Heavy Weapon License</license> <license>Heavy Weapon License</license>
<mass>40</mass> <mass>40</mass>
<price>220000</price> <price>220000</price>
<description> The Imperator launcher is a very heavy torpedo launcher that is both bulky and demanding, but whose raw firepower is a must for any captain looking to blow up some capital ships.</description> <description>The Imperator launcher is a very heavy torpedo launcher that is both bulky and demanding, but whose raw firepower is a must for any captain looking to blow up some capital ships.</description>
<gfx_store>caesarlauncher</gfx_store> <gfx_store>caesarlauncher</gfx_store>
</general> </general>
<specific type="launcher" secondary="1"> <specific type="launcher" secondary="1">
Expand Down
38 changes: 30 additions & 8 deletions src/land_outfits.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "player_gui.h" #include "player_gui.h"
#include "toolkit.h" #include "toolkit.h"
#include "dialogue.h" #include "dialogue.h"
#include "map_find.h"




/* Modifier for buying and selling quantity. */ /* Modifier for buying and selling quantity. */
Expand All @@ -43,6 +44,7 @@ static void outfits_sell( unsigned int wid, char* str );
static int outfits_getMod (void); static int outfits_getMod (void);
static void outfits_renderMod( double bx, double by, double w, double h, void *data ); static void outfits_renderMod( double bx, double by, double w, double h, void *data );
static void outfits_rmouse( unsigned int wid, char* widget_name ); static void outfits_rmouse( unsigned int wid, char* widget_name );
static void outfits_find( unsigned int wid, char* str );




/** /**
Expand All @@ -51,6 +53,8 @@ static void outfits_rmouse( unsigned int wid, char* widget_name );
static void outfits_getSize( unsigned int wid, int *w, int *h, static void outfits_getSize( unsigned int wid, int *w, int *h,
int *iw, int *ih, int *bw, int *bh ) int *iw, int *ih, int *bw, int *bh )
{ {
int padding;

/* Get window dimensions. */ /* Get window dimensions. */
window_dimWindow( wid, w, h ); window_dimWindow( wid, w, h );


Expand All @@ -60,9 +64,12 @@ static void outfits_getSize( unsigned int wid, int *w, int *h,
if (ih != NULL) if (ih != NULL)
*ih = *h - 60; *ih = *h - 60;


/* Left padding + per-button padding * nbuttons */
padding = 40 + 20 * 4;

/* Calculate button dimensions. */ /* Calculate button dimensions. */
if (bw != NULL) if (bw != NULL)
*bw = (*w - (iw!=NULL?*iw:0) - 100) / 3; *bw = (*w - (iw!=NULL?*iw:0) - padding) / 4;
if (bh != NULL) if (bh != NULL)
*bh = LAND_BUTTON_HEIGHT; *bh = LAND_BUTTON_HEIGHT;
} }
Expand All @@ -81,7 +88,7 @@ void outfits_open( unsigned int wid )
int noutfits; int noutfits;
int w, h; int w, h;
int iw, ih; int iw, ih;
int bw, bh; int bw, bh, off;
glColour *bg, blend; glColour *bg, blend;
const glColour *c; const glColour *c;
char **slottype; char **slottype;
Expand All @@ -94,15 +101,18 @@ void outfits_open( unsigned int wid )
window_setAccept( wid, outfits_buy ); window_setAccept( wid, outfits_buy );


/* buttons */ /* buttons */
window_addButtonKey( wid, -20, 20, window_addButtonKey( wid, off = -20, 20,
bw, bh, "btnCloseOutfits", bw, bh, "btnCloseOutfits",
"Take Off", land_buttonTakeoff, SDLK_t ); "Take Off", land_buttonTakeoff, SDLK_t );
window_addButtonKey( wid, -40-bw, 20, window_addButtonKey( wid, off -= 20+bw, 20,
bw, bh, "btnSellOutfit", bw, bh, "btnSellOutfit",
"Sell", outfits_sell, SDLK_s ); "Sell", outfits_sell, SDLK_s );
window_addButtonKey( wid, -60-bw*2, 20, window_addButtonKey( wid, off -= 20+bw, 20,
bw, bh, "btnBuyOutfit", bw, bh, "btnBuyOutfit",
"Buy", outfits_buy, SDLK_b ); "Buy", outfits_buy, SDLK_b );
window_addButtonKey( wid, off -= 20+bw, 20,
bw, bh, "btnFindOutfits",
"Find Outfits", outfits_find, SDLK_f );


/* fancy 128x128 image */ /* fancy 128x128 image */
window_addRect( wid, 19 + iw + 20, -50, 128, 129, "rctImage", &cBlack, 0 ); window_addRect( wid, 19 + iw + 20, -50, 128, 129, "rctImage", &cBlack, 0 );
Expand All @@ -114,9 +124,9 @@ void outfits_open( unsigned int wid )


/* the descriptive text */ /* the descriptive text */
window_addText( wid, 20 + iw + 20 + 128 + 20, -60, window_addText( wid, 20 + iw + 20 + 128 + 20, -60,
320, 160, 0, "txtOutfitName", &gl_defFont, &cBlack, NULL ); 280, 160, 0, "txtOutfitName", &gl_defFont, &cBlack, NULL );
window_addText( wid, 20 + iw + 20 + 128 + 20, -60 - gl_defFont.h - 20, window_addText( wid, 20 + iw + 20 + 128 + 20, -60 - gl_defFont.h - 20,
320, 160, 0, "txtDescShort", &gl_smallFont, &cBlack, NULL ); 280, 160, 0, "txtDescShort", &gl_smallFont, &cBlack, NULL );
window_addText( wid, 20 + iw + 20, -60-128-10, window_addText( wid, 20 + iw + 20, -60-128-10,
60, 160, 0, "txtSDesc", &gl_smallFont, &cDConsole, 60, 160, 0, "txtSDesc", &gl_smallFont, &cDConsole,
"Owned:\n" "Owned:\n"
Expand Down Expand Up @@ -301,7 +311,7 @@ void outfits_update( unsigned int wid, char* str )
window_modifyText( wid, "txtDDesc", buf ); window_modifyText( wid, "txtDDesc", buf );
window_modifyText( wid, "txtOutfitName", outfit->name ); window_modifyText( wid, "txtOutfitName", outfit->name );
window_modifyText( wid, "txtDescShort", outfit->desc_short ); window_modifyText( wid, "txtDescShort", outfit->desc_short );
th = MAX( 128, gl_printHeightRaw( &gl_smallFont, 320, outfit->desc_short ) ); th = MAX( 128, gl_printHeightRaw( &gl_smallFont, 280, outfit->desc_short ) );
window_moveWidget( wid, "txtSDesc", 40+iw+20, -60-th-20 ); window_moveWidget( wid, "txtSDesc", 40+iw+20, -60-th-20 );
window_moveWidget( wid, "txtDDesc", 40+iw+20+60, -60-th-20 ); window_moveWidget( wid, "txtDDesc", 40+iw+20+60, -60-th-20 );
th += gl_printHeightRaw( &gl_smallFont, 250, buf ); th += gl_printHeightRaw( &gl_smallFont, 250, buf );
Expand Down Expand Up @@ -331,6 +341,18 @@ void outfits_updateEquipmentOutfits( void )
} }




/**
* @brief Starts the map find with outfit search selected.
* @param wid Window buying outfit from.
* @param str Unused.
*/
static void outfits_find( unsigned int wid, char* str )
{
(void) str;
map_inputFindType(wid, "outfit");
}


/** /**
* @brief Checks to see if the player can buy the outfit. * @brief Checks to see if the player can buy the outfit.
* @param outfit Outfit to buy. * @param outfit Outfit to buy.
Expand Down
32 changes: 27 additions & 5 deletions src/land_shipyard.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "toolkit.h" #include "toolkit.h"
#include "tk/toolkit_priv.h" #include "tk/toolkit_priv.h"
#include "dialogue.h" #include "dialogue.h"
#include "map_find.h"




/* /*
Expand All @@ -40,6 +41,7 @@ static void shipyard_trade( unsigned int wid, char* str );
static void shipyard_rmouse( unsigned int wid, char* widget_name ); static void shipyard_rmouse( unsigned int wid, char* widget_name );
static void shipyard_renderSlots( double bx, double by, double bw, double bh, void *data ); static void shipyard_renderSlots( double bx, double by, double bw, double bh, void *data );
static void shipyard_renderSlotsRow( double bx, double by, double bw, char *str, ShipOutfitSlot *s, int n ); static void shipyard_renderSlotsRow( double bx, double by, double bw, char *str, ShipOutfitSlot *s, int n );
static void shipyard_find( unsigned int wid, char* str );




/** /**
Expand All @@ -54,7 +56,7 @@ void shipyard_open( unsigned int wid )
int nships; int nships;
int w, h; int w, h;
int iw, ih; int iw, ih;
int bw, bh; int bw, bh, padding, off;
int th; int th;
int y; int y;
const char *buf; const char *buf;
Expand All @@ -69,20 +71,26 @@ void shipyard_open( unsigned int wid )
iw = 310 + (w-800); iw = 310 + (w-800);
ih = h - 60; ih = h - 60;


/* Left padding + per-button padding * nbuttons */
padding = 40 + 20 * 4;

/* Calculate button dimensions. */ /* Calculate button dimensions. */
bw = (w - iw - 100) / 3; bw = (w - iw - padding) / 4;
bh = LAND_BUTTON_HEIGHT; bh = LAND_BUTTON_HEIGHT;


/* buttons */ /* buttons */
window_addButtonKey( wid, -20, 20, window_addButtonKey( wid, off = -20, 20,
bw, bh, "btnCloseShipyard", bw, bh, "btnCloseShipyard",
"Take Off", land_buttonTakeoff, SDLK_t ); "Take Off", land_buttonTakeoff, SDLK_t );
window_addButtonKey( wid, -40 - bw, 20, window_addButtonKey( wid, off -= 20+bw, 20,
bw, bh, "btnTradeShip", bw, bh, "btnTradeShip",
"Trade-In", shipyard_trade, SDLK_r ); "Trade-In", shipyard_trade, SDLK_r );
window_addButtonKey( wid, -60 - bw*2, 20, window_addButtonKey( wid, off -= 20+bw, 20,
bw, bh, "btnBuyShip", bw, bh, "btnBuyShip",
"Buy", shipyard_buy, SDLK_b ); "Buy", shipyard_buy, SDLK_b );
window_addButtonKey( wid, off -= 20+bw, 20,
bw, bh, "btnFindShips",
"Find Ships", shipyard_find, SDLK_f );


/* target gfx */ /* target gfx */
window_addRect( wid, -41, -50, window_addRect( wid, -41, -50,
Expand Down Expand Up @@ -271,6 +279,19 @@ void shipyard_update( unsigned int wid, char* str )
window_enableButton( wid, "btnTradeShip"); window_enableButton( wid, "btnTradeShip");
} }



/**
* @brief Starts the map find with ship search selected.
* @param wid Window buying outfit from.
* @param str Unused.
*/
static void shipyard_find( unsigned int wid, char* str )
{
(void) str;
map_inputFindType(wid, "ship");
}


/** /**
* @brief Player right-clicks on a ship. * @brief Player right-clicks on a ship.
* @param wid Window player is buying ship from. * @param wid Window player is buying ship from.
Expand All @@ -282,6 +303,7 @@ static void shipyard_rmouse( unsigned int wid, char* widget_name )
return shipyard_buy(wid, widget_name); return shipyard_buy(wid, widget_name);
} }



/** /**
* @brief Player attempts to buy a ship. * @brief Player attempts to buy a ship.
* @param wid Window player is buying ship from. * @param wid Window player is buying ship from.
Expand Down
64 changes: 46 additions & 18 deletions src/map_find.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -159,6 +159,32 @@ static void map_find_check_update( unsigned int wid, char* str )
} }




/**
* @brief Starts the map search with a specific default type.
*
* @param Parent window's ID.
* @param Default type to search for.
*/
void map_inputFindType( unsigned int parent, char *type )
{
map_find_systems = 0;
map_find_planets = 0;
map_find_outfits = 0;
map_find_ships = 0;

if (strcmp(type,"system")==0)
map_find_systems = 1;
else if (strcmp(type,"planet")==0)
map_find_planets = 1;
else if (strcmp(type,"outfit")==0)
map_find_outfits = 1;
else if (strcmp(type,"ship")==0)
map_find_ships = 1;

map_inputFind(parent, NULL);
}


/** /**
* @brief Closes the find window. * @brief Closes the find window.
*/ */
Expand Down Expand Up @@ -211,7 +237,7 @@ static void map_findDisplayResult( unsigned int parent, map_find_t *found, int n
map_found_ncur = n; map_found_ncur = n;


/* Create window. */ /* Create window. */
wid = window_create( "Search Results", -1, -1, 500, 400 ); wid = window_create( "Search Results", -1, -1, 500, 452 );
window_setParent( wid, parent ); window_setParent( wid, parent );
window_setAccept( wid, map_findDisplayMark ); window_setAccept( wid, map_findDisplayMark );
window_setCancel( wid, window_close ); window_setCancel( wid, window_close );
Expand Down Expand Up @@ -622,14 +648,14 @@ static void map_addOutfitDetailFields(unsigned int wid, int x, int y, int w, int


iw = x; iw = x;


window_addRect( wid, 19 + iw + 20, -50, 128, 129, "rctImage", &cBlack, 0 ); window_addRect( wid, -1 + iw, -50, 128, 129, "rctImage", &cBlack, 0 );
window_addImage( wid, 20 + iw + 20, -50-128, 0, 0, "imgOutfit", NULL, 1 ); window_addImage( wid, iw, -50-128, 0, 0, "imgOutfit", NULL, 1 );


window_addText( wid, 20 + iw + 20 + 128 + 20, -60, window_addText( wid, iw + 128 + 20, -60,
320, 160, 0, "txtOutfitName", &gl_defFont, &cBlack, NULL ); 280, 160, 0, "txtOutfitName", &gl_defFont, &cBlack, NULL );
window_addText( wid, 20 + iw + 20 + 128 + 20, -60 - gl_defFont.h - 20, window_addText( wid, iw + 128 + 20, -60 - gl_defFont.h - 20,
320, 160, 0, "txtDescShort", &gl_smallFont, &cBlack, NULL ); 280, 160, 0, "txtDescShort", &gl_smallFont, &cBlack, NULL );
window_addText( wid, 20 + iw + 20, -60-128-10, window_addText( wid, iw+20, -60-128-10,
60, 160, 0, "txtSDesc", &gl_smallFont, &cDConsole, 60, 160, 0, "txtSDesc", &gl_smallFont, &cDConsole,
"Owned:\n" "Owned:\n"
"\n" "\n"
Expand All @@ -640,9 +666,9 @@ static void map_addOutfitDetailFields(unsigned int wid, int x, int y, int w, int
"Price:\n" "Price:\n"
"Money:\n" "Money:\n"
"License:\n" ); "License:\n" );
window_addText( wid, 20 + iw + 20 + 60, -60-128-10, window_addText( wid, iw+20, -60-128-10,
250, 160, 0, "txtDDesc", &gl_smallFont, &cBlack, NULL ); 280, 160, 0, "txtDDesc", &gl_smallFont, &cBlack, NULL );
window_addText( wid, 20 + iw + 20, -60-128-10-160, window_addText( wid, iw+20, -60-128-10-160,
w-(iw+80), 180, 0, "txtDescription", w-(iw+80), 180, 0, "txtDescription",
&gl_smallFont, NULL, NULL ); &gl_smallFont, NULL, NULL );
} }
Expand All @@ -666,7 +692,9 @@ static void map_showOutfitDetail(unsigned int wid, char* wgtname, int x, int y,
double th; double th;
int iw; int iw;


iw = w - 400; /* 452 px is the sum of the 128 px outfit image width, its 4 px border,
* a 20 px gap, 280 px for the outfit's name and a final 20 px gap. */
iw = w - 452;


outfit = outfit_get( toolkit_getList(wid, wgtname) ); outfit = outfit_get( toolkit_getList(wid, wgtname) );
window_modifyText( wid, "txtOutfitName", outfit->name ); window_modifyText( wid, "txtOutfitName", outfit->name );
Expand Down Expand Up @@ -695,11 +723,11 @@ static void map_showOutfitDetail(unsigned int wid, char* wgtname, int x, int y,
window_modifyText( wid, "txtDDesc", buf ); window_modifyText( wid, "txtDDesc", buf );
window_modifyText( wid, "txtOutfitName", outfit->name ); window_modifyText( wid, "txtOutfitName", outfit->name );
window_modifyText( wid, "txtDescShort", outfit->desc_short ); window_modifyText( wid, "txtDescShort", outfit->desc_short );
th = MAX( 128, gl_printHeightRaw( &gl_smallFont, 320, outfit->desc_short ) ); th = MAX( 128, gl_printHeightRaw( &gl_smallFont, 280, outfit->desc_short ) );
window_moveWidget( wid, "txtSDesc", 40+iw+20, -60-th-20 ); window_moveWidget( wid, "txtSDesc", iw+20, -60-th-20 );
window_moveWidget( wid, "txtDDesc", 40+iw+20+60, -60-th-20 ); window_moveWidget( wid, "txtDDesc", iw+20+60, -60-th-20 );
th += gl_printHeightRaw( &gl_smallFont, 250, buf ); th += gl_printHeightRaw( &gl_smallFont, 280, buf );
window_moveWidget( wid, "txtDescription", 20+iw+40, -60-th-40 ); window_moveWidget( wid, "txtDescription", iw+20, -60-th-40 );
} }


/** /**
Expand Down Expand Up @@ -735,7 +763,7 @@ static int map_findSearchOutfits( unsigned int parent, const char *name )
list = malloc( len*sizeof(char*) ); list = malloc( len*sizeof(char*) );
for (i=0; i<len; i++) for (i=0; i<len; i++)
list[i] = strdup( names[i] ); list[i] = strdup( names[i] );
i = dialogue_listPanel( "Search Results", list, len, 400, 550, i = dialogue_listPanel( "Search Results", list, len, 452, 550,
map_addOutfitDetailFields, map_showOutfitDetail, map_addOutfitDetailFields, map_showOutfitDetail,
"Search results for outfits matching '%s':", name ); "Search results for outfits matching '%s':", name );
if (i < 0) { if (i < 0) {
Expand Down
1 change: 1 addition & 0 deletions src/map_find.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@




void map_inputFind( unsigned int parent, char* str ); void map_inputFind( unsigned int parent, char* str );
void map_inputFindType( unsigned int parent, char *type );




#endif /* MAP_FIND_H */ #endif /* MAP_FIND_H */
Expand Down

0 comments on commit d6e2818

Please sign in to comment.