void SceneViewer::enterEvent(QEvent *) {
  if (m_isMouseEntered) return;

  m_isMouseEntered = true;

  TApp *app        = TApp::instance();
  modifiers        = 0;
  TTool *tool      = app->getCurrentTool()->getTool();
  TXshLevel *level = app->getCurrentLevel()->getLevel();
  if (level && level->getSimpleLevel())
    m_dpiScale =
        getCurrentDpiScale(level->getSimpleLevel(), tool->getCurrentFid());
  else
    m_dpiScale = TPointD(1, 1);

  if (m_freezedStatus != NO_FREEZED) return;

  invalidateToolStatus();
  if (tool && tool->isEnabled()) {
    tool->setViewer(this);
    tool->updateMatrix();
    tool->onEnter();
  }

  setFocus();
  updateGL();
}
示例#2
0
void TApp::onXshLevelSwitched(TXshLevel *) {
  TXshLevel *level = m_currentLevel->getLevel();
  if (level) {
    TXshSimpleLevel *simpleLevel = level->getSimpleLevel();

    // Devo aggiornare la paletta corrente
    if (simpleLevel) {
      m_paletteController->getCurrentLevelPalette()->setPalette(
          simpleLevel->getPalette());

      // Se il nuovo livello selezionato e' un ovl,
      // la paletta corrente e' una cleanup palette
      //  => setto come handle corrente quello della paletta di cleanup.
      TPalette *currentPalette =
          m_paletteController->getCurrentPalette()->getPalette();

      if (simpleLevel->getType() == OVL_XSHLEVEL && currentPalette &&
          currentPalette->isCleanupPalette())
        m_paletteController->editCleanupPalette();

      return;
    }

    TXshPaletteLevel *paletteLevel = level->getPaletteLevel();
    if (paletteLevel) {
      m_paletteController->getCurrentLevelPalette()->setPalette(
          paletteLevel->getPalette());
      return;
    }
  }

  m_paletteController->getCurrentLevelPalette()->setPalette(0);
}
示例#3
0
/*! Notify change of image in \b fid: update icon and notify level change.
*/
void TTool::notifyImageChanged(const TFrameId &fid) {
  onImageChanged();

  if (!m_application) return;

  m_application->getCurrentScene()->setDirtyFlag(true);
  if (m_application->getCurrentFrame()->isEditingLevel()) {
    TXshLevel *xl = m_application->getCurrentLevel()->getLevel();
    if (!xl) return;
    TXshSimpleLevel *sl = xl->getSimpleLevel();
    if (!sl) return;
    sl->setDirtyFlag(true);
    IconGenerator::instance()->invalidate(sl, fid);
    IconGenerator::instance()->invalidateSceneIcon();
  } else {
    int row = m_application->getCurrentFrame()->getFrame();
    int col = m_application->getCurrentColumn()->getColumnIndex();
    if (col < 0) return;
    TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
    if (!xsh) return;
    TXshCell cell       = xsh->getCell(row, col);
    TXshSimpleLevel *sl = cell.getSimpleLevel();
    if (sl) {
      IconGenerator::instance()->invalidate(sl, fid);
      IconGenerator::instance()->invalidateSceneIcon();
      sl->setDirtyFlag(true);
    }
  }
  m_application->getCurrentLevel()->notifyLevelChange();
}
示例#4
0
void TApp::onLevelColorStyleSwitched() {
  TPaletteHandle *ph = m_paletteController->getCurrentLevelPalette();
  assert(ph);

  if (ToonzCheck::instance()->setColorIndex(ph->getStyleIndex())) {
    ToonzCheck *tc = ToonzCheck::instance();
    int mask       = tc->getChecks();

    if (mask & ToonzCheck::eInk || mask & ToonzCheck::ePaint) {
      IconGenerator::Settings s;
      s.m_blackBgCheck      = mask & ToonzCheck::eBlackBg;
      s.m_transparencyCheck = mask & ToonzCheck::eTransparency;
      s.m_inksOnly          = mask & ToonzCheck::eInksOnly;
      s.m_inkIndex   = mask & ToonzCheck::eInk ? tc->getColorIndex() : -1;
      s.m_paintIndex = mask & ToonzCheck::ePaint ? tc->getColorIndex() : -1;

      IconGenerator::instance()->setSettings(s);

      TXshLevel *sl = m_currentLevel->getLevel();
      if (!sl) return;

      std::vector<TFrameId> fids;
      sl->getFids(fids);

      for (int i = 0; i < (int)fids.size(); i++)
        IconGenerator::instance()->invalidate(sl, fids[i]);

      m_currentLevel->notifyLevelViewChange();
    }

    /*-- 表示オプションが切り替わっただけなので、DirtyFlagを立てない --*/
    m_currentScene->notifySceneChanged(false);
  }
}
void StudioPaletteCmd::updateAllLinkedStyles(TPaletteHandle *paletteHandle,
                                             TXsheetHandle *xsheetHandle) {
  if (!xsheetHandle) return;
  TXsheet *xsheet = xsheetHandle->getXsheet();
  if (!xsheet) return;
  ToonzScene *scene = xsheet->getScene();
  if (!scene) return;

  // emit signal only if something changed
  bool somethingChanged = false;

  StudioPalette *sp   = StudioPalette::instance();
  TLevelSet *levelSet = scene->getLevelSet();
  for (int i = 0; i < levelSet->getLevelCount(); i++) {
    TXshLevel *xl       = levelSet->getLevel(i);
    TXshSimpleLevel *sl = xl ? xl->getSimpleLevel() : 0;
    if (!sl) continue;
    TPalette *palette = sl->getPalette();
    if (palette) {
      somethingChanged = somethingChanged | sp->updateLinkedColors(palette);
      if (sl->getType() == TZP_XSHLEVEL) {
        std::vector<TFrameId> fids;
        sl->getFids(fids);
        std::vector<TFrameId>::iterator it;
        for (it = fids.begin(); it != fids.end(); ++it) {
          TFrameId fid   = *it;
          std::string id = sl->getImageId(fid);
        }
      }
    }
  }
  if (!paletteHandle || !paletteHandle->getPalette()) return;
  if (somethingChanged) paletteHandle->notifyColorStyleChanged();
}
示例#6
0
void TApp::onXshLevelChanged() {
  TXshLevel *level = m_currentLevel->getLevel();
  std::vector<TFrameId> fids;
  if (level != 0) level->getFids(fids);
  m_currentFrame->setFrameIds(fids);
  // update current tool
  m_currentTool->onImageChanged((TImage::Type)getCurrentImageType());
}
示例#7
0
 void undo() const override {
   TXshLevel *level = m_levelHandle->getLevel();
   if (level) {
     std::vector<TFrameId> fids;
     level->getFids(fids);
     invalidateIcons(level, fids);
   }
 }
