From 481b675e1abf432e0fccb69f253237fb97c4bcf9 Mon Sep 17 00:00:00 2001 From: robxnano <89391914+robxnano@users.noreply.github.com> Date: Sat, 3 Sep 2022 14:31:30 +0100 Subject: [PATCH] Try to fix building on SDL 1.2 --- BasiliskII/src/SDL/audio_sdl.cpp | 4 +++ BasiliskII/src/SDL/video_sdl.cpp | 39 ++++++++++++++++++++------ BasiliskII/src/SDL/video_sdl2.cpp | 12 ++++---- BasiliskII/src/include/user_strings.h | 2 -- BasiliskII/src/user_strings.cpp | 16 ++++++----- SheepShaver/src/include/user_strings.h | 5 ++-- SheepShaver/src/user_strings.cpp | 21 ++++++++------ 7 files changed, 65 insertions(+), 34 deletions(-) diff --git a/BasiliskII/src/SDL/audio_sdl.cpp b/BasiliskII/src/SDL/audio_sdl.cpp index 7d126a0d..0afa4859 100644 --- a/BasiliskII/src/SDL/audio_sdl.cpp +++ b/BasiliskII/src/SDL/audio_sdl.cpp @@ -362,6 +362,7 @@ void audio_set_speaker_volume(uint32 vol) } static int play_startup(void *arg) { +#if SDL_VERSION_ATLEAST(2,0,0) SDL_AudioSpec wav_spec; Uint8 *wav_buffer; Uint32 wav_length; @@ -378,9 +379,12 @@ static int play_startup(void *arg) { else printf("play_startup: Audio driver failed to initialize\n"); SDL_FreeWAV(wav_buffer); } +#endif return 0; } void PlayStartupSound() { +#if SDL_VERSION_ATLEAST(2,0,0) SDL_CreateThread(play_startup, "", NULL); +#endif } diff --git a/BasiliskII/src/SDL/video_sdl.cpp b/BasiliskII/src/SDL/video_sdl.cpp index 395778a0..a2b39c77 100644 --- a/BasiliskII/src/SDL/video_sdl.cpp +++ b/BasiliskII/src/SDL/video_sdl.cpp @@ -520,12 +520,28 @@ static void set_mac_frame_buffer(SDL_monitor_desc &monitor, int depth) } // Set window name and class -static void set_window_name(int name) +static void set_window_name(bool mouse_grabbed) { + int grabbed = 0; + if (mouse_grabbed) + { + int hotkey = PrefsFindInt32("hotkey"); + if (hotkey & 2) + grabbed = STR_WINDOW_TITLE_GRABBED2; + else if (hotkey & 4) + grabbed = STR_WINDOW_TITLE_GRABBED3; + else + grabbed = STR_WINDOW_TITLE_GRABBED1; + } const SDL_VideoInfo *vi = SDL_GetVideoInfo(); - if (vi && vi->wm_available) { - const char *str = GetString(name); - SDL_WM_SetCaption(str, str); + if (vi && vi->wm_available) + { + const char *title = PrefsFindString("title"); + char *str = (char *)(title ? title : GetString(STR_WINDOW_TITLE)); + if(grabbed) + strcat(str, GetString(grabbed)); + //The icon name should stay the same + SDL_WM_SetCaption(str, GetString(STR_WINDOW_TITLE)); } } @@ -736,7 +752,7 @@ void driver_base::adapt_to_video_mode() { SDL_ShowCursor(hardware_cursor); // Set window name/class - set_window_name(STR_WINDOW_TITLE); + set_window_name(false); // Everything went well init_ok = true; @@ -1304,8 +1320,8 @@ void VideoVBL(void) // Setting the window name must happen on the main thread, else it doesn't work on // some platforms - e.g. macOS Sierra. if (mouse_grabbed_window_name_status != mouse_grabbed) { - set_window_name(mouse_grabbed ? STR_WINDOW_TITLE_GRABBED : STR_WINDOW_TITLE); - mouse_grabbed_window_name_status = mouse_grabbed; + set_window_name(mouse_grabbed); + mouse_grabbed_window_name_status = mouse_grabbed; } // Temporarily give up frame buffer lock (this is the point where @@ -1333,7 +1349,7 @@ void VideoInterrupt(void) // Setting the window name must happen on the main thread, else it doesn't work on // some platforms - e.g. macOS Sierra. if (mouse_grabbed_window_name_status != mouse_grabbed) { - set_window_name(mouse_grabbed ? STR_WINDOW_TITLE_GRABBED : STR_WINDOW_TITLE); + set_window_name(mouse_grabbed); mouse_grabbed_window_name_status = mouse_grabbed; } @@ -2337,4 +2353,11 @@ void video_set_dirty_area(int x, int y, int w, int h) } #endif +#ifdef SHEEPSHAVER +void video_set_gamma(int n_colors) +{ + // Not supported in SDL 1.2 +} +#endif + #endif // ends: SDL version check diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index e7f43a1e..1ee0c5c5 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -555,14 +555,12 @@ static void set_window_name() { if (!sdl_window) return; const char *title = PrefsFindString("title"); std::string s = title ? title : GetString(STR_WINDOW_TITLE); - if (mouse_grabbed) { - s += GetString(STR_WINDOW_TITLE_GRABBED0); + if (mouse_grabbed) + { int hotkey = PrefsFindInt32("hotkey"); - if (!hotkey) hotkey = 1; - if (hotkey & 1) s += GetString(STR_WINDOW_TITLE_GRABBED1); - if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2); - if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED3); - s += GetString(STR_WINDOW_TITLE_GRABBED4); + if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2); + else if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED3); + else s += GetString(STR_WINDOW_TITLE_GRABBED1); } SDL_SetWindowTitle(sdl_window, s.c_str()); } diff --git a/BasiliskII/src/include/user_strings.h b/BasiliskII/src/include/user_strings.h index f75a738e..9de07918 100644 --- a/BasiliskII/src/include/user_strings.h +++ b/BasiliskII/src/include/user_strings.h @@ -218,11 +218,9 @@ enum { // Mac window STR_WINDOW_TITLE = 4000, - STR_WINDOW_TITLE_GRABBED0, STR_WINDOW_TITLE_GRABBED1, STR_WINDOW_TITLE_GRABBED2, STR_WINDOW_TITLE_GRABBED3, - STR_WINDOW_TITLE_GRABBED4, STR_WINDOW_MENU = 4050, STR_WINDOW_ITEM_ABOUT, STR_WINDOW_ITEM_REFRESH, diff --git a/BasiliskII/src/user_strings.cpp b/BasiliskII/src/user_strings.cpp index 1e608b27..47bce211 100644 --- a/BasiliskII/src/user_strings.cpp +++ b/BasiliskII/src/user_strings.cpp @@ -231,16 +231,18 @@ user_string_def common_strings[] = { {STR_JIT_FOLLOW_CONST_JUMPS, "Translate through constant jumps (inline blocks)"}, {STR_WINDOW_TITLE, "Basilisk II"}, - {STR_WINDOW_TITLE_GRABBED0, " (mouse grabbed, press "}, - {STR_WINDOW_TITLE_GRABBED1, "Ctrl-"}, + {STR_WINDOW_TITLE_GRABBED1, " (mouse grabbed, press Ctrl+F5 to release)"}, #ifdef __APPLE__ - {STR_WINDOW_TITLE_GRABBED2, "Opt-"}, - {STR_WINDOW_TITLE_GRABBED3, "Cmd-"}, + {STR_WINDOW_TITLE_GRABBED2, " (mouse grabbed, press Opt+F5 to release)"}, + {STR_WINDOW_TITLE_GRABBED3, " (mouse grabbed, press Cmd+F5 to release)"}, #else - {STR_WINDOW_TITLE_GRABBED2, "Alt-"}, - {STR_WINDOW_TITLE_GRABBED3, "Win-"}, + {STR_WINDOW_TITLE_GRABBED2, " (mouse grabbed, press Alt+F5 to release)"}, +#endif +#ifdef __WIN32__ + {STR_WINDOW_TITLE_GRABBED3, " (mouse grabbed, press Win+F5 to release)"}, +#elif !defined(__APPLE__) + {STR_WINDOW_TITLE_GRABBED3, " (mouse grabbed, press Super+F5 to release)"}, #endif - {STR_WINDOW_TITLE_GRABBED4, "F5 to release)"}, {STR_WINDOW_MENU, "Basilisk II"}, {STR_WINDOW_ITEM_ABOUT, "About Basilisk II" ELLIPSIS}, {STR_WINDOW_ITEM_REFRESH, "Refresh Rate"}, diff --git a/SheepShaver/src/include/user_strings.h b/SheepShaver/src/include/user_strings.h index 5a4f4048..41d47d54 100644 --- a/SheepShaver/src/include/user_strings.h +++ b/SheepShaver/src/include/user_strings.h @@ -163,6 +163,9 @@ enum { STR_IGNORESEGV_CTRL, STR_IDLEWAIT_CTRL, STR_ROM_FILE_CTRL, + STR_NOGUI_CTRL, + STR_NOGUI_TIP, + STR_NOGUI_TIP2, // JIT Compiler pane STR_JIT_PANE_TITLE = 3700, @@ -171,11 +174,9 @@ enum { // Mac window STR_WINDOW_TITLE = 4000, - STR_WINDOW_TITLE_GRABBED0, STR_WINDOW_TITLE_GRABBED1, STR_WINDOW_TITLE_GRABBED2, STR_WINDOW_TITLE_GRABBED3, - STR_WINDOW_TITLE_GRABBED4, STR_WINDOW_MENU = 4050, STR_WINDOW_ITEM_ABOUT, STR_WINDOW_ITEM_REFRESH, diff --git a/SheepShaver/src/user_strings.cpp b/SheepShaver/src/user_strings.cpp index c29f7cff..165d6253 100644 --- a/SheepShaver/src/user_strings.cpp +++ b/SheepShaver/src/user_strings.cpp @@ -102,7 +102,7 @@ user_string_def common_strings[] = { {STR_NOCDROM_CTRL, "Disable CD-ROM Driver"}, {STR_ADD_VOLUME_TITLE, "Add Volume"}, {STR_CREATE_VOLUME_TITLE, "Create Hardfile"}, - {STR_HARDFILE_SIZE_CTRL, "Size (MB)"}, + {STR_HARDFILE_SIZE_CTRL, "Size (MiB)"}, {STR_GRAPHICS_SOUND_PANE_TITLE, "Graphics/Sound"}, {STR_FRAMESKIP_CTRL, "Window Refresh Rate"}, @@ -171,22 +171,27 @@ user_string_def common_strings[] = { {STR_IGNORESEGV_CTRL, "Ignore Illegal Memory Accesses"}, {STR_IDLEWAIT_CTRL, "Don't Use CPU When Idle"}, {STR_ROM_FILE_CTRL, "ROM File"}, + {STR_NOGUI_CTRL, "Don't show settings window on launch"}, + {STR_NOGUI_TIP, "Tip: You can access the settings by right-clicking on the launcher icon." }, + {STR_NOGUI_TIP2, "Tip: You can access the settings with the command: SheepShaver --nogui false" }, {STR_JIT_PANE_TITLE, "JIT Compiler"}, {STR_JIT_CTRL, "Enable JIT Compiler"}, {STR_JIT_68K_CTRL, "Enable built-in 68k DR Emulator (EXPERIMENTAL)"}, {STR_WINDOW_TITLE, "SheepShaver"}, - {STR_WINDOW_TITLE_GRABBED0, " (mouse grabbed, press "}, - {STR_WINDOW_TITLE_GRABBED1, "Ctrl-"}, + {STR_WINDOW_TITLE_GRABBED1, " (mouse grabbed, press Ctrl+F5 to release)"}, #ifdef __APPLE__ - {STR_WINDOW_TITLE_GRABBED2, "Opt-"}, - {STR_WINDOW_TITLE_GRABBED3, "Cmd-"}, + {STR_WINDOW_TITLE_GRABBED2, " (mouse grabbed, press Opt+F5 to release)"}, + {STR_WINDOW_TITLE_GRABBED3, " (mouse grabbed, press Cmd+F5 to release)"}, #else - {STR_WINDOW_TITLE_GRABBED2, "Alt-"}, - {STR_WINDOW_TITLE_GRABBED3, "Win-"}, + {STR_WINDOW_TITLE_GRABBED2, " (mouse grabbed, press Alt+F5 to release)"}, +#endif +#ifdef __WIN32__ + {STR_WINDOW_TITLE_GRABBED3, " (mouse grabbed, press Win+F5 to release)"}, +#elif !defined(__APPLE__) + {STR_WINDOW_TITLE_GRABBED3, " (mouse grabbed, press Super+F5 to release)"}, #endif - {STR_WINDOW_TITLE_GRABBED4, "F5 to release)"}, {STR_WINDOW_MENU, "SheepShaver"}, {STR_WINDOW_ITEM_ABOUT, "About SheepShaver" ELLIPSIS}, {STR_WINDOW_ITEM_REFRESH, "Refresh Rate"},