{
const TreeInfo *entry1 = *((TreeInfo **)object1);
const TreeInfo *entry2 = *((TreeInfo **)object2);
- int class_sorting1 = 0, class_sorting2 = 0;
- int compare_result;
+ int tree_sorting1 = TREE_SORTING(entry1);
+ int tree_sorting2 = TREE_SORTING(entry2);
- if (entry1->type == TREE_TYPE_LEVEL_DIR)
- {
- class_sorting1 = LEVELSORTING(entry1);
- class_sorting2 = LEVELSORTING(entry2);
- }
- else if (entry1->type == TREE_TYPE_GRAPHICS_DIR ||
- entry1->type == TREE_TYPE_SOUNDS_DIR ||
- entry1->type == TREE_TYPE_MUSIC_DIR)
- {
- class_sorting1 = ARTWORKSORTING(entry1);
- class_sorting2 = ARTWORKSORTING(entry2);
- }
-
- if (entry1->parent_link || entry2->parent_link)
- compare_result = (entry1->parent_link ? -1 : +1);
- else if (entry1->level_group != entry2->level_group)
- compare_result = (entry1->level_group ? -1 : +1);
- else if (entry1->sort_priority == entry2->sort_priority)
- compare_result = strcasecmp(entry1->name_sorting, entry2->name_sorting);
- else if (class_sorting1 == class_sorting2)
- compare_result = entry1->sort_priority - entry2->sort_priority;
+ if (tree_sorting1 != tree_sorting2)
+ return (tree_sorting1 - tree_sorting2);
else
- compare_result = class_sorting1 - class_sorting2;
-
- return compare_result;
+ return strcasecmp(entry1->name_sorting, entry2->name_sorting);
}
static TreeInfo *createParentTreeInfoNode(TreeInfo *node_parent)
IS_ARTWORKCLASS_LEVEL(n) ? ARTWORKCLASS_LEVEL : \
ARTWORKCLASS_UNDEFINED)
+#define TREE_SORTING_DIR(ti) \
+ (((ti)->parent_link ? 0 : \
+ (ti)->in_user_dir ? 8 : \
+ (ti)->sort_priority >= LEVELCLASS_CLASSICS_START ? 6 : \
+ (ti)->sort_priority >= LEVELCLASS_TUTORIAL_START ? 4 : \
+ 2) + \
+ ((ti)->level_group ? 0 : 1))
+
+#define TREE_COLOR_DIR(ti, active) \
+ ((active) ? FC_YELLOW : \
+ TREE_SORTING(ti) / 2 == 4 ? FC_GREEN : \
+ TREE_SORTING(ti) / 2 == 2 ? FC_BLUE : \
+ FC_RED)
+
+#define TREE_SORTING(ti) \
+ (TREE_TYPE_IS_DIR((ti)->type) ? TREE_SORTING_DIR(ti) : \
+ (ti)->sort_priority)
+
+#define TREE_COLOR(ti, active) \
+ (TREE_TYPE_IS_DIR((ti)->type) ? TREE_COLOR_DIR(ti, active) : \
+ (ti)->color)
+
char *getUserGraphicsDir(void);
char *getUserSoundsDir(void);
#define NUM_BASE_TREE_TYPES 4
#define NUM_TREE_TYPES 6
+#define TREE_TYPE_IS_DIR(type) ((type) == TREE_TYPE_GRAPHICS_DIR || \
+ (type) == TREE_TYPE_SOUNDS_DIR || \
+ (type) == TREE_TYPE_MUSIC_DIR || \
+ (type) == TREE_TYPE_LEVEL_DIR)
+
#define INFOTEXT_UNDEFINED ""
#define INFOTEXT_GRAPHICS_DIR "Custom Graphics"
#define INFOTEXT_SOUNDS_DIR "Custom Sounds"
// other screen text constants
#define STR_CHOOSE_TREE_EDIT "Edit"
#define MENU_CHOOSE_TREE_FONT(x) (FONT_TEXT_1 + (x))
+#define MENU_CHOOSE_TREE_COLOR(ti, a) TREE_COLOR(ti, a)
// for input setup functions
#define SETUPINPUT_SCREEN_POS_START 0
int entry_pos = first_entry + y;
TreeInfo *node_first = getTreeInfoFirstGroupEntry(ti);
TreeInfo *node = getTreeInfoFromPos(node_first, entry_pos);
- int node_color = (node->color == FC_YELLOW ? FC_GREEN : node->color);
- int color = (active ? FC_YELLOW : node_color);
- int font_nr = MENU_CHOOSE_TREE_FONT(color);
+ int font_color = MENU_CHOOSE_TREE_COLOR(node, active);
+ int font_nr = MENU_CHOOSE_TREE_FONT(font_color);
int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
int xpos = MENU_SCREEN_START_XPOS;
int ypos = MENU_SCREEN_START_YPOS + y;