mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-11 14:41:57 +00:00
Mass refactoring part 1/2: establishing multiple subprojects, moving source files to their new location, adding resources/templates to version control
This commit is contained in:
48
src/Editor/WorldEditor/CLayerModel.cpp
Normal file
48
src/Editor/WorldEditor/CLayerModel.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "CLayerModel.h"
|
||||
#include "../UICommon.h"
|
||||
#include <Resource/script/CScriptLayer.h>
|
||||
|
||||
CLayerModel::CLayerModel(QObject *pParent) : QAbstractListModel(pParent)
|
||||
{
|
||||
mpArea = nullptr;
|
||||
mHasGenerateLayer = false;
|
||||
}
|
||||
|
||||
CLayerModel::~CLayerModel()
|
||||
{
|
||||
}
|
||||
|
||||
int CLayerModel::rowCount(const QModelIndex& /*parent*/) const
|
||||
{
|
||||
if (!mpArea) return 0;
|
||||
if (mHasGenerateLayer) return mpArea->GetScriptLayerCount() + 1;
|
||||
else return mpArea->GetScriptLayerCount();
|
||||
}
|
||||
|
||||
QVariant CLayerModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (mpArea && (role == Qt::DisplayRole) && (index.row() < rowCount(QModelIndex())))
|
||||
return TO_QSTRING(Layer(index)->Name());
|
||||
|
||||
return QVariant::Invalid;
|
||||
}
|
||||
|
||||
void CLayerModel::SetArea(CGameArea *pArea)
|
||||
{
|
||||
mpArea = pArea;
|
||||
mHasGenerateLayer = (pArea->GetGeneratorLayer() != nullptr);
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
CScriptLayer* CLayerModel::Layer(const QModelIndex& index) const
|
||||
{
|
||||
if (!mpArea) return nullptr;
|
||||
u32 NumLayers = mpArea->GetScriptLayerCount();
|
||||
|
||||
if (index.row() < (int) NumLayers)
|
||||
return mpArea->GetScriptLayer(index.row());
|
||||
if (mHasGenerateLayer && (index.row() == NumLayers))
|
||||
return mpArea->GetGeneratorLayer();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
Reference in New Issue
Block a user