Finish lerge refactor of systems

This commit is contained in:
Carl Philipp Klemm 2026-03-22 23:23:18 +01:00
parent 6d742e60db
commit 913d7df56d
36 changed files with 614 additions and 634 deletions

View file

@ -0,0 +1,38 @@
#include "itemloadersource.h"
#include <QJsonArray>
ItemLoaderSource::ItemLoaderSource(const QJsonObject& json, QObject *parent):
ItemSource{parent},
json(json)
{
}
void ItemLoaderSource::refresh()
{
std::vector<std::shared_ptr<Item>> items;
const QJsonArray itemsArray(json["Items"].toArray());
for(int i = 0; i < itemsArray.size(); ++i)
{
if(!itemsArray[i].isObject())
continue;
const QJsonObject itemObject = itemsArray[i].toObject();
std::shared_ptr<Item> newItem = Item::loadItem(itemObject);
if(newItem)
{
items.push_back(newItem);
qDebug()<<"Loaded item"<<newItem->getName();
}
}
gotItems(items);
}
void ItemLoaderSource::updateJson(const QJsonObject& json)
{
this->json = json;
}
ItemLoaderSource::~ItemLoaderSource()
{}