Ejemplo n.º 1
0
void Door::loadAppearance() {
	if (_appearanceID == 0) {
		if (_genericType == Aurora::kFieldIDInvalid)
			throw Common::Exception("Door \"%s\" has no appearance ID and no generic type",
			                        _tag.c_str());

		loadAppearance(TwoDAReg.get("genericdoors"), _genericType);
	} else
		loadAppearance(TwoDAReg.get("doortypes"), _appearanceID);
}
Ejemplo n.º 2
0
void Door::loadAppearance() {
	if (_appearanceID == 0) {
		if (_genericType == Aurora::kFieldIDInvalid)
			_invisible = true;
		else
			loadAppearance(TwoDAReg.get2DA("genericdoors"), _genericType);
	} else
		loadAppearance(TwoDAReg.get2DA("doortypes"), _appearanceID);

	// Invisible doors have no model and are always open
	if (_invisible) {
		_modelName.clear();
		_state = kStateOpened1;
	}
}
Ejemplo n.º 3
0
void Creature::load(const Aurora::GFF3Struct &creature) {
	Common::UString temp = creature.getString("ResRef");

	if (!temp.empty()) {
		try {
			Common::ScopedPtr<Aurora::GFF3File>
				cre(new Aurora::GFF3File(temp, Aurora::kFileTypeCRE, MKTAG('C', 'R', 'E', ' ')));

			loadBlueprint(cre->getTopLevel());

		} catch (Common::Exception &e) {
			e.add("Creature \"%s\" has no blueprint", temp.c_str());
			throw;
		}
	}

	// Tag
	_tag = creature.getString("Tag");

	// Appearance

	if (_appearance == Aurora::kFieldIDInvalid)
		throw Common::Exception("Creature without an appearance");

	loadAppearance();

	loadInstance(creature);
}
Ejemplo n.º 4
0
void Situated::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) {
	// General properties

	if (blueprint)
		loadProperties(*blueprint); // Blueprint
	loadProperties(instance);    // Instance


	// Specialized object properties

	if (blueprint)
		loadObject(*blueprint); // Blueprint
	loadObject(instance);    // Instance


	// Appearance

	if (_appearanceID == Aurora::kFieldIDInvalid)
		throw Common::Exception("Situated object without an appearance");

	loadAppearance();
	loadSounds();


	// Position

	float posX = instance.getDouble("X");
	float posY = instance.getDouble("Y");
	float posZ = instance.getDouble("Z");

	if (instance.hasField("Position")) {
		const Aurora::GFF3Struct &pos = instance.getStruct("Position");

		posX = pos.getDouble("x");
		posY = pos.getDouble("y");
		posZ = pos.getDouble("z");
	}

	setPosition(posX, posY, posZ);

	// Orientation

	float bearing = instance.getDouble("Bearing");

	float rotX = 0.0f;
	float rotY = 0.0f;
	float rotZ = 1.0f;
	float rotW = Common::rad2deg(bearing);

	if (instance.hasField("Orientation")) {
		const Aurora::GFF3Struct &o = instance.getStruct("Orientation");

		rotX = o.getDouble("x");
		rotY = o.getDouble("y");
		rotZ = o.getDouble("z");
		rotW = -Common::rad2deg(acos(o.getDouble("w")) * 2.0);
	}

	setOrientation(rotX, rotY, rotZ, rotW);
}
Ejemplo n.º 5
0
void Creature::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) {
	// General properties

	if (blueprint)
		loadProperties(*blueprint); // Blueprint
	loadProperties(instance);    // Instance


	// Appearance

	if (_appearance == Aurora::kFieldIDInvalid)
		throw Common::Exception("Creature without an appearance");

	loadAppearance();

	// Position

	setPosition(instance.getDouble("XPosition"),
	            instance.getDouble("YPosition"),
	            instance.getDouble("ZPosition"));

	// Orientation

	float bearingX = instance.getDouble("XOrientation");
	float bearingY = instance.getDouble("YOrientation");

	setOrientation(0.0f, 0.0f, 1.0f, -Common::rad2deg(atan2(bearingX, bearingY)));
}
Ejemplo n.º 6
0
void Creature::load(const Aurora::GFFStruct &instance, const Aurora::GFFStruct *blueprint) {
	assert(!_loaded);

	// General properties

	if (blueprint)
		loadProperties(*blueprint); // Blueprint
	loadProperties(instance);    // Instance


	// Appearance

	if (_appearance == Aurora::kFieldIDInvalid)
		throw Common::Exception("Creature without an appearance");

	loadAppearance();

	// Position

	setPosition(instance.getDouble("XPosition"),
	            instance.getDouble("YPosition"),
	            instance.getDouble("ZPosition"));

	// Orientation

	float bearingX = instance.getDouble("XOrientation");
	float bearingY = instance.getDouble("YOrientation");

	float o[3];
	Common::vector2orientation(bearingX, bearingY, o[0], o[1], o[2]);

	setOrientation(o[0], o[1], o[2]);

	_loaded = true;
}
Ejemplo n.º 7
0
Archivo: door.cpp Proyecto: kevL/xoreos
void Door::loadAppearance() {
	if (_appearanceID == 0) {
		if (_genericType == Aurora::kFieldIDInvalid)
			_invisible = true;
		else
			loadAppearance(TwoDAReg.get2DA("genericdoors"), _genericType);
	} else
		loadAppearance(TwoDAReg.get2DA("doortypes"), _appearanceID);

	// Invisible doors have no model and are always open
	if (_invisible) {
		_modelName.clear();
		_state = kStateOpened1;
	}

	// Doors have a default, fallback portrait
	if (_portrait.empty())
		_portrait = "po_door01_";
}
Ejemplo n.º 8
0
void Situated::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) {
	// General properties

	if (blueprint)
		loadProperties(*blueprint); // Blueprint
	loadProperties(instance);    // Instance


	// Specialized object properties

	if (blueprint)
		loadObject(*blueprint); // Blueprint
	loadObject(instance);    // Instance


	// Appearance

	if (_appearanceID == Aurora::kFieldIDInvalid)
		warning("Situated object \"%s\" without an appearance", _tag.c_str());

	loadAppearance();
	loadSounds();

	// Model

	if (!_modelName.empty()) {
		_model.reset(loadModelObject(_modelName));

		if (!_model)
			throw Common::Exception("Failed to load situated object model \"%s\"",
			                        _modelName.c_str());
	} else
		warning("Situated object \"%s\" (\"%s\") has no model", _name.c_str(), _tag.c_str());

	if (_model) {
		// Clickable
		_model->setTag(_tag);
		_model->setClickable(isClickable());

		// ID
		_ids.push_back(_model->getID());
	}

	// Position

	setPosition(instance.getDouble("X"),
	            instance.getDouble("Y"),
	            instance.getDouble("Z"));

	// Orientation

	float bearing = instance.getDouble("Bearing");

	setOrientation(0.0f, 0.0f, 1.0f, Common::rad2deg(bearing));
}
Ejemplo n.º 9
0
void PreferenceDialog::importAppearance()
{
    QStringList list = QStandardPaths::standardLocations(
                QStandardPaths::DocumentsLocation);
    QString path = QFileDialog::getOpenFileName(
                this, tr("ファイルを選択"), list.at(0),
                tr("設定ファイル (*.ini);;すべてのファイル (*)"));
    if (path.isEmpty()) {
        return;
    }

    QSettings settings(path, QSettings::IniFormat);
    loadAppearance(settings, true);
}
Ejemplo n.º 10
0
void Situated::load(const Aurora::GFFStruct &instance, const Aurora::GFFStruct *blueprint) {
	// General properties

	if (blueprint)
		loadProperties(*blueprint); // Blueprint
	loadProperties(instance);    // Instance


	// Specialized object properties

	if (blueprint)
		loadObject(*blueprint); // Blueprint
	loadObject(instance);    // Instance


	// Appearance

	if (_appearanceID == Aurora::kFieldIDInvalid)
		throw Common::Exception("Situated object without an appearance");

	loadAppearance();
	loadSounds();


	// Position

	setPosition(instance.getDouble("X"),
	            instance.getDouble("Y"),
	            instance.getDouble("Z"));

	// Orientation

	float bearing = instance.getDouble("Bearing");

	setOrientation(0.0, Common::rad2deg(bearing), 0.0);
}
Ejemplo n.º 11
0
PreferenceDialog::PreferenceDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::PreferenceDialog),
    m_model(),
    m_colorMap()
{
    m_model.setColorMap(&m_colorMap);

    ui->setupUi(this);
    ui->tabWidget->setCurrentIndex(0);
    // アドレスボックスの外観サンプル
    ui->sampleEdit->setText(QDir::homePath());
    // ファイルビューの外観サンプル
    ui->sampleTable->setModel(&m_model);

    QHeaderView *header;
    header = ui->sampleTable->horizontalHeader();
    header->setSectionResizeMode(0, QHeaderView::Stretch);
    header->setSectionResizeMode(1, QHeaderView::ResizeToContents);
    header->setSectionResizeMode(2, QHeaderView::ResizeToContents);
    header = ui->sampleTable->verticalHeader();
    header->setDefaultSectionSize(header->defaultSectionSize() * 0.75);

    // シグナル&スロット
    connect(ui->bootSize, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
    connect(ui->sizeAbsolute, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
    connect(ui->sizeRelative, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
    connect(ui->bootPos, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
    connect(ui->posAbsolute, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
    connect(ui->posRelative, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));

    connect(ui->boxClrBg, SIGNAL(clicked()), this, SLOT(selectBoxColor()));
    connect(ui->boxClrFg, SIGNAL(clicked()), this, SLOT(selectBoxColor()));
    connect(ui->chooseBoxFont, SIGNAL(clicked()), this, SLOT(chooseFont()));

    connect(ui->clrBgMark, SIGNAL(clicked()), this, SLOT(selectViewColor()));
    connect(ui->clrBgNormal, SIGNAL(clicked()), this, SLOT(selectViewColor()));
    connect(ui->clrFgHidden, SIGNAL(clicked()), this, SLOT(selectViewColor()));
    connect(ui->clrFgMark, SIGNAL(clicked()), this, SLOT(selectViewColor()));
    connect(ui->clrFgNormal, SIGNAL(clicked()), this, SLOT(selectViewColor()));
    connect(ui->clrFgReadonly, SIGNAL(clicked()), this, SLOT(selectViewColor()));
    connect(ui->clrFgSystem, SIGNAL(clicked()), this, SLOT(selectViewColor()));
    connect(ui->chooseViewFont, SIGNAL(clicked()), this, SLOT(chooseFont()));

    connect(ui->importAppearance, SIGNAL(clicked()), this, SLOT(importAppearance()));
    connect(ui->exportAppearance, SIGNAL(clicked()), this, SLOT(exportAppearance()));

    connect(ui->browseArchiver, SIGNAL(clicked()), this, SLOT(browseApp()));
    connect(ui->browseEditor, SIGNAL(clicked()), this, SLOT(browseApp()));
    connect(ui->browseTerminal, SIGNAL(clicked()), this, SLOT(browseApp()));

    connect(ui->chooseViewerFont, SIGNAL(clicked()), this, SLOT(chooseFont()));
    connect(ui->viewerClrBg, SIGNAL(clicked()), this, SLOT(selectViewerColor()));
    connect(ui->viewerClrFg, SIGNAL(clicked()), this, SLOT(selectViewerColor()));
    connect(ui->viewerInherit, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
    connect(ui->enableViewerIgnoreExt, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
    connect(ui->defaultIgnoreExt, SIGNAL(clicked()), this, SLOT(setIgnoreExtDefault()));

    // 現在の設定で各コントロールを初期化する
    QSettings settings;
    QString strValue;
    QSize size;
    QPoint point;
    QRadioButton *radioBtn;

    //>>>>> 起動と終了
    // 起動時のサイズ
    ui->bootSize->setChecked(true);
    strValue = settings.value(IniKey_BootSizeSpec).toString();
    radioBtn = findChild<QRadioButton*>(strValue);
    if (radioBtn == NULL) {
        radioBtn = ui->sizeRelative;
    }
    radioBtn->setChecked(true);
    if (strValue.isEmpty()) {
        ui->bootSize->setChecked(false);
    }
    size = settings.value(IniKey_BootSizeAbs).toSize();
    ui->absoluteWidth->setValue(size.width());
    ui->absoluteHeight->setValue(size.height());
    size = settings.value(IniKey_BootSizeRel).toSize();
    ui->relativeWidth->setValue(size.width());
    ui->relativeHeight->setValue(size.height());
    // 起動時の位置
    ui->bootPos->setChecked(true);
    strValue = settings.value(IniKey_BootPosSpec).toString();
    radioBtn = findChild<QRadioButton*>(strValue);
    if (radioBtn == NULL) {
        radioBtn = ui->posCenter;
    }
    radioBtn->setChecked(true);
    if (strValue.isEmpty()) {
        ui->bootPos->setChecked(false);
    }
    point = settings.value(IniKey_BootPosAbs).toPoint();
    ui->absoluteLeft->setValue(point.x());
    ui->absoluteTop->setValue(point.y());
    point = settings.value(IniKey_BootPosRel).toPoint();
    ui->relativeLeft->setValue(point.x());
    ui->relativeTop->setValue(point.y());
    // 起動時の設定削除
    ui->resetOnBoot->setChecked(settings.value(IniKey_ResetOnBoot).toBool());
    // アップデートの確認
    ui->checkUpdates->setChecked(settings.value(IniKey_CheckUpdates).toBool());
    // 終了時の確認ダイアログ
    ui->confirmExit->setChecked(settings.value(IniKey_ConfirmExit).toBool());

    //>>>>> 色とフォント、テキストビューア
    loadAppearance(settings, false);
    ui->dark->setValue(settings.value(IniKey_Darkness).toInt());

    //>>>>> ファイル操作
    // 確認ダイアログの表示
    ui->confirmCopy->setChecked(settings.value(IniKey_ConfirmCopy).toBool());
    ui->confirmDelete->setChecked(settings.value(IniKey_ConfirmDelete).toBool());
    ui->confirmMove->setChecked(settings.value(IniKey_ConfirmMove).toBool());
    ui->confirmRename->setChecked(settings.value(IniKey_ConfirmRename).toBool());
    // 完了ダイアログの自動クローズ
    ui->autoCloseCopy->setChecked(settings.value(IniKey_AutoCloseCopy).toBool());
    ui->autoCloseDelete->setChecked(settings.value(IniKey_AutoCloseDelete).toBool());
    ui->autoCloseMove->setChecked(settings.value(IniKey_AutoCloseMove).toBool());
    ui->autoCloseRename->setChecked(settings.value(IniKey_AutoCloseRename).toBool());
    // 上書き時の既定動作
    strValue = settings.value(IniKey_DefaultOnCopy).toString();
    if (strValue.isEmpty()) {
        strValue = "owDefIfNew";
    }
    radioBtn = findChild<QRadioButton*>(strValue);
    if (radioBtn == NULL) {
        radioBtn = ui->rbOverWriteIfNew;
    }
    radioBtn->setChecked(true);
    ui->moveAfterCreate->setChecked(settings.value(IniKey_MoveAfterCreateFolder).toBool());
    ui->openAfterCreate->setChecked(settings.value(IniKey_OpenAfterCreateFile).toBool());

    //>>>>> パス設定
    // エディタ
    ui->editorPath->setText(settings.value(IniKey_PathEditor).toString());
    // ターミナル
    ui->terminalPath->setText(settings.value(IniKey_PathTerminal).toString());
    // アーカイバ
    ui->archiverPath->setText(settings.value(IniKey_PathArchiver).toString());

    //>>>>> テキストビューア
    ui->enableViewerIgnoreExt->setChecked(true);
    ui->enableViewerIgnoreExt->setChecked(!settings.value(IniKey_ViewerForceOpen).toBool());
    ui->viewerIgnoreExt->setPlainText(settings.value(IniKey_ViewerIgnoreExt).toString());
}
Ejemplo n.º 12
0
void Situated::load(const Aurora::GFFStruct &instance, const Aurora::GFFStruct *blueprint) {
	// General properties

	if (blueprint)
		loadProperties(*blueprint); // Blueprint
	loadProperties(instance);    // Instance


	// Specialized object properties

	if (blueprint)
		loadObject(*blueprint); // Blueprint
	loadObject(instance);    // Instance


	// Appearance

	if (_appearanceID == Aurora::kFieldIDInvalid)
		throw Common::Exception("Situated object without an appearance");

	loadAppearance();
	loadSounds();


	// Position

	float posX = instance.getDouble("X");
	float posY = instance.getDouble("Y");
	float posZ = instance.getDouble("Z");

	if (instance.hasField("Position")) {
		const Aurora::GFFStruct &pos = instance.getStruct("Position");

		posX = pos.getDouble("x");
		posY = pos.getDouble("y");
		posZ = pos.getDouble("z");
	}

	setPosition(posX, posY, posZ);

	// Orientation

	float bearing = instance.getDouble("Bearing");

	float rotX = 0.0;
	float rotY = Common::rad2deg(bearing);
	float rotZ = 0.0;

	if (instance.hasField("Orientation")) {
		const Aurora::GFFStruct &o = instance.getStruct("Orientation");

		float oX = o.getDouble("x");
		float oY = o.getDouble("y");
		float oZ = o.getDouble("z");
		float oW = o.getDouble("w");

		// Convert quaternions to roll/pitch/yaw
		rotY = 180.0f - Common::rad2deg(atan2(2 * (oX*oY + oZ*oW), 1 - 2 * (oY*oY + oZ*oZ)));
		rotX = 180.0f - Common::rad2deg(asin(2 * (oX*oZ - oW*oY)));
		rotZ = Common::rad2deg(atan2(2 * (oX*oW + oY*oZ), 1 - 2 * (oZ*oZ + oW*oW)));
	}

	setOrientation(rotX, rotY, rotZ);
}