[Feature request] Map thumbnails in the OS file browser

[Feature request] Map thumbnails in the OS file browser

Discuss your problems with the latest release of the engine here. Problems with games, maps or other utilities belong in their respective forums.

Moderator: Moderators

Post Reply
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

[Feature request] Map thumbnails in the OS file browser

Post by hoijui »

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!
2 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6187
Joined: 29 Apr 2005, 01:14

Re: [Feature request] Map thumbnails in the OS file browser

Post by FLOZi »

Hello hoijui. Not aware of this being possible but agree it would be neat.
0 x

User avatar
Silentwings
Moderator
Posts: 3655
Joined: 25 Oct 2008, 00:23

Re: [Feature request] Map thumbnails in the OS file browser

Post by Silentwings »

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.
0 x

User avatar
ThinkSome
Posts: 340
Joined: 14 Jun 2015, 13:36

Re: [Feature request] Map thumbnails in the OS file browser

Post by ThinkSome »

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).
Silentwings wrote:
14 Jun 2020, 07:00
Some code could be taken from SL and put into engine to generate this stuff imo
SL gets the previews ("thumbnails") from unitsync.
0 x


User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: [Feature request] Map thumbnails in the OS file browser

Post by hoijui »

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.
0 x

Post Reply

Return to “Help & Bugs”