示例#8
0
bool TXsheet::setCell(int row, int col, const TXshCell &cell) {
  if (row < 0 || col < 0) return false;

  bool wasColumnEmpty = isColumnEmpty(col);
  TXshCellColumn *cellColumn;

  if (!cell.isEmpty()) {
    TXshLevel *level = cell.m_level.getPointer();
    assert(level);

    int levelType               = level->getType();
    TXshColumn::ColumnType type = TXshColumn::eLevelType;

    if (levelType == SND_XSHLEVEL)
      type = TXshColumn::eSoundType;
    else if (levelType == SND_TXT_XSHLEVEL)
      type = TXshColumn::eSoundTextType;
    else if (levelType == PLT_XSHLEVEL)
      type = TXshColumn::ePaletteType;
    else if (levelType == ZERARYFX_XSHLEVEL)
      type = TXshColumn::eZeraryFxType;
    else if (levelType == MESH_XSHLEVEL)
      type = TXshColumn::eMeshType;

    cellColumn = touchColumn(col, type)->getCellColumn();
  } else {
    TXshColumn *column = getColumn(col);
    cellColumn         = column ? column->getCellColumn() : 0;
  }

  if (!cellColumn || cellColumn->isLocked()) return false;

  cellColumn->setXsheet(this);

  if (!cellColumn->setCell(row, cell)) {
    if (wasColumnEmpty) {
      removeColumn(col);
      insertColumn(col);
    }

    return false;
  }

  TFx *fx = cellColumn->getFx();
  if (wasColumnEmpty && fx && fx->getOutputConnectionCount() == 0 &&
      cellColumn->getPaletteColumn() == 0)
    getFxDag()->addToXsheet(fx);

  if (cell.isEmpty())
    updateFrameCount();
  else if (row >= m_imp->m_frameCount)
    m_imp->m_frameCount = row + 1;

  TNotifier::instance()->notify(TXsheetChange());

  return true;
}
void TXshLevelHandle::setLevel(TXshLevel *level) {
  if (m_level == level) return;

  TXshLevel *oldLevel = m_level;
  m_level             = level;
  if (level) level->addRef();
  bool levelExists = oldLevel ? oldLevel->getRefCount() > 1 : false;
  if (oldLevel) oldLevel->release();
  emit xshLevelSwitched(levelExists ? oldLevel : 0);
}
示例#10
0
TXshLevel *TLevelSet::getLevel(const ToonzScene &scene,
                               const TFilePath &levelPath) const {
  const TFilePath &decodedPath = scene.decodeFilePath(levelPath);

  int l, lCount = getLevelCount();
  for (l = 0; l != lCount; ++l) {
    TXshLevel *level = getLevel(l);
    if (decodedPath == scene.decodeFilePath(level->getPath())) return level;
  }

  return 0;
}
void FullColorBrushTool::leftButtonUp(const TPointD &pos, const TMouseEvent &e)
{
	m_brushPos = m_mousePos = pos;

	TRasterImageP ri = (TRasterImageP)getImage(true);
	if (!ri)
		return;

	if (m_points.size() != 1) {
		double maxThickness = m_thickness.getValue().second;
		double thickness = m_pressure.getValue() ? computeThickness(e.m_pressure, m_thickness) : maxThickness;
		double opacity = (m_pressure.getValue() ? computeThickness(e.m_pressure, m_opacity) : m_opacity.getValue().second) * 0.01;
		TPointD rasCenter = ri->getRaster()->getCenterD();
		TThickPoint point(pos + rasCenter, thickness);
		m_points.push_back(point);
		int m = m_points.size();
		vector<TThickPoint> points;
		points.push_back(m_points[m - 3]);
		points.push_back(m_points[m - 2]);
		points.push_back(m_points[m - 1]);
		TRect bbox = m_brush->getBoundFromPoints(points);
		updateWorkAndBackupRasters(bbox);
		m_tileSaver->save(bbox);
		m_brush->addArc(points[0], points[1], points[2], m_oldOpacity, opacity);
		m_brush->updateDrawing(ri->getRaster(), m_backUpRas, m_currentColor, bbox, m_opacity.getValue().second * 0.01);
		TRectD invalidateRect = ToolUtils::getBounds(points, maxThickness);
		invalidate(invalidateRect.enlarge(2) - rasCenter);
		m_strokeRect += bbox;
		m_lastRect.empty();
	}

	if (m_brush) {
		delete m_brush;
		m_brush = 0;
	}

	m_workRaster->unlock();

	if (m_tileSet->getTileCount() > 0) {
		delete m_tileSaver;
		TTool::Application *app = TTool::getApplication();
		TXshLevel *level = app->getCurrentLevel()->getLevel();
		TXshSimpleLevelP simLevel = level->getSimpleLevel();
		TFrameId frameId = getCurrentFid();
		TRasterP ras = ri->getRaster()->extract(m_strokeRect)->clone();
		TUndoManager::manager()->add(new FullColorBrushUndo(m_tileSet, simLevel.getPointer(), frameId,
															m_isFrameCreated, ras, m_strokeRect.getP00()));
	}

	notifyImageChanged();
	m_strokeRect.empty();
}
示例#12
0
void Filmstrip::onLevelSwitched(TXshLevel *oldLevel) {
  updateWindowTitle();

  int tc = ToonzCheck::instance()->getChecks();
  if (tc & (ToonzCheck::eInk | ToonzCheck::ePaint)) {
    TXshLevel *sl = TApp::instance()->getCurrentLevel()->getLevel();
    if (!sl) return;
    std::vector<TFrameId> fids;
    sl->getFids(fids);
    removeIcons(sl, fids, true);
  }
  update();
}
示例#13
0
void MeshifyPopup::onCellSwitched()
{
	// In case current cell level is not of the suitable type, disable the
	// rasterization parameter
	{
		TXshLevel *level = ::levelToMeshify();

		int type = level ? level->getType() : UNKNOWN_XSHLEVEL;
		m_rasterizationDpi->setEnabled(type == PLI_XSHLEVEL || type == CHILD_XSHLEVEL);
	}

	acquirePreview();
}
示例#14
0
QScriptValue getLevel(QScriptContext *ctx, QScriptEngine *eng)
{
	QString levelName = ctx->argument(0).toString();

	ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
	TXshLevel *level = scene->getLevelSet()->getLevel(levelName.toStdWString());
	if (!level) {
		level = scene->createNewLevel(PLI_XSHLEVEL, levelName.toStdWString());
		levelName = QString::fromStdWString(level->getName());
	}
	if (level->getSimpleLevel())
		return eng->newQObject(new ScriptWrapper::Level(level->getSimpleLevel()), QScriptEngine::ScriptOwnership);
	else
		return QScriptValue();
}
示例#15
0
void CastTreeViewer::dropEvent(QDropEvent *event)
{
	m_dropTargetItem = 0;
	if (m_dropFilePath != TFilePath()) {
		IoCmd::loadScene(m_dropFilePath);
		m_dropFilePath = TFilePath();
		m_dropTargetItem = 0;
		update();
		return;
	}

	if (!event->mimeData()->hasFormat("application/vnd.toonz.levels"))
		return;
	m_dropTargetItem = itemAt(event->pos());
	if (!m_dropTargetItem)
		return;
	TFilePath folderPath(m_dropTargetItem->data(1, Qt::DisplayRole).toString().toStdWString());
	m_dropTargetItem = 0;
	update();

	if (folderPath.getName() == AudioFolderName) {
		event->ignore();
		return;
	}
	event->acceptProposedAction();

	TLevelSet *levelSet = getLevelSet();

	const CastItems *castItems = dynamic_cast<const CastItems *>(event->mimeData());
	assert(castItems);
	if (!castItems)
		return;
	int i;
	TUndoManager::manager()->beginBlock();
	for (i = 0; i < castItems->getItemCount(); i++) {
		CastItem *item = castItems->getItem(i);
		if (LevelCastItem *li = dynamic_cast<LevelCastItem *>(item)) {
			TXshLevel *level = li->getLevel();
			wstring levelName = level->getName();
			MoveLevelToFolderUndo *undo = new MoveLevelToFolderUndo(levelSet, levelName, folderPath);
			levelSet->moveLevelToFolder(folderPath, level);
			TUndoManager::manager()->add(undo);
		} else if (SoundCastItem *si = dynamic_cast<SoundCastItem *>(item)) {
		}
	}
	TUndoManager::manager()->endBlock();
	emit itemMovedToFolder();
}
示例#16
0
void TLevelSet::clear() {
  for (std::vector<TXshLevel *>::iterator it = m_levels.begin();
       it != m_levels.end(); ++it) {
    TXshLevel *level = *it;
    if (level->getSimpleLevel()) level->getSimpleLevel()->clearFrames();
    (*it)->release();
  }
  m_levelTable.clear();
  m_levels.clear();

  m_folderTable.clear();
  m_folders.clear();
  m_folders.push_back(defaultRootFolder);
  m_folders.push_back(defaultSoundRootFolder);
  m_defaultFolder = defaultRootFolder;
}
示例#17
0
	MergeCmappedUndo(TXshLevel *xl, int mergeCmappedSessionId,
					 int column, TXshSimpleLevel *level, const std::map<TFrameId, QString> &images,
					 int mColumn,
					 TPalette *palette)
		: TUndo(), m_xl(xl), m_mergeCmappedSessionId(mergeCmappedSessionId), m_palette(palette->clone()), m_level(level), m_column(column), m_mColumn(mColumn), m_images(images)

	{
		m_fullpath = m_xl->getPath().getWideString();
	}
