From dc76f5627b238d72f71ae5ce89d711369b73b58f Mon Sep 17 00:00:00 2001 From: Hash Borgir Date: Wed, 8 May 2024 17:56:23 -0600 Subject: [PATCH] r01 not extracting. --- .../loot_filter/loot_filter_settings_menu.h | 1 + .../loot_filter_settings_toggle_menu.h | 6 + .../loot_filter/loot_filter_settings_menu.cpp | 107 ++++++++++-------- .../loot_filter_settings_toggle_menu.cpp | 15 +++ .../modules/item_move/item_move_server.cpp | 17 ++- src/d2tweaks/ui/ui_manager.cpp | 9 ++ 6 files changed, 105 insertions(+), 50 deletions(-) diff --git a/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.h b/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.h index c50b280..bcec854 100644 --- a/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.h +++ b/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.h @@ -128,6 +128,7 @@ namespace d2_tweaks { void reload_settings(); void draw() override; + private: std::string m_selected_gem; diff --git a/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.h b/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.h index 38839f0..5e6cc78 100644 --- a/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.h +++ b/include/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.h @@ -29,6 +29,12 @@ namespace d2_tweaks { public: explicit loot_filter_settings_toggle_menu(token); + void toggle_show() { + m_show = !m_show; + set_enabled(m_show); + set_visible(m_show); + } + void toggle_filter_settings_click(); void toggle_stats_settings_click(); void toggle_help_click(); diff --git a/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.cpp b/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.cpp index 9ef0ba4..851ec9c 100644 --- a/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.cpp +++ b/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.cpp @@ -44,6 +44,9 @@ #include #include +// include d2common.h +#include + #include #include #include @@ -78,6 +81,9 @@ #include #include // Include for GetTickCount() +d2_tweaks::common::asset* m_chips_asset; +diablo2::structures::gfxdata m_chips_gfxdata; + d2_tweaks::client::modules::loot_filter_settings_menu::loot_filter_settings_menu(token) : m_last_packet_sent(std::chrono::steady_clock::now()) { menu::set_enabled(false); @@ -98,6 +104,7 @@ d2_tweaks::client::modules::loot_filter_settings_menu::loot_filter_settings_menu } +auto D2CLIENT_StoredTickCount = GetTickCount(); // Define the initial X position and Y position for the stats display int initialX = 400; @@ -150,9 +157,10 @@ void displayStat() { int textOffset = 0; - int x = 400; - int y = 122; - int z = 120; + // get the value of x , y, and z from the d2tweaks.ini file using getprofileint + int x = GetPrivateProfileInt("Options", "bagStatsx", 360, "d2tweaks.ini"); + int y = GetPrivateProfileInt("Options", "bagStatsy", 155, "d2tweaks.ini"); + int z = GetPrivateProfileInt("Options", "bagStatsz", 160, "d2tweaks.ini"); for (auto item = inventory->first_item; item != nullptr; item = item->item_data->pt_next_item) { const auto record = diablo2::d2_common::get_item_record(item->data_record_index); @@ -224,75 +232,84 @@ void displayStat() { //diablo2::d2_win::draw_text((wchar_t*)((L"Quartz: " + std::to_wstring(gembag_Stones_Quartz)).c_str()), 400, 307 + textOffset, diablo2::UI_COLOR_WHITE, 0); //diablo2::d2_win::draw_text((wchar_t*)((L"Tiger Eye: " + std::to_wstring(gembag_Stones_TigerEye)).c_str()), 400, 319 + textOffset, diablo2::UI_COLOR_YELLOW, 0); - diablo2::d2_win::draw_text(const_cast((L"C.Ruby: ")), x, y + 15 + textOffset, diablo2::UI_COLOR_RED, 0); + diablo2::d2_win::set_current_font(diablo2::UI_FONT_8); + + diablo2::d2_win::draw_text(const_cast((L"Chipped Rubies: ")), x, y + 15 + textOffset, diablo2::UI_COLOR_RED, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(statRuby)).c_str()), x + z, y + 15 + textOffset, diablo2::UI_COLOR_RED, 0); - diablo2::d2_win::draw_text(const_cast((L"C.Amethyst: ")), x, y + 27 + textOffset, diablo2::UI_COLOR_PURPLE, 0); + diablo2::d2_win::draw_text(const_cast((L"Chipped Amethyst: ")), x, y + 27 + textOffset, diablo2::UI_COLOR_PURPLE, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(statAmethyst)).c_str()), x + z, y + 27 + textOffset, diablo2::UI_COLOR_PURPLE, 0); - diablo2::d2_win::draw_text(const_cast((L"C.Diamond: ")), x, y + 39 + textOffset, diablo2::UI_COLOR_WHITE, 0); + diablo2::d2_win::draw_text(const_cast((L"Chipped Diamonds: ")), x, y + 39 + textOffset, diablo2::UI_COLOR_WHITE, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(statDiamond)).c_str()), x + z, y + 39 + textOffset, diablo2::UI_COLOR_WHITE, 0); - diablo2::d2_win::draw_text(const_cast((L"C.Emerald: ")), x, y + 51 + textOffset, diablo2::UI_COLOR_LIGHT_GREEN, 0); + diablo2::d2_win::draw_text(const_cast((L"Chipped Emeralds: ")), x, y + 51 + textOffset, diablo2::UI_COLOR_LIGHT_GREEN, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(statEmerald)).c_str()), x + z, y + 51 + textOffset, diablo2::UI_COLOR_LIGHT_GREEN, 0); - diablo2::d2_win::draw_text(const_cast((L"C.Sapphire: ")), x, y + 63 + textOffset, diablo2::UI_COLOR_BLUE, 0); + diablo2::d2_win::draw_text(const_cast((L"Chipped Sapphires: ")), x, y + 63 + textOffset, diablo2::UI_COLOR_BLUE, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(statSapphire)).c_str()), x + z, y + 63 + textOffset, diablo2::UI_COLOR_BLUE, 0); - diablo2::d2_win::draw_text(const_cast((L"C.Topaz: ")), x, y + 75 + textOffset, diablo2::UI_COLOR_YELLOW, 0); + diablo2::d2_win::draw_text(const_cast((L"Chipped Topaz: ")), x, y + 75 + textOffset, diablo2::UI_COLOR_YELLOW, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(statTopaz)).c_str()), x + z, y + 75 + textOffset, diablo2::UI_COLOR_YELLOW, 0); - diablo2::d2_win::draw_text(const_cast((L"C.Skull: ")), x, y + 87 + textOffset, diablo2::UI_COLOR_GREY, 0); + diablo2::d2_win::draw_text(const_cast((L"Chipped Skulls: ")), x, y + 87 + textOffset, diablo2::UI_COLOR_GREY, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(statSkull)).c_str()), x + z, y + 87 + textOffset, diablo2::UI_COLOR_GREY, 0); - diablo2::d2_win::draw_text(const_cast((L"Runes Tier 1: ")), x, y + 109 + textOffset, diablo2::UI_COLOR_GREY, 0); + diablo2::d2_win::draw_text(const_cast((L"Runes 1 - 6: ")), x, y + 109 + textOffset, diablo2::UI_COLOR_GREY, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(runebag_RunesA)).c_str()), x + z, y + 109 + textOffset, diablo2::UI_COLOR_GREY, 0); - diablo2::d2_win::draw_text(const_cast((L"Runes Tier 2: ")), x, y + 121 + textOffset, diablo2::UI_COLOR_GREY, 0); + diablo2::d2_win::draw_text(const_cast((L"Runes 7 - 12: ")), x, y + 121 + textOffset, diablo2::UI_COLOR_GREY, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(runebag_RunesB)).c_str()), x + z, y + 121 + textOffset, diablo2::UI_COLOR_GREY, 0); - diablo2::d2_win::draw_text(const_cast((L"Runes Tier 3: ")), x, y + 133 + textOffset, diablo2::UI_COLOR_GREY, 0); + diablo2::d2_win::draw_text(const_cast((L"Runes 13 - 18: ")), x, y + 133 + textOffset, diablo2::UI_COLOR_GREY, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(runebag_RunesC)).c_str()), x + z, y + 133 + textOffset, diablo2::UI_COLOR_GREY, 0); - diablo2::d2_win::draw_text(const_cast((L"Runes Tier 4: ")), x, y + 145 + textOffset, diablo2::UI_COLOR_GREY, 0); + diablo2::d2_win::draw_text(const_cast((L"Runes 19 - 24: ")), x, y + 145 + textOffset, diablo2::UI_COLOR_GREY, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(runebag_RunesD)).c_str()), x + z, y + 145 + textOffset, diablo2::UI_COLOR_GREY, 0); - diablo2::d2_win::draw_text(const_cast((L"Runes Tier 5: ")), x, y + 157 + textOffset, diablo2::UI_COLOR_GREY, 0); + diablo2::d2_win::draw_text(const_cast((L"Runes 25 - 30: ")), x, y + 157 + textOffset, diablo2::UI_COLOR_GREY, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(runebag_RunesE)).c_str()), x + z, y + 157 + textOffset, diablo2::UI_COLOR_GREY, 0); - diablo2::d2_win::draw_text(const_cast((L"Runes Tier 6: ")), x, y + 169 + textOffset, diablo2::UI_COLOR_GREY, 0); + diablo2::d2_win::draw_text(const_cast((L"Runes 31 - 33: ")), x, y + 169 + textOffset, diablo2::UI_COLOR_GREY, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(runebag_RunesF)).c_str()), x + z, y + 169 + textOffset, diablo2::UI_COLOR_GREY, 0); - diablo2::d2_win::draw_text(const_cast((L"Rejuv: ")), x, y + 191 + textOffset, diablo2::UI_COLOR_PURPLE, 0); + diablo2::d2_win::draw_text(const_cast((L"Rejuv Potions: ")), x, y + 191 + textOffset, diablo2::UI_COLOR_PURPLE, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(gembag_Potions)).c_str()), x + z, y + 191 + textOffset, diablo2::UI_COLOR_PURPLE, 0); - diablo2::d2_win::draw_text(const_cast((L"Potions HP: ")), x, y + 213 + textOffset, diablo2::UI_COLOR_RED, 0); + diablo2::d2_win::draw_text(const_cast((L"Healing Potions: ")), x, y + 213 + textOffset, diablo2::UI_COLOR_RED, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(gembag_PotionsHP)).c_str()), x + z, y + 213 + textOffset, diablo2::UI_COLOR_RED, 0); - diablo2::d2_win::draw_text(const_cast((L"Potions Mana: ")), x, y + 225 + textOffset, diablo2::UI_COLOR_BLUE, 0); + diablo2::d2_win::draw_text(const_cast((L"Mana Potions: ")), x, y + 225 + textOffset, diablo2::UI_COLOR_BLUE, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(gembag_PotionsMana)).c_str()), x + z, y + 225 + textOffset, diablo2::UI_COLOR_BLUE, 0); - diablo2::d2_win::draw_text(const_cast((L"Flourite: ")), x, y + 247 + textOffset, diablo2::UI_COLOR_RED, 0); + diablo2::d2_win::draw_text(const_cast((L"Flourite Stones: ")), x, y + 247 + textOffset, diablo2::UI_COLOR_RED, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(gembag_Stones_Flourite)).c_str()), x + z, y + 247 + textOffset, diablo2::UI_COLOR_RED, 0); - diablo2::d2_win::draw_text(const_cast((L"Jade: ")), x, y + 259 + textOffset, diablo2::UI_COLOR_LIGHT_GREEN, 0); + diablo2::d2_win::draw_text(const_cast((L"Jade Stones: ")), x, y + 259 + textOffset, diablo2::UI_COLOR_LIGHT_GREEN, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(gembag_Stones_Jade)).c_str()), x + z, y + 259 + textOffset, diablo2::UI_COLOR_LIGHT_GREEN, 0); - diablo2::d2_win::draw_text(const_cast((L"Argonite: ")), x, y + 271 + textOffset, diablo2::UI_COLOR_RED, 0); + diablo2::d2_win::draw_text(const_cast((L"Argonite Stones: ")), x, y + 271 + textOffset, diablo2::UI_COLOR_RED, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(gembag_Stones_Argonite)).c_str()), x + z, y + 271 + textOffset, diablo2::UI_COLOR_RED, 0); - diablo2::d2_win::draw_text(const_cast((L"Azurite: ")), x, y + 283 + textOffset, diablo2::UI_COLOR_BLUE, 0); + diablo2::d2_win::draw_text(const_cast((L"Azurite Stones: ")), x, y + 283 + textOffset, diablo2::UI_COLOR_BLUE, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(gembag_Stones_Azurite)).c_str()), x + z, y + 283 + textOffset, diablo2::UI_COLOR_BLUE, 0); - diablo2::d2_win::draw_text(const_cast((L"Sulpher: ")), x, y + 295 + textOffset, diablo2::UI_COLOR_ORANGE, 0); + diablo2::d2_win::draw_text(const_cast((L"Sulpher Stones: ")), x, y + 295 + textOffset, diablo2::UI_COLOR_ORANGE, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(gembag_Stones_Sulpher)).c_str()), x + z, y + 295 + textOffset, diablo2::UI_COLOR_ORANGE, 0); - diablo2::d2_win::draw_text(const_cast((L"Quartz: ")), x, y + 307 + textOffset, diablo2::UI_COLOR_WHITE, 0); + diablo2::d2_win::draw_text(const_cast((L"Quartz Stones: ")), x, y + 307 + textOffset, diablo2::UI_COLOR_WHITE, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(gembag_Stones_Quartz)).c_str()), x + z, y + 307 + textOffset, diablo2::UI_COLOR_WHITE, 0); - diablo2::d2_win::draw_text(const_cast((L"Tiger Eye: ")), x, y + 319 + textOffset, diablo2::UI_COLOR_YELLOW, 0); + diablo2::d2_win::draw_text(const_cast((L"Tiger Eye Stones: ")), x, y + 319 + textOffset, diablo2::UI_COLOR_YELLOW, 0); diablo2::d2_win::draw_text(const_cast((std::to_wstring(gembag_Stones_TigerEye)).c_str()), x + z, y + 319 + textOffset, diablo2::UI_COLOR_YELLOW, 0); + + diablo2::d2_win::set_current_font(diablo2::UI_FONT_24); + + // print a string using draw_text + diablo2::d2_win::draw_text(const_cast((L"Gem/Rune/Stone/Potion storage & extraction menu")), 10, 25, diablo2::UI_COLOR_YELLOW, 0); + + diablo2::d2_win::set_current_font(diablo2::UI_FONT_16); } } @@ -1142,26 +1159,26 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::extract_item(bool va statValue = diablo2::d2_common::get_stat(item, stat, NULL); } } + if (250 < GetTickCount() - D2CLIENT_StoredTickCount) { + D2CLIENT_StoredTickCount = GetTickCount(); + if (statValue >= val) { + static d2_tweaks::common::item_move_cs packet; + packet.item_guid = bagGuid; + packet.bag_guid = bagGuid; + packet.target_page = 0; + packet.extract = 1; + packet.iCode = itemCode; + packet.prop = prop - 3; + packet.val = -val; + diablo2::d2_client::send_to_server(&packet, sizeof packet); - //MessageBoxA(0, std::to_string(statValue).c_str(), "statValue", 0); - - if (statValue >= val) { - static d2_tweaks::common::item_move_cs packet; - packet.item_guid = bagGuid; - packet.bag_guid = bagGuid; - packet.target_page = 0; - packet.extract = 1; - packet.iCode = itemCode; - packet.prop = prop - 3; - packet.val = -val; - diablo2::d2_client::send_to_server(&packet, sizeof packet); - - D2PropertyStrc itemProperty = {}; - itemProperty.nProperty = prop - 3; // Adjust the property ID - itemProperty.nLayer = 0; - itemProperty.nMin = -val; - itemProperty.nMax = -val; - diablo2::d2_common::add_property(bag, &itemProperty, 0); + D2PropertyStrc itemProperty = {}; + itemProperty.nProperty = prop - 3; // Adjust the property ID + itemProperty.nLayer = 0; + itemProperty.nMin = -val; + itemProperty.nMax = -val; + diablo2::d2_common::add_property(bag, &itemProperty, 0); + } } } diff --git a/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp b/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp index bede0df..da3f7d8 100644 --- a/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp +++ b/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp @@ -133,6 +133,7 @@ d2_tweaks::client::modules::loot_filter_settings_toggle_menu::loot_filter_settin void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_filter_settings_click() { m_show = !m_show; + m_stats_enabled = !m_stats_enabled; m_filter_settings_menu->set_enabled(m_show); m_filter_settings_menu->set_visible(m_show); @@ -251,6 +252,20 @@ void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::draw() { } bool d2_tweaks::client::modules::loot_filter_settings_toggle_menu::key_event(uint32_t key, bool up) { + + if (key == 'E' && up) { + m_show = !m_show; + m_stats_enabled = !m_stats_enabled; + + m_filter_settings_menu->set_enabled(m_show); + m_filter_settings_menu->set_visible(m_show); + + m_btn_toggle_stats->set_enabled(true); + m_btn_toggle_stats->set_visible(true); + } + return menu::key_event(key, up); + + if (key == VK_ESCAPE && m_show) { m_show = false; diff --git a/src/d2tweaks/server/modules/item_move/item_move_server.cpp b/src/d2tweaks/server/modules/item_move/item_move_server.cpp index 23076f7..0434850 100644 --- a/src/d2tweaks/server/modules/item_move/item_move_server.cpp +++ b/src/d2tweaks/server/modules/item_move/item_move_server.cpp @@ -56,7 +56,7 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g // Display key in a message box //MessageBox(NULL, key, "Item code", MB_OK | MB_ICONINFORMATION); - const auto item = instance.get_server_unit(game, itemMove->item_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item + auto item = instance.get_server_unit(game, itemMove->item_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item const auto record = diablo2::d2_common::get_item_record(item->data_record_index); @@ -123,13 +123,20 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g //diablo2::d2_common::set_unit_mode(item, 0); // mode 4 - предмет нельзя взять мышкой из инвентаря, mode 0 - обычный режим + // here we need to remove the item if item data page is 99 + //if (itemMove->target_page == 99) { + // diablo2::d2_common::inv_remove_item(player->inventory, item); + //} + + item->item_data->page = itemMove->target_page; - diablo2::d2_common::inv_add_item(player->inventory, item, tx, ty, inventoryIndex, false, item->item_data->page); - diablo2::d2_common::inv_update_item(player->inventory, item, false); - - diablo2::d2_game::update_inventory_items(game, player); + //if (itemMove->target_page != 99) { + diablo2::d2_common::inv_add_item(player->inventory, item, tx, ty, inventoryIndex, false, item->item_data->page); + diablo2::d2_common::inv_update_item(player->inventory, item, false); + diablo2::d2_game::update_inventory_items(game, player); + //} //send update packet resp.item_guid = itemMove->item_guid; resp.target_page = itemMove->target_page; diff --git a/src/d2tweaks/ui/ui_manager.cpp b/src/d2tweaks/ui/ui_manager.cpp index 0818702..b48aaa1 100644 --- a/src/d2tweaks/ui/ui_manager.cpp +++ b/src/d2tweaks/ui/ui_manager.cpp @@ -40,6 +40,8 @@ #include #include // Include for edit control +#include "d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.h" + // Define a static variable to keep track of the last time the stash window was toggled static std::chrono::steady_clock::time_point lastToggleTime; @@ -543,6 +545,13 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, block = true; // block the game from processing this key } + // Send transmute packet + if (wParam == 'E') { + // send packet from server to client + block = true; // block the game from processing this key + } + + if (wParam == 'V') { // Define a cooldown duration in milliseconds constexpr int cooldownDuration = 500; // Adjust this value as needed