Initial commit

This commit is contained in:
Hash Borgir
2024-04-16 21:45:38 -06:00
commit 3159020c38
533 changed files with 135446 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
#pragma once
#include <d2tweaks/ui/controls/control.h>
#include <d2tweaks/ui/rect.h>
#include <cstdint>
#include <functional>
#include <pugixml.hpp>
namespace diablo2 {
namespace structures {
struct cell_file;
}
}
namespace d2_tweaks {
namespace common {
class asset;
}
namespace ui {
namespace controls {
class image;
class button final : public control {
rect m_rect;
image* m_image;
int32_t m_frame_down;
int32_t m_frame_up;
int32_t m_click_sound;
bool m_is_down;
int32_t m_current_frame;
uint32_t m_res_count;
std::wstring m_popup;
std::function<void()> m_on_click;
std::vector<respos> m_respos;
public:
button(menu* menu, const rect& rect, const std::function<void()>& onClick,
common::asset* image, int32_t frameDown, int32_t frameUp, int32_t clickSound = -1);
explicit button(menu* menu, const pugi::xml_node& node);
virtual ~button();
void set_x(int32_t value) override;
int32_t get_x() const override {
return m_rect.get_x();
}
void set_y(int32_t value) override;
int32_t get_y() const override {
return m_rect.get_y();
}
std::wstring popup() const {
return m_popup;
}
void set_popup(const std::wstring& popup) {
m_popup = popup;
}
void set_current_frame(int32_t value) {
m_current_frame = value;
}
int32_t get_current_frame() {
return m_current_frame;
}
std::function<void()> get_on_click() const {
return m_on_click;
}
void set_on_click(const std::function<void()>& on_click) {
m_on_click = on_click;
}
void draw() override;
void draw(int32_t offsetX, int32_t offsetY) override;
void left_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) override;
void right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) override;
void key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) override;
};
}
}
}

View File

@@ -0,0 +1,85 @@
#pragma once
#include <d2tweaks/ui/controls/control.h>
#include <pugixml.hpp>
#include <functional>
#include <d2tweaks/ui/rect.h>
namespace d2_tweaks {
namespace common {
class asset;
}
}
namespace d2_tweaks {
namespace ui {
namespace controls {
class image;
class label;
class checkbox : public control {
rect m_rect;
image* m_image;
label* m_label;
std::wstring m_popup;
int32_t m_frame_checked;
int32_t m_frame_unchecked;
int32_t m_click_sound;
bool m_is_down;
bool m_state;
std::function<void(bool)> m_on_click;
public:
explicit 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 = -1);
explicit checkbox(menu* menu, const pugi::xml_node& node);
void set_x(int32_t value) override;
int32_t get_x() const override {
return m_rect.get_x();
}
void set_y(int32_t value) override;
int32_t get_y() const override {
return m_rect.get_y();
}
std::wstring popup() const {
return m_popup;
}
void set_popup(const std::wstring& popup) {
m_popup = popup;
}
std::function<void(bool)> get_on_click() const {
return m_on_click;
}
void set_on_click(const std::function<void(bool)>& on_click) {
m_on_click = on_click;
}
bool get_state() const {
return m_state;
}
void set_state(bool value) {
m_state = value;
}
void draw() override;
void draw(int32_t offsetX, int32_t offsetY) override;
void left_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) override;
void right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) override;
void key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) override;
};
}
}
}

View File

