Added layer toggle support for quickplay

This commit is contained in:
Aruki 2019-04-08 01:04:54 -07:00
parent da30cac887
commit cfd5088a30
8 changed files with 92 additions and 9 deletions

Binary file not shown.

View File

@ -35,6 +35,7 @@ CEditorApplication::CEditorApplication(int& rArgc, char **ppArgv)
CEditorApplication::~CEditorApplication()
{
NDolphinIntegration::KillQuickplay();
delete mpWorldEditor;
delete mpProjectDialog;
}

View File

@ -1,6 +1,8 @@
#include "CQuickplayPropertyEditor.h"
#include "ui_CQuickplayPropertyEditor.h"
#include "UICommon.h"
#include "WorldEditor/CWorldEditor.h"
#include <Core/Resource/Script/CScriptLayer.h>
#include <QFileInfo>
/** 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<CWorldEditor*>(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);
}

View File

@ -1,9 +1,13 @@
#ifndef CQUICKPLAYPROPERTYEDITOR_H
#define CQUICKPLAYPROPERTYEDITOR_H
#include <QListWidgetItem>
#include <QMenu>
#include "NDolphinIntegration.h"
#include <Core/Resource/CWorld.h>
#include <Core/Resource/Area/CGameArea.h>
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

View File

@ -61,6 +61,28 @@
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="LayerList">
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="spacing">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -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();

View File

@ -219,12 +219,6 @@ CWorldEditor::~CWorldEditor()
delete ui;
}
/*void CWorldEditor::closeEvent(QCloseEvent *pEvent)
{
mpCollisionDialog->close();
mpLinkDialog->close();
}*/
bool CWorldEditor::CloseWorld()
{
if (CheckUnsavedChanges())

View File

@ -1,6 +1,5 @@
#include "CEditorApplication.h"
#include "CUIRelay.h"
#include "NDolphinIntegration.h"
#include "UICommon.h"
#include <Common/Log.h>
@ -76,7 +75,6 @@ public:
/** Clean up any resources at the end of application execution */
~CMain()
{
NDolphinIntegration::KillQuickplay();
NGameList::Shutdown();
}