Color properties now update in realtime while the user is choosing a color from the color dialog; also some misc bugfixes
This commit is contained in:
parent
e461039882
commit
f9a2d019e1
|
@ -75,11 +75,14 @@ public:
|
||||||
{
|
{
|
||||||
CScriptObject *pSender = mpArea->InstanceByID(mSenderID);
|
CScriptObject *pSender = mpArea->InstanceByID(mSenderID);
|
||||||
|
|
||||||
|
if (pSender)
|
||||||
|
{
|
||||||
for (u32 iLink = 0; iLink < pSender->NumLinks(eOutgoing); iLink++)
|
for (u32 iLink = 0; iLink < pSender->NumLinks(eOutgoing); iLink++)
|
||||||
{
|
{
|
||||||
if (pSender->Link(eOutgoing, iLink) == this)
|
if (pSender->Link(eOutgoing, iLink) == this)
|
||||||
return iLink;
|
return iLink;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -88,11 +91,14 @@ public:
|
||||||
{
|
{
|
||||||
CScriptObject *pReceiver = mpArea->InstanceByID(mReceiverID);
|
CScriptObject *pReceiver = mpArea->InstanceByID(mReceiverID);
|
||||||
|
|
||||||
|
if (pReceiver)
|
||||||
|
{
|
||||||
for (u32 iLink = 0; iLink < pReceiver->NumLinks(eIncoming); iLink++)
|
for (u32 iLink = 0; iLink < pReceiver->NumLinks(eIncoming); iLink++)
|
||||||
{
|
{
|
||||||
if (pReceiver->Link(eIncoming, iLink) == this)
|
if (pReceiver->Link(eIncoming, iLink) == this)
|
||||||
return iLink;
|
return iLink;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,14 +193,16 @@ void CScriptObject::BreakAllLinks()
|
||||||
for (auto it = mInLinks.begin(); it != mInLinks.end(); it++)
|
for (auto it = mInLinks.begin(); it != mInLinks.end(); it++)
|
||||||
{
|
{
|
||||||
CLink *pLink = *it;
|
CLink *pLink = *it;
|
||||||
pLink->Sender()->RemoveLink(eOutgoing, pLink);
|
CScriptObject *pSender = pLink->Sender();
|
||||||
|
if (pSender) pSender->RemoveLink(eOutgoing, pLink);
|
||||||
delete pLink;
|
delete pLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = mOutLinks.begin(); it != mOutLinks.end(); it++)
|
for (auto it = mOutLinks.begin(); it != mOutLinks.end(); it++)
|
||||||
{
|
{
|
||||||
CLink *pLink = *it;
|
CLink *pLink = *it;
|
||||||
pLink->Receiver()->RemoveLink(eIncoming, pLink);
|
CScriptObject *pReceiver = pLink->Receiver();
|
||||||
|
if (pReceiver) pReceiver->RemoveLink(eIncoming, pLink);
|
||||||
delete pLink;
|
delete pLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,6 +280,7 @@ void CScene::ClearScene()
|
||||||
mNodes.clear();
|
mNodes.clear();
|
||||||
mAreaAttributesObjects.clear();
|
mAreaAttributesObjects.clear();
|
||||||
mNodeMap.clear();
|
mNodeMap.clear();
|
||||||
|
mScriptMap.clear();
|
||||||
mNumNodes = 0;
|
mNumNodes = 0;
|
||||||
|
|
||||||
mpArea = nullptr;
|
mpArea = nullptr;
|
||||||
|
@ -335,7 +336,7 @@ CScriptNode* CScene::NodeForInstanceID(u32 InstanceID)
|
||||||
|
|
||||||
CScriptNode* CScene::NodeForInstance(CScriptObject *pObj)
|
CScriptNode* CScene::NodeForInstance(CScriptObject *pObj)
|
||||||
{
|
{
|
||||||
return NodeForInstanceID(pObj->InstanceID());
|
return (pObj ? NodeForInstanceID(pObj->InstanceID()) : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLightNode* CScene::NodeForLight(CLight *pLight)
|
CLightNode* CScene::NodeForLight(CLight *pLight)
|
||||||
|
|
|
@ -536,7 +536,7 @@ void CScriptNode::GeneratePosition()
|
||||||
{
|
{
|
||||||
if (!mHasValidPosition)
|
if (!mHasValidPosition)
|
||||||
{
|
{
|
||||||
// Default to center of the active area; this is to preven recursion issues
|
// Default to center of the active area; this is to prevent recursion issues
|
||||||
CTransform4f& AreaTransform = mpScene->ActiveArea()->Transform();
|
CTransform4f& AreaTransform = mpScene->ActiveArea()->Transform();
|
||||||
mPosition = CVector3f(AreaTransform[0][3], AreaTransform[1][3], AreaTransform[2][3]);
|
mPosition = CVector3f(AreaTransform[0][3], AreaTransform[1][3], AreaTransform[2][3]);
|
||||||
mHasValidPosition = true;
|
mHasValidPosition = true;
|
||||||
|
|
|
@ -19,9 +19,11 @@
|
||||||
|
|
||||||
// This macro should be used on every widget where changes should be reflected in realtime and not just when the edit is finished.
|
// This macro should be used on every widget where changes should be reflected in realtime and not just when the edit is finished.
|
||||||
#define CONNECT_RELAY(Widget, Index, Signal) \
|
#define CONNECT_RELAY(Widget, Index, Signal) \
|
||||||
|
{ \
|
||||||
CPropertyRelay *pRelay = new CPropertyRelay(Widget, Index); \
|
CPropertyRelay *pRelay = new CPropertyRelay(Widget, Index); \
|
||||||
connect(Widget, SIGNAL(Signal), pRelay, SLOT(OnWidgetEdited())); \
|
connect(Widget, SIGNAL(Signal), pRelay, SLOT(OnWidgetEdited())); \
|
||||||
connect(pRelay, SIGNAL(WidgetEdited(QWidget*, const QModelIndex&)), this, SLOT(WidgetEdited(QWidget*, const QModelIndex&)))
|
connect(pRelay, SIGNAL(WidgetEdited(QWidget*, const QModelIndex&)), this, SLOT(WidgetEdited(QWidget*, const QModelIndex&))); \
|
||||||
|
}
|
||||||
|
|
||||||
CPropertyDelegate::CPropertyDelegate(QObject *pParent /*= 0*/)
|
CPropertyDelegate::CPropertyDelegate(QObject *pParent /*= 0*/)
|
||||||
: QStyledItemDelegate(pParent)
|
: QStyledItemDelegate(pParent)
|
||||||
|
@ -57,7 +59,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
||||||
case eBoolProperty:
|
case eBoolProperty:
|
||||||
{
|
{
|
||||||
QCheckBox *pCheckBox = new QCheckBox(pParent);
|
QCheckBox *pCheckBox = new QCheckBox(pParent);
|
||||||
CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool));
|
CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool))
|
||||||
pOut = pCheckBox;
|
pOut = pCheckBox;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +70,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
||||||
pSpinBox->setMinimum(INT16_MIN);
|
pSpinBox->setMinimum(INT16_MIN);
|
||||||
pSpinBox->setMaximum(INT16_MAX);
|
pSpinBox->setMaximum(INT16_MAX);
|
||||||
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
||||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int));
|
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int))
|
||||||
pOut = pSpinBox;
|
pOut = pSpinBox;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +81,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
||||||
pSpinBox->setMinimum(INT32_MIN);
|
pSpinBox->setMinimum(INT32_MIN);
|
||||||
pSpinBox->setMaximum(INT32_MAX);
|
pSpinBox->setMaximum(INT32_MAX);
|
||||||
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
||||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int));
|
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int))
|
||||||
pOut = pSpinBox;
|
pOut = pSpinBox;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +91,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
||||||
WDraggableSpinBox *pSpinBox = new WDraggableSpinBox(pParent);
|
WDraggableSpinBox *pSpinBox = new WDraggableSpinBox(pParent);
|
||||||
pSpinBox->setSingleStep(0.1);
|
pSpinBox->setSingleStep(0.1);
|
||||||
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
||||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(double));
|
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(double))
|
||||||
pOut = pSpinBox;
|
pOut = pSpinBox;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +99,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
||||||
case eColorProperty:
|
case eColorProperty:
|
||||||
{
|
{
|
||||||
WColorPicker *pColorPicker = new WColorPicker(pParent);
|
WColorPicker *pColorPicker = new WColorPicker(pParent);
|
||||||
CONNECT_RELAY(pColorPicker, rkIndex, ColorChanged(QColor));
|
CONNECT_RELAY(pColorPicker, rkIndex, ColorChanged(QColor))
|
||||||
pOut = pColorPicker;
|
pOut = pColorPicker;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +107,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
||||||
case eStringProperty:
|
case eStringProperty:
|
||||||
{
|
{
|
||||||
QLineEdit *pLineEdit = new QLineEdit(pParent);
|
QLineEdit *pLineEdit = new QLineEdit(pParent);
|
||||||
CONNECT_RELAY(pLineEdit, rkIndex, textEdited(QString));
|
CONNECT_RELAY(pLineEdit, rkIndex, textEdited(QString))
|
||||||
pOut = pLineEdit;
|
pOut = pLineEdit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +121,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
||||||
for (u32 iEnum = 0; iEnum < pTemp->NumEnumerators(); iEnum++)
|
for (u32 iEnum = 0; iEnum < pTemp->NumEnumerators(); iEnum++)
|
||||||
pComboBox->addItem(TO_QSTRING(pTemp->EnumeratorName(iEnum)));
|
pComboBox->addItem(TO_QSTRING(pTemp->EnumeratorName(iEnum)));
|
||||||
|
|
||||||
CONNECT_RELAY(pComboBox, rkIndex, currentIndexChanged(int));
|
CONNECT_RELAY(pComboBox, rkIndex, currentIndexChanged(int))
|
||||||
pOut = pComboBox;
|
pOut = pComboBox;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +133,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
||||||
pSelector->SetAllowedExtensions(pTemp->Extensions());
|
pSelector->SetAllowedExtensions(pTemp->Extensions());
|
||||||
pSelector->setFont(qobject_cast<QWidget*>(parent())->font()); // bit of a hack to stop the resource selector font from changing
|
pSelector->setFont(qobject_cast<QWidget*>(parent())->font()); // bit of a hack to stop the resource selector font from changing
|
||||||
|
|
||||||
CONNECT_RELAY(pSelector, rkIndex, ResourceChanged(QString));
|
CONNECT_RELAY(pSelector, rkIndex, ResourceChanged(QString))
|
||||||
pOut = pSelector;
|
pOut = pSelector;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +164,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
||||||
else if (pProp->Type() == eBitfieldProperty)
|
else if (pProp->Type() == eBitfieldProperty)
|
||||||
{
|
{
|
||||||
QCheckBox *pCheckBox = new QCheckBox(pParent);
|
QCheckBox *pCheckBox = new QCheckBox(pParent);
|
||||||
CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool));
|
CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool))
|
||||||
pOut = pCheckBox;
|
pOut = pCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +183,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
||||||
pSpinBox->setMaximum(1.0);
|
pSpinBox->setMaximum(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(double));
|
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(double))
|
||||||
pOut = pSpinBox;
|
pOut = pSpinBox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -530,13 +532,13 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
|
||||||
// Check for edit in progress
|
// Check for edit in progress
|
||||||
bool Matches = pOldValue->Matches(pProp->RawValue());
|
bool Matches = pOldValue->Matches(pProp->RawValue());
|
||||||
|
|
||||||
if (!Matches && mInRelayWidgetEdit && pEditor->hasFocus())
|
if (!Matches && mInRelayWidgetEdit && (pEditor->hasFocus() || pProp->Type() == eColorProperty))
|
||||||
mEditInProgress = true;
|
mEditInProgress = true;
|
||||||
|
|
||||||
bool EditInProgress = mEditInProgress;
|
bool EditInProgress = mEditInProgress;
|
||||||
|
|
||||||
// Check for edit finished
|
// Check for edit finished
|
||||||
if (!mInRelayWidgetEdit || !pEditor->hasFocus())
|
if (!mInRelayWidgetEdit || (!pEditor->hasFocus() && pProp->Type() != eColorProperty))
|
||||||
mEditInProgress = false;
|
mEditInProgress = false;
|
||||||
|
|
||||||
// Create undo command
|
// Create undo command
|
||||||
|
|
|
@ -72,6 +72,8 @@ CDeleteSelectionCommand::CDeleteSelectionCommand(CWorldEditor *pEditor, const QS
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove selected objects from the linked instances list.
|
// Remove selected objects from the linked instances list.
|
||||||
|
LinkedInstances.removeAll(nullptr);
|
||||||
|
|
||||||
foreach (CScriptObject *pInst, LinkedInstances)
|
foreach (CScriptObject *pInst, LinkedInstances)
|
||||||
{
|
{
|
||||||
if (mpEditor->Scene()->NodeForInstance(pInst)->IsSelected())
|
if (mpEditor->Scene()->NodeForInstance(pInst)->IsSelected())
|
||||||
|
@ -117,7 +119,7 @@ void CDeleteSelectionCommand::undo()
|
||||||
SDeletedLink& rLink = mDeletedLinks[iLink];
|
SDeletedLink& rLink = mDeletedLinks[iLink];
|
||||||
|
|
||||||
// Adding to the sender is only needed if the sender is not one of the nodes we just spawned. If it is, it already has this link.
|
// Adding to the sender is only needed if the sender is not one of the nodes we just spawned. If it is, it already has this link.
|
||||||
if (!NewInstanceIDs.contains(rLink.SenderID))
|
if (!NewInstanceIDs.contains(rLink.SenderID) && *rLink.pSender)
|
||||||
{
|
{
|
||||||
CLink *pLink = new CLink(rLink.pSender->Area(), rLink.State, rLink.Message, rLink.SenderID, rLink.ReceiverID);
|
CLink *pLink = new CLink(rLink.pSender->Area(), rLink.State, rLink.Message, rLink.SenderID, rLink.ReceiverID);
|
||||||
rLink.pSender->AddLink(eOutgoing, pLink, rLink.SenderIndex);
|
rLink.pSender->AddLink(eOutgoing, pLink, rLink.SenderIndex);
|
||||||
|
@ -132,9 +134,13 @@ void CDeleteSelectionCommand::undo()
|
||||||
for (int iLink = 0; iLink < mDeletedLinks.size(); iLink++)
|
for (int iLink = 0; iLink < mDeletedLinks.size(); iLink++)
|
||||||
{
|
{
|
||||||
SDeletedLink& rLink = mDeletedLinks[iLink];
|
SDeletedLink& rLink = mDeletedLinks[iLink];
|
||||||
CLink *pLink = rLink.pSender->Link(eOutgoing, rLink.SenderIndex);
|
|
||||||
|
if (*rLink.pReceiver)
|
||||||
|
{
|
||||||
|
CLink *pLink = (*rLink.pSender ? rLink.pSender->Link(eOutgoing, rLink.SenderIndex) : new CLink(rLink.pReceiver->Area(), rLink.State, rLink.Message, rLink.SenderID, rLink.ReceiverID));
|
||||||
rLink.pReceiver->AddLink(eIncoming, pLink, rLink.ReceiverIndex);
|
rLink.pReceiver->AddLink(eIncoming, pLink, rLink.ReceiverIndex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Run OnLoadFinished
|
// Run OnLoadFinished
|
||||||
foreach (CSceneNode *pNode, NewNodes)
|
foreach (CSceneNode *pNode, NewNodes)
|
||||||
|
|
|
@ -62,15 +62,19 @@ void WColorPicker::mouseReleaseEvent(QMouseEvent *pEvent)
|
||||||
{
|
{
|
||||||
if ((pEvent->x() < width()) && (pEvent->y() < height()))
|
if ((pEvent->x() < width()) && (pEvent->y() < height()))
|
||||||
{
|
{
|
||||||
QColorDialog ColorPick;
|
mOldColor = mColor;
|
||||||
|
|
||||||
|
QColorDialog ColorPick(this);
|
||||||
ColorPick.setOptions(QColorDialog::ShowAlphaChannel);
|
ColorPick.setOptions(QColorDialog::ShowAlphaChannel);
|
||||||
ColorPick.setCurrentColor(mColor);
|
ColorPick.setCurrentColor(mColor);
|
||||||
|
connect(&ColorPick, SIGNAL(currentColorChanged(QColor)), this, SLOT(DialogColorChanged(QColor)));
|
||||||
|
connect(&ColorPick, SIGNAL(rejected()), this, SLOT(DialogRejected()));
|
||||||
int Result = ColorPick.exec();
|
int Result = ColorPick.exec();
|
||||||
|
|
||||||
if (Result)
|
if (Result)
|
||||||
{
|
{
|
||||||
mColor = ColorPick.currentColor();
|
mColor = ColorPick.currentColor();
|
||||||
emit ColorChanged(mColor);
|
emit ColorEditComplete(mColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +89,19 @@ void WColorPicker::SetColor(QColor Color)
|
||||||
if (mColor != Color)
|
if (mColor != Color)
|
||||||
{
|
{
|
||||||
mColor = Color;
|
mColor = Color;
|
||||||
emit ColorChanged(mColor);
|
emit ColorEditComplete(mColor);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WColorPicker::DialogColorChanged(QColor NewColor)
|
||||||
|
{
|
||||||
|
mColor = NewColor;
|
||||||
|
emit ColorChanged(mColor);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WColorPicker::DialogRejected()
|
||||||
|
{
|
||||||
|
SetColor(mOldColor);
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ class WColorPicker : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QColor mColor;
|
QColor mColor;
|
||||||
|
QColor mOldColor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WColorPicker(QWidget *pParent = 0);
|
explicit WColorPicker(QWidget *pParent = 0);
|
||||||
|
@ -20,8 +21,11 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ColorChanged(QColor NewColor);
|
void ColorChanged(QColor NewColor);
|
||||||
|
void ColorEditComplete(QColor NewColor);
|
||||||
|
|
||||||
public slots:
|
private slots:
|
||||||
|
void DialogColorChanged(QColor NewColor);
|
||||||
|
void DialogRejected();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WCOLORPICKER_H
|
#endif // WCOLORPICKER_H
|
||||||
|
|
|
@ -59,9 +59,9 @@ QVariant CLinkModel::data(const QModelIndex& rkIndex, int Role) const
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString strID = QString::number(TargetID, 16);
|
QString StrID = QString::number(TargetID, 16).toUpper();
|
||||||
while (strID.length() < 8) strID = "0" + strID;
|
while (StrID.length() < 8) StrID = "0" + StrID;
|
||||||
return QString("External: 0x") + strID;
|
return QString("External: ") + StrID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue