Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
Version 3.0 (already, yes)
  • Loading branch information
Tetragramm committed Jul 19, 2022
0 parents commit d3a9da5
Show file tree
Hide file tree
Showing 10 changed files with 705 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys
import re
import os
if os.path.isfile('./AuthorInfo.text'):
with open('./AuthorInfo.text', 'r') as AI:
Title = AI.readline()
Title = Title.strip()
if os.path.isfile(Title+'.tex'):
os.system(
f'lualatex -synctex=1 -interaction=nonstopmode -file-line-error -pdf "{Title}.tex"')
os.system(
f'lualatex -synctex=1 -interaction=nonstopmode -file-line-error -pdf "{Title}.tex"')
os.system(
f'lualatex -synctex=1 -interaction=nonstopmode -file-line-error -pdf "{Title}.tex"')
else:
print('No LaTeX file matching saved Title found.')
else:
print('No saved AuthorInfo.text found. Cannot compile.')
231 changes: 231 additions & 0 deletions Create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
import sys
import re
import os

subfiles = []
Title = "Default"
Authors = []


def ParseVitalParts(vp):
part_list = vp.split(',')
part_list = [x.strip() for x in part_list]
singular = [x for x in part_list if not '#' in x]
Engines = [x for x in part_list if 'Engine' in x]
Radiators = [x for x in part_list if 'Radiator' in x]
OilCooler = [x for x in part_list if 'Oil Cooler' in x]
OilPan = [x for x in part_list if 'Oil Pan' in x]
OilTank = [x for x in part_list if 'Oil Tank' in x]
Guns = [x for x in part_list if 'Weapon' in x]
Pilot = [x for x in part_list if ': Pilot' in x]
CoPilot = [x for x in part_list if 'Co-Pilot' in x]
Gunner = [x for x in part_list if 'Gunner' in x]
Bombadier = [x for x in part_list if 'Bombadier' in x]
Aircrew = [x for x in part_list if 'Aircrew' in x]

output = []

def append(arr, str):
if len(arr) == 1:
output.append(str)
elif len(arr) > 1:
output.append('x{} {}s'.format(len(arr), str))

append(Engines, 'Engine')
append(OilCooler, 'Oil Cooler')
append(OilPan, 'Oil Pan')
append(OilTank, 'Oil Tank')
append(Radiators, 'Radiator')
append(Guns, 'Gun')
output = output + singular
str = ', '.join(output) + '\\\\'
output = []
append(Pilot, 'Pilot')
append(CoPilot, 'Co-Pilot')
append(Bombadier, 'Bombadier')
append(Gunner, 'Gunner')
append(Aircrew, 'Aircrew')
return str + ', '.join(output)


def MakeSubfile(osfile):
print("Subfile {}".format(osfile))
with open(osfile, 'r', encoding='utf-8') as file:
lines = file.readlines()
lines = [x.strip() for x in lines]
lines = [re.sub('#', '\#', x) for x in lines]

FileName = re.sub('[^0-9a-zA-Z]', '_', lines[1])

Link = lines[0]
AircraftName = lines[1]
Nickname = lines[2]
Cost = lines[3]
Upkeep = lines[4]

FirstRow, FullBoost, FullHandling, FullClimb, FullStall, FullSpeed = lines[6].split(
'\t')
if 'Full Fuel' in FirstRow:
_, HalfBoost, HalfHandling, HalfClimb, HalfStall, HalfSpeed = lines[7].split(
'\t')
_, _, EmptyBoost, EmptyHandling, EmptyClimb, EmptyStall, EmptySpeed = lines[8].split(
'\t')
VitalParts = ParseVitalParts(lines[11])
FirstLine = lines[13]
SecondLine = lines[15]
ThirdLine = lines[17]
SpecialRules = '\\\\'.join(lines[19:])

StatTable = f"""
Full Fuel & {FullBoost} & {FullHandling} & {FullClimb} & {FullStall} & {FullSpeed} \\\\
Half Fuel & {HalfBoost} & {HalfHandling} & {HalfClimb} & {HalfStall} & {HalfSpeed} \\\\
Empty & {EmptyBoost} & {EmptyHandling} & {
EmptyClimb} & {EmptyStall} & {EmptySpeed}
\\CodeAfter
\\begin{{tikzpicture}}
\\draw [thick] (2-|2) -- (2-|7) ;
\\draw [thick] (3-|2) -- (3-|7) ;
\\draw [thick] (4-|2) -- (4-|7) ;
\\draw [thick] (5-|2) -- (5-|7) ;
\\draw [thick] (2-|2) -- (last-|2) ;
\\draw [thick] (2-|3) -- (last-|3) ;
\\draw [thick] (2-|4) -- (last-|4) ;
\\draw [thick] (2-|5) -- (last-|5) ;
\\draw [thick] (2-|6) -- (last-|6) ;
\\draw [thick] (2-|7) -- (last-|7) ;"""
else:
FwBBoost, FwBHandling, FwBClimb, FwBStall, FwBSpeed = (
FullBoost, FullHandling, FullClimb, FullStall, FullSpeed)
_, HwBBoost, HwBHandling, HwBClimb, HwBStall, HwBSpeed = lines[7].split(
'\t')
_, FullBoost, FullHandling, FullClimb, FullStall, FullSpeed = lines[8].split(
'\t')
_, HalfBoost, HalfHandling, HalfClimb, HalfStall, HalfSpeed = lines[9].split(
'\t')
_, _, EmptyBoost, EmptyHandling, EmptyClimb, EmptyStall, EmptySpeed = lines[10].split(
'\t')
VitalParts = ParseVitalParts(lines[13])
FirstLine = lines[15]
SecondLine = lines[17]
ThirdLine = lines[19]
SpecialRules = '\\\\'.join(lines[21:])

