forked from teamnwah/openmw-tes3coop
Drop textures to landtextures from assets (try-method)
This commit is contained in:
parent
7139889566
commit
e8a9bff85c
2 changed files with 55 additions and 0 deletions
|
@ -271,6 +271,16 @@ void CSVRender::TerrainTextureMode::handleDropEvent (QDropEvent *event) {
|
|||
emit passBrushTexture(mBrushTexture);
|
||||
}
|
||||
}
|
||||
if (mime->holdsType (CSMWorld::UniversalId::Type_Texture))
|
||||
{
|
||||
const std::vector<CSMWorld::UniversalId> ids = mime->getData();
|
||||
|
||||
for (const CSMWorld::UniversalId& uid : ids)
|
||||
{
|
||||
std::string textureFileName = uid.toString();
|
||||
createTexture(textureFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSVRender::TerrainTextureMode::handleMouseEvent (QMouseEvent *event)
|
||||
|
@ -446,6 +456,48 @@ void CSVRender::TerrainTextureMode::pushEditToCommand(CSMWorld::LandTexturesColu
|
|||
undoStack.push (new CSMWorld::ModifyCommand(landTable, index, changedLand));
|
||||
}
|
||||
|
||||
void CSVRender::TerrainTextureMode::createTexture(std::string textureFileName)
|
||||
{
|
||||
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
||||
|
||||
CSMWorld::IdTable& ltexTable = dynamic_cast<CSMWorld::IdTable&> (
|
||||
*document.getData().getTableModel (CSMWorld::UniversalId::Type_LandTextures));
|
||||
|
||||
QUndoStack& undoStack = document.getUndoStack();
|
||||
|
||||
std::string newId;
|
||||
|
||||
int counter=0;
|
||||
bool freeIndexFound = false;
|
||||
do {
|
||||
const size_t maxCounter = std::numeric_limits<uint16_t>::max() - 1;
|
||||
try
|
||||
{
|
||||
newId = CSMWorld::LandTexture::createUniqueRecordId(0, counter);
|
||||
if (ltexTable.getRecord(newId).isDeleted() == 0) counter = (counter + 1) % maxCounter;
|
||||
} catch (const std::exception& e)
|
||||
{
|
||||
newId = CSMWorld::LandTexture::createUniqueRecordId(0, counter);
|
||||
freeIndexFound = true;
|
||||
}
|
||||
} while (freeIndexFound == false);
|
||||
|
||||
std::size_t idlocation = textureFileName.find("Texture: ");
|
||||
textureFileName = textureFileName.substr (idlocation + 9);
|
||||
|
||||
QVariant textureNameVariant;
|
||||
|
||||
QVariant textureFileNameVariant;
|
||||
textureFileNameVariant.setValue(QString::fromStdString(textureFileName));
|
||||
|
||||
undoStack.beginMacro ("Add land texture record");
|
||||
|
||||
undoStack.push (new CSMWorld::CreateCommand (ltexTable, newId));
|
||||
QModelIndex index(ltexTable.getModelIndex (newId, ltexTable.findColumnIndex (CSMWorld::Columns::ColumnId_Texture)));
|
||||
undoStack.push (new CSMWorld::ModifyCommand(ltexTable, index, textureFileNameVariant));
|
||||
undoStack.endMacro();
|
||||
}
|
||||
|
||||
void CSVRender::TerrainTextureMode::dragMoveEvent (QDragMoveEvent *event) {
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,9 @@ namespace CSVRender
|
|||
void pushEditToCommand (CSMWorld::LandTexturesColumn::DataType& newLandGrid, CSMDoc::Document& document,
|
||||
CSMWorld::IdTable& landTable, std::string cellId);
|
||||
|
||||
/// \brief Create new land texture record from texture asset
|
||||
void createTexture(std::string textureFileName);
|
||||
|
||||
private:
|
||||
TextureBrushWindow *textureBrushWindow;
|
||||
std::string mCellId;
|
||||
|
|
Loading…
Reference in a new issue