X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=91aa31b8d2cfad6e6683773c5cd4a3b5b43d6986;hb=2ae6ae8ed951e87fcba7c363705cd6ddea8de91c;hp=4839ab3927153319d3009f12a7f81807d95f7536;hpb=370a25a79d2e8df1e6e3e4cb4be39496d0190c28;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 4839ab39..91aa31b8 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1,25 +1,24 @@ /*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * +* Rocks'n'Diamonds -- McDuffin Strikes Back! * *----------------------------------------------------------* -* (c) 1995-98 Artsoft Entertainment * -* Holger Schemel * -* Oststrasse 11a * -* 33604 Bielefeld * -* phone: ++49 +521 290471 * -* email: aeglos@valinor.owl.de * +* (c) 1995-2000 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * *----------------------------------------------------------* -* screens.c * +* screens.c * ***********************************************************/ +#include "libgame/libgame.h" + #include "screens.h" #include "events.h" -#include "sound.h" #include "game.h" #include "tools.h" #include "editor.h" -#include "misc.h" #include "files.h" -#include "buttons.h" #include "tape.h" #include "joystick.h" #include "cartoons.h" @@ -55,26 +54,23 @@ static void HandleScreenGadgets(struct GadgetInfo *); static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS]; -#ifdef MSDOS -extern unsigned char get_ascii(KeySym); -#endif - void DrawHeadline() { int x = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * FONT1_XSIZE) / 2; DrawText(x, SY + 8, PROGRAM_TITLE_STRING, FS_BIG, FC_YELLOW); - DrawTextFCentered(46, FC_RED, COPYRIGHT_STRING); + DrawTextFCentered(46, FC_RED, WINDOW_SUBTITLE_STRING); } void DrawMainMenu() { + static struct LevelDirInfo *leveldir_last_valid = NULL; int i; char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:"); UnmapAllGadgets(); FadeSounds(); - XAutoRepeatOn(display); + KeyboardAutoRepeatOn(); /* needed if last screen was the playing screen, invoked from level editor */ if (level_editor_test_game) @@ -87,10 +83,23 @@ void DrawMainMenu() /* needed if last screen was the editor screen */ UndrawSpecialEditorDoor(); + /* needed if last screen was the setup screen and fullscreen state changed */ + setup.fullscreen = ChangeVideoModeIfNeeded(setup.fullscreen); +#ifdef TARGET_SDL + SetDrawtoField(DRAW_BACKBUFFER); +#endif + /* map gadgets for main menu screen */ MapTapeButtons(); - /* level_nr may have set to value over handicap with level editor */ + /* leveldir_current may be invalid (level group, parent link) */ + if (!validLevelSeries(leveldir_current)) + leveldir_current = getFirstValidLevelSeries(leveldir_last_valid); + + /* store valid level series information */ + leveldir_last_valid = leveldir_current; + + /* level_nr may have been set to value over handicap with level editor */ if (setup.handicap && level_nr > leveldir_current->handicap_level) level_nr = leveldir_current->handicap_level; @@ -157,6 +166,35 @@ void DrawMainMenu() } +static void gotoTopLevelDir() +{ + /* move upwards to top level directory */ + while (leveldir_current->node_parent) + { + /* write a "path" into level tree for easy navigation to last level */ + if (leveldir_current->node_parent->node_group->cl_first == -1) + { + int num_leveldirs = numLevelDirInfoInGroup(leveldir_current); + int leveldir_pos = posLevelDirInfo(leveldir_current); + int num_page_entries; + int cl_first, cl_cursor; + + if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN) + num_page_entries = num_leveldirs; + else + num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1; + + cl_first = MAX(0, leveldir_pos - num_page_entries + 1); + cl_cursor = leveldir_pos - cl_first + 3; + + leveldir_current->node_parent->node_group->cl_first = cl_first; + leveldir_current->node_parent->node_group->cl_cursor = cl_cursor; + } + + leveldir_current = leveldir_current->node_parent; + } +} + void HandleMainMenu(int mx, int my, int dx, int dy, int button) { static int choice = 3; @@ -223,9 +261,9 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) level_nr = new_level_nr; - DrawTextExt(drawto, gc, SX + 11 * 32, SY + 3 * 32, + DrawTextExt(drawto, SX + 11 * 32, SY + 3 * 32, int2str(level_nr, 3), FS_BIG, font_color); - DrawTextExt(window, gc, SX + 11 * 32, SY + 3 * 32, + DrawTextExt(window, SX + 11 * 32, SY + 3 * 32, int2str(level_nr, 3), FS_BIG, font_color); LoadLevel(level_nr); @@ -237,7 +275,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) /* needed because DrawMicroLevel() takes some time */ BackToFront(); - XSync(display, FALSE); + SyncDisplay(); DelayReached(&level_delay, 0); /* reset delay counter */ } else if (x == 1 && y >= 3 && y <= 10) @@ -260,11 +298,14 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (y == 4) { - if (num_leveldirs) + if (leveldir_first) { game_status = CHOOSELEVEL; SaveLevelSetup_LastSeries(); SaveLevelSetup_SeriesInfo(); + + gotoTopLevelDir(); + DrawChooseLevel(); } } @@ -291,7 +332,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) if (setup.autorecord) TapeStartRecording(); -#ifndef MSDOS +#if defined(PLATFORM_UNIX) if (options.network) SendToServer_StartPlaying(); else @@ -432,8 +473,8 @@ static int helpscreen_action[] = GFX_DIAMANT,1,10, HA_NEXT, GFX_LIFE,1,100, HA_NEXT, GFX_LIFE_ASYNC,1,100, HA_NEXT, - GFX_SIEB_INAKTIV,4,2, HA_NEXT, - GFX_SIEB2_INAKTIV,4,2, HA_NEXT, + GFX_MAGIC_WALL_OFF,4,2, HA_NEXT, + GFX_MAGIC_WALL_BD_OFF,4,2, HA_NEXT, GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2, GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2, GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT, @@ -575,7 +616,7 @@ void DrawHelpScreenElAction(int start) } j++; - DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame); + DrawGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame); i++; } @@ -650,7 +691,7 @@ void DrawHelpScreenCreditsText() DrawTextFCentered(100, FC_GREEN, "Credits:"); DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW, - "DOS/Windows port of the game:"); + "DOS port of the game:"); DrawTextFCentered(ystart + 1 * ystep, FC_RED, "Guido Schulz"); DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW, @@ -680,13 +721,13 @@ void DrawHelpScreenContactText() DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW, "If you like it, send e-mail to:"); DrawTextFCentered(ystart + 2 * ystep, FC_RED, - "aeglos@valinor.owl.de"); + "info@artsoft.org"); DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW, "or SnailMail to:"); DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED, "Holger Schemel"); DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED, - "Oststrasse 11a"); + "Detmolder Strasse 189"); DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED, "33604 Bielefeld"); DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED, @@ -774,7 +815,7 @@ void HandleHelpScreen(int button) BackToFront(); } -void HandleTypeName(int newxpos, KeySym key) +void HandleTypeName(int newxpos, Key key) { static int xpos = 0, ypos = 2; @@ -786,33 +827,34 @@ void HandleTypeName(int newxpos, KeySym key) return; } - if (((key >= XK_A && key <= XK_Z) || (key >= XK_a && key <= XK_z)) && + if (((key >= KSYM_A && key <= KSYM_Z) || + (key >= KSYM_a && key <= KSYM_z)) && xpos < MAX_PLAYER_NAME_LEN) { char ascii; - if (key >= XK_A && key <= XK_Z) - ascii = 'A' + (char)(key - XK_A); + if (key >= KSYM_A && key <= KSYM_Z) + ascii = 'A' + (char)(key - KSYM_A); else - ascii = 'a' + (char)(key - XK_a); + ascii = 'a' + (char)(key - KSYM_a); setup.player_name[xpos] = ascii; setup.player_name[xpos + 1] = 0; xpos++; - DrawTextExt(drawto, gc, SX + 6*32, SY + ypos*32, + DrawTextExt(drawto, SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW); - DrawTextExt(window, gc, SX + 6*32, SY + ypos*32, + DrawTextExt(window, SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW); DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT); } - else if ((key == XK_Delete || key == XK_BackSpace) && xpos > 0) + else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0) { xpos--; setup.player_name[xpos] = 0; DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT); DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM); } - else if (key == XK_Return && xpos > 0) + else if (key == KSYM_Return && xpos > 0) { DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED); DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM); @@ -824,6 +866,33 @@ void HandleTypeName(int newxpos, KeySym key) BackToFront(); } +static void drawCursorExt(int ypos, int color, int graphic) +{ + static int cursor_array[SCR_FIELDY]; + + if (graphic) + cursor_array[ypos] = graphic; + + graphic = cursor_array[ypos]; + + if (color == FC_RED) + graphic = (graphic == GFX_ARROW_BLUE_LEFT ? GFX_ARROW_RED_LEFT : + graphic == GFX_ARROW_BLUE_RIGHT ? GFX_ARROW_RED_RIGHT : + GFX_KUGEL_ROT); + + DrawGraphic(0, ypos, graphic); +} + +static void initCursor(int ypos, int graphic) +{ + drawCursorExt(ypos, FC_BLUE, graphic); +} + +static void drawCursor(int ypos, int color) +{ + drawCursorExt(ypos, color, 0); +} + void DrawChooseLevel() { UnmapAllGadgets(); @@ -842,7 +911,7 @@ 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_max = numLevelDirInfoInGroup(leveldir_current); items_visible = MAX_LEVEL_SERIES_ON_SCREEN - 1; item_position = first_entry; @@ -858,24 +927,33 @@ 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; + int num_leveldirs = numLevelDirInfoInGroup(leveldir_current); - XFillRectangle(display, backbuffer, gc, SX, SY, SXSIZE - 32, SYSIZE); + ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE); redraw_mask |= REDRAW_FIELD; DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN); for(i=0; iname , max_buffer_len); + node_first = getLevelDirInfoFirstGroupEntry(leveldir_current); + node = getLevelDirInfoFromPos(node_first, leveldir_pos); + + strncpy(buffer, node->name , max_buffer_len); buffer[max_buffer_len] = '\0'; - DrawText(SX + 32, SY + (i + 2) * 32, buffer, FS_MEDIUM, - leveldir_node->color); - DrawGraphic(0, i + 2, GFX_KUGEL_BLAU); + DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color); + + if (node->parent_link) + initCursor(ypos, GFX_ARROW_BLUE_LEFT); + else if (node->level_group) + initCursor(ypos, GFX_ARROW_BLUE_RIGHT); + else + initCursor(ypos, GFX_KUGEL_BLAU); } if (first_entry > 0) @@ -887,16 +965,21 @@ static void drawChooseLevelList(int first_entry, int num_page_entries) static void drawChooseLevelInfo(int leveldir_pos) { - struct LevelDirInfo *leveldir_node; + struct LevelDirInfo *node, *node_first; int x, last_redraw_mask = redraw_mask; - leveldir_node = getLevelDirInfoFromPos(leveldir_first, leveldir_pos); + node_first = getLevelDirInfoFirstGroupEntry(leveldir_current); + node = getLevelDirInfoFromPos(node_first, leveldir_pos); - XFillRectangle(display, drawto, gc, SX + 32, SY + 32, SXSIZE - 64, 32); + ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32); - DrawTextFCentered(40, FC_RED, "%3d levels (%s)", - leveldir_node->levels, - leveldir_node->class_desc); + if (node->parent_link) + DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc); + else if (node->level_group) + DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc); + else + 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; @@ -906,12 +989,11 @@ static void drawChooseLevelInfo(int leveldir_pos) void HandleChooseLevel(int mx, int my, int dx, int dy, int button) { - static int choice = 3; - static int first_entry = -1; static unsigned long choose_delay = 0; static int redraw = TRUE; int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32; int step = (button == 1 ? 1 : button == 2 ? 5 : 10); + int num_leveldirs = numLevelDirInfoInGroup(leveldir_current); int num_page_entries; if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN) @@ -923,24 +1005,27 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) { int leveldir_pos = posLevelDirInfo(leveldir_current); - if (first_entry == -1) + if (leveldir_current->cl_first == -1) { - first_entry = MAX(0, leveldir_pos - num_page_entries + 1); - choice = leveldir_pos - first_entry + 3; - AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, first_entry); + leveldir_current->cl_first = MAX(0, leveldir_pos - num_page_entries + 1); + leveldir_current->cl_cursor = + leveldir_pos - leveldir_current->cl_first + 3; } - if (dx == 1) /* 'first_entry' is set by scrollbar position */ - first_entry = dy; + if (dx == 999) /* first entry is set by scrollbar position */ + leveldir_current->cl_first = dy; + else + AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, + leveldir_current->cl_first); - drawChooseLevelList(first_entry, num_page_entries); + drawChooseLevelList(leveldir_current->cl_first, num_page_entries); drawChooseLevelInfo(leveldir_pos); redraw = TRUE; } if (redraw) { - DrawGraphic(0, choice - 1, GFX_KUGEL_ROT); + drawCursor(leveldir_current->cl_cursor - 1, FC_RED); redraw = FALSE; } @@ -952,12 +1037,12 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) if (dy) { x = 1; - y = choice + dy; + y = leveldir_current->cl_cursor + dy; } else x = y = 0; /* no action */ - if (ABS(dy) == SCR_FIELDY) /* handle XK_Page_Up, XK_Page_Down */ + if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */ { dy = SIGN(dy); step = num_page_entries - 1; @@ -968,33 +1053,37 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) if (x == 1 && y == 2) { - if (first_entry > 0 && + if (leveldir_current->cl_first > 0 && (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY))) { - first_entry -= step; - if (first_entry < 0) - first_entry = 0; - - drawChooseLevelList(first_entry, num_page_entries); - drawChooseLevelInfo(first_entry + choice - 3); - AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, first_entry); - DrawGraphic(0, choice - 1, GFX_KUGEL_ROT); + leveldir_current->cl_first -= step; + if (leveldir_current->cl_first < 0) + leveldir_current->cl_first = 0; + + drawChooseLevelList(leveldir_current->cl_first, num_page_entries); + drawChooseLevelInfo(leveldir_current->cl_first + + leveldir_current->cl_cursor - 3); + drawCursor(leveldir_current->cl_cursor - 1, FC_RED); + AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, + leveldir_current->cl_first); return; } } else if (x == 1 && y > num_page_entries + 2) { - if (first_entry + num_page_entries < num_leveldirs && + if (leveldir_current->cl_first + num_page_entries < num_leveldirs && (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY))) { - first_entry += step; - if (first_entry + num_page_entries > num_leveldirs) - first_entry = MAX(0, num_leveldirs - num_page_entries); - - drawChooseLevelList(first_entry, num_page_entries); - drawChooseLevelInfo(first_entry + choice - 3); - AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, first_entry); - DrawGraphic(0, choice - 1, GFX_KUGEL_ROT); + leveldir_current->cl_first += step; + if (leveldir_current->cl_first + num_page_entries > num_leveldirs) + leveldir_current->cl_first = MAX(0, num_leveldirs - num_page_entries); + + drawChooseLevelList(leveldir_current->cl_first, num_page_entries); + drawChooseLevelInfo(leveldir_current->cl_first + + leveldir_current->cl_cursor - 3); + drawCursor(leveldir_current->cl_cursor - 1, FC_RED); + AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, + leveldir_current->cl_first); return; } } @@ -1002,43 +1091,77 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) if (!mx && !my && !dx && !dy) { x = 1; - y = choice; + y = leveldir_current->cl_cursor; + } + + if (dx == 1) + { + struct LevelDirInfo *node_first, *node_cursor; + int leveldir_pos = + leveldir_current->cl_first + leveldir_current->cl_cursor - 3; + + node_first = getLevelDirInfoFirstGroupEntry(leveldir_current); + node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos); + + if (node_cursor->node_group) + { + node_cursor->cl_first = leveldir_current->cl_first; + node_cursor->cl_cursor = leveldir_current->cl_cursor; + leveldir_current = node_cursor->node_group; + DrawChooseLevel(); + } + } + else if (dx == -1 && leveldir_current->node_parent) + { + leveldir_current = leveldir_current->node_parent; + DrawChooseLevel(); } if (x == 1 && y >= 3 && y <= num_page_entries + 2) { if (button) { - if (y != choice) + if (y != leveldir_current->cl_cursor) { - DrawGraphic(0, y - 1, GFX_KUGEL_ROT); - DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU); - drawChooseLevelInfo(first_entry + y - 3); - choice = y; + drawCursor(y - 1, FC_RED); + drawCursor(leveldir_current->cl_cursor - 1, FC_BLUE); + drawChooseLevelInfo(leveldir_current->cl_first + y - 3); + leveldir_current->cl_cursor = y; } } else { - int leveldir_pos = first_entry + y - 3; - - leveldir_current = getLevelDirInfoFromPos(leveldir_first, leveldir_pos); + struct LevelDirInfo *node_first, *node_cursor; + int leveldir_pos = leveldir_current->cl_first + y - 3; - LoadLevelSetup_SeriesInfo(); - - SaveLevelSetup_LastSeries(); - SaveLevelSetup_SeriesInfo(); - TapeErase(); + node_first = getLevelDirInfoFirstGroupEntry(leveldir_current); + node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos); + if (node_cursor->node_group) + { + node_cursor->cl_first = leveldir_current->cl_first; + node_cursor->cl_cursor = leveldir_current->cl_cursor; + leveldir_current = node_cursor->node_group; + DrawChooseLevel(); + } + else if (node_cursor->parent_link) + { + leveldir_current = node_cursor->node_parent; + DrawChooseLevel(); + } + else + { + leveldir_current = node_cursor; - printf("first_level == %d, last_level == %d, levels == %d\n", - leveldir_current->first_level, - leveldir_current->last_level, - leveldir_current->levels); + LoadLevelSetup_SeriesInfo(); + SaveLevelSetup_LastSeries(); + SaveLevelSetup_SeriesInfo(); + TapeErase(); - game_status = MAINMENU; - DrawMainMenu(); - redraw = TRUE; + game_status = MAINMENU; + DrawMainMenu(); + } } } @@ -1107,7 +1230,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) return; } - if (ABS(dy) == SCR_FIELDY) /* handle XK_Page_Up, XK_Page_Down */ + if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */ step = MAX_LEVEL_SERIES_ON_SCREEN - 1; if (dy < 0) @@ -1166,7 +1289,10 @@ void DrawSetupScreen() #endif { &setup.scroll_delay, "Scroll Delay:" }, { &setup.soft_scrolling, "Soft Scroll.:" }, +#if 0 { &setup.fading, "Fading:" }, +#endif + { &setup.fullscreen, "Fullscreen:" }, { &setup.quick_doors, "Quick Doors:" }, { &setup.autorecord, "Auto-Record:" }, { &setup.team_mode, "Team-Mode:" }, @@ -1190,8 +1316,12 @@ void DrawSetupScreen() if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2)) { - DrawGraphic(0,i,GFX_KUGEL_BLAU); DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN); + + if (strcmp(setup_info[base].text, "Input Devices") == 0) + initCursor(i, GFX_ARROW_BLUE_RIGHT); + else + initCursor(i, GFX_KUGEL_BLAU); } if (setup_info[base].value) @@ -1223,7 +1353,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) if (redraw) { - DrawGraphic(0,choice-1,GFX_KUGEL_ROT); + drawCursor(choice - 1, FC_RED); redraw = FALSE; } @@ -1255,6 +1385,13 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) y = choice; } + if (dx == 1 && choice == 14) + { + game_status = SETUPINPUT; + DrawSetupInputScreen(); + redraw = TRUE; + } + if (x==1 && y >= pos_start && y <= pos_end && !(y >= pos_empty1 && y <= pos_empty2)) { @@ -1262,8 +1399,8 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) { if (y!=choice) { - DrawGraphic(0,y-1,GFX_KUGEL_ROT); - DrawGraphic(0,choice-1,GFX_KUGEL_BLAU); + drawCursor(y - 1, FC_RED); + drawCursor(choice - 1, FC_BLUE); } choice = y; } @@ -1271,7 +1408,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) { int yy = y-1; - if (y==3 && sound_status==SOUND_AVAILABLE) + if (y == 3 && audio.sound_available) { if (setup.sound) { @@ -1285,7 +1422,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.sound = !setup.sound; } - else if (y==4 && sound_loops_allowed) + else if (y == 4 && audio.loops_available) { if (setup.sound_loops) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1297,7 +1434,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) } setup.sound_loops = !setup.sound_loops; } - else if (y==5 && sound_loops_allowed) + else if (y == 5 && audio.loops_available) { if (setup.sound_music) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1311,7 +1448,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) } #if 0 - else if (y==6) + else if (y == 6) { if (setup.toons) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1319,7 +1456,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.toons = !setup.toons; } - else if (y==7) + else if (y == 7) { #if 0 if (setup.double_buffering) @@ -1336,7 +1473,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) } #endif - else if (y==6) + else if (y == 6) { if (setup.scroll_delay) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1344,7 +1481,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.scroll_delay = !setup.scroll_delay; } - else if (y==7) + else if (y == 7) { if (setup.soft_scrolling) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1352,7 +1489,8 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.soft_scrolling = !setup.soft_scrolling; } - else if (y==8) +#if 0 + else if (y == 8) { if (setup.fading) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1360,7 +1498,16 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.fading = !setup.fading; } - else if (y==9) +#endif + else if (y == 8 && video.fullscreen_available) + { + if (setup.fullscreen) + DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); + else + DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); + setup.fullscreen = !setup.fullscreen; + } + else if (y == 9) { if (setup.quick_doors) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1368,7 +1515,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.quick_doors = !setup.quick_doors; } - else if (y==10) + else if (y == 10) { if (setup.autorecord) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1376,7 +1523,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.autorecord = !setup.autorecord; } - else if (y==11) + else if (y == 11) { if (setup.team_mode) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1384,7 +1531,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.team_mode = !setup.team_mode; } - else if (y==12) + else if (y == 12) { if (setup.handicap) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1392,7 +1539,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.handicap = !setup.handicap; } - else if (y==13) + else if (y == 13) { if (setup.time_limit) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1400,7 +1547,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.time_limit = !setup.time_limit; } - else if (y==14) + else if (y == 14) { game_status = SETUPINPUT; DrawSetupInputScreen(); @@ -1416,7 +1563,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) SaveJoystickData(); */ -#ifdef MSDOS +#if defined(PLATFORM_MSDOS) save_joystick_data(JOYSTICK_FILENAME); #endif @@ -1440,10 +1587,11 @@ void DrawSetupInputScreen() ClearWindow(); DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW); - DrawGraphic(0, 2, GFX_KUGEL_BLAU); - DrawGraphic(0, 3, GFX_KUGEL_BLAU); - DrawGraphic(0, 4, GFX_KUGEL_BLAU); - DrawGraphic(0, 15, GFX_KUGEL_BLAU); + initCursor(2, GFX_KUGEL_BLAU); + initCursor(3, GFX_KUGEL_BLAU); + initCursor(4, GFX_ARROW_BLUE_RIGHT); + initCursor(15, GFX_KUGEL_BLAU); + DrawGraphic(10, 2, GFX_ARROW_BLUE_LEFT); DrawGraphic(12, 2, GFX_ARROW_BLUE_RIGHT); @@ -1485,7 +1633,7 @@ static void drawPlayerSetupInputInfo(int player_nr) static struct SetupKeyboardInfo custom_key; static struct { - KeySym *keysym; + Key *key; char *text; } custom[] = { @@ -1545,7 +1693,7 @@ static void drawPlayerSetupInputInfo(int player_nr) DrawText(SX + 3*32, SY + ypos*32, (setup.input[player_nr].use_joystick ? custom[i].text : - getKeyNameFromKeySym(*custom[i].keysym)), + getKeyNameFromKey(*custom[i].key)), FS_BIG, FC_YELLOW); } } @@ -1569,7 +1717,7 @@ void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button) if (redraw) { - DrawGraphic(0,choice-1,GFX_KUGEL_ROT); + drawCursor(choice - 1, FC_RED); redraw = FALSE; } @@ -1630,8 +1778,8 @@ void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button) { if (y != choice) { - DrawGraphic(0, y-1, GFX_KUGEL_ROT); - DrawGraphic(0, choice-1, GFX_KUGEL_BLAU); + drawCursor(y - 1, FC_RED); + drawCursor(choice - 1, FC_BLUE); } choice = y; } @@ -1725,7 +1873,7 @@ void CustomizeKeyboard(int player_nr) static struct SetupKeyboardInfo custom_key; static struct { - KeySym *keysym; + Key *key; char *text; } customize_step[] = { @@ -1752,47 +1900,50 @@ void CustomizeKeyboard(int player_nr) DrawText(SX, SY + (2+2*step_nr+1)*32, "Key:", FS_BIG, FC_RED); DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32, - getKeyNameFromKeySym(*customize_step[step_nr].keysym), + getKeyNameFromKey(*customize_step[step_nr].key), FS_BIG, FC_BLUE); while(!finished) { - if (XPending(display)) /* got event from X server */ + if (PendingEvent()) /* got event */ { - XEvent event; + Event event; - XNextEvent(display, &event); + NextEvent(&event); switch(event.type) { - case KeyPress: + case EVENT_KEYPRESS: { - KeySym key = XLookupKeysym((XKeyEvent *)&event, - ((XKeyEvent *)&event)->state); + Key key = GetEventKey((KeyEvent *)&event, TRUE); - if (key == XK_Escape || (key == XK_Return && step_nr == 6)) + if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6)) { finished = TRUE; break; } + /* all keys configured -- wait for "Escape" or "Return" key */ + if (step_nr == 6) + break; + /* press 'Enter' to keep the existing key binding */ - if (key == XK_Return || step_nr == 6) - key = *customize_step[step_nr].keysym; + if (key == KSYM_Return) + key = *customize_step[step_nr].key; /* check if key already used */ for (i=0; istate)) + case EVENT_KEYPRESS: + switch(GetEventKey((KeyEvent *)&event, TRUE)) { - case XK_Return: + case KSYM_Return: if (check_remaining == 0) result = 1; break; - case XK_Escape: + case KSYM_Escape: result = 0; break; @@ -1949,7 +2099,7 @@ void CalibrateJoystick(int player_nr) } break; - case KeyRelease: + case EVENT_KEYRELEASE: key_joystick_mapping = 0; break; @@ -1959,12 +2109,18 @@ void CalibrateJoystick(int player_nr) } } -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) + +#if defined(TARGET_SDL) + joy_ctrl.x = Get_SDL_Joystick_Axis(joystick_fd, 0); + joy_ctrl.y = Get_SDL_Joystick_Axis(joystick_fd, 1); +#else if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) { joystick_status = JOYSTICK_OFF; goto error_out; } +#endif new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x); new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x); @@ -1992,7 +2148,7 @@ void CalibrateJoystick(int player_nr) { result = 1; -#ifdef MSDOS +#if defined(PLATFORM_MSDOS) if (calibration_step == 1) { remove_joystick(); @@ -2033,7 +2189,7 @@ void CalibrateJoystick(int player_nr) if (x != last_x || y != last_y) { -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB); #else DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU); @@ -2072,7 +2228,20 @@ void CalibrateJoystick(int player_nr) StopAnimation(); DrawSetupInputScreen(); - while(Joystick(player_nr) & JOY_BUTTON); + + /* wait until the last pressed button was released */ + while(Joystick(player_nr) & JOY_BUTTON) + { + if (PendingEvent()) /* got event */ + { + Event event; + + NextEvent(&event); + HandleOtherEvents(&event); + + Delay(10); + } + } return; error_out: @@ -2167,7 +2336,7 @@ static struct static void CreateScreenScrollbuttons() { - Pixmap gd_pixmap = pix[PIX_MORE]; + Bitmap *gd_bitmap = pix[PIX_MORE]; struct GadgetInfo *gi; unsigned long event_mask; int i; @@ -2201,8 +2370,8 @@ static void CreateScreenScrollbuttons() GDI_HEIGHT, height, GDI_TYPE, GD_TYPE_NORMAL_BUTTON, GDI_STATE, GD_BUTTON_UNPRESSED, - GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1, - GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2, + GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1, + GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleScreenGadgets, GDI_END); @@ -2221,13 +2390,14 @@ static void CreateScreenScrollbars() for (i=0; ievent.item_position, MB_MENU_INITIALIZE); + HandleChooseLevel(0,0, 999,gi->event.item_position, MB_MENU_INITIALIZE); break; default: