mirror of
https://gitlab.com/hashborgir/d2tweaks-rnd2k.git
synced 2025-11-29 20:31:36 -06:00
Stats display refactor using ini file done.
This commit is contained in:
@@ -10,13 +10,13 @@
|
||||
#include <common/string_utils.h>
|
||||
|
||||
d2_tweaks::ui::controls::button::button(menu* menu,
|
||||
const rect& rect, const std::function<void()>& onClick,
|
||||
common::asset* image,
|
||||
int32_t frameDown, int32_t frameUp, int32_t clickSound) : control(menu,
|
||||
rect.get_x(),
|
||||
rect.get_y(),
|
||||
rect.get_width(),
|
||||
rect.get_height()) {
|
||||
const rect& rect, const std::function<void()>& onClick,
|
||||
common::asset* image,
|
||||
int32_t frameDown, int32_t frameUp, int32_t clickSound) : control(menu,
|
||||
rect.get_x(),
|
||||
rect.get_y(),
|
||||
rect.get_width(),
|
||||
rect.get_height()) {
|
||||
control::set_enabled(true);
|
||||
control::set_visible(true);
|
||||
|
||||
@@ -42,8 +42,6 @@ d2_tweaks::ui::controls::button::button(menu* menu,
|
||||
// uint32_t pos_y;
|
||||
//};
|
||||
|
||||
|
||||
|
||||
d2_tweaks::ui::controls::button::button(menu* menu, const pugi::xml_node& node) : control(menu, 0, 0, 0, 0) {
|
||||
char buf[32] = { 0 };
|
||||
|
||||
@@ -51,7 +49,7 @@ d2_tweaks::ui::controls::button::button(menu* menu, const pugi::xml_node& node)
|
||||
auto cy = node.attribute("default_pos_y").as_int(0);
|
||||
|
||||
m_res_count = node.attribute("resolution_count").as_int(1);
|
||||
|
||||
|
||||
respos temp;
|
||||
for (uint32_t i = 1; i <= m_res_count; i++) {
|
||||
sprintf_s(buf, "res%d_x", i);
|
||||
@@ -143,9 +141,9 @@ void d2_tweaks::ui::controls::button::draw(int32_t offsetX, int32_t offsetY) {
|
||||
!m_popup.empty()) {
|
||||
diablo2::d2_win::set_current_font(diablo2::UI_FONT_16);
|
||||
diablo2::d2_win::set_popup_properties(const_cast<wchar_t*>(m_popup.c_str()),
|
||||
get_x() + offsetX + m_rect.get_width() / 2,
|
||||
get_y() + offsetY - m_rect.get_height(),
|
||||
diablo2::UI_COLOR_WHITE, TRUE);
|
||||
get_x() + offsetX + m_rect.get_width() / 2,
|
||||
get_y() + offsetY - m_rect.get_height(),
|
||||
diablo2::UI_COLOR_WHITE, TRUE);
|
||||
diablo2::d2_win::draw_popup();
|
||||
}
|
||||
|
||||
@@ -185,4 +183,4 @@ void d2_tweaks::ui::controls::button::left_mouse(int32_t offsetX, int32_t offset
|
||||
|
||||
void d2_tweaks::ui::controls::button::right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) {}
|
||||
|
||||
void d2_tweaks::ui::controls::button::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
|
||||
void d2_tweaks::ui::controls::button::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
|
||||
@@ -9,13 +9,13 @@
|
||||
const int32_t PADDING = 3;
|
||||
|
||||
d2_tweaks::ui::controls::checkbox::checkbox(menu* menu, const std::wstring& text, const rect& rect,
|
||||
const std::function<void()>& onClick,
|
||||
common::asset* image, int32_t frameChecked, int32_t frameUnchecked, int32_t clickSound)
|
||||
const std::function<void()>& onClick,
|
||||
common::asset* image, int32_t frameChecked, int32_t frameUnchecked, int32_t clickSound)
|
||||
: control(menu,
|
||||
rect.get_x(),
|
||||
rect.get_y(),
|
||||
rect.get_width(),
|
||||
rect.get_height()) {
|
||||
rect.get_x(),
|
||||
rect.get_y(),
|
||||
rect.get_width(),
|
||||
rect.get_height()) {
|
||||
control::set_enabled(true);
|
||||
control::set_visible(true);
|
||||
|
||||
@@ -72,7 +72,7 @@ d2_tweaks::ui::controls::checkbox::checkbox(menu* menu, const pugi::xml_node& no
|
||||
|
||||
m_image = new image(menu, cimg, cx, cy, m_frame_unchecked);
|
||||
m_label = new label(menu, string_utils::string_to_wstring(ctext), cx + m_image->get_width() + PADDING, cy,
|
||||
static_cast<diablo2::ui_color_t>(ccolor), static_cast<diablo2::ui_font_t>(cfont));
|
||||
static_cast<diablo2::ui_color_t>(ccolor), static_cast<diablo2::ui_font_t>(cfont));
|
||||
|
||||
checkbox::set_x(cx);
|
||||
checkbox::set_y(cy);
|
||||
@@ -103,9 +103,9 @@ void d2_tweaks::ui::controls::checkbox::draw(int32_t offsetX, int32_t offsetY) {
|
||||
!m_popup.empty()) {
|
||||
diablo2::d2_win::set_current_font(diablo2::UI_FONT_16);
|
||||
diablo2::d2_win::set_popup_properties(const_cast<wchar_t*>(m_popup.c_str()),
|
||||
get_x() + offsetX + m_rect.get_width() / 2,
|
||||
get_y() + offsetY - m_rect.get_height(),
|
||||
diablo2::UI_COLOR_WHITE, TRUE);
|
||||
get_x() + offsetX + m_rect.get_width() / 2,
|
||||
get_y() + offsetY - m_rect.get_height(),
|
||||
diablo2::UI_COLOR_WHITE, TRUE);
|
||||
diablo2::d2_win::draw_popup();
|
||||
}
|
||||
|
||||
@@ -152,4 +152,4 @@ void d2_tweaks::ui::controls::checkbox::left_mouse(int32_t offsetX, int32_t offs
|
||||
|
||||
void d2_tweaks::ui::controls::checkbox::right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) {}
|
||||
|
||||
void d2_tweaks::ui::controls::checkbox::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
|
||||
void d2_tweaks::ui::controls::checkbox::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
|
||||
@@ -88,7 +88,7 @@ void d2_tweaks::ui::controls::group::right_mouse(int32_t offsetX, int32_t offset
|
||||
}
|
||||
|
||||
void d2_tweaks::ui::controls::group::key_event(int32_t offsetX, int32_t offsetY,
|
||||
uint32_t key, bool up, bool& block) {
|
||||
uint32_t key, bool up, bool& block) {
|
||||
for (auto control : m_controls) {
|
||||
if (!control->get_enabled())
|
||||
continue;
|
||||
@@ -105,4 +105,4 @@ void d2_tweaks::ui::controls::group::add_control(control* control) {
|
||||
return;
|
||||
|
||||
get_menu()->add_control(control);
|
||||
}
|
||||
}
|
||||
@@ -92,4 +92,4 @@ void d2_tweaks::ui::controls::image::right_mouse(int32_t offsetX, int32_t offset
|
||||
block = m_rect.contains(diablo2::d2_client::get_mouse_x(), diablo2::d2_client::get_mouse_y(), offsetX, offsetY);
|
||||
}
|
||||
|
||||
void d2_tweaks::ui::controls::image::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
|
||||
void d2_tweaks::ui::controls::image::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <diablo2/d2client.h>
|
||||
|
||||
d2_tweaks::ui::controls::label::label(menu* menu, const std::wstring& text, int32_t x, int32_t y, diablo2::ui_color_t color,
|
||||
diablo2::ui_font_t font) : control(menu, x, y, 0, 0) {
|
||||
diablo2::ui_font_t font) : control(menu, x, y, 0, 0) {
|
||||
control::set_enabled(true);
|
||||
control::set_visible(true);
|
||||
|
||||
@@ -97,4 +97,4 @@ void d2_tweaks::ui::controls::label::left_mouse(int32_t offsetX, int32_t offsetY
|
||||
|
||||
void d2_tweaks::ui::controls::label::right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) {}
|
||||
|
||||
void d2_tweaks::ui::controls::label::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
|
||||
void d2_tweaks::ui::controls::label::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
|
||||
@@ -70,7 +70,6 @@ bool d2_tweaks::ui::menu::load_xml(const char* path) {
|
||||
m_respos.push_back(temp);
|
||||
}
|
||||
|
||||
|
||||
m_name = menuNode.node().attribute("name").as_string();
|
||||
m_width = menuNode.node().attribute("width").as_int(-1);
|
||||
m_height = menuNode.node().attribute("height").as_int(-1);
|
||||
@@ -220,7 +219,6 @@ bool d2_tweaks::ui::menu::mouse_wheel(bool up) {
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
bool d2_tweaks::ui::menu::key_event(uint32_t key, bool up) {
|
||||
auto block = false;
|
||||
|
||||
@@ -234,4 +232,4 @@ bool d2_tweaks::ui::menu::key_event(uint32_t key, bool up) {
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,8 @@
|
||||
#include <string>
|
||||
#include <CommCtrl.h> // Include for edit control
|
||||
|
||||
#include <d2tweaks/client/client.h>
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
using namespace std;
|
||||
@@ -220,7 +222,7 @@ diablo2::structures::unit unserialize_item(const std::string& hexString) {
|
||||
}
|
||||
|
||||
// Create an item object
|
||||
diablo2::structures::unit item;
|
||||
diablo2::structures::unit item{};
|
||||
|
||||
// Convert the hexadecimal string to binary data
|
||||
for (size_t i = 0; i < hexString.size(); i += 2) {
|
||||
@@ -244,6 +246,38 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
block = true; // block the game from processing this key
|
||||
}
|
||||
|
||||
if (wParam == 'V') {
|
||||
const auto player = diablo2::d2_client::get_local_player();
|
||||
int32_t st0Guid = 0;
|
||||
uint32_t st0X = 0;
|
||||
uint32_t st0Y = 0;
|
||||
diablo2::structures::unit* box{};
|
||||
for (auto item = player->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);
|
||||
char* st0Code = record->string_code;
|
||||
if (strncmp(st0Code, "st0", 3) == 0) {
|
||||
box = item;
|
||||
st0Guid = box->guid;
|
||||
st0X = player->path->mapx;
|
||||
st0Y = player->path->mapy;
|
||||
}
|
||||
}
|
||||
struct D2GSPacketClt20 {
|
||||
uint8_t PacketId; // 0x01
|
||||
uint32_t guid; // 0x06
|
||||
uint32_t tx; // 0x07
|
||||
uint32_t ty; // 0x09
|
||||
};
|
||||
D2GSPacketClt20 packet;
|
||||
packet.PacketId = 0x20;
|
||||
packet.guid = st0Guid;
|
||||
packet.tx = st0X;
|
||||
packet.ty = st0Y;
|
||||
diablo2::d2_client::send_to_server(&packet, sizeof packet);
|
||||
m_stash_enabled = false;
|
||||
block = true;
|
||||
}
|
||||
|
||||
// Send item move packet + transmute packet for certain codes only for runes and gems
|
||||
if (wParam == 'G') {
|
||||
// Call the item_click function using the function pointer
|
||||
@@ -1607,7 +1641,6 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
|| record->type == 53 - 3
|
||||
|
||||
) {
|
||||
|
||||
// open the cube
|
||||
struct D2GSPacketClt20 {
|
||||
uint8_t PacketId; // 0x01
|
||||
@@ -1655,7 +1688,6 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
}
|
||||
diablo2::d2_client::send_to_server(&packet, sizeof packet);
|
||||
diablo2::d2_client::send_to_server_7(0x4F, 0x18, 0, 0);
|
||||
|
||||
|
||||
// now move the harvester back to the inv
|
||||
//static d2_tweaks::common::item_move_cs h1packet;
|
||||
@@ -1664,7 +1696,6 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
//diablo2::d2_client::send_to_server(&h1packet, sizeof h1packet);
|
||||
|
||||
(*reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4)) = nullptr;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user