mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
- menu transition animation added.
This commit is contained in:
parent
dce633de8b
commit
2ed598bb6c
2 changed files with 53 additions and 0 deletions
|
@ -49,6 +49,8 @@
|
||||||
#include "v_draw.h"
|
#include "v_draw.h"
|
||||||
#include "gamecontrol.h"
|
#include "gamecontrol.h"
|
||||||
#include "fx_man.h"
|
#include "fx_man.h"
|
||||||
|
#include "pragmas.h"
|
||||||
|
#include "build.h"
|
||||||
|
|
||||||
void RegisterDukeMenus();
|
void RegisterDukeMenus();
|
||||||
extern bool rotatesprite_2doverride;
|
extern bool rotatesprite_2doverride;
|
||||||
|
@ -86,6 +88,56 @@ static bool MenuEnabled = true;
|
||||||
#define KEY_REPEAT_DELAY (MENU_TICRATE*5/12)
|
#define KEY_REPEAT_DELAY (MENU_TICRATE*5/12)
|
||||||
#define KEY_REPEAT_RATE (3)
|
#define KEY_REPEAT_RATE (3)
|
||||||
|
|
||||||
|
enum MenuTransitionType
|
||||||
|
{ // Note: This enum is for logical categories, not visual types.
|
||||||
|
MA_None,
|
||||||
|
MA_Return,
|
||||||
|
MA_Advance,
|
||||||
|
} ;
|
||||||
|
|
||||||
|
struct MenuTransition
|
||||||
|
{
|
||||||
|
DMenu *previous;
|
||||||
|
DMenu *current;
|
||||||
|
|
||||||
|
int32_t start;
|
||||||
|
int32_t length;
|
||||||
|
int32_t dir;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool M_StartTransition(DMenu *from, DMenu *to, MenuTransitionType animtype, MenuTransition &transition)
|
||||||
|
{
|
||||||
|
if (!from->canAnimate || !to->canAnimate || animtype == MA_None)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transition.start = (int32_t) totalclock;
|
||||||
|
transition.length = 30;
|
||||||
|
transition.dir = animtype == MA_Advance? 1 : -1;
|
||||||
|
transition.previous = from;
|
||||||
|
transition.current = to;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool M_DrawTransition(MenuTransition &transition)
|
||||||
|
{
|
||||||
|
if (totalclock < transition.start + transition.length)
|
||||||
|
{
|
||||||
|
double factor = 120 * xdim / ydim;
|
||||||
|
double phase = ((int32_t) totalclock - transition.start) / double(transition.length) * M_PI + M_PI/2;
|
||||||
|
|
||||||
|
transition.previous->origin.X = factor * transition.dir * (sin(phase) - 1.);
|
||||||
|
transition.current->origin.X = factor * transition.dir * (sin(phase) + 1.);
|
||||||
|
transition.previous->Drawer();
|
||||||
|
transition.current->Drawer();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
//
|
//
|
||||||
// DMenu base class
|
// DMenu base class
|
||||||
|
|
|
@ -320,6 +320,7 @@ public:
|
||||||
DMenu *mParentMenu;
|
DMenu *mParentMenu;
|
||||||
DVector2 origin;
|
DVector2 origin;
|
||||||
int scriptID = INT_MAX;
|
int scriptID = INT_MAX;
|
||||||
|
bool canAnimate = false;
|
||||||
|
|
||||||
DMenu(DMenu *parent = NULL);
|
DMenu(DMenu *parent = NULL);
|
||||||
virtual ~DMenu() = default;
|
virtual ~DMenu() = default;
|
||||||
|
|
Loading…
Reference in a new issue