mirror of
https://github.com/zeldaret/ss
synced 2026-08-20 14:14:40 -04:00
lyt_picture match...
Im dreading Material
This commit is contained in:
@@ -35,7 +35,7 @@ void SetTagProcessorImpl(Pane *pPane, ut::TagProcessorBase<wchar_t> *pTagProcess
|
||||
bool IsIncludeAnimationGroupRef(GroupContainer *pGroupContainer, const AnimationGroupRef *groupRefs, u16 bindGroupNum,
|
||||
bool bDescendingBind, Pane *pTargetPane) {
|
||||
for (u16 grpIdx = 0; grpIdx < bindGroupNum; grpIdx++) {
|
||||
Group *pGroup = pGroupContainer->FindGroupByName(groupRefs[grpIdx].name);
|
||||
Group *pGroup = pGroupContainer->FindGroupByName(groupRefs[grpIdx].GetName());
|
||||
for (ut::LinkList<detail::PaneLink, 0>::Iterator paneList = pGroup->GetPaneList()->GetBeginIter();
|
||||
paneList != pGroup->GetPaneList()->GetEndIter(); paneList++) {
|
||||
const Pane *t = paneList->mTarget;
|
||||
@@ -95,9 +95,10 @@ bool Layout::Build(const void *lytResBuf, ResourceAccessor *pResAcsr) {
|
||||
const res::DataBlockHeader *pDataBlockHead = (const res::DataBlockHeader *)dataPtr;
|
||||
switch (pDataBlockHead->kind) {
|
||||
case 'lyt1': // Main Layout
|
||||
{
|
||||
const res::Layout *pResLyt = ((const res::Layout *)dataPtr);
|
||||
mLayoutSize = pResLyt->layoutSize;
|
||||
break;
|
||||
} break;
|
||||
case 'txl1': // Texture List
|
||||
resBlockSet.pTextureList = (const res::TextureList *)dataPtr;
|
||||
break;
|
||||
@@ -112,6 +113,7 @@ bool Layout::Build(const void *lytResBuf, ResourceAccessor *pResAcsr) {
|
||||
case 'pic1': // Picture
|
||||
case 'txt1': // Text Box
|
||||
case 'bnd1': // Boundary Pane
|
||||
{
|
||||
Pane *pPane = BuildPaneObj(pDataBlockHead->kind, dataPtr, resBlockSet);
|
||||
if (pPane) {
|
||||
if (mpRootPane == nullptr) {
|
||||
@@ -122,7 +124,7 @@ bool Layout::Build(const void *lytResBuf, ResourceAccessor *pResAcsr) {
|
||||
}
|
||||
pLastPane = pPane;
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case 'usd1': // User Data
|
||||
pLastPane->SetExtUserDataList((const res::ExtUserDataList *)dataPtr);
|
||||
break;
|
||||
|
||||
@@ -347,12 +347,12 @@ void Pane::Animate(u32 option) {
|
||||
void Pane::AnimateSelf(u32 option) {
|
||||
for (ut::LinkList<AnimationLink, 0>::Iterator it = this->mAnimList.GetBeginIter();
|
||||
it != this->mAnimList.GetEndIter(); it++) {
|
||||
if (!it->mbDisable) {
|
||||
AnimTransform *animTrans = it->mAnimTrans;
|
||||
animTrans->Animate(it->mIdx, this);
|
||||
if (it->IsEnable()) {
|
||||
AnimTransform *animTrans = it->GetAnimTransform();
|
||||
animTrans->Animate(it->GetIndex(), this);
|
||||
}
|
||||
}
|
||||
if (IsVisible() || !(option & 1)) {
|
||||
if (IsVisible() || !detail::TestBit(option, 0)) {
|
||||
if (this->mpMaterial) {
|
||||
mpMaterial->Animate();
|
||||
}
|
||||
@@ -407,7 +407,7 @@ AnimationLink *Pane::FindAnimationLinkSelf(const AnimResource &animRes) {
|
||||
void Pane::SetAnimationEnable(AnimTransform *pAnimTrans, bool bEnable, bool bRecursive) {
|
||||
AnimationLink *pAnimLink = FindAnimationLinkSelf(pAnimTrans);
|
||||
if (pAnimLink) {
|
||||
pAnimLink->mbDisable = !bEnable;
|
||||
pAnimLink->SetEnable(bEnable);
|
||||
}
|
||||
|
||||
u8 materialNum = GetMaterialNum();
|
||||
@@ -426,7 +426,7 @@ void Pane::SetAnimationEnable(AnimTransform *pAnimTrans, bool bEnable, bool bRec
|
||||
void Pane::SetAnimationEnable(const AnimResource &animRes, bool bEnable, bool bRecursive) {
|
||||
AnimationLink *pAnimLink = FindAnimationLinkSelf(animRes);
|
||||
if (pAnimLink) {
|
||||
pAnimLink->mbDisable = !bEnable;
|
||||
pAnimLink->SetEnable(bEnable);
|
||||
}
|
||||
|
||||
u8 materialNum = GetMaterialNum();
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
#include <nw4r/lyt/lyt_bounding.h>
|
||||
#include <nw4r/lyt/lyt_layout.h>
|
||||
#include <nw4r/lyt/lyt_material.h>
|
||||
#include <nw4r/lyt/lyt_picture.h>
|
||||
#include <nw4r/lyt/lyt_texMap.h>
|
||||
|
||||
namespace nw4r {
|
||||
namespace lyt {
|
||||
|
||||
NW4R_UT_RTTI_DEF_DERIVED(Picture, Pane);
|
||||
|
||||
// __ct__Q34nw4r3lyt7PictureFUc
|
||||
// COMPLETE GUESS (needed for the weak Color ctor)
|
||||
Picture::Picture(u8 texNum) {
|
||||
Init(texNum);
|
||||
}
|
||||
|
||||
// __ct__Q34nw4r3lyt7PictureFRCQ34nw4r3lyt6TexMap
|
||||
|
||||
// __ct__Q34nw4r3lyt7PictureFPCQ44nw4r3lyt3res7PictureRCQ34nw4r3lyt11ResBlockSet
|
||||
Picture::Picture(const res::Picture *pResPic, const ResBlockSet &resBlockSet)
|
||||
: Pane(pResPic), mVtxColors(), mTexCoordAry() {
|
||||
u8 texCoordNum = ut::Min<u8>(pResPic->texCoordNum, 8);
|
||||
|
||||
Init(texCoordNum);
|
||||
|
||||
for (int i = 0; i < TEXCOORD_VTX_COUNT; i++) {
|
||||
mVtxColors[i] = pResPic->vtxCols[i];
|
||||
}
|
||||
if (texCoordNum != 0 && !mTexCoordAry.IsEmpty()) {
|
||||
mTexCoordAry.Copy((void *)&pResPic[1], texCoordNum);
|
||||
}
|
||||
const u32 *matOffsTbl = detail::ConvertOffsetToPtr<u32>(resBlockSet.pMaterialList, sizeof(res::MaterialList));
|
||||
const res::Material *pResMaterial =
|
||||
detail::ConvertOffsetToPtr<res::Material>(resBlockSet.pMaterialList, matOffsTbl[pResPic->materialIdx]);
|
||||
mpMaterial = Layout::NewObj<Material>(pResMaterial, resBlockSet);
|
||||
}
|
||||
|
||||
// Init__Q34nw4r3lyt7PictureFUc
|
||||
void Picture::Init(u8 texNum) {
|
||||
ReserveTexCoord(texNum);
|
||||
}
|
||||
|
||||
// __dt__Q34nw4r3lyt7PictureFv
|
||||
Picture::~Picture() {
|
||||
if (mpMaterial && !mpMaterial->IsUserAllocated()) {
|
||||
Layout::DeleteObj(mpMaterial);
|
||||
mpMaterial = nullptr;
|
||||
}
|
||||
mTexCoordAry.Free();
|
||||
}
|
||||
|
||||
// Append__Q34nw4r3lyt7PictureFRCQ34nw4r3lyt6TexMap
|
||||
void Picture::Append(const TexMap &texMap) {
|
||||
if (mpMaterial->GetTextureNum() >= mpMaterial->GetTextureCap() ||
|
||||
mpMaterial->GetTextureNum() >= mpMaterial->GetTexCoordGenCap()) {
|
||||
return;
|
||||
}
|
||||
u8 texIdx = mpMaterial->GetTextureNum();
|
||||
mpMaterial->SetTextureNum(texIdx + 1);
|
||||
mpMaterial->SetTexture(texIdx, texMap);
|
||||
mpMaterial->SetTexCoordGenNum(mpMaterial->GetTextureNum());
|
||||
mpMaterial->SetTexCoordGen(texIdx, TexCoordGen());
|
||||
SetTexCoordNum(mpMaterial->GetTextureNum());
|
||||
if (mSize == Size(0.0f, 0.0f) && mpMaterial->GetTextureNum() == 1) {
|
||||
mSize = detail::GetTextureSize(mpMaterial, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// ReserveTexCoord__Q34nw4r3lyt7PictureFUc
|
||||
void Picture::ReserveTexCoord(u8 texNum) {
|
||||
if (texNum != 0) {
|
||||
mTexCoordAry.Reserve(texNum);
|
||||
}
|
||||
}
|
||||
|
||||
// GetTexCoordNum__Q34nw4r3lyt7PictureCFv
|
||||
|
||||
// SetTexCoordNum__Q34nw4r3lyt7PictureFUc
|
||||
void Picture::SetTexCoordNum(u8 num) {
|
||||
mTexCoordAry.SetSize(num);
|
||||
}
|
||||
|
||||
// GetVtxColor__Q34nw4r3lyt7PictureCFUl
|
||||
ut::Color Picture::GetVtxColor(u32 idx) const {
|
||||
return mVtxColors[idx];
|
||||
}
|
||||
|
||||
// SetVtxColor__Q34nw4r3lyt7PictureFUlQ34nw4r2ut5Color
|
||||
void Picture::SetVtxColor(u32 idx, ut::Color value) {
|
||||
mVtxColors[idx] = value;
|
||||
}
|
||||
|
||||
// GetVtxColorElement__Q34nw4r3lyt7PictureCFUl
|
||||
u8 Picture::GetVtxColorElement(u32 idx) const {
|
||||
return detail::GetVtxColorElement(mVtxColors, idx);
|
||||
}
|
||||
|
||||
// SetVtxColorElement__Q34nw4r3lyt7PictureFUlUc
|
||||
void Picture::SetVtxColorElement(u32 idx, u8 value) {
|
||||
detail::SetVtxColElement(mVtxColors, idx, value);
|
||||
}
|
||||
|
||||
// DrawSelf__Q34nw4r3lyt7PictureFRCQ34nw4r3lyt8DrawInfo
|
||||
void Picture::DrawSelf(const DrawInfo &drawInfo) {
|
||||
if (mpMaterial) {
|
||||
LoadMtx(drawInfo);
|
||||
bool bUseVtxCol = mpMaterial->SetupGX(detail::IsModulateVertexColor(mVtxColors, mGlbAlpha), mGlbAlpha);
|
||||
detail::SetVertexFormat(bUseVtxCol, mTexCoordAry.GetSize());
|
||||
detail::DrawQuad(GetVtxPos(), mSize, mTexCoordAry.GetSize(), mTexCoordAry.GetArray(),
|
||||
bUseVtxCol ? mVtxColors : nullptr, mGlbAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace lyt
|
||||
|
||||
} // namespace nw4r
|
||||
|
||||
Reference in New Issue
Block a user