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,10 +75,13 @@ public:
|
|||
{
|
||||
CScriptObject *pSender = mpArea->InstanceByID(mSenderID);
|
||||
|
||||
for (u32 iLink = 0; iLink < pSender->NumLinks(eOutgoing); iLink++)
|
||||
if (pSender)
|
||||
{
|
||||
if (pSender->Link(eOutgoing, iLink) == this)
|
||||
return iLink;
|
||||
for (u32 iLink = 0; iLink < pSender->NumLinks(eOutgoing); iLink++)
|
||||
{
|
||||
if (pSender->Link(eOutgoing, iLink) == this)
|
||||
return iLink;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -88,10 +91,13 @@ public:
|
|||
{
|
||||
CScriptObject *pReceiver = mpArea->InstanceByID(mReceiverID);
|
||||
|
||||
for (u32 iLink = 0; iLink < pReceiver->NumLinks(eIncoming); iLink++)
|
||||
if (pReceiver)
|
||||
{
|
||||
if (pReceiver->Link(eIncoming, iLink) == this)
|
||||
return iLink;
|
||||
for (u32 iLink = 0; iLink < pReceiver->NumLinks(eIncoming); iLink++)
|
||||
{
|
||||
if (pReceiver->Link(eIncoming, iLink) == this)
|
||||
return iLink;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
|
@ -193,14 +193,16 @@ void CScriptObject::BreakAllLinks()
|
|||
for (auto it = mInLinks.begin(); it != mInLinks.end(); it++)
|
||||
{
|
||||
CLink *pLink = *it;
|
||||
pLink->Sender()->RemoveLink(eOutgoing, pLink);
|
||||
CScriptObject *pSender = pLink->Sender();
|
||||
if (pSender) pSender->RemoveLink(eOutgoing, pLink);
|
||||
delete pLink;
|
||||
}
|
||||
|
||||
for (auto it = mOutLinks.begin(); it != mOutLinks.end(); it++)
|
||||
{
|
||||
CLink *pLink = *it;
|
||||
pLink->Receiver()->RemoveLink(eIncoming, pLink);
|
||||
CScriptObject *pReceiver = pLink->Receiver();
|
||||
if (pReceiver) pReceiver->RemoveLink(eIncoming, pLink);
|
||||
delete pLink;
|
||||
}
|
||||
|
||||
|
|
|
@ -280,6 +280,7 @@ void CScene::ClearScene()
|
|||
mNodes.clear();
|
||||
mAreaAttributesObjects.clear();
|
||||
mNodeMap.clear();
|
||||
mScriptMap.clear();
|
||||
mNumNodes = 0;
|
||||
|
||||
mpArea = nullptr;
|
||||
|
@ -335,7 +336,7 @@ CScriptNode* CScene::NodeForInstanceID(u32 InstanceID)
|
|||
|
||||
CScriptNode* CScene::NodeForInstance(CScriptObject *pObj)
|
||||
{
|
||||
return NodeForInstanceID(pObj->InstanceID());
|
||||
return (pObj ? NodeForInstanceID(pObj->InstanceID()) : nullptr);
|
||||
}
|
||||
|
||||
CLightNode* CScene::NodeForLight(CLight *pLight)
|
||||
|
|
|
@ -536,7 +536,7 @@ void CScriptNode::GeneratePosition()
|
|||
{
|
||||
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();
|
||||
mPosition = CVector3f(AreaTransform[0][3], AreaTransform[1][3], AreaTransform[2][3]);
|
||||
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.
|
||||
#define CONNECT_RELAY(Widget, Index, Signal) \
|
||||
{ \
|
||||
CPropertyRelay *pRelay = new CPropertyRelay(Widget, Index); \
|
||||
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*/)
|
||||
: QStyledItemDelegate(pParent)
|
||||
|
@ -57,7 +59,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
case eBoolProperty:
|
||||
{
|
||||
QCheckBox *pCheckBox = new QCheckBox(pParent);
|
||||
CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool));
|
||||
CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool))
|
||||
pOut = pCheckBox;
|
||||
break;
|
||||
}
|
||||
|
@ -68,7 +70,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
pSpinBox->setMinimum(INT16_MIN);
|
||||
pSpinBox->setMaximum(INT16_MAX);
|
||||
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int));
|
||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int))
|
||||
pOut = pSpinBox;
|
||||
break;
|
||||
}
|
||||
|
@ -79,7 +81,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
pSpinBox->setMinimum(INT32_MIN);
|
||||
pSpinBox->setMaximum(INT32_MAX);
|
||||
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int));
|
||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int))
|
||||
pOut = pSpinBox;
|
||||
break;
|
||||
}
|
||||
|
@ -89,7 +91,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
WDraggableSpinBox *pSpinBox = new WDraggableSpinBox(pParent);
|
||||
pSpinBox->setSingleStep(0.1);
|
||||
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(double));
|
||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(double))
|
||||
pOut = pSpinBox;
|
||||
break;
|
||||
}
|
||||
|
@ -97,7 +99,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
case eColorProperty:
|
||||
{
|
||||
WColorPicker *pColorPicker = new WColorPicker(pParent);
|
||||
CONNECT_RELAY(pColorPicker, rkIndex, ColorChanged(QColor));
|
||||
CONNECT_RELAY(pColorPicker, rkIndex, ColorChanged(QColor))
|
||||
pOut = pColorPicker;
|
||||
break;
|
||||
}
|
||||
|
@ -105,7 +107,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
case eStringProperty:
|
||||
{
|
||||
QLineEdit *pLineEdit = new QLineEdit(pParent);
|
||||
CONNECT_RELAY(pLineEdit, rkIndex, textEdited(QString));
|
||||
CONNECT_RELAY(pLineEdit, rkIndex, textEdited(QString))
|
||||
pOut = pLineEdit;
|
||||
break;
|
||||
}
|
||||
|
@ -119,7 +121,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
for (u32 iEnum = 0; iEnum < pTemp->NumEnumerators(); iEnum++)
|
||||
pComboBox->addItem(TO_QSTRING(pTemp->EnumeratorName(iEnum)));
|
||||
|
||||
CONNECT_RELAY(pComboBox, rkIndex, currentIndexChanged(int));
|
||||
CONNECT_RELAY(pComboBox, rkIndex, currentIndexChanged(int))
|
||||
pOut = pComboBox;
|
||||
break;
|
||||
}
|
||||
|
@ -131,7 +133,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
pSelector->SetAllowedExtensions(pTemp->Extensions());
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -162,7 +164,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
else if (pProp->Type() == eBitfieldProperty)
|
||||
{
|
||||
QCheckBox *pCheckBox = new QCheckBox(pParent);
|
||||
CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool));
|
||||
CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool))
|
||||
pOut = pCheckBox;
|
||||
}
|
||||
|
||||
|
@ -181,7 +183,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||
pSpinBox->setMaximum(1.0);
|
||||
}
|
||||
|
||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(double));
|
||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(double))
|
||||
pOut = pSpinBox;
|
||||
}
|
||||
}
|
||||
|
@ -530,13 +532,13 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
|
|||
// Check for edit in progress
|
||||
bool Matches = pOldValue->Matches(pProp->RawValue());
|
||||
|
||||
if (!Matches && mInRelayWidgetEdit && pEditor->hasFocus())
|
||||
if (!Matches && mInRelayWidgetEdit && (pEditor->hasFocus() || pProp->Type() == eColorProperty))
|
||||
mEditInProgress = true;
|
||||
|
||||
bool EditInProgress = mEditInProgress;
|
||||
|
||||
// Check for edit finished
|
||||
if (!mInRelayWidgetEdit || !pEditor->hasFocus())
|
||||
if (!mInRelayWidgetEdit || (!pEditor->hasFocus() && pProp->Type() != eColorProperty))
|
||||
mEditInProgress = false;
|
||||
|
||||
// Create undo command
|
||||
|
|
|
@ -72,6 +72,8 @@ CDeleteSelectionCommand::CDeleteSelectionCommand(CWorldEditor *pEditor, const QS
|
|||
}
|
||||
|
||||
// Remove selected objects from the linked instances list.
|
||||
LinkedInstances.removeAll(nullptr);
|
||||
|
||||
foreach (CScriptObject *pInst, LinkedInstances)
|
||||
{
|
||||
if (mpEditor->Scene()->NodeForInstance(pInst)->IsSelected())
|
||||
|
@ -117,7 +119,7 @@ void CDeleteSelectionCommand::undo()
|
|||
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.
|
||||
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);
|
||||
rLink.pSender->AddLink(eOutgoing, pLink, rLink.SenderIndex);
|
||||
|
@ -132,8 +134,12 @@ void CDeleteSelectionCommand::undo()
|
|||
for (int iLink = 0; iLink < mDeletedLinks.size(); iLink++)
|
||||
{
|
||||
SDeletedLink& rLink = mDeletedLinks[iLink];
|
||||
CLink *pLink = rLink.pSender->Link(eOutgoing, rLink.SenderIndex);
|
||||
rLink.pReceiver->AddLink(eIncoming, pLink, rLink.ReceiverIndex);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Run OnLoadFinished
|
||||
|
|
|
@ -62,15 +62,19 @@ void WColorPicker::mouseReleaseEvent(QMouseEvent *pEvent)
|
|||
{
|
||||
if ((pEvent->x() < width()) && (pEvent->y() < height()))
|
||||
{
|
||||
QColorDialog ColorPick;
|
||||
mOldColor = mColor;
|
||||
|
||||
QColorDialog ColorPick(this);
|
||||
ColorPick.setOptions(QColorDialog::ShowAlphaChannel);
|
||||
ColorPick.setCurrentColor(mColor);
|
||||
connect(&ColorPick, SIGNAL(currentColorChanged(QColor)), this, SLOT(DialogColorChanged(QColor)));
|
||||
connect(&ColorPick, SIGNAL(rejected()), this, SLOT(DialogRejected()));
|
||||
int Result = ColorPick.exec();
|
||||
|
||||
if (Result)
|
||||
{
|
||||
mColor = ColorPick.currentColor();
|
||||
emit ColorChanged(mColor);
|
||||
emit ColorEditComplete(mColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +89,19 @@ void WColorPicker::SetColor(QColor Color)
|
|||
if (mColor != Color)
|
||||
{
|
||||
mColor = Color;
|
||||
emit ColorChanged(mColor);
|
||||
emit ColorEditComplete(mColor);
|
||||
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
|
||||
QColor mColor;
|
||||
QColor mOldColor;
|
||||
|
||||
public:
|
||||
explicit WColorPicker(QWidget *pParent = 0);
|
||||
|
@ -20,8 +21,11 @@ public:
|
|||
|
||||
signals:
|
||||
void ColorChanged(QColor NewColor);
|
||||
void ColorEditComplete(QColor NewColor);
|
||||
|
||||
public slots:
|
||||
private slots:
|
||||
void DialogColorChanged(QColor NewColor);
|
||||
void DialogRejected();
|
||||
};
|
||||
|
||||
#endif // WCOLORPICKER_H
|
||||
|
|
|
@ -59,9 +59,9 @@ QVariant CLinkModel::data(const QModelIndex& rkIndex, int Role) const
|
|||
|
||||
else
|
||||
{
|
||||
QString strID = QString::number(TargetID, 16);
|
||||
while (strID.length() < 8) strID = "0" + strID;
|
||||
return QString("External: 0x") + strID;
|
||||
QString StrID = QString::number(TargetID, 16).toUpper();
|
||||
while (StrID.length() < 8) StrID = "0" + StrID;
|
||||
return QString("External: ") + StrID;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue