-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wheremyfoodat:master' into ui
- Loading branch information
Showing
13 changed files
with
190 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <QApplication> | ||
#include <QDialog> | ||
#include <QWidget> | ||
#include <string> | ||
|
||
#include "zep.h" | ||
#include "zep/mode_repl.h" | ||
#include "zep/regress.h" | ||
|
||
class TextEditorWindow : public QDialog { | ||
Q_OBJECT | ||
|
||
private: | ||
Zep::ZepWidget_Qt zepWidget; | ||
Zep::IZepReplProvider replProvider; | ||
static constexpr float fontSize = 14.0f; | ||
|
||
public: | ||
TextEditorWindow(QWidget* parent, const std::string& filename, const std::string& initialText); | ||
void setText(const std::string& text) { zepWidget.GetEditor().GetMRUBuffer()->SetText(text); } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "panda_qt/text_editor.hpp" | ||
|
||
#include <QPushButton> | ||
#include <QVBoxLayout> | ||
|
||
#include "panda_qt/main_window.hpp" | ||
|
||
using namespace Zep; | ||
|
||
TextEditorWindow::TextEditorWindow(QWidget* parent, const std::string& filename, const std::string& initialText) | ||
: QDialog(parent), zepWidget(this, qApp->applicationDirPath().toStdString(), fontSize) { | ||
resize(600, 600); | ||
|
||
// Register our extensions | ||
ZepRegressExCommand::Register(zepWidget.GetEditor()); | ||
ZepReplExCommand::Register(zepWidget.GetEditor(), &replProvider); | ||
|
||
// Default to standard mode instead of vim mode, initialize text box | ||
zepWidget.GetEditor().SetGlobalMode(Zep::ZepMode_Standard::StaticName()); | ||
zepWidget.GetEditor().InitWithText(filename, initialText); | ||
|
||
// Layout for widgets | ||
QVBoxLayout* mainLayout = new QVBoxLayout(); | ||
setLayout(mainLayout); | ||
|
||
QPushButton* button = new QPushButton(tr("Load script"), this); | ||
button->setFixedSize(100, 20); | ||
|
||
// When the Load Script button is pressed, send the current text to the MainWindow, which will upload it to the emulator's lua object | ||
connect(button, &QPushButton::pressed, this, [this]() { | ||
if (parentWidget()) { | ||
auto buffer = zepWidget.GetEditor().GetMRUBuffer(); | ||
const std::string text = buffer->GetBufferText(buffer->Begin(), buffer->End()); | ||
|
||
static_cast<MainWindow*>(parentWidget())->loadLuaScript(text); | ||
} else { | ||
// This should be unreachable, only here for safety purposes | ||
printf("Text editor does not have any parent widget, click doesn't work :(\n"); | ||
} | ||
}); | ||
|
||
mainLayout->addWidget(button); | ||
mainLayout->addWidget(&zepWidget); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#define ZEP_SINGLE_HEADER_BUILD | ||
#include "zep.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,4 @@ private Key(String name, T defaultValue) { | |
this.defaultValue = defaultValue; | ||
} | ||
} | ||
} | ||
} |