mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add menu_anim_t and easing helper functions
This commit is contained in:
parent
3f15fca32e
commit
93e9bd5485
3 changed files with 33 additions and 0 deletions
|
|
@ -178,6 +178,12 @@ struct menu_t
|
|||
boolean (*inputroutine)(INT32); // if set, called every frame in the input handler. Returning true overwrites normal input handling.
|
||||
};
|
||||
|
||||
struct menu_anim_t
|
||||
{
|
||||
tic_t start;
|
||||
INT16 dist;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MM_NOTHING = 0, // is just displayed until the user do someting
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@
|
|||
// And just some randomness for the exits.
|
||||
#include "m_random.h"
|
||||
|
||||
#include "i_time.h"
|
||||
#include "m_easing.h"
|
||||
|
||||
#ifdef PC_DOS
|
||||
#include <stdio.h> // for snprintf
|
||||
int snprintf(char *str, size_t n, const char *fmt, ...);
|
||||
|
|
@ -77,6 +80,29 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
|
|||
#include "discord.h"
|
||||
#endif
|
||||
|
||||
static fixed_t M_TimeFrac(tic_t tics, tic_t duration)
|
||||
{
|
||||
return tics < duration ? (tics * FRACUNIT + rendertimefrac) / duration : FRACUNIT;
|
||||
}
|
||||
|
||||
static fixed_t M_ReverseTimeFrac(tic_t tics, tic_t duration)
|
||||
{
|
||||
return FRACUNIT - M_TimeFrac(duration - tics, duration);
|
||||
}
|
||||
|
||||
static fixed_t M_DueFrac(tic_t start, tic_t duration)
|
||||
{
|
||||
tic_t t = I_GetTime();
|
||||
tic_t n = t - start;
|
||||
return M_TimeFrac(min(n, duration), duration);
|
||||
}
|
||||
|
||||
// FIXME: C++ template
|
||||
#define M_EaseWithTransition(EasingFunc, N) \
|
||||
(menutransition.tics != menutransition.dest ? EasingFunc(menutransition.in ?\
|
||||
M_ReverseTimeFrac(menutransition.tics, menutransition.endmenu->transitionTics) :\
|
||||
M_TimeFrac(menutransition.tics, menutransition.startmenu->transitionTics), 0, N) : 0)
|
||||
|
||||
#define SKULLXOFF -32
|
||||
#define LINEHEIGHT 16
|
||||
#define STRINGHEIGHT 8
|
||||
|
|
|
|||
|
|
@ -200,6 +200,7 @@ TYPEDEF (trackingResult_t);
|
|||
TYPEDEF (menucolor_t);
|
||||
TYPEDEF (menuitem_t);
|
||||
TYPEDEF (menu_t);
|
||||
TYPEDEF (menu_anim_t);
|
||||
TYPEDEF (menucmd_t);
|
||||
TYPEDEF (setup_player_colors_t);
|
||||
TYPEDEF (setup_player_t);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue