From: Holger Schemel Date: Wed, 10 Feb 2021 00:34:50 +0000 (+0100) Subject: changed sorting and coloring in level sets and custom artwork menu X-Git-Tag: 4.2.3.0~16 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=38142eccb93284bef9c3aeb2d9e81389a21da82a;p=rocksndiamonds.git changed sorting and coloring in level sets and custom artwork menu --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index f85738a1..90fb933a 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -2858,34 +2858,13 @@ static int compareTreeInfoEntries(const void *object1, const void *object2) { 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) diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 7877ccb2..2f5489d9 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -227,6 +227,28 @@ typedef struct hashtable SetupFileHash; 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); diff --git a/src/libgame/system.h b/src/libgame/system.h index f5b2967e..9b3dfe75 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -774,6 +774,11 @@ #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" diff --git a/src/screens.c b/src/screens.c index dbac21b3..81a54b06 100644 --- a/src/screens.c +++ b/src/screens.c @@ -126,6 +126,7 @@ // 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 @@ -4408,9 +4409,8 @@ static void drawChooseTreeText(int y, boolean active, TreeInfo *ti) 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;