From f966c056189c316407070d38e76c36dde3fc2a11 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Wed, 5 Aug 2015 20:50:25 -0700 Subject: [PATCH] Add a hacky viewer for inspecting plIcicle flags --- src/PrpShop/CMakeLists.txt | 2 + src/PrpShop/PRP/Geometry/QIcicle.cpp | 111 ++++++++++++++++++++++ src/PrpShop/PRP/Geometry/QIcicle.h | 52 ++++++++++ src/PrpShop/PRP/Object/QDrawInterface.cpp | 9 ++ src/PrpShop/PRP/Object/QDrawInterface.h | 1 + src/PrpShop/PRP/QCreatable.cpp | 7 ++ src/PrpShop/QPlasmaUtils.h | 1 + 7 files changed, 183 insertions(+) create mode 100644 src/PrpShop/PRP/Geometry/QIcicle.cpp create mode 100644 src/PrpShop/PRP/Geometry/QIcicle.h diff --git a/src/PrpShop/CMakeLists.txt b/src/PrpShop/CMakeLists.txt index 71c4963..9ff5db8 100644 --- a/src/PrpShop/CMakeLists.txt +++ b/src/PrpShop/CMakeLists.txt @@ -18,6 +18,7 @@ set(PrpShop_Headers PRP/Avatar/QMultistageBehMod.h PRP/Avatar/QAvLadderMod.h PRP/Avatar/QSeekPointMod.h + PRP/Geometry/QIcicle.h PRP/GUI/QGUIButtonMod.h PRP/GUI/QGUICheckBoxCtrl.h PRP/GUI/QGUIClickMapCtrl.h @@ -88,6 +89,7 @@ set(PrpShop_Sources PRP/Avatar/QMultistageBehMod.cpp PRP/Avatar/QAvLadderMod.cpp PRP/Avatar/QSeekPointMod.cpp + PRP/Geometry/QIcicle.cpp PRP/GUI/QGUIButtonMod.cpp PRP/GUI/QGUICheckBoxCtrl.cpp PRP/GUI/QGUIClickMapCtrl.cpp diff --git a/src/PrpShop/PRP/Geometry/QIcicle.cpp b/src/PrpShop/PRP/Geometry/QIcicle.cpp new file mode 100644 index 0000000..b1c08a4 --- /dev/null +++ b/src/PrpShop/PRP/Geometry/QIcicle.cpp @@ -0,0 +1,111 @@ +/* This file is part of PlasmaShop. + * + * PlasmaShop is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlasmaShop is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PlasmaShop. If not, see . + */ + +#include "QIcicle.h" + +#include +#include + +QIcicle::QIcicle(plCreatable* pCre, size_t idx, QWidget* parent) + : QCreatable(pCre, kSpan_Type|idx, parent) +{ + plDrawableSpans* dspan = plDrawableSpans::Convert(fCreatable); + fSpan = dspan->getIcicle(idx); + + setWindowTitle(pqGetFriendlyClassName(dspan->ClassIndex()) + + ": " + st2qstr(dspan->getKey()->getName())); + + QIcon ico = pqGetTypeIcon(dspan->ClassIndex()); + if (!ico.isNull()) + setWindowIcon(ico); + + QGroupBox* grpFlags = new QGroupBox(tr("Flags"), this); + fFlags[kPropNoDraw] = new QCheckBox(tr("No Draw"), grpFlags); + fFlags[kPropNoShadowCast] = new QCheckBox(tr("No Shadow Cast"), grpFlags); + fFlags[kPropFacesSortable] = new QCheckBox(tr("Faces Sortable"), grpFlags); + fFlags[kPropVolatile] = new QCheckBox(tr("Volatile"), grpFlags); + fFlags[kWaterHeight] = new QCheckBox(tr("Water Height"), grpFlags); + fFlags[kPropRunTimeLight] = new QCheckBox(tr("Run-Time Light"), grpFlags); + fFlags[kPropReverseSort] = new QCheckBox(tr("Reverse Sort"), grpFlags); + fFlags[kPropHasPermaLights] = new QCheckBox(tr("PermaLights"), grpFlags); + fFlags[kPropHasPermaProjs] = new QCheckBox(tr("PermaProjs"), grpFlags); + fFlags[kPropMatHasSpecular] = new QCheckBox(tr("Has Specular"), grpFlags); + fFlags[kPropProjAsVtx] = new QCheckBox(tr("ProjAsVtx"), grpFlags); + fFlags[kPropSkipProjection] = new QCheckBox(tr("Skip Projection"), grpFlags); + fFlags[kPropNoShadow] = new QCheckBox(tr("No Shadow"), grpFlags); + fFlags[kPropForceShadow] = new QCheckBox(tr("Force Shadow"), grpFlags); + fFlags[kPropDisableNormal] = new QCheckBox(tr("Disable Normal"), grpFlags); + fFlags[kPropCharacter] = new QCheckBox(tr("Character"), grpFlags); + fFlags[kPartialSort] = new QCheckBox(tr("Partial Sort"), grpFlags); + fFlags[kVisLOS] = new QCheckBox(tr("Vis LOS"), grpFlags); + + fLightingType = new QComboBox(grpFlags); + fLightingType->addItems(QStringList() << "Material Lighting" << "Vertex Preshaded Lighting" << "Vertex Non-Preshaded Lighting" << "Projection" << "Shadow Erase" << "Shadow"); + fLightingType->setCurrentIndex(0); + + int lighting = (fSpan->getProps() & 0x3E00) >> 8; + for (int i = 0; i < 6; i++) { + if (lighting & (1 << i)) { + fLightingType->setCurrentIndex(i); + } + } + + fFlags[kPropNoDraw]->setChecked((fSpan->getProps() & plSpan::kPropNoDraw) != 0); + fFlags[kPropNoShadowCast]->setChecked((fSpan->getProps() & plSpan::kPropNoShadowCast) != 0); + fFlags[kPropFacesSortable]->setChecked((fSpan->getProps() & plSpan::kPropFacesSortable) != 0); + fFlags[kPropVolatile]->setChecked((fSpan->getProps() & plSpan::kPropVolatile) != 0); + fFlags[kWaterHeight]->setChecked((fSpan->getProps() & plSpan::kWaterHeight) != 0); + fFlags[kPropRunTimeLight]->setChecked((fSpan->getProps() & plSpan::kPropRunTimeLight) != 0); + fFlags[kPropReverseSort]->setChecked((fSpan->getProps() & plSpan::kPropReverseSort) != 0); + fFlags[kPropHasPermaLights]->setChecked((fSpan->getProps() & plSpan::kPropHasPermaLights) != 0); + fFlags[kPropHasPermaProjs]->setChecked((fSpan->getProps() & plSpan::kPropHasPermaProjs) != 0); + fFlags[kPropMatHasSpecular]->setChecked((fSpan->getProps() & plSpan::kPropMatHasSpecular) != 0); + fFlags[kPropProjAsVtx]->setChecked((fSpan->getProps() & plSpan::kPropProjAsVtx) != 0); + fFlags[kPropSkipProjection]->setChecked((fSpan->getProps() & plSpan::kPropSkipProjection) != 0); + fFlags[kPropNoShadow]->setChecked((fSpan->getProps() & plSpan::kPropNoShadow) != 0); + fFlags[kPropForceShadow]->setChecked((fSpan->getProps() & plSpan::kPropForceShadow) != 0); + fFlags[kPropDisableNormal]->setChecked((fSpan->getProps() & plSpan::kPropDisableNormal) != 0); + fFlags[kPropCharacter]->setChecked((fSpan->getProps() & plSpan::kPropCharacter) != 0); + fFlags[kPartialSort]->setChecked((fSpan->getProps() & plSpan::kPartialSort) != 0); + fFlags[kVisLOS]->setChecked((fSpan->getProps() & plSpan::kVisLOS) != 0); + + QGridLayout* layFlags = new QGridLayout(grpFlags); + layFlags->setVerticalSpacing(0); + layFlags->setHorizontalSpacing(8); + layFlags->addWidget(fFlags[kPropNoDraw], 0, 0); + layFlags->addWidget(fFlags[kPropNoShadowCast], 0, 1); + layFlags->addWidget(fFlags[kPropFacesSortable], 0, 2); + layFlags->addWidget(fFlags[kPropVolatile], 0, 3); + layFlags->addWidget(fFlags[kWaterHeight], 1, 0); + layFlags->addWidget(fFlags[kPropRunTimeLight], 1, 1); + layFlags->addWidget(fFlags[kPropReverseSort], 1, 2); + layFlags->addWidget(fFlags[kPropHasPermaLights], 1, 3); + layFlags->addWidget(fFlags[kPropHasPermaProjs], 2, 0); + layFlags->addWidget(fFlags[kPropMatHasSpecular], 2, 1); + layFlags->addWidget(fFlags[kPropProjAsVtx], 2, 2); + layFlags->addWidget(fFlags[kPropSkipProjection], 2, 3); + layFlags->addWidget(fFlags[kPropNoShadow], 3, 0); + layFlags->addWidget(fFlags[kPropForceShadow], 3, 1); + layFlags->addWidget(fFlags[kPropDisableNormal], 3, 2); + layFlags->addWidget(fFlags[kPropCharacter], 3, 3); + layFlags->addWidget(fLightingType, 4, 0, 1, 2); + layFlags->addWidget(fFlags[kPartialSort], 4, 2); + layFlags->addWidget(fFlags[kVisLOS], 4, 3); + + QGridLayout* layout = new QGridLayout(this); + layout->setContentsMargins(8, 8, 8, 8); + layout->addWidget(grpFlags, 0, 0, 1, 2); +} diff --git a/src/PrpShop/PRP/Geometry/QIcicle.h b/src/PrpShop/PRP/Geometry/QIcicle.h new file mode 100644 index 0000000..f77f587 --- /dev/null +++ b/src/PrpShop/PRP/Geometry/QIcicle.h @@ -0,0 +1,52 @@ +/* This file is part of PlasmaShop. + * + * PlasmaShop is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlasmaShop is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PlasmaShop. If not, see . + */ + +#ifndef _QICICLE_H +#define _QICICLE_H + +#include +#include +#include +#include +#include "PRP/QCreatable.h" +#include "PRP/QKeyList.h" +#include "PRP/QObjLink.h" + +class QIcicle : public QCreatable { + Q_OBJECT + +protected: + enum { + kPropNoDraw, kPropNoShadowCast, kPropFacesSortable, kPropVolatile, + kWaterHeight, kPropRunTimeLight, kPropReverseSort, kPropHasPermaLights, + kPropHasPermaProjs, kPropMatHasSpecular, kPropProjAsVtx, + kPropSkipProjection, kPropNoShadow, kPropForceShadow, + kPropDisableNormal, kPropCharacter, kPartialSort, kVisLOS, kNumFlags + }; + + plIcicle* fSpan; + + QComboBox* fLightingType; + QCheckBox* fFlags[kNumFlags]; + QKeyList* fLights; + QKeyList* fProjs; + QCreatableLink* fMatLink; + +public: + QIcicle(plCreatable* pCre, size_t idx, QWidget* parent = NULL); +}; + +#endif diff --git a/src/PrpShop/PRP/Object/QDrawInterface.cpp b/src/PrpShop/PRP/Object/QDrawInterface.cpp index b1ab492..fdef022 100644 --- a/src/PrpShop/PRP/Object/QDrawInterface.cpp +++ b/src/PrpShop/PRP/Object/QDrawInterface.cpp @@ -52,6 +52,7 @@ void QDrawableList::contextMenuEvent(QContextMenuEvent* evt) QAction* delObjItem = menu.addAction(tr("Remove Object")); menu.addSeparator(); QAction* openMatItem = menu.addAction(tr("Open Materials")); + QAction* openIcicle = menu.addAction(tr("Open Icicles")); if (currentItem() == NULL) delObjItem->setEnabled(false); @@ -76,6 +77,14 @@ void QDrawableList::contextMenuEvent(QContextMenuEvent* evt) hsKeyedObject* mat = mgr->getObject(mats[ice->getMaterialIdx()]); PrpShopMain::Instance()->editCreatable(mat); } + } else if (sel == openIcicle) { + plResManager* mgr = PrpShopMain::ResManager(); + int idx = indexOfTopLevelItem(currentItem()); + plDrawableSpans* dspans = plDrawableSpans::Convert(mgr->getObject(fKeys[idx])); + plDISpanIndex dis = dspans->getDIIndex(fDrawKeys[idx]); + for (size_t i = 0; i < dis.fIndices.size(); i++) { + PrpShopMain::Instance()->editCreatable(dspans, kSpan_Type | dis.fIndices[i]); + } } } diff --git a/src/PrpShop/PRP/Object/QDrawInterface.h b/src/PrpShop/PRP/Object/QDrawInterface.h index 954ef35..051c825 100644 --- a/src/PrpShop/PRP/Object/QDrawInterface.h +++ b/src/PrpShop/PRP/Object/QDrawInterface.h @@ -20,6 +20,7 @@ #include "PRP/QCreatable.h" #include +#include #include #include #include diff --git a/src/PrpShop/PRP/QCreatable.cpp b/src/PrpShop/PRP/QCreatable.cpp index ac822f4..372fdb1 100644 --- a/src/PrpShop/PRP/QCreatable.cpp +++ b/src/PrpShop/PRP/QCreatable.cpp @@ -75,6 +75,7 @@ void QCreatable::closeEvent(QCloseEvent*) #include "PRP/Avatar/QMultistageBehMod.h" #include "PRP/Avatar/QAvLadderMod.h" #include "PRP/Avatar/QSeekPointMod.h" +#include "PRP/Geometry/QIcicle.h" #include "PRP/GUI/QGUIButtonMod.h" #include "PRP/GUI/QGUICheckBoxCtrl.h" #include "PRP/GUI/QGUIClickMapCtrl.h" @@ -134,6 +135,12 @@ QCreatable* pqMakeCreatableForm(plCreatable* pCre, QWidget* parent, int forceTyp if ((type & kHex_Type) != 0) return new QHexViewer(pCre, parent); + if ((type & kSpan_Type) != 0) { + // pCre is a plDrawableSpan object + // type is kSpanType ORed with the index of the icicle we want + return new QIcicle(pCre, type & ~kSpan_Type, parent); + } + switch (type) { // Keyed Object types case k2WayWinAudible: diff --git a/src/PrpShop/QPlasmaUtils.h b/src/PrpShop/QPlasmaUtils.h index 565cea7..06796da 100644 --- a/src/PrpShop/QPlasmaUtils.h +++ b/src/PrpShop/QPlasmaUtils.h @@ -33,6 +33,7 @@ enum kTargets_Type = 0x4000, kRESERVED_Type = 0x8000, // 0x8000 is reserved for null keyed objects kHex_Type = 0x10000, + kSpan_Type = 0x20000, kRealType_Mask = 0x8FFF, kPreviewSceneNode = kPreview_Type | kSceneNode,