2012-11-22 12:30:02 +00:00
|
|
|
#ifndef CS_EDITOR_H
|
|
|
|
#define CS_EDITOR_H
|
|
|
|
|
2022-06-25 15:51:01 +00:00
|
|
|
#include <boost/program_options/variables_map.hpp>
|
2014-12-04 14:09:42 +00:00
|
|
|
|
2023-04-24 13:34:06 +00:00
|
|
|
#include <QLockFile>
|
2012-11-23 13:05:49 +00:00
|
|
|
#include <QObject>
|
2013-09-03 09:12:19 +00:00
|
|
|
#include <QString>
|
2013-09-03 06:44:21 +00:00
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <filesystem>
|
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
2013-03-31 16:00:46 +00:00
|
|
|
#ifndef Q_MOC_RUN
|
2013-03-07 02:00:59 +00:00
|
|
|
#include <components/files/configurationmanager.hpp>
|
2013-03-31 16:00:46 +00:00
|
|
|
#endif
|
2013-09-08 07:26:43 +00:00
|
|
|
|
2014-02-25 10:58:32 +00:00
|
|
|
#include <components/files/multidircollection.hpp>
|
|
|
|
|
2012-11-22 12:30:02 +00:00
|
|
|
#include "model/doc/documentmanager.hpp"
|
2015-12-06 10:18:31 +00:00
|
|
|
#include "model/prefs/state.hpp"
|
|
|
|
|
2013-03-07 02:00:59 +00:00
|
|
|
#include "view/doc/filedialog.hpp"
|
2013-09-08 10:06:28 +00:00
|
|
|
#include "view/doc/newgame.hpp"
|
2013-02-02 15:14:58 +00:00
|
|
|
#include "view/doc/startup.hpp"
|
2015-12-06 10:18:31 +00:00
|
|
|
#include "view/prefs/dialogue.hpp"
|
2015-08-06 10:52:10 +00:00
|
|
|
#include "view/tools/merge.hpp"
|
|
|
|
|
2022-10-09 10:39:43 +00:00
|
|
|
class QLocalServer;
|
|
|
|
class QLocalSocket;
|
|
|
|
|
2015-08-06 10:52:10 +00:00
|
|
|
namespace CSMDoc
|
|
|
|
{
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
2022-10-09 10:39:43 +00:00
|
|
|
namespace CSVDoc
|
|
|
|
{
|
|
|
|
class ViewManager;
|
|
|
|
}
|
|
|
|
|
2012-11-22 12:30:02 +00:00
|
|
|
namespace CS
|
|
|
|
{
|
2012-11-23 13:05:49 +00:00
|
|
|
class Editor : public QObject
|
2012-11-22 12:30:02 +00:00
|
|
|
{
|
2012-11-23 13:05:49 +00:00
|
|
|
Q_OBJECT
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-09-27 09:36:06 +00:00
|
|
|
Files::ConfigurationManager mCfgMgr;
|
2022-01-16 00:59:20 +00:00
|
|
|
boost::program_options::variables_map mConfigVariables;
|
2015-12-06 10:18:31 +00:00
|
|
|
CSMPrefs::State mSettingsState;
|
2012-11-22 12:30:02 +00:00
|
|
|
CSMDoc::DocumentManager mDocumentManager;
|
2013-02-02 15:14:58 +00:00
|
|
|
CSVDoc::StartupDialogue mStartup;
|
2013-09-08 10:06:28 +00:00
|
|
|
CSVDoc::NewGameDialogue mNewGame;
|
2015-12-06 10:18:31 +00:00
|
|
|
CSVPrefs::Dialogue mSettings;
|
2013-08-18 20:11:29 +00:00
|
|
|
CSVDoc::FileDialog mFileDialog;
|
2022-06-08 21:25:50 +00:00
|
|
|
std::filesystem::path mLocal;
|
|
|
|
std::filesystem::path mResources;
|
|
|
|
std::filesystem::path mPid;
|
2023-04-24 13:34:06 +00:00
|
|
|
QLockFile mLockFile;
|
2022-06-08 21:25:50 +00:00
|
|
|
std::ofstream mPidFile;
|
2014-03-09 11:32:21 +00:00
|
|
|
bool mFsStrict;
|
2015-08-06 10:52:10 +00:00
|
|
|
CSVTools::Merge mMerge;
|
2019-01-22 06:08:48 +00:00
|
|
|
CSVDoc::ViewManager* mViewManager;
|
2022-06-08 21:25:50 +00:00
|
|
|
std::filesystem::path mFileToLoad;
|
2019-07-02 16:07:38 +00:00
|
|
|
Files::PathContainer mDataDirs;
|
|
|
|
std::string mEncodingName;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2022-01-16 00:59:20 +00:00
|
|
|
boost::program_options::variables_map readConfiguration();
|
|
|
|
///< Calls mCfgMgr.readConfiguration; should be used before initialization of mSettingsState as it depends on
|
|
|
|
///< the configuration.
|
2015-06-16 02:48:45 +00:00
|
|
|
std::pair<Files::PathContainer, std::vector<std::string>> readConfig(bool quiet = false);
|
2014-02-25 10:58:32 +00:00
|
|
|
///< \return data paths
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2012-11-22 12:30:02 +00:00
|
|
|
// not implemented
|
|
|
|
Editor(const Editor&);
|
|
|
|
Editor& operator=(const Editor&);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2012-11-22 12:30:02 +00:00
|
|
|
public:
|
2018-07-05 20:55:19 +00:00
|
|
|
Editor(int argc, char** argv);
|
2014-10-14 20:02:19 +00:00
|
|
|
~Editor();
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-09-03 06:44:21 +00:00
|
|
|
bool makeIPCServer();
|
2013-09-03 09:12:19 +00:00
|
|
|
void connectToIPCServer();
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2012-11-22 12:30:02 +00:00
|
|
|
int run();
|
|
|
|
///< \return error status
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-02-02 15:14:58 +00:00
|
|
|
private slots:
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-09-08 10:06:28 +00:00
|
|
|
void createGame();
|
|
|
|
void createAddon();
|
2015-05-29 22:37:58 +00:00
|
|
|
void cancelCreateGame();
|
|
|
|
void cancelFileDialog();
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-02-02 15:14:58 +00:00
|
|
|
void loadDocument();
|
2022-07-02 22:02:29 +00:00
|
|
|
void openFiles(
|
|
|
|
const std::filesystem::path& path, const std::vector<std::filesystem::path>& discoveredFiles = {});
|
2022-06-08 21:25:50 +00:00
|
|
|
void createNewFile(const std::filesystem::path& path);
|
|
|
|
void createNewGame(const std::filesystem::path& file);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-09-03 09:12:19 +00:00
|
|
|
void showStartup();
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-09-08 07:26:43 +00:00
|
|
|
void showSettings();
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2014-04-21 07:02:58 +00:00
|
|
|
void documentAdded(CSMDoc::Document* document);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2015-08-06 10:52:10 +00:00
|
|
|
void documentAboutToBeRemoved(CSMDoc::Document* document);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2014-04-26 11:11:27 +00:00
|
|
|
void lastDocumentDeleted();
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2015-08-06 10:52:10 +00:00
|
|
|
void mergeDocument(CSMDoc::Document* document);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-09-03 06:44:21 +00:00
|
|
|
private:
|
2013-09-03 10:22:48 +00:00
|
|
|
QString mIpcServerName;
|
|
|
|
QLocalServer* mServer;
|
|
|
|
QLocalSocket* mClientSocket;
|
2012-11-22 12:30:02 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-03-07 02:00:59 +00:00
|
|
|
#endif
|