Block new frames in Single Frame levels

This commit is contained in:
manongjohn 2021-03-11 11:22:23 -05:00
parent e70e7ead32
commit c9ade85c0f
3 changed files with 64 additions and 0 deletions

View file

@ -350,6 +350,13 @@ TImage *TTool::touchImage() {
TXshSimpleLevel *sl = cell.getSimpleLevel();
if (sl) {
// For Single Frame levels, don't create anything
std::vector<TFrameId> fids;
sl->getFids(fids);
if (fids.size() == 1 && (fids[0].getNumber() == TFrameId::EMPTY_FRAME ||
fids[0].getNumber() == TFrameId::NO_FRAME))
return 0;
// If for some reason there is no palette, try and set a default one now.
if (!sl->getPalette() &&
(sl->getType() == TZP_XSHLEVEL || sl->getType() == PLI_XSHLEVEL)) {
@ -1072,6 +1079,20 @@ QString TTool::updateEnabled(int rowIndex, int columnIndex) {
return (enable(false),
QObject::tr("The current level is not editable."));
// For Single Frame raster levels, don't allow new levels to be created
if (levelType == OVL_XSHLEVEL && !filmstrip) {
std::vector<TFrameId> fids;
sl->getFids(fids);
if (fids.size() == 1 && (fids[0].getNumber() == TFrameId::EMPTY_FRAME ||
fids[0].getNumber() == TFrameId::NO_FRAME)) {
TXshCell cell = xsh->getCell(rowIndex, columnIndex);
if (cell.isEmpty())
return (enable(false),
QObject::tr("The current tool cannot be used on empty "
"frames of a Single Frame level."));
}
}
}
}

View file

@ -2706,6 +2706,19 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
DVGui::warning(QObject::tr("The current level is not editable"));
return;
}
// Do not duplicate frames on Single Frame levels
if (level->getSimpleLevel()) {
std::vector<TFrameId> fids;
level->getSimpleLevel()->getFids(fids);
if (fids.size() == 1 && (fids[0].getNumber() == TFrameId::EMPTY_FRAME ||
fids[0].getNumber() == TFrameId::NO_FRAME)) {
if (!multiple)
DVGui::warning(QObject::tr(
"Unable to create a blank drawing on a Single Frame level"));
return;
}
}
}
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
@ -2867,6 +2880,19 @@ void TCellSelection::duplicateFrame(int row, int col, bool multiple) {
TXshSimpleLevel *sl = prevCell.getSimpleLevel();
if (!sl || sl->isSubsequence() || sl->isReadOnly()) return;
// Do not duplicate frames on Single Frame levels
if (sl) {
std::vector<TFrameId> fids;
sl->getFids(fids);
if (fids.size() == 1 && (fids[0].getNumber() == TFrameId::EMPTY_FRAME ||
fids[0].getNumber() == TFrameId::NO_FRAME)) {
if (!multiple)
DVGui::warning(QObject::tr(
"Unable to duplicate a drawing on a Single Frame level"));
return;
}
}
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
//----- Going to cheat a little. Use autocreate rules to help create what we

View file

@ -850,6 +850,18 @@ void FilmstripFrames::mousePressEvent(QMouseEvent *event) {
TFrameId fid = index2fid(index);
TXshSimpleLevel *sl = getLevel();
// If accessed after 1st frame on a Single Frame level
// Block movement so we can't create new images
if (index > 0) {
std::vector<TFrameId> fids;
sl->getFids(fids);
if (fids.empty() ||
(fids.size() == 1 && (fids[0].getNumber() == TFrameId::EMPTY_FRAME ||
fids[0].getNumber() == TFrameId::NO_FRAME)))
return;
}
int frameHeight = m_iconSize.height() + fs_frameSpacing + fs_iconMarginTop +
fs_iconMarginBottom;
int frameWidth = m_iconSize.width() + fs_frameSpacing + fs_iconMarginLR +
@ -1130,6 +1142,11 @@ void FilmstripFrames::keyPressEvent(QKeyEvent *event) {
std::vector<TFrameId> fids;
level->getFids(fids);
if (fids.empty()) return;
// Do not allow movement on Single Frame levels
if (fids.empty() ||
(fids.size() == 1 && (fids[0].getNumber() == TFrameId::EMPTY_FRAME ||
fids[0].getNumber() == TFrameId::NO_FRAME)))
return;
// If on a level frame pass the frame id after the last frame to allow
// creating a new frame with the down arrow key