Create new color profiles (This post not relevant anymore))
  • At the moment of posting this was already out of date. I just leave it here for reference.
    ** This is without a doubt not supported by MapFactor and therefore not supported in this forum except by me. But I don't accept any responsibility if your MNF doesn't work anymore and you need to uninstall it and do a fresh install **
    (It works for me without a flaw)

    Hi,

    The new 1.5.11 development version also adds the possibilty to modify the map colors in the "album.style" file from within MNF. However, you can only modify the current profiles and not add a new one.
    The python script below can do that for you.
    You need to copy the album.style file from your device and put it in the same folder where you have saved this python script (lets call this script "new_style.py").
    From this folder you simply execute the python script.
    In Linux/FreeBSD/Mac-OSX/un*x systems: "$ ./new_style.py"
    On windows (install some python 2.6+ first): "python new_style.py"

    #!/usr/bin/env python

    # version 01, 2015-01-26, Harry van der Wolf

    import os, csv

    map_file = "album.style"
    new_rows = ""

    dos2unix = open(map_file, 'rb').read().replace('\r\n', '\n')
    open(map_file, 'wb').write(dos2unix)
    print('reading contents of: ' + map_file)
    with open(map_file, 'rb') as mapfile:
       rows = mapfile.readlines()
       for row in rows:
             if '="nm"' in row:
                new_rows += row
                new_rows += row.replace('"nm"', '"nmg"')
             else:
                new_rows += row

    print('\n\nNow writing the new style')
    text_file = open('newalbum.style', 'w')
    text_file.write(new_rows)
    text_file.close()

    (Continued in post 2 due to post length limit)
  • 6 Comments sorted by
  • The script above in post 1 uses the "album.style" file and creates a file "newalbum.style". In the python script above you see the lines:
             if '="nm"' in row:
                new_rows += row
                new_rows += row.replace('"nm"', '"nmg"')

    It looks for the lines that contain ="nm" which are the lines that contain the settings for the default night mode. As I don't like that one I made one myself "night mode grey".
    When you open the newly created "newalbum.style" file in a text-editor (on Windows you need a linux line-ending aware editor like notepad-++), you will find in the top section a row of schemes like:

        <scheme>
          <scheme_id>uk</scheme_id>
          <name tr="yes">Day mode United Kingdom</name>
        </scheme>
        <scheme>
          <scheme_id>nm</scheme_id>
          <name tr="yes">Night mode</name>
        </scheme>

    In this case duplicate the bold lines and change "nm" to "nmg" and "Night mode" to "Night mode Grey".
    So you need to create/duplicate a new scheme yourself. All the other lines in the new "newalbum.style" are automatically duplicate to follow the new scheme "nmg", which is at this moment a complete copy of nm of course.
    Of course you can do the same with one of the other schemes, like for example where you would change "uk" to "muk" (my uk). Simply change the lines
             if '="nm"' in row:
                new_rows += row
                new_rows += row.replace('"nm"', '"nmg"')

    You need to take the real scheme name.

    Make sure you have your backup of "album.style". You can either modify your "newalbum.style" in the map editor (works fine in wine as well) or copy it as album.style back onto your phone and edit it directly in the new MNF 1.5.11+. 

  • If you are on windows and don't want to fiddle at all with differences between dos and unix line endings you can also remove the two lines
    dos2unix = open(map_file, 'rb').read().replace('\r\n', '\n')
    open(map_file, 'wb').write(dos2unix)
    from the script
  • Nice but why not use CLONE function(when you click on theme any theme)?
  • Yes, that is of course very convenient but where do I do that?
    I assume that something like that is also more fool proof that my way of working.
    The only reason I wrote that little script was because I was missing such a function. (The script took me 10-15 minutes to write so that wasn't a big deal either)
  • Sorry. I see it already. From the Android MNF edit screen. I thought you meant from the Map Editor.
  • No problem, it makes me a bit surprised only

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion