Working on save-load system and UI

This commit is contained in:
Vladislav Khorev committed 2026-06-20 21:41:07 +03:00
1 parent 901142385d
commit d7db0faea3
29 files changed
+708 -180

No files matched your search

+6 -4
View File
@@ -3,6 +3,7 @@
#include <memory>
#include <vector>
#include <functional>
#include "ISaveable.h"
namespace ZL {
@@ -19,11 +20,9 @@ namespace ZL {
}
};
class Inventory {
private:
std::vector<Item> items;
class Inventory : public ISaveable {
public:
std::vector<Item> items;
void addItem(const Item& item);
void removeItem(const std::string& itemId);
const std::vector<Item>& getItems() const { return items; }
@@ -31,6 +30,9 @@ namespace ZL {
void clear() { items.clear(); }
size_t getCount() const { return items.size(); }
void save(nlohmann::json& out) const override;
void load(const nlohmann::json& in) override;
// Called whenever an item is added/removed; receives the item id.
std::function<void(const std::string&)> onItemAdded;
std::function<void(const std::string&)> onItemRemoved;