Pass numtweens as pointer

This commit is contained in:
twinaphex 2015-02-10 23:49:26 +01:00
parent 453e5b7681
commit 9a839fce2f
3 changed files with 36 additions and 35 deletions

View File

@ -493,10 +493,10 @@ static void xmb_selection_pointer_changed(void)
iz = xmb->i_active_zoom;
}
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL);
tweens_push(XMB_DELAY, iy, &node->y, &inOutQuad, NULL);
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, iy, &node->y, &inOutQuad, NULL, &driver.menu->numtweens);
}
}
@ -521,9 +521,9 @@ static void xmb_list_open_old(file_list_t *list, int dir, size_t current)
if (dir == -1)
ia = 0;
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, xmb->icon_size*dir*-2, &node->x, &inOutQuad, NULL);
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, xmb->icon_size*dir*-2, &node->x, &inOutQuad, NULL, &driver.menu->numtweens);
}
}
@ -567,9 +567,9 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current)
if (i == current)
ia = xmb->i_active_alpha;
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL);
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL, &driver.menu->numtweens);
}
xmb->old_depth = xmb->depth;
@ -699,9 +699,9 @@ static void xmb_list_switch_old(file_list_t *list, int dir, size_t current)
if (!xmb)
continue;
tweens_push(XMB_DELAY, 0, &node->alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, -xmb->hspacing*dir, &node->x, &inOutQuad, NULL);
tweens_push(XMB_DELAY, 0, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, -xmb->hspacing*dir, &node->x, &inOutQuad, NULL, &driver.menu->numtweens);
}
}
@ -729,9 +729,9 @@ static void xmb_list_switch_new(file_list_t *list, int dir, size_t current)
if (i == current)
ia = 1.0;
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL);
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL, &driver.menu->numtweens);
}
}
@ -795,12 +795,12 @@ static void xmb_list_open(void)
iz = xmb->c_active_zoom;
}
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL);
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL, &driver.menu->numtweens);
}
tweens_push(XMB_DELAY, xmb->hspacing * -(float)driver.menu->cat_selection_ptr,
&xmb->categories_x, &inOutQuad, NULL);
&xmb->categories_x, &inOutQuad, NULL, &driver.menu->numtweens);
dir = -1;
if (driver.menu->cat_selection_ptr > xmb->cat_selection_ptr_old)
@ -840,7 +840,7 @@ static void xmb_list_switch(void)
else if (xmb->depth <= 1)
ia = xmb->c_passive_alpha;
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens);
}
xmb_list_open_old(xmb->selection_buf_old, dir, xmb->selection_ptr_old);
@ -849,12 +849,12 @@ static void xmb_list_switch(void)
switch (xmb->depth)
{
case 1:
tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL);
tweens_push(XMB_DELAY, 0, &xmb->arrow_alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, 0, &xmb->arrow_alpha, &inOutQuad, NULL, &driver.menu->numtweens);
break;
case 2:
tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL);
tweens_push(XMB_DELAY, 1, &xmb->arrow_alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL, &driver.menu->numtweens);
tweens_push(XMB_DELAY, 1, &xmb->arrow_alpha, &inOutQuad, NULL, &driver.menu->numtweens);
break;
}
@ -1062,7 +1062,7 @@ static void xmb_frame(void)
if (!xmb || !gl)
return;
tweens_update(driver.menu->tweens, 0.002);
tweens_update(driver.menu->tweens, 0.002, &driver.menu->numtweens);
glViewport(0, 0, gl->win_width, gl->win_height);
@ -1670,7 +1670,7 @@ static void xmb_toggle(bool menu_on)
return;
}
tweens_push(XMB_DELAY, 1.0f, &xmb->alpha, &inOutQuad, NULL);
tweens_push(XMB_DELAY, 1.0f, &xmb->alpha, &inOutQuad, NULL, &driver.menu->numtweens);
xmb->prevent_populate = !menu->need_refresh;

View File

@ -25,7 +25,7 @@ void tweens_free(tween_t *tween)
}
bool tweens_push(float duration, float target_value, float* subject,
easingFunc easing, tween_cb cb)
easingFunc easing, tween_cb cb, unsigned *numtweens)
{
tween_t *tween = NULL, *temp_tweens = NULL;
@ -33,13 +33,13 @@ bool tweens_push(float duration, float target_value, float* subject,
return false;
temp_tweens = (tween_t*)realloc(driver.menu->tweens,
(driver.menu->numtweens + 1) * sizeof(tween_t));
(*numtweens + 1) * sizeof(tween_t));
if (!temp_tweens)
return false;
driver.menu->tweens = temp_tweens;
tween = (tween_t*)&driver.menu->tweens[driver.menu->numtweens];
tween = (tween_t*)&driver.menu->tweens[*numtweens];
if (!tween)
return false;
@ -53,7 +53,7 @@ bool tweens_push(float duration, float target_value, float* subject,
tween->easing = easing;
tween->cb = cb;
driver.menu->numtweens++;
*numtweens = *numtweens + 1;
return true;
}
@ -89,16 +89,17 @@ static int tweens_iterate(tween_t *tween, float dt,
return 0;
}
void tweens_update(tween_t *tweens, float dt)
void tweens_update(tween_t *tweens, float dt,
unsigned *numtweens)
{
unsigned i;
unsigned active_tweens = 0;
for(i = 0; i < driver.menu->numtweens; i++)
for(i = 0; i < *numtweens; i++)
tweens_iterate(&tweens[i], dt, &active_tweens);
if (!active_tweens)
driver.menu->numtweens = 0;
*numtweens = 0;
}
/* Linear */

View File

@ -41,9 +41,9 @@ typedef struct
} tween_t;
bool tweens_push(float duration, float target_value, float* subject,
easingFunc easing, tween_cb cb);
easingFunc easing, tween_cb cb, unsigned *numtweens);
void tweens_update(tween_t *tweens, float dt);
void tweens_update(tween_t *tweens, float dt, unsigned *numtweens);
/* from https://github.com/kikito/tween.lua/blob/master/tween.lua */