From cfd5088a3034ed994cfa7e5adca91499d6ad9df4 Mon Sep 17 00:00:00 2001 From: Aruki Date: Mon, 8 Apr 2019 01:04:54 -0700 Subject: [PATCH] Added layer toggle support for quickplay --- resources/quickplay/MP1/v1.088.rel | Bin 2620 -> 3024 bytes src/Editor/CEditorApplication.cpp | 1 + src/Editor/CQuickplayPropertyEditor.cpp | 55 ++++++++++++++++++++++++ src/Editor/CQuickplayPropertyEditor.h | 7 +++ src/Editor/CQuickplayPropertyEditor.ui | 22 ++++++++++ src/Editor/NDolphinIntegration.h | 8 +++- src/Editor/WorldEditor/CWorldEditor.cpp | 6 --- src/Editor/main.cpp | 2 - 8 files changed, 92 insertions(+), 9 deletions(-) diff --git a/resources/quickplay/MP1/v1.088.rel b/resources/quickplay/MP1/v1.088.rel index 6ecd7dfb7d8179e4e5b2eb6473d70177d3b7f6d7..9477479e0b2fd25d1b44ece006fc6e4b3a4e2314 100644 GIT binary patch delta 799 zcmZ8f&1(}u9DVzlNg7L#1p}rgrGiBRe&ENJ1dJfGr;?;As7Q&}W3QsZnjK9K9y}zh z2Zd4%hT@?Y@t{y43ZANm9&?p?=${Z!sBf|xs1D4&-@JLhx9Mu?T1$Yqgd;o%zn2v3N_ylBm6h47{&17GNyv@l;xAMA%e;rPMvN7oq1mx)W2CrAf-zaJ`F zg;GPVMU6X+tS^ksMTx?p{z1QsT?5N>FhGW39cAuvMm4A6Sv#s8ZQc{p9txNJmhR9uD+A=(D@eCZ z2=_62H=;hNrBK{vYECp8?phVE{}tlu7pc3=xoTNbxfcJSS^jkROpWC>Kc*E|`bFLA zv96gL*G%hd)9*vYKB}kG8&YdRgm=WEZVtmO(G7Zbf}DV9MmV%}&a=;RgnEi-4vA+ZNVklM>y>Fk;7jbEu<3w delta 384 zcmca0zDHz&GG_n-14j%H`%Kg^(qb`SU|{oMU|?7Rq(1;@79jlvO8;PBUzP0BJ@b z?b-okPj+Desmoz04|GRU=LS{h-oVPhFoBUl!eSv1*E2A90QFncbK5i|GcW+naMJ*q z3p9U;4l@H2ke&n8=Qi1dRhdy_as+F`5u|R< #include /** Validator class for Dolphin line edit */ @@ -35,6 +37,7 @@ CQuickplayPropertyEditor::CQuickplayPropertyEditor(SQuickplayParameters& Paramet mpUI->DolphinPathLineEdit->setValidator( new CDolphinValidator(this) ); mpUI->BootToAreaCheckBox->setChecked( Parameters.Features.HasFlag(EQuickplayFeature::JumpToArea) ); mpUI->SpawnAtCameraLocationCheckBox->setChecked( Parameters.Features.HasFlag(EQuickplayFeature::SetSpawnPosition) ); + mpUI->GiveAllItemsCheckBox->setChecked( Parameters.Features.HasFlag(EQuickplayFeature::GiveAllItems) ); connect(mpUI->DolphinPathLineEdit, SIGNAL(textChanged(QString)), this, SLOT(OnDolphinPathChanged(QString))); @@ -47,6 +50,18 @@ CQuickplayPropertyEditor::CQuickplayPropertyEditor(SQuickplayParameters& Paramet connect(mpUI->GiveAllItemsCheckBox, SIGNAL(toggled(bool)), this, SLOT(OnGiveAllItemsToggled(bool))); + + connect(mpUI->LayerList, SIGNAL(itemChanged(QListWidgetItem*)), + this, SLOT(OnLayerListItemChanged(QListWidgetItem*))); + + // Connect to World Editor signals + CWorldEditor* pWorldEditor = qobject_cast(pParent); + + if (pWorldEditor) + { + connect(pWorldEditor, SIGNAL(MapChanged(CWorld*,CGameArea*)), + this, SLOT(OnWorldEditorAreaChanged(CWorld*,CGameArea*))); + } } CQuickplayPropertyEditor::~CQuickplayPropertyEditor() @@ -113,3 +128,43 @@ void CQuickplayPropertyEditor::OnGiveAllItemsToggled(bool Enabled) NDolphinIntegration::SaveQuickplayParameters(mParameters); } + +void CQuickplayPropertyEditor::OnLayerListItemChanged(QListWidgetItem* pItem) +{ + int LayerIdx = mpUI->LayerList->row(pItem); + uint64 LayerBit = 1ULL << LayerIdx; + mParameters.BootAreaLayerFlags &= ~LayerBit; + + if (pItem->checkState() == Qt::Checked) + { + mParameters.BootAreaLayerFlags |= LayerBit; + } +} + +void CQuickplayPropertyEditor::OnWorldEditorAreaChanged(CWorld* pWorld, CGameArea* pArea) +{ + mParameters.BootAreaLayerFlags = 0; + mpUI->LayerList->blockSignals(true); + mpUI->LayerList->clear(); + + if (pArea) + { + for (uint LayerIdx = 0; LayerIdx < pArea->NumScriptLayers(); LayerIdx++) + { + CScriptLayer* pLayer = pArea->ScriptLayer(LayerIdx); + bool bActive = pLayer->IsActive(); + + QListWidgetItem* pItem = new QListWidgetItem(); + pItem->setText( TO_QSTRING(pLayer->Name()) ); + pItem->setCheckState( bActive ? Qt::Checked : Qt::Unchecked ); + mpUI->LayerList->addItem( pItem ); + + if (bActive) + { + mParameters.BootAreaLayerFlags |= (1ULL << LayerIdx); + } + } + } + + mpUI->LayerList->blockSignals(false); +} diff --git a/src/Editor/CQuickplayPropertyEditor.h b/src/Editor/CQuickplayPropertyEditor.h index 3a480da7..545f54ff 100644 --- a/src/Editor/CQuickplayPropertyEditor.h +++ b/src/Editor/CQuickplayPropertyEditor.h @@ -1,9 +1,13 @@ #ifndef CQUICKPLAYPROPERTYEDITOR_H #define CQUICKPLAYPROPERTYEDITOR_H +#include #include #include "NDolphinIntegration.h" +#include +#include + namespace Ui { class CQuickplayPropertyEditor; } @@ -28,6 +32,9 @@ public slots: void OnBootToAreaToggled(bool Enabled); void OnSpawnAtCameraLocationToggled(bool Enabled); void OnGiveAllItemsToggled(bool Enabled); + void OnLayerListItemChanged(QListWidgetItem* pItem); + + void OnWorldEditorAreaChanged(CWorld* pWorld, CGameArea* pArea); }; #endif // CQUICKPLAYPROPERTYEDITOR_H diff --git a/src/Editor/CQuickplayPropertyEditor.ui b/src/Editor/CQuickplayPropertyEditor.ui index 65e93a00..40593d0e 100644 --- a/src/Editor/CQuickplayPropertyEditor.ui +++ b/src/Editor/CQuickplayPropertyEditor.ui @@ -61,6 +61,28 @@ + + + + + 0 + 150 + + + + true + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + 5 + + + diff --git a/src/Editor/NDolphinIntegration.h b/src/Editor/NDolphinIntegration.h index 61941714..5bd5535d 100644 --- a/src/Editor/NDolphinIntegration.h +++ b/src/Editor/NDolphinIntegration.h @@ -43,13 +43,17 @@ struct SQuickplayParameters { /** Magic/Version */ static const uint32 kParmsMagic = 0x00BADB01; - static const uint32 kParmsVersion = 1; + static const uint32 kParmsVersion = 2; /** Flags indicating which features are enabled. */ FQuickplayFeatures Features; /** Asset ID of the world/area to load on boot (if JumpToArea is set). */ uint32 BootWorldAssetID; uint32 BootAreaAssetID; + /** Explicit align to 64 bits */ + uint32 __PADDING; + /** Flags indicating which layers to enable on boot (if JumpToArea is set). */ + uint64 BootAreaLayerFlags; /** Location to spawn the player at when the game initially starts up. */ CTransform4f SpawnTransform; @@ -67,6 +71,8 @@ struct SQuickplayParameters Stream.WriteLong( Features.ToInt32() ); Stream.WriteLong( BootWorldAssetID ); Stream.WriteLong( BootAreaAssetID ); + Stream.WriteLong( 0 ); + Stream.WriteLongLong( BootAreaLayerFlags ); SpawnTransform.Write( Stream ); Stream.Close(); diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp index 8afbe008..a97e6882 100644 --- a/src/Editor/WorldEditor/CWorldEditor.cpp +++ b/src/Editor/WorldEditor/CWorldEditor.cpp @@ -219,12 +219,6 @@ CWorldEditor::~CWorldEditor() delete ui; } -/*void CWorldEditor::closeEvent(QCloseEvent *pEvent) -{ - mpCollisionDialog->close(); - mpLinkDialog->close(); -}*/ - bool CWorldEditor::CloseWorld() { if (CheckUnsavedChanges()) diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 0dc6dd56..943f5723 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -1,6 +1,5 @@ #include "CEditorApplication.h" #include "CUIRelay.h" -#include "NDolphinIntegration.h" #include "UICommon.h" #include @@ -76,7 +75,6 @@ public: /** Clean up any resources at the end of application execution */ ~CMain() { - NDolphinIntegration::KillQuickplay(); NGameList::Shutdown(); }