From 003f4a035e18a0c0cf67e5691d1d43dfbfcaf840 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Nov 2022 11:14:38 +0100 Subject: [PATCH] - backend update from GZDoom menu enhancements, IQM indices and an important fix in the sound system. --- source/common/audio/sound/s_soundinternal.h | 2 +- source/common/menu/menu.cpp | 7 ++++ source/common/menu/menu.h | 7 ++++ source/common/menu/menudef.cpp | 44 ++++++++++++++++++++- source/common/models/model.h | 2 +- source/common/models/model_iqm.h | 2 +- source/common/models/models_iqm.cpp | 19 ++++++--- 7 files changed, 74 insertions(+), 9 deletions(-) diff --git a/source/common/audio/sound/s_soundinternal.h b/source/common/audio/sound/s_soundinternal.h index c206ccd7e..c38f8d4ce 100644 --- a/source/common/audio/sound/s_soundinternal.h +++ b/source/common/audio/sound/s_soundinternal.h @@ -357,7 +357,7 @@ public: bool isValidSoundId(FSoundID sid) { int id = sid.index(); - return id > 0 && id < (int)S_sfx.Size() && !S_sfx[id].bTentative && S_sfx[id].lumpnum != sfx_empty; + return id > 0 && id < (int)S_sfx.Size() && !S_sfx[id].bTentative && (S_sfx[id].lumpnum != sfx_empty || S_sfx[id].bRandomHeader || S_sfx[id].link != sfxinfo_t::NO_LINK); } template bool EnumerateChannels(func callback) diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 6a8ce3ddc..deee74597 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -1033,6 +1033,8 @@ DEFINE_FIELD(DListMenuDescriptor, mFontColor2) DEFINE_FIELD(DListMenuDescriptor, mAnimatedTransition) DEFINE_FIELD(DListMenuDescriptor, mAnimated) DEFINE_FIELD(DListMenuDescriptor, mCenter) +DEFINE_FIELD(DListMenuDescriptor, mDontDim) +DEFINE_FIELD(DListMenuDescriptor, mDontBlur) DEFINE_FIELD(DListMenuDescriptor, mVirtWidth) DEFINE_FIELD(DListMenuDescriptor, mVirtHeight) @@ -1045,6 +1047,9 @@ DEFINE_FIELD(DOptionMenuDescriptor, mScrollPos) DEFINE_FIELD(DOptionMenuDescriptor, mIndent) DEFINE_FIELD(DOptionMenuDescriptor, mPosition) DEFINE_FIELD(DOptionMenuDescriptor, mDontDim) +DEFINE_FIELD(DOptionMenuDescriptor, mDontBlur) +DEFINE_FIELD(DOptionMenuDescriptor, mAnimatedTransition) +DEFINE_FIELD(DOptionMenuDescriptor, mAnimated) DEFINE_FIELD(DOptionMenuDescriptor, mFont) DEFINE_FIELD(FOptionMenuSettings, mTitleColor) @@ -1063,6 +1068,8 @@ DEFINE_FIELD(DImageScrollerDescriptor,textFont) DEFINE_FIELD(DImageScrollerDescriptor, textScale) DEFINE_FIELD(DImageScrollerDescriptor, mAnimatedTransition) DEFINE_FIELD(DImageScrollerDescriptor, mAnimated) +DEFINE_FIELD(DImageScrollerDescriptor, mDontDim) +DEFINE_FIELD(DImageScrollerDescriptor, mDontBlur) DEFINE_FIELD(DImageScrollerDescriptor, virtWidth) DEFINE_FIELD(DImageScrollerDescriptor, virtHeight) diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index aaeecbcd4..3bd23b3b8 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -91,6 +91,8 @@ public: bool mFromEngine; bool mAnimated; bool mAnimatedTransition; + bool mDontDim; + bool mDontBlur; int mVirtWidth; int mVirtHeight; bool mCustomSizeSet; @@ -124,6 +126,9 @@ public: int mIndent; int mPosition; bool mDontDim; + bool mDontBlur; + bool mAnimatedTransition; + bool mAnimated; FFont *mFont; void CalcIndent(); @@ -143,6 +148,8 @@ public: double textScale; bool mAnimatedTransition; bool mAnimated; + bool mDontDim; + bool mDontBlur; int virtWidth, virtHeight; }; diff --git a/source/common/menu/menudef.cpp b/source/common/menu/menudef.cpp index 1b25fcdad..7076f8b7b 100644 --- a/source/common/menu/menudef.cpp +++ b/source/common/menu/menudef.cpp @@ -358,6 +358,14 @@ static void DoParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &s { desc->mAnimated = true; } + else if (sc.Compare("DontDim")) + { + desc->mDontDim = true; + } + else if (sc.Compare("DontBlur")) + { + desc->mDontBlur = true; + } else if (sc.Compare("MouseWindow")) { sc.MustGetNumber(); @@ -763,6 +771,10 @@ static void ParseListMenu(FScanner &sc) desc->mFromEngine = fileSystem.GetFileContainer(sc.LumpNum) == 0; // flags menu if the definition is from the IWAD. desc->mVirtWidth = -2; desc->mCustomSizeSet = false; + desc->mAnimatedTransition = false; + desc->mAnimated = false; + desc->mDontDim = false; + desc->mDontBlur = false; desc->mForceList = false; if (DefaultListMenuSettings->mCustomSizeSet) { @@ -1020,6 +1032,22 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc, int i sc.MustGetNumber(); desc->mIndent = sc.Number; } + else if (sc.Compare("AnimatedTransition")) + { + desc->mAnimatedTransition = true; + } + else if (sc.Compare("Animated")) + { + desc->mAnimated = true; + } + else if (sc.Compare("DontDim")) + { + desc->mDontDim = true; + } + else if (sc.Compare("DontBlur")) + { + desc->mDontBlur = true; + } else { bool success = false; @@ -1189,7 +1217,10 @@ static void ParseOptionMenu(FScanner &sc) desc->mPosition = DefaultOptionMenuSettings->mPosition; desc->mScrollTop = DefaultOptionMenuSettings->mScrollTop; desc->mIndent = DefaultOptionMenuSettings->mIndent; - desc->mDontDim = DefaultOptionMenuSettings->mDontDim; + desc->mDontDim = false; + desc->mDontBlur = false; + desc->mAnimatedTransition = false; + desc->mAnimated = false; desc->mProtected = sc.CheckString("protected"); ParseOptionMenuBody(sc, desc, -1); @@ -1275,6 +1306,14 @@ static void ParseImageScrollerBody(FScanner& sc, DImageScrollerDescriptor* desc) { desc->mAnimated = true; } + else if (sc.Compare("DontDim")) + { + desc->mDontDim = true; + } + else if (sc.Compare("DontBlur")) + { + desc->mDontBlur = true; + } else if (sc.Compare("textBackground")) { sc.MustGetString(); @@ -1450,7 +1489,10 @@ static void ParseImageScroller(FScanner& sc) desc->textBackgroundBrightness = 0xffffffff; desc->textFont = SmallFont; desc->textScale = 1; + desc->mDontDim = false; + desc->mDontBlur = false; desc->mAnimatedTransition = false; + desc->mAnimated = false; desc->virtWidth = 320; desc->virtHeight = 200; diff --git a/source/common/models/model.h b/source/common/models/model.h index 6084e5407..dc4d64476 100644 --- a/source/common/models/model.h +++ b/source/common/models/model.h @@ -77,7 +77,7 @@ public: virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) = 0; virtual float getAspectFactor(float vscale) { return 1.f; } virtual const TArray* AttachAnimationData() { return nullptr; }; - virtual const TArray CalculateBones(int frame1, int frame2, double inter, const TArray& animationData, DBoneComponents* bones, int index) { return {}; }; + virtual const TArray CalculateBones(int frame1, int frame2, double inter, const TArray* animationData, DBoneComponents* bones, int index) { return {}; }; void SetVertexBuffer(int type, IModelVertexBuffer *buffer) { mVBuf[type] = buffer; } IModelVertexBuffer *GetVertexBuffer(int type) const { return mVBuf[type]; } diff --git a/source/common/models/model_iqm.h b/source/common/models/model_iqm.h index cd87a78f3..3ab956689 100644 --- a/source/common/models/model_iqm.h +++ b/source/common/models/model_iqm.h @@ -116,7 +116,7 @@ public: void BuildVertexBuffer(FModelRenderer* renderer) override; void AddSkins(uint8_t* hitlist, const FTextureID* surfaceskinids) override; const TArray* AttachAnimationData() override; - const TArray CalculateBones(int frame1, int frame2, double inter, const TArray& animationData, DBoneComponents* bones, int index) override; + const TArray CalculateBones(int frame1, int frame2, double inter, const TArray* animationData, DBoneComponents* bones, int index) override; private: void LoadGeometry(); diff --git a/source/common/models/models_iqm.cpp b/source/common/models/models_iqm.cpp index 514fb2833..95c2549de 100644 --- a/source/common/models/models_iqm.cpp +++ b/source/common/models/models_iqm.cpp @@ -434,10 +434,19 @@ void IQMModel::UnloadGeometry() int IQMModel::FindFrame(const char* name, bool nodefault) { - // This doesn't really mean all that much for IQM + // [MK] allow looking up frames by animation name plus offset (using a colon as separator) + const char* colon = strrchr(name,':'); + int nlen = (colon==nullptr)?strlen(name):(colon-name); for (unsigned i = 0; i < Anims.Size(); i++) { - if (!stricmp(name, Anims[i].Name.GetChars())) return i; + if (!strnicmp(name, Anims[i].Name.GetChars(), nlen)) + { + // if no offset is given, return the first frame + if (colon == nullptr) return Anims[i].FirstFrame; + unsigned offset = atoi(colon+1); + if (offset >= Anims[i].NumFrames) return FErr_NotFound; + return Anims[i].FirstFrame+offset; + } } return FErr_NotFound; } @@ -514,9 +523,9 @@ const TArray* IQMModel::AttachAnimationData() return &TRSData; } -const TArray IQMModel::CalculateBones(int frame1, int frame2, double inter, const TArray& animationData, DBoneComponents* boneComponentData, int index) +const TArray IQMModel::CalculateBones(int frame1, int frame2, double inter, const TArray* animationData, DBoneComponents* boneComponentData, int index) { - const TArray& animationFrames = &animationData ? animationData : TRSData; + const TArray& animationFrames = animationData ? *animationData : TRSData; if (Joints.Size() > 0) { int numbones = Joints.Size(); @@ -604,4 +613,4 @@ const TArray IQMModel::CalculateBones(int frame1, int frame2, double i return bones; } return {}; -} \ No newline at end of file +}