Permalink
Browse files

Added search shortcut to outfitter and shipyard.

  • Loading branch information...
1 parent 8ddcf42 commit 54769da1009e94c36067ef91f954796b6421696c @Deiz Deiz committed Apr 8, 2012
Showing with 81 additions and 10 deletions.
  1. +27 −5 src/land_outfits.c
  2. +27 −5 src/land_shipyard.c
  3. +26 −0 src/map_find.c
  4. +1 −0 src/map_find.h
View
@@ -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 );
@@ -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.
* @param outfit Outfit to buy.
View
@@ -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
@@ -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.
*/
View
@@ -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 54769da

Please sign in to comment.