[XLib, SDL] Add function window_get_icon(), window_set_icon(), etc.

Reporter: time-killer-games  |  Status: open  |  Last Modified: September 12, 2019, 03:14:45 AM

Well, for the first time in the roughly 10 years the ENIGMA game engine has been around, you can now natively set a PNG icon for your game that will show in the title bar, task manager, system monitor, and Alt+Tab process swapper. No thanks to those fat lards Josh, Robert, and fundies. No offense, I love you guys, but I couldn't take it any longer so I decided to step in and add Linux icon support.

Includes the following functions:

  • string window_get_icon() returns the absolute path to the custom icon being used by the game. Returns an empty string "" if there is not one currently used.

  • void window_set_icon(string fname) sets the icon to use for the game from the given PNG filename fname.

  • void window_set_icon_from_unpacked_sprite(int ind, unsigned subimg, string fname) Want to export your game as a single executable? You can! Exports the internal sprite resource of the given sprite index ind and subimage subimg. Export it to preferably the temp_directory or game_save_id folders with the provided PNG filename fname. The image will be loaded from that exported location and will be displayed as the icon.

  • void window_set_icon_from_unpacked_background(int ind, string fname) Similar to the sprite function. Exports the internal backgound resource of the given background index ind. Export it to preferably the temp_directory or game_save_id folders with the provided PNG filename fname. The image will be loaded from that exported location and will be displayed as the icon.

Example project and 64-bit demo executable: animated_icon.zip

Screenshot_20190830_131818

As a small side note - this pull request also allows capturing SDL's window handle on linux for widget use. Although I still haven't fixed the SDL bug where the game doesn't respond and then segfaults, if you click the close button in the main game window's title bar over and over while a dialog is open. Not many people will do that so it's not a huge bug.

codecov[bot]  
>Codecov Report

Merging #1854 into master will decrease coverage by 0.11%.
The diff coverage is 1.2%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1854      +/-   ##
==========================================
- Coverage   25.15%   25.03%   -0.12%     
==========================================
  Files         177      178       +1     
  Lines       16844    16927      +83     
==========================================
+ Hits         4237     4238       +1     
- Misses      12607    12689      +82
Impacted Files Coverage Δ
ENIGMAsystem/SHELL/Platforms/General/PFwindow.h 100% <ø> (ø) ⬆️
ENIGMAsystem/SHELL/Platforms/xlib/XLIBicon.cpp 0% <0%> (ø)
ENIGMAsystem/SHELL/Platforms/xlib/XLIBwindow.cpp 50.74% <6.66%> (-1.7%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 130e673...c8711dc. Read the comment docs.

time-killer-games  

@JoshDreamland please review kthx
Please sign in to post comments, or you can view this issue on GitHub.