feat(script): added source property
This commit is contained in:
parent
1858c703c7
commit
4cfb327b65
4 changed files with 27 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "script.h"
|
||||
#include "objects/base/instance.h"
|
||||
#include "objects/base/member.h"
|
||||
|
||||
const InstanceType Script::TYPE = {
|
||||
.super = &Instance::TYPE,
|
||||
|
@ -13,6 +14,17 @@ const InstanceType* Script::GetClass() {
|
|||
}
|
||||
|
||||
Script::Script(): Instance(&TYPE) {
|
||||
this->memberMap = std::make_unique<MemberMap>(MemberMap {
|
||||
.super = std::move(this->memberMap),
|
||||
.members = {
|
||||
{ "Source", {
|
||||
.backingField = &source,
|
||||
.type = &Data::String::TYPE,
|
||||
.codec = fieldCodecOf<Data::String, std::string>(),
|
||||
.flags = PROP_HIDDEN,
|
||||
}},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Script::~Script() {
|
||||
|
|
|
@ -10,6 +10,8 @@ public:
|
|||
Script();
|
||||
~Script();
|
||||
|
||||
std::string source;
|
||||
|
||||
static inline std::shared_ptr<Script> New() { return std::make_shared<Script>(); };
|
||||
static inline std::shared_ptr<Instance> Create() { return std::make_shared<Script>(); };
|
||||
virtual const InstanceType* GetClass() override;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "panes/propertiesview.h"
|
||||
#include "common.h"
|
||||
#include "datatypes/base.h"
|
||||
#include "objects/base/member.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
#include <QLineEdit>
|
||||
|
@ -296,7 +297,7 @@ void PropertiesView::setSelected(std::optional<InstanceRef> instance) {
|
|||
PropertyMeta meta = inst->GetPropertyMeta(property).expect();
|
||||
Data::Variant currentValue = inst->GetPropertyValue(property).expect();
|
||||
|
||||
// if (meta.type == &CFrame::TYPE) continue;
|
||||
if (meta.type == &CFrame::TYPE || meta.flags & PROP_HIDDEN) continue;
|
||||
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem;
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsSelectable);
|
||||
|
@ -311,9 +312,9 @@ void PropertiesView::setSelected(std::optional<InstanceRef> instance) {
|
|||
} else if (meta.type == &Vector3::TYPE) {
|
||||
Vector3 vector = currentValue.get<Vector3>();
|
||||
item->setData(1, Qt::DisplayRole, QString::fromStdString(currentValue.ToString()));
|
||||
} else if (meta.type == &CFrame::TYPE) {
|
||||
Vector3 vector = currentValue.get<CFrame>().Position();
|
||||
item->setData(1, Qt::DisplayRole, QString::fromStdString(currentValue.ToString()));
|
||||
// } else if (meta.type == &CFrame::TYPE) {
|
||||
// Vector3 vector = currentValue.get<CFrame>().Position();
|
||||
// item->setData(1, Qt::DisplayRole, QString::fromStdString(currentValue.ToString()));
|
||||
} else {
|
||||
item->setData(1, Qt::DisplayRole, QString::fromStdString(currentValue.ToString()));
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <Qsci/qscilexer.h>
|
||||
#include <qboxlayout.h>
|
||||
#include <qfont.h>
|
||||
#include <qdebug.h>
|
||||
#include <qglobal.h>
|
||||
#include <qlayout.h>
|
||||
#include "objects/script.h"
|
||||
|
||||
|
@ -35,6 +37,12 @@ ScriptDocument::ScriptDocument(std::shared_ptr<Script> script, QWidget* parent):
|
|||
scintilla->setFont(font);
|
||||
|
||||
scintilla->setLexer();
|
||||
|
||||
connect(scintilla, &QsciScintilla::textChanged, [this]() {
|
||||
// this-> is important here, as otherwise it will refer to the
|
||||
// parameter passed in, which will get gc'ed eventually
|
||||
this->script->source = scintilla->text().toStdString();
|
||||
});
|
||||
}
|
||||
|
||||
ScriptDocument::~ScriptDocument() {
|
||||
|
|
Loading…
Add table
Reference in a new issue