예제 #1
0
void DefinitionManager::removeDefinition(QString path) {
  // find the definition and remove it from disk
  Definition &def = definitions[path];
  if (def.path == path) {
    switch (def.type) {
      case Definition::Block:
        blockManager.disableDefinitions(def.id);
        break;
      case Definition::Biome:
        biomeManager.disableDefinitions(def.id);
        break;
      case Definition::Dimension:
        dimensionManager.disableDefinitions(def.id);
        break;
      case Definition::Entity:
        entityManager.disableDefinitions(def.id);
        break;
      case Definition::Pack:
        blockManager.disableDefinitions(def.blockid);
        biomeManager.disableDefinitions(def.biomeid);
        dimensionManager.disableDefinitions(def.dimensionid);
        entityManager.disableDefinitions(def.entityid);
        break;
    }
    definitions.remove(path);
    QFile::remove(path);
    sorted.removeOne(path);
    QSettings settings;
    settings.setValue("packs", sorted);
    emit packsChanged();
    refresh();
  }
}
예제 #2
0
파일: mapview.cpp 프로젝트: Metibor/minutor
void MapView::attach(DefinitionManager *dm) {
  this->dm = dm;
  connect(dm, SIGNAL(packsChanged()),
          this, SLOT(redraw()));
  this->blocks = dm->blockIdentifier();
  this->biomes = dm->biomeIdentifier();
}
예제 #3
0
void DefinitionManager::toggledPack(bool onoff)
{
	if (definitions.contains(selected))
	{
		Definition &def=definitions[selected];
		def.enabled=onoff;
		switch (def.type)
		{
		case Definition::Block:
			if (onoff)
				blocks->enableDefinitions(def.id);
			else
				blocks->disableDefinitions(def.id);
			break;
		case Definition::Biome:
			if (onoff)
				biomes->enableDefinitions(def.id);
			else
				biomes->disableDefinitions(def.id);
			break;
		case Definition::Dimension:
			if (onoff)
				dimensionList->enableDefinitions(def.id);
			else
				dimensionList->disableDefinitions(def.id);
			break;
		case Definition::Entity:
			if (onoff)
				entityManager.enableDefinitions(def.id);
			else
				entityManager.disableDefinitions(def.id);
			break;
		case Definition::Pack:
			if (onoff)
			{
				blocks->enableDefinitions(def.blockid);
				biomes->enableDefinitions(def.biomeid);
				dimensionList->enableDefinitions(def.dimensionid);
				entityManager.enableDefinitions(def.entityid);
			}
			else
			{
				blocks->disableDefinitions(def.blockid);
				biomes->disableDefinitions(def.biomeid);
				dimensionList->disableDefinitions(def.dimensionid);
				entityManager.disableDefinitions(def.entityid);
			}
			break;
		}
	}
	emit packsChanged();
	refresh();
}
예제 #4
0
void DefinitionManager::addPack() {
  QString packName = QFileDialog::getOpenFileName(this, tr("Open Pack"),
    QString(), tr("Definitions (*.zip *.json)"));
  if (!packName.isEmpty()) {
    if (packName.endsWith(".json", Qt::CaseInsensitive))  // raw json
      installJson(packName);
    else
      installZip(packName);
    emit packsChanged();
    QSettings settings;
    settings.setValue("packs", sorted);
    refresh();
  }
}
예제 #5
0
파일: minutor.cpp 프로젝트: Metibor/minutor
Minutor::Minutor(): maxentitydistance(0) {
  mapview = new MapView;
  connect(mapview, SIGNAL(hoverTextChanged(QString)),
          statusBar(), SLOT(showMessage(QString)));
  connect(mapview, SIGNAL(showProperties(QVariant)),
          this, SLOT(showProperties(QVariant)));
  connect(mapview, SIGNAL(addOverlayItemType(QString, QColor)),
          this, SLOT(addOverlayItemType(QString, QColor)));
  dm = new DefinitionManager(this);
  mapview->attach(dm);
  connect(dm,   SIGNAL(packsChanged()),
          this, SLOT(updateDimensions()));
  dimensions = dm->dimensionIdentifer();
  connect(dimensions, SIGNAL(dimensionChanged(const DimensionInfo &)),
          this, SLOT(viewDimension(const DimensionInfo &)));
  settings = new Settings(this);
  connect(settings, SIGNAL(settingsUpdated()),
          this, SLOT(rescanWorlds()));
  jumpTo = new JumpTo(this);

  if (settings->autoUpdate) {
    // get time of last update
    QSettings settings;
    QDateTime lastUpdateTime = settings.value("packupdate").toDateTime();

    // auto-update only once a week
    if (lastUpdateTime.addDays(7) < QDateTime::currentDateTime())
      dm->autoUpdate();
  }

  createActions();
  createMenus();
  createStatusBar();

  QBoxLayout *mainLayout;
  if (settings->verticalDepth) {
    mainLayout = new QHBoxLayout;
    depth = new LabelledSlider(Qt::Vertical);
    mainLayout->addWidget(mapview, 1);
    mainLayout->addWidget(depth);
  } else {
    mainLayout = new QVBoxLayout;
    depth = new LabelledSlider(Qt::Horizontal);
    mainLayout->addWidget(depth);
    mainLayout->addWidget(mapview, 1);
  }
  depth->setValue(255);
  mainLayout->setSpacing(0);
  mainLayout->setContentsMargins(0, 0, 0, 0);

  connect(depth, SIGNAL(valueChanged(int)),
          mapview, SLOT(setDepth(int)));
  connect(mapview, SIGNAL(demandDepthChange(int)),
          depth, SLOT(changeValue(int)));
  connect(mapview, SIGNAL(demandDepthValue(int)),
          depth, SLOT(setValue(int)));
  connect(this, SIGNAL(worldLoaded(bool)),
          mapview, SLOT(setEnabled(bool)));
  connect(this, SIGNAL(worldLoaded(bool)),
          depth, SLOT(setEnabled(bool)));

  QWidget *central = new QWidget;
  central->setLayout(mainLayout);

  setCentralWidget(central);
  layout()->setContentsMargins(0, 0, 0, 0);

  setWindowTitle(qApp->applicationName());

  propView = new Properties(this);

  emit worldLoaded(false);
}