A working SDL2 client (linux and windows)#79
Conversation
|
for those who like to read, here is more exhausting list with differences from native x11 client
|
|
Ok, I found the windowDecorations setting from tomenet.cfg and got my borders back. I think the borders should be enabled by default. Having the configuration file in a new location ($HOME/.local/share/TomenetGame/tomenet/tomenet.cfg) was a bit confusing. You did add the new location to the guide which is good. I just wonder if it's possible to make the configuration file easier to find. |
|
I tested the SDL2 client on Windows and it works but it has pretty much the same bugs as the Linux client. I tried editing %APPDATA%/TomenetGame/tomenet/tomenet.cfg to enable window borders but it didn't work. SDL_TEXTINPUT event probably needs to be used to get the keyboard input working correctly with respect to layout. Both Angband and MAngband are using SDL_TEXTINPUT. |
|
@mhirki thx, i know about the SDL_TEXTINPUT, i'm working on it... but it is not that easy... something works with SDL_TEXTINPUT, something (most ctrl combinations, special keys, ...) only with SDL_KEYDOWN, i have to make an hybrid approach... and if that isn't enough, in the SDL_KEYDOWN you can't figure out the keycode when shift was pressed in SDL2... i'm really considering closing this PR and rewriting to SDL3 (which has this figured out)... however, i have mostly figured out all the issues you reported, i'm testing it now... when i'm satisfied with the test, i'll push and ping you |
- Increased vesion to 4.9.3.0.1.1. - Add USE_SDL2 macros thorough the code. - Add OS_SUB_SDL2 and OS_SUB_GCU_SDL2 and use it in VERSION_OS_SUB. - Add Unified makefile.sdl2 for linux compiling and windows cross compiling. - Compile windows sdl2 client without wine and tolua.exe - Remove unnecessary generation rules for common/z_pack - Refactor the tolua file generation - Make tomenet and tomenet.exe executables in one run in SDL2 client - add automatic header-dependency tracking with -MMD/-MP - Update .gitignore - Introducing SDL2_GAME_PATH, SDL2_USER_PATH and SDL2_PATH_SEP variables. - Introduce SDL2 user directory - Declare and expose new ANGBAND_USER_DIR* pointers based on ANGBAND_DIR* - Inform about creating user directories, refactor - Copy default scripts into `ANGBAND_USER_DIR_SCPT` when it's created - Redirect SDL2 client file I/O to the SDL2 user directory - Store temporary files and logs in the SDL2 temp folder - Rename copy_file to my_fcopy. - Edit my_fopen to open files with fallback and use instead of fopen in SDL2 client - Prefer user dir for fonts/tilesets/macros; install audio packs to user xtra - Use user dir when saving sound/music.cfg files - Override the user storage dir via TOMENET_SDL2_USER_PATH environment variable - Using a dir in sdl2 user path as tmpdir when no env value is set. - Add common/net-sdl2.c using the SDL2 SDL_net library and use it with sdl2 clients. - Add main-sdl2.c based on main-x11.c and use it in SDL2 client. - Add multi-layer multi-masks tiles support. - Add tile cache support, but turn it off (not needed, it is fast). - Graphic tiles are initialized after pref file is loaded. - Graphics pref file now contains information about masks colors. - Per-subtileset mask colors are now loaded from .prf files and used. - Support PCF and TTF fonts in the SDL2 fonts menu, handle PCF fonts as graphical - Add pcf fonts to lib/xtra/font for sdl2 clients - Add window decorations toggle to settings file and in-game window flags menu - On window move, store coordinates considering decorations. - Windows are created with decorations by default. - Using tomenet.cfg in sdl2 user path as config (based on .tomenetrc). - Make check_guide_checksums work for sdl2 with curl & ssl. - Removing goto from client/client.c in mangrc read function. - Use SDL2_image library for screenshots, but it is optional. - If not using SDL2_image, save screenshots to BMP instead of PNG. - Add SDL2_STICKY_KEYS macro and disable by default - Create snd-sdl2.c file based on snd-sdl.c - switch SDL2 client sound to SDL2 - allow sound code to compile with either `SOUND_SDL` or `SOUND_SDL2` - fix sdl2 quit on music quit, add debug logs to sdl2 unarchive - guard SDL mixer shutdown - determine fd availability by opening null files on init - fix SDL2 audio FD accounting for samples vs music - fix wrong mutex unlock when loading music (also in snd-sdl.c) - refactor sound_sdl_init function - fix audio init failure cleanup - Add subset logic - Fix jukebox autoplay finish and destuctive pack-switch - Fix post-autoplay cursor restore - Ix autoplay stop after first song after a/u/e session - Stabilize jukebox restore/fadeout/shutdown state across mixer reloads and previews - Preserve force-disabled and runtime-disabled SDL2 audio state correctly in config and toggles - Ignore transient EMFILE/ENFILE when loading audio events - Add libarchive-based unzipping sound/music pack 7zipped files. - detect libarchive in makefile.sdl2 via pkg-config and link when available - Notify when unpacking unsupprted 7z encrypted archive - More archives support in sdl2 clients (.zip, .tar, .tar.gz). - Use SDL_OpenURL for file and link opening - Hide disable_tile_cache into TILE_CACHE_SIZE ifdef macro - Fix double separator in lua scripts. - Using semi-transparent black as top tile outline color for UG_2MASK mode - Graphics tiles outline layer generation for fg/bg tiles when UG_2MASK mode. Option to force outline generation of specific width. - Graphics tiles preferences on-the-fly change and tiles with layers preview in in-game graphics menu. - Graphic subtiles implemenation. Respects subtiles in preview an cache. - Graphics cache resets subset/index during init and teardown to keep entries clean before reuse. - Loading graphics images of tiles and subtiles from user location first - Add tileset resize modes support, default is NEAREST. - Treating the SDL2 Delete key separately from Backspace so prompts receive '\177' (0x7F), while keeping the Backspace handling unchanged. - In knowledge menu, open last screenshot instead of conversion - Open user folders in in-game knowledge menu too. - Make macroset scan OS independent for SDL2 test clients - Add basic player sounds according to sound.cfg.default content. - Create fake but deterministic MAC depending on PC stats - Add .prf files to lib/user for sdl2 clients - Get rid of most compiler warnings. - Build sdl2 linux client to prefer .so beside the binary. - Make SDL2 ip_iface return IPv4 string like Windows client. - Add optional GCU support for SDL2 Linux client build, default is off - Added build scripts for fedora 41 & 43 distrobox build containers. - Added CI for github with Fedora 41 build image and compile-check workflow - Added CI for building client/server release archives on tag push and append them if release is made. - Updated guide with info about sdl2 clients how to build them - Startup logo is graphic only when all used solid tiles are loaded - Add mask color documentation for sdl2 clients tileset bitmap
|
@mhirki i'm done with fixest for issues you found... tldr; changed version to v4.9.3.0.1.1, fixed the meta server failings, used SDL_TEXTINPUT for non-us layouts, decorations are on by default... for more info and answers read below but i'm converting this PR to a draft, cause i will rewrite to use SDL3, mainly for the SDL2 inability to right handle key-presses on non-us layouts without complex logic (keydown & textinput hybrid approach) and maybe it fixes some other issues... you can still test this version, it's very probable that any found issues will still be in the SDL3 version Answers:
OK, i understand... i just needed to test CI/CD for releases... i changed only brang and build numbers to indicate this is on other branch (in my fork) and that this is second iteration of SDL2 client... you can tell me to what version to change when everything is ready for merge and i'll change it
the idea is to have most code in the tomenet repo the same for all clients... now you have to maintain 2 versions of
fixed, now decorations are set as default in tomenet.cfg... it works on linux client and windows client trough wine on linux... btw. you can change the decorations on-the-fly in game in the "window flags" (= w) menu
i don't know why decorations on windows does not work, maybe in sdl3 it will work... maybe in meantime, try to build in fedora 43 container, it has sdl2-compat (which uses sdl3) and test... i don't have a windows pc at home, so i can't test/fix
my fault, haven't tested on live server (only localhost) so i didn't catch the metaserver fails... it should be fixed now
the path to files and folders can be found in ingame knowledge menu (~)... in the menu, shortcut for editing .cfg file is "C"... btw. the path to user dir is a default SDL2 user path, but can be overriden by env. variable
this should be working now, but the macro compatibility with x11 is not full... especially for crtl+shift and alt+shift combinations... this should be fixed in SDL3 rewrite |
Ok, version 4.9.3.0.1.1 should be fine for now.
Yes, I was also thinking about converting this PR to draft. It's a good way to prevent this from accidentally getting merged. You're welcome to continue porting over to SDL3. I tested the SDL2 client again and most of the important keys seem to be working, including numpad movement. So the SDL2 client actually seems to be in a playable state.
My initial thought was that we have working network code so we don't really "need" sdl2-net. Upon further thought, I'm starting to like the idea more. The old code has a strange license so it would be nice to jettison parts of it. With SDL3-net we could also get IPv6 support.
Actually, I tested the Windows client again and the borders are working but they are drawn offscreen. The content of the window is precisely at the top left corner of the display which hides the title bar of the window. If I move the windows manually and restart, the windows move up by the height of the title bar. |

This is a draft, do not merge, until everything is done
TODO
SDL2 clients
hello, this is a bigger one... i present you a working sdl2 client for linux & windows (windows client is compiled & tested trough mingw/wine only)
Why?
i think it is annoying whenever making some changes in graphics to implement it for linux & windows separately... sdl2 is multi-platform so the same code is for linux and windows client... and not only for graphics... i made it so, that all the code (net, snd, ...), except for some one-liner macros, is the same... no external dependencies
Highlights
Caveats
SDL_VIDEODRIVER=x11environment variable set to fallback to x11 and right windows positions on startWhat next?