Skip to content
Browse files

Merge branch 'master' of git://github.com/Deiz/naev into slots

  • Loading branch information...
2 parents d4676e4 + 54769da commit d6e28183c62ab669cdd0a702674db5fb867fc916 @bobbens bobbens committed
Showing with 105 additions and 32 deletions.
  1. +1 −1 dat/outfits/launchers/teracom_imperator_launcher.xml
  2. +30 −8 src/land_outfits.c
  3. +27 −5 src/land_shipyard.c
  4. +46 −18 src/map_find.c
  5. +1 −0 src/map_find.h
View
2 dat/outfits/launchers/teracom_imperator_launcher.xml
@@ -6,7 +6,7 @@
<license>Heavy Weapon License</license>
<mass>40</mass>
<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>
</general>
<specific type="launcher" secondary="1">
View
38 src/land_outfits.c
@@ -27,6 +27,7 @@
#include "player_gui.h"
#include "toolkit.h"
#include "dialogue.h"
+#include "map_find.h"
/* Modifier for buying and selling quantity. */
@@ -43,6 +44,7 @@ static void outfits_sell( unsigned int wid, char* str );
static int outfits_getMod (void);
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_find( unsigned int wid, char* str );
/**
@@ -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,
int *iw, int *ih, int *bw, int *bh )
{
+ int padding;
+
/* Get window dimensions. */
window_dimWindow( wid, w, h );
@@ -60,9 +64,12 @@ static void outfits_getSize( unsigned int wid, int *w, int *h,
if (ih != NULL)
*ih = *h - 60;
+ /* Left padding + per-button padding * nbuttons */
+ padding = 40 + 20 * 4;
+
/* Calculate button dimensions. */
if (bw != NULL)
- *bw = (*w - (iw!=NULL?*iw:0) - 100) / 3;
+ *bw = (*w - (iw!=NULL?*iw:0) - padding) / 4;
if (bh != NULL)
*bh = LAND_BUTTON_HEIGHT;
}
@@ -81,7 +88,7 @@ void outfits_open( unsigned int wid )
int noutfits;
int w, h;
int iw, ih;
- int bw, bh;
+ int bw, bh, off;
glColour *bg, blend;
const glColour *c;
char **slottype;
@@ -94,15 +101,18 @@ void outfits_open( unsigned int wid )
window_setAccept( wid, outfits_buy );
/* buttons */
- window_addButtonKey( wid, -20, 20,
+ window_addButtonKey( wid, off = -20, 20,
bw, bh, "btnCloseOutfits",
"Take Off", land_buttonTakeoff, SDLK_t );
- window_addButtonKey( wid, -40-bw, 20,
+ window_addButtonKey( wid, off -= 20+bw, 20,
bw, bh, "btnSellOutfit",
"Sell", outfits_sell, SDLK_s );
- window_addButtonKey( wid, -60-bw*2, 20,
+ window_addButtonKey( wid, off -= 20+bw, 20,
bw, bh, "btnBuyOutfit",
"Buy", outfits_buy, SDLK_b );
+ window_addButtonKey( wid, off -= 20+bw, 20,
+ bw, bh, "btnFindOutfits",
+ "Find Outfits", outfits_find, SDLK_f );
/* fancy 128x128 image */
window_addRect( wid, 19 + iw + 20, -50, 128, 129, "rctImage", &cBlack, 0 );
@@ -114,9 +124,9 @@ void outfits_open( unsigned int wid )
/* the descriptive text */
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,
- 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,
60, 160, 0, "txtSDesc", &gl_smallFont, &cDConsole,
"Owned:\n"
@@ -301,7 +311,7 @@ void outfits_update( unsigned int wid, char* str )
window_modifyText( wid, "txtDDesc", buf );
window_modifyText( wid, "txtOutfitName", outfit->name );
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, "txtDDesc", 40+iw+20+60, -60-th-20 );
th += gl_printHeightRaw( &gl_smallFont, 250, buf );
@@ -332,6 +342,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.
* @param outfit Outfit to buy.
*/
View
32 src/land_shipyard.c
@@ -24,6 +24,7 @@
#include "toolkit.h"
#include "tk/toolkit_priv.h"
#include "dialogue.h"
+#include "map_find.h"
/*
@@ -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_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_find( unsigned int wid, char* str );
/**
@@ -54,7 +56,7 @@ void shipyard_open( unsigned int wid )
int nships;
int w, h;
int iw, ih;
- int bw, bh;
+ int bw, bh, padding, off;
int th;
int y;
const char *buf;
@@ -69,20 +71,26 @@ void shipyard_open( unsigned int wid )
iw = 310 + (w-800);
ih = h - 60;
+ /* Left padding + per-button padding * nbuttons */
+ padding = 40 + 20 * 4;
+
/* Calculate button dimensions. */
- bw = (w - iw - 100) / 3;
+ bw = (w - iw - padding) / 4;
bh = LAND_BUTTON_HEIGHT;
/* buttons */
- window_addButtonKey( wid, -20, 20,
+ window_addButtonKey( wid, off = -20, 20,
bw, bh, "btnCloseShipyard",
"Take Off", land_buttonTakeoff, SDLK_t );
- window_addButtonKey( wid, -40 - bw, 20,
+ window_addButtonKey( wid, off -= 20+bw, 20,
bw, bh, "btnTradeShip",
"Trade-In", shipyard_trade, SDLK_r );
- window_addButtonKey( wid, -60 - bw*2, 20,
+ window_addButtonKey( wid, off -= 20+bw, 20,
bw, bh, "btnBuyShip",
"Buy", shipyard_buy, SDLK_b );
+ window_addButtonKey( wid, off -= 20+bw, 20,
+ bw, bh, "btnFindShips",
+ "Find Ships", shipyard_find, SDLK_f );
/* target gfx */
window_addRect( wid, -41, -50,
@@ -271,6 +279,19 @@ void shipyard_update( unsigned int wid, char* str )
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.
* @param wid Window player is buying ship from.
@@ -282,6 +303,7 @@ static void shipyard_rmouse( unsigned int wid, char* widget_name )
return shipyard_buy(wid, widget_name);
}
+
/**
* @brief Player attempts to buy a ship.
* @param wid Window player is buying ship from.
View
64 src/map_find.c
@@ -160,6 +160,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.
*/
static void map_findClose( unsigned int wid, char* str )
@@ -211,7 +237,7 @@ static void map_findDisplayResult( unsigned int parent, map_find_t *found, int n
map_found_ncur = n;
/* 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_setAccept( wid, map_findDisplayMark );
window_setCancel( wid, window_close );
@@ -622,14 +648,14 @@ static void map_addOutfitDetailFields(unsigned int wid, int x, int y, int w, int
iw = x;
- window_addRect( wid, 19 + iw + 20, -50, 128, 129, "rctImage", &cBlack, 0 );
- window_addImage( wid, 20 + iw + 20, -50-128, 0, 0, "imgOutfit", NULL, 1 );
+ window_addRect( wid, -1 + iw, -50, 128, 129, "rctImage", &cBlack, 0 );
+ window_addImage( wid, iw, -50-128, 0, 0, "imgOutfit", NULL, 1 );
- window_addText( wid, 20 + iw + 20 + 128 + 20, -60,
- 320, 160, 0, "txtOutfitName", &gl_defFont, &cBlack, NULL );
- window_addText( wid, 20 + iw + 20 + 128 + 20, -60 - gl_defFont.h - 20,
- 320, 160, 0, "txtDescShort", &gl_smallFont, &cBlack, NULL );
- window_addText( wid, 20 + iw + 20, -60-128-10,
+ window_addText( wid, iw + 128 + 20, -60,
+ 280, 160, 0, "txtOutfitName", &gl_defFont, &cBlack, NULL );
+ window_addText( wid, iw + 128 + 20, -60 - gl_defFont.h - 20,
+ 280, 160, 0, "txtDescShort", &gl_smallFont, &cBlack, NULL );
+ window_addText( wid, iw+20, -60-128-10,
60, 160, 0, "txtSDesc", &gl_smallFont, &cDConsole,
"Owned:\n"
"\n"
@@ -640,9 +666,9 @@ static void map_addOutfitDetailFields(unsigned int wid, int x, int y, int w, int
"Price:\n"
"Money:\n"
"License:\n" );
- window_addText( wid, 20 + iw + 20 + 60, -60-128-10,
- 250, 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,
+ 280, 160, 0, "txtDDesc", &gl_smallFont, &cBlack, NULL );
+ window_addText( wid, iw+20, -60-128-10-160,
w-(iw+80), 180, 0, "txtDescription",
&gl_smallFont, NULL, NULL );
}
@@ -666,7 +692,9 @@ static void map_showOutfitDetail(unsigned int wid, char* wgtname, int x, int y,
double th;
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) );
window_modifyText( wid, "txtOutfitName", outfit->name );
@@ -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, "txtOutfitName", outfit->name );
window_modifyText( wid, "txtDescShort", outfit->desc_short );
- th = MAX( 128, gl_printHeightRaw( &gl_smallFont, 320, outfit->desc_short ) );
- window_moveWidget( wid, "txtSDesc", 40+iw+20, -60-th-20 );
- window_moveWidget( wid, "txtDDesc", 40+iw+20+60, -60-th-20 );
- th += gl_printHeightRaw( &gl_smallFont, 250, buf );
- window_moveWidget( wid, "txtDescription", 20+iw+40, -60-th-40 );
+ th = MAX( 128, gl_printHeightRaw( &gl_smallFont, 280, outfit->desc_short ) );
+ window_moveWidget( wid, "txtSDesc", iw+20, -60-th-20 );
+ window_moveWidget( wid, "txtDDesc", iw+20+60, -60-th-20 );
+ th += gl_printHeightRaw( &gl_smallFont, 280, buf );
+ window_moveWidget( wid, "txtDescription", iw+20, -60-th-40 );
}
/**
@@ -735,7 +763,7 @@ static int map_findSearchOutfits( unsigned int parent, const char *name )
list = malloc( len*sizeof(char*) );
for (i=0; i<len; 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,
"Search results for outfits matching '%s':", name );
if (i < 0) {
View
1 src/map_find.h
@@ -9,6 +9,7 @@
void map_inputFind( unsigned int parent, char* str );
+void map_inputFindType( unsigned int parent, char *type );
#endif /* MAP_FIND_H */

0 comments on commit d6e2818

Please sign in to comment.
Something went wrong with that request. Please try again.