-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.cls
190 lines (170 loc) · 5.57 KB
/
script.cls
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
\ProvidesClass{script}
\LoadClass[10pt]{article}
% \documentclass[10pt]{article}
% some latex distributions approximate letterpaper with cm values
% and I'm too lazy to figure out how to change mine to use exact inches
\usepackage[paperheight=8.5in, paperwidth=11in,margin=0.25in]{geometry}
\usepackage[parfill]{parskip} % Remove paragraph indentation
\usepackage{array}
\usepackage{tabu}
\usepackage{vcell}
\usepackage{color}
\usepackage{ifthen}
\usepackage{graphicx}
\graphicspath{ {./icons/} }
\usepackage{fontspec}
\setmainfont[
Path = Lora/,
Extension = .ttf,
UprightFont = *-Regular,
BoldFont = *-Bold,
ItalicFont = *-Italic,
BoldItalicFont = *-BoldItalic
]{Lora}
% create two side by side copies of data
\newenvironment{doubledoc}[1]{
\begin{minipage}[t][7.95in]{5.0in}
#1
\end{minipage}
\hspace{.5in}
\begin{minipage}[t][7.95in]{5.0in}
#1
\end{minipage}
}{}
% ------------------------- script front -------------------------
\newcommand{\scriptname}[1]{
\centerline{\Large\textit{#1}}
\smallskip
}
% this sets whether things stretch to the bottom of the page
% I figure most teensyville scripts will be cut smaller so don't need to stretch
\newboolean{teensyville}
\newcommand{\notfirstnight}{
\ifthenelse{\boolean{teensyville}} {\smallskip} {\vfill}
\centerline{\small\textbf{\textit{* Not the first night.}}}
\smallskip
}
% parameterized widths for new column types
\newlength{\iconwidth}
\newlength{\descwidth}
\newlength{\betweenwidth}
\setlength{\iconwidth}{0.46in}
\setlength{\descwidth}{1.95in}
\setlength{\betweenwidth}{5pt}
% new column types for character Icons and Descriptions that make the tables work
\newcolumntype{I}{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{\iconwidth}}
\newcolumntype{D}{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{\descwidth}}
% and custom table spacing
\setlength{\tabcolsep}{2pt}
\renewcommand{\arraystretch}{1.05}
% these handle the two column nature of the character table
\newcounter{chartypes}
\newcounter{chars_in_type}[chartypes] % chars_in_type resets to 0 when chartypes increments
\setcounter{chartypes}{0}
\setcounter{chars_in_type}{0}
\newenvironment{chartype}[1]{ % 1: character type
\stepcounter{chartypes}
\rule[3pt]{2in}{0.5pt}
\hfill {\large \textbf{#1}} \hfill
\rule[3pt]{2in}{0.5pt}
\\
\begin{tabular}{@{} I D @{\hspace{\betweenwidth}} I D @{}}
}{
\end{tabular}
}
\newcommand{\characterimage}[2]{ % 1: width, 2: icon file
% trim order is: left bottom right top
\includegraphics[width=#1,trim=0 120 0 35,clip]{#2}
}
\newcommand{\character}[3]{ % 1: character id, 2: name, 3: description
\characterimage{\linewidth}{#1.png}
& {\small\textbf{#2}}
\newline \vspace{-.2em}
\scriptsize #3
% this handles the two column nature of the character table
\stepcounter{chars_in_type} % 1 indexing
\ifthenelse{\isodd{\value{chars_in_type}}} {&} {\\}
}
% ------------------------- night order -------------------------
% parameterized widths for night stuff
\newlength{\nighticonwidth}
\setlength{\nighticonwidth}{0.3in}
\newcolumntype{F}{>{\centering\arraybackslash}m{\nighticonwidth}}
\newcolumntype{N}{>{\centering\arraybackslash}l}
\newlength{\nightspacing}
\setlength{\nightspacing}{2.0ex}
\newcommand{\nighttext}[2]{ % 1: text, 2: name
{\large\textbf{#1}}
% the tabular centers the vertical space which makes everything nice
& {\small\textbf{#2}} \begin{tabular}{l} \vspace{\nightspacing} \end{tabular} \\
}
\newcommand{\nighticon}[2]{ % 1: character id, 2: name
\nighttext{\characterimage{\linewidth}{#1.png}}{#2}
}
% don't worry about these - don't question it
\newsavebox{\fnightbox}
\newsavebox{\onightbox}
\newlength{\oheight}
\newlength{\fheight}
\newlength{\fwidth}
\newlength{\owidth}
\newlength{\diffh}
\newlength{\fillheight}
\newlength{\fillwidth}
\newenvironment{nights}[2]{
% Getting other nights to align to the bottom of the page or the bottom of
% first night was an incredible struggle of Latex fuckery. But it works
% and it is beautiful.
% technically you can just use tabular here, but tabu makes the line spacing
% better and I'm not entirely sure why
\savebox{\fnightbox}{
\begin{tabu}{@{} F N @{}}
\nighttext{}{\large First Night}
\nighttext{*}{Travellers}
#1
\nighttext{}{$\sim$ Dawn $\sim$}
\end{tabu}
}
\savebox{\onightbox}{
\begin{tabu}{@{} F N @{}}
\nighttext{}{\large Other Nights}
\nighttext{}{$\sim$ Dusk $\sim$}
\nighttext{*}{Travellers}
#2
\nighttext{}{$\sim$ Dawn $\sim$}
\end{tabu}
}
% get the heights and widths of the nights and use them to set the lengths
\settoheight{\oheight}{\usebox{\onightbox}}
\settoheight{\fheight}{\usebox{\fnightbox}}
\settowidth{\owidth}{\usebox{\onightbox}}
\settowidth{\fwidth}{\usebox{\fnightbox}}
\setlength{\diffh}{\fheight}
\addtolength{\diffh}{-\oheight}
\setlength{\fillheight}{\textheight}
\addtolength{\fillheight}{-\oheight}
\setlength{\fillwidth}{\linewidth}
\addtolength{\fillwidth}{-\owidth}
\addtolength{\fillwidth}{-\fwidth}
\addtolength{\fillwidth}{-.25in}
% actually print the table
\begin{tabular}{@{} l @{\hspace{\fillwidth}} r @{}}
\vcell{
\usebox{\fnightbox} % first night is easy
} & \vcell{
\ifthenelse{\boolean{teensyville}} { % not other nights
\ifthenelse{\lengthtest{\diffh > 0pt}} {
% why can't I use a strut here?
\raisebox{-\diffh}[0pt][0pt]{
\rotatebox{180}{\usebox{\onightbox}}
}}{\rotatebox{180}{\usebox{\onightbox}}}
}{
\rotatebox{180}{\usebox{\onightbox}}
\rule{0pt}{\fillheight}
}
} \\[-\rowheight]
\printcelltop & \printcellbottom \\
\end{tabular}
}
% bruh - it doesn't compile unless I have at least two blank lines here
% this was weird to debug