1 /* 2 * Copyright (C) 2006-2019 Christopho, Solarus - http://www.solarus-games.org 3 * 4 * Solarus Quest Editor is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * Solarus Quest Editor is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License along 15 * with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 #ifndef SOLARUS_GUI_QUEST_RUNNER_H 18 #define SOLARUS_GUI_QUEST_RUNNER_H 19 20 #include "solarus/gui/gui_common.h" 21 #include <QProcess> 22 23 namespace SolarusGui { 24 25 /** 26 * @brief Class to run a quest in a dedicated process. 27 */ 28 class SOLARUS_GUI_API QuestRunner : public QObject { 29 Q_OBJECT 30 31 public: 32 33 QuestRunner(QObject* parent = nullptr); 34 ~QuestRunner(); 35 36 bool is_started() const; 37 bool is_running() const; 38 int execute_command(const QString& command); 39 bool apply_settings(); 40 41 public slots: 42 43 void start(const QString& quest_path); 44 void stop(); 45 46 signals: 47 48 void running(); 49 void finished(); 50 void solarus_fatal(const QString& what); 51 void output_produced(const QStringList& lines); 52 53 private slots: 54 55 void standard_output_data_available(); 56 void on_finished(); 57 58 private: 59 60 QStringList create_arguments(const QString& quest_path) const; 61 QStringList get_quest_lua_commands_from_settings() const; 62 63 QProcess process; /**< The Solarus process. */ 64 int last_command_id; /**< Id of the last command executed (-1 if none). */ 65 }; 66 67 } 68 69 #endif 70