-
Notifications
You must be signed in to change notification settings - Fork 1
/
InventoryGrid.h
94 lines (90 loc) · 3.33 KB
/
InventoryGrid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once
#include "4dm.h"
#include "Inventory.h"
#include "TexRenderer.h"
#include "FontRenderer.h"
#include "Item.h"
namespace fdm
{
class Inventory;
class TexRenderer;
class FontRenderer;
class Item;
class InventoryGrid : public Inventory
{
public:
inline static TexRenderer* tr = reinterpret_cast<TexRenderer*>((base + 0x2BE5B8));
inline static FontRenderer* fr = reinterpret_cast<FontRenderer*>((base + 0x279360));
glm::ivec2 renderPos; // 0x30
glm::ivec2 size; // 0x38
int selectedIndex; // 0x40
PAD(0x4);
stl::string label; // 0x48
std::vector<std::unique_ptr<Item>> slots; // 0x68
~InventoryGrid()
{
reinterpret_cast<void(__thiscall*)(InventoryGrid* self)>(getFuncAddr((int)Func::InventoryGrid::destr_InventoryGrid))(this);
}
InventoryGrid() {}
InventoryGrid(const glm::ivec2& size)
{
reinterpret_cast<void(__thiscall*)(InventoryGrid* self, const glm::ivec2& size)>(getFuncAddr((int)Func::InventoryGrid::InventoryGrid))(this, size);
}
bool addItem(std::unique_ptr<Item>& item) override
{
// decompiled from InventoryPlayer loooool. also yea i didnt bother fixing/optimizing it. fuck it. its literally 3:38.
auto v4 = combineItem(item);
if (!item.get())
return v4;
auto v5 = placeItem(item);
if (v5)
return true;
return v4;
}
void render(const glm::ivec2& cursorPos) override
{
return reinterpret_cast<void (__thiscall*)(InventoryGrid* self, const glm::ivec2& cursorPos)>(getFuncAddr((int)Func::InventoryGrid::render))(this, cursorPos);
}
bool combineItem(std::unique_ptr<Item>& item) override
{
return reinterpret_cast<bool (__thiscall*)(InventoryGrid* self, std::unique_ptr<Item>& item)>(getFuncAddr((int)Func::InventoryGrid::combineItem))(this, item);
}
bool placeItem(std::unique_ptr<Item>& item) override
{
return reinterpret_cast<bool (__thiscall*)(InventoryGrid* self, std::unique_ptr<Item>& item)>(getFuncAddr((int)Func::InventoryGrid::placeItem))(this, item);
}
int getSlotIndex(const glm::ivec2& cursorPos) override
{
return reinterpret_cast<int (__thiscall*)(InventoryGrid* self, const glm::ivec2& cursorPos)>(getFuncAddr((int)Func::InventoryGrid::getSlotIndex))(this, cursorPos);
}
uint32_t getSlotCount() override
{
return reinterpret_cast<uint32_t (__thiscall*)(InventoryGrid* self)>(getFuncAddr((int)Func::InventoryGrid::getSlotCount))(this);
}
std::unique_ptr<Item>* getSlot(int index) override
{
return reinterpret_cast<std::unique_ptr<Item>* (__thiscall*)(InventoryGrid* self, int index)>(getFuncAddr((int)Func::InventoryGrid::getSlot))(this, index);
}
Inventory::iterator begin() override
{
// bruh. 3:39 btw
return Inventory::iterator{ this, 0 };
}
Inventory::iterator end() override
{
iterator result;
return reinterpret_cast<Inventory::iterator& (__thiscall*)(InventoryGrid* self, Inventory::iterator* result)>(getFuncAddr((int)Func::InventoryGrid::end))(this, &result);
return result;
}
void load(nlohmann::json& j)
{
return reinterpret_cast<void (__thiscall*)(InventoryGrid* self, nlohmann::json& j)>(getFuncAddr((int)Func::InventoryGrid::load))(this, j);
}
nlohmann::json save()
{
nlohmann::json result;
return reinterpret_cast<nlohmann::json& (__thiscall*)(InventoryGrid* self, nlohmann::json* result)>(getFuncAddr((int)Func::InventoryGrid::save))(this, &result);
return result;
}
};
}