diff --git a/RetroEDv2/tools/sceneeditor.cpp b/RetroEDv2/tools/sceneeditor.cpp index e08cd8c..c59453b 100644 --- a/RetroEDv2/tools/sceneeditor.cpp +++ b/RetroEDv2/tools/sceneeditor.cpp @@ -364,7 +364,7 @@ SceneEditor::SceneEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SceneEdi connect(objProp, &SceneObjectProperties::typeChanged, this, &SceneEditor::updateType); connect(ui->addEnt, &QToolButton::clicked, [this] { - uint c = viewer->entities.count(); + uint c = viewer->entities.count() ? viewer->entities.last().slotID + 1 : 0; uint entType = (viewer->selectedObject > -1 ? viewer->selectedObject : 0); AddEntity(entType, viewer->cameraPos.x + ((viewer->storedW / 2) * viewer->invZoom()), viewer->cameraPos.y + ((viewer->storedH / 2) * viewer->invZoom())); @@ -372,7 +372,7 @@ SceneEditor::SceneEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SceneEdi viewer->selectedEntity = c; ui->addEnt->setDisabled(viewer->entities.count() >= FormatHelpers::Scene::entityLimit); - DoAction("Added Entity " + QString::number(viewer->entities.count() - 1)); + DoAction("Added Entity " + QString::number(c)); }); connect(ui->upEnt, &QToolButton::clicked, [this] { @@ -468,10 +468,8 @@ SceneEditor::SceneEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SceneEdi viewer->selectedEntity = n; - auto *entity = &viewer->entities[viewer->selectedEntity]; - - if (n != -1){ + auto *entity = &viewer->entities[viewer->selectedEntity]; viewer->cameraPos.x = viewer->entities[n].pos.x - ((viewer->storedW / 2) * viewer->invZoom()); viewer->cameraPos.y = viewer->entities[n].pos.y - ((viewer->storedH / 2) * viewer->invZoom()); @@ -479,6 +477,13 @@ SceneEditor::SceneEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SceneEdi &compilerv2->objectEntityList[entity->gameEntitySlot], &compilerv3->objectEntityList[entity->gameEntitySlot], &compilerv4->objectEntityList[entity->gameEntitySlot], viewer->gameType); + ui->propertiesBox->setCurrentWidget(ui->objPropPage); + + for (int s = n; s < viewer->selectedEntities.count(); ++s) { + if (viewer->selectedEntities[s] == (int)c) + viewer->selectedEntities[s] = c - 1; + viewer->entities[s].slotID = viewer->entities[s - 1].slotID; + } } ui->horizontalScrollBar->blockSignals(true); @@ -489,14 +494,6 @@ SceneEditor::SceneEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SceneEdi ui->verticalScrollBar->setValue(viewer->cameraPos.y); ui->verticalScrollBar->blockSignals(false); - ui->propertiesBox->setCurrentWidget(ui->objPropPage); - - for (int s = n; s < viewer->selectedEntities.count(); ++s) { - if (viewer->selectedEntities[s] == (int)c) - viewer->selectedEntities[s] = c - 1; - viewer->entities[s].slotID = viewer->entities[s - 1].slotID; - } - ui->rmEnt->setDisabled(viewer->entities.count() <= 0); ui->addEnt->setDisabled(viewer->entities.count() >= FormatHelpers::Scene::entityLimit); DoAction(); @@ -907,6 +904,9 @@ SceneEditor::SceneEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SceneEdi for (int o = viewer->entities.count() - 1; o >= 0; --o) { SceneEntity &obj = viewer->entities[o]; if (obj.type >= count){ + // that's not going to be blank object, ignore + if (obj.type == count && stageConfig.loadGlobalScripts) + continue; int newType = newTypes[obj.type - count]; if (newType >= 0) obj.type = newType; @@ -1023,19 +1023,19 @@ SceneEditor::SceneEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SceneEdi CopyPlane *sel = new CopyPlane(this); if (sel->exec() == QDialog::Accepted) { float progress = 1.6; - if (sel->copyTilePlanes ){ + if (sel->copyTilePlanes){ SetStatus("Copying tile collision....", true); - RSDKv5::TileConfig configStore = viewer->tileconfig; - for (int i = 0; i < 0x400; ++i) { viewer->tileconfig.collisionPaths[1][i] = configStore.collisionPaths[0][i]; }; + for (int i = 0; i < 0x400; ++i) { viewer->tileconfig.collisionPaths[1][i] = viewer->tileconfig.collisionPaths[0][i]; }; AddStatusProgress(progress / 5); // finished copying tile planes progress = 3.2; } if (sel->copyChunkPlane){ + SetStatus("Copying Chunk Planes....", true); for (int i = 0; i < 0x200; ++i) { for(int y = 0; y < 8; ++y){ for(int x = 0; x < 8; ++x){ - viewer->chunkset.chunks[i].tiles[y][x].solidityB = viewer->chunkset.chunks[i].tiles[y][x].solidityA; + chunkset.chunks[i].tiles[y][x].solidityB = chunkset.chunks[i].tiles[y][x].solidityA; } } }; @@ -1043,6 +1043,7 @@ SceneEditor::SceneEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SceneEdi } } if (sel->copyTilePlanes || sel->copyChunkPlane) { + viewer->chunkset = chunkset; viewer->updateChunkColMap(); AddStatusProgress(5 / 5); // finished copying chunks planes DoAction(); @@ -1209,6 +1210,9 @@ SceneEditor::SceneEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SceneEdi for (int o = viewer->entities.count() - 1; o >= 0; --o) { SceneEntity &obj = viewer->entities[o]; if (obj.type >= count){ + // that's not going to be blank object, ignore + if (obj.type == count && stageConfig.loadGlobalScripts) + continue; int newType = newTypes[obj.type - count]; if (newType >= 0) obj.type = newType; @@ -1272,6 +1276,7 @@ SceneEditor::SceneEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SceneEdi connect(chunkRpl, &QDialog::finished, [this] { if (chunkRpl->modified){ + chunkset = viewer->chunkset; chkProp->RefreshList(); DoAction(); } @@ -1455,18 +1460,21 @@ SceneEditor::~SceneEditor() delete compilerv4; } -void SceneEditor::updateType(SceneEntity *entity, byte type) +void SceneEditor::updateType(SceneEntity *entity, byte type, bool keepVals) { int c = viewer->selectedEntity; ui->entityList->item(c)->setText(QString::number(viewer->entities[c].slotID) + ": " + viewer->objects[viewer->entities[c].type].name); - entity->propertyValue = 0; - entity->variables.clear(); - for (int v = 0; v < viewer->objects[type].variables.count(); ++v) { - RSDKv5::Scene::VariableValue val; - val.type = VAR_UINT8; - val.value_uint8 = 0; - entity->variables.append(val); + + if (!keepVals){ + entity->propertyValue = 0; + entity->variables.clear(); + for (int v = 0; v < viewer->objects[type].variables.count(); ++v) { + RSDKv5::Scene::VariableValue val; + val.type = VAR_UINT8; + val.value_uint8 = 0; + entity->variables.append(val); + } } // maybe make it use updateUI? objProp->setupUI(entity, viewer->selectedEntity, @@ -1633,6 +1641,9 @@ bool SceneEditor::eventFilter(QObject *object, QEvent *event) viewer->selectSize.x = 0; viewer->selectSize.y = 0; viewer->selectedEntities.clear(); + viewer->selectedEntitiesXPos.clear(); + viewer->selectedEntitiesYPos.clear(); + viewer->selectedEntity = -1; } else { Rect box; int selectedEntity = -1; @@ -1816,8 +1827,8 @@ bool SceneEditor::eventFilter(QObject *object, QEvent *event) if (viewer->selectedLayer >= 0) { Rect box; - for (int y = 0; y < viewer->sceneBoundsB / 0x80; ++y) { - for (int x = 0; x < viewer->sceneBoundsR / 0x80; ++x) { + for (int y = 0; y < viewer->layers[viewer->selectedLayer].height; ++y) { + for (int x = 0; x < viewer->layers[viewer->selectedLayer].width; ++x) { box = Rect(x * 0x80, y * 0x80, 0x80, 0x80); Vector2 pos = Vector2( @@ -3025,7 +3036,6 @@ void SceneEditor::LoadScene(QString scnPath, QString gcfPath, byte gameType) } AddStatusProgress(1. / 7); // finish objects & entities - QImage tileset(16, 0x400 * 16, QImage::Format_Indexed8); for (int i = 0; i < 256; ++i) tileset.setColor(i, QRgb(0xFFFF00FF)); @@ -4009,9 +4019,44 @@ bool SceneEditor::HandleKeyPress(QKeyEvent *event) if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier && event->key() == Qt::Key_V && !event->isAutoRepeat() && viewerActive) { - if (clipboard) { + if (clipboard || clipboardIDs.count()) { switch (clipboardType) { default: break; + case COPY_ENTITY_SELECT: { + if (viewer->activeEntityCount() + clipboardIDs.count() >= FormatHelpers::Scene::entityLimit){ + QMessageBox msgBox = + QMessageBox(QMessageBox::Information, "RetroED", + QString("Copied entities will exceed the entity cap. \nPlease remove some entities first."), + QMessageBox::NoButton, this); + msgBox.exec(); + break; + } + viewer->selectedEntities.clear(); + viewer->selectedEntitiesXPos.clear(); + viewer->selectedEntitiesYPos.clear(); + for(int i = 0; i < clipboardIDs.count(); i++){ + clipboard = &viewer->entities[clipboardIDs[i]]; + SceneEntity *entity = (SceneEntity *)clipboard; + + float entXPos = sceneMousePos.x + clipboardOffset[i].x - clipPosCenter.x; + float entYPos = sceneMousePos.y + clipboardOffset[i].y - clipPosCenter.y; + + PasteEntity(entity, entXPos, entYPos); + viewer->selectedEntities.append(viewer->entities.count() - 1); + viewer->selectedEntitiesXPos.append(entXPos); + viewer->selectedEntitiesYPos.append(entYPos); + } + viewer->sceneInfo.listPos = -1; + // cheat + viewer->centerEntity = viewer->selectedEntities.count() - 1; + viewer->selectSize.x = 1; + viewer->selectSize.y = 1; + + DoAction(QString("Pasted Entities: %1 - %2") + .arg(viewer->selectedEntities[0]) + .arg(viewer->selectedEntities[viewer->selectedEntities.count() - 1])); + break; + } case COPY_ENTITY: { if (viewer->entities.count() < FormatHelpers::Scene::entityLimit) { SceneEntity *entity = (SceneEntity *)clipboard; @@ -4089,15 +4134,49 @@ bool SceneEditor::HandleKeyPress(QKeyEvent *event) objProp->unsetUI(); CreateEntityList(); viewer->selectedEntities.clear(); + DoAction("Deleted Entities"); } - int move = 4; - if (ctrlDownL) - move *= 4; - if (shiftDownL) - move /= 4; + if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier + && event->key() == Qt::Key_C) { + std::sort(viewer->selectedEntities.begin(), viewer->selectedEntities.end(), + [](const int &a, const int &b) -> bool { return a < b; }); + + clipboardIDs.clear(); + clipboardOffset.clear(); + Vector2 clipPos1 = Vector2(viewer->selectedEntitiesXPos[0], viewer->selectedEntitiesYPos[0]); + Vector2 clipPos2 = Vector2(viewer->selectedEntitiesXPos[0], viewer->selectedEntitiesYPos[0]); + for (int s = viewer->selectedEntities.count() - 1; s >= 0; --s) { + clipboardIDs.append(viewer->selectedEntities[s]); + if (viewer->selectedEntitiesXPos[s] < clipPos1.x) + clipPos1.x = viewer->selectedEntitiesXPos[s]; + if (viewer->selectedEntitiesYPos[s] < clipPos1.y) + clipPos1.y = viewer->selectedEntitiesYPos[s]; + + if (viewer->selectedEntitiesXPos[s] > clipPos2.x) + clipPos2.x = viewer->selectedEntitiesXPos[s]; + if (viewer->selectedEntitiesYPos[s] > clipPos2.y) + clipPos2.y = viewer->selectedEntitiesYPos[s]; + } + for (int s = viewer->selectedEntities.count() - 1; s >= 0; --s) { + Vector2 pos; + pos.x = viewer->selectedEntitiesXPos[s] - clipPos1.x; + pos.y = viewer->selectedEntitiesYPos[s] - clipPos1.y; + clipboardOffset.append(pos); + } + clipPosCenter.x = (clipPos2.x - clipPos1.x) / 2; + clipPosCenter.y = (clipPos2.y - clipPos1.y) / 2; + clipboardType = COPY_ENTITY_SELECT; + clipboardInfo = viewer->selectedEntity; + } for (auto o : viewer->selectedEntities){ + int move = 4; + if (ctrlDownL) + move *= 4; + if (shiftDownL) + move /= 4; + if (event->key() == Qt::Key_Up) viewer->entities[o].pos.y -= move; @@ -4128,8 +4207,8 @@ bool SceneEditor::HandleKeyPress(QKeyEvent *event) if (viewer->selectedLayer >= 0) { Rect box; - for (int y = 0; y < viewer->sceneBoundsB / 0x80; ++y) { - for (int x = 0; x < viewer->sceneBoundsR / 0x80; ++x) { + for (int y = 0; y < viewer->layers[viewer->selectedLayer].height; ++y) { + for (int x = 0; x < viewer->layers[viewer->selectedLayer].width; ++x) { box = Rect(x * 0x80, y * 0x80, 0x80, 0x80); Vector2 pos = Vector2( @@ -4150,8 +4229,8 @@ bool SceneEditor::HandleKeyPress(QKeyEvent *event) if (viewer->selectedLayer >= 0) { Rect box; - for (int y = 0; y < viewer->sceneBoundsB / 0x80; ++y) { - for (int x = 0; x < viewer->sceneBoundsR / 0x80; ++x) { + for (int y = 0; y < viewer->layers[viewer->selectedLayer].height; ++y) { + for (int x = 0; x < viewer->layers[viewer->selectedLayer].width; ++x) { box = Rect(x * 0x80, y * 0x80, 0x80, 0x80); Vector2 pos = Vector2( @@ -4195,7 +4274,7 @@ bool SceneEditor::HandleKeyPress(QKeyEvent *event) DeleteEntity(viewer->selectedEntity); viewer->selectedEntity = -1; - DoAction(); + DoAction("Deleted Entity"); } int move = 4; @@ -4256,7 +4335,7 @@ int SceneEditor::AddEntity(int type, float x, float y) entity.pos.x = x; entity.pos.y = y; - int cnt = viewer->entities.count(); + int cnt = viewer->entities.count() ? viewer->entities.last().slotID + 1 : 0; entity.slotID = cnt; entity.prevSlot = entity.slotID; entity.gameEntitySlot = entity.slotID; @@ -4285,7 +4364,7 @@ int SceneEditor::AddEntity(int type, float x, float y) compilerv4->objectEntityList[entity.gameEntitySlot].XPos = x * 65536; compilerv4->objectEntityList[entity.gameEntitySlot].YPos = y * 65536; - viewer->selectedEntity = cnt; + viewer->selectedEntity = viewer->entities.count() - 1; ui->entityList->blockSignals(true); ui->entityList->setCurrentRow(viewer->selectedEntity); @@ -4309,6 +4388,9 @@ int SceneEditor::AddEntity(int type, float x, float y) void SceneEditor::PasteEntity(SceneEntity *copy, float x, float y) { + if (!copy) + return; + if (x == 0xFFFF) x = viewer->cameraPos.x; @@ -4375,6 +4457,30 @@ void SceneEditor::PasteEntity(SceneEntity *copy, float x, float y) void SceneEditor::DeleteEntity(int slot, bool updateUI) { + if (clipboardType == COPY_ENTITY){ + if (clipboardInfo == slot){ + clipboard = nullptr; + clipboardType = COPY_NONE; + clipboardInfo = 0; + } + } else if (clipboardType == COPY_ENTITY_SELECT){ + for (int i = clipboardIDs.count() - 1; i >= 0; i--){ + if (clipboardIDs[i] == slot){ + for (int i2 = clipboardIDs.count() - 1; i2 >= 0; i2--) + if (viewer->entities[clipboardIDs[i2]].slotID > slot) + clipboardIDs[i2]--; + + clipboardIDs.removeAt(i); + clipboardOffset.removeAt(i); + } + } + if (!clipboardIDs.count()){ + clipboard = nullptr; + clipboardType = COPY_NONE; + clipboardInfo = 0; + } + } + const SceneEntity &entity = viewer->entities.takeAt(slot); compilerv4->objectEntityList[entity.gameEntitySlot].type = 0; diff --git a/RetroEDv2/tools/sceneeditor.hpp b/RetroEDv2/tools/sceneeditor.hpp index a17c0ff..aae6159 100644 --- a/RetroEDv2/tools/sceneeditor.hpp +++ b/RetroEDv2/tools/sceneeditor.hpp @@ -167,7 +167,7 @@ class SceneEditor : public QWidget void TitleChanged(QString title, QString tabFullPath); public slots: - void updateType(SceneEntity *entity, byte type); + void updateType(SceneEntity *entity, byte type, bool keepVals = false); protected: bool event(QEvent *event); bool eventFilter(QObject *object, QEvent *event); @@ -178,9 +178,13 @@ public slots: COPY_LAYER, COPY_CHUNK, COPY_ENTITY, + COPY_ENTITY_SELECT, COPY_SCROLLINFO, }; void *clipboard = nullptr; + QList clipboardIDs; + QList> clipboardOffset; + Vector2 clipPosCenter; byte clipboardType = COPY_NONE; int clipboardInfo = 0; diff --git a/RetroEDv2/tools/sceneeditor.ui b/RetroEDv2/tools/sceneeditor.ui index 5f0f33e..f7945df 100644 --- a/RetroEDv2/tools/sceneeditor.ui +++ b/RetroEDv2/tools/sceneeditor.ui @@ -23,7 +23,7 @@ - 0 + 3 @@ -139,68 +139,38 @@ Entity List - + - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Adds an entity - - - + - - - - :/icons/ic_add_circle_48px.svg:/icons/ic_add_circle_48px.svg - - - - - - - false - + + - Removes an entity + Moves an entity down - - + D - :/icons/ic_cancel_48px.svg:/icons/ic_cancel_48px.svg + :/icons/ic_arrow_downward_48px.svg:/icons/ic_arrow_downward_48px.svg - - + + - Moves an entity down + Adds an entity - D + + - :/icons/ic_arrow_downward_48px.svg:/icons/ic_arrow_downward_48px.svg + :/icons/ic_add_circle_48px.svg:/icons/ic_add_circle_48px.svg - + Moves an entity up @@ -214,7 +184,27 @@ - + + + + Find entities... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + Qt::Horizontal @@ -227,10 +217,27 @@ - - - - Find entities... + + + + false + + + Removes an entity + + + - + + + + :/icons/ic_cancel_48px.svg:/icons/ic_cancel_48px.svg + + + + + + + Total Entity Count diff --git a/RetroEDv2/tools/sceneeditorv5.cpp b/RetroEDv2/tools/sceneeditorv5.cpp index ebfb3bf..bf91559 100644 --- a/RetroEDv2/tools/sceneeditorv5.cpp +++ b/RetroEDv2/tools/sceneeditorv5.cpp @@ -152,7 +152,6 @@ SceneEditorv5::SceneEditorv5(QWidget *parent) : QWidget(parent), ui(new Ui::Scen viewer->screens->position.y = v; }); - QCheckBox *filterToggles[] = { ui->filterBox1, ui->filterBox2, ui->filterBox3, ui->filterBox4, ui->filterBox5, ui->filterBox6, ui->filterBox7, ui->filterBox8 }; @@ -160,7 +159,10 @@ SceneEditorv5::SceneEditorv5(QWidget *parent) : QWidget(parent), ui(new Ui::Scen filterToggles[f]->setDisabled(viewer->engineRevision == 1); filterToggles[f]->setChecked(viewer->engineRevision != 1 || Utils::getBit(viewer->sceneFilter, f)); - connect(filterToggles[f], &QCheckBox::toggled, [this, f] { viewer->sceneFilter ^= (1 << f); }); + connect(filterToggles[f], &QCheckBox::toggled, [this, f] { + viewer->sceneFilter ^= (1 << f); + ui->addEnt->setDisabled(viewer->activeEntityCount() >= SCENEENTITY_COUNT_v5); + }); } #ifndef Q_NO_PROCESS @@ -573,6 +575,9 @@ SceneEditorv5::SceneEditorv5(QWidget *parent) : QWidget(parent), ui(new Ui::Scen for (int o = viewer->entities.count() - 1; o >= 0; --o) { SceneEntity &entity = viewer->entities[o]; if (entity.type >= objOffset){ + // that's not going to be blank object, ignore + if (entity.type == objOffset && stageConfig.loadGlobalObjects) + continue; int newType = removeFlags[entity.type - objOffset]; if (newType < 0) { DeleteEntity(o, false); @@ -802,7 +807,7 @@ SceneEditorv5::SceneEditorv5(QWidget *parent) : QWidget(parent), ui(new Ui::Scen connect(objProp, &SceneObjectPropertiesv5::typeChanged, this, &SceneEditorv5::updateType); connect(ui->addEnt, &QToolButton::clicked, [this] { - uint c = viewer->entities.count(); + uint c = viewer->entities.count() ? viewer->entities.last().slotID + 1 : 0; uint entType = (viewer->selectedObject > -1 ? viewer->selectedObject : 0); int xpos = viewer->cameraPos.x + ((viewer->storedW / 2) * viewer->invZoom()); @@ -814,7 +819,7 @@ SceneEditorv5::SceneEditorv5(QWidget *parent) : QWidget(parent), ui(new Ui::Scen viewer->selectedEntity = c; ui->addEnt->setDisabled(viewer->activeEntityCount() >= SCENEENTITY_COUNT_v5); - DoAction("Add Entity: " + QString::number(viewer->entities.count() - 1)); + DoAction("Add Entity: " + QString::number(c)); }); connect(ui->rmEnt, &QToolButton::clicked, [this] { @@ -833,6 +838,13 @@ SceneEditorv5::SceneEditorv5(QWidget *parent) : QWidget(parent), ui(new Ui::Scen viewer->cameraPos.x = viewer->entities[n].pos.x - ((viewer->storedW / 2) * viewer->invZoom()); viewer->cameraPos.y = viewer->entities[n].pos.y - ((viewer->storedH / 2) * viewer->invZoom()); objProp->setupUI(&viewer->entities[n]); + ui->propertiesBox->setCurrentWidget(ui->objPropPage); + + for (int s = n; s < viewer->selectedEntities.count(); ++s) { + if (viewer->selectedEntities[s] == (int)c) + viewer->selectedEntities[s] = c - 1; + viewer->entities[s].slotID = viewer->entities[s - 1].slotID; + } } ui->horizontalScrollBar->blockSignals(true); @@ -842,9 +854,8 @@ SceneEditorv5::SceneEditorv5(QWidget *parent) : QWidget(parent), ui(new Ui::Scen ui->verticalScrollBar->blockSignals(true); ui->verticalScrollBar->setValue(viewer->cameraPos.y); ui->verticalScrollBar->blockSignals(false); - ui->rmEnt->setDisabled(viewer->entities.count() <= 0); - ui->addEnt->setDisabled(viewer->activeEntityCount() >= 0x800); + ui->addEnt->setDisabled(viewer->activeEntityCount() >= SCENEENTITY_COUNT_v5); DoAction("Remove Entity: " + QString::number(c)); }); @@ -920,6 +931,25 @@ SceneEditorv5::SceneEditorv5(QWidget *parent) : QWidget(parent), ui(new Ui::Scen ui->upEnt->setDisabled(false); }); + connect(ui->alignEnt, &QToolButton::clicked, [this] { + ui->entityList->blockSignals(true); + int slot = 0; + while (slot < viewer->entities.count()){ + SceneEntity *ent = &viewer->entities[slot]; + if (ent->slotID != slot){ + ent->prevSlot = ent->slotID; + ent->slotID = slot; + ent->gameEntitySlot = slot; + ui->entityList->item(slot)->setText(QString::number(ent->slotID) + ": " + + viewer->objects[viewer->entities[slot].type].name); + } + + slot++; + } + ui->entityList->blockSignals(false); + objProp->updateUI(); + }); + connect(ui->scrollList, &QListWidget::currentRowChanged, [this](int c) { ui->rmScr->setDisabled(c == -1); scrProp->setDisabled(c == -1); @@ -1757,23 +1787,25 @@ SceneEditorv5::~SceneEditorv5() releaseStorage(dataStorage); } -void SceneEditorv5::updateType(SceneEntity *entity, byte type) +void SceneEditorv5::updateType(SceneEntity *entity, byte type, bool keepVals) { int c = viewer->selectedEntity; ui->entityList->item(c)->setText(QString::number(viewer->entities[c].slotID) + ": " + viewer->objects[viewer->entities[c].type].name); - entity->variables.clear(); - for (int v = 0; v < viewer->objects[type].variables.length(); ++v) { - RSDKv5::Scene::VariableValue var; - var.type = viewer->objects[type].variables[v].type; - entity->variables.append(var); - } + if (!keepVals){ + entity->variables.clear(); + for (int v = 0; v < viewer->objects[type].variables.length(); ++v) { + RSDKv5::Scene::VariableValue var; + var.type = viewer->objects[type].variables[v].type; + entity->variables.append(var); + } - for (int v = 0; v < viewer->objects[type].variables.count(); ++v) { - if (viewer->objects[type].variables[v].name == "filter") { - if (v < entity->variables.count()) - entity->variables[v].value_uint8 = viewer->sceneFilter; - break; + for (int v = 0; v < viewer->objects[type].variables.count(); ++v) { + if (viewer->objects[type].variables[v].name == "filter") { + if (v < entity->variables.count()) + entity->variables[v].value_uint8 = viewer->sceneFilter; + break; + } } } objProp->setupUI(&viewer->entities[c]); // maybe make it use updateUI? @@ -2013,6 +2045,9 @@ bool SceneEditorv5::eventFilter(QObject *object, QEvent *event) viewer->selectSize.x = 0; viewer->selectSize.y = 0; viewer->selectedEntities.clear(); + viewer->selectedEntitiesXPos.clear(); + viewer->selectedEntitiesYPos.clear(); + viewer->selectedEntity = -1; } else { Rect box; int selectedEntity = -1; @@ -2057,9 +2092,6 @@ bool SceneEditorv5::eventFilter(QObject *object, QEvent *event) selectionOffset.x = pos.x - viewer->entities[o].pos.x; selectionOffset.y = pos.y - viewer->entities[o].pos.y; - - objProp->setupUI(&viewer->entities[viewer->selectedEntity]); - ui->propertiesBox->setCurrentWidget(ui->objPropPage); } break; } @@ -2520,77 +2552,77 @@ bool SceneEditorv5::eventFilter(QObject *object, QEvent *event) default: break; case SceneViewer::TOOL_MOUSE: break; case SceneViewer::TOOL_SELECT: { - if (viewer->isSelecting){ - viewer->selectSize.x = sceneMousePos.x - viewer->selectPos.x; - viewer->selectSize.y = sceneMousePos.y - viewer->selectPos.y; + if (viewer->isSelecting){ + viewer->selectSize.x = sceneMousePos.x - viewer->selectPos.x; + viewer->selectSize.y = sceneMousePos.y - viewer->selectPos.y; - float cx = viewer->selectPos.x; - float cy = viewer->selectPos.y; - if (viewer->selectSize.x < 0) - cx -= fabsf(viewer->selectSize.x); - if (viewer->selectSize.y < 0) - cy -= fabsf(viewer->selectSize.y); + float cx = viewer->selectPos.x; + float cy = viewer->selectPos.y; + if (viewer->selectSize.x < 0) + cx -= fabsf(viewer->selectSize.x); + if (viewer->selectSize.y < 0) + cy -= fabsf(viewer->selectSize.y); - cx += fabsf(viewer->selectSize.x) / 2; - cy += fabsf(viewer->selectSize.y) / 2; + cx += fabsf(viewer->selectSize.x) / 2; + cy += fabsf(viewer->selectSize.y) / 2; - float oLeft = cx - (fabsf(viewer->selectSize.x) / 2); - float oTop = cy - (fabsf(viewer->selectSize.y) / 2); - float oRight = cx + (fabsf(viewer->selectSize.x) / 2); - float oBottom = cy + (fabsf(viewer->selectSize.y) / 2); + float oLeft = cx - (fabsf(viewer->selectSize.x) / 2); + float oTop = cy - (fabsf(viewer->selectSize.y) / 2); + float oRight = cx + (fabsf(viewer->selectSize.x) / 2); + float oBottom = cy + (fabsf(viewer->selectSize.y) / 2); - viewer->selectedEntities.clear(); - viewer->selectedEntitiesXPos.clear(); - viewer->selectedEntitiesYPos.clear(); - for (int e = 0; e < viewer->entities.count(); ++e) { - SceneEntity &entity = viewer->entities[e]; + viewer->selectedEntities.clear(); + viewer->selectedEntitiesXPos.clear(); + viewer->selectedEntitiesYPos.clear(); + for (int e = 0; e < viewer->entities.count(); ++e) { + SceneEntity &entity = viewer->entities[e]; - int filter = 0xFF; - for (int v = 0; v < viewer->objects[entity.type].variables.count(); ++v) { - if (viewer->objects[entity.type].variables[v].name == "filter") { - if (v < entity.variables.count()) - filter = entity.variables[v].value_uint8; - break; + int filter = 0xFF; + for (int v = 0; v < viewer->objects[entity.type].variables.count(); ++v) { + if (viewer->objects[entity.type].variables[v].name == "filter") { + if (v < entity.variables.count()) + filter = entity.variables[v].value_uint8; + break; + } } - } - if (!(filter & viewer->sceneFilter) && filter) - continue; + if (!(filter & viewer->sceneFilter) && filter) + continue; - float left = entity.pos.x + entity.box.x; - float top = entity.pos.y + entity.box.y; - float right = entity.pos.x + entity.box.w; - float bottom = entity.pos.y + entity.box.h; + float left = entity.pos.x + entity.box.x; + float top = entity.pos.y + entity.box.y; + float right = entity.pos.x + entity.box.w; + float bottom = entity.pos.y + entity.box.h; - if (left < oRight && right > oLeft && top < oBottom && bottom > oTop) { - viewer->selectedEntities.append(e); - viewer->selectedEntitiesXPos.append(entity.pos.x); - viewer->selectedEntitiesYPos.append(entity.pos.y); + if (left < oRight && right > oLeft && top < oBottom && bottom > oTop) { + viewer->selectedEntities.append(e); + viewer->selectedEntitiesXPos.append(entity.pos.x); + viewer->selectedEntitiesYPos.append(entity.pos.y); + } } - } - } else { - for (int o = 0; o < viewer->selectedEntities.count(); ++o) { - int pos = viewer->selectedEntities[o]; - SceneEntity &entity = viewer->entities[pos]; - int xOffset = ((viewer->selectedEntitiesXPos[viewer->centerEntity] - viewer->selectedEntitiesXPos[o])); - int yOffset = ((viewer->selectedEntitiesYPos[viewer->centerEntity] - viewer->selectedEntitiesYPos[o])); + } else { + for (int o = 0; o < viewer->selectedEntities.count(); ++o) { + int pos = viewer->selectedEntities[o]; + SceneEntity &entity = viewer->entities[pos]; + int xOffset = ((viewer->selectedEntitiesXPos[viewer->centerEntity] - viewer->selectedEntitiesXPos[o])); + int yOffset = ((viewer->selectedEntitiesYPos[viewer->centerEntity] - viewer->selectedEntitiesYPos[o])); - entity.pos.x = (viewer->mousePos.x * viewer->invZoom()) + viewer->cameraPos.x; - entity.pos.y = (viewer->mousePos.y * viewer->invZoom()) + viewer->cameraPos.y; + entity.pos.x = (viewer->mousePos.x * viewer->invZoom()) + viewer->cameraPos.x; + entity.pos.y = (viewer->mousePos.y * viewer->invZoom()) + viewer->cameraPos.y; - if (ctrlDownL) { - entity.pos.x = (entity.pos.x - fmodf(entity.pos.x, viewer->gridSize.x)) - xOffset; - entity.pos.y = (entity.pos.y - fmodf(entity.pos.y, viewer->gridSize.y)) - yOffset; - } - else { - entity.pos.x -= xOffset + selectionOffset.x; - entity.pos.y -= yOffset + selectionOffset.y; + if (ctrlDownL) { + entity.pos.x = (entity.pos.x - fmodf(entity.pos.x, viewer->gridSize.x)) - xOffset; + entity.pos.y = (entity.pos.y - fmodf(entity.pos.y, viewer->gridSize.y)) - yOffset; + } + else { + entity.pos.x -= xOffset + selectionOffset.x; + entity.pos.y -= yOffset + selectionOffset.y; + } + if (viewer->selectedEntity == pos) + objProp->updateUI(); } - if (viewer->selectedEntity == pos) - objProp->updateUI(); - } - } + } break; } case SceneViewer::TOOL_PENCIL: { @@ -2791,8 +2823,6 @@ int SceneEditorv5::AddEntity(int type, float x, float y) y = viewer->cameraPos.y; SceneEntity entity; - entity.slotID = viewer->entities.count(); - entity.prevSlot = entity.slotID; entity.type = type; entity.pos.x = x; entity.pos.y = y; @@ -2816,14 +2846,14 @@ int SceneEditorv5::AddEntity(int type, float x, float y) } } - int cnt = viewer->entities.count(); + int cnt = viewer->entities.count() ? viewer->entities.last().slotID + 1 : 0; entity.slotID = cnt; entity.prevSlot = entity.slotID; CallGameEvent(viewer->objects[entity.type].name, SceneViewer::EVENT_CREATE, &entity); viewer->entities.append(entity); - viewer->selectedEntity = cnt; + viewer->selectedEntity = viewer->entities.count() - 1; viewer->sceneInfo.listPos = viewer->entities[viewer->selectedEntity].slotID; viewer->sceneInfoV1.listPos = viewer->sceneInfo.listPos; @@ -2845,6 +2875,9 @@ int SceneEditorv5::AddEntity(int type, float x, float y) void SceneEditorv5::PasteEntity(SceneEntity *copy, float x, float y) { + if (!copy) + return; + if (x == 0xFFFF) x = viewer->cameraPos.x; @@ -2852,8 +2885,6 @@ void SceneEditorv5::PasteEntity(SceneEntity *copy, float x, float y) y = viewer->cameraPos.y; SceneEntity entity; - entity.slotID = viewer->entities.count(); - entity.prevSlot = entity.slotID; entity.type = copy->type; entity.pos.x = x; entity.pos.y = y; @@ -2866,16 +2897,19 @@ void SceneEditorv5::PasteEntity(SceneEntity *copy, float x, float y) } for (int v = 0; v < viewer->objects[entity.type].variables.count(); ++v) - entity.variables[v] = copy->variables[v]; + if (viewer->objects[entity.type].variables[v].name == "filter") + entity.variables[v].value_uint8 = viewer->sceneFilter; + else + entity.variables[v] = copy->variables[v]; - int cnt = viewer->entities.count(); + int cnt = viewer->entities.count() ? viewer->entities.last().slotID + 1 : 0; entity.slotID = cnt; entity.prevSlot = entity.slotID; CallGameEvent(viewer->objects[entity.type].name, SceneViewer::EVENT_CREATE, &entity); viewer->entities.append(entity); - viewer->selectedEntity = cnt; + viewer->selectedEntity = viewer->entities.count() - 1; viewer->sceneInfo.listPos = viewer->entities[viewer->selectedEntity].slotID; viewer->sceneInfoV1.listPos = viewer->sceneInfo.listPos; @@ -2889,12 +2923,34 @@ void SceneEditorv5::PasteEntity(SceneEntity *copy, float x, float y) ui->entityList->addItem(QString::number(entity.slotID) + ": " + name); - objProp->setupUI(&viewer->entities[viewer->selectedEntity]); - ui->propertiesBox->setCurrentWidget(ui->objPropPage); } void SceneEditorv5::DeleteEntity(int slot, bool updateUI) { + if (clipboardType == COPY_ENTITY){ + if (clipboardInfo == slot){ + clipboard = nullptr; + clipboardType = COPY_NONE; + clipboardInfo = 0; + } + } else if (clipboardType == COPY_ENTITY_SELECT){ + for (int i = clipboardIDs.count() - 1; i >= 0; i--){ + if (clipboardIDs[i] == slot){ + for (int i2 = clipboardIDs.count() - 1; i2 >= 0; i2--) + if (viewer->entities[clipboardIDs[i2]].slotID > slot) + clipboardIDs[i2]--; + + clipboardIDs.removeAt(i); + clipboardOffset.removeAt(i); + } + } + if (!clipboardIDs.count()){ + clipboard = nullptr; + clipboardType = COPY_NONE; + clipboardInfo = 0; + } + } + const SceneEntity &entity = viewer->entities.takeAt(slot); if (entity.gameEntity) { @@ -2923,6 +2979,7 @@ void SceneEditorv5::DeleteEntity(int slot, bool updateUI) ui->entityList->blockSignals(true); delete ui->entityList->item(slot); ui->entityList->blockSignals(false); + if (updateUI) { objProp->unsetUI(); @@ -3256,6 +3313,7 @@ void SceneEditorv5::LoadScene(QString scnPath, QString gcfPath, byte sceneVer) viewer->stopTimer(); viewer->unloadScene(); + clipboardIDs.clear(); releaseStorage(dataStorage); initStorage(dataStorage); @@ -3574,7 +3632,7 @@ void SceneEditorv5::LoadScene(QString scnPath, QString gcfPath, byte sceneVer) || Utils::getBit(viewer->sceneFilter, f)); } - ui->addEnt->setDisabled(viewer->activeEntityCount() >= 0x800); + ui->addEnt->setDisabled(viewer->activeEntityCount() >= SCENEENTITY_COUNT_v5); tabTitle = Utils::getFilenameAndFolder(scnPath); tabPath = scnPath; @@ -3749,11 +3807,11 @@ void SceneEditorv5::CreateEntityList(int startSlot) std::sort(viewer->entities.begin(), viewer->entities.end(), [](const SceneEntity &a, const SceneEntity &b) -> bool { return a.slotID < b.slotID; }); + for (int i = startSlot; i < viewer->entities.count(); ++i) { QString name = "Unknown Object " + QString::number(viewer->entities[i].type); if (viewer->entities[i].type < viewer->objects.count()) name = viewer->objects[viewer->entities[i].type].name; - ui->entityList->addItem(QString::number(viewer->entities[i].slotID) + ": " + name); } ui->entityList->blockSignals(false); @@ -4480,11 +4538,47 @@ bool SceneEditorv5::HandleKeyPress(QKeyEvent *event) if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier && event->key() == Qt::Key_V && !event->isAutoRepeat() && viewerActive) { - if (clipboard) { + if (clipboard || clipboardIDs.count()) { switch (clipboardType) { default: break; + case COPY_ENTITY_SELECT: { + if (viewer->activeEntityCount() + clipboardIDs.count() >= SCENEENTITY_COUNT_v5){ + QMessageBox msgBox = + QMessageBox(QMessageBox::Information, "RetroED", + QString("Copied entities will exceed the entity cap. \nPlease remove some entities first."), + QMessageBox::NoButton, this); + msgBox.exec(); + break; + } + viewer->selectedEntities.clear(); + viewer->selectedEntitiesXPos.clear(); + viewer->selectedEntitiesYPos.clear(); + for(int i = 0; i < clipboardIDs.count(); i++){ + clipboard = &viewer->entities[clipboardIDs[i]]; + SceneEntity *entity = (SceneEntity *)clipboard; + + float entXPos = sceneMousePos.x + clipboardOffset[i].x - clipPosCenter.x; + float entYPos = sceneMousePos.y + clipboardOffset[i].y - clipPosCenter.y; + + PasteEntity(entity, entXPos, entYPos); + viewer->selectedEntities.append(viewer->entities.count() - 1); + viewer->selectedEntitiesXPos.append(entXPos); + viewer->selectedEntitiesYPos.append(entYPos); + } + viewer->sceneInfo.listPos = -1; + viewer->sceneInfoV1.listPos = viewer->sceneInfo.listPos; + // cheat + viewer->centerEntity = viewer->selectedEntities.count() - 1; + viewer->selectSize.x = 1; + viewer->selectSize.y = 1; + + DoAction(QString("Pasted Entities: %1 - %2") + .arg(viewer->selectedEntities[0]) + .arg(viewer->selectedEntities[viewer->selectedEntities.count() - 1])); + break; + } case COPY_ENTITY: { - if (viewer->activeEntityCount() < 0x800) { + if (viewer->activeEntityCount() < SCENEENTITY_COUNT_v5) { SceneEntity *entity = (SceneEntity *)clipboard; PasteEntity(entity, sceneMousePos.x, sceneMousePos.y); @@ -4568,6 +4662,40 @@ bool SceneEditorv5::HandleKeyPress(QKeyEvent *event) objProp->unsetUI(); CreateEntityList(); viewer->selectedEntities.clear(); + DoAction("Deleted Entities"); + } + + if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier + && event->key() == Qt::Key_C) { + std::sort(viewer->selectedEntities.begin(), viewer->selectedEntities.end(), + [](const int &a, const int &b) -> bool { return a < b; }); + + clipboardIDs.clear(); + clipboardOffset.clear(); + Vector2 clipPos1 = Vector2(viewer->selectedEntitiesXPos[0], viewer->selectedEntitiesYPos[0]); + Vector2 clipPos2 = Vector2(viewer->selectedEntitiesXPos[0], viewer->selectedEntitiesYPos[0]); + for (int s = viewer->selectedEntities.count() - 1; s >= 0; --s) { + clipboardIDs.append(viewer->selectedEntities[s]); + if (viewer->selectedEntitiesXPos[s] < clipPos1.x) + clipPos1.x = viewer->selectedEntitiesXPos[s]; + if (viewer->selectedEntitiesYPos[s] < clipPos1.y) + clipPos1.y = viewer->selectedEntitiesYPos[s]; + + if (viewer->selectedEntitiesXPos[s] > clipPos2.x) + clipPos2.x = viewer->selectedEntitiesXPos[s]; + if (viewer->selectedEntitiesYPos[s] > clipPos2.y) + clipPos2.y = viewer->selectedEntitiesYPos[s]; + } + for (int s = viewer->selectedEntities.count() - 1; s >= 0; --s) { + Vector2 pos; + pos.x = viewer->selectedEntitiesXPos[s] - clipPos1.x; + pos.y = viewer->selectedEntitiesYPos[s] - clipPos1.y; + clipboardOffset.append(pos); + } + clipPosCenter.x = (clipPos2.x - clipPos1.x) / 2; + clipPosCenter.y = (clipPos2.y - clipPos1.y) / 2; + clipboardType = COPY_ENTITY_SELECT; + clipboardInfo = viewer->selectedEntity; } for (auto o : viewer->selectedEntities){ @@ -4643,7 +4771,7 @@ bool SceneEditorv5::HandleKeyPress(QKeyEvent *event) DeleteEntity(viewer->selectedEntity); viewer->selectedEntity = -1; - DoAction(); + DoAction("Deleted Entity"); } int move = 4; @@ -4671,6 +4799,7 @@ bool SceneEditorv5::HandleKeyPress(QKeyEvent *event) if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier && event->key() == Qt::Key_C) { + clipboardIDs.clear(); clipboard = &viewer->entities[viewer->selectedEntity]; clipboardType = COPY_ENTITY; clipboardInfo = viewer->selectedEntity; diff --git a/RetroEDv2/tools/sceneeditorv5.hpp b/RetroEDv2/tools/sceneeditorv5.hpp index 72680c5..b55450d 100644 --- a/RetroEDv2/tools/sceneeditorv5.hpp +++ b/RetroEDv2/tools/sceneeditorv5.hpp @@ -159,7 +159,7 @@ class SceneEditorv5 : public QWidget void TitleChanged(QString title, QString tabFullPath); public slots: - void updateType(SceneEntity *entity, byte type); + void updateType(SceneEntity *entity, byte type, bool keepVals = false); void updateStampName(QString name); void updateLayer(QString name); void updateTileSel(); @@ -174,9 +174,13 @@ public slots: COPY_LAYER, COPY_TILE, COPY_ENTITY, + COPY_ENTITY_SELECT, COPY_SCROLLINFO, }; void *clipboard = nullptr; + QList clipboardIDs; + QList> clipboardOffset; + Vector2 clipPosCenter; byte clipboardType = COPY_NONE; int clipboardInfo = 0; diff --git a/RetroEDv2/tools/sceneeditorv5.ui b/RetroEDv2/tools/sceneeditorv5.ui index aca73ef..ab65f41 100644 --- a/RetroEDv2/tools/sceneeditorv5.ui +++ b/RetroEDv2/tools/sceneeditorv5.ui @@ -1151,6 +1151,9 @@ Object List + + + @@ -1168,6 +1171,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -1182,22 +1198,6 @@ - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -1220,35 +1220,7 @@ Entity List - - - - Moves an entity down - - - D - - - - :/icons/ic_arrow_downward_48px.svg:/icons/ic_arrow_downward_48px.svg - - - - - - - Moves an entity up - - - U - - - - :/icons/ic_arrow_upward_48px.svg:/icons/ic_arrow_upward_48px.svg - - - - + false @@ -1265,21 +1237,7 @@ - - - - Adds an entity - - - + - - - - :/icons/ic_add_circle_48px.svg:/icons/ic_add_circle_48px.svg - - - - + Qt::Horizontal @@ -1293,9 +1251,43 @@ + + + + + + + + + Find entities... + + + + - + + + + Moves an entity up + + + U + + + + :/icons/ic_arrow_upward_48px.svg:/icons/ic_arrow_upward_48px.svg + + + + + + + Re-Align Entity Slots + + + + Qt::Horizontal @@ -1308,16 +1300,31 @@ - - + + - + Moves an entity down - - + + D - - Find entities... + + + :/icons/ic_arrow_downward_48px.svg:/icons/ic_arrow_downward_48px.svg + + + + + + + Adds an entity + + + + + + + + :/icons/ic_add_circle_48px.svg:/icons/ic_add_circle_48px.svg diff --git a/RetroEDv2/tools/sceneproperties/chunkreplaceoptions.cpp b/RetroEDv2/tools/sceneproperties/chunkreplaceoptions.cpp index af562d2..d33c9e9 100644 --- a/RetroEDv2/tools/sceneproperties/chunkreplaceoptions.cpp +++ b/RetroEDv2/tools/sceneproperties/chunkreplaceoptions.cpp @@ -152,6 +152,7 @@ ChunkReplaceOptions::ChunkReplaceOptions(byte gameVer, FormatHelpers::Chunks *ch ui->srcChunkList->item(replacedChunk + i)->setIcon(QPixmap::fromImage(chunks->chunks[replacedChunk + i].getImage((tileList)))); ui->dstChunkList->item(replacedChunk + i)->setIcon(QPixmap::fromImage(chunks->chunks[replacedChunk + i].getImage((tileList)))); } + modified = true; } else { // PrintLog(QString("Single replace mode")); diff --git a/RetroEDv2/tools/sceneproperties/sceneobjectproperties.cpp b/RetroEDv2/tools/sceneproperties/sceneobjectproperties.cpp index 723ad64..e0a7b0e 100644 --- a/RetroEDv2/tools/sceneproperties/sceneobjectproperties.cpp +++ b/RetroEDv2/tools/sceneproperties/sceneobjectproperties.cpp @@ -74,7 +74,8 @@ void SceneObjectProperties::setupUI(SceneEntity *entity, int entityID, Compilerv QString("An entity already exists with slotID %1.").arg(entity->slotID), QMessageBox::NoButton, this); msgBox->open(); - entity->slotID = entity->prevSlot; + entity->slotID = entity->prevSlot; + entity->gameEntitySlot = entity->prevSlot; flag = true; infoGroup[1]->updateValue(); @@ -82,19 +83,19 @@ void SceneObjectProperties::setupUI(SceneEntity *entity, int entityID, Compilerv } } byte type = *(byte *)infoGroup[0]->valuePtr; - emit typeChanged(entity, type); + emit typeChanged(entity, type, true); } if (!flag) entity->prevSlot = entity->slotID; }); connect(infoGroup[2], &Property::changed, - [this, infoGroup, entity, entityv2, entityv3, entityv4, ver] { + [this, infoGroup, entity, entityv2, entityv3, entityv4, ver, entityID] { byte propVal = *(byte *)infoGroup[2]->valuePtr; // we set propertyValue via this so the game can run logic on it bool called = false; - callRSDKEdit(scnEditor, false, entity->slotID, -1, propVal, &called); + callRSDKEdit(scnEditor, false, entityID, -1, propVal, &called); if (called) { if (ver == ENGINE_v3) @@ -117,7 +118,7 @@ void SceneObjectProperties::setupUI(SceneEntity *entity, int entityID, Compilerv for (int i = startGroup; i < properties->propertySet.count(); ++i) { auto &var = entity->variables[i - startGroup]; var.value_int32 = - callRSDKEdit(scnEditor, true, entity->slotID, i - startGroup, var.value_int32); + callRSDKEdit(scnEditor, true, entityID, i - startGroup, var.value_int32); switch (ver) { case ENGINE_v2: entity->propertyValue = entityv2->propertyValue; break; @@ -247,7 +248,7 @@ void SceneObjectProperties::setupUI(SceneEntity *entity, int entityID, Compilerv for (int i = 3; i < properties->propertySet.count(); ++i) { auto &var = entity->variables[i - 3]; var.value_int32 = - callRSDKEdit(scnEditor, true, entity->slotID, i - 3, var.value_int32); + callRSDKEdit(scnEditor, true, entityID, i - 3, var.value_int32); entity->propertyValue = entityv4->propertyValue; for(int v = 0; v < 0xF; v++){ @@ -288,7 +289,7 @@ void SceneObjectProperties::setupUI(SceneEntity *entity, int entityID, Compilerv } } - var.value_int32 = callRSDKEdit(scnEditor, true, entity->slotID, v, 0); + var.value_int32 = callRSDKEdit(scnEditor, true, entityID, v, 0); if (aliases.count()) { valGroup.append(new Property("enum", aliases, &var.value_int32, Property::INT_MANAGER)); diff --git a/RetroEDv2/tools/sceneproperties/sceneobjectproperties.hpp b/RetroEDv2/tools/sceneproperties/sceneobjectproperties.hpp index 21b72dc..36ade30 100644 --- a/RetroEDv2/tools/sceneproperties/sceneobjectproperties.hpp +++ b/RetroEDv2/tools/sceneproperties/sceneobjectproperties.hpp @@ -33,7 +33,7 @@ class SceneObjectProperties : public QWidget PropertyBrowser *properties = nullptr; signals: - void typeChanged(SceneEntity *entity, byte type); + void typeChanged(SceneEntity *entity, byte type, bool keepVals = false); private: Ui::SceneObjectProperties *ui; diff --git a/RetroEDv2/tools/sceneproperties/sceneobjectpropertiesv5.cpp b/RetroEDv2/tools/sceneproperties/sceneobjectpropertiesv5.cpp index dca84ef..0b6ff64 100644 --- a/RetroEDv2/tools/sceneproperties/sceneobjectpropertiesv5.cpp +++ b/RetroEDv2/tools/sceneproperties/sceneobjectpropertiesv5.cpp @@ -61,7 +61,7 @@ void SceneObjectPropertiesv5::setupUI(SceneEntity *entity) } } byte type = *(byte *)infoGroup[0]->valuePtr; - emit typeChanged(entity, type); + emit typeChanged(entity, type, true); } if (!flag) entity->prevSlot = entity->slotID; @@ -384,7 +384,6 @@ void SceneObjectPropertiesv5::updateUI() { if (!entityPtr) return; - properties->propertySet[0]->subProperties[0]->updateValue(); properties->propertySet[0]->subProperties[1]->updateValue(); properties->propertySet[1]->subProperties[0]->updateValue(); diff --git a/RetroEDv2/tools/sceneproperties/sceneobjectpropertiesv5.hpp b/RetroEDv2/tools/sceneproperties/sceneobjectpropertiesv5.hpp index b758a1b..93cbd98 100644 --- a/RetroEDv2/tools/sceneproperties/sceneobjectpropertiesv5.hpp +++ b/RetroEDv2/tools/sceneproperties/sceneobjectpropertiesv5.hpp @@ -25,7 +25,7 @@ class SceneObjectPropertiesv5 : public QWidget PropertyBrowser *properties = nullptr; signals: - void typeChanged(SceneEntity *entity, byte type); + void typeChanged(SceneEntity *entity, byte type, bool keepVals = false); private: Ui::SceneObjectPropertiesv5 *ui; diff --git a/RetroEDv2/tools/sceneproperties/scenetileproperties.cpp b/RetroEDv2/tools/sceneproperties/scenetileproperties.cpp index 2d4c9a8..021460d 100644 --- a/RetroEDv2/tools/sceneproperties/scenetileproperties.cpp +++ b/RetroEDv2/tools/sceneproperties/scenetileproperties.cpp @@ -14,6 +14,7 @@ SceneTileProperties::SceneTileProperties(QWidget *parent) ui->setupUi(this); replaceTile = ui->replaceTile; + edit.tileImg = QImage(16,16, QImage::Format_Indexed8); ui->tileFrame->layout()->addWidget(&edit); } @@ -44,6 +45,7 @@ void SceneTileProperties::setupUI(ushort tid, QList &tiles, SceneViewer } edit.paintVer = gameType; edit.tileImg = tileImg; + edit.update(); ui->colPlaneA->setChecked(true); @@ -435,7 +437,7 @@ void SceneTileProperties::unsetUI() cmaskv1[1] = nullptr; edit.cmask = cmask[0]; - edit.tileImg = QImage(0,0); + edit.tileImg = QImage(16,16, QImage::Format_Indexed8); ui->tileFrame->layout()->removeWidget(&edit); } @@ -465,7 +467,6 @@ TileCollisionWidget::TileCollisionWidget(QWidget *parent) : QWidget(parent) { se void TileCollisionWidget::paintEvent(QPaintEvent *) { QPainter p(this); - QRectF rect(0, 0, (qreal)width() / 16, (qreal)height() / 16); p.drawImage(QRect(0, 0, width(), height()), tileImg); diff --git a/RetroEDv2/tools/sceneproperties/scenetileproperties.ui b/RetroEDv2/tools/sceneproperties/scenetileproperties.ui index fa0b835..82060bf 100644 --- a/RetroEDv2/tools/sceneproperties/scenetileproperties.ui +++ b/RetroEDv2/tools/sceneproperties/scenetileproperties.ui @@ -6,8 +6,8 @@ 0 0 - 211 - 651 + 267 + 653 @@ -35,6 +35,13 @@ 3 + + + + Replace Tile + + + @@ -42,155 +49,6 @@ - - - - - 0 - 50 - - - - - 3 - - - 3 - - - 3 - - - - - - 140 - 13 - - - - Retro-Sonic Properties - - - - - - - - 30 - 22 - - - - - 16777215 - 22 - - - - Col Mode - - - - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - - Floor - - - - - LWall - - - - - RWall - - - - - Roof - - - - - All - - - - - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Index - - - - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - - 0 - - - - - 1 - - - - - 2 - - - - - 3 - - - - - - - @@ -198,36 +56,62 @@ - - + + + + false + + + + 0 + 0 + + - Replace Tile + Edit Chunk Collision - - - + + + + false + + + QAbstractItemView::DragDrop + + + Qt::IgnoreAction + + - 60 - 0 + 16 + 16 - - Tile: + + Qt::ElideNone - - - - - + + QListView::Free + + + QListView::LeftToRight + + + true + + - 30 - 0 + 28 + 32 - - B + + QListView::IconMode + + + true @@ -685,47 +569,192 @@ - - - - false - - - QAbstractItemView::NoDragDrop - - - Qt::IgnoreAction - - + + + - 16 - 16 + 30 + 0 - - Qt::ElideNone - - - QListView::Free + + A - - QListView::LeftToRight + + + + + + + 60 + 0 + - - true + + Tile: - + + + + + - 28 - 32 + 30 + 0 - - QListView::IconMode + + B - - true + + + + + + + 0 + 50 + + + + 3 + + + 3 + + + 3 + + + + + + 140 + 13 + + + + Retro-Sonic Properties + + + + + + + + 30 + 22 + + + + + 16777215 + 22 + + + + Col Mode + + + + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + + Floor + + + + + LWall + + + + + RWall + + + + + Roof + + + + + All + + + + + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Index + + + + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + + 0 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + @@ -742,6 +771,12 @@ 256 + + + 256 + 256 + + Qt::StrongFocus @@ -767,35 +802,6 @@ - - - - - 30 - 0 - - - - A - - - - - - - false - - - - 0 - 0 - - - - Edit Chunk Collision - - - diff --git a/RetroEDv2/tools/sceneproperties/scenetilepropertiesv5.cpp b/RetroEDv2/tools/sceneproperties/scenetilepropertiesv5.cpp index a97f293..1c1c7a9 100644 --- a/RetroEDv2/tools/sceneproperties/scenetilepropertiesv5.cpp +++ b/RetroEDv2/tools/sceneproperties/scenetilepropertiesv5.cpp @@ -10,6 +10,7 @@ SceneTilePropertiesv5::SceneTilePropertiesv5(QWidget *parent) ui->setupUi(this); replaceTile = ui->replaceTile; + edit.tileImg = QImage(16, 16, QImage::Format_Indexed8); ui->frame->layout()->addWidget(&edit); } @@ -31,6 +32,7 @@ void SceneTilePropertiesv5::setupUI(RSDKv5::TileConfig::CollisionMask *cmA, curTile = tile; edit.cmask = cmask[collisionLyr]; edit.tileImg = tileImg; + edit.update(); ui->colPlaneA->setChecked(true); diff --git a/RetroEDv2/tools/sceneproperties/scenetilepropertiesv5.ui b/RetroEDv2/tools/sceneproperties/scenetilepropertiesv5.ui index 42e8bbc..d84c427 100644 --- a/RetroEDv2/tools/sceneproperties/scenetilepropertiesv5.ui +++ b/RetroEDv2/tools/sceneproperties/scenetilepropertiesv5.ui @@ -172,7 +172,7 @@ - + 0 0