(menu_animation.c) Cleanups

This commit is contained in:
twinaphex 2015-02-01 23:05:16 +01:00
parent 48032486f4
commit a1cf3c1eae
3 changed files with 19 additions and 13 deletions

View File

@ -18,32 +18,35 @@
#include "../driver.h"
#include <math.h>
static void tween_free(tween_t *tw)
static void tween_free(tween_t *tween)
{
if (tw)
free(tw);
tw = NULL;
if (tween)
free(tween);
tween = NULL;
}
void add_tween(float duration, float target_value, float* subject,
bool add_tween(float duration, float target_value, float* subject,
easingFunc easing, tweenCallback callback)
{
tween_t *tween = NULL;
tween_t *temp_tweens = (tween_t*)
realloc(driver.menu->tweens,
(driver.menu->numtweens + 1) * sizeof(tween_t));
tween_t *tween = NULL, *temp_tweens = NULL;
if (!driver.menu)
return false;
temp_tweens = (tween_t*)realloc(driver.menu->tweens,
(driver.menu->numtweens + 1) * sizeof(tween_t));
if (!temp_tweens)
{
tween_free(driver.menu->tweens);
return;
return false;
}
driver.menu->tweens = temp_tweens;
tween = (tween_t*)&driver.menu->tweens[driver.menu->numtweens];
if (!tween)
return;
return false;
tween->alive = 1;
tween->duration = duration;
@ -55,6 +58,8 @@ void add_tween(float duration, float target_value, float* subject,
tween->callback = callback;
driver.menu->numtweens++;
return true;
}
void update_tweens(float dt)

View File

@ -19,6 +19,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <boolean.h>
#ifdef __cplusplus
extern "C" {
@ -39,7 +40,7 @@ typedef struct
tweenCallback callback;
} tween_t;
void add_tween(float duration, float target_value, float* subject,
bool add_tween(float duration, float target_value, float* subject,
easingFunc easing, tweenCallback callback);
void update_tweens(float dt);

View File

@ -141,7 +141,7 @@ typedef struct
rarch_setting_t *list_settings;
tween_t* tweens;
int numtweens;
unsigned numtweens;
} menu_handle_t;
typedef struct menu_file_list_cbs