(Lakka) Indent/style nits

This commit is contained in:
twinaphex 2014-09-12 06:29:39 +02:00
parent f5e523a8c3
commit 33750bc046

View File

@ -39,15 +39,19 @@
#include "../../../config.h"
#endif
// 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. */
static void lakka_switch_categories(void)
{
int i, j;
// translation
add_tween(LAKKA_DELAY, -menu_active_category * hspacing, &all_categories_x, &inOutQuad, NULL);
/* Translation */
add_tween(LAKKA_DELAY,
-menu_active_category * hspacing,
&all_categories_x, &inOutQuad, NULL);
// alpha tweening
/* Alpha tweening */
for (i = 0; i < num_categories; i++)
{
float ca, cz;
@ -63,10 +67,17 @@ static void lakka_switch_categories(void)
for (j = 0; j < category->num_items; j++)
{
float ia = (i != menu_active_category ) ? 0 :
(j == category->active_item) ? 1.0 : 0.5;
float ia = 0;
add_tween(LAKKA_DELAY, ia, &category->items[j].alpha, &inOutQuad, NULL);
if (i == menu_active_category)
{
ia = 0.5;
if (j == category->active_item)
ia = 1.0;
}
add_tween(LAKKA_DELAY, ia,
&category->items[j].alpha,&inOutQuad, NULL);
}
}
}
@ -74,21 +85,29 @@ static void lakka_switch_categories(void)
static void lakka_switch_items(void)
{
int j;
menu_category_t *active_category = (menu_category_t*)&categories[menu_active_category];
menu_category_t *active_category = (menu_category_t*)
&categories[menu_active_category];
for (j = 0; j < active_category->num_items; j++)
{
float ia, iz, iy;
float iy;
float ia = 0.5;
float iz = i_passive_zoom;
menu_item_t *active_item = (menu_item_t*)&active_category->items[j];
if (!active_item)
continue;
ia = (j == active_category->active_item) ? 1.0 : 0.5;
iz = (j == active_category->active_item) ? i_active_zoom : i_passive_zoom;
iy = (j == active_category->active_item) ? vspacing*active_item_factor :
(j < active_category->active_item) ? vspacing*(j - active_category->active_item + above_item_offset) :
vspacing*(j - active_category->active_item + under_item_offset);
iy = (j < active_category->active_item) ? vspacing *
(j - active_category->active_item + above_item_offset) :
vspacing * (j - active_category->active_item + under_item_offset);
if (j == active_category->active_item)
{
ia = 1.0;
iz = i_active_zoom;
iy = vspacing * active_item_factor;
}
add_tween(LAKKA_DELAY, ia, &active_item->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, iz, &active_item->zoom, &inOutQuad, NULL);
@ -99,8 +118,10 @@ static void lakka_switch_items(void)
static void lakka_switch_subitems(void)
{
int k;
menu_category_t *active_category = (menu_category_t*)&categories[menu_active_category];
menu_item_t *item = (menu_item_t*)&active_category->items[active_category->active_item];
menu_category_t *active_category = (menu_category_t*)
&categories[menu_active_category];
menu_item_t *item = (menu_item_t*)
&active_category->items[active_category->active_item];
for (k = 0; k < item->num_subitems; k++)
{
@ -112,23 +133,30 @@ static void lakka_switch_subitems(void)
if (k < item->active_subitem)
{
/* Above items */
add_tween(LAKKA_DELAY, 0.5, &subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, vspacing*(k - item->active_subitem + above_subitem_offset), &subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, i_passive_zoom, &subitem->zoom, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0.5,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, vspacing*(k - item->active_subitem +
above_subitem_offset), &subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, i_passive_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
else if (k == item->active_subitem)
{
/* Active item */
add_tween(LAKKA_DELAY, 1.0, &subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, vspacing*active_item_factor, &subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, i_active_zoom, &subitem->zoom, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, vspacing*active_item_factor,
&subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, i_active_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
else if (k > item->active_subitem)
{
/* Under items */
add_tween(LAKKA_DELAY, 0.5, &subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, vspacing*(k - item->active_subitem + under_item_offset), &subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, i_passive_zoom, &subitem->zoom, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, vspacing*(k - item->active_subitem +
under_item_offset), &subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, i_passive_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
}
}
@ -136,36 +164,45 @@ static void lakka_switch_subitems(void)
static void lakka_reset_submenu(void)
{
int i, j, k;
menu_category_t *active_category = (menu_category_t*)&categories[menu_active_category];
menu_category_t *active_category = (menu_category_t*)
&categories[menu_active_category];
if (!(
bool do_reset = (!(
g_extern.main_is_init
&& !g_extern.libretro_dummy
&& strcmp(g_extern.fullpath, active_category->items[active_category->active_item].rom) == 0))
&& (!strcmp(g_extern.fullpath,
active_category->items[
active_category->active_item].rom))));
if (!do_reset)
return;
/* Keeps active submenu state (do we really want that?) */
active_category->items[active_category->active_item].active_subitem = 0;
for (i = 0; i < num_categories; i++)
{
menu_category_t *category = (menu_category_t*)&categories[i];
// Keeps active submenu state (do we really want that?)
active_category->items[active_category->active_item].active_subitem = 0;
for (i = 0; i < num_categories; i++)
if (!category)
continue;
for (j = 0; j < category->num_items; j++)
{
menu_category_t *category = (menu_category_t*)&categories[i];
if (!category)
continue;
for (j = 0; j < category->num_items; j++)
for (k = 0; k < category->items[j].num_subitems; k++)
{
for (k = 0; k < category->items[j].num_subitems; k++)
{
menu_subitem_t *subitem = (menu_subitem_t*)&category->items[j].subitems[k];
menu_subitem_t *subitem = (menu_subitem_t*)
&category->items[j].subitems[k];
if (!subitem)
continue;
if (!subitem)
continue;
subitem->alpha = 0;
subitem->zoom = k == category->items[j].active_subitem ? i_active_zoom : i_passive_zoom;
subitem->y = k == 0 ? vspacing * active_item_factor : vspacing * (k + under_item_offset);
}
subitem->alpha = 0;
subitem->zoom = (k == category->items[j].active_subitem) ?
i_active_zoom : i_passive_zoom;
subitem->y = k == 0 ?
vspacing * active_item_factor :
vspacing * (k + under_item_offset);
}
}
}
@ -175,10 +212,11 @@ static void lakka_open_submenu(void)
{
int i, j, k;
add_tween(LAKKA_DELAY, -hspacing * (menu_active_category+1), &all_categories_x, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, -hspacing * (menu_active_category+1),
&all_categories_x, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 1.0, &arrow_alpha, &inOutQuad, NULL);
// Reset contextual menu style
/* Reset contextual menu style */
lakka_reset_submenu();
for (i = 0; i < num_categories; i++)
@ -189,10 +227,12 @@ static void lakka_open_submenu(void)
continue;
if (i != menu_active_category)
add_tween(LAKKA_DELAY, 0, &category->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0,
&category->alpha, &inOutQuad, NULL);
else
{
add_tween(LAKKA_DELAY, 1.0, &category->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 1.0,
&category->alpha, &inOutQuad, NULL);
for (j = 0; j < category->num_items; j++)
{
@ -200,22 +240,28 @@ static void lakka_open_submenu(void)
{
for (k = 0; k < category->items[j].num_subitems; k++)
{
menu_subitem_t *subitem = (menu_subitem_t*)&category->items[j].subitems[k];
menu_subitem_t *subitem = (menu_subitem_t*)
&category->items[j].subitems[k];
if (k == category->items[j].active_subitem)
{
add_tween(LAKKA_DELAY, 1.0, &subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, i_active_zoom, &subitem->zoom, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 1.0,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, i_active_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
else
{
add_tween(LAKKA_DELAY, 0.5, &subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, i_passive_zoom, &subitem->zoom, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0.5,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, i_passive_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
}
}
else
add_tween(LAKKA_DELAY, 0, &category->items[j].alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0,
&category->items[j].alpha, &inOutQuad, NULL);
}
}
}
@ -225,7 +271,8 @@ static void lakka_close_submenu(void)
{
int i, j, k;
add_tween(LAKKA_DELAY, -hspacing * menu_active_category, &all_categories_x, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, -hspacing * menu_active_category,
&all_categories_x, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0.0, &arrow_alpha, &inOutQuad, NULL);
for (i = 0; i < num_categories; i++)
@ -238,37 +285,45 @@ static void lakka_close_submenu(void)
if (i == menu_active_category)
{
add_tween(LAKKA_DELAY, 1.0, &category->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, c_active_zoom, &category->zoom, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, c_active_zoom,
&category->zoom, &inOutQuad, NULL);
for (j = 0; j < category->num_items; j++)
{
if (j == category->active_item)
{
add_tween(LAKKA_DELAY, 1.0, &category->items[j].alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 1.0,
&category->items[j].alpha, &inOutQuad, NULL);
for (k = 0; k < category->items[j].num_subitems; k++)
add_tween(LAKKA_DELAY, 0, &category->items[j].subitems[k].alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0,
&category->items[j].subitems[k].alpha,
&inOutQuad, NULL);
}
else
add_tween(LAKKA_DELAY, 0.5, &category->items[j].alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0.5,
&category->items[j].alpha, &inOutQuad, NULL);
}
}
else
{
add_tween(LAKKA_DELAY, 0.5, &category->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, c_passive_zoom, &category->zoom, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0.5,
&category->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, c_passive_zoom,
&category->zoom, &inOutQuad, NULL);
for (j = 0; j < category->num_items; j++)
add_tween(LAKKA_DELAY, 0, &category->items[j].alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0,
&category->items[j].alpha, &inOutQuad, NULL);
}
}
}
static int menu_lakka_iterate(unsigned action)
{
menu_category_t *active_category;
menu_item_t *active_item;
menu_subitem_t * active_subitem;
menu_category_t *active_category = NULL;
menu_item_t *active_item = NULL;
menu_subitem_t * active_subitem = NULL;
if (!driver.menu)
{
@ -276,17 +331,15 @@ static int menu_lakka_iterate(unsigned action)
return 0;
}
active_category = NULL;
active_item = NULL;
active_subitem = NULL;
active_category = (menu_category_t*)&categories[menu_active_category];
if (active_category)
active_item = (menu_item_t*)&active_category->items[active_category->active_item];
active_item = (menu_item_t*)
&active_category->items[active_category->active_item];
if (active_item)
active_subitem = (menu_subitem_t*)&active_item->subitems[active_item->active_subitem];
active_subitem = (menu_subitem_t*)
&active_item->subitems[active_item->active_subitem];
if (!active_category || !active_item)
return 0;
@ -351,15 +404,26 @@ static int menu_lakka_iterate(unsigned action)
break;
case MENU_ACTION_DOWN:
if (depth == 0 && active_category->active_item < active_category->num_items - 1)
if (depth == 0
&& (active_category->active_item <
(active_category->num_items - 1)))
{
active_category->active_item++;
lakka_switch_items();
}
if (depth == 1 // if we are on subitems level
&& active_item->active_subitem < active_item->num_subitems -1 // and we do not exceed the number of subitems
&& (menu_active_category == 0 // and we are in settings or a rom is launched
|| ((active_item->active_subitem < active_item->num_subitems -1) && (g_extern.main_is_init && !g_extern.libretro_dummy) && strcmp(g_extern.fullpath, active_item->rom) == 0)))
/* If we are on subitems level, and we do not
* exceed the number of subitems, and we
* are in settings or content is launched. */
if (depth == 1
&& (active_item->active_subitem <
(active_item->num_subitems -1))
&& (menu_active_category == 0
|| ((active_item->active_subitem <
(active_item->num_subitems - 1))
&&
(g_extern.main_is_init && !g_extern.libretro_dummy)
&& (!strcmp(g_extern.fullpath, active_item->rom)))))
{
active_item->active_subitem++;
lakka_switch_subitems();
@ -387,14 +451,17 @@ static int menu_lakka_iterate(unsigned action)
case 0:
global_alpha = 0.0;
if (g_extern.main_is_init && !g_extern.libretro_dummy
&& strcmp(g_extern.fullpath, active_item->rom) == 0)
&& (!strcmp(g_extern.fullpath, active_item->rom)))
{
rarch_main_command(RARCH_CMD_RESUME);
}
else
{
strlcpy(g_extern.fullpath, active_item->rom, sizeof(g_extern.fullpath));
strlcpy(g_settings.libretro, active_category->libretro, sizeof(g_settings.libretro));
strlcpy(g_extern.fullpath,
active_item->rom, sizeof(g_extern.fullpath));
strlcpy(g_settings.libretro,
active_category->libretro,
sizeof(g_settings.libretro));
#ifdef HAVE_DYNAMIC
rarch_main_command(RARCH_CMD_LOAD_CORE);
@ -428,7 +495,10 @@ static int menu_lakka_iterate(unsigned action)
lakka_open_submenu();
depth = 1;
}
else if (depth == 0 && menu_active_category == 0 && active_category->active_item == active_category->num_items-1)
else if (depth == 0 &&
(menu_active_category == 0 &&
(active_category->active_item ==
(active_category->num_items - 1))))
{
add_tween(LAKKA_DELAY, 1.0, &global_alpha, &inOutQuad, NULL);
rarch_main_set_state(RARCH_ACTION_STATE_RUNNING_FINISHED);