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:
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)
save this under
Code: Select all
~/bin/springrts_map_thumbnailer.py
, and then set it up with:
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"
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.