From: Holger Schemel Date: Sun, 30 Nov 2003 01:59:46 +0000 (+0100) Subject: rnd-20031130-1-src X-Git-Tag: 3.0.8^2~11 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=2a357b702b5ceb9bf9173ac02f68cf42340b3158 rnd-20031130-1-src --- diff --git a/src/conftime.h b/src/conftime.h index c1ac7383..7643c40f 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-11-29 19:53]" +#define COMPILE_DATE_STRING "[2003-11-30 02:58]" diff --git a/src/events.c b/src/events.c index 92cda692..8cb7c51d 100644 --- a/src/events.c +++ b/src/events.c @@ -374,7 +374,11 @@ void HandleButton(int mx, int my, int button) old_my = my; } - HandleGadgets(mx, my, button); + if (HandleGadgets(mx, my, button)) + { + /* do not handle this button event anymore */ + mx = my = 0; + } switch(game_status) { @@ -398,7 +402,7 @@ void HandleButton(int mx, int my, int button) break; case GAME_MODE_INFO: - HandleInfoScreen(button); + HandleInfoScreen(mx,my, 0,0, button); break; case GAME_MODE_SETUP: @@ -409,11 +413,10 @@ void HandleButton(int mx, int my, int button) #ifdef DEBUG if (button == MB_RELEASED) { - int sx = (mx - SX) / TILEX; - int sy = (my - SY) / TILEY; - - if (IN_VIS_FIELD(sx,sy)) + if (IN_GFX_SCREEN(mx, my)) { + int sx = (mx - SX) / TILEX; + int sy = (my - SY) / TILEY; int x = LEVELX(sx); int y = LEVELY(sy); @@ -563,19 +566,6 @@ void HandleKey(Key key, int key_status) return; } - /* allow quick escape to the main menu with the Escape key */ - if (key == KSYM_Escape && - game_status != GAME_MODE_MAIN && - game_status != GAME_MODE_PLAYING && - game_status != GAME_MODE_EDITOR && - game_status != GAME_MODE_LEVELS && - game_status != GAME_MODE_SETUP) - { - game_status = GAME_MODE_MAIN; - DrawMainMenu(); - return; - } - /* special key shortcuts */ if (game_status == GAME_MODE_MAIN || game_status == GAME_MODE_PLAYING) { @@ -587,17 +577,11 @@ void HandleKey(Key key, int key_status) TapeTogglePause(TAPE_TOGGLE_MANUAL); } -#if 0 -#ifndef DEBUG - - if (game_status == GAME_MODE_PLAYING && (tape.playing || tape.pausing)) - return; - -#endif -#endif - - - HandleGadgetsKeyInput(key); + if (HandleGadgetsKeyInput(key)) + { + if (key != KSYM_Escape) /* always allow ESC key to be handled */ + key = KSYM_UNDEFINED; + } switch(game_status) { @@ -608,6 +592,7 @@ void HandleKey(Key key, int key_status) case GAME_MODE_MAIN: case GAME_MODE_LEVELS: case GAME_MODE_SETUP: + case GAME_MODE_INFO: switch(key) { case KSYM_Return: @@ -617,6 +602,8 @@ void HandleKey(Key key, int key_status) HandleChooseLevel(0,0, 0,0, MB_MENU_CHOICE); else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 0,0, MB_MENU_CHOICE); + else if (game_status == GAME_MODE_INFO) + HandleInfoScreen(0,0, 0,0, MB_MENU_CHOICE); break; case KSYM_Escape: @@ -624,6 +611,8 @@ void HandleKey(Key key, int key_status) HandleChooseLevel(0,0, 0,0, MB_MENU_LEAVE); else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 0,0, MB_MENU_LEAVE); + else if (game_status == GAME_MODE_INFO) + HandleInfoScreen(0,0, 0,0, MB_MENU_LEAVE); break; case KSYM_Page_Up: @@ -631,6 +620,8 @@ void HandleKey(Key key, int key_status) HandleChooseLevel(0,0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); + else if (game_status == GAME_MODE_INFO) + HandleInfoScreen(0,0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); break; case KSYM_Page_Down: @@ -638,6 +629,8 @@ void HandleKey(Key key, int key_status) HandleChooseLevel(0,0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); + else if (game_status == GAME_MODE_INFO) + HandleInfoScreen(0,0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); break; #ifdef DEBUG @@ -651,17 +644,13 @@ void HandleKey(Key key, int key_status) } break; - case GAME_MODE_INFO: - HandleInfoScreen(MB_RELEASED); - break; - case GAME_MODE_SCORES: switch(key) { case KSYM_Return: + case KSYM_Escape: game_status = GAME_MODE_MAIN; DrawMainMenu(); - BackToFront(); break; case KSYM_Page_Up: @@ -834,7 +823,13 @@ void HandleKey(Key key, int key_status) break; } default: - break; + if (key == KSYM_Escape) + { + game_status = GAME_MODE_MAIN; + DrawMainMenu(); + + return; + } } } @@ -899,6 +894,7 @@ void HandleJoystick() case GAME_MODE_MAIN: case GAME_MODE_LEVELS: case GAME_MODE_SETUP: + case GAME_MODE_INFO: { static unsigned long joystickmove_delay = 0; @@ -912,6 +908,8 @@ void HandleJoystick() HandleChooseLevel(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); + else if (game_status == GAME_MODE_INFO) + HandleInfoScreen(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); break; } @@ -919,10 +917,6 @@ void HandleJoystick() HandleHallOfFame(0,0, dx,dy, !newbutton); break; - case GAME_MODE_INFO: - HandleInfoScreen(!newbutton); - break; - case GAME_MODE_EDITOR: HandleLevelEditorIdle(); break; diff --git a/src/files.c b/src/files.c index f445f8dd..011f715e 100644 --- a/src/files.c +++ b/src/files.c @@ -2846,7 +2846,7 @@ void LoadUserDefinedEditorElementList(int **elements, int *num_elements) #endif } -static struct MusicFileInfo *get_music_file_info(char *basename) +static struct MusicFileInfo *get_music_file_info(char *basename, int music) { SetupFileHash *setup_file_hash = NULL; struct MusicFileInfo tmp_music_file_info, *new_music_file_info; @@ -2911,14 +2911,19 @@ static struct MusicFileInfo *get_music_file_info(char *basename) /* ---------- music file info found ---------- */ + memset(&tmp_music_file_info, 0, sizeof(struct MusicFileInfo)); + for (i = 0; token_to_value_ptr[i].token != NULL; i++) { char *value = getHashEntry(setup_file_hash, token_to_value_ptr[i].token); - *token_to_value_ptr[i].value_ptr = getStringCopy(value); /* may be NULL */ + *token_to_value_ptr[i].value_ptr = + getStringCopy(value != NULL ? value : UNKNOWN_NAME); } - new_music_file_info = checked_calloc(sizeof(struct MusicFileInfo)); + tmp_music_file_info.music = music; + + new_music_file_info = checked_malloc(sizeof(struct MusicFileInfo)); *new_music_file_info = tmp_music_file_info; return new_music_file_info; @@ -2928,6 +2933,7 @@ void LoadMusicInfo() { char *music_directory = getCustomMusicDirectory(); int num_music = getMusicListSize(); + int num_music_noconf = 0; DIR *dir; struct dirent *dir_entry; struct FileInfo *music; @@ -2963,11 +2969,15 @@ void LoadMusicInfo() if (strcmp(music->filename, UNDEFINED_FILENAME) == 0) continue; + /* a configured file may be not recognized as music */ + if (!FileIsMusic(music->filename)) + continue; + #if 0 - printf("::: -> '%s'\n", music->filename); + printf("::: -> '%s' (configured)\n", music->filename); #endif - *new = get_music_file_info(music->filename); + *new = get_music_file_info(music->filename, i); if (*new != NULL) new = &(*new)->next; } @@ -2998,16 +3008,18 @@ void LoadMusicInfo() if (music_already_used) continue; - if (!FileIsSound(basename) && !FileIsMusic(basename)) + if (!FileIsMusic(basename)) continue; #if 0 - printf("::: -> '%s'\n", basename); + printf("::: -> '%s' (found in directory)\n", basename); #endif - *new = get_music_file_info(basename); + *new = get_music_file_info(basename, MAP_NOCONF_MUSIC(num_music_noconf)); if (*new != NULL) new = &(*new)->next; + + num_music_noconf++; } closedir(dir); diff --git a/src/game.c b/src/game.c index 22a65dc7..36e0701e 100644 --- a/src/game.c +++ b/src/game.c @@ -8734,14 +8734,10 @@ static void StopLevelSoundActionIfLoop(int x, int y, int action) static void PlayLevelMusic() { -#if 1 if (levelset.music[level_nr] != MUS_UNDEFINED) PlayMusic(levelset.music[level_nr]); /* from config file */ else - PlayMusic(-(level_nr + 1)); /* from music dir */ -#else - PlayMusic(level_nr); -#endif + PlayMusic(MAP_NOCONF_MUSIC(level_nr)); /* from music dir */ } void RaiseScore(int value) diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 15a84286..ddc5ac60 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -1302,7 +1302,7 @@ void ClickOnGadget(struct GadgetInfo *gi, int button) HandleGadgets(gi->x, gi->y, 0); } -void HandleGadgets(int mx, int my, int button) +boolean HandleGadgets(int mx, int my, int button) { static struct GadgetInfo *last_info_gi = NULL; static unsigned long pressed_delay = 0; @@ -1327,7 +1327,7 @@ void HandleGadgets(int mx, int my, int button) /* check if there are any gadgets defined */ if (gadget_list_first_entry == NULL) - return; + return FALSE; /* simulated release of mouse button over last gadget */ if (mx == -1 && my == -1 && button == 0) @@ -1591,7 +1591,7 @@ void HandleGadgets(int mx, int my, int button) /* don't handle this scrollbar anymore while mouse button pressed */ last_gi = NULL; - return; + return TRUE; } } @@ -1723,6 +1723,9 @@ void HandleGadgets(int mx, int my, int button) /* handle gadgets unmapped/mapped between pressing and releasing */ if (release_event && !gadget_released && new_gi) new_gi->state = GD_BUTTON_UNPRESSED; + + return (gadget_pressed || gadget_pressed_repeated || + gadget_released || gadget_moving); } static void insertCharIntoTextArea(struct GadgetInfo *gi, char c) @@ -1740,7 +1743,7 @@ static void insertCharIntoTextArea(struct GadgetInfo *gi, char c) setTextAreaCursorPosition(gi, gi->textarea.cursor_position + 1); } -void HandleGadgetsKeyInput(Key key) +boolean HandleGadgetsKeyInput(Key key) { struct GadgetInfo *gi = last_gi; @@ -1748,7 +1751,7 @@ void HandleGadgetsKeyInput(Key key) !(gi->type & GD_TYPE_TEXT_INPUT || gi->type & GD_TYPE_TEXT_AREA || gi->type & GD_TYPE_SELECTBOX)) - return; + return FALSE; if (key == KSYM_Return) /* valid for both text input and selectbox */ { @@ -1900,4 +1903,6 @@ void HandleGadgetsKeyInput(Key key) DrawGadget(gi, DG_PRESSED, gi->direct_draw); } } + + return TRUE; } diff --git a/src/libgame/gadgets.h b/src/libgame/gadgets.h index 160bd611..4e1dd0f7 100644 --- a/src/libgame/gadgets.h +++ b/src/libgame/gadgets.h @@ -249,7 +249,7 @@ void RemapAllGadgets(); boolean anyTextGadgetActive(); void ClickOnGadget(struct GadgetInfo *, int); -void HandleGadgets(int, int, int); -void HandleGadgetsKeyInput(Key); +boolean HandleGadgets(int, int, int); +boolean HandleGadgetsKeyInput(Key); #endif /* GADGETS_H */ diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 7bc108bb..cb06ff46 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1559,18 +1559,30 @@ boolean fileHasSuffix(char *basename, char *suffix) return FALSE; } -boolean FileIsGraphic(char *basename) +boolean FileIsGraphic(char *filename) { + char *basename = strrchr(filename, '/'); + + basename = (basename != NULL ? basename + 1 : filename); + return fileHasSuffix(basename, "pcx"); } -boolean FileIsSound(char *basename) +boolean FileIsSound(char *filename) { + char *basename = strrchr(filename, '/'); + + basename = (basename != NULL ? basename + 1 : filename); + return fileHasSuffix(basename, "wav"); } -boolean FileIsMusic(char *basename) +boolean FileIsMusic(char *filename) { + char *basename = strrchr(filename, '/'); + + basename = (basename != NULL ? basename + 1 : filename); + if (FileIsSound(basename)) return TRUE; diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 512d0506..2220e714 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -33,13 +33,14 @@ TYPE_YES_NO) /* additional values for setup screen */ -#define TYPE_ENTER_MENU (1 << 8) -#define TYPE_LEAVE_MENU (1 << 9) -#define TYPE_EMPTY (1 << 10) -#define TYPE_KEYTEXT (1 << 11) +#define TYPE_ENTER_SCREEN (1 << 8) +#define TYPE_ENTER_MENU (1 << 9) +#define TYPE_LEAVE_MENU (1 << 10) +#define TYPE_EMPTY (1 << 11) +#define TYPE_KEYTEXT (1 << 12) -#define TYPE_GHOSTED (1 << 12) -#define TYPE_QUERY (1 << 13) +#define TYPE_GHOSTED (1 << 13) +#define TYPE_QUERY (1 << 14) #define TYPE_VALUE (TYPE_BOOLEAN_STYLE | \ TYPE_KEY | \ @@ -52,7 +53,8 @@ TYPE_KEY | \ TYPE_STRING) -#define TYPE_ENTER_OR_LEAVE_MENU (TYPE_ENTER_MENU | \ +#define TYPE_ENTER_OR_LEAVE_MENU (TYPE_ENTER_SCREEN | \ + TYPE_ENTER_MENU | \ TYPE_LEAVE_MENU) /* cookie token for file identifier and version number */ diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 96165fe4..ea4e8463 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -862,7 +862,7 @@ static void Mixer_InsertSound(SoundControl snd_ctrl) if (num_music_noconf == 0) /* no fallback music available */ return; - snd_ctrl.nr = (-(snd_ctrl.nr + 1)) % num_music_noconf; + snd_ctrl.nr = UNMAP_NOCONF_MUSIC(snd_ctrl.nr) % num_music_noconf; snd_info = Music_NoConf[snd_ctrl.nr]; } else @@ -1868,13 +1868,9 @@ static void *Load_MOD(char *filename) static void *Load_WAV_or_MOD(char *filename) { - char *basename = strrchr(filename, '/'); - - basename = (basename != NULL ? basename + 1 : filename); - - if (FileIsSound(basename)) + if (FileIsSound(filename)) return Load_WAV(filename); - else if (FileIsMusic(basename)) + else if (FileIsMusic(filename)) return Load_MOD(filename); else return NULL; @@ -1944,10 +1940,15 @@ void LoadCustomMusic_NoConf(void) filename = getPath2(music_directory, basename); +#if 1 + if (FileIsMusic(basename)) + mus_info = Load_WAV_or_MOD(filename); +#else if (FileIsSound(basename)) mus_info = Load_WAV(filename); else if (FileIsMusic(basename)) mus_info = Load_MOD(filename); +#endif free(filename); diff --git a/src/libgame/sound.h b/src/libgame/sound.h index b4bcafcf..17a1cee2 100644 --- a/src/libgame/sound.h +++ b/src/libgame/sound.h @@ -102,6 +102,10 @@ SND_CTRL_RELOAD_MUSIC)) #define ALL_SOUNDS(x) ((x).state & SND_CTRL_ALL_SOUNDS) +#define MAP_NOCONF_MUSIC(x) (-((x) + 1)) +#define UNMAP_NOCONF_MUSIC(x) MAP_NOCONF_MUSIC(x) + + #define SOUND_MIN_VOLUME 0 #if defined(TARGET_SDL) #define SOUND_MAX_VOLUME SDL_MIX_MAXVOLUME diff --git a/src/libgame/system.h b/src/libgame/system.h index 4f4496a6..d0594377 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -157,6 +157,12 @@ #define REDRAW_FPS (1 << 11) #define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2) +#define IN_GFX_SCREEN(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \ + y >= gfx.sy && y < gfx.sy + gfx.sysize) +#define IN_GFX_DOOR(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \ + y >= gfx.dy && y < gfx.dy + gfx.dysize) +#define IN_GFX_VIDEO(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \ + y >= gfx.vy && y < gfx.vy + gfx.vysize) /* values for mouse cursor */ #define CURSOR_DEFAULT 0 @@ -175,6 +181,9 @@ /* default name for unknown player names */ #define ANONYMOUS_NAME "anonymous" +/* default for other unknown names */ +#define UNKNOWN_NAME "unknown" + /* default name for new levels */ #define NAMELESS_LEVEL_NAME "nameless level" diff --git a/src/main.h b/src/main.h index 1b002b0d..ff701a20 100644 --- a/src/main.h +++ b/src/main.h @@ -1542,6 +1542,8 @@ struct MusicFileInfo char *album; char *year; + int music; + struct MusicFileInfo *next; }; diff --git a/src/screens.c b/src/screens.c index 346bb927..efa7e2e2 100644 --- a/src/screens.c +++ b/src/screens.c @@ -46,12 +46,13 @@ #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1) /* screens on the info screen */ -#define INFO_MODE_ELEMENTS 0 -#define INFO_MODE_MUSIC 1 -#define INFO_MODE_CREDITS 2 -#define INFO_MODE_PROGRAM 3 +#define INFO_MODE_MAIN 0 +#define INFO_MODE_ELEMENTS 1 +#define INFO_MODE_MUSIC 2 +#define INFO_MODE_CREDITS 3 +#define INFO_MODE_PROGRAM 4 -#define MAX_INFO_MODES 4 +#define MAX_INFO_MODES 5 /* for various menu stuff */ #define MAX_INFO_ELEMENTS_ON_SCREEN 10 @@ -77,21 +78,23 @@ static void CalibrateJoystick(int); static void execSetupArtwork(void); static void HandleChooseTree(int, int, int, int, int, TreeInfo **); -static void DrawInfoScreenDemoAnim(int, boolean); -static void DrawInfoScreenDemoText(int, int, int, int); -static void DrawInfoScreenMusicText(int); -static void DrawInfoScreenCreditsText(void); +static void DrawChooseLevel(void); static void DrawInfoScreen(void); +static void DrawSetupScreen(void); + +static void DrawInfoScreen_HelpAnim(int, int, boolean); +static void DrawInfoScreen_HelpText(int, int, int, int); +static void HandleInfoScreen_Main(int, int, int, int, int); +static void HandleInfoScreen_Elements(int); +static void HandleInfoScreen_Music(int); +static void HandleInfoScreen_Credits(int); +static void HandleInfoScreen_Program(int); + +static void MapChooseTreeGadgets(TreeInfo *); static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS]; static int setup_mode = SETUP_MODE_MAIN; - -static long infoscreen_state; -static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN]; -static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN]; -static int num_infoscreen_elements; -static int num_infoscreen_music; -static int infoscreen_musicpos; +static int info_mode = INFO_MODE_MAIN; #define mSX (SX + (game_status >= GAME_MODE_MAIN && \ game_status <= GAME_MODE_SETUP ? \ @@ -329,7 +332,8 @@ void DrawMainMenu() FadeToFront(); InitAnimation(); - HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE); + + HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE); TapeStop(); if (TAPE_IS_EMPTY(tape)) @@ -340,10 +344,6 @@ void DrawMainMenu() PlayMenuMusic(); OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); - -#if 0 - ClearEventQueue(); -#endif } static void gotoTopLevelDir() @@ -439,7 +439,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) DelayReached(&level_delay, 0); /* reset delay counter */ } } - else if (x == 0 && y >= 0 && y <= 7) + else if (IN_GFX_SCREEN(mx, my) && + y >= 0 && y <= 7 && (y != 1 || x < 10)) { if (button) { @@ -486,6 +487,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) else if (y == 4) { game_status = GAME_MODE_INFO; + info_mode = INFO_MODE_MAIN; DrawInfoScreen(); } else if (y == 5) @@ -525,13 +527,185 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE); DoAnimation(); } +} - BackToFront(); + +/* ========================================================================= */ +/* info screen functions */ +/* ========================================================================= */ + +static struct TokenInfo *info_info; +static int num_info_info; + +static void execInfoElements() +{ + info_mode = INFO_MODE_ELEMENTS; + DrawInfoScreen(); +} + +static void execInfoMusic() +{ + info_mode = INFO_MODE_MUSIC; + DrawInfoScreen(); +} + +static void execInfoCredits() +{ + info_mode = INFO_MODE_CREDITS; + DrawInfoScreen(); +} + +static void execInfoProgram() +{ + info_mode = INFO_MODE_PROGRAM; + DrawInfoScreen(); +} + +static void execExitInfo() +{ + game_status = GAME_MODE_MAIN; + DrawMainMenu(); +} + +static struct TokenInfo info_info_main[] = +{ + { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" }, + { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" }, + { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" }, + { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_LEAVE_MENU, execExitInfo, "Exit" }, + + { 0, NULL, NULL } +}; + +static void DrawInfoScreen_Main() +{ + int i; + + UnmapAllGadgets(); + CloseDoor(DOOR_CLOSE_2); + + ClearWindow(); + + DrawText(mSX + 16, mSY + 16, "Info Screen", FONT_TITLE_1); + + info_info = info_info_main; + num_info_info = 0; + + for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++) + { + int ypos = MENU_SCREEN_START_YPOS + i; + int font_nr = FONT_MENU_1; + + DrawText(mSX + 32, mSY + ypos * 32, info_info[i].text, font_nr); + + if (info_info[i].type & TYPE_ENTER_MENU) + initCursor(i, IMG_MENU_BUTTON_RIGHT); + else if (info_info[i].type & TYPE_LEAVE_MENU) + initCursor(i, IMG_MENU_BUTTON_LEFT); + else if (info_info[i].type & ~TYPE_SKIP_ENTRY) + initCursor(i, IMG_MENU_BUTTON); + + num_info_info++; + } + + FadeToFront(); + InitAnimation(); + + PlayMenuSound(); + PlayMenuMusic(); + + HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE); +} + +void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button) +{ + static int choice_store[MAX_INFO_MODES]; + int choice = choice_store[info_mode]; /* always starts with 0 */ + int x = 0; + int y = choice; + + if (button == MB_MENU_INITIALIZE) + { + /* advance to first valid menu entry */ + while (choice < num_info_info && + info_info[choice].type & TYPE_SKIP_ENTRY) + choice++; + choice_store[info_mode] = choice; + + drawCursor(choice, FC_RED); + return; + } + else if (button == MB_MENU_LEAVE) + { + for (y = 0; y < num_info_info; y++) + { + if (info_info[y].type & TYPE_LEAVE_MENU) + { + void (*menu_callback_function)(void) = info_info[y].value; + + menu_callback_function(); + break; /* absolutely needed because function changes 'info_info'! */ + } + } + + return; + } + + if (mx || my) /* mouse input */ + { + x = (mx - mSX) / 32; + y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS; + } + else if (dx || dy) /* keyboard input */ + { + if (dx) + { + int menu_navigation_type = (dx < 0 ? TYPE_LEAVE_MENU : TYPE_ENTER_MENU); + + if (info_info[choice].type & menu_navigation_type || + info_info[choice].type & TYPE_ENTER_SCREEN || + info_info[choice].type & TYPE_BOOLEAN_STYLE) + button = MB_MENU_CHOICE; + } + else if (dy) + y = choice + dy; + + /* jump to next non-empty menu entry (up or down) */ + while (y > 0 && y < num_info_info - 1 && + info_info[y].type & TYPE_SKIP_ENTRY) + y += dy; + } + + if (IN_GFX_SCREEN(mx, my) && + y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY) + { + if (button) + { + if (y != choice) + { + drawCursor(y, FC_RED); + drawCursor(choice, FC_BLUE); + choice = choice_store[info_mode] = y; + } + } + else if (!(info_info[y].type & TYPE_GHOSTED)) + { + if (info_info[y].type & TYPE_ENTER_OR_LEAVE_MENU) + { + void (*menu_callback_function)(void) = info_info[choice].value; + + menu_callback_function(); + } + } + } } -void DrawInfoScreenDemoAnim(int start, boolean init) +void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init) { - int i = 0, j = 0; + static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN]; + static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN]; int xstart = mSX + 16; int ystart = mSY + 64 + 2 * 32; int ystep = TILEY + 4; @@ -539,9 +713,13 @@ void DrawInfoScreenDemoAnim(int start, boolean init) int graphic; int delay; int sync_frame; + int i, j; if (init) { + for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++) + infoscreen_step[i] = infoscreen_frame[i] = 0; + SetMainBackgroundImage(IMG_BACKGROUND_INFO); ClearWindow(); DrawHeadline(); @@ -550,12 +728,15 @@ void DrawInfoScreenDemoAnim(int start, boolean init) DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4, "Press any key or button for next page"); + + FrameCounter = 0; } + i = j = 0; while (helpanim_info[j].element != HELPANIM_LIST_END) { if (i >= start + MAX_INFO_ELEMENTS_ON_SCREEN || - i >= num_infoscreen_elements) + i >= max_anims) break; else if (i < start) { @@ -620,7 +801,7 @@ void DrawInfoScreenDemoAnim(int start, boolean init) graphic, sync_frame, USE_MASKING); if (init) - DrawInfoScreenDemoText(element, action, direction, i - start); + DrawInfoScreen_HelpText(element, action, direction, i - start); i++; } @@ -630,7 +811,7 @@ void DrawInfoScreenDemoAnim(int start, boolean init) FrameCounter++; } -void DrawInfoScreenDemoText(int element, int action, int direction, int ypos) +void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos) { int font_nr = FONT_TEXT_2; int max_chars_per_line = 34; @@ -640,10 +821,12 @@ void DrawInfoScreenDemoText(int element, int action, int direction, int ypos) int ystep = TILEY + 4; char *text; + /* 1st try: get text for base element */ text = getHashEntry(helptext_info, element_info[element].token_name); if (text == NULL) { + /* 2nd try: get text for element/action/direction */ char token[MAX_LINE_LEN]; strcpy(token, element_info[element].token_name); @@ -660,51 +843,172 @@ void DrawInfoScreenDemoText(int element, int action, int direction, int ypos) text = "No description available"; } - if (strlen(text) <= max_chars_per_line) + if (strlen(text) <= max_chars_per_line) /* only one line of text */ sy += getFontHeight(font_nr) / 2; DrawTextWrapped(sx, sy + ypos * ystep, text, font_nr, max_chars_per_line, max_lines_per_text); } -void DrawInfoScreenMusicText(int num) +void DrawInfoScreen_Elements() { - struct MusicFileInfo *list = music_file_info; - int ystart = 150, ystep = 30; - int ybottom = SYSIZE - 20; + LoadHelpAnimInfo(); + LoadHelpTextInfo(); + + HandleInfoScreen_Elements(MB_MENU_INITIALIZE); + + FadeToFront(); + InitAnimation(); +} + +void HandleInfoScreen_Elements(int button) +{ + static unsigned long info_delay = 0; + static int num_anims; + static int num_pages; + static int page; + int anims_per_page = MAX_INFO_ELEMENTS_ON_SCREEN; + int button_released = !button; int i; - for (i=0; i < num && list; i++) - list = list->next; + if (button == MB_MENU_INITIALIZE) + { + boolean new_element = TRUE; - FadeSoundsAndMusic(); + num_anims = 0; + for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++) + { + if (helpanim_info[i].element == HELPANIM_LIST_NEXT) + new_element = TRUE; + else if (new_element) + { + num_anims++; + new_element = FALSE; + } + } + + num_pages = (num_anims + anims_per_page - 1) / anims_per_page; + page = 0; + } + else if (button == MB_MENU_LEAVE) + { + info_mode = INFO_MODE_MAIN; + DrawInfoScreen(); + + return; + } + + if (button_released || button == MB_MENU_INITIALIZE) + { + if (button != MB_MENU_INITIALIZE) + page++; + + if (page >= num_pages) + { + FadeSoundsAndMusic(); + + info_mode = INFO_MODE_MAIN; + DrawInfoScreen(); + + return; + } + + DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE); + } + else + { + if (DelayReached(&info_delay, GAME_FRAME_DELAY)) + if (page < num_pages) + DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE); + + PlayMenuSoundIfLoop(); + } +} + +void DrawInfoScreen_Music() +{ ClearWindow(); DrawHeadline(); - DrawTextSCentered(100, FONT_TEXT_1, "The game background music loops:"); + LoadMusicInfo(); - DrawTextSCentered(ystart + 0 * ystep, FONT_TEXT_2, "Excerpt from"); - DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3, "\"%s\"", list->title); - DrawTextSCentered(ystart + 2 * ystep, FONT_TEXT_2, "by"); - DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_3, "%s", list->artist); - DrawTextSCentered(ystart + 4 * ystep, FONT_TEXT_2, "from the album"); - DrawTextFCentered(ystart + 5 * ystep, FONT_TEXT_3, "\"%s\"", list->album); + HandleInfoScreen_Music(MB_MENU_INITIALIZE); +} - DrawTextSCentered(ybottom, FONT_TEXT_4, - "Press any key or button for next page"); +void HandleInfoScreen_Music(int button) +{ + static struct MusicFileInfo *list = NULL; + int ystart = 150, ystep = 30; + int ybottom = SYSIZE - 20; + int button_released = !button; - /* !!! add playing music !!! */ -#if 0 - PlaySoundLoop(background_loop[num]); -#endif + if (button == MB_MENU_INITIALIZE) + { + list = music_file_info; + + if (list == NULL) + { + FadeSoundsAndMusic(); + + ClearWindow(); + DrawHeadline(); + + DrawTextSCentered(100, FONT_TEXT_1, "No music info for this level set."); + + DrawTextSCentered(ybottom, FONT_TEXT_4, + "Press any key or button for info menu"); + + return; + } + } + else if (button == MB_MENU_LEAVE) + { + info_mode = INFO_MODE_MAIN; + DrawInfoScreen(); + + return; + } + + if (button_released || button == MB_MENU_INITIALIZE) + { + if (list == NULL) + { + info_mode = INFO_MODE_MAIN; + DrawInfoScreen(); + + return; + } + + FadeSoundsAndMusic(); + + ClearWindow(); + DrawHeadline(); + + DrawTextSCentered(100, FONT_TEXT_1, "The game background music:"); + + DrawTextSCentered(ystart + 0 * ystep, FONT_TEXT_2, "Excerpt from"); + DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3, "\"%s\"", list->title); + DrawTextSCentered(ystart + 2 * ystep, FONT_TEXT_2, "by"); + DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_3, "%s", list->artist); + DrawTextSCentered(ystart + 4 * ystep, FONT_TEXT_2, "from the album"); + DrawTextFCentered(ystart + 5 * ystep, FONT_TEXT_3, "\"%s\"", list->album); + + DrawTextSCentered(ybottom, FONT_TEXT_4, + "Press any key or button for next page"); + + PlayMusic(list->music); + + list = list->next; + } } -void DrawInfoScreenCreditsText() +void DrawInfoScreen_Credits() { int ystart = 150, ystep = 30; int ybottom = SYSIZE - 20; FadeSoundsAndMusic(); + ClearWindow(); DrawHeadline(); @@ -718,10 +1022,35 @@ void DrawInfoScreenCreditsText() DrawTextSCentered(ystart + 6 * ystep, FONT_TEXT_2, "of new levels!"); DrawTextSCentered(ybottom, FONT_TEXT_4, - "Press any key or button for next page"); + "Press any key or button for info menu"); } -void DrawInfoScreenContactText() +void HandleInfoScreen_Credits(int button) +{ + int button_released = !button; + + if (button == MB_MENU_LEAVE) + { + info_mode = INFO_MODE_MAIN; + DrawInfoScreen(); + + return; + } + + if (button_released) + { + FadeSoundsAndMusic(); + + info_mode = INFO_MODE_MAIN; + DrawInfoScreen(); + } + else + { + PlayMenuSoundIfLoop(); + } +} + +void DrawInfoScreen_Program() { int ystart = 150, ystep = 30; int ybottom = SYSIZE - 20; @@ -756,155 +1085,77 @@ void DrawInfoScreenContactText() ":-)"); DrawTextSCentered(ybottom, FONT_TEXT_4, - "Press any key or button for main menu"); + "Press any key or button for info menu"); } -#if 1 -void DrawInfoScreen() +void HandleInfoScreen_Program(int button) { - struct MusicFileInfo *list; - int i; - - UnmapAllGadgets(); - CloseDoor(DOOR_CLOSE_2); - - for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++) - infoscreen_step[i] = infoscreen_frame[i] = 0; - infoscreen_musicpos = 0; - infoscreen_state = 0; - - LoadHelpAnimInfo(); - LoadHelpTextInfo(); - LoadMusicInfo(); - - num_infoscreen_elements = 0; - for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++) - if (helpanim_info[i].element == HELPANIM_LIST_NEXT) - num_infoscreen_elements++; + int button_released = !button; - num_infoscreen_music = 0; - for (list = music_file_info; list != NULL; list = list->next) - num_infoscreen_music++; + if (button == MB_MENU_LEAVE) + { + info_mode = INFO_MODE_MAIN; + DrawInfoScreen(); - DrawInfoScreenDemoAnim(0, TRUE); -#if 0 - DrawInfoScreenDemoText(0); -#endif + return; + } - FadeToFront(); - InitAnimation(); + if (button_released) + { + FadeSoundsAndMusic(); - PlayMenuSound(); - PlayMenuMusic(); + info_mode = INFO_MODE_MAIN; + DrawInfoScreen(); + } + else + { + PlayMenuSoundIfLoop(); + } } -#else - void DrawInfoScreen() { - struct MusicFileInfo *list; - int i; - - UnmapAllGadgets(); - CloseDoor(DOOR_CLOSE_2); - - for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++) - infoscreen_step[i] = infoscreen_frame[i] = 0; - infoscreen_musicpos = 0; - infoscreen_state = 0; + SetMainBackgroundImage(IMG_BACKGROUND_INFO); - LoadHelpAnimInfo(); - LoadHelpTextInfo(); - LoadMusicInfo(); - - num_infoscreen_elements = 0; - for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++) - if (helpanim_info[i].element == HELPANIM_LIST_NEXT) - num_infoscreen_elements++; - - num_infoscreen_music = 0; - for (list = music_file_info; list != NULL; list = list->next) - num_infoscreen_music++; - - DrawInfoScreenDemoAnim(0, TRUE); -#if 0 - DrawInfoScreenDemoText(0); -#endif - - FadeToFront(); - InitAnimation(); + if (info_mode == INFO_MODE_ELEMENTS) + DrawInfoScreen_Elements(); + else if (info_mode == INFO_MODE_MUSIC) + DrawInfoScreen_Music(); + else if (info_mode == INFO_MODE_CREDITS) + DrawInfoScreen_Credits(); + else if (info_mode == INFO_MODE_PROGRAM) + DrawInfoScreen_Program(); + else + DrawInfoScreen_Main(); - PlayMenuSound(); - PlayMenuMusic(); + if (info_mode != INFO_MODE_MUSIC) + { + PlayMenuSound(); + PlayMenuMusic(); + } } -#endif -void HandleInfoScreen(int button) +void HandleInfoScreen(int mx, int my, int dx, int dy, int button) { - static unsigned long hs_delay = 0; - int num_infoscreen_element_pages = - (num_infoscreen_elements + MAX_INFO_ELEMENTS_ON_SCREEN - 1) - / MAX_INFO_ELEMENTS_ON_SCREEN; - int button_released = !button; - int i; - - if (button_released) - { - if (infoscreen_state < num_infoscreen_element_pages - 1) - { - for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++) - infoscreen_step[i] = infoscreen_frame[i] = 0; - infoscreen_state++; - - FrameCounter = 0; - DrawInfoScreenDemoAnim(infoscreen_state * MAX_INFO_ELEMENTS_ON_SCREEN, - TRUE); -#if 0 - DrawInfoScreenDemoText(infoscreen_state * MAX_INFO_ELEMENTS_ON_SCREEN); -#endif - } - else if (infoscreen_state < - num_infoscreen_element_pages + num_infoscreen_music - 1) - { - infoscreen_state++; - DrawInfoScreenMusicText(infoscreen_state - num_infoscreen_element_pages); - } - else if (infoscreen_state == - num_infoscreen_element_pages + num_infoscreen_music - 1) - { - infoscreen_state++; - DrawInfoScreenCreditsText(); - } - else if (infoscreen_state == - num_infoscreen_element_pages + num_infoscreen_music) - { - infoscreen_state++; - DrawInfoScreenContactText(); - } - else - { - FadeSoundsAndMusic(); - - game_status = GAME_MODE_MAIN; - DrawMainMenu(); - } - } + if (info_mode == INFO_MODE_ELEMENTS) + HandleInfoScreen_Elements(button); + else if (info_mode == INFO_MODE_MUSIC) + HandleInfoScreen_Music(button); + else if (info_mode == INFO_MODE_CREDITS) + HandleInfoScreen_Credits(button); + else if (info_mode == INFO_MODE_PROGRAM) + HandleInfoScreen_Program(button); else - { - if (DelayReached(&hs_delay, GAME_FRAME_DELAY)) - { - if (infoscreen_state < num_infoscreen_element_pages) - DrawInfoScreenDemoAnim(infoscreen_state * MAX_INFO_ELEMENTS_ON_SCREEN, - FALSE); - } - - PlayMenuSoundIfLoop(); - } + HandleInfoScreen_Main(mx, my, dx, dy, button); DoAnimation(); - BackToFront(); } + +/* ========================================================================= */ +/* type name functions */ +/* ========================================================================= */ + void HandleTypeName(int newxpos, Key key) { static int xpos = 0, ypos = 2; @@ -956,10 +1207,13 @@ void HandleTypeName(int newxpos, Key key) SaveSetup(); game_status = GAME_MODE_MAIN; } - - BackToFront(); } + +/* ========================================================================= */ +/* tree menu functions */ +/* ========================================================================= */ + static void DrawChooseTree(TreeInfo **ti_ptr) { UnmapAllGadgets(); @@ -971,7 +1225,7 @@ static void DrawChooseTree(TreeInfo **ti_ptr) ClearWindow(); - HandleChooseTree(0,0, 0,0, MB_MENU_INITIALIZE, ti_ptr); + HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr); MapChooseTreeGadgets(*ti_ptr); FadeToFront(); @@ -1243,7 +1497,9 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, return; } - if (x == 0 && y >= 0 && y < num_page_entries) + if (IN_GFX_SCREEN(mx, my) && + mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x && + y >= 0 && y < num_page_entries) { if (button) { @@ -1302,13 +1558,6 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } } } - -#if 0 - if (game_status == GAME_MODE_LEVELS || game_status == GAME_MODE_SETUP) - DoAnimation(); - - BackToFront(); -#endif } void DrawChooseLevel() @@ -1326,7 +1575,6 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) HandleChooseTree(mx, my, dx, dy, button, &leveldir_current); DoAnimation(); - BackToFront(); } void DrawHallOfFame(int highlight_position) @@ -1341,10 +1589,10 @@ void DrawHallOfFame(int highlight_position) FadeToFront(); InitAnimation(); - HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE); - PlayMenuSound(); PlayMenuMusic(); + + HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE); } static void drawHallOfFameList(int first_entry, int highlight_position) @@ -1433,7 +1681,6 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) PlayMenuSoundIfLoop(); DoAnimation(); - BackToFront(); } @@ -1550,6 +1797,7 @@ static struct TokenInfo setup_info_main[] = { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execExitSetup, "Exit" }, { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" }, + { 0, NULL, NULL } }; @@ -1561,6 +1809,7 @@ static struct TokenInfo setup_info_game[] = { TYPE_SWITCH, &setup.autorecord, "Auto-Record:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, + { 0, NULL, NULL } }; @@ -1581,6 +1830,7 @@ static struct TokenInfo setup_info_editor[] = { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, + { 0, NULL, NULL } }; @@ -1597,6 +1847,7 @@ static struct TokenInfo setup_info_graphics[] = { TYPE_SWITCH, &setup.toons, "Toons:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, + { 0, NULL, NULL } }; @@ -1607,6 +1858,7 @@ static struct TokenInfo setup_info_sound[] = { TYPE_SWITCH, &setup.sound_music, "Game Music:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, + { 0, NULL, NULL } }; @@ -1625,6 +1877,7 @@ static struct TokenInfo setup_info_artwork[] = { TYPE_YES_NO, &setup.override_level_music, "Music:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, + { 0, NULL, NULL } }; @@ -1640,6 +1893,7 @@ static struct TokenInfo setup_info_shortcut[] = { TYPE_YES_NO, &setup.ask_on_escape, "Ask on Esc:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, + { 0, NULL, NULL } }; @@ -1837,7 +2091,7 @@ static void DrawSetupScreen_Generic() FadeToFront(); InitAnimation(); - HandleSetupScreen_Generic(0,0,0,0,MB_MENU_INITIALIZE); + HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE); } void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) @@ -1851,7 +2105,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) { /* advance to first valid menu entry */ while (choice < num_setup_info && - (setup_info[choice].type & TYPE_SKIP_ENTRY)) + setup_info[choice].type & TYPE_SKIP_ENTRY) choice++; choice_store[setup_mode] = choice; @@ -1885,8 +2139,8 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) { int menu_navigation_type = (dx < 0 ? TYPE_LEAVE_MENU : TYPE_ENTER_MENU); - if ((setup_info[choice].type & menu_navigation_type) || - (setup_info[choice].type & TYPE_BOOLEAN_STYLE)) + if (setup_info[choice].type & menu_navigation_type || + setup_info[choice].type & TYPE_BOOLEAN_STYLE) button = MB_MENU_CHOICE; } else if (dy) @@ -1894,12 +2148,12 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) /* jump to next non-empty menu entry (up or down) */ while (y > 0 && y < num_setup_info - 1 && - (setup_info[y].type & TYPE_SKIP_ENTRY)) + setup_info[y].type & TYPE_SKIP_ENTRY) y += dy; } - if (x == 0 && y >= 0 && y < num_setup_info && - (setup_info[y].type & ~TYPE_SKIP_ENTRY)) + if (IN_GFX_SCREEN(mx, my) && + y >= 0 && y < num_setup_info && setup_info[y].type & ~TYPE_SKIP_ENTRY) { if (button) { @@ -1920,8 +2174,8 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) } else { - if ((setup_info[y].type & TYPE_KEYTEXT) && - (setup_info[y + 1].type & TYPE_KEY)) + if (setup_info[y].type & TYPE_KEYTEXT && + setup_info[y + 1].type & TYPE_KEY) y++; if (setup_info[y].type & TYPE_VALUE) @@ -1929,13 +2183,6 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) } } } - -#if 0 - BackToFront(); - - if (game_status == GAME_MODE_SETUP) - DoAnimation(); -#endif } void DrawSetupScreen_Input() @@ -1962,7 +2209,7 @@ void DrawSetupScreen_Input() "Joysticks deactivated on this screen"); #endif - HandleSetupScreen_Input(0,0, 0,0, MB_MENU_INITIALIZE); + HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE); FadeToFront(); InitAnimation(); } @@ -2078,6 +2325,7 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) { drawPlayerSetupInputInfo(player_nr); drawCursor(choice, FC_RED); + return; } else if (button == MB_MENU_LEAVE) @@ -2085,6 +2333,8 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) setup_mode = SETUP_MODE_MAIN; DrawSetupScreen(); InitJoysticks(); + + return; } if (mx || my) /* mouse input */ @@ -2107,7 +2357,8 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1); } - if (y == 0 && ((x == 0 && !button) || ((x == 10 || x == 12) && button))) + if (IN_GFX_SCREEN(mx, my) && + y == 0 && ((x < 10 && !button) || ((x == 10 || x == 12) && button))) { static unsigned long delay = 0; @@ -2118,7 +2369,8 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) drawPlayerSetupInputInfo(player_nr); } - else if (x == 0 && y >= pos_start && y <= pos_end && + else if (IN_GFX_SCREEN(mx, my) && + y >= pos_start && y <= pos_end && !(y >= pos_empty1 && y <= pos_empty2)) { if (button) @@ -2538,7 +2790,6 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) HandleSetupScreen_Generic(mx, my, dx, dy, button); DoAnimation(); - BackToFront(); } void HandleGameActions() @@ -2553,13 +2804,10 @@ void HandleGameActions() TapeStop(); GameActions(); - BackToFront(); -#if 1 if (tape.auto_play && !tape.playing) AutoPlayTape(); /* continue automatically playing next tape */ -#endif } /* ---------- new screen button stuff -------------------------------------- */ @@ -2831,6 +3079,7 @@ void MapChooseTreeGadgets(TreeInfo *ti) MapGadget(screen_gadget[i]); } +#if 0 void UnmapChooseTreeGadgets() { int i; @@ -2838,6 +3087,7 @@ void UnmapChooseTreeGadgets() for (i = 0; i < NUM_SCREEN_GADGETS; i++) UnmapGadget(screen_gadget[i]); } +#endif static void HandleScreenGadgets(struct GadgetInfo *gi) { diff --git a/src/screens.h b/src/screens.h index ff3a5684..949267f0 100644 --- a/src/screens.h +++ b/src/screens.h @@ -16,34 +16,23 @@ #include "main.h" -/* (randomly chosen) values for HandleChooseTree() */ +/* (arbitrary, but unique) values for HandleChooseTree() */ #define SCROLL_LINE (1 * SCR_FIELDY) #define SCROLL_PAGE (2 * SCR_FIELDY) -void DrawHeadline(void); - void DrawMainMenu(void); -void HandleMainMenu(int, int, int, int, int); - -void HandleInfoScreen(int); - -void HandleTypeName(int, Key); +void DrawHallOfFame(int); -void DrawChooseLevel(void); +void HandleMainMenu(int, int, int, int, int); void HandleChooseLevel(int, int, int, int, int); - -void DrawHallOfFame(int); void HandleHallOfFame(int, int, int, int, int); - -void DrawSetupScreen(void); +void HandleInfoScreen(int, int, int, int, int); void HandleSetupScreen(int, int, int, int, int); - +void HandleTypeName(int, Key); void HandleGameActions(void); void CreateScreenGadgets(); void FreeScreenGadgets(); -void MapChooseTreeGadgets(TreeInfo *); -void UnmapChooseTreeGadgets(); #endif /* SCREENS_H */