From: Holger Schemel Date: Tue, 28 Sep 1999 23:38:34 +0000 (+0200) Subject: rnd-19990929-1-src X-Git-Tag: 1.4.0^2~10 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=11c94b20f4d8020213d2df5fde3637e837a03f05;p=rocksndiamonds.git rnd-19990929-1-src --- diff --git a/src/files.c b/src/files.c index 1e44ad71..f1b581fe 100644 --- a/src/files.c +++ b/src/files.c @@ -1629,7 +1629,7 @@ static int LoadLevelInfoFromLevelDir(char *level_directory, int start_entry) if (leveldir[current_entry].name_sorting == NULL) leveldir[current_entry].name_sorting = - getStringCopy(leveldir[current_entry].name_short); + getStringCopy(leveldir[current_entry].name); leveldir[current_entry].filename = getStringCopy(dir_entry->d_name); leveldir[current_entry].last_level = diff --git a/src/init.c b/src/init.c index b8fe9cc7..4adf31ec 100644 --- a/src/init.c +++ b/src/init.c @@ -85,8 +85,8 @@ void OpenAll(int argc, char *argv[]) InitGfx(); InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ - InitGadgets(); InitLevelAndPlayerInfo(); + InitGadgets(); /* needs to know number of level series */ DrawMainMenu(); @@ -813,6 +813,7 @@ void InitGadgets() CreateGameButtons(); CreateTapeButtons(); CreateToolButtons(); + CreateScreenGadgets(); } void InitElementProperties() diff --git a/src/screens.c b/src/screens.c index 6fccd1dc..75727695 100644 --- a/src/screens.c +++ b/src/screens.c @@ -41,6 +41,20 @@ /* for HandleChooseLevel() */ #define MAX_LEVEL_SERIES_ON_SCREEN (SCR_FIELDY - 2) +/* buttons and scrollbars identifiers */ +#define SCREEN_CTRL_ID_SCROLL_UP 0 +#define SCREEN_CTRL_ID_SCROLL_DOWN 1 +#define SCREEN_CTRL_ID_SCROLL_VERTICAL 2 + +#define NUM_SCREEN_SCROLLBUTTONS 2 +#define NUM_SCREEN_SCROLLBARS 1 +#define NUM_SCREEN_GADGETS 3 + +/* forward declaration for internal use */ +static void HandleScreenGadgets(struct GadgetInfo *); + +static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS]; + #ifdef MSDOS extern unsigned char get_ascii(KeySym); #endif @@ -815,17 +829,39 @@ void DrawChooseLevel() UnmapAllGadgets(); CloseDoor(DOOR_CLOSE_2); + ClearWindow(); + HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE); + MapChooseLevelGadgets(); + FadeToFront(); InitAnimation(); - HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE); +} + +static void AdjustChooseLevelScrollbar(int id, int first_entry) +{ + struct GadgetInfo *gi = screen_gadget[id]; + int items_max, items_visible, item_position; + + items_max = num_leveldirs; + items_visible = MAX_LEVEL_SERIES_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 drawChooseLevelList(int first_entry, int num_page_entries) { int i; char buffer[SCR_FIELDX * 2]; + int max_buffer_len = (SCR_FIELDX - 2) * 2; + + XFillRectangle(display, backbuffer, gc, SX, SY, SXSIZE - 32, SYSIZE); + redraw_mask |= REDRAW_FIELD; - ClearWindow(); DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN); for(i=0; icustom_id; + + if (game_status != CHOOSELEVEL) + return; + + switch (id) + { + case SCREEN_CTRL_ID_SCROLL_UP: + HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK); + break; + + case SCREEN_CTRL_ID_SCROLL_DOWN: + HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK); + break; + + case SCREEN_CTRL_ID_SCROLL_VERTICAL: + HandleChooseLevel(0,0, 1,gi->event.item_position, MB_MENU_INITIALIZE); + break; + + default: + break; + } +} diff --git a/src/screens.h b/src/screens.h index 67ee9c28..d4043273 100644 --- a/src/screens.h +++ b/src/screens.h @@ -38,4 +38,8 @@ void CustomizeKeyboard(int); void CalibrateJoystick(int); void HandleGameActions(void); +void CreateScreenGadgets(); +void MapChooseLevelGadgets(); +void UnmapChooseLevelGadgets(); + #endif /* SCREENS_H */