示例#18
0
void TXsheet::getUsedLevels(set<TXshLevel *> &levels) const {
  set<const TXsheet *> visitedXshs;
  vector<const TXsheet *> todoXshs;

  visitedXshs.insert(this);
  todoXshs.push_back(this);

  while (!todoXshs.empty()) {
    const TXsheet *xsh = todoXshs.back();
    todoXshs.pop_back();

    int c0 = 0, c1 = xsh->getColumnCount() - 1;
    for (int c = c0; c <= c1; ++c) {
      TXshColumnP column = const_cast<TXsheet *>(xsh)->getColumn(c);
      if (!column) continue;

      TXshCellColumn *cellColumn = column->getCellColumn();
      if (!cellColumn) continue;

      int r0, r1;
      if (!cellColumn->getRange(r0, r1)) continue;

      TXshLevel *level = 0;
      for (int r = r0; r <= r1; r++) {
        TXshCell cell = cellColumn->getCell(r);
        if (cell.isEmpty() || !cell.m_level) continue;

        if (level != cell.m_level.getPointer()) {
          level = cell.m_level.getPointer();
          levels.insert(level);
          if (level->getChildLevel()) {
            TXsheet *childXsh = level->getChildLevel()->getXsheet();
            if (visitedXshs.count(childXsh) == 0) {
              visitedXshs.insert(childXsh);
              todoXshs.push_back(childXsh);
            }
          }
        }
      }
    }
  }
}
示例#19
0
void TApp::onLevelColorStyleChanged() {
  onPaletteChanged();
  TXshLevel *level = m_currentLevel->getLevel();
  if (!level) return;
  TPalette *palette            = getCurrentPalette()->getPalette();
  TXshSimpleLevel *simpleLevel = level->getSimpleLevel();
  if (simpleLevel && simpleLevel->getPalette() == palette) {
    notifyPaletteChanged(simpleLevel);
  } else {
    TLevelSet *levelSet = getCurrentScene()->getScene()->getLevelSet();
    for (int i = 0; i < levelSet->getLevelCount(); i++) {
      if (levelSet->getLevel(i)) {
        simpleLevel = levelSet->getLevel(i)->getSimpleLevel();
        if (simpleLevel && simpleLevel->getPalette() == palette) {
          notifyPaletteChanged(simpleLevel);
        }
      }
    }
  }
}
示例#20
0
/*! Notify change of current image: update icon and notify level change.
    If current object is a spline commit spline chenged.
    If current mode is EditingLevel touch current frame.
*/
void TTool::notifyImageChanged() {
  onImageChanged();

  if (!m_application) return;

  m_application->getCurrentScene()->setDirtyFlag(true);
  if (m_application->getCurrentFrame()->isEditingLevel()) {
    TXshLevel *xl = m_application->getCurrentLevel()->getLevel();
    if (!xl) return;
    TXshSimpleLevel *sl = xl->getSimpleLevel();
    if (!sl) return;
    TFrameId fid = m_application->getCurrentFrame()->getFid();
    sl->touchFrame(fid);
    // sl->setDirtyFlag(true);
    IconGenerator::instance()->invalidate(sl, fid);
    IconGenerator::instance()->invalidateSceneIcon();
  } else {
    TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
    if (!xsh) return;

    TObjectHandle *currentObject = m_application->getCurrentObject();

    if (currentObject->isSpline()) {
      m_application->getCurrentObject()->commitSplineChanges();
      TStageObject *pegbar = xsh->getStageObject(currentObject->getObjectId());
      IconGenerator::instance()->invalidate(pegbar->getSpline());
    } else {
      int row = m_application->getCurrentFrame()->getFrame();
      int col = m_application->getCurrentColumn()->getColumnIndex();
      if (col < 0) return;
      TXshCell cell       = xsh->getCell(row, col);
      TXshSimpleLevel *sl = cell.getSimpleLevel();
      if (sl) {
        IconGenerator::instance()->invalidate(sl, cell.m_frameId);
        sl->touchFrame(cell.m_frameId);
        IconGenerator::instance()->invalidateSceneIcon();
      }
    }
  }
  m_application->getCurrentLevel()->notifyLevelChange();
}
示例#21
0
void StudioPaletteTreeViewer::loadInCurrentPalette() {
  QList<QTreeWidgetItem *> items = selectedItems();
  int count                      = items.size();
  if (count == 0) return;

  TPalette *palette = m_levelPaletteHandle->getPalette();
  if (!palette) return;

  if (palette->isLocked()) {
    DVGui::warning("Palette is Locked!");
    return;
  }

  TPalette *newPalette =
      StudioPalette::instance()->getPalette(getItemPath(items[0]), false);
  if (!newPalette) return;
  if (m_xsheetHandle) {
    int ret = DVGui::eraseStylesInDemand(palette, m_xsheetHandle, newPalette);
    if (ret == 0) return;
  }

  StudioPaletteCmd::loadIntoCurrentPalette(m_levelPaletteHandle, newPalette);
  m_currentLevelHandle->notifyLevelChange();

  TXshLevel *level = m_currentLevelHandle->getLevel();
  if (level) {
    std::vector<TFrameId> fids;
    level->getFids(fids);
    invalidateIcons(level, fids);
  }

  int i;
  for (i = 1; i < count; i++) {
    TFilePath path = getItemPath(items[i]);
    StudioPaletteCmd::mergeIntoCurrentPalette(m_levelPaletteHandle, path);
  }
  // in order to update the title bar of palette viewer
  m_levelPaletteHandle->getPalette()->setDirtyFlag(true);
  m_levelPaletteHandle->notifyPaletteChanged();
}
示例#22
0
bool StylePickerTool::startOrganizePalette() {
  /* Check if the organizing operation is available */
  TXshLevel *level = getApplication()->getCurrentLevel()->getLevel();
  if (!level) {
    DVGui::error(tr("No current level."));
    return false;
  }
  if (level->getType() != PLI_XSHLEVEL && level->getType() != TZP_XSHLEVEL &&
      level->getType() != PLT_XSHLEVEL) {
    DVGui::error(tr("Current level has no available palette."));
    return false;
  }
  /* palette should have more than one page to organize */
  TPalette *pal = NULL;
  if (level->getType() == PLT_XSHLEVEL)
    pal = level->getPaletteLevel()->getPalette();
  else
    pal = level->getSimpleLevel()->getPalette();
  if (!pal || pal->getPageCount() < 2) {
    DVGui::error(
        tr("Palette must have more than one palette to be organized."));
    return false;
  }

  m_paletteToBeOrganized = pal;

  std::cout << "Start Organize Palette" << std::endl;

  return true;
}
示例#23
0
void BinarizePopup::fetchSample()
{
	TApp *app = TApp::instance();
	TImageP img;
	if (app->getCurrentFrame()->isEditingLevel()) {
		TXshLevel *xshLevel = app->getCurrentLevel()->getLevel();
		if (xshLevel && xshLevel->getSimpleLevel()) {
			TXshSimpleLevel *sl = xshLevel->getSimpleLevel();
			img = sl->getFrame(app->getCurrentFrame()->getFid(), false);
		}
	} else {
		TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet();
		TXshCell cell = xsh->getCell(app->getCurrentFrame()->getFrame(), app->getCurrentColumn()->getColumnIndex());
		img = cell.getImage(false);
	}
	TRasterImageP ri = img;
	if (ri) {
		setSample(ri->getRaster());
	} else {
		setSample(TRasterP());
	}
}
示例#24
0
/*
  If the working palette is changed, then deactivate the "organize palette"
  toggle.
*/
void StylePickerTool::onImageChanged() {
  std::cout << "StylePickerTool::onImageChanged" << std::endl;
  if (!m_organizePalette.getValue() || !m_paletteToBeOrganized) return;

  TXshLevel *level = getApplication()->getCurrentLevel()->getLevel();
  if (!level) {
    m_organizePalette.setValue(false);
    getApplication()->getCurrentTool()->notifyToolChanged();
    return;
  }
  TPalette *pal = NULL;
  if (level->getType() == PLT_XSHLEVEL)
    pal = level->getPaletteLevel()->getPalette();
  else if (level->getSimpleLevel()) {
    pal = level->getSimpleLevel()->getPalette();
  }
  if (!pal || pal != m_paletteToBeOrganized) {
    m_organizePalette.setValue(false);
    getApplication()->getCurrentTool()->notifyToolChanged();
    return;
  }
}
示例#25
0
void LevelSettingsPopup::onNameChanged() {
  QString text     = m_nameFld->text();
  TXshLevel *level = 0;
  if (m_sl)
    level = m_sl.getPointer();
  else if (m_cl)
    level = m_cl.getPointer();
  else
    return;

  if (text.length() == 0) {
    error("The name " + text +
          " you entered for the level is not valid.\n Please enter a different "
          "name.");
    m_nameFld->setFocus();
    return;
  }

  /*-- Level名に変更がない場合 --*/
  if (level->getName() == text.toStdWString()) {
    // warning("Level name unchanged.");
    return;
  }

  TLevelSet *levelSet =
      TApp::instance()->getCurrentScene()->getScene()->getLevelSet();

  if (!levelSet->renameLevel(level, text.toStdWString())) {
    error("The name " + text +
          " you entered for the level is already used.\nPlease enter a "
          "different name.");
    m_nameFld->setFocus();
    return;
  }

  TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
  TApp::instance()->getCurrentScene()->notifyCastChange();
}
示例#26
0
void TLevelSet::loadFolder(TIStream &is, TFilePath folder) {
  std::string s;
  is.getTagParam("type", s);
  if (s == "default") setDefaultFolder(folder);
  while (!is.eos()) {
    std::string tagName;
    is.matchTag(tagName);
    if (tagName == "levels") {
      while (!is.eos()) {
        TPersist *p = 0;
        is >> p;
        TXshLevel *xshLevel = dynamic_cast<TXshLevel *>(p);
        if (xshLevel && !xshLevel->getChildLevel())
          moveLevelToFolder(folder, xshLevel);
      }
    } else if (tagName == "folder") {
      is.getTagParam("name", s);
      TFilePath child = createFolder(folder, ::to_wstring(s));
      loadFolder(is, child);
    } else
      throw TException("expected <levels> or <folder>");
    is.closeChild();
  }
示例#27
0
QScriptValue Level::load(const QScriptValue &fpArg) {
  if (m_sl) {
    m_scene->getLevelSet()->removeLevel(m_sl, true);
    m_sl->release();
    m_sl = 0;
  }

  // get the path
  TFilePath fp;
  QScriptValue err = checkFilePath(context(), fpArg, fp);
  if (err.isError()) return err;
  QString fpStr = fpArg.toString();

  try {
    if (!TSystem::doesExistFileOrLevel(fp)) {
      return context()->throwError(tr("File %1 doesn't exist").arg(fpStr));
    }
    TFileType::Type fileType = TFileType::getInfo(fp);
    if (TFileType::isVector(fileType))
      m_type = PLI_XSHLEVEL;
    else if (0 != (fileType & TFileType::CMAPPED_IMAGE))
      m_type = TZP_XSHLEVEL;
    else if (0 != (fileType & TFileType::RASTER_IMAGE))
      m_type = OVL_XSHLEVEL;
    else {
      return context()->throwError(tr("File %1 is unsupported").arg(fpStr));
    }
    TXshLevel *xl = m_scene->loadLevel(fp);
    if (xl) {
      m_sl = xl->getSimpleLevel();
      m_sl->addRef();
    }
    return context()->thisObject();
  } catch (...) {
    return context()->throwError(tr("Exception reading %1").arg(fpStr));
  }
}
示例#28
0
void TApp::updateXshLevel() {
  TXshLevel *xl = 0;
  if (m_currentFrame->isEditingScene()) {
    int frame       = m_currentFrame->getFrame();
    int column      = m_currentColumn->getColumnIndex();
    TXsheet *xsheet = m_currentXsheet->getXsheet();

    if (xsheet && column >= 0 && frame >= 0 && !xsheet->isColumnEmpty(column)) {
      TXshCell cell = xsheet->getCell(frame, column);
      xl            = cell.m_level.getPointer();

      // Se sono su una cella vuota successiva a celle di un certo livello
      // prendo questo come livello corrente.
      if (!xl && frame > 0) {
        TXshCell cell = xsheet->getCell(frame - 1, column);
        xl            = cell.m_level.getPointer();
      }
    }

    m_currentLevel->setLevel(xl);

    // level could be the same, but palette could have changed
    if (xl && xl->getSimpleLevel()) {
      TPalette *currentPalette =
          m_paletteController->getCurrentPalette()->getPalette();
      int styleIndex =
          m_paletteController->getCurrentLevelPalette()->getStyleIndex();

      m_paletteController->getCurrentLevelPalette()->setPalette(
          xl->getSimpleLevel()->getPalette(), styleIndex);

      // Se il nuovo livello selezionato e' un ovl,
      // la paletta corrente e' una cleanup palette
      //  => setto come handle corrente quello della paletta di cleanup.

      if (xl->getType() == OVL_XSHLEVEL && currentPalette &&
          currentPalette->isCleanupPalette())

        m_paletteController->editCleanupPalette();
    } else if (xl && xl->getPaletteLevel()) {
      int styleIndex =
          m_paletteController->getCurrentLevelPalette()->getStyleIndex();
      m_paletteController->getCurrentLevelPalette()->setPalette(
          xl->getPaletteLevel()->getPalette(), styleIndex);
    } else
      m_paletteController->getCurrentLevelPalette()->setPalette(0);
  }
}
示例#29
0
    }
  };  // locals

  TXshColumnP column = xsh->getColumn(col);
  assert(column);

  TStageObject *pegbar = xsh->getStageObject(TStageObjectId::ColumnId(col));

  // Build affine placements

  TAffine columnAff     = pegbar->getPlacement(row);
  double columnZ        = pegbar->getZ(row);
  double columnNoScaleZ = pegbar->getGlobalNoScaleZ();

  TXshCell cell = xsh->getCell(row, col);
  TXshLevel *xl = cell.m_level.getPointer();
  if (!xl) return;

  ZPlacement cameraPlacement;
  if (m_subXSheetStack.empty())
    cameraPlacement = m_cameraPlacement;
  else
    cameraPlacement = m_subXSheetStack.back().m_camera;
  TAffine columnZaff;
  bool columnBehindCamera = TStageObject::perspective(
      columnZaff, cameraPlacement.m_aff, cameraPlacement.m_z, columnAff,
      columnZ, columnNoScaleZ);

  if (!columnBehindCamera) return;

  TXshSimpleLevel *sl = xl->getSimpleLevel();
