Skip to content

Commit 783e376

Browse files
committed
select_pokemon: Use intermediate variable for curr_pokemon
Make it easier to change this later as curr_pokemon might be redundant.
1 parent 5d8823a commit 783e376

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

views/select_pokemon.cpp

+17-14
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ static void select_pokemon_render_callback(Canvas* canvas, void* model) {
2323

2424
static bool select_pokemon_input_callback(InputEvent* event, void* context) {
2525
PokemonFap* pokemon_fap = (PokemonFap*)context;
26+
int pokemon_num = pokemon_fap->curr_pokemon;
2627
bool consumed = false;
2728

2829
furi_assert(context);
@@ -45,41 +46,41 @@ static bool select_pokemon_input_callback(InputEvent* event, void* context) {
4546

4647
/* Move back one through the pokedex listing */
4748
case InputKeyLeft:
48-
if(pokemon_fap->curr_pokemon == 0)
49-
pokemon_fap->curr_pokemon = 150;
49+
if(pokemon_num == 0)
50+
pokemon_num = 150;
5051
else
51-
pokemon_fap->curr_pokemon--;
52+
pokemon_num--;
5253
consumed = true;
5354
break;
5455

55-
/* Move back ten through the pokemon listing, wrap to max pokemon on
56+
/* Move back ten through the pokemon listing, wrap to max pokemon on
5657
* underflow.
5758
*/
5859
case InputKeyDown:
59-
if(pokemon_fap->curr_pokemon >= 10)
60-
pokemon_fap->curr_pokemon -= 10;
60+
if(pokemon_num >= 10)
61+
pokemon_num -= 10;
6162
else
62-
pokemon_fap->curr_pokemon = 150;
63+
pokemon_num = 150;
6364
consumed = true;
6465
break;
6566

6667
/* Move forward one through the pokedex listing */
6768
case InputKeyRight:
68-
if(pokemon_fap->curr_pokemon == 150)
69-
pokemon_fap->curr_pokemon = 0;
69+
if(pokemon_num == 150)
70+
pokemon_num = 0;
7071
else
71-
pokemon_fap->curr_pokemon++;
72+
pokemon_num++;
7273
consumed = true;
7374
break;
7475

75-
/* Move forward ten through the pokemon listing, wrap to min pokemon on
76+
/* Move forward ten through the pokemon listing, wrap to min pokemon on
7677
* overflow.
7778
*/
7879
case InputKeyUp:
79-
if(pokemon_fap->curr_pokemon <= 140)
80-
pokemon_fap->curr_pokemon += 10;
80+
if(pokemon_num <= 140)
81+
pokemon_num += 10;
8182
else
82-
pokemon_fap->curr_pokemon = 0;
83+
pokemon_num = 0;
8384
consumed = true;
8485
break;
8586

@@ -88,6 +89,8 @@ static bool select_pokemon_input_callback(InputEvent* event, void* context) {
8889
break;
8990
}
9091

92+
pokemon_fap->curr_pokemon = pokemon_num;
93+
9194
return consumed;
9295
}
9396

0 commit comments

Comments
 (0)