minor code improvement
[rocksndiamonds.git] / src / libgame / setup.h
index 38a732f475ec74ac68a1524c27f1919ba2d0a634..8ec6b4d8dc14fd616eea7c3ee8ff06564ded463e 100644 (file)
@@ -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                                     ? 4 :   \
+         (ti)->sort_priority >= LEVELCLASS_CLASSICS_START      ? 3 :   \
+         (ti)->sort_priority >= LEVELCLASS_TUTORIAL_START      ? 2 :   \
+         1) * 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);
@@ -262,6 +284,7 @@ void InitLevelSetupDirectory(char *);
 TreeInfo *newTreeInfo(void);
 TreeInfo *newTreeInfo_setDefaults(int);
 void pushTreeInfo(TreeInfo **, TreeInfo *);
+void removeTreeInfo(TreeInfo **);
 int numTreeInfo(TreeInfo *);
 boolean validLevelSeries(TreeInfo *);
 TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *);
@@ -343,6 +366,8 @@ void AddTreeSetToTreeInfo(TreeInfo *, char *, char *, int);
 boolean UpdateUserLevelSet(char *, char *, char *, int);
 boolean CreateUserLevelSet(char *, char *, char *, int, boolean);
 
+void UpdateLastPlayedLevels_TreeInfo(void);
+
 void LoadLevelSetup_LastSeries(void);
 void SaveLevelSetup_LastSeries(void);
 void SaveLevelSetup_LastSeries_Deactivate(void);