示例#30
0
bool TXsheet::setCells(int row, int col, int rowCount, const TXshCell cells[]) {
  static const TXshCell emptyCell;
  int i = 0;
  while (i < rowCount && cells[i].isEmpty()) i++;

  // inserito da Elisa verso novembre 2009.
  // cosi' ha il difetto che se assegno celle vuote non fa nulla
  // per ora lo commento. bisogna indagare se questo rompe qualcosa

  // ho modificato il seguito per gestire il caso in cui i>=rowCount
  // => niente livelli dentro cells

  // if(i>=rowCount)
  //  return false;

  TXshColumn::ColumnType type = TXshColumn::eLevelType;
  if (i < rowCount) {
    TXshLevel *level = cells[i].m_level.getPointer();
    int levelType    = level->getType();

    if (levelType == SND_XSHLEVEL)
      type = TXshColumn::eSoundType;
    else if (levelType == SND_TXT_XSHLEVEL)
      type = TXshColumn::eSoundTextType;
    else if (levelType == PLT_XSHLEVEL)
      type = TXshColumn::ePaletteType;
    else if (levelType == ZERARYFX_XSHLEVEL)
      type = TXshColumn::eZeraryFxType;
    else if (levelType == MESH_XSHLEVEL)
      type = TXshColumn::eMeshType;
  }
  bool wasColumnEmpty    = isColumnEmpty(col);
  TXshCellColumn *column = touchColumn(col, type)->getCellColumn();
  if (!column) return false;

  int oldColRowCount = column->getMaxFrame() + 1;
  bool ret           = column->setCells(row, rowCount, cells);
  if (!ret || column->isLocked()) {
    if (wasColumnEmpty) {
      removeColumn(col);
      insertColumn(col);
    }
    return false;
  }
  int newColRowCount = column->getMaxFrame() + 1;

  TFx *fx = column->getFx();
  if (wasColumnEmpty && fx && fx->getOutputConnectionCount() == 0)
    getFxDag()->addToXsheet(fx);
  column->setXsheet(this);

  if (newColRowCount > m_imp->m_frameCount)
    m_imp->m_frameCount = newColRowCount;
  else {
    if (oldColRowCount == m_imp->m_frameCount &&
        newColRowCount < m_imp->m_frameCount)
      updateFrameCount();
  }

  return true;
}