#define SETUP_TOKEN_TIME_LIMIT 13
#define SETUP_TOKEN_FULLSCREEN 14
#define SETUP_TOKEN_ASK_ON_ESCAPE 15
+#define SETUP_TOKEN_GRAPHICS_DIR 16
+#define SETUP_TOKEN_SOUNDS_DIR 17
+#define SETUP_TOKEN_MUSIC_DIR 18
-#define NUM_GLOBAL_SETUP_TOKENS 16
+#define NUM_GLOBAL_SETUP_TOKENS 19
/* shortcut setup */
#define SETUP_TOKEN_SAVE_GAME 0
{ TYPE_SWITCH, &si.team_mode, "team_mode" },
{ TYPE_SWITCH, &si.handicap, "handicap" },
{ TYPE_SWITCH, &si.time_limit, "time_limit" },
+ { TYPE_SWITCH, &si.fullscreen, "fullscreen" },
{ TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" },
- { TYPE_SWITCH, &si.fullscreen, "fullscreen" }
+ { TYPE_STRING, &si.graphics_dir, "graphics_dir" },
+ { TYPE_STRING, &si.sounds_dir, "sounds_dir" },
+ { TYPE_STRING, &si.music_dir, "music_dir" },
};
static struct TokenInfo shortcut_setup_tokens[] =
si->fullscreen = FALSE;
si->ask_on_escape = TRUE;
+ si->graphics_dir = getStringCopy(GRAPHICS_DIRECTORY);
+ si->sounds_dir = getStringCopy(SOUNDS_DIRECTORY);
+ si->music_dir = getStringCopy(MUSIC_DIRECTORY);
+
si->shortcut.save_game = DEFAULT_KEY_SAVE_GAME;
si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME;
fprintf(file, "%s\n", getSetupLine(global_setup_tokens, "", i));
/* just to make things nicer :) */
- if (i == SETUP_TOKEN_PLAYER_NAME)
+ if (i == SETUP_TOKEN_PLAYER_NAME || i == SETUP_TOKEN_GRAPHICS_DIR - 1)
fprintf(file, "\n");
}
{
int i;
+ printf("Dumping TreeInfo:\n");
+
while (node)
{
- for (i=0; i<depth * 3; i++)
+ for (i=0; i<(depth + 1) * 3; i++)
printf(" ");
printf("filename == '%s' [%s]\n", node->filename, node->name);
{ TYPE_BOOLEAN, &ldi.readonly, "readonly" }
};
-static void setTreeInfoToDefaults(TreeInfo *ldi)
+static void setTreeInfoToDefaults(TreeInfo *ldi, int type)
{
- /* ldi->type is expected to be already set! */
-
- if (ldi->type == 0)
- Error(ERR_EXIT, "ldi->type == 0");
+ ldi->type = type;
ldi->node_top = (ldi->type == TREE_TYPE_LEVEL_DIR ? &leveldir_first :
ldi->type == TREE_TYPE_GRAPHICS_DIR ? &artwork.gfx_first :
{
if (parent == NULL)
{
- setTreeInfoToDefaults(ldi);
+ Error(ERR_WARN, "setTreeInfoToDefaultsFromParent(): parent == NULL");
+
+ setTreeInfoToDefaults(ldi, TREE_TYPE_GENERIC);
return;
}
return;
ti_new = newTreeInfo();
- ti_new->type = node_parent->type;
-
- setTreeInfoToDefaults(ti_new);
+ setTreeInfoToDefaults(ti_new, node_parent->type);
ti_new->node_parent = node_parent;
ti_new->parent_link = TRUE;
}
leveldir_new = newTreeInfo();
- leveldir_new->type = TREE_TYPE_LEVEL_DIR;
+
+ if (node_parent)
+ setTreeInfoToDefaultsFromParent(leveldir_new, node_parent);
+ else
+ setTreeInfoToDefaults(leveldir_new, TREE_TYPE_LEVEL_DIR);
checkSetupFileListIdentifier(setup_file_list, getCookie("LEVELINFO"));
- setTreeInfoToDefaultsFromParent(leveldir_new, node_parent);
/* set all structure fields according to the token/value pairs */
ldi = *leveldir_new;
}
artwork_new = newTreeInfo();
- artwork_new->type = type;
- setTreeInfoToDefaultsFromParent(artwork_new, node_parent);
+ if (node_parent)
+ setTreeInfoToDefaultsFromParent(artwork_new, node_parent);
+ else
+ setTreeInfoToDefaults(artwork_new, type);
artwork_new->filename = getStringCopy(directory_name);
- if (setup_file_list)
+ if (setup_file_list) /* (before defining ".color" and ".class_desc") */
{
#if 0
checkSetupFileListIdentifier(setup_file_list, getCookie("..."));
if (artwork_new->name_sorting == NULL)
artwork_new->name_sorting = getStringCopy(artwork_new->name);
}
- else
- {
- if (artwork_new->name != NULL)
- free(artwork_new->name);
-
- if (strcmp(artwork_new->filename, ".") == 0)
- artwork_new->name = getStringCopy("default");
- else
- artwork_new->name = getStringCopy(artwork_new->filename);
-
- artwork_new->name_short = getStringCopy(artwork_new->name);
- artwork_new->name_sorting = getStringCopy(artwork_new->name);
- }
if (node_parent == NULL) /* top level group */
{
artwork_new->user_defined =
(artwork_new->basepath == check_dir ? FALSE : TRUE);
-#if 0
+ /* (may use ".sort_priority" from "setup_file_list" above) */
artwork_new->color = LEVELCOLOR(artwork_new);
artwork_new->class_desc = getLevelClassDescription(artwork_new);
-#endif
+
+ if (setup_file_list == NULL) /* (after determining ".user_defined") */
+ {
+ if (artwork_new->name != NULL)
+ free(artwork_new->name);
+
+ if (strcmp(artwork_new->filename, ".") == 0)
+ {
+ if (artwork_new->user_defined)
+ artwork_new->name = getStringCopy("private");
+ else
+ artwork_new->name = getStringCopy("default");
+ }
+ else
+ artwork_new->name = getStringCopy(artwork_new->filename);
+
+ artwork_new->name_short = getStringCopy(artwork_new->name);
+ artwork_new->name_sorting = getStringCopy(artwork_new->name);
+ }
pushTreeInfo(node_first, artwork_new);
getUserMusicDir(NULL),
TREE_TYPE_MUSIC_DIR);
+ /* before sorting, the first entries will be from the user directory */
artwork.gfx_current = artwork.gfx_first;
artwork.snd_current = artwork.snd_first;
artwork.mus_current = artwork.mus_first;
sortTreeInfo(&artwork.snd_first, compareTreeInfoEntries);
sortTreeInfo(&artwork.mus_first, compareTreeInfoEntries);
-#if 0
+#if 1
dumpTreeInfo(artwork.gfx_first, 0);
dumpTreeInfo(artwork.snd_first, 0);
dumpTreeInfo(artwork.mus_first, 0);
}
/* always start with reliable default values */
- setTreeInfoToDefaults(&ldi);
+ setTreeInfoToDefaults(&ldi, TREE_TYPE_LEVEL_DIR);
ldi.name = getLoginName();
ldi.author = getRealName();