From 8caaf4fa641fffb721440c48307efa0590c4ec52 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Oct 2020 16:33:11 +0200 Subject: [PATCH] - menu transitions are working again. --- source/common/2d/v_2ddrawer.cpp | 8 ++++++++ source/common/2d/v_draw.cpp | 5 +++++ source/common/2d/v_draw.h | 2 ++ source/common/menu/menu.cpp | 6 +++++- source/common/menu/menu.h | 3 ++- wadsrc/static/zscript/base.zs | 1 + wadsrc/static/zscript/ui/menu/listmenu.zs | 2 ++ wadsrc/static/zscript/ui/menu/menu.zs | 6 ++++-- 8 files changed, 29 insertions(+), 4 deletions(-) diff --git a/source/common/2d/v_2ddrawer.cpp b/source/common/2d/v_2ddrawer.cpp index b79da9e73..22d8565a4 100644 --- a/source/common/2d/v_2ddrawer.cpp +++ b/source/common/2d/v_2ddrawer.cpp @@ -439,6 +439,9 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) std::swap(v1, v2); } + auto osave = offset; + if (parms.nooffset) offset = { 0,0 }; + if (parms.rotateangle == 0) { double x = parms.x - parms.left * xscale; @@ -521,6 +524,7 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) dg.mIndexCount += 6; AddIndices(dg.mVertIndex, 6, 0, 1, 2, 1, 3, 2); AddCommand(&dg); + offset = osave; } //========================================================================== @@ -561,6 +565,9 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms) shape->dirty = false; } + auto osave = offset; + if (parms.nooffset) offset = { 0,0 }; + double minx = 16383, miny = 16383, maxx = -16384, maxy = -16384; for ( int i=0; imIndices[i], shape->mIndices[i+1], shape->mIndices[i+2]); } AddCommand(&dg); + offset = osave; } //========================================================================== diff --git a/source/common/2d/v_draw.cpp b/source/common/2d/v_draw.cpp index c6ca5188b..32b55f1ca 100644 --- a/source/common/2d/v_draw.cpp +++ b/source/common/2d/v_draw.cpp @@ -703,6 +703,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double parms->rotateangle = 0; parms->flipoffsets = false; parms->indexed = false; + parms->nooffset = false; // Parse the tag list for attributes. (For floating point attributes, // consider that the C ABI dictates that all floats be promoted to @@ -914,6 +915,10 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double parms->flipoffsets = ListGetInt(tags); break; + case DTA_NoOffset: + parms->nooffset = ListGetInt(tags); + break; + case DTA_SrcX: parms->srcx = ListGetDouble(tags) / img->GetDisplayWidth(); break; diff --git a/source/common/2d/v_draw.h b/source/common/2d/v_draw.h index dc9b8d28c..b7eafbbec 100644 --- a/source/common/2d/v_draw.h +++ b/source/common/2d/v_draw.h @@ -131,6 +131,7 @@ enum DTA_FlipOffsets, // Flips offsets when using DTA_FlipX and DTA_FlipY, this cannot be automatic due to unexpected behavior with unoffsetted graphics. DTA_Indexed, // Use an indexed texture combined with the given translation. DTA_CleanTop, // Like DTA_Clean but aligns to the top of the screen instead of the center. + DTA_NoOffset, // Ignore 2D drawer's offset. }; @@ -198,6 +199,7 @@ struct DrawParms bool burn; bool flipoffsets; bool indexed; + bool nooffset; int8_t fsscalemode; double srcx, srcy; double srcwidth, srcheight; diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 1c08e4d6d..7e6ce1404 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -230,7 +230,7 @@ bool MenuTransition::Draw() double now = I_GetTimeNS() * (120. / 1'000'000'000); if (now < start + length) { - double factor = 120 * screen->GetWidth() / screen->GetHeight(); + double factor = screen->GetWidth()/2; double phase = (now - start) / double(length) * M_PI + M_PI / 2; DVector2 origin; @@ -241,6 +241,8 @@ bool MenuTransition::Draw() origin.X = factor * dir * (sin(phase) + 1.); twod->SetOffset(origin); current->CallDrawer(); + origin = { 0,0 }; + twod->SetOffset(origin); return true; } if (destroyprev && previous) previous->Destroy(); @@ -977,6 +979,7 @@ DEFINE_FIELD(DMenu, mMouseCapture); DEFINE_FIELD(DMenu, mBackbuttonSelected); DEFINE_FIELD(DMenu, DontDim); DEFINE_FIELD(DMenu, DontBlur); +DEFINE_FIELD(DMenu, AnimatedTransition); DEFINE_FIELD(DMenuDescriptor, mMenuName) DEFINE_FIELD(DMenuDescriptor, mNetgameMessage) @@ -1002,6 +1005,7 @@ DEFINE_FIELD(DListMenuDescriptor, mAutoselect) DEFINE_FIELD(DListMenuDescriptor, mFont) DEFINE_FIELD(DListMenuDescriptor, mFontColor) DEFINE_FIELD(DListMenuDescriptor, mFontColor2) +DEFINE_FIELD(DListMenuDescriptor, mAnimatedTransition) DEFINE_FIELD(DListMenuDescriptor, mCenter) DEFINE_FIELD(DListMenuDescriptor, mVirtWidth) DEFINE_FIELD(DListMenuDescriptor, mVirtHeight) diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index 7b236ee48..9be66b2ec 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -213,6 +213,7 @@ public: bool mBackbuttonSelected; bool DontDim; bool DontBlur; + bool AnimatedTransition; static int InMenu; DMenu(DMenu *parent = NULL); @@ -223,7 +224,7 @@ public: bool CallMenuEvent(int mkey, bool fromcontroller); void CallTicker(); void CallDrawer(); - bool canAnimate() { return false; } + bool canAnimate() { return AnimatedTransition; } }; //============================================================================= diff --git a/wadsrc/static/zscript/base.zs b/wadsrc/static/zscript/base.zs index 17f9e680f..fb381262a 100644 --- a/wadsrc/static/zscript/base.zs +++ b/wadsrc/static/zscript/base.zs @@ -348,6 +348,7 @@ enum DrawTextureTags DTA_FlipOffsets, // Flips offsets when using DTA_FlipX and DTA_FlipY, this cannot be automatic due to unexpected behavior with unoffsetted graphics. DTA_Indexed, // Use an indexed texture combined with the given translation. DTA_CleanTop, // Like DTA_Clean but aligns to the top of the screen instead of the center. + DTA_NoOffset, // Ignore 2D drawer's offset. }; diff --git a/wadsrc/static/zscript/ui/menu/listmenu.zs b/wadsrc/static/zscript/ui/menu/listmenu.zs index 917fe270c..c10256518 100644 --- a/wadsrc/static/zscript/ui/menu/listmenu.zs +++ b/wadsrc/static/zscript/ui/menu/listmenu.zs @@ -21,6 +21,7 @@ class ListMenuDescriptor : MenuDescriptor native native int mFontColor; native int mFontColor2; native bool mCenter; + native bool mAnimatedTransition; native int mVirtWidth, mVirtHeight; native void Reset(); @@ -51,6 +52,7 @@ class ListMenu : Menu { Super.Init(parent); mDesc = desc; + AnimatedTransition = mDesc.mAnimatedTransition; if (desc.mCenter) { double center = 160; diff --git a/wadsrc/static/zscript/ui/menu/menu.zs b/wadsrc/static/zscript/ui/menu/menu.zs index 10b7adb58..7c08a1f45 100644 --- a/wadsrc/static/zscript/ui/menu/menu.zs +++ b/wadsrc/static/zscript/ui/menu/menu.zs @@ -94,6 +94,7 @@ class Menu : Object native ui version("2.4") native bool mBackbuttonSelected; native bool DontDim; native bool DontBlur; + native bool AnimatedTransition; native static int MenuTime(); native static Menu GetCurrentMenu(); @@ -116,6 +117,7 @@ class Menu : Object native ui version("2.4") mBackbuttonSelected = false; DontDim = false; DontBlur = false; + AnimatedTransition = false; } //============================================================================= @@ -241,11 +243,11 @@ class Menu : Object native ui version("2.4") int y = (!(m_show_backbutton&2))? 0:screen.GetHeight() - h; if (mBackbuttonSelected && (mMouseCapture || m_use_mouse == 1)) { - screen.DrawTexture(tex, true, x, y, DTA_CleanNoMove, true, DTA_ColorOverlay, Color(40, 255,255,255)); + screen.DrawTexture(tex, true, x, y, DTA_CleanNoMove, true, DTA_ColorOverlay, Color(40, 255,255,255), DTA_NOOFFSET, true); } else { - screen.DrawTexture(tex, true, x, y, DTA_CleanNoMove, true, DTA_Alpha, BackbuttonAlpha); + screen.DrawTexture(tex, true, x, y, DTA_CleanNoMove, true, DTA_Alpha, BackbuttonAlpha, DTA_NOOFFSET, true); } } }