新增根据帧数控制可见性
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QFormLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QListWidget>
|
||||
@@ -55,6 +56,15 @@ EntityPropertySection::EntityPropertySection(QWidget* parent)
|
||||
m_userScale->setToolTip(QStringLiteral("人为整体缩放,与深度距离缩放相乘"));
|
||||
form->addRow(QStringLiteral("整体缩放"), m_userScale);
|
||||
|
||||
m_ignoreDistanceScale = new QCheckBox(QStringLiteral("不受距离缩放影响"), this);
|
||||
m_ignoreDistanceScale->setToolTip(QStringLiteral("开启后实体不受深度驱动的距离缩放影响,仅受整体缩放影响(对话气泡默认开启)"));
|
||||
form->addRow(QStringLiteral("距离缩放"), m_ignoreDistanceScale);
|
||||
|
||||
m_visible = new QCheckBox(QString(), this);
|
||||
m_visible->setChecked(true);
|
||||
m_visible->setToolTip(QStringLiteral("随帧变化:在当前帧切换会写入可见性关键帧(10帧淡入淡出)"));
|
||||
form->addRow(QStringLiteral("可见性"), m_visible);
|
||||
|
||||
lay->addLayout(form);
|
||||
|
||||
m_introHeader = new QWidget(this);
|
||||
@@ -133,6 +143,8 @@ EntityPropertySection::EntityPropertySection(QWidget* parent)
|
||||
connect(m_pivot, &Vec2ParamControl::valueChanged, this, &EntityPropertySection::pivotEdited);
|
||||
connect(m_centroid, &Vec2ParamControl::valueChanged, this, &EntityPropertySection::centroidEdited);
|
||||
connect(m_userScale, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &EntityPropertySection::userScaleEdited);
|
||||
connect(m_ignoreDistanceScale, &QCheckBox::toggled, this, &EntityPropertySection::ignoreDistanceScaleToggled);
|
||||
connect(m_visible, &QCheckBox::toggled, this, &EntityPropertySection::visibleToggled);
|
||||
|
||||
connect(m_introTitle, &QLineEdit::textChanged, this, [this](const QString&) { scheduleIntroPersist(); });
|
||||
connect(m_introBody, &QTextEdit::textChanged, this, [this]() { scheduleIntroPersist(); });
|
||||
@@ -183,6 +195,16 @@ void EntityPropertySection::clearDisconnected() {
|
||||
m_userScale->setValue(1.0);
|
||||
m_userScale->blockSignals(false);
|
||||
}
|
||||
if (m_ignoreDistanceScale) {
|
||||
m_ignoreDistanceScale->blockSignals(true);
|
||||
m_ignoreDistanceScale->setChecked(false);
|
||||
m_ignoreDistanceScale->blockSignals(false);
|
||||
}
|
||||
if (m_visible) {
|
||||
m_visible->blockSignals(true);
|
||||
m_visible->setChecked(true);
|
||||
m_visible->blockSignals(false);
|
||||
}
|
||||
if (m_introTitle) {
|
||||
m_introTitle->blockSignals(true);
|
||||
m_introTitle->clear();
|
||||
@@ -224,6 +246,16 @@ void EntityPropertySection::applyState(const EntityPropertyUiState& s) {
|
||||
m_userScale->setValue(s.userScale);
|
||||
m_userScale->blockSignals(false);
|
||||
}
|
||||
if (m_ignoreDistanceScale) {
|
||||
m_ignoreDistanceScale->blockSignals(true);
|
||||
m_ignoreDistanceScale->setChecked(s.ignoreDistanceScale);
|
||||
m_ignoreDistanceScale->blockSignals(false);
|
||||
}
|
||||
if (m_visible) {
|
||||
m_visible->blockSignals(true);
|
||||
m_visible->setChecked(s.visible);
|
||||
m_visible->blockSignals(false);
|
||||
}
|
||||
if (m_introTitle) {
|
||||
m_introTitle->blockSignals(true);
|
||||
m_introTitle->setText(s.intro.title);
|
||||
@@ -288,6 +320,8 @@ void EntityPropertySection::setEditingEnabled(bool on) {
|
||||
if (m_pivot) m_pivot->setEnabled(on);
|
||||
if (m_centroid) m_centroid->setEnabled(on);
|
||||
if (m_userScale) m_userScale->setEnabled(on);
|
||||
if (m_ignoreDistanceScale) m_ignoreDistanceScale->setEnabled(on);
|
||||
if (m_visible) m_visible->setEnabled(on);
|
||||
if (m_introHeader) m_introHeader->setEnabled(on);
|
||||
if (m_introToggle) m_introToggle->setEnabled(on);
|
||||
if (m_introTitle) m_introTitle->setEnabled(on);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QDoubleSpinBox;
|
||||
class QCheckBox;
|
||||
class QTextEdit;
|
||||
class QListWidget;
|
||||
class QPushButton;
|
||||
@@ -29,6 +30,8 @@ struct EntityPropertyUiState {
|
||||
QPointF pivot;
|
||||
QPointF centroid;
|
||||
double userScale = 1.0;
|
||||
bool ignoreDistanceScale = false;
|
||||
bool visible = true;
|
||||
core::EntityIntroContent intro;
|
||||
};
|
||||
|
||||
@@ -49,6 +52,9 @@ signals:
|
||||
void pivotEdited(double x, double y);
|
||||
void centroidEdited(double x, double y);
|
||||
void userScaleEdited(double value);
|
||||
void ignoreDistanceScaleToggled(bool on);
|
||||
// 可见性(动画通道):在当前帧写关键帧
|
||||
void visibleToggled(bool on);
|
||||
/// 介绍字段变更后防抖触发,由主窗口写入工程
|
||||
void introContentEdited();
|
||||
void introAddImageRequested();
|
||||
@@ -63,6 +69,8 @@ private:
|
||||
Vec2ParamControl* m_pivot = nullptr;
|
||||
Vec2ParamControl* m_centroid = nullptr;
|
||||
QDoubleSpinBox* m_userScale = nullptr;
|
||||
QCheckBox* m_ignoreDistanceScale = nullptr;
|
||||
QCheckBox* m_visible = nullptr;
|
||||
|
||||
QLineEdit* m_introTitle = nullptr;
|
||||
QTextEdit* m_introBody = nullptr;
|
||||
|
||||
130
client/gui/props/ToolPropertySection.cpp
Normal file
130
client/gui/props/ToolPropertySection.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
#include "props/ToolPropertySection.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QLineEdit>
|
||||
#include <QSlider>
|
||||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace gui {
|
||||
|
||||
ToolPropertySection::ToolPropertySection(QWidget* parent)
|
||||
: PropertySectionWidget(parent) {
|
||||
auto* lay = new QVBoxLayout(this);
|
||||
lay->setContentsMargins(0, 0, 0, 0);
|
||||
lay->setSpacing(6);
|
||||
|
||||
auto* form = new QFormLayout();
|
||||
form->setContentsMargins(0, 0, 0, 0);
|
||||
form->setSpacing(6);
|
||||
|
||||
m_text = new QLineEdit(this);
|
||||
m_text->setPlaceholderText(QStringLiteral("对话内容…"));
|
||||
form->addRow(QStringLiteral("文字"), m_text);
|
||||
|
||||
m_pointerT = new QSlider(Qt::Horizontal, this);
|
||||
m_pointerT->setRange(0, 1000);
|
||||
m_pointerT->setSingleStep(10);
|
||||
m_pointerT->setPageStep(50);
|
||||
m_pointerT->setValue(500);
|
||||
m_pointerT->setToolTip(QStringLiteral("发言实体位置"));
|
||||
form->addRow(QStringLiteral("指向"), m_pointerT);
|
||||
|
||||
m_fontPx = new QSpinBox(this);
|
||||
m_fontPx->setRange(8, 120);
|
||||
m_fontPx->setSingleStep(1);
|
||||
m_fontPx->setValue(18);
|
||||
form->addRow(QStringLiteral("字号"), m_fontPx);
|
||||
|
||||
m_align = new QComboBox(this);
|
||||
m_align->addItems({QStringLiteral("左对齐"), QStringLiteral("居中"), QStringLiteral("右对齐")});
|
||||
form->addRow(QStringLiteral("对齐"), m_align);
|
||||
|
||||
m_visible = new QCheckBox(QString(), this);
|
||||
m_visible->setChecked(true);
|
||||
m_visible->setToolTip(QStringLiteral("随帧变化:在当前帧切换会写入可见性关键帧(10帧淡入淡出)"));
|
||||
form->addRow(QStringLiteral("可见性"), m_visible);
|
||||
|
||||
lay->addLayout(form);
|
||||
lay->addStretch(1);
|
||||
|
||||
connect(m_text, &QLineEdit::editingFinished, this, [this]() {
|
||||
if (m_text) emit textCommitted(m_text->text());
|
||||
});
|
||||
connect(m_pointerT, &QSlider::valueChanged, this, &ToolPropertySection::pointerTChanged);
|
||||
connect(m_fontPx, qOverload<int>(&QSpinBox::valueChanged), this, &ToolPropertySection::fontPxChanged);
|
||||
connect(m_align, qOverload<int>(&QComboBox::currentIndexChanged), this, &ToolPropertySection::alignChanged);
|
||||
connect(m_visible, &QCheckBox::toggled, this, &ToolPropertySection::visibleToggled);
|
||||
}
|
||||
|
||||
void ToolPropertySection::setEditingEnabled(bool on) {
|
||||
for (auto* w : {static_cast<QWidget*>(m_text), static_cast<QWidget*>(m_pointerT),
|
||||
static_cast<QWidget*>(m_fontPx), static_cast<QWidget*>(m_align),
|
||||
static_cast<QWidget*>(m_visible)}) {
|
||||
if (w) w->setEnabled(on);
|
||||
}
|
||||
}
|
||||
|
||||
void ToolPropertySection::clearDisconnected() {
|
||||
setEditingEnabled(false);
|
||||
if (m_text) {
|
||||
m_text->blockSignals(true);
|
||||
m_text->clear();
|
||||
m_text->blockSignals(false);
|
||||
}
|
||||
if (m_pointerT) {
|
||||
m_pointerT->blockSignals(true);
|
||||
m_pointerT->setValue(500);
|
||||
m_pointerT->blockSignals(false);
|
||||
}
|
||||
if (m_fontPx) {
|
||||
m_fontPx->blockSignals(true);
|
||||
m_fontPx->setValue(18);
|
||||
m_fontPx->blockSignals(false);
|
||||
}
|
||||
if (m_align) {
|
||||
m_align->blockSignals(true);
|
||||
m_align->setCurrentIndex(1);
|
||||
m_align->blockSignals(false);
|
||||
}
|
||||
if (m_visible) {
|
||||
m_visible->blockSignals(true);
|
||||
m_visible->setChecked(true);
|
||||
m_visible->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ToolPropertySection::applyState(const ToolPropertyUiState& s) {
|
||||
setEditingEnabled(true);
|
||||
if (m_text) {
|
||||
m_text->blockSignals(true);
|
||||
m_text->setText(s.text);
|
||||
m_text->blockSignals(false);
|
||||
}
|
||||
if (m_pointerT) {
|
||||
m_pointerT->blockSignals(true);
|
||||
m_pointerT->setValue(std::clamp(s.pointerTThousandths, 0, 1000));
|
||||
m_pointerT->blockSignals(false);
|
||||
}
|
||||
if (m_fontPx) {
|
||||
m_fontPx->blockSignals(true);
|
||||
m_fontPx->setValue(std::clamp(s.fontPx, 8, 120));
|
||||
m_fontPx->blockSignals(false);
|
||||
}
|
||||
if (m_align) {
|
||||
m_align->blockSignals(true);
|
||||
m_align->setCurrentIndex(std::clamp(s.alignIndex, 0, 2));
|
||||
m_align->blockSignals(false);
|
||||
}
|
||||
if (m_visible) {
|
||||
m_visible->blockSignals(true);
|
||||
m_visible->setChecked(s.visible);
|
||||
m_visible->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gui
|
||||
50
client/gui/props/ToolPropertySection.h
Normal file
50
client/gui/props/ToolPropertySection.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include "props/PropertySectionWidget.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
class QSlider;
|
||||
class QSpinBox;
|
||||
class QCheckBox;
|
||||
|
||||
namespace gui {
|
||||
|
||||
struct ToolPropertyUiState {
|
||||
QString displayName;
|
||||
QString text;
|
||||
int pointerTThousandths = 500; // bubblePointerT01 * 1000,0=左 1000=右
|
||||
int fontPx = 18;
|
||||
int alignIndex = 1; // 0=left,1=center,2=right
|
||||
bool visible = true;
|
||||
};
|
||||
|
||||
class ToolPropertySection final : public PropertySectionWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ToolPropertySection(QWidget* parent = nullptr);
|
||||
|
||||
void clearDisconnected();
|
||||
void applyState(const ToolPropertyUiState& s);
|
||||
void setEditingEnabled(bool on);
|
||||
|
||||
signals:
|
||||
void textCommitted(const QString& text);
|
||||
void pointerTChanged(int thousandths);
|
||||
void fontPxChanged(int px);
|
||||
void alignChanged(int alignIndex);
|
||||
// 可见性(动画通道):在当前帧写关键帧
|
||||
void visibleToggled(bool on);
|
||||
|
||||
private:
|
||||
QLineEdit* m_text = nullptr;
|
||||
QSlider* m_pointerT = nullptr;
|
||||
QSpinBox* m_fontPx = nullptr;
|
||||
QComboBox* m_align = nullptr;
|
||||
QCheckBox* m_visible = nullptr;
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
Reference in New Issue
Block a user