@@ -0,0 +1,120 @@
#pragma once
#include <string>
#include <cstdint>
namespace d2_tweaks {
namespace ui {
class menu;
namespace controls {
struct respos {
uint32_t res_x;
uint32_t res_y;
uint32_t pos_x;
uint32_t pos_y;
};
class control {
control* m_parent;
menu* m_menu;
std::string m_name;
bool m_enabled = false;
bool m_visible = false;
int32_t m_x;
int32_t m_y;
int32_t m_width;
int32_t m_height;
public:
control(menu* menu, int32_t x, int32_t y, int32_t w, int32_t h) : m_parent(nullptr),
m_menu(menu),
m_x(x), m_y(y),
m_width(w), m_height(h) {}
virtual ~control() = default;
control* get_parent() const {
return m_parent;
}
void set_parent(control* const parent) {
m_parent = parent;
}
menu* get_menu() const {
return m_menu;
}
void set_menu(menu* const menu) {
m_menu = menu;
}
std::string get_name() const {
return m_name;
}
void set_name(const std::string& name) {
m_name = name;
}
virtual bool get_enabled() const {
return m_enabled;
}
virtual void set_enabled(bool value) {
m_enabled = value;
}
virtual bool get_visible() const {
return m_visible;
}
virtual void set_visible(bool value) {
m_visible = value;
}
virtual int32_t get_x() const {
return m_x;
}
virtual void set_x(int32_t value) {
m_x = value;
}
virtual int32_t get_y() const {
return m_y;
}
virtual void set_y(int32_t value) {
m_y = value;
}
virtual int32_t get_width() const {
return m_width;
}
virtual void set_width(const int32_t width) {
m_width = width;
}
virtual int32_t get_height() const {
return m_height;
}
virtual void set_height(const int32_t height) {
m_height = height;
}
virtual void draw() = 0;
virtual void draw(int32_t offsetX, int32_t offsetY) = 0;
virtual void left_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) = 0;
virtual void right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) = 0;
virtual void key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) = 0;
};
}
}
}

View File

@@ -0,0 +1,31 @@
#pragma once
#include <d2tweaks/ui/controls/control.h>
#include <pugixml.hpp>
#include <vector>
namespace d2_tweaks {
namespace ui {
class menu;
namespace controls {
class group : public control {
std::vector<control*> m_controls;
public:
explicit group(menu* menu, int32_t x, int32_t y);
explicit group(menu* menu, const pugi::xml_node& node);
void draw() override;
void draw(int32_t offsetX, int32_t offsetY) override;
void left_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) override;
void right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) override;
void key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) override;
private:
void add_control(control* control);
};
}
}
}

View File

@@ -0,0 +1,45 @@
#pragma once
#include <d2tweaks/ui/controls/control.h>
#include <diablo2/structures/gfxdata.h>
#include <pugixml.hpp>
#include <d2tweaks/ui/rect.h>
namespace d2_tweaks {
namespace common {
class asset;
}
namespace ui {
namespace controls {
class image : public control {
common::asset* m_image;
int32_t m_frame;
rect m_rect;
bool m_block_click;
diablo2::structures::gfxdata m_draw_info;
public:
explicit image(menu* menu, common::asset* image, int32_t x = 0, int32_t y = 0, int32_t frame = 0);
explicit image(menu* menu, const pugi::xml_node& node);
void set_frame(int32_t frame) {
m_frame = static_cast<uint32_t>(frame);
}
int32_t get_frame() const {
return static_cast<int32_t>(m_frame);
}
void draw() override;
void draw(int32_t offsetX, int32_t offsetY) override;
void left_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) override;
void right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) override;
void key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) override;
};
}
}
}

View File

@@ -0,0 +1,61 @@
#pragma once
#include <d2tweaks/ui/controls/control.h>
#include <vector>
#include <pugixml.hpp>
#include <diablo2/d2win.h>
namespace d2_tweaks {
namespace ui {
namespace controls {
class label : public control {
std::wstring m_text;
bool m_text_owned;
diablo2::ui_color_t m_color;
diablo2::ui_font_t m_font;
uint32_t m_res_count;
std::vector<respos> m_respos;
public:
explicit label(menu* menu, const std::wstring& text, int32_t x = 0, int32_t y = 0,
diablo2::ui_color_t color = diablo2::UI_COLOR_WHITE,
diablo2::ui_font_t font = diablo2::UI_FONT_16);
explicit label(menu* menu, const pugi::xml_node& node);
void set_text(const std::wstring& text) {
m_text = text;
}
const std::wstring& get_text() const {
return m_text;
}
diablo2::ui_color_t get_color() const {
return m_color;
}
void set_color(const diablo2::ui_color_t color) {
m_color = color;
}
diablo2::ui_font_t get_font() const {
return m_font;
}
void set_font(const diablo2::ui_font_t font) {
m_font = font;
}
void draw() override;
void draw(int32_t offsetX, int32_t offsetY) override;
void left_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) override;
void right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) override;
void key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) override;
};
}
}
}