StatTable = f"""
Full Load & {FwBBoost} & {FwBHandling} & {FwBClimb} & {FwBStall} & {FwBSpeed} \\\\
\\nicefrac{{1}}{{2}}, Bombs & {HwBBoost} & {HwBHandling} & {HwBClimb} & {HwBStall} & {HwBSpeed} \\\\
Full Fuel & {FullBoost} & {FullHandling} & {FullClimb} & {FullStall} & {FullSpeed} \\\\
Half Fuel & {HalfBoost} & {HalfHandling} & {HalfClimb} & {HalfStall} & {HalfSpeed} \\\\
Empty & {EmptyBoost} & {EmptyHandling} & {
EmptyClimb} & {EmptyStall} & {EmptySpeed}
\\CodeAfter
\\begin{{tikzpicture}}
\\draw [thick] (2-|2) -- (2-|7) ;
\\draw [thick] (3-|2) -- (3-|7) ;
\\draw [thick] (4-|2) -- (4-|7) ;
\\draw [thick] (5-|2) -- (5-|7) ;
\\draw [thick] (6-|2) -- (6-|7) ;
\\draw [thick] (7-|2) -- (7-|7) ;
\\draw [thick] (2-|2) -- (last-|2) ;
\\draw [thick] (2-|3) -- (last-|3) ;
\\draw [thick] (2-|4) -- (last-|4) ;
\\draw [thick] (2-|5) -- (last-|5) ;
\\draw [thick] (2-|6) -- (last-|6) ;
\\draw [thick] (2-|7) -- (last-|7) ;"""

with open('./templates/Sub.pretex', 'r', encoding='utf-8') as file:
str = file.read()

str = str.format(
FileName=FileName,
AcftName=AircraftName,
Cost=Cost,
Upkeep=Upkeep,
Description=Nickname,
StatTable=StatTable,
VitalParts=VitalParts,
Stats1=FirstLine,
Stats2=SecondLine,
Stats3=ThirdLine,
SpecialRules=SpecialRules,
Link=Link
)
subfiles.append(FileName+'.tex')
with open('./subfiles/'+FileName+'.tex', 'w', encoding='utf-8') as file:
file.writelines(str)

if not os.path.isfile('./desc/'+FileName+'_desc.txt'):
with open('./desc/'+FileName+'_desc.txt', 'w', encoding='utf-8') as file:
file.write(
'\\documentclass[../subfiles/'+FileName+'.tex]{subfiles}\n')
file.write('\\begin{document}\n')
file.write('\n')
file.write('\\end{document}\n')

if not os.path.isfile('./desc/'+FileName+'_table.txt'):
with open('./desc/'+FileName+'_table.txt', 'w', encoding='utf-8') as file:
file.write("""Role=Edit, Add or
Served With=remove lines
First Flight=to fill
Strengths=out the
Weaknesses=table
Inspiration=like this.""")

has_image = False
for file in os.listdir('./images/'):
if FileName+'_image' in file:
has_image = True
break
if not has_image:
with open('./images/'+FileName+'_image.png', 'wb') as img_out, open('./templates/Default.png', 'rb') as img_in:
img_out.write(img_in.read())


if not os.path.isdir('./desc'):
os.mkdir('./desc')
if not os.path.isdir('./images'):
os.mkdir('./images')
if not os.path.isdir('./subfiles'):
os.mkdir('./subfiles')

if os.path.isfile('./AuthorInfo.text'):
with open('./AuthorInfo.text', 'r', encoding='utf-8') as AI:
Title = AI.readline()
Title = Title.strip()
for line in AI:
Authors.append(line)
else:
Title = input('Title: ')
Title = Title.strip()
auth = 'stuff'
while auth:
auth = input("Author (press enter to end entry): ")
if auth:
Authors.append(auth)
with open('./AuthorInfo.text', 'w', encoding='utf-8') as AI:
AI.write(Title+'\n')
for auth in Authors:
AI.write(auth+'\\\\')

for file in os.listdir('.'):
if file.endswith('.txt'):
MakeSubfile(file)

with open('./templates/Main.pretex', 'r', encoding='utf-8') as main_in, open(Title+'.tex', 'w', encoding='utf-8') as main_out:
str = main_in.read()
AuthorStr = '\\'.join(Authors)
SubfileString = ''
for sf in subfiles:
SubfileString += f"\\subfile{{./subfiles/{sf}}}\n"
str = str.format(
Title=Title,
Authors=AuthorStr,
SubfileIncludes=SubfileString
)
main_out.write(str)

os.system(
f'lualatex -synctex=1 -interaction=nonstopmode -file-line-error -pdf "{Title}.tex"')
os.system(
f'lualatex -synctex=1 -interaction=nonstopmode -file-line-error -pdf "{Title}.tex"')
os.system(
f'lualatex -synctex=1 -interaction=nonstopmode -file-line-error -pdf "{Title}.tex"')
Binary file added Instructions.pdf
Binary file not shown.
Binary file added fonts/Balthazar-Regular.ttf
Binary file not shown.
Binary file added fonts/Koch Fraktur.ttf
Binary file not shown.
93 changes: 93 additions & 0 deletions fonts/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright (c) 2011, Dario Manuel Muhafara (http://www.tipo.net.ar),
with Reserved Font Name "Balthazar".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added templates/Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d3a9da5

Please sign in to comment.