Skip to content

Commit

Permalink
+ Gold bolder around currently selected inventory slot.
Browse files Browse the repository at this point in the history
  • Loading branch information
addictgamer committed Oct 3, 2016
1 parent 516b5d3 commit b9df224
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,22 @@ int drawRect( SDL_Rect *src, Uint32 color, Uint8 alpha ) {
return 0;
}


/*-------------------------------------------------------------------------------
drawBox
draws the border of a rectangle
-------------------------------------------------------------------------------*/
int drawBox(SDL_Rect *src, Uint32 color, Uint8 alpha)
{
drawLine(src->x, src->y, src->x + src->w, src->y, color, alpha); //Top.
drawLine(src->x, src->y, src->x, src->y + src->h, color, alpha); //Left.
drawLine(src->x + src->w, src->y, src->x + src->w, src->y + src->h, color, alpha); //Right.
drawLine(src->x, src->y + src->h, src->x + src->w, src->y + src->h, color, alpha); //Bottom.
}

/*-------------------------------------------------------------------------------
drawGear
Expand Down
3 changes: 3 additions & 0 deletions src/interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ int chestgui_offset_x = 0;
int chestgui_offset_y = 0;
bool dragging_chestGUI = FALSE;

int selected_inventory_slot_x = 0;
int selected_inventory_slot_y = 0;

//Identify GUI definitions.
bool identifygui_active = FALSE;
bool identifygui_appraising = FALSE;
Expand Down
3 changes: 3 additions & 0 deletions src/interface/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ extern int inventorycategory;
extern int itemscroll;
extern view_t camera_charsheet;

extern int selected_inventory_slot_x;
extern int selected_inventory_slot_y;

extern SDL_Surface *inventoryChest_bmp;
extern SDL_Surface *invclose_bmp;
extern SDL_Surface *invgraball_bmp;
Expand Down
17 changes: 17 additions & 0 deletions src/interface/playerinventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,29 @@ void updatePlayerInventory() {
drawLine(pos.x,pos.y+y*INVENTORY_SLOTSIZE,pos.x+pos.w,pos.y+y*INVENTORY_SLOTSIZE,SDL_MapRGB(mainsurface->format,150,150,150),255);
}

//Highlight currently selected inventory slot (for gamepad).
pos.w = INVENTORY_SLOTSIZE; pos.h = INVENTORY_SLOTSIZE;
for (x = 0; x < INVENTORY_SIZEX; x++)
{
for (y = 0; y < INVENTORY_SIZEY; y++)
{
if (x == selected_inventory_slot_x && y == selected_inventory_slot_y)
{
pos.x = INVENTORY_STARTX + x*INVENTORY_SLOTSIZE;
pos.y = INVENTORY_STARTY + y*INVENTORY_SLOTSIZE;
Uint32 color = SDL_MapRGBA(mainsurface->format, 255, 255, 0, 127);
drawBox(&pos, color, 127);
}
}
}

// draw contents of each slot
x = INVENTORY_STARTX;
y = INVENTORY_STARTY;
for( node=stats[clientnum]->inventory.first; node!=NULL; node=nextnode ) {
nextnode = node->next;
Item *item = (Item *)node->element;

if( item==selectedItem || (inventory_mode == INVENTORY_MODE_ITEM && itemCategory(item) == SPELL_CAT) || (inventory_mode == INVENTORY_MODE_SPELL && itemCategory(item) != SPELL_CAT))
//Item is selected, or, item is a spell but it's item inventory mode, or, item is an item but it's spell inventory mode...(this filters out items)
continue;
Expand Down
1 change: 1 addition & 0 deletions src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ void drawCircle(int x, int y, double radius, Uint32 color, Uint8 alpha);
void drawArc(int x, int y, double radius, double angle1, double angle2, Uint32 color, Uint8 alpha);
void drawLine(int x1, int y1, int x2, int y2, Uint32 color, Uint8 alpha);
int drawRect(SDL_Rect *src, Uint32 color, Uint8 alpha);
int drawBox(SDL_Rect *src, Uint32 color, Uint8 alpha);
void drawGear(Sint16 x, Sint16 y, double size, Sint32 rotation);
void drawImage(SDL_Surface *image, SDL_Rect *src, SDL_Rect *pos);
void drawImageScaled(SDL_Surface *image, SDL_Rect *src, SDL_Rect *pos);
Expand Down

0 comments on commit b9df224

Please sign in to comment.