Added "add/edit link" dialog to the modify tab
This commit is contained in:
parent
2860c27d15
commit
984d9cf3f3
|
@ -115,7 +115,6 @@ HEADERS += \
|
|||
Resource/Script/CScriptTemplate.h \
|
||||
Resource/Script/EPropertyType.h \
|
||||
Resource/Script/EVolumeShape.h \
|
||||
Resource/Script/SConnection.h \
|
||||
Resource/CAnimationParameters.h \
|
||||
Resource/CAnimSet.h \
|
||||
Resource/CCollisionMesh.h \
|
||||
|
@ -186,7 +185,8 @@ HEADERS += \
|
|||
Resource/Cooker/CPoiToWorldCooker.h \
|
||||
Resource/Factory/CSectionMgrIn.h \
|
||||
Resource/Cooker/CScriptCooker.h \
|
||||
ScriptExtra/CSplinePathExtra.h
|
||||
ScriptExtra/CSplinePathExtra.h \
|
||||
Resource/Script/SLink.h
|
||||
|
||||
# Source Files
|
||||
SOURCES += \
|
||||
|
|
|
@ -150,23 +150,39 @@ void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster)
|
|||
}
|
||||
|
||||
// Write script states/messages
|
||||
std::map<u32, TString> *pMaps[2] = { &pMaster->mStates, &pMaster->mMessages };
|
||||
TString Types[2] = { "state", "message" };
|
||||
|
||||
for (u32 iScr = 0; iScr < 2; iScr++)
|
||||
for (u32 iType = 0; iType < 2; iType++)
|
||||
{
|
||||
XMLElement *pElem = Master.NewElement(*(Types[iScr] + "s"));
|
||||
TString Type = (iType == 0 ? "state" : "message");
|
||||
XMLElement *pElem = Master.NewElement(*(Type + "s"));
|
||||
pBase->LinkEndChild(pElem);
|
||||
|
||||
for (auto it = pMaps[iScr]->begin(); it != pMaps[iScr]->end(); it++)
|
||||
{
|
||||
TString ID;
|
||||
if (it->first <= 0xFF) ID = TString::HexString(it->first, true, true, 2);
|
||||
else ID = CFourCC(it->first).ToString();
|
||||
u32 Num = (iType == 0 ? pMaster->NumStates() : pMaster->NumMessages());
|
||||
|
||||
XMLElement *pSubElem = Master.NewElement(*Types[iScr]);
|
||||
pSubElem->SetAttribute("ID", *ID);
|
||||
pSubElem->SetAttribute("name", *(it->second));
|
||||
for (u32 iScr = 0; iScr < Num; iScr++)
|
||||
{
|
||||
u32 ID;
|
||||
TString Name;
|
||||
|
||||
if (iType == 0)
|
||||
{
|
||||
SState State = pMaster->StateByIndex(iScr);
|
||||
ID = State.ID;
|
||||
Name = State.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
SMessage Message = pMaster->MessageByIndex(iScr);
|
||||
ID = Message.ID;
|
||||
Name = Message.Name;
|
||||
}
|
||||
|
||||
TString StrID;
|
||||
if (ID <= 0xFF) StrID = TString::HexString(ID, true, true, 2);
|
||||
else StrID = CFourCC(ID).ToString();
|
||||
|
||||
XMLElement *pSubElem = Master.NewElement(*Type);
|
||||
pSubElem->SetAttribute("ID", *StrID);
|
||||
pSubElem->SetAttribute("name", *Name);
|
||||
pElem->LinkEndChild(pSubElem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define CAREALOADER_H
|
||||
|
||||
#include "CSectionMgrIn.h"
|
||||
#include "Core/Resource/Script/SConnection.h"
|
||||
#include "Core/Resource/Script/SLink.h"
|
||||
#include "Core/Resource/CGameArea.h"
|
||||
#include "Core/Resource/EGame.h"
|
||||
#include "Core/Resource/CResCache.h"
|
||||
|
|
|
@ -732,7 +732,7 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
|
|||
StateID = CFourCC(StrID).ToLong();
|
||||
|
||||
TString StateName = pState->Attribute("name");
|
||||
mpMaster->mStates[StateID] = StateName;
|
||||
mpMaster->mStates[StateID] = SState(StateID, StateName);
|
||||
pState = pState->NextSiblingElement("state");
|
||||
}
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
|
|||
MessageID = CFourCC(StrID).ToLong();
|
||||
|
||||
TString MessageName = pMessage->Attribute("name");
|
||||
mpMaster->mMessages[MessageID] = MessageName;
|
||||
mpMaster->mMessages[MessageID] = SMessage(MessageID, MessageName);
|
||||
pMessage = pMessage->NextSiblingElement("message");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,43 +57,43 @@ CScriptTemplate* CMasterTemplate::TemplateByIndex(u32 Index)
|
|||
return (std::next(it, Index))->second;
|
||||
}
|
||||
|
||||
TString CMasterTemplate::StateByID(u32 StateID)
|
||||
SState CMasterTemplate::StateByID(u32 StateID)
|
||||
{
|
||||
auto it = mStates.find(StateID);
|
||||
|
||||
if (it != mStates.end())
|
||||
return it->second;
|
||||
else
|
||||
return "Invalid";
|
||||
return SState(-1, "Invalid");
|
||||
}
|
||||
|
||||
TString CMasterTemplate::StateByID(const CFourCC& State)
|
||||
SState CMasterTemplate::StateByID(const CFourCC& State)
|
||||
{
|
||||
return StateByID(State.ToLong());
|
||||
}
|
||||
|
||||
TString CMasterTemplate::StateByIndex(u32 Index)
|
||||
SState CMasterTemplate::StateByIndex(u32 Index)
|
||||
{
|
||||
auto it = mStates.begin();
|
||||
return (std::next(it, Index))->second;
|
||||
}
|
||||
|
||||
TString CMasterTemplate::MessageByID(u32 MessageID)
|
||||
SMessage CMasterTemplate::MessageByID(u32 MessageID)
|
||||
{
|
||||
auto it = mMessages.find(MessageID);
|
||||
|
||||
if (it != mMessages.end())
|
||||
return it->second;
|
||||
else
|
||||
return "Invalid";
|
||||
return SMessage(-1, "Invalid");
|
||||
}
|
||||
|
||||
TString CMasterTemplate::MessageByID(const CFourCC& MessageID)
|
||||
SMessage CMasterTemplate::MessageByID(const CFourCC& MessageID)
|
||||
{
|
||||
return MessageByID(MessageID.ToLong());
|
||||
}
|
||||
|
||||
TString CMasterTemplate::MessageByIndex(u32 Index)
|
||||
SMessage CMasterTemplate::MessageByIndex(u32 Index)
|
||||
{
|
||||
auto it = mMessages.begin();
|
||||
return (std::next(it, Index))->second;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define CMASTERTEMPLATE_H
|
||||
|
||||
#include "CScriptTemplate.h"
|
||||
#include "SLink.h"
|
||||
#include "Core/Resource/EGame.h"
|
||||
#include <Common/types.h>
|
||||
#include <map>
|
||||
|
@ -21,8 +22,8 @@ class CMasterTemplate
|
|||
std::map<TString, CStructTemplate*> mStructTemplates;
|
||||
|
||||
std::map<u32, CScriptTemplate*> mTemplates;
|
||||
std::map<u32, TString> mStates;
|
||||
std::map<u32, TString> mMessages;
|
||||
std::map<u32, SState> mStates;
|
||||
std::map<u32, SMessage> mMessages;
|
||||
|
||||
struct SPropIDInfo
|
||||
{
|
||||
|
@ -46,12 +47,12 @@ public:
|
|||
CScriptTemplate* TemplateByID(u32 ObjectID);
|
||||
CScriptTemplate* TemplateByID(const CFourCC& ObjectID);
|
||||
CScriptTemplate* TemplateByIndex(u32 Index);
|
||||
TString StateByID(u32 StateID);
|
||||
TString StateByID(const CFourCC& StateID);
|
||||
TString StateByIndex(u32 Index);
|
||||
TString MessageByID(u32 MessageID);
|
||||
TString MessageByID(const CFourCC& MessageID);
|
||||
TString MessageByIndex(u32 Index);
|
||||
SState StateByID(u32 StateID);
|
||||
SState StateByID(const CFourCC& StateID);
|
||||
SState StateByIndex(u32 Index);
|
||||
SMessage MessageByID(u32 MessageID);
|
||||
SMessage MessageByID(const CFourCC& MessageID);
|
||||
SMessage MessageByIndex(u32 Index);
|
||||
TString GetDirectory() const;
|
||||
CStructTemplate* GetStructAtSource(const TString& rkSource);
|
||||
bool IsLoadedSuccessfully();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef CSCRIPTOBJECT_H
|
||||
#define CSCRIPTOBJECT_H
|
||||
|
||||
#include "SConnection.h"
|
||||
#include "SLink.h"
|
||||
#include "IProperty.h"
|
||||
#include "IPropertyTemplate.h"
|
||||
#include "CScriptTemplate.h"
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#ifndef SCONNECTION_H
|
||||
#define SCONNECTION_H
|
||||
|
||||
#include <Common/types.h>
|
||||
|
||||
struct SLink
|
||||
{
|
||||
u32 State;
|
||||
u32 Message;
|
||||
u32 ObjectID; // not a pointer because it can refer to objects outside the current area
|
||||
};
|
||||
|
||||
#endif // SCONNECTION_H
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef SLINK_H
|
||||
#define SLINK_H
|
||||
|
||||
#include <Common/TString.h>
|
||||
#include <Common/types.h>
|
||||
|
||||
struct SState
|
||||
{
|
||||
u32 ID;
|
||||
TString Name;
|
||||
|
||||
SState() {}
|
||||
SState(u32 _ID, const TString& rkName) : ID(_ID), Name(rkName) {}
|
||||
};
|
||||
|
||||
struct SMessage
|
||||
{
|
||||
u32 ID;
|
||||
TString Name;
|
||||
|
||||
SMessage() {}
|
||||
SMessage(u32 _ID, const TString& rkName) : ID(_ID), Name(rkName) {}
|
||||
};
|
||||
|
||||
struct SLink
|
||||
{
|
||||
u32 State;
|
||||
u32 Message;
|
||||
u32 ObjectID; // not a pointer because it can refer to objects outside the current area
|
||||
};
|
||||
|
||||
#endif // SLINK_H
|
|
@ -142,7 +142,10 @@ HEADERS += \
|
|||
Undo/IUndoCommand.h \
|
||||
WorldEditor/WEditorProperties.h \
|
||||
Undo/CChangeLayerCommand.h \
|
||||
WorldEditor/CTemplateEditDialog.h
|
||||
WorldEditor/CTemplateEditDialog.h \
|
||||
WorldEditor/CLinkDialog.h \
|
||||
WorldEditor/CStateMessageModel.h \
|
||||
WorldEditor/CSelectInstanceDialog.h
|
||||
|
||||
# Source Files
|
||||
SOURCES += \
|
||||
|
@ -199,7 +202,9 @@ SOURCES += \
|
|||
Undo/CBasicPropertyCommand.cpp \
|
||||
WorldEditor/WEditorProperties.cpp \
|
||||
Undo/CChangeLayerCommand.cpp \
|
||||
WorldEditor/CTemplateEditDialog.cpp
|
||||
WorldEditor/CTemplateEditDialog.cpp \
|
||||
WorldEditor/CLinkDialog.cpp \
|
||||
WorldEditor/CSelectInstanceDialog.cpp
|
||||
|
||||
# UI Files
|
||||
FORMS += \
|
||||
|
@ -216,4 +221,6 @@ FORMS += \
|
|||
WorldEditor/WModifyTab.ui \
|
||||
CErrorLogDialog.ui \
|
||||
WorldEditor/CPoiMapEditDialog.ui \
|
||||
WorldEditor/CTemplateEditDialog.ui
|
||||
WorldEditor/CTemplateEditDialog.ui \
|
||||
WorldEditor/CLinkDialog.ui \
|
||||
WorldEditor/CSelectInstanceDialog.ui
|
||||
|
|
|
@ -36,5 +36,9 @@
|
|||
<file>icons/Redo.png</file>
|
||||
<file>icons/Save.png</file>
|
||||
<file>icons/Undo.png</file>
|
||||
<file>icons/Instances_16px.png</file>
|
||||
<file>icons/SelectMode_16px.png</file>
|
||||
<file>icons/Swap_16px.png</file>
|
||||
<file>icons/Swap_24px.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -38,6 +38,7 @@ CInstancesModel::CInstancesModel(QObject *pParent) : QAbstractItemModel(pParent)
|
|||
mpArea = nullptr;
|
||||
mpCurrentMaster = nullptr;
|
||||
mModelType = eLayers;
|
||||
mShowColumnEnabled = true;
|
||||
mBaseItems << "Script";
|
||||
}
|
||||
|
||||
|
@ -199,7 +200,7 @@ int CInstancesModel::rowCount(const QModelIndex &parent) const
|
|||
|
||||
int CInstancesModel::columnCount(const QModelIndex& /*parent*/) const
|
||||
{
|
||||
return 3;
|
||||
return (mShowColumnEnabled ? 3 : 2);
|
||||
}
|
||||
|
||||
QVariant CInstancesModel::data(const QModelIndex &index, int role) const
|
||||
|
@ -340,6 +341,12 @@ void CInstancesModel::SetModelType(EInstanceModelType type)
|
|||
mModelType = type;
|
||||
}
|
||||
|
||||
void CInstancesModel::SetShowColumnEnabled(bool Enabled)
|
||||
{
|
||||
mShowColumnEnabled = Enabled;
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
void CInstancesModel::NodeCreated(CSceneNode *pNode)
|
||||
{
|
||||
if (mModelType == eTypes)
|
||||
|
|
|
@ -36,6 +36,7 @@ private:
|
|||
EInstanceModelType mModelType;
|
||||
QList<CScriptTemplate*> mTemplateList;
|
||||
QStringList mBaseItems;
|
||||
bool mShowColumnEnabled;
|
||||
|
||||
public:
|
||||
explicit CInstancesModel(QObject *pParent = 0);
|
||||
|
@ -46,10 +47,12 @@ public:
|
|||
int rowCount(const QModelIndex &parent) const;
|
||||
int columnCount(const QModelIndex &parent) const;
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
|
||||
void SetEditor(CWorldEditor *pEditor);
|
||||
void SetMaster(CMasterTemplate *pMaster);
|
||||
void SetArea(CGameArea *pArea);
|
||||
void SetModelType(EInstanceModelType type);
|
||||
void SetShowColumnEnabled(bool Enabled);
|
||||
void NodeCreated(CSceneNode *pNode);
|
||||
void NodeDeleted(CSceneNode *pNode);
|
||||
CScriptLayer* IndexLayer(const QModelIndex& index) const;
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
#include "CLinkDialog.h"
|
||||
#include "ui_CLinkDialog.h"
|
||||
#include "CSelectInstanceDialog.h"
|
||||
#include "CStateMessageModel.h"
|
||||
#include <Core/Resource/Script/CScriptObject.h>
|
||||
|
||||
CLinkDialog::CLinkDialog(CWorldEditor *pEditor, QWidget *pParent /*= 0*/)
|
||||
: QDialog(pParent)
|
||||
, ui(new Ui::CLinkDialog)
|
||||
, mpEditor(pEditor)
|
||||
, mpMaster(nullptr)
|
||||
, mpSender(nullptr)
|
||||
, mpReceiver(nullptr)
|
||||
, mSenderStateModel(CStateMessageModel::eStates, this)
|
||||
, mReceiverMessageModel(CStateMessageModel::eMessages, this)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->SenderStateComboBox->setModel(&mSenderStateModel);
|
||||
ui->ReceiverMessageComboBox->setModel(&mReceiverMessageModel);
|
||||
|
||||
connect(ui->SwapButton, SIGNAL(clicked()), this, SLOT(OnSwapClicked()));
|
||||
connect(ui->SenderPickFromViewport, SIGNAL(clicked()), this, SLOT(OnPickFromViewportClicked()));
|
||||
connect(ui->SenderPickFromList, SIGNAL(clicked()), this, SLOT(OnPickFromListClicked()));
|
||||
connect(ui->ReceiverPickFromViewport, SIGNAL(clicked()), this, SLOT(OnPickFromViewportClicked()));
|
||||
connect(ui->ReceiverPickFromList, SIGNAL(clicked()), this, SLOT(OnPickFromListClicked()));
|
||||
}
|
||||
|
||||
CLinkDialog::~CLinkDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CLinkDialog::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
SetSenderNameLabel();
|
||||
SetReceiverNameLabel();
|
||||
}
|
||||
|
||||
void CLinkDialog::showEvent(QShowEvent *)
|
||||
{
|
||||
// This is needed to get the labels to elide correctly when the window is first shown. It shouldn't be
|
||||
// needed because showing the window generates a resize event, but for some reason it is, so whatever.
|
||||
SetSenderNameLabel();
|
||||
SetReceiverNameLabel();
|
||||
}
|
||||
|
||||
void CLinkDialog::SetMaster(CMasterTemplate *pMaster)
|
||||
{
|
||||
if (mpMaster != pMaster)
|
||||
{
|
||||
mpMaster = pMaster;
|
||||
mSenderStateModel.SetMasterTemplate(pMaster);
|
||||
mReceiverMessageModel.SetMasterTemplate(pMaster);
|
||||
}
|
||||
}
|
||||
|
||||
void CLinkDialog::SetSender(CScriptObject *pSender)
|
||||
{
|
||||
bool HadSender = mpSender != nullptr;
|
||||
mpSender = pSender;
|
||||
mSenderStateModel.SetScriptTemplate(pSender ? pSender->Template() : nullptr);
|
||||
SetSenderNameLabel();
|
||||
|
||||
if (pSender)
|
||||
{
|
||||
if (!HadSender) ui->SenderStateComboBox->setCurrentIndex(0);
|
||||
ui->SenderStateComboBox->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->SenderStateComboBox->setCurrentIndex(-1);
|
||||
ui->SenderStateComboBox->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CLinkDialog::SetReceiver(CScriptObject *pReceiver)
|
||||
{
|
||||
bool HadReceiver = mpReceiver != nullptr;
|
||||
mpReceiver = pReceiver;
|
||||
mReceiverMessageModel.SetScriptTemplate(pReceiver ? pReceiver->Template() : nullptr);
|
||||
SetReceiverNameLabel();
|
||||
|
||||
if (pReceiver)
|
||||
{
|
||||
if (!HadReceiver) ui->ReceiverMessageComboBox->setCurrentIndex(0);
|
||||
ui->ReceiverMessageComboBox->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->ReceiverMessageComboBox->setCurrentIndex(-1);
|
||||
ui->ReceiverMessageComboBox->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
u32 CLinkDialog::State() const
|
||||
{
|
||||
return mSenderStateModel.State(ui->SenderStateComboBox->currentIndex());
|
||||
}
|
||||
|
||||
u32 CLinkDialog::Message() const
|
||||
{
|
||||
return mReceiverMessageModel.State(ui->ReceiverMessageComboBox->currentIndex());
|
||||
}
|
||||
|
||||
void CLinkDialog::SetSenderNameLabel()
|
||||
{
|
||||
QString Text = (mpSender ? TO_QSTRING(mpSender->InstanceName()) : "<i>No sender</i>");
|
||||
ui->SenderNameLabel->setToolTip(Text);
|
||||
|
||||
QFontMetrics Metrics(ui->SenderNameLabel->font());
|
||||
QString Elided = Metrics.elidedText(Text, Qt::ElideRight, ui->SenderNameLabel->width() - (ui->SenderNameLabel->frameWidth() * 2));
|
||||
ui->SenderNameLabel->setText(Elided);
|
||||
|
||||
ui->SenderGroupBox->setTitle(mpSender ? "Sender - " + TO_QSTRING(mpSender->Template()->Name()) : "Sender");
|
||||
}
|
||||
|
||||
void CLinkDialog::SetReceiverNameLabel()
|
||||
{
|
||||
QString Text = (mpReceiver ? TO_QSTRING(mpReceiver->InstanceName()) : "<i>No receiver</i>");
|
||||
ui->ReceiverNameLabel->setToolTip(Text);
|
||||
|
||||
QFontMetrics Metrics(ui->ReceiverNameLabel->font());
|
||||
QString Elided = Metrics.elidedText(Text, Qt::ElideRight, ui->ReceiverNameLabel->width() - (ui->ReceiverNameLabel->frameWidth() * 2));
|
||||
ui->ReceiverNameLabel->setText(Elided);
|
||||
|
||||
ui->ReceiverGroupBox->setTitle(mpReceiver ? "Receiver - " + TO_QSTRING(mpReceiver->Template()->Name()) : "Receiver");
|
||||
}
|
||||
|
||||
// ************ PUBLIC SLOTS ************
|
||||
void CLinkDialog::OnSwapClicked()
|
||||
{
|
||||
CScriptObject *pSender = mpReceiver;
|
||||
CScriptObject *pReceiver = mpSender;
|
||||
SetSender(pSender);
|
||||
SetReceiver(pReceiver);
|
||||
}
|
||||
|
||||
void CLinkDialog::OnPickFromViewportClicked()
|
||||
{
|
||||
QPushButton *pButton = qobject_cast<QPushButton*>(sender());
|
||||
|
||||
if (pButton && pButton->isChecked())
|
||||
{
|
||||
mpEditor->EnterPickMode(eScriptNode, true, false, false);
|
||||
connect(mpEditor, SIGNAL(PickModeClick(SRayIntersection,QMouseEvent*)), this, SLOT(OnPickModeClick(SRayIntersection,QMouseEvent*)));
|
||||
connect(mpEditor, SIGNAL(PickModeExited()), this, SLOT(OnPickModeExit()));
|
||||
|
||||
QPushButton *pOtherButton = (pButton == ui->SenderPickFromViewport ? ui->ReceiverPickFromViewport : ui->SenderPickFromViewport);
|
||||
pOtherButton->setChecked(false);
|
||||
}
|
||||
|
||||
else
|
||||
mpEditor->ExitPickMode();
|
||||
}
|
||||
|
||||
void CLinkDialog::OnPickModeClick(const SRayIntersection& rkHit, QMouseEvent* /*pEvent*/)
|
||||
{
|
||||
CScriptNode *pScript = static_cast<CScriptNode*>(rkHit.pNode);
|
||||
|
||||
if (ui->SenderPickFromViewport->isChecked())
|
||||
SetSender(pScript->Object());
|
||||
else
|
||||
SetReceiver(pScript->Object());
|
||||
|
||||
mpEditor->ExitPickMode();
|
||||
}
|
||||
|
||||
void CLinkDialog::OnPickModeExit()
|
||||
{
|
||||
ui->SenderPickFromViewport->setChecked(false);
|
||||
ui->ReceiverPickFromViewport->setChecked(false);
|
||||
disconnect(mpEditor, SIGNAL(PickModeClick(SRayIntersection,QMouseEvent*)), this, 0);
|
||||
disconnect(mpEditor, SIGNAL(PickModeExited()), this, 0);
|
||||
}
|
||||
|
||||
void CLinkDialog::OnPickFromListClicked()
|
||||
{
|
||||
CSelectInstanceDialog Dialog(mpEditor, this);
|
||||
Dialog.exec();
|
||||
CScriptObject *pResult = Dialog.SelectedInstance();
|
||||
|
||||
if (pResult)
|
||||
{
|
||||
if (sender() == ui->SenderPickFromList)
|
||||
SetSender(pResult);
|
||||
else
|
||||
SetReceiver(pResult);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef CLINKDIALOG_H
|
||||
#define CLINKDIALOG_H
|
||||
|
||||
#include "CStateMessageModel.h"
|
||||
#include "CWorldEditor.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class CLinkDialog;
|
||||
}
|
||||
|
||||
class CLinkDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
CWorldEditor *mpEditor;
|
||||
CMasterTemplate *mpMaster;
|
||||
CScriptObject *mpSender;
|
||||
CScriptObject *mpReceiver;
|
||||
|
||||
CStateMessageModel mSenderStateModel;
|
||||
CStateMessageModel mReceiverMessageModel;
|
||||
|
||||
Ui::CLinkDialog *ui;
|
||||
|
||||
public:
|
||||
explicit CLinkDialog(CWorldEditor *pEditor, QWidget *parent = 0);
|
||||
~CLinkDialog();
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void showEvent(QShowEvent *);
|
||||
|
||||
void SetMaster(CMasterTemplate *pMaster);
|
||||
void SetSender(CScriptObject *pSender);
|
||||
void SetReceiver(CScriptObject *pReceiver);
|
||||
u32 State() const;
|
||||
u32 Message() const;
|
||||
|
||||
void SetSenderNameLabel();
|
||||
void SetReceiverNameLabel();
|
||||
|
||||
inline CScriptObject* Sender() const { return mpSender; }
|
||||
inline CScriptObject* Receiver() const { return mpReceiver; }
|
||||
|
||||
public slots:
|
||||
void OnSwapClicked();
|
||||
void OnPickFromViewportClicked();
|
||||
void OnPickModeClick(const SRayIntersection& rkHit, QMouseEvent *pEvent);
|
||||
void OnPickModeExit();
|
||||
void OnPickFromListClicked();
|
||||
};
|
||||
|
||||
#endif // CLINKDIALOG_H
|
|
@ -0,0 +1,277 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CLinkDialog</class>
|
||||
<widget class="QDialog" name="CLinkDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>622</width>
|
||||
<height>134</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create Link</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="SenderGroupBox">
|
||||
<property name="title">
|
||||
<string>Sender</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="SenderNameLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SENDER</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="SenderPickFromList">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/Instances_16px.png</normaloff>:/icons/Instances_16px.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="SenderPickFromViewport">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/SelectMode_16px.png</normaloff>:/icons/SelectMode_16px.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="SenderStateComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="SwapButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/Swap_16px.png</normaloff>:/icons/Swap_16px.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="ReceiverGroupBox">
|
||||
<property name="title">
|
||||
<string>Receiver</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="ReceiverNameLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>RECEIVER</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ReceiverPickFromList">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/Instances_16px.png</normaloff>:/icons/Instances_16px.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ReceiverPickFromViewport">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/SelectMode_16px.png</normaloff>:/icons/SelectMode_16px.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="ReceiverMessageComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="ButtonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../Icons.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>ButtonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CLinkDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>ButtonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CLinkDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -67,13 +67,13 @@ QVariant CLinkModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
case 1: // Column 1 - State
|
||||
{
|
||||
TString StateName = mpObject->MasterTemplate()->StateByID(link.State);
|
||||
TString StateName = mpObject->MasterTemplate()->StateByID(link.State).Name;
|
||||
return UICommon::ToQString(StateName);
|
||||
}
|
||||
|
||||
case 2: // Column 2 - Message
|
||||
{
|
||||
TString MessageName = mpObject->MasterTemplate()->MessageByID(link.Message);
|
||||
TString MessageName = mpObject->MasterTemplate()->MessageByID(link.Message).Name;
|
||||
return UICommon::ToQString(MessageName);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/SelectMode.png</normaloff>:/icons/SelectMode.png</iconset>
|
||||
<normaloff>:/icons/SelectMode_16px.png</normaloff>:/icons/SelectMode_16px.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
|
@ -96,7 +96,7 @@
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/Instances.png</normaloff>:/icons/Instances.png</iconset>
|
||||
<normaloff>:/icons/Instances_16px.png</normaloff>:/icons/Instances_16px.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
#include "CSelectInstanceDialog.h"
|
||||
#include "ui_CSelectInstanceDialog.h"
|
||||
|
||||
CSelectInstanceDialog::CSelectInstanceDialog(CWorldEditor *pEditor, QWidget *pParent)
|
||||
: QDialog(pParent)
|
||||
, ui(new Ui::CSelectInstanceDialog)
|
||||
, mpEditor(pEditor)
|
||||
, mValidSelection(false)
|
||||
, mpLayersInst(nullptr)
|
||||
, mpTypesInst(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
mLayersModel.SetModelType(CInstancesModel::eLayers);
|
||||
mLayersModel.SetEditor(pEditor);
|
||||
mLayersModel.SetArea(pEditor->ActiveArea());
|
||||
mLayersModel.SetShowColumnEnabled(false);
|
||||
|
||||
mTypesModel.SetModelType(CInstancesModel::eTypes);
|
||||
mTypesModel.SetEditor(pEditor);
|
||||
mTypesModel.SetArea(pEditor->ActiveArea());
|
||||
mTypesModel.SetMaster(CMasterTemplate::GetMasterForGame(pEditor->CurrentGame()));
|
||||
mTypesModel.SetShowColumnEnabled(false);
|
||||
|
||||
int Col0Width = ui->LayersTreeView->width() * 0.9;
|
||||
int Col1Width = ui->LayersTreeView->width() * 0.1;
|
||||
mLayersProxyModel.setSourceModel(&mLayersModel);
|
||||
ui->LayersTreeView->setModel(&mLayersProxyModel);
|
||||
ui->LayersTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
ui->LayersTreeView->header()->resizeSection(0, Col0Width);
|
||||
ui->LayersTreeView->header()->resizeSection(1, Col1Width);
|
||||
|
||||
mTypesProxyModel.setSourceModel(&mTypesModel);
|
||||
ui->TypesTreeView->setModel(&mTypesProxyModel);
|
||||
ui->TypesTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
ui->TypesTreeView->header()->resizeSection(0, Col0Width);
|
||||
ui->TypesTreeView->header()->resizeSection(1, Col1Width);
|
||||
|
||||
ui->LayersTreeView->expand(mLayersProxyModel.index(0, 0));
|
||||
ui->TypesTreeView->expand(mTypesProxyModel.index(0, 0));
|
||||
|
||||
ui->ButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
connect(ui->TabWidget, SIGNAL(currentChanged(int)), this, SLOT(OnTabChanged(int)));
|
||||
connect(ui->LayersTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(OnTreeClicked(QModelIndex)));
|
||||
connect(ui->LayersTreeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnTreeDoubleClicked(QModelIndex)));
|
||||
connect(ui->TypesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(OnTreeClicked(QModelIndex)));
|
||||
connect(ui->TypesTreeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnTreeDoubleClicked(QModelIndex)));
|
||||
}
|
||||
|
||||
CSelectInstanceDialog::~CSelectInstanceDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
CScriptObject* CSelectInstanceDialog::SelectedInstance() const
|
||||
{
|
||||
return (ui->TabWidget->currentIndex() == 0 ? mpLayersInst : mpTypesInst);
|
||||
}
|
||||
|
||||
// ************ PUBLIC SLOTS ************
|
||||
void CSelectInstanceDialog::OnTabChanged(int NewTabIndex)
|
||||
{
|
||||
if (NewTabIndex == 0)
|
||||
mValidSelection = (mpLayersInst != nullptr);
|
||||
else
|
||||
mValidSelection = (mpTypesInst != nullptr);
|
||||
|
||||
ui->ButtonBox->button(QDialogButtonBox::Ok)->setEnabled(mValidSelection);
|
||||
}
|
||||
|
||||
void CSelectInstanceDialog::OnTreeClicked(QModelIndex Index)
|
||||
{
|
||||
int TabIndex = ui->TabWidget->currentIndex();
|
||||
|
||||
if (TabIndex == 0)
|
||||
{
|
||||
QModelIndex SourceIndex = mLayersProxyModel.mapToSource(Index);
|
||||
mpLayersInst = mLayersModel.IndexObject(SourceIndex);
|
||||
mValidSelection = (mpLayersInst != nullptr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
QModelIndex SourceIndex = mTypesProxyModel.mapToSource(Index);
|
||||
mpTypesInst = mTypesModel.IndexObject(SourceIndex);
|
||||
mValidSelection = (mpTypesInst != nullptr);
|
||||
}
|
||||
|
||||
ui->ButtonBox->button(QDialogButtonBox::Ok)->setEnabled(mValidSelection);
|
||||
}
|
||||
|
||||
void CSelectInstanceDialog::OnTreeDoubleClicked(QModelIndex /*Index*/)
|
||||
{
|
||||
// Instance selection was handled in OnTreeClicked on the first click.
|
||||
if (mValidSelection)
|
||||
close();
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef CSELECTINSTANCEDIALOG_H
|
||||
#define CSELECTINSTANCEDIALOG_H
|
||||
|
||||
#include "CInstancesModel.h"
|
||||
#include "CInstancesProxyModel.h"
|
||||
#include <QDialog>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
namespace Ui {
|
||||
class CSelectInstanceDialog;
|
||||
}
|
||||
|
||||
class CSelectInstanceDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
CWorldEditor *mpEditor;
|
||||
CInstancesModel mLayersModel;
|
||||
CInstancesModel mTypesModel;
|
||||
CInstancesProxyModel mLayersProxyModel;
|
||||
CInstancesProxyModel mTypesProxyModel;
|
||||
|
||||
bool mValidSelection;
|
||||
CScriptObject *mpLayersInst;
|
||||
CScriptObject *mpTypesInst;
|
||||
|
||||
Ui::CSelectInstanceDialog *ui;
|
||||
|
||||
public:
|
||||
explicit CSelectInstanceDialog(CWorldEditor *pEditor, QWidget *pParent = 0);
|
||||
~CSelectInstanceDialog();
|
||||
|
||||
CScriptObject* SelectedInstance() const;
|
||||
|
||||
public slots:
|
||||
void OnTabChanged(int NewTabIndex);
|
||||
void OnTreeClicked(QModelIndex Index);
|
||||
void OnTreeDoubleClicked(QModelIndex Index);
|
||||
};
|
||||
|
||||
#endif // CSELECTINSTANCEDIALOG_H
|
|
@ -0,0 +1,147 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSelectInstanceDialog</class>
|
||||
<widget class="QDialog" name="CSelectInstanceDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>816</width>
|
||||
<height>534</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Select Instance</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="TabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="LayersTab">
|
||||
<attribute name="title">
|
||||
<string>Layers</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="LayersTreeView">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="TypesTab">
|
||||
<attribute name="title">
|
||||
<string>Types</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="TypesTreeView">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="ButtonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>ButtonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CSelectInstanceDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>ButtonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CSelectInstanceDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -0,0 +1,110 @@
|
|||
#ifndef CSTATEMESSAGEMODEL_H
|
||||
#define CSTATEMESSAGEMODEL_H
|
||||
|
||||
#include "Editor/UICommon.h"
|
||||
#include <Core/Resource/Script/CMasterTemplate.h>
|
||||
#include <Core/Resource/Script/CScriptTemplate.h>
|
||||
#include <QAbstractListModel>
|
||||
|
||||
// todo: support pulling states/messages from script templates instead of master
|
||||
class CStateMessageModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum EType
|
||||
{
|
||||
eStates,
|
||||
eMessages
|
||||
};
|
||||
|
||||
private:
|
||||
struct SEntry
|
||||
{
|
||||
u32 ID;
|
||||
QString Name;
|
||||
|
||||
SEntry() {}
|
||||
SEntry(u32 _ID, const QString& rkName)
|
||||
: ID(_ID), Name(rkName) {}
|
||||
|
||||
bool operator<(const SEntry& rkOther) const
|
||||
{
|
||||
return Name < rkOther.Name;
|
||||
}
|
||||
};
|
||||
QList<SEntry> mEntries;
|
||||
|
||||
CMasterTemplate *mpMaster;
|
||||
CScriptTemplate *mpScript;
|
||||
EType mType;
|
||||
|
||||
public:
|
||||
explicit CStateMessageModel(EType Type, QObject *pParent = 0)
|
||||
: QAbstractListModel(pParent)
|
||||
, mType(Type)
|
||||
, mpMaster(nullptr)
|
||||
, mpScript(nullptr)
|
||||
{}
|
||||
|
||||
int rowCount(const QModelIndex& /*rkParent*/) const
|
||||
{
|
||||
return mEntries.size();
|
||||
}
|
||||
|
||||
QVariant data(const QModelIndex& rkIndex, int Role) const
|
||||
{
|
||||
if (Role == Qt::DisplayRole)
|
||||
{
|
||||
return mEntries[rkIndex.row()].Name;
|
||||
}
|
||||
|
||||
else return QVariant::Invalid;
|
||||
}
|
||||
|
||||
void SetMasterTemplate(CMasterTemplate *pMaster)
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
mpMaster = pMaster;
|
||||
mEntries.clear();
|
||||
|
||||
if (mType == eStates)
|
||||
{
|
||||
for (u32 iState = 0; iState < pMaster->NumStates(); iState++)
|
||||
{
|
||||
SState State = pMaster->StateByIndex(iState);
|
||||
mEntries << SEntry(State.ID, TO_QSTRING(State.Name));
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
for (u32 iMsg = 0; iMsg < pMaster->NumMessages(); iMsg++)
|
||||
{
|
||||
SMessage Message = pMaster->MessageByIndex(iMsg);
|
||||
mEntries << SEntry(Message.ID, TO_QSTRING(Message.Name));
|
||||
}
|
||||
}
|
||||
|
||||
qSort(mEntries);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void SetScriptTemplate(CScriptTemplate *pScript)
|
||||
{
|
||||
mpScript = pScript;
|
||||
}
|
||||
|
||||
inline u32 State(u32 Index) const
|
||||
{
|
||||
return (mType == eStates ? mEntries[Index].ID : 0);
|
||||
}
|
||||
|
||||
inline u32 Message(u32 Index) const
|
||||
{
|
||||
return (mType == eMessages ? mEntries[Index].ID : 0);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CSTATEMESSAGEMODEL_H
|
|
@ -111,6 +111,8 @@ void CWorldEditor::closeEvent(QCloseEvent *pEvent)
|
|||
|
||||
if (mpPoiDialog)
|
||||
mpPoiDialog->close();
|
||||
|
||||
emit Closed();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -97,6 +97,7 @@ private slots:
|
|||
void on_ActionEditPoiToWorldMap_triggered();
|
||||
|
||||
signals:
|
||||
void Closed();
|
||||
void LayersModified();
|
||||
void InstancesLayerAboutToChange();
|
||||
void InstancesLayerChanged(const QList<CScriptNode*>& rkInstanceList);
|
||||
|
|
|
@ -56,6 +56,9 @@
|
|||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
|
@ -98,7 +101,7 @@
|
|||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
#include "WModifyTab.h"
|
||||
#include "ui_WModifyTab.h"
|
||||
|
||||
#include "CLinkDialog.h"
|
||||
#include "CWorldEditor.h"
|
||||
#include <Core/Scene/CScriptNode.h>
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QScrollBar>
|
||||
|
||||
WModifyTab::WModifyTab(QWidget *pParent) :
|
||||
QWidget(pParent),
|
||||
ui(new Ui::WModifyTab)
|
||||
WModifyTab::WModifyTab(QWidget *pParent)
|
||||
: QWidget(pParent)
|
||||
, ui(new Ui::WModifyTab)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -21,6 +23,7 @@ WModifyTab::WModifyTab(QWidget *pParent) :
|
|||
mpInLinkModel->SetConnectionType(CLinkModel::eIncoming);
|
||||
mpOutLinkModel = new CLinkModel(this);
|
||||
mpOutLinkModel->SetConnectionType(CLinkModel::eOutgoing);
|
||||
mpLinkDialog = nullptr;
|
||||
|
||||
ui->InLinksTableView->setModel(mpInLinkModel);
|
||||
ui->OutLinksTableView->setModel(mpOutLinkModel);
|
||||
|
@ -28,6 +31,10 @@ WModifyTab::WModifyTab(QWidget *pParent) :
|
|||
ui->OutLinksTableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
connect(ui->InLinksTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnLinkTableDoubleClick(QModelIndex)));
|
||||
connect(ui->OutLinksTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnLinkTableDoubleClick(QModelIndex)));
|
||||
connect(ui->AddOutgoingConnectionButton, SIGNAL(clicked()), this, SLOT(OnAddOutgoingLinkClicked()));
|
||||
connect(ui->AddIncomingConnectionButton, SIGNAL(clicked()), this, SLOT(OnAddIncomingLinkClicked()));
|
||||
connect(ui->DeleteOutgoingConnectionButton, SIGNAL(clicked()), this, SLOT(OnDeleteOutgoingLinkClicked()));
|
||||
connect(ui->DeleteIncomingConnectionButton, SIGNAL(clicked()), this, SLOT(OnDeleteIncomingLinkClicked()));
|
||||
|
||||
ClearUI();
|
||||
}
|
||||
|
@ -41,6 +48,7 @@ void WModifyTab::SetEditor(CWorldEditor *pEditor)
|
|||
{
|
||||
mpWorldEditor = pEditor;
|
||||
ui->PropertyView->SetEditor(mpWorldEditor);
|
||||
connect(mpWorldEditor, SIGNAL(Closed()), this, SLOT(OnWorldEditorClosed()));
|
||||
connect(mpWorldEditor, SIGNAL(SelectionTransformed()), this, SLOT(OnWorldSelectionTransformed()));
|
||||
}
|
||||
|
||||
|
@ -80,11 +88,95 @@ void WModifyTab::ClearUI()
|
|||
mpSelectedNode = nullptr;
|
||||
}
|
||||
|
||||
void WModifyTab::CreateLinkDialog()
|
||||
{
|
||||
if (!mpLinkDialog)
|
||||
{
|
||||
mpLinkDialog = new CLinkDialog(mpWorldEditor, this);
|
||||
|
||||
if (mpSelectedNode && mpSelectedNode->NodeType() == eScriptNode)
|
||||
{
|
||||
CScriptNode *pScript = static_cast<CScriptNode*>(mpSelectedNode);
|
||||
mpLinkDialog->SetMaster(pScript->Object()->MasterTemplate());
|
||||
}
|
||||
|
||||
connect(mpLinkDialog, SIGNAL(accepted()), this, SLOT(OnLinkDialogAccept()));
|
||||
connect(mpLinkDialog, SIGNAL(rejected()), this, SLOT(OnLinkDialogReject()));
|
||||
}
|
||||
}
|
||||
|
||||
void WModifyTab::DeleteLinkDialog()
|
||||
{
|
||||
if (mpLinkDialog)
|
||||
{
|
||||
delete mpLinkDialog;
|
||||
mpLinkDialog = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// ************ PUBLIC SLOTS ************
|
||||
void WModifyTab::OnWorldEditorClosed()
|
||||
{
|
||||
DeleteLinkDialog();
|
||||
}
|
||||
|
||||
void WModifyTab::OnWorldSelectionTransformed()
|
||||
{
|
||||
ui->PropertyView->UpdateEditorProperties(QModelIndex());
|
||||
}
|
||||
|
||||
void WModifyTab::OnAddOutgoingLinkClicked()
|
||||
{
|
||||
if (mpSelectedNode && mpSelectedNode->NodeType() == eScriptNode)
|
||||
{
|
||||
CScriptObject *pInst = static_cast<CScriptNode*>(mpSelectedNode)->Object();
|
||||
CreateLinkDialog();
|
||||
|
||||
if (mpLinkDialog->Sender() != pInst)
|
||||
{
|
||||
mpLinkDialog->SetSender(pInst);
|
||||
mpLinkDialog->SetReceiver(nullptr);
|
||||
}
|
||||
|
||||
mpLinkDialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
void WModifyTab::OnAddIncomingLinkClicked()
|
||||
{
|
||||
if (mpSelectedNode && mpSelectedNode->NodeType() == eScriptNode)
|
||||
{
|
||||
CScriptObject *pInst = static_cast<CScriptNode*>(mpSelectedNode)->Object();
|
||||
CreateLinkDialog();
|
||||
|
||||
if (mpLinkDialog->Receiver() != pInst)
|
||||
{
|
||||
mpLinkDialog->SetSender(nullptr);
|
||||
mpLinkDialog->SetReceiver(pInst);
|
||||
}
|
||||
|
||||
mpLinkDialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
void WModifyTab::OnDeleteOutgoingLinkClicked()
|
||||
{
|
||||
}
|
||||
|
||||
void WModifyTab::OnDeleteIncomingLinkClicked()
|
||||
{
|
||||
}
|
||||
|
||||
void WModifyTab::OnLinkDialogAccept()
|
||||
{
|
||||
DeleteLinkDialog();
|
||||
}
|
||||
|
||||
void WModifyTab::OnLinkDialogReject()
|
||||
{
|
||||
DeleteLinkDialog();
|
||||
}
|
||||
|
||||
// ************ PRIVATE SLOTS ************
|
||||
void WModifyTab::OnLinkTableDoubleClick(QModelIndex Index)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef WMODIFYTAB_H
|
||||
#define WMODIFYTAB_H
|
||||
|
||||
#include "CLinkDialog.h"
|
||||
#include "CLinkModel.h"
|
||||
#include <Core/Scene/CSceneNode.h>
|
||||
#include <Core/Scene/CScriptNode.h>
|
||||
|
@ -27,16 +28,28 @@ class WModifyTab : public QWidget
|
|||
CLinkModel *mpInLinkModel;
|
||||
CLinkModel *mpOutLinkModel;
|
||||
|
||||
CLinkDialog *mpLinkDialog;
|
||||
|
||||
public:
|
||||
explicit WModifyTab(QWidget *pParent = 0);
|
||||
~WModifyTab();
|
||||
void SetEditor(CWorldEditor *pEditor);
|
||||
void GenerateUI(QList<CSceneNode*>& Selection);
|
||||
void ClearUI();
|
||||
void CreateLinkDialog();
|
||||
void DeleteLinkDialog();
|
||||
|
||||
public slots:
|
||||
void OnWorldEditorClosed();
|
||||
void OnWorldSelectionTransformed();
|
||||
|
||||
void OnAddOutgoingLinkClicked();
|
||||
void OnAddIncomingLinkClicked();
|
||||
void OnDeleteOutgoingLinkClicked();
|
||||
void OnDeleteIncomingLinkClicked();
|
||||
void OnLinkDialogAccept();
|
||||
void OnLinkDialogReject();
|
||||
|
||||
private:
|
||||
Ui::WModifyTab *ui;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">alternate-background-color: rgb(35,35,35);</string>
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::AllEditTriggers</set>
|
||||
|
@ -149,6 +149,45 @@
|
|||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="AddOutgoingConnectionButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/Plus.png</normaloff>:/icons/Plus.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="DeleteOutgoingConnectionButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/Minus v2.png</normaloff>:/icons/Minus v2.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="OutgoingButtonsSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -174,6 +213,45 @@
|
|||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="AddIncomingConnectionButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/Plus.png</normaloff>:/icons/Plus.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="DeleteIncomingConnectionButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../Icons.qrc">
|
||||
<normaloff>:/icons/Minus v2.png</normaloff>:/icons/Minus v2.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="IncomingButtonsSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -201,6 +279,8 @@
|
|||
<header>Editor/PropertyEdit/CPropertyView.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../Icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
|
@ -45,7 +45,7 @@ int main(int argc, char *argv[])
|
|||
darkPalette.setColor(QPalette::Window, QColor(53,53,53));
|
||||
darkPalette.setColor(QPalette::WindowText, Qt::white);
|
||||
darkPalette.setColor(QPalette::Base, QColor(25,25,25));
|
||||
darkPalette.setColor(QPalette::AlternateBase, QColor(53,53,53));
|
||||
darkPalette.setColor(QPalette::AlternateBase, QColor(35,35,35));
|
||||
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
|
||||
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
|
||||
darkPalette.setColor(QPalette::Text, Qt::white);
|
||||
|
|
Loading…
Reference in New Issue