Merge pull request #612 from manongjohn/block_new_frames_on_single_frame_files
Block new frames in Single Frame levels
This commit is contained in:
commit
ff648d6981
3 changed files with 64 additions and 0 deletions
|
@ -350,6 +350,13 @@ TImage *TTool::touchImage() {
|
||||||
TXshSimpleLevel *sl = cell.getSimpleLevel();
|
TXshSimpleLevel *sl = cell.getSimpleLevel();
|
||||||
|
|
||||||
if (sl) {
|
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 for some reason there is no palette, try and set a default one now.
|
||||||
if (!sl->getPalette() &&
|
if (!sl->getPalette() &&
|
||||||
(sl->getType() == TZP_XSHLEVEL || sl->getType() == PLI_XSHLEVEL)) {
|
(sl->getType() == TZP_XSHLEVEL || sl->getType() == PLI_XSHLEVEL)) {
|
||||||
|
@ -1072,6 +1079,20 @@ QString TTool::updateEnabled(int rowIndex, int columnIndex) {
|
||||||
|
|
||||||
return (enable(false),
|
return (enable(false),
|
||||||
QObject::tr("The current level is not editable."));
|
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."));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2741,6 +2741,19 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
|
||||||
DVGui::warning(QObject::tr("The current level is not editable"));
|
DVGui::warning(QObject::tr("The current level is not editable"));
|
||||||
return;
|
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();
|
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
|
||||||
|
@ -2902,6 +2915,19 @@ void TCellSelection::duplicateFrame(int row, int col, bool multiple) {
|
||||||
TXshSimpleLevel *sl = prevCell.getSimpleLevel();
|
TXshSimpleLevel *sl = prevCell.getSimpleLevel();
|
||||||
if (!sl || sl->isSubsequence() || sl->isReadOnly()) return;
|
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();
|
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
|
||||||
|
|
||||||
//----- Going to cheat a little. Use autocreate rules to help create what we
|
//----- Going to cheat a little. Use autocreate rules to help create what we
|
||||||
|
|
|
@ -850,6 +850,18 @@ void FilmstripFrames::mousePressEvent(QMouseEvent *event) {
|
||||||
TFrameId fid = index2fid(index);
|
TFrameId fid = index2fid(index);
|
||||||
|
|
||||||
TXshSimpleLevel *sl = getLevel();
|
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 +
|
int frameHeight = m_iconSize.height() + fs_frameSpacing + fs_iconMarginTop +
|
||||||
fs_iconMarginBottom;
|
fs_iconMarginBottom;
|
||||||
int frameWidth = m_iconSize.width() + fs_frameSpacing + fs_iconMarginLR +
|
int frameWidth = m_iconSize.width() + fs_frameSpacing + fs_iconMarginLR +
|
||||||
|
@ -1130,6 +1142,11 @@ void FilmstripFrames::keyPressEvent(QKeyEvent *event) {
|
||||||
std::vector<TFrameId> fids;
|
std::vector<TFrameId> fids;
|
||||||
level->getFids(fids);
|
level->getFids(fids);
|
||||||
if (fids.empty()) return;
|
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
|
// If on a level frame pass the frame id after the last frame to allow
|
||||||
// creating a new frame with the down arrow key
|
// creating a new frame with the down arrow key
|
||||||
|
|
Loading…
Reference in a new issue