diff --git a/src/Core/GameProject/CGameProject.h b/src/Core/GameProject/CGameProject.h index 6f0ba745..4f0aea44 100644 --- a/src/Core/GameProject/CGameProject.h +++ b/src/Core/GameProject/CGameProject.h @@ -96,6 +96,7 @@ public: // Accessors inline void SetProjectName(const TString& rkName) { mProjectName = rkName; } + inline TString Name() const { return mProjectName; } inline u32 NumPackages() const { return mPackages.size(); } inline CPackage* PackageByIndex(u32 Index) const { return mPackages[Index]; } inline void AddPackage(CPackage *pPackage) { mPackages.push_back(pPackage); } diff --git a/src/Core/Resource/CWorld.cpp b/src/Core/Resource/CWorld.cpp index 3169a6aa..e297c4b5 100644 --- a/src/Core/Resource/CWorld.cpp +++ b/src/Core/Resource/CWorld.cpp @@ -60,6 +60,24 @@ void CWorld::SetAreaLayerInfo(CGameArea *pArea) } } +TString CWorld::InGameName() const +{ + if (mpWorldName) + return mpWorldName->String("ENGL", 0).ToUTF8(); + else + return Entry()->Name().ToUTF8(); +} + +TString CWorld::AreaInGameName(u32 AreaIndex) const +{ + const SArea& rkArea = mAreas[AreaIndex]; + + if (rkArea.pAreaName) + return rkArea.pAreaName->String("ENGL", 0).ToUTF8(); + else + return "!!" + rkArea.InternalName; +} + // ************ SERIALIZATION ************ void CWorld::Serialize(IArchive& rArc) { diff --git a/src/Core/Resource/CWorld.h b/src/Core/Resource/CWorld.h index 9160a2de..0bdde2f3 100644 --- a/src/Core/Resource/CWorld.h +++ b/src/Core/Resource/CWorld.h @@ -80,6 +80,8 @@ public: CDependencyTree* BuildDependencyTree() const; void SetAreaLayerInfo(CGameArea *pArea); + TString InGameName() const; + TString AreaInGameName(u32 AreaIndex) const; // Serialization virtual void Serialize(IArchive& rArc); diff --git a/src/Editor/Editor.pro b/src/Editor/Editor.pro index 80554c98..69b695a0 100644 --- a/src/Editor/Editor.pro +++ b/src/Editor/Editor.pro @@ -109,7 +109,6 @@ HEADERS += \ Widgets/WColorPicker.h \ Widgets/WDraggableSpinBox.h \ Widgets/WIntegralSpinBox.h \ - Widgets/WResourceSelector.h \ Widgets/WScanPreviewPanel.h \ Widgets/WStringPreviewPanel.h \ Widgets/WTextureGLWidget.h \ @@ -198,7 +197,6 @@ SOURCES += \ Widgets/WColorPicker.cpp \ Widgets/WDraggableSpinBox.cpp \ Widgets/WIntegralSpinBox.cpp \ - Widgets/WResourceSelector.cpp \ Widgets/WScanPreviewPanel.cpp \ Widgets/WStringPreviewPanel.cpp \ Widgets/WTextureGLWidget.cpp \ diff --git a/src/Editor/ModelEditor/CModelEditorWindow.cpp b/src/Editor/ModelEditor/CModelEditorWindow.cpp index 06bd5d02..0381e421 100644 --- a/src/Editor/ModelEditor/CModelEditorWindow.cpp +++ b/src/Editor/ModelEditor/CModelEditorWindow.cpp @@ -2,7 +2,6 @@ #include "ui_CModelEditorWindow.h" #include "Editor/UICommon.h" #include "Editor/Widgets/WColorPicker.h" -#include "Editor/Widgets/WResourceSelector.h" #include #include diff --git a/src/Editor/PropertyEdit/CPropertyDelegate.cpp b/src/Editor/PropertyEdit/CPropertyDelegate.cpp index b76a79af..f8e39ed4 100644 --- a/src/Editor/PropertyEdit/CPropertyDelegate.cpp +++ b/src/Editor/PropertyEdit/CPropertyDelegate.cpp @@ -8,7 +8,6 @@ #include "Editor/Widgets/WColorPicker.h" #include "Editor/Widgets/WDraggableSpinBox.h" #include "Editor/Widgets/WIntegralSpinBox.h" -#include "Editor/Widgets/WResourceSelector.h" #include #include @@ -140,6 +139,8 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie case eAssetProperty: { CResourceSelector *pSelector = new CResourceSelector(pParent); + pSelector->SetFrameVisible(false); + CAssetTemplate *pTemp = static_cast(pProp->Template()); pSelector->SetAllowedExtensions(pTemp->AllowedExtensions()); @@ -598,6 +599,7 @@ QWidget* CPropertyDelegate::CreateCharacterEditor(QWidget *pParent, const QModel if (Type == eAssetProperty) { CResourceSelector *pSelector = new CResourceSelector(pParent); + pSelector->SetFrameVisible(false); if (Params.Version() <= eEchoes) pSelector->SetAllowedExtensions("ANCS"); diff --git a/src/Editor/ResourceBrowser/CResourceBrowser.ui b/src/Editor/ResourceBrowser/CResourceBrowser.ui index 4c68ca08..34c5dc78 100644 --- a/src/Editor/ResourceBrowser/CResourceBrowser.ui +++ b/src/Editor/ResourceBrowser/CResourceBrowser.ui @@ -130,7 +130,7 @@ 0 0 189 - 128 + 126 diff --git a/src/Editor/Widgets/CResourceSelector.cpp b/src/Editor/Widgets/CResourceSelector.cpp index b8acb3e7..c8ea3f78 100644 --- a/src/Editor/Widgets/CResourceSelector.cpp +++ b/src/Editor/Widgets/CResourceSelector.cpp @@ -11,6 +11,7 @@ CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/) : QWidget(pParent) , mpResEntry(nullptr) + , mIsEditable(true) { setContextMenuPolicy(Qt::CustomContextMenu); @@ -35,13 +36,21 @@ CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/) mpClearButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); mpClearButton->setFixedSize(16, 16); - mpLayout = new QHBoxLayout(this); - mpLayout->setSpacing(2); + mpFrameLayout = new QHBoxLayout(this); + mpFrameLayout->setSpacing(2); + mpFrameLayout->setContentsMargins(3, 0, 0, 0); + mpFrameLayout->addWidget(mpResNameLabel); + mpFrameLayout->addWidget(mpSetButton); + mpFrameLayout->addWidget(mpFindButton); + mpFrameLayout->addWidget(mpClearButton); + mpFrame = new QFrame(this); + mpFrame->setBackgroundRole(QPalette::AlternateBase); + mpFrame->setLayout(mpFrameLayout); + SetFrameVisible(true); + + mpLayout = new QVBoxLayout(this); + mpLayout->addWidget(mpFrame); mpLayout->setContentsMargins(0, 0, 0, 0); - mpLayout->addWidget(mpResNameLabel); - mpLayout->addWidget(mpSetButton); - mpLayout->addWidget(mpFindButton); - mpLayout->addWidget(mpClearButton); setLayout(mpLayout); // UI Connections @@ -63,6 +72,19 @@ CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/) UpdateUI(); } +void CResourceSelector::SetFrameVisible(bool Visible) +{ + mpFrame->setFrameStyle(Visible ? QFrame::StyledPanel : QFrame::NoFrame); + mpFrame->setAutoFillBackground(Visible); +} + +void CResourceSelector::SetEditable(bool Editable) +{ + mpSetButton->setVisible(Editable); + mpClearButton->setVisible(Editable); + mIsEditable = Editable; +} + void CResourceSelector::UpdateUI() { bool HasResource = mpResEntry != nullptr; diff --git a/src/Editor/Widgets/CResourceSelector.h b/src/Editor/Widgets/CResourceSelector.h index 414f5c27..b40ae784 100644 --- a/src/Editor/Widgets/CResourceSelector.h +++ b/src/Editor/Widgets/CResourceSelector.h @@ -12,9 +12,12 @@ class CResourceSelector : public QWidget Q_OBJECT CResourceEntry *mpResEntry; + bool mIsEditable; // UI - QHBoxLayout *mpLayout; + QVBoxLayout *mpLayout; + QHBoxLayout *mpFrameLayout; + QFrame *mpFrame; QLabel *mpResNameLabel; QPushButton *mpSetButton; QPushButton *mpFindButton; @@ -27,6 +30,8 @@ class CResourceSelector : public QWidget public: explicit CResourceSelector(QWidget *pParent = 0); + void SetFrameVisible(bool Visible); + void SetEditable(bool Editable); void SetAllowedExtensions(const QString& rkExtension); void SetAllowedExtensions(const TStringList& rkExtensions); void SetResource(const CAssetID& rkID); @@ -35,6 +40,7 @@ public: // Accessors inline CResourceEntry* Entry() const { return mpResEntry; } + inline bool IsEditable() const { return mIsEditable; } public slots: void CreateContextMenu(const QPoint& rkPoint); diff --git a/src/Editor/Widgets/WResourceSelector.cpp b/src/Editor/Widgets/WResourceSelector.cpp deleted file mode 100644 index 8a08ab25..00000000 --- a/src/Editor/Widgets/WResourceSelector.cpp +++ /dev/null @@ -1,286 +0,0 @@ -#include "WResourceSelector.h" -#include "WTexturePreviewPanel.h" -#include "Editor/UICommon.h" -#include - -#include -#include -#include -#include -#include -#include - -WResourceSelector::WResourceSelector(QWidget *parent) - : QWidget(parent) - // Preview Panel Members - , mpPreviewPanel(nullptr) - , mEnablePreviewPanel(true) - , mPreviewPanelValid(false) - , mShowingPreviewPanel(false) - , mAdjustPreviewToParent(false) - // Resource Members - , mpResource(nullptr) - , mResourceValid(false) -{ - // Create Widgets - mUI.LineEdit = new QLineEdit(this); - mUI.BrowseButton = new QPushButton(this); - - // Create Layout - mUI.Layout = new QHBoxLayout(this); - setLayout(mUI.Layout); - mUI.Layout->addWidget(mUI.LineEdit); - mUI.Layout->addWidget(mUI.BrowseButton); - mUI.Layout->setContentsMargins(0,0,0,0); - mUI.Layout->setSpacing(1); - - // Set Up Widgets - mUI.LineEdit->installEventFilter(this); - mUI.LineEdit->setMouseTracking(true); - mUI.LineEdit->setMaximumHeight(23); - mUI.LineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - mUI.BrowseButton->installEventFilter(this); - mUI.BrowseButton->setMouseTracking(true); - mUI.BrowseButton->setText("..."); - mUI.BrowseButton->setMaximumSize(25, 23); - mUI.BrowseButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - - connect(mUI.LineEdit, SIGNAL(editingFinished()), this, SLOT(OnLineEditTextEdited())); - connect(mUI.BrowseButton, SIGNAL(clicked()), this, SLOT(OnBrowseButtonClicked())); -} - -WResourceSelector::~WResourceSelector() -{ - delete mpPreviewPanel; -} - -bool WResourceSelector::event(QEvent *pEvent) -{ - if ((pEvent->type() == QEvent::Leave) || (pEvent->type() == QEvent::WindowDeactivate)) - HidePreviewPanel(); - - return false; -} - -bool WResourceSelector::eventFilter(QObject* /*pObj*/, QEvent *pEvent) -{ - if (pEvent->type() == QEvent::MouseMove) - if (mEnablePreviewPanel) - ShowPreviewPanel(); - - return false; -} - -bool WResourceSelector::IsSupportedExtension(const QString& rkExtension) -{ - foreach(const QString& rkStr, mSupportedExtensions) - if (rkStr == rkExtension) return true; - - return false; -} - -bool WResourceSelector::HasSupportedExtension(CResourceEntry *pEntry) -{ - return IsSupportedExtension(TO_QSTRING(pEntry->CookedExtension().ToString())); -} - -void WResourceSelector::UpdateFrameColor() -{ - // Red frame should only display if the current path is either invalid or points to an entry of an invalid type. - bool RedFrame = (!GetText().isEmpty() && !mpResource) || (mpResource && !mResourceValid); - mUI.LineEdit->setStyleSheet(RedFrame ? "border: 1px solid red" : ""); - mUI.LineEdit->setFont(font()); -} - -// ************ GETTERS ************ -CResourceEntry* WResourceSelector::GetResourceEntry() -{ - return mpResource; -} - -CResource* WResourceSelector::GetResource() -{ - return mpResource->Load(); -} - -QString WResourceSelector::GetText() -{ - return mUI.LineEdit->text(); -} - -bool WResourceSelector::IsPreviewPanelEnabled() -{ - return mEnablePreviewPanel; -} - -// ************ SETTERS ************ -void WResourceSelector::SetResource(CResource *pRes) -{ - SetResource(pRes ? pRes->Entry() : nullptr); -} - -void WResourceSelector::SetResource(CResourceEntry *pRes) -{ - if (mpResource != pRes) - { - mpResource = pRes; - - // We might prefer to have the line edit be cleared if pRes is null. However atm this function triggers - // when the user types in a resource path so I'd prefer for the text not to be cleared out in that case - if (mpResource) - { - TWideString Path = mpResource->CookedAssetPath(true); - mUI.LineEdit->setText(TO_QSTRING(Path)); - mResourceValid = HasSupportedExtension(mpResource); - } - else - mResourceValid = false; - - UpdateFrameColor(); - CreatePreviewPanel(); - emit ResourceChanged(mpResource); - } -} - -void WResourceSelector::SetResource(const CAssetID& rkID) -{ - CResourceEntry *pEntry = gpResourceStore->FindEntry(rkID); - SetResource(pEntry); -} - -void WResourceSelector::SetResource(const QString& rkRes) -{ - CResourceEntry *pEntry = gpResourceStore->FindEntry(TO_TWIDESTRING(rkRes)); - SetResource(pEntry); -} - -void WResourceSelector::SetAllowedExtensions(const QString& rkExtension) -{ - TStringList list = TString(rkExtension.toStdString()).Split(","); - SetAllowedExtensions(list); -} - -void WResourceSelector::SetAllowedExtensions(const TStringList& rkExtensions) -{ - mSupportedExtensions.clear(); - for (auto it = rkExtensions.begin(); it != rkExtensions.end(); it++) - mSupportedExtensions << TO_QSTRING(*it); -} - -void WResourceSelector::SetText(const QString& rkResPath) -{ - mUI.LineEdit->setText(rkResPath); - CResourceEntry *pEntry = gpResourceStore->FindEntry(TO_TWIDESTRING(rkResPath)); - SetResource(pEntry); -} - -void WResourceSelector::SetPreviewPanelEnabled(bool Enabled) -{ - mEnablePreviewPanel = Enabled; - if (!mPreviewPanelValid) CreatePreviewPanel(); -} - -void WResourceSelector::AdjustPreviewToParent(bool Adjust) -{ - mAdjustPreviewToParent = Adjust; -} - -// ************ SLOTS ************ -void WResourceSelector::OnLineEditTextEdited() -{ - SetResource(mUI.LineEdit->text()); -} - -void WResourceSelector::OnBrowseButtonClicked() -{ - // Construct filter string - QString Filter; - - if (mSupportedExtensions.size() > 1) - { - QString All = "All allowed extensions ("; - - for (int iExt = 0; iExt < mSupportedExtensions.size(); iExt++) - { - if (iExt > 0) All += " "; - All += "*." + mSupportedExtensions[iExt]; - } - All += ")"; - Filter += All + ";;"; - } - - for (int iExt = 0; iExt < mSupportedExtensions.size(); iExt++) - { - if (iExt > 0) Filter += ";;"; - Filter += UICommon::ExtensionFilterString(mSupportedExtensions[iExt]); - } - - QString NewRes = UICommon::OpenFileDialog(this, "Select resource", Filter); - - if (!NewRes.isEmpty()) - { - mUI.LineEdit->setText(NewRes); - SetResource(NewRes); - } -} - -// ************ PRIVATE ************ -void WResourceSelector::CreatePreviewPanel() -{ - delete mpPreviewPanel; - mpPreviewPanel = nullptr; - - if (mResourceValid) - mpPreviewPanel = IPreviewPanel::CreatePanel(mpResource->ResourceType(), this); - - if (!mpPreviewPanel) mPreviewPanelValid = false; - - else - { - mPreviewPanelValid = true; - mpPreviewPanel->setWindowFlags(Qt::ToolTip); - if (mResourceValid) mpPreviewPanel->SetResource(mpResource->Load()); - } -} - -void WResourceSelector::ShowPreviewPanel() -{ - if (mPreviewPanelValid) - { - // Preferred panel point is lower-right, but can move if there's not enough room - QPoint Position = parentWidget()->mapToGlobal(pos()); - QRect ScreenResolution = QApplication::desktop()->screenGeometry(); - QSize PanelSize = mpPreviewPanel->size(); - QPoint PanelPoint = Position; - - // Calculate parent adjustment with 9 pixels of buffer - int ParentAdjustLeft = (mAdjustPreviewToParent ? pos().x() + 9 : 0); - int ParentAdjustRight = (mAdjustPreviewToParent ? parentWidget()->width() - pos().x() + 9 : 0); - - // Is there enough space on the right? - if (Position.x() + width() + PanelSize.width() + ParentAdjustRight >= ScreenResolution.width()) - PanelPoint.rx() -= PanelSize.width() + ParentAdjustLeft; - else - PanelPoint.rx() += width() + ParentAdjustRight; - - // Is there enough space on the bottom? - if (Position.y() + PanelSize.height() >= ScreenResolution.height() - 30) - { - int Difference = Position.y() + PanelSize.height() - ScreenResolution.height() + 30; - PanelPoint.ry() -= Difference; - } - - mpPreviewPanel->move(PanelPoint); - mpPreviewPanel->show(); - mShowingPreviewPanel = true; - } -} - -void WResourceSelector::HidePreviewPanel() -{ - if (mPreviewPanelValid && mShowingPreviewPanel) - { - mpPreviewPanel->hide(); - mShowingPreviewPanel = false; - } -} diff --git a/src/Editor/Widgets/WResourceSelector.h b/src/Editor/Widgets/WResourceSelector.h deleted file mode 100644 index 291beb0d..00000000 --- a/src/Editor/Widgets/WResourceSelector.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef WRESOURCESELECTOR_H -#define WRESOURCESELECTOR_H - -#include "IPreviewPanel.h" -#include -#include - -#include -#include -#include -#include -#include - -class WResourceSelector : public QWidget -{ - Q_OBJECT - - // Selector - QStringList mSupportedExtensions; - - // Preview Panel - IPreviewPanel *mpPreviewPanel; - bool mEnablePreviewPanel; - bool mPreviewPanelValid; - bool mShowingPreviewPanel; - bool mAdjustPreviewToParent; - - // Resource - CResourceEntry *mpResource; - bool mResourceValid; - - // UI - struct { - QLineEdit *LineEdit; - QPushButton *BrowseButton; - QHBoxLayout *Layout; - } mUI; - - // Functions -signals: - void ResourceChanged(CResourceEntry *pNewRes); - -public: - explicit WResourceSelector(QWidget *pParent = 0); - ~WResourceSelector(); - bool event(QEvent *); - bool eventFilter(QObject *, QEvent *); - bool IsSupportedExtension(const QString& rkExtension); - bool HasSupportedExtension(CResourceEntry *pEntry); - void UpdateFrameColor(); - - // Getters - CResourceEntry* GetResourceEntry(); - CResource* GetResource(); - QString GetText(); - bool IsPreviewPanelEnabled(); - - // Setters - void SetResource(CResource *pRes); - void SetResource(CResourceEntry *pEntry); - void SetResource(const CAssetID& rkID); - void SetResource(const QString& rkResPath); - void SetAllowedExtensions(const QString& rkExtension); - void SetAllowedExtensions(const QStringList& rkExtensions); - void SetAllowedExtensions(const TStringList& rkExtensions); - void SetText(const QString& rkResPath); - void SetPreviewPanelEnabled(bool Enabled); - void AdjustPreviewToParent(bool Adjust); - - // Slots -public slots: - void OnLineEditTextEdited(); - void OnBrowseButtonClicked(); - -private: - void CreatePreviewPanel(); - void ShowPreviewPanel(); - void HidePreviewPanel(); -}; - -#endif // WRESOURCESELECTOR_H diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp index 9d386f44..e5861e36 100644 --- a/src/Editor/WorldEditor/CWorldEditor.cpp +++ b/src/Editor/WorldEditor/CWorldEditor.cpp @@ -118,6 +118,7 @@ CWorldEditor::CWorldEditor(QWidget *parent) { QAction *pAction = new QAction(this); pAction->setVisible(false); + pAction->setData((int) iAct); connect(pAction, SIGNAL(triggered(bool)), this, SLOT(OpenRecentProject())); mpOpenRecentMenu->addAction(pAction); diff --git a/src/Editor/WorldEditor/CWorldInfoSidebar.cpp b/src/Editor/WorldEditor/CWorldInfoSidebar.cpp index 360f61d0..f655899f 100644 --- a/src/Editor/WorldEditor/CWorldInfoSidebar.cpp +++ b/src/Editor/WorldEditor/CWorldInfoSidebar.cpp @@ -16,8 +16,34 @@ CWorldInfoSidebar::CWorldInfoSidebar(CWorldEditor *pEditor) QHeaderView *pHeader = mpUI->WorldTreeView->header(); pHeader->resizeSection(0, pHeader->width() * 2); // I really have no idea how this works, I just got this from trial & error + connect(gpEdApp, SIGNAL(ActiveProjectChanged(CGameProject*)), this, SLOT(OnActiveProjectChanged(CGameProject*))); connect(mpUI->AreaSearchLineEdit, SIGNAL(StoppedTyping(QString)), this, SLOT(OnAreaFilterStringChanged(QString))); + connect(mpUI->WorldTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(OnWorldTreeClicked(QModelIndex))); connect(mpUI->WorldTreeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnWorldTreeDoubleClicked(QModelIndex))); + + // Set up UI for world/area info; disable editing for now + mpUI->ProjectInfoWidget->setHidden(true); + mpUI->WorldInfoWidget->setHidden(true); + mpUI->AreaInfoWidget->setHidden(true); + + QSizePolicy SizePolicy = mpUI->WorldInfoWidget->sizePolicy(); + SizePolicy.setRetainSizeWhenHidden(true); + mpUI->WorldInfoWidget->setSizePolicy(SizePolicy); + + SizePolicy = mpUI->AreaInfoWidget->sizePolicy(); + SizePolicy.setRetainSizeWhenHidden(true); + mpUI->AreaInfoWidget->setSizePolicy(SizePolicy); + + mpUI->WorldSelector->SetEditable(false); + mpUI->WorldNameSelector->SetEditable(false); + mpUI->DarkWorldNameStringLabel->setHidden(true); + mpUI->DarkWorldNameSelector->SetEditable(false); + mpUI->DarkWorldNameSelector->setHidden(true); + mpUI->SkySelector->SetEditable(false); + + mpUI->AreaNameLineEdit->setEnabled(false); + mpUI->AreaSelector->SetEditable(false); + mpUI->AreaNameSelector->SetEditable(false); } CWorldInfoSidebar::~CWorldInfoSidebar() @@ -26,6 +52,19 @@ CWorldInfoSidebar::~CWorldInfoSidebar() } // ************ SLOTS ************ +void CWorldInfoSidebar::OnActiveProjectChanged(CGameProject *pProj) +{ + mpUI->ProjectInfoWidget->setHidden( pProj == nullptr ); + mpUI->WorldInfoWidget->setHidden(true); + mpUI->AreaInfoWidget->setHidden(true); + + bool IsEchoes = pProj && (pProj->Game() == eEchoesDemo || pProj->Game() == eEchoes); + mpUI->GameNameLabel->setText( pProj ? TO_QSTRING(pProj->Name()) : "" ); + mpUI->DarkWorldNameStringLabel->setHidden(!IsEchoes); + mpUI->DarkWorldNameSelector->setHidden(!IsEchoes); + ClearWorldInfo(); +} + void CWorldInfoSidebar::OnAreaFilterStringChanged(const QString& rkFilter) { mProxyModel.SetFilterString(rkFilter); @@ -42,6 +81,43 @@ void CWorldInfoSidebar::OnAreaFilterStringChanged(const QString& rkFilter) } } +void CWorldInfoSidebar::OnWorldTreeClicked(QModelIndex Index) +{ + QModelIndex RealIndex = mProxyModel.mapToSource(Index); + + // Fill in world info + mpUI->WorldInfoWidget->setHidden(false); + + CWorld *pWorld = mModel.WorldForIndex(RealIndex); + mpUI->WorldNameLabel->setText( TO_QSTRING(pWorld->InGameName()) ); + mpUI->WorldSelector->SetResource(pWorld); + mpUI->WorldNameSelector->SetResource(pWorld->WorldName()); + mpUI->DarkWorldNameSelector->SetResource(pWorld->DarkWorldName()); + mpUI->SkySelector->SetResource(pWorld->DefaultSkybox()); + + // Fill in area info + bool IsArea = !mModel.IndexIsWorld(RealIndex); + mpUI->AreaInfoWidget->setHidden(!IsArea); + + if (IsArea) + { + int AreaIndex = mModel.AreaIndexForIndex(RealIndex); + mpUI->AreaNameLabel->setText( TO_QSTRING(pWorld->AreaInGameName(AreaIndex)) ); + mpUI->AreaSelector->SetResource( pWorld->AreaResourceID(AreaIndex) ); + mpUI->AreaNameLineEdit->setText( TO_QSTRING(pWorld->AreaInternalName(AreaIndex)) ); + mpUI->AreaNameSelector->SetResource( pWorld->AreaName(AreaIndex) ); + + mpUI->AttachedAreasList->clear(); + + for (u32 iAtt = 0; iAtt < pWorld->AreaAttachedCount(AreaIndex); iAtt++) + { + u32 AttachedIdx = pWorld->AreaAttachedID(AreaIndex, iAtt); + QString Name = TO_QSTRING( pWorld->AreaInGameName(AttachedIdx) ); + mpUI->AttachedAreasList->addItem(Name); + } + } +} + void CWorldInfoSidebar::OnWorldTreeDoubleClicked(QModelIndex Index) { QModelIndex RealIndex = mProxyModel.mapToSource(Index); @@ -53,3 +129,22 @@ void CWorldInfoSidebar::OnWorldTreeDoubleClicked(QModelIndex Index) gpEdApp->WorldEditor()->SetArea(pWorld, AreaIndex); } } + +void CWorldInfoSidebar::ClearWorldInfo() +{ + mpUI->WorldNameLabel->clear(); + mpUI->WorldSelector->Clear(); + mpUI->WorldNameSelector->Clear(); + mpUI->DarkWorldNameSelector->Clear(); + mpUI->SkySelector->Clear(); + ClearAreaInfo(); +} + +void CWorldInfoSidebar::ClearAreaInfo() +{ + mpUI->AreaNameLabel->clear(); + mpUI->AreaSelector->Clear(); + mpUI->AreaNameLineEdit->clear(); + mpUI->AreaNameSelector->Clear(); + mpUI->AttachedAreasList->clear(); +} diff --git a/src/Editor/WorldEditor/CWorldInfoSidebar.h b/src/Editor/WorldEditor/CWorldInfoSidebar.h index 1fc201fa..706ec191 100644 --- a/src/Editor/WorldEditor/CWorldInfoSidebar.h +++ b/src/Editor/WorldEditor/CWorldInfoSidebar.h @@ -24,8 +24,12 @@ public: ~CWorldInfoSidebar(); public slots: + void OnActiveProjectChanged(CGameProject *pProj); void OnAreaFilterStringChanged(const QString& rkFilter); + void OnWorldTreeClicked(QModelIndex Index); void OnWorldTreeDoubleClicked(QModelIndex Index); + void ClearWorldInfo(); + void ClearAreaInfo(); }; #endif // CWORLDINFOSIDEBAR_H diff --git a/src/Editor/WorldEditor/CWorldInfoSidebar.ui b/src/Editor/WorldEditor/CWorldInfoSidebar.ui index b21073cd..c39225e2 100644 --- a/src/Editor/WorldEditor/CWorldInfoSidebar.ui +++ b/src/Editor/WorldEditor/CWorldInfoSidebar.ui @@ -7,7 +7,7 @@ 0 0 314 - 585 + 670 @@ -15,48 +15,307 @@ - - - - 10 - - - - - - - Search... - - - true - + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 12 + + + + GAME NAME + + + + + + + + 10 + + + + + + + Search... + + + true + + + + + + + + 0 + 1 + + + + + 10 + + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::ScrollPerPixel + + + 15 + + + true + + + false + + + + - - - - 10 - - - - QAbstractItemView::NoEditTriggers - - - true - - - QAbstractItemView::ScrollPerPixel - - - 15 - - - true - - - true - + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 12 + + + + WORLD NAME + + + + + + + + + + 9 + + + + World: + + + + + + + + + + + 9 + + + + Name String: + + + + + + + + + + + 9 + + + + Dark World Name: + + + + + + + + + + + 9 + + + + Default Sky: + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 12 + + + + AREA NAME + + + + + + + + + + 9 + + + + Name: + + + + + + + + + + + 9 + + + + Area: + + + + + + AreaNameLineEdit + AreaInternalNameLabel + + + + + + + 9 + + + + Name String: + + + + + + + + + + + + 1 + + + + + + 9 + + + + Attached Areas + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 70 + + + + true + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + + + + @@ -67,6 +326,12 @@ QLineEdit
Editor/Widgets/CTimedLineEdit.h
+ + CResourceSelector + QWidget +
Editor/Widgets/CResourceSelector.h
+ 1 +