-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTR_CE_Create_SubsecFiles_Console.py
More file actions
123 lines (97 loc) · 4.09 KB
/
Copy pathTR_CE_Create_SubsecFiles_Console.py
File metadata and controls
123 lines (97 loc) · 4.09 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#
# Cepheus Engine Subsector Generation
#
# About:
#
# This script generates a CE SRD subsector and outputs to text, and alternatively
# JSON and PNG files
#
#
# Version: 0.1
# Author: Michael Bailey
# Date: 17 September 2020
#
# Usage
#
# usage: TR_CE_Create_SubsecFiles.py [-h] [--sector SECTOR] [--letter {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P}] [--density {RIFT,SPARSE,SCATTERED,STANDARD,DENSE}] [-p] [-j] [-n] name
# Generate a CE SRD subsector
# positional arguments:
# name Subsector Name
# optional arguments:
# -h, --help show this help message and exit
# --sector SECTOR Parent Sector Name (default: Placeholder)
# --letter {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P}
# Subsector Letter (default: A)
# --density {RIFT,SPARSE,SCATTERED,STANDARD,DENSE}
# subsector density (default: STANDARD)
# -p, --writepng Write the subsector data to a PNG file
# -j, --writejson Write the subsector data to a JSON file
# -n, --nonames Do not add mainworld names to the PNG file
# Import modules here
# Python modules
import argparse
import sys
# from gooey import Gooey
# App modules
import TR_Constants
import TR_Support
import TR_CE_Subsector
import TR_Imaging
# @Gooey(monospace_display=True)
def main():
# Parse command line arguments
parser = ""
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="""
Generate a CE SRD subsector
""")
parser.add_argument("name", default='subsec', help="Subsector Name")
parser.add_argument("--sector", default='Placeholder', help="Parent Sector Name (default: %(default)s)")
parser.add_argument("--letter", \
choices=TR_Constants.SUBSECLETTERS, \
default = 'A', help="Subsector Letter (default: %(default)s)")
parser.add_argument("--density", \
choices=TR_Constants.DENSITY_VALUES, \
default = 'STANDARD', help="subsector density (default: %(default)s)")
parser.add_argument("-p", "--writepng", action="store_true", \
help="Write the subsector data to a PNG file")
parser.add_argument("-j", "--writejson", action="store_true", \
help="Write the subsector data to a JSON file")
parser.add_argument("-n", "--nonames", action="store_true", \
help="Do not add mainworld names to the PNG file")
parser.add_argument("-f", "--namefile", default='', help='System names file')
# Process the arguments
args = parser.parse_args()
ARG_NAME = args.name
ARG_SECTOR = args.sector
ARG_LETTER = args.letter
ARG_DENSITY = args.density
ARG_JSON = args.writejson
ARG_PNG = args.writepng
ARG_NONAMES = args.nonames
ARG_NAMEFILE = args.namefile
# Convert density values to integers for lookup
stellarDensity = TR_Constants.DENSITY_VALUES.index(ARG_DENSITY)
# Create and generate the subsector
# Parameters will be eventually available as command line arguments
print("Generating " + ARG_NAME + " Subsector (" + ARG_SECTOR + "/" + ARG_LETTER + ")")
print("Stellar Density = " + ARG_DENSITY)
print()
s1 = TR_CE_Subsector.Subsector(ARG_NAME, ARG_SECTOR, ARG_LETTER, stellarDensity)
s1.genSubSec()
print("```")
s1.printSubSec()
print("```")
# Write to an output SEC file - once again this will be passed by a command line argument in the future
print("Writing subsector data to " + ARG_NAME + ".uwp")
with open(ARG_NAME + ".uwp", 'w', encoding='utf-8') as f: f.write(s1.writeSubSec())
if ARG_JSON:
print("Writing subsector data to " + ARG_NAME + ".json")
with open(ARG_NAME + ".json", 'w', encoding='utf-8') as j: j.write(s1.writeSubSecJSON())
if ARG_PNG:
addnames = not ARG_NONAMES
pngfile = ARG_NAME + ".png"
print("Writing subsector data to " + pngfile)
TR_Imaging.drawHexMap(s1, pngfile, addnames)
if __name__ == "__main__":
main()