From: Holger Schemel Date: Tue, 2 Apr 2002 00:58:25 +0000 (+0200) Subject: rnd-20020402-2-src X-Git-Tag: 2.1.0^2~68 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f25f84638db551dfef62b019ca2390193ad53600;p=rocksndiamonds.git rnd-20020402-2-src --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index edfa4d35..454f66c5 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1083,7 +1083,7 @@ static void setTreeInfoToDefaults(TreeInfo *ldi) ldi->cl_first = -1; ldi->cl_cursor = -1; - ldi->type = TREE_TYPE_GENERIC; + /* ldi->type is expected to be already set! */ ldi->filename = NULL; ldi->fullpath = NULL; @@ -1092,22 +1092,26 @@ static void setTreeInfoToDefaults(TreeInfo *ldi) ldi->name_short = NULL; ldi->name_sorting = NULL; ldi->author = getStringCopy(ANONYMOUS_NAME); - ldi->imported_from = NULL; - ldi->levels = 0; - ldi->first_level = 0; - ldi->last_level = 0; + ldi->sort_priority = LEVELCLASS_UNDEFINED; /* default: least priority */ - ldi->level_group = FALSE; ldi->parent_link = FALSE; ldi->user_defined = FALSE; - ldi->readonly = TRUE; ldi->color = 0; ldi->class_desc = NULL; - ldi->handicap_level = 0; + + if (ldi->type == TREE_TYPE_LEVEL_DIR) + { + ldi->imported_from = NULL; + ldi->levels = 0; + ldi->first_level = 0; + ldi->last_level = 0; + ldi->level_group = FALSE; + ldi->handicap_level = 0; + ldi->readonly = TRUE; + } } -static void setTreeInfoToDefaultsFromParent(TreeInfo *ldi, - TreeInfo *parent) +static void setTreeInfoToDefaultsFromParent(TreeInfo *ldi, TreeInfo *parent) { if (parent == NULL) { @@ -1210,24 +1214,30 @@ static int compareTreeInfoEntries(const void *object1, const void *object2) static void createParentTreeInfoNode(TreeInfo *node_parent) { - TreeInfo *leveldir_new = newTreeInfo(); + TreeInfo *ti_new; - setTreeInfoToDefaults(leveldir_new); + if (node_parent == NULL) + return; - leveldir_new->node_parent = node_parent; - leveldir_new->parent_link = TRUE; + ti_new = newTreeInfo(); + ti_new->type = node_parent->type; - leveldir_new->name = ".. (parent directory)"; - leveldir_new->name_short = getStringCopy(leveldir_new->name); - leveldir_new->name_sorting = getStringCopy(leveldir_new->name); + setTreeInfoToDefaults(ti_new); - leveldir_new->filename = ".."; - leveldir_new->fullpath = getStringCopy(node_parent->fullpath); + ti_new->node_parent = node_parent; + ti_new->parent_link = TRUE; - leveldir_new->sort_priority = node_parent->sort_priority; - leveldir_new->class_desc = getLevelClassDescription(leveldir_new); + ti_new->name = ".. (parent directory)"; + ti_new->name_short = getStringCopy(ti_new->name); + ti_new->name_sorting = getStringCopy(ti_new->name); + + ti_new->filename = ".."; + ti_new->fullpath = getStringCopy(node_parent->fullpath); + + ti_new->sort_priority = node_parent->sort_priority; + ti_new->class_desc = getLevelClassDescription(ti_new); - pushTreeInfo(&node_parent->node_group, leveldir_new); + pushTreeInfo(&node_parent->node_group, ti_new); } /* forward declaration for recursive call by "LoadLevelInfoFromLevelDir()" */ @@ -1255,6 +1265,7 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, } leveldir_new = newTreeInfo(); + leveldir_new->type = TREE_TYPE_LEVEL_DIR; checkSetupFileListIdentifier(setup_file_list, getCookie("LEVELINFO")); setTreeInfoToDefaultsFromParent(leveldir_new, node_parent); @@ -1402,9 +1413,6 @@ void LoadLevelInfo() #endif } -/* declaration for recursive call by "LoadArtworkInfoFromArtworkConf()" */ -static void LoadArtworkInfoFromArtworkDir(TreeInfo **, TreeInfo *, char *,int); - static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, TreeInfo *node_parent, char *base_directory, @@ -1460,6 +1468,8 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, } artwork_new = newTreeInfo(); + artwork_new->type = type; + setTreeInfoToDefaultsFromParent(artwork_new, node_parent); artwork_new->filename = getStringCopy(directory_name); diff --git a/src/screens.c b/src/screens.c index d1d8e119..5479da0d 100644 --- a/src/screens.c +++ b/src/screens.c @@ -59,6 +59,7 @@ static void HandleSetupScreen_Generic(int, int, int, int, int); static void HandleSetupScreen_Input(int, int, int, int, int); static void CustomizeKeyboard(int); static void CalibrateJoystick(int); +static void HandleChooseTree(int, int, int, int, int, TreeInfo **); static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS]; @@ -917,6 +918,315 @@ void HandleTypeName(int newxpos, Key key) BackToFront(); } + +#if 1 + +static void DrawChooseTree(TreeInfo **ti_ptr) +{ + UnmapAllGadgets(); + CloseDoor(DOOR_CLOSE_2); + + ClearWindow(); + HandleChooseTree(0,0, 0,0, MB_MENU_INITIALIZE, ti_ptr); + MapChooseTreeGadgets(); + + FadeToFront(); + InitAnimation(); +} + +static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti) +{ + struct GadgetInfo *gi = screen_gadget[id]; + int items_max, items_visible, item_position; + + items_max = numTreeInfoInGroup(ti); + items_visible = MAX_MENU_ENTRIES_ON_SCREEN - 1; + item_position = first_entry; + + if (item_position > items_max - items_visible) + item_position = items_max - items_visible; + + ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max, + GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END); +} + +static void drawChooseTreeList(int first_entry, int num_page_entries, + TreeInfo *ti) +{ + int i; + char buffer[SCR_FIELDX * 2]; + int max_buffer_len = (SCR_FIELDX - 2) * 2; + int num_entries = numTreeInfoInGroup(ti); + char *title_string = NULL; + + ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE); + redraw_mask |= REDRAW_FIELD; + + title_string = + (ti->type == TREE_TYPE_LEVEL_DIR ? "Level Directories" : + ti->type == TREE_TYPE_GRAPHICS_DIR ? "Game Graphics" : + ti->type == TREE_TYPE_SOUNDS_DIR ? "Game Sounds" : + ti->type == TREE_TYPE_MUSIC_DIR ? "Game Music" : ""); + + DrawText(SX, SY, title_string, FS_BIG, FC_GREEN); + + for(i=0; iname , max_buffer_len); + buffer[max_buffer_len] = '\0'; + + DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color); + + if (node->parent_link) + initCursor(i, GFX_ARROW_BLUE_LEFT); + else if (node->level_group) + initCursor(i, GFX_ARROW_BLUE_RIGHT); + else + initCursor(i, GFX_KUGEL_BLAU); + } + + if (first_entry > 0) + DrawGraphic(0, 1, GFX_ARROW_BLUE_UP); + + if (first_entry + num_page_entries < num_entries) + DrawGraphic(0, MAX_MENU_ENTRIES_ON_SCREEN + 1, GFX_ARROW_BLUE_DOWN); +} + +static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti) +{ + TreeInfo *node, *node_first; + int x, last_redraw_mask = redraw_mask; + char *text = (ti->type == TREE_TYPE_LEVEL_DIR ? "group" : "directory"); + + node_first = getTreeInfoFirstGroupEntry(ti); + node = getTreeInfoFromPos(node_first, entry_pos); + + ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32); + + if (node->parent_link) + DrawTextFCentered(40, FC_RED, "leave %s \"%s\"", text, node->class_desc); + else if (node->level_group) + DrawTextFCentered(40, FC_RED, "enter %s \"%s\"", text, node->class_desc); + else if (ti->type == TREE_TYPE_LEVEL_DIR) + DrawTextFCentered(40, FC_RED, "%3d levels (%s)", + node->levels, node->class_desc); + + /* let BackToFront() redraw only what is needed */ + redraw_mask = last_redraw_mask | REDRAW_TILES; + for (x=0; xcl_cursor; + int step = (button == 1 ? 1 : button == 2 ? 5 : 10); + int num_entries = numTreeInfoInGroup(ti); + int num_page_entries; + + if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN) + num_page_entries = num_entries; + else + num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1; + + if (button == MB_MENU_INITIALIZE) + { + int entry_pos = posTreeInfo(ti); + + if (ti->cl_first == -1) + { + ti->cl_first = MAX(0, entry_pos - num_page_entries + 1); + ti->cl_cursor = + entry_pos - ti->cl_first; + } + + if (dx == 999) /* first entry is set by scrollbar position */ + ti->cl_first = dy; + else + AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, + ti->cl_first, ti); + + drawChooseTreeList(ti->cl_first, num_page_entries, ti); + drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); + drawCursor(ti->cl_cursor, FC_RED); + return; + } + else if (button == MB_MENU_LEAVE) + { + if (ti->node_parent) + { + *ti_ptr = ti->node_parent; + DrawChooseTree(ti_ptr); + } + else + { + game_status = MAINMENU; + DrawMainMenu(); + } + return; + } + + if (mx || my) /* mouse input */ + { + x = (mx - SX) / 32; + y = (my - SY) / 32 - MENU_SCREEN_START_YPOS; + } + else if (dx || dy) /* keyboard input */ + { + if (dy) + y = ti->cl_cursor + dy; + + if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */ + { + dy = SIGN(dy); + step = num_page_entries - 1; + y = (dy < 0 ? -1 : num_page_entries); + } + } + + if (x == 0 && y == -1) + { + if (ti->cl_first > 0 && + (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY))) + { + ti->cl_first -= step; + if (ti->cl_first < 0) + ti->cl_first = 0; + + drawChooseTreeList(ti->cl_first, num_page_entries, ti); + drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); + drawCursor(ti->cl_cursor, FC_RED); + AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, + ti->cl_first, ti); + return; + } + } + else if (x == 0 && y > num_page_entries - 1) + { + if (ti->cl_first + num_page_entries < num_entries && + (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY))) + { + ti->cl_first += step; + if (ti->cl_first + num_page_entries > num_entries) + ti->cl_first = MAX(0, num_entries - num_page_entries); + + drawChooseTreeList(ti->cl_first, num_page_entries, ti); + drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); + drawCursor(ti->cl_cursor, FC_RED); + AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, + ti->cl_first, ti); + return; + } + } + + if (dx == 1) + { + TreeInfo *node_first, *node_cursor; + int entry_pos = ti->cl_first + y; + + node_first = getTreeInfoFirstGroupEntry(ti); + node_cursor = getTreeInfoFromPos(node_first, entry_pos); + + if (node_cursor->node_group) + { + node_cursor->cl_first = ti->cl_first; + node_cursor->cl_cursor = ti->cl_cursor; + *ti_ptr = node_cursor->node_group; + DrawChooseTree(ti_ptr); + return; + } + } + else if (dx == -1 && ti->node_parent) + { + *ti_ptr = ti->node_parent; + DrawChooseTree(ti_ptr); + return; + } + + if (x == 0 && y >= 0 && y < num_page_entries) + { + if (button) + { + if (y != ti->cl_cursor) + { + drawCursor(y, FC_RED); + drawCursor(ti->cl_cursor, FC_BLUE); + drawChooseTreeInfo(ti->cl_first + y, ti); + ti->cl_cursor = y; + } + } + else + { + TreeInfo *node_first, *node_cursor; + int entry_pos = ti->cl_first + y; + + node_first = getTreeInfoFirstGroupEntry(ti); + node_cursor = getTreeInfoFromPos(node_first, entry_pos); + + if (node_cursor->node_group) + { + node_cursor->cl_first = ti->cl_first; + node_cursor->cl_cursor = ti->cl_cursor; + *ti_ptr = node_cursor->node_group; + DrawChooseTree(ti_ptr); + } + else if (node_cursor->parent_link) + { + *ti_ptr = node_cursor->node_parent; + DrawChooseTree(ti_ptr); + } + else + { + node_cursor->cl_first = ti->cl_first; + node_cursor->cl_cursor = ti->cl_cursor; + *ti_ptr = node_cursor; + + if (ti->type == TREE_TYPE_LEVEL_DIR) + { + LoadLevelSetup_SeriesInfo(); + + SaveLevelSetup_LastSeries(); + SaveLevelSetup_SeriesInfo(); + TapeErase(); + } + + game_status = MAINMENU; + DrawMainMenu(); + } + } + } + + BackToFront(); + + if (game_status == CHOOSELEVEL || game_status == SETUP) + DoAnimation(); +} + +void DrawChooseLevel() +{ + DrawChooseTree(&leveldir_current); +} + +void HandleChooseLevel(int mx, int my, int dx, int dy, int button) +{ + HandleChooseTree(mx, my, dx, dy, button, &leveldir_current); +} + + +#else + + void DrawChooseLevel() { UnmapAllGadgets(); @@ -1200,6 +1510,9 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) DoAnimation(); } +#endif + + void DrawHallOfFame(int highlight_position) { UnmapAllGadgets(); @@ -2449,7 +2762,7 @@ void CreateScreenGadgets() CreateScreenScrollbars(); } -void MapChooseLevelGadgets() +void MapChooseTreeGadgets() { int num_leveldirs = numTreeInfoInGroup(leveldir_current); int i; @@ -2461,7 +2774,7 @@ void MapChooseLevelGadgets() MapGadget(screen_gadget[i]); } -void UnmapChooseLevelGadgets() +void UnmapChooseTreeGadgets() { int i; diff --git a/src/screens.h b/src/screens.h index bf0702b4..6180547e 100644 --- a/src/screens.h +++ b/src/screens.h @@ -42,7 +42,7 @@ void HandleSetupScreen(int, int, int, int, int); void HandleGameActions(void); void CreateScreenGadgets(); -void MapChooseLevelGadgets(); -void UnmapChooseLevelGadgets(); +void MapChooseTreeGadgets(); +void UnmapChooseTreeGadgets(); #endif /* SCREENS_H */ diff --git a/src/timestamp.h b/src/timestamp.h index a8481f46..2643a1de 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-04-02 01:43]" +#define COMPILE_DATE_STRING "[2002-04-02 02:41]"