Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup merchant window override #949

Merged
merged 2 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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