72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
#include "storypresent.h"
|
||
#include "dag_layout.h"
|
||
#include "xast_parse.h"
|
||
#include "dag_present.h"
|
||
#include "cmp_present.h"
|
||
#include <argsparser.h>
|
||
#include "storypresent.h"
|
||
#include <QDebug>
|
||
#include <QMessageBox>
|
||
#include <QTextEdit>
|
||
#include <QtWidgets/QApplication>
|
||
|
||
|
||
using namespace args_parse;
|
||
using namespace std;
|
||
|
||
|
||
int main(int argc, char* argv[]) {
|
||
QApplication a(argc, argv);
|
||
|
||
ArgsParser cmdrec;
|
||
auto help_mode = std::make_shared<MatchMode>(0x000au, u8"打印帮助文档");
|
||
cmdrec << help_mode;
|
||
(*help_mode) << std::make_shared<IndexParam>(u8"StoryPresent", u8"程序名") << make_shared<FloatOption>(u8"help", u8"打印帮助文档");
|
||
|
||
auto test_mode = std::make_shared<MatchMode>(0x000bu, u8"开发过程内部测试");
|
||
cmdrec << test_mode;
|
||
(*test_mode) << std::make_shared<IndexParam>(u8"StoryPresent", u8"程序名") << make_shared<FloatOption>(u8"test", u8"内部开发测试选项");
|
||
|
||
auto graph_mode = std::make_shared<MatchMode>(0x000cu, u8"图形化展示故事内容");
|
||
cmdrec << graph_mode;
|
||
(*graph_mode) << std::make_shared<IndexParam>(u8"StoryPresent", u8"程序名")
|
||
<< make_shared<FloatKeyValue>(u8"graph", u8"内部开发测试选项,填写dag或udg")
|
||
<< make_shared<FloatKeyValue>(u8"path", u8"指定xast文件路径");
|
||
|
||
auto rst = cmdrec.parse(argc, argv);
|
||
QTextEdit msg;
|
||
msg.setReadOnly(true);
|
||
if (!rst) {
|
||
msg.setWindowTitle(u8"参数输入错误");
|
||
msg.setPlainText(cmdrec.helperDoc());
|
||
msg.show();
|
||
}
|
||
else {
|
||
switch (rst->modeCode()) {
|
||
case 0x000au:
|
||
msg.setWindowTitle(u8"帮助信息");
|
||
msg.setPlainText(cmdrec.helperDoc());
|
||
msg.show();
|
||
break;
|
||
|
||
case 0x000bu:
|
||
{
|
||
}break;
|
||
case 0x000cu:
|
||
{
|
||
auto type = rst->getUnitViaKey(u8"graph");
|
||
auto path = rst->getUnitViaKey(u8"path");
|
||
if (type->value().toString() == "dag") {
|
||
auto view = new StoryPresent();
|
||
view->loadXAST(path->value().toString());
|
||
view->show();
|
||
}
|
||
}break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
return a.exec();
|
||
}
|