#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Dililatum: a quest system for simple RPGs
# Copyright (C) 2010  Niels Serup

# This file is part of Dililatum.
#
# Dililatum is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dililatum is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dililatum.  If not, see <http://www.gnu.org/licenses/>.

##[ Name        ]## mark-os-pos
##[ Maintainer  ]## Niels Serup <ns@metanohi.org>
##[ Description ]## Shows a background for marking where characters
                  # can safely walk

import sys

try:
    from dililatum.tools.posmarker import *
except ImportError:
    import os.path
    sys.path.append(os.path.split(os.path.dirname(os.path.realpath(__file__)))[0])
    from dililatum.tools.posmarker import *

args = sys.argv[1:]
if len(args) == 1:
    if args[0] == '-H' or args[0] == '--help':
        print """\
Usage: mark-where-pos-ok [OPTION] IMGFILE POSFILE
Shows a background for marking where characters can safely walk

Options:
  -H, --help        show this help and exit
  -V, --version     show version information and exit

Use the left mouse button to mark, PageUp and PageDown to adjust the
"brush" size and the right mouse button to unmark."""
        sys.exit()
    elif args[0] == '-V' or args[0] == '--version':
        import dililatum.generalinformation as ginfo
        print ginfo.version_text
        sys.exit()
    else:
        sys.stderr.write('mark-where-pos-ok: error: you didn\'t specify a POSFILE\n')
        sys.exit(1)
elif len(args) == 0:
    sys.stderr.write('mark-where-pos-ok: error: you didn\'t specify any files!\n')
    sys.exit(1)
else:
    imgfile = args[0]
    posfile = args[1]

pm = OKPositionsMarker(imgfile, posfile)
try:
    pm.start()
except (KeyboardInterrupt, EOFError):
    print # A newline
finally:
    pm.end()
