I have quite some maps, and would like to delete many of the ones I do not like/play.
I do not know the maps by name, but by mini-map, I do. If I had this plus the map dimensions in the thumbnail of a map when browsing the file-system, I could free up a few GB on my hard-disc, and have less visual noise in the lobby.
Is that already possible? (am on Debian testing).
btw.... hello, everyone!
greetz to abma!
[Feature request] Map thumbnails in the OS file browser
Moderator: Moderators
Re: [Feature request] Map thumbnails in the OS file browser
Hello hoijui. Not aware of this being possible but agree it would be neat.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: [Feature request] Map thumbnails in the OS file browser
SL puts minimaps in /appdata/roaming/springlobby/cache - not sure where on linux - provided it was given the chance in the map browser/battleroom to generate the previews. The dimensions are in the corresponding json file (for each map) and are called height/width, some easy Python/bash script can extract them.
Some code could be taken from SL and put into engine to generate this stuff imo - suggested because lualobbies currently have no means to see the minimaps (outside of the dummy map that they load in the background). SL is presumably calling unitsync, which lualobbies can't do.
Some code could be taken from SL and put into engine to generate this stuff imo - suggested because lualobbies currently have no means to see the minimaps (outside of the dummy map that they load in the background). SL is presumably calling unitsync, which lualobbies can't do.
Re: [Feature request] Map thumbnails in the OS file browser
Probably the easiest way to do this would be to add a delete button to Springlobby's map picker (the one where thumbnails are arranged in a grid).
SL gets the previews ("thumbnails") from unitsync.Silentwings wrote: ↑14 Jun 2020, 07:00Some code could be taken from SL and put into engine to generate this stuff imo
Re: [Feature request] Map thumbnails in the OS file browser
Cool Beherit, thanks!
using your code, I tried to hack something together that would work on linux (or at least gnome, not sure about others), according to the instructions here:
https://developer.gnome.org/integration ... er.html.en
I was unable to test it, as I can't get pymapconv working.
So it will likely have a lot of bugs, including wrongly spelled variables and such,
but .. it is getting there:
save this under , and then set it up with:
if you have it all set up correctly and debugged, it should, in theory, show you the mini-maps as file thumbnails in the liunx file browser of your choice.
using your code, I tried to hack something together that would work on linux (or at least gnome, not sure about others), according to the instructions here:
https://developer.gnome.org/integration ... er.html.en
I was unable to test it, as I can't get pymapconv working.
So it will likely have a lot of bugs, including wrongly spelled variables and such,
but .. it is getting there:
Code: Select all
#!/usr/bin/env python
from pymapconv import SMFMapDecompiler
import pyunpack
import os
import sys
import shutil
def sprintrts_extract_map_minimap(tmp_dir, map_file, minimap_file, size_px):
if map_file.lower().endswith('.sd7') or map_file.lower().endswith('.sdz'):
if map_file.endswith('7'):
new_suffix = '7z'
else:
new_suffix = 'zip'
renamed_map_file = os.path.join(tmp_dir, os.path.basename(map_file)[:-3] + new_suffix)
shutil.copyfile(map_file, renamed_map_file)
unzip_dir = os.path.join(tmp_dir, map_file)
pyunpack.Archive(renamed_map_file).extractall(unzip_dir, auto_create_dir = True)
for smf_file in os.listdir(os.path.join(unzip_dir,'maps')):
if smf_file.lower().endswith('.smf'):
SMFMapDecompiler(os.path.join(unzip_dir, 'maps', smf_file), minimaponly = True)
if len(sys.argv) != 3:
print ("Usage: command line parameters are: map-file-path output-thumpnail-file-path output-thumbnail-side-length-px")
exit(1)
map_file = sys.argv[0]
thumbnail_file = sys.argv[1]
thumbnail_size = sys.argv[2]
with tempfile.TemporaryDirectory() as tmp_dir:
os.mkdir(tmpdir)
sprintrts_extract_map_minimap(tmp_dir, map_file, thumbnail_file, thumbnail_size)
shutil.rmtree(tmp_dir)
Code: Select all
~/bin/springrts_map_thumbnailer.py
Code: Select all
# for sd7 maps:
gconftool-2 --set "/desktop/gnome/thumbnailers/application@x-7z-compressed/enable" --type boolean "true"
gconftool-2 --set "/desktop/gnome/thumbnailers/application@x-7z-compressed/command" --type string "python ~/bin/springrts_map_thumbnailer.py %i %o %s"
# for sdz maps:
gconftool-2 --set "/desktop/gnome/thumbnailers/application@zip/enable" --type boolean "true"
gconftool-2 --set "/desktop/gnome/thumbnailers/application@zip/command" --type string "python ~/bin/springrts_map_thumbnailer.py %i %o %s"