Skip to content

Commit

Permalink
Merge pull request #949 from ChandlerFerry/chore/recastMerchantWindow…
Browse files Browse the repository at this point in the history
…Item

chore: cleanup merchant window override
  • Loading branch information
3vcloud authored Oct 14, 2023
2 parents 65aa5ce + bd4bdb6 commit 0ce722b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
39 changes: 18 additions & 21 deletions GWToolboxdll/Modules/InventoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ namespace {
"Bag 2"
};

bool hide_unsellable_items = false;
bool hide_weapon_sets_and_customized_items = false;
std::map<uint32_t, std::string> hide_from_merchant_items;


bool GetIsProfessionUnlocked(GW::Constants::Profession prof)
{
const auto world = GW::GetWorldContext();
Expand Down Expand Up @@ -756,23 +751,11 @@ namespace {
{
GW::Hook::EnterHook();
if (merchant_list_tab == 0xb) {
const auto item = GW::Items::GetItemById(item_id);

if (item) {
if (hide_unsellable_items && !item->value) {
GW::Hook::LeaveHook();
return;
}
const auto item = reinterpret_cast<InventoryManager::Item*>(GW::Items::GetItemById(item_id));

if (hide_weapon_sets_and_customized_items && (item->customized || item->equipped)) {
GW::Hook::LeaveHook();
return;
}

if (hide_from_merchant_items.contains(item->model_id)) {
GW::Hook::LeaveHook();
return;
}
if (item && item->IsHiddenFromMerchants()) {
GW::Hook::LeaveHook();
return;
}
}
RetAddItemRowToWindow(ecx, edx, frame, item_id);
Expand Down Expand Up @@ -2387,6 +2370,20 @@ bool InventoryManager::Item::IsArmor()
}
}

bool InventoryManager::Item::IsHiddenFromMerchants()
{
if (Instance().hide_unsellable_items && !InventoryManager::Item::value) {
return true;
}
if (Instance().hide_weapon_sets_and_customized_items && (InventoryManager::Item::customized || InventoryManager::Item::IsWeaponSetItem())) {
return true;
}
if (Instance().hide_from_merchant_items.contains(InventoryManager::Item::model_id)) {
return true;
}
return false;
}

GW::ItemModifier* InventoryManager::Item::GetModifier(const uint32_t identifier) const
{
for (size_t i = 0; i < mod_struct_size; i++) {
Expand Down
4 changes: 4 additions & 0 deletions GWToolboxdll/Modules/InventoryManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class InventoryManager : public ToolboxUIElement {
bool show_salvage_all_popup = true;
bool salvage_listeners_attached = false;
bool only_use_superior_salvage_kits = false;
bool hide_unsellable_items = false;
bool hide_weapon_sets_and_customized_items = false;
std::map<uint32_t, std::string> hide_from_merchant_items;
bool salvage_rare_mats = false;
bool show_transact_quantity_popup = false;
bool transaction_listeners_attached = false;
Expand Down Expand Up @@ -154,6 +157,7 @@ class InventoryManager : public ToolboxUIElement {
bool IsWeapon();
bool IsArmor();
bool IsSalvagable();
bool IsHiddenFromMerchants();

bool IsRareMaterial() const;
bool IsWeaponSetItem();
Expand Down

0 comments on commit 0ce722b

Please sign in to comment.