X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=b97c44a134777973bdf98284cb50733a7e7728ee;hb=1150bdce04915bf329bd816307fb2507eba80e15;hp=f2335cac639ab23a52c3e2e5e3854f5f2aba8649;hpb=f8f7840ddc57a2c31a3d6ab664b0e4e7e7ad69ce;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index f2335cac..b97c44a1 100644 --- a/src/screens.c +++ b/src/screens.c @@ -55,16 +55,12 @@ 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() @@ -75,7 +71,7 @@ void DrawMainMenu() UnmapAllGadgets(); FadeSounds(); - XAutoRepeatOn(display); + KeyboardAutoRepeatOn(); /* needed if last screen was the playing screen, invoked from level editor */ if (level_editor_test_game) @@ -88,6 +84,12 @@ void DrawMainMenu() /* needed if last screen was the editor screen */ UndrawSpecialEditorDoor(); + /* needed if last screen was the setup screen and fullscreen state changed */ + ChangeVideoModeIfNeeded(); +#ifdef TARGET_SDL + SetDrawtoField(DRAW_BACKBUFFER); +#endif + /* map gadgets for main menu screen */ MapTapeButtons(); @@ -274,7 +276,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) @@ -331,7 +333,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 @@ -690,7 +692,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, @@ -720,13 +722,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, @@ -814,7 +816,7 @@ void HandleHelpScreen(int button) BackToFront(); } -void HandleTypeName(int newxpos, KeySym key) +void HandleTypeName(int newxpos, Key key) { static int xpos = 0, ypos = 2; @@ -826,15 +828,16 @@ 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; @@ -845,14 +848,14 @@ void HandleTypeName(int newxpos, KeySym key) 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); @@ -927,7 +930,7 @@ static void drawChooseLevelList(int first_entry, int num_page_entries) 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); @@ -969,7 +972,7 @@ static void drawChooseLevelInfo(int 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); if (node->parent_link) DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc); @@ -1040,7 +1043,7 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) 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; @@ -1228,7 +1231,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) @@ -1287,7 +1290,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:" }, @@ -1403,7 +1409,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 && sysinfo.audio_available) { if (setup.sound) { @@ -1417,7 +1423,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 && sysinfo.audio_loops_available) { if (setup.sound_loops) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1429,7 +1435,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 && sysinfo.audio_loops_available) { if (setup.sound_music) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1443,7 +1449,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); @@ -1451,7 +1457,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) @@ -1468,7 +1474,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); @@ -1476,7 +1482,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); @@ -1484,7 +1490,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); @@ -1492,7 +1499,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 && 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); @@ -1500,7 +1516,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); @@ -1508,7 +1524,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); @@ -1516,7 +1532,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); @@ -1524,7 +1540,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); @@ -1532,7 +1548,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(); @@ -1548,7 +1564,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 @@ -1618,7 +1634,7 @@ static void drawPlayerSetupInputInfo(int player_nr) static struct SetupKeyboardInfo custom_key; static struct { - KeySym *keysym; + Key *key; char *text; } custom[] = { @@ -1678,7 +1694,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); } } @@ -1858,7 +1874,7 @@ void CustomizeKeyboard(int player_nr) static struct SetupKeyboardInfo custom_key; static struct { - KeySym *keysym; + Key *key; char *text; } customize_step[] = { @@ -1885,47 +1901,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; @@ -2082,7 +2100,7 @@ void CalibrateJoystick(int player_nr) } break; - case KeyRelease: + case EVENT_KEYRELEASE: key_joystick_mapping = 0; break; @@ -2092,12 +2110,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); @@ -2125,7 +2149,7 @@ void CalibrateJoystick(int player_nr) { result = 1; -#ifdef MSDOS +#if defined(PLATFORM_MSDOS) if (calibration_step == 1) { remove_joystick(); @@ -2166,7 +2190,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); @@ -2205,7 +2229,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: @@ -2300,7 +2337,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; @@ -2334,8 +2371,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); @@ -2354,7 +2391,7 @@ static void CreateScreenScrollbars() for (i=0; i