projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b4e8ba5
)
moved calculating first entry on high score screen to separate function
author
Holger Schemel
<info@artsoft.org>
Sat, 1 May 2021 13:55:40 +0000
(15:55 +0200)
committer
Holger Schemel
<info@artsoft.org>
Sat, 1 May 2021 13:55:40 +0000
(15:55 +0200)
src/screens.c
patch
|
blob
|
history
diff --git
a/src/screens.c
b/src/screens.c
index d86fa57267864ca83e626f6917683fddb8966c8a..fb3aabc2cc8476e5f385859f4ecfc851fc6df572 100644
(file)
--- a/
src/screens.c
+++ b/
src/screens.c
@@
-5075,6
+5075,21
@@
void DrawHallOfFame(int level_nr, int highlight_position)
FadeIn(fade_mask);
}
FadeIn(fade_mask);
}
+static int getHallOfFameFirstEntry(int first_entry, int step)
+{
+ if (step == 0)
+ first_entry = scores.last_added - (NUM_MENU_ENTRIES_ON_SCREEN + 1) / 2 + 1;
+ else
+ first_entry += step;
+
+ if (first_entry < 0)
+ first_entry = 0;
+ else if (first_entry > MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN)
+ first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
+
+ return first_entry;
+}
+
static char *getHallOfFameScoreText(int nr)
{
if (!level.rate_time_over_score)
static char *getHallOfFameScoreText(int nr)
{
if (!level.rate_time_over_score)
@@
-5147,12
+5162,7
@@
void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
level_nr = mx;
highlight_position = my;
level_nr = mx;
highlight_position = my;
- first_entry = highlight_position - (NUM_MENU_ENTRIES_ON_SCREEN + 1) / 2 + 1;
-
- if (first_entry < 0)
- first_entry = 0;
- else if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
- first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
+ first_entry = getHallOfFameFirstEntry(0, 0);
drawHallOfFameList(level_nr, first_entry, highlight_position);
drawHallOfFameList(level_nr, first_entry, highlight_position);
@@
-5164,25
+5174,15
@@
void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
if (dy < 0)
{
if (dy < 0)
{
- if (first_entry > 0)
- {
- first_entry -= step;
- if (first_entry < 0)
- first_entry = 0;
+ first_entry = getHallOfFameFirstEntry(first_entry, -step);
- drawHallOfFameList(level_nr, first_entry, highlight_position);
- }
+ drawHallOfFameList(level_nr, first_entry, highlight_position);
}
else if (dy > 0)
{
}
else if (dy > 0)
{
- if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
- {
- first_entry += step;
- if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
- first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
+ first_entry = getHallOfFameFirstEntry(first_entry, step);
- drawHallOfFameList(level_nr, first_entry, highlight_position);
- }
+ drawHallOfFameList(level_nr, first_entry, highlight_position);
}
else if (button == MB_MENU_LEAVE || button == MB_MENU_CHOICE)
{
}
else if (button == MB_MENU_LEAVE || button == MB_MENU_CHOICE)
{