Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add a hacky viewer for inspecting plIcicle flags #82

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/PrpShop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
111 changes: 111 additions & 0 deletions src/PrpShop/PRP/Geometry/QIcicle.cpp
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

#include "QIcicle.h"

#include <QGroupBox>
#include <QGridLayout>

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);
}
52 changes: 52 additions & 0 deletions src/PrpShop/PRP/Geometry/QIcicle.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

#ifndef _QICICLE_H
#define _QICICLE_H

#include <QCheckBox>
#include <QComboBox>
#include <PRP/Geometry/plDrawableSpans.h>
#include <PRP/Geometry/plIcicle.h>
#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
9 changes: 9 additions & 0 deletions src/PrpShop/PRP/Object/QDrawInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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]);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/PrpShop/PRP/Object/QDrawInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "PRP/QCreatable.h"

#include <PRP/Object/plDrawInterface.h>
#include <PRP/Geometry/plIcicle.h>
#include <QCheckBox>
#include <QSpinBox>
#include <QComboBox>
Expand Down
7 changes: 7 additions & 0 deletions src/PrpShop/PRP/QCreatable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/PrpShop/QPlasmaUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down