Commit 6af9bdd4 authored by Victor Yacovlev's avatar Victor Yacovlev

Implemented Isometric Robot environment loading

parent 37af47a7
......@@ -20,6 +20,8 @@ IsometricRobotModule::IsometricRobotModule(ExtensionSystem::KPlugin * parent)
, window_(new Robot25DWindow(0))
, robotView_(window_->robotView())
{
connect(m_actionRobot25DLoadEnvironment, SIGNAL(triggered()),
window_, SLOT(handleLoadAction()));
}
QList<ExtensionSystem::CommandLineParameter> IsometricRobotModule::acceptableCommandLineParameters()
......
......@@ -34,6 +34,20 @@
"gui": {
"windows": [
{ "role": "main", "icon": "robot25d" }
],
"menus": [
{
"title": { "ascii": "Robot25D", "ru_RU": "Вертун" },
"items": [
{
"title": {
"ascii": "Load Environment...",
"ru_RU": "Загрузить обстановку..."
},
"icon": "file-open"
}
]
}
]
}
}
......@@ -160,35 +160,36 @@ void Robot25DWindow::loadEnvironment(const QString &fileName)
f.close();
Schema::Game g;
Schema::Task oneTask;
if (Schema::parceKumirFil(content, oneTask.environment)) {
if (Schema::parceJSON(content, oneTask.environment)) {
g.tasks.append(oneTask);
m_game = g;
setTaskIndex(0);
}
else {
// statusBar()->showMessage(QString::fromUtf8("Невозможно загрузить %1: это не обстановка Вертуна").arg(QFileInfo(fileName).fileName()));
const QString message =
QString::fromUtf8("Невозможно загрузить %1: это не обстановка Вертуна").arg(QFileInfo(fileName).fileName());
QMessageBox::critical(this, tr("Can't load environment"), message);
}
}
else {
// statusBar()->showMessage(QString::fromUtf8("Невозможно загрузить %1: файл не читается").arg(QFileInfo(fileName).fileName()));
const QString message =
QString::fromUtf8("Невозможно загрузить %1: файл не читается").arg(QFileInfo(fileName).fileName());
QMessageBox::critical(this, tr("Can't load environment"), message);
}
}
void Robot25DWindow::handleLoadAction()
{
QSettings s;
QString lastDir = s.value("Robot25D/LastDir", QApplication::applicationDirPath()+"/Addons/robot25d/resources/default.pm.json").toString();
QString lastDir = s.value("Robot25D/LastDir", QDir::currentPath()).toString();
const QString fileName = QFileDialog::getOpenFileName(this
, QString::fromUtf8("Загрузить обстановку")
, lastDir
, QString::fromUtf8("Все поддерживаемые файлы (*.pm.json *.fil);;(Игры ПиктоМир >= 0.12 (*.pm.json);;Отдельные обстановки (*.fil)")
, QString::fromUtf8("Обстановки вертуна (*.env.json)")
);
if (!fileName.isEmpty()) {
s.setValue("Robot25D/LastDir", fileName);
if (fileName.endsWith(".pm.json"))
loadGame(fileName);
else
loadEnvironment(fileName);
loadEnvironment(fileName);
}
}
......
......@@ -342,7 +342,8 @@ extern bool parceJSON(const QScriptValue &value, Environment &environment)
extern bool parceJSON(const QString &data, Environment &environment)
{
QScriptEngine engine;
QScriptValue value = engine.evaluate(data);
engine.evaluate("var data = " + data);
QScriptValue value = engine.evaluate("data");
if (value.isObject()) {
return parceJSON(value, environment);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment