mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
(Lakka) Integrate tween.c code into disp/lakka.c
This commit is contained in:
parent
fb3f558b49
commit
50ff38195a
2
Makefile
2
Makefile
@ -104,7 +104,7 @@ ifeq ($(HAVE_RGUI), 1)
|
|||||||
DEFINES += -DHAVE_MENU
|
DEFINES += -DHAVE_MENU
|
||||||
HAVE_MENU_COMMON = 1
|
HAVE_MENU_COMMON = 1
|
||||||
ifeq ($(HAVE_LAKKA), 1)
|
ifeq ($(HAVE_LAKKA), 1)
|
||||||
OBJ += frontend/menu/disp/png_texture_load.o frontend/menu/disp/tween.o frontend/menu/backend/menu_lakka_backend.o frontend/menu/disp/lakka.o
|
OBJ += frontend/menu/disp/png_texture_load.o frontend/menu/backend/menu_lakka_backend.o frontend/menu/disp/lakka.o
|
||||||
DEFINES += -DHAVE_LAKKA
|
DEFINES += -DHAVE_LAKKA
|
||||||
LIBS += -lpng
|
LIBS += -lpng
|
||||||
endif
|
endif
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
#include "../../../gfx/fonts/bitmap.h"
|
#include "../../../gfx/fonts/bitmap.h"
|
||||||
|
|
||||||
#include "lakka.h"
|
#include "lakka.h"
|
||||||
#include "tween.h"
|
|
||||||
#include "png_texture_load.h"
|
#include "png_texture_load.h"
|
||||||
|
|
||||||
#define HSPACING 300
|
#define HSPACING 300
|
||||||
@ -94,6 +93,74 @@ GLuint loadstate_icon;
|
|||||||
GLuint screenshot_icon;
|
GLuint screenshot_icon;
|
||||||
GLuint reload_icon;
|
GLuint reload_icon;
|
||||||
|
|
||||||
|
typedef float (*easingFunc)(float, float, float, float);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int alive;
|
||||||
|
float duration;
|
||||||
|
float running_since;
|
||||||
|
float initial_value;
|
||||||
|
float target_value;
|
||||||
|
float* subject;
|
||||||
|
easingFunc easing;
|
||||||
|
} tween;
|
||||||
|
|
||||||
|
static tween* tweens = NULL;
|
||||||
|
int numtweens = 0;
|
||||||
|
|
||||||
|
static float inOutQuad(float t, float b, float c, float d)
|
||||||
|
{
|
||||||
|
t = t / d * 2;
|
||||||
|
if (t < 1)
|
||||||
|
return c / 2 * pow(t, 2) + b;
|
||||||
|
return -c / 2 * ((t - 1) * (t - 3) - 1) + b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void add_tween(float duration, float target_value, float* subject, easingFunc easing)
|
||||||
|
{
|
||||||
|
numtweens++;
|
||||||
|
tweens = realloc(tweens, numtweens * sizeof(tween));
|
||||||
|
tweens[numtweens-1].alive = 1;
|
||||||
|
tweens[numtweens-1].duration = duration;
|
||||||
|
tweens[numtweens-1].running_since = 0;
|
||||||
|
tweens[numtweens-1].initial_value = *subject;
|
||||||
|
tweens[numtweens-1].target_value = target_value;
|
||||||
|
tweens[numtweens-1].subject = subject;
|
||||||
|
tweens[numtweens-1].easing = easing;
|
||||||
|
}
|
||||||
|
|
||||||
|
static tween update_tween(tween tw, float dt)
|
||||||
|
{
|
||||||
|
if (tw.running_since < tw.duration)
|
||||||
|
{
|
||||||
|
tw.running_since += dt;
|
||||||
|
*(tw.subject) = tw.easing(
|
||||||
|
tw.running_since,
|
||||||
|
tw.initial_value,
|
||||||
|
tw.target_value - tw.initial_value,
|
||||||
|
tw.duration);
|
||||||
|
if (tw.running_since >= tw.duration)
|
||||||
|
*(tw.subject) = tw.target_value;
|
||||||
|
}
|
||||||
|
return tw;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void update_tweens(float dt)
|
||||||
|
{
|
||||||
|
int i, active_tweens;
|
||||||
|
|
||||||
|
active_tweens = 0;
|
||||||
|
for(i = 0; i < numtweens; i++)
|
||||||
|
{
|
||||||
|
tweens[i] = update_tween(tweens[i], dt);
|
||||||
|
active_tweens += tweens[i].running_since < tweens[i].duration ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numtweens && !active_tweens)
|
||||||
|
numtweens = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Move the categories left or right depending on the menu_active_category variable
|
// Move the categories left or right depending on the menu_active_category variable
|
||||||
void lakka_switch_categories(void)
|
void lakka_switch_categories(void)
|
||||||
{
|
{
|
||||||
@ -898,6 +965,8 @@ void lakka_init_items(int i, menu_category *mcat, core_info_t corenfo, char* gam
|
|||||||
|
|
||||||
static void lakka_free_assets(void *data)
|
static void lakka_free_assets(void *data)
|
||||||
{
|
{
|
||||||
|
if (tweens)
|
||||||
|
free(tweens);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lakka_free(void *data)
|
static void lakka_free(void *data)
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2014 - Daniel De Matteis
|
|
||||||
* Copyright (C) 2014 - Jean-André Santoni
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "tween.h"
|
|
||||||
|
|
||||||
tween* tweens = NULL;
|
|
||||||
int numtweens = 0;
|
|
||||||
|
|
||||||
float inOutQuad(float t, float b, float c, float d)
|
|
||||||
{
|
|
||||||
t = t / d * 2;
|
|
||||||
if (t < 1)
|
|
||||||
return c / 2 * pow(t, 2) + b;
|
|
||||||
return -c / 2 * ((t - 1) * (t - 3) - 1) + b;
|
|
||||||
}
|
|
||||||
|
|
||||||
void add_tween(float duration, float target_value, float* subject, easingFunc easing)
|
|
||||||
{
|
|
||||||
numtweens++;
|
|
||||||
tweens = realloc(tweens, numtweens * sizeof(tween));
|
|
||||||
tweens[numtweens-1].alive = 1;
|
|
||||||
tweens[numtweens-1].duration = duration;
|
|
||||||
tweens[numtweens-1].running_since = 0;
|
|
||||||
tweens[numtweens-1].initial_value = *subject;
|
|
||||||
tweens[numtweens-1].target_value = target_value;
|
|
||||||
tweens[numtweens-1].subject = subject;
|
|
||||||
tweens[numtweens-1].easing = easing;
|
|
||||||
}
|
|
||||||
|
|
||||||
void update_tweens(float dt)
|
|
||||||
{
|
|
||||||
int i, active_tweens;
|
|
||||||
|
|
||||||
active_tweens = 0;
|
|
||||||
for(i = 0; i < numtweens; i++)
|
|
||||||
{
|
|
||||||
tweens[i] = update_tween(tweens[i], dt);
|
|
||||||
active_tweens += tweens[i].running_since < tweens[i].duration ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numtweens && !active_tweens)
|
|
||||||
numtweens = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
tween update_tween(tween tw, float dt)
|
|
||||||
{
|
|
||||||
if (tw.running_since < tw.duration)
|
|
||||||
{
|
|
||||||
tw.running_since += dt;
|
|
||||||
*(tw.subject) = tw.easing(
|
|
||||||
tw.running_since,
|
|
||||||
tw.initial_value,
|
|
||||||
tw.target_value - tw.initial_value,
|
|
||||||
tw.duration);
|
|
||||||
if (tw.running_since >= tw.duration)
|
|
||||||
*(tw.subject) = tw.target_value;
|
|
||||||
}
|
|
||||||
return tw;
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_tweens(void)
|
|
||||||
{
|
|
||||||
if (tweens)
|
|
||||||
free(tweens);
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2014 - Daniel De Matteis
|
|
||||||
* Copyright (C) 2014 - Jean-André Santoni
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LAKKA_TWEEN_H
|
|
||||||
#define _LAKKA_TWEEN_h
|
|
||||||
|
|
||||||
#include "math.h"
|
|
||||||
|
|
||||||
typedef float (*easingFunc)(float, float, float, float);
|
|
||||||
|
|
||||||
float inOutQuad(float, float, float, float);
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int alive;
|
|
||||||
float duration;
|
|
||||||
float running_since;
|
|
||||||
float initial_value;
|
|
||||||
float target_value;
|
|
||||||
float* subject;
|
|
||||||
easingFunc easing;
|
|
||||||
} tween;
|
|
||||||
|
|
||||||
tween update_tween(tween, float);
|
|
||||||
void update_tweens(float);
|
|
||||||
void add_tween(float, float, float*, easingFunc);
|
|
||||||
void free_tweens();
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
x
Reference in New Issue
Block a user