Skip to content

Commit

Permalink
trade_ui: show held and worn items last
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei8l committed Nov 2, 2021
1 parent 17ef216 commit 6a9de5d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/trade_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "type_id.h"

static const flag_id json_flag_NO_UNWIELD( "NO_UNWIELD" );
static const item_category_id item_category_WEAPON_HELD( "WEAPON_HELD" );
static const item_category_id item_category_ITEMS_WORN( "ITEMS_WORN" );
namespace
{
point _pane_orig( int side )
Expand Down Expand Up @@ -69,6 +71,16 @@ std::string trade_preset::get_denial( const item_location &loc ) const
return inventory_selector_preset::get_denial( loc );
}

bool trade_preset::cat_sort_compare( const inventory_entry &lhs, const inventory_entry &rhs ) const
{
item_category const *const rcat = rhs.get_category_ptr();
if( rcat->get_id() == item_category_ITEMS_WORN or rcat->get_id() == item_category_WEAPON_HELD ) {
return true;
}

return inventory_selector_preset::cat_sort_compare( lhs, rhs );
}

trade_ui::trade_ui( party_t &you, npc &trader, currency_t cost, std::string title )
: _upreset{ you, trader }, _tpreset{ trader, you },
_panes{ std::make_unique<pane_t>( this, trader, _tpreset, std::string(), _pane_size(),
Expand Down
1 change: 1 addition & 0 deletions src/trade_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class trade_preset : public inventory_selector_preset

bool is_shown( item_location const &loc ) const override;
std::string get_denial( const item_location &loc ) const override;
bool cat_sort_compare( const inventory_entry &lhs, const inventory_entry &rhs ) const override;

private:
Character const &_u, &_trader;
Expand Down

0 comments on commit 6a9de5d

Please sign in to comment.