1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-05-14 20:47:46 +00:00

Load a bunch of possible LGB files

This now loads the various LGB names I know of when opening a map in the
editor, and they are properly categorized in the object list widget. The
next step is drawing these in the view or adding a property pane.
This commit is contained in:
Joshua Goins 2025-05-13 16:08:19 -04:00
parent 8ba4d0ba6f
commit 66808619f3
3 changed files with 40 additions and 23 deletions

View file

@ -12,7 +12,7 @@ class AppState : public QObject
public:
explicit AppState(QObject *parent = nullptr);
physis_LayerGroup bgGroup;
std::vector<std::pair<QString, physis_LayerGroup>> lgbFiles;
Q_SIGNALS:
void mapLoaded();

View file

@ -85,11 +85,24 @@ void MainWindow::openMap(const QString &basePath)
setWindowTitle(basePath);
QString lgbPath = QStringLiteral("bg/%1/level/bg.lgb").arg(base2Path);
std::string bgLgbPathStd = lgbPath.toStdString();
const auto loadLgb = [this, base2Path](const QString &name) {
QString lgbPath = QStringLiteral("bg/%1/level/%2.lgb").arg(base2Path, name);
std::string bgLgbPathStd = lgbPath.toStdString();
auto bg_buffer = physis_gamedata_extract_file(data, bgLgbPathStd.c_str());
m_appState->bgGroup = physis_layergroup_read(bg_buffer);
auto bg_buffer = physis_gamedata_extract_file(data, bgLgbPathStd.c_str());
auto lgb = physis_layergroup_read(bg_buffer);
if (lgb.num_chunks > 0) {
m_appState->lgbFiles.push_back({name, lgb});
}
};
loadLgb(QStringLiteral("planevent"));
loadLgb(QStringLiteral("vfx"));
loadLgb(QStringLiteral("planmap"));
loadLgb(QStringLiteral("planner"));
loadLgb(QStringLiteral("bg"));
loadLgb(QStringLiteral("sound"));
loadLgb(QStringLiteral("planlive"));
Q_EMIT m_appState->mapLoaded();
}

View file

@ -103,26 +103,30 @@ void ObjectListModel::refresh()
{
beginResetModel();
auto fileItem = new TreeInformation();
fileItem->type = TreeType::File;
fileItem->parent = m_rootItem;
fileItem->name = QStringLiteral("bg");
m_rootItem->children.push_back(fileItem);
for (int y = 0; y < m_appState->lgbFiles.size(); y++) {
const auto &[name, lgb] = m_appState->lgbFiles[y];
for (int i = 0; i < m_appState->bgGroup.num_chunks; i++) {
const auto chunk = m_appState->bgGroup.chunks[i];
for (int j = 0; j < chunk.num_layers; j++) {
const auto layer = chunk.layers[j];
for (int z = 0; z < layer.num_objects; z++) {
const auto object = layer.objects[z];
const QString name = QString::fromLatin1(object.name);
auto fileItem = new TreeInformation();
fileItem->type = TreeType::File;
fileItem->parent = m_rootItem;
fileItem->name = name;
fileItem->row = y;
m_rootItem->children.push_back(fileItem);
auto objectItem = new TreeInformation();
objectItem->type = TreeType::Object;
objectItem->parent = fileItem;
objectItem->name = i18n("Unknown (%1)", object.instance_id); // TODO: do display names if we have them
objectItem->row = z;
fileItem->children.push_back(objectItem);
for (int i = 0; i < lgb.num_chunks; i++) {
const auto chunk = lgb.chunks[i];
for (int j = 0; j < chunk.num_layers; j++) {
const auto layer = chunk.layers[j];
for (int z = 0; z < layer.num_objects; z++) {
const auto object = layer.objects[z];
auto objectItem = new TreeInformation();
objectItem->type = TreeType::Object;
objectItem->parent = fileItem;
objectItem->name = i18n("Unknown (%1)", object.instance_id); // TODO: do display names if we have them
objectItem->row = z;
fileItem->children.push_back(objectItem);
}
}
}
}