-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCiv_V_Map_Plotter.py
87 lines (76 loc) · 3.36 KB
/
Civ_V_Map_Plotter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import argparse
from Civ_V_Image_Manip import *
# Configure command line arguments.
parser = argparse.ArgumentParser(add_help=False)
# Optional arguments.
parser.add_argument('-d', '--diagnostic',
help='Create diagnostic graphic of hexagon operations.',
action="store_true")
parser.add_argument('-h', '--help',
help='Show this help screen and exit.',
action="help")
parser.add_argument('-m', '--method',
help='The capture method use. Allowable options are: \'sc3\': \
OSX\'s Shift-Cmd-3 to capture the full screen; \'sc4sb\': \
OSX\'s Shift-Cmd-4, Spacebar to capture the window with a \
shadow,\n',
type=str)
parser.add_argument('-nc', '--nocrop',
help='Do not crop the image specified.',
action='store_true')
parser.add_argument('-p', '--pdf',
help='Create PDF instead of PNG.',
action='store_true')
parser.add_argument('-s', '--single',
help='Flag to enable processing of a single image.',
action='store_true')
parser.add_argument('-v', '--verbosity',
help='The degree of output (higher gives more).',
type=int)
# Required arguments.
parser.add_argument('infilename',
help='The filename for the raw screenshot from Civilization \
V.')
parser.add_argument('mapsize',
help='The size of the map played. Valid options are: Duel, \
Tiny, Small, Standard, Large, and Huge.')
# Start working by first processing the command line arguments.
args = parser.parse_args()
# Provide error checking of command line arguments.
mapsize = args.mapsize.lower()
if(mapsize not in ['duel', 'tiny', 'small', 'standard', 'large', 'huge']):
raise RuntimeError('Mapsize specified not recognized. Valid options \
are: Duel, Tiny, Small, Standard, Large, and Huge.')
if(args.method):
method = args.method.lower()
if(method not in ['sc3', 'sc4sb']):
raise RuntimeError('Improper screen capture method specified. Valid \
options are: sc3 and sc4sb.')
else:
method = 'sc3'
if(args.verbosity):
print("Enabling verbose output, degree " + str(args.verbosity) + ".")
verbosity = args.verbosity
else:
verbosity = 0
if(verbosity >= 1):
print("Processing raw screenshot file " + args.infilename + \
" as a " + args.mapsize.lower() + " map.")
# Unless the user specified not to crop, do it.
img_manip = Civ_V_Image_Manip( args.infilename,
args.mapsize.lower(),
method,
verbosity,
args.diagnostic,
args.pdf)
# Crop and reset infilename to the cropped image.
if(not args.nocrop):
args.infilename = img_manip.Crop()
img_manip = Civ_V_Image_Manip( args.infilename,
args.mapsize.lower(),
method,
verbosity,
args.diagnostic,
args.pdf)
# Finally, we make the image that we are interested in.
img_manip.Create_Map_Image()