| 41 | std::atomic<int> revCount = 0; |
| 42 | |
| 43 | class Window : public QDialog, Localizer |
| 44 | { |
| 45 | public: |
| 46 | Window() : QDialog(nullptr, Qt::WindowMinMaxButtonsHint) |
| 47 | { |
| 48 | connect(&loadButton, &QPushButton::clicked, this, &Window::LoadScript); |
| 49 | |
| 50 | if (scriptEditor.toPlainText().isEmpty()) scriptEditor.setPlainText(LUA_INTRO); |
| 51 | layout.addWidget(&scriptEditor); |
| 52 | layout.addWidget(&loadButton); |
| 53 | |
| 54 | resize(800, 600); |
| 55 | setWindowTitle("Lua"); |
| 56 | QMetaObject::invokeMethod(this, &QWidget::show, Qt::QueuedConnection); |
| 57 | |
| 58 | LoadScript(); |
| 59 | } |
| 60 | |
| 61 | ~Window() |
| 62 | { |
| 63 | Save(); |
| 64 | } |
| 65 | |
| 66 | private: |
| 67 | void LoadScript() |
| 68 | { |
| 69 | revCount += 1; |
| 70 | script->assign(scriptEditor.toPlainText().toUtf8()); |
| 71 | Save(); |
| 72 | } |
| 73 | |
| 74 | void Save() |
| 75 | { |
| 76 | QTextFile(LUA_SAVE_FILE, QIODevice::WriteOnly | QIODevice::Truncate).write(scriptEditor.toPlainText().toUtf8()); |
| 77 | } |
| 78 | |
| 79 | QHBoxLayout layout{ this }; |
| 80 | QPlainTextEdit scriptEditor{ QTextFile(LUA_SAVE_FILE, QIODevice::ReadOnly).readAll(), this }; |
| 81 | QPushButton loadButton{ LOAD_SCRIPT, this }; |
| 82 | } window; |
| 83 | |
| 84 | bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) |
| 85 | { |