Files
Star-Wars-ffg/star-wars-formatting.sty
2023-05-29 00:31:27 +02:00

307 lines
7.9 KiB
TeX

\usepackage{tikz}
\usepackage{ifthen}
\usepackage[margin=0.4in,bottom=0.2in]{geometry}
\usepackage{fontspec}
\usepackage{xstring}
\usepackage{multirow}
\usepackage{forloop}
\usepackage{xparse}
\usepackage{multicol}
\usetikzlibrary {shapes.multipart,shapes.misc,shapes.symbols,calc,positioning,fit}
\input{star-wars-icons.sty}
\input{star-wars-talents.sty}
\setmainfont{ITCSymbol Book}
\newfontfamily{\tn}{Elektra Medium Pro}
\DeclareTextFontCommand{\texttn}{\tn}
\newfontfamily{\ltn}{Elektra Light Pro}
\DeclareTextFontCommand{\textltn}{\ltn}
\newcounter{undeffed}
\setcounter{undeffed}{0}
\setlength{\parindent}{0pt}
\def\specialization{}
\makeatletter
\NewDocumentCommand {\getnodedimen} {O{\nodewidth} O{\nodeheight} m} {
\begin{pgfinterruptboundingbox}
\begin{scope}[local bounding box=bb@temp]
\node[inner sep=0pt, fit=(#3)] {};
\end{scope}
\path ($(bb@temp.north east)-(bb@temp.south west)$);
\end{pgfinterruptboundingbox}
\pgfgetlastxy{#1}{#2}
}
\let\@var\@empty
\newcommand{\append}[1]{\addtocounter{undeffed}{1}\xdef\@var{\@var #1} }
% Another variant with kernel \g@addto@macro
\newcommand{\appendother}[1]{\g@addto@macro{\@var}{#1}}
\newcommand{\undeffed}{\@var}
\newcommand{\drawforce}{%
\@ifundefined{force@\specialization}{}{%
\definecolor{talentcolor}{HTML}{000000}
\node[forcepower] at (0.2,-2.48) {};
\node[talentname] at (0,-2.1) {\footnotesize{}\texttn{FORCE TALENT}};
}
}
\newcommand{\setforce}{%
\protected@write\@auxout{}{%
\global\string\@namedef{force@\specialization}{}%
}%
}
\makeatother
\newlength{\textlength}
\pagestyle{empty}
\def\career{}
\def\careerskills{}
\newcommand{\setcareer}[2]{%
\def\career{#1}%
\def\careerskills{#2}%
}
\tikzset{
every node/.style={anchor=north west},
talent/.style={
chamfered rectangle,
chamfered rectangle corners={north east, south west, south east},
draw,
thick,
double,
inner xsep=-2pt,
inner ysep=0pt
},
talentname/.style={
chamfered rectangle,
chamfered rectangle corners={north east, south east},
inner ysep=0cm,
inner xsep=0.11cm,
text width = 2.81cm,
align=left,
text=white,
fill=talentcolor
},
cost/.style={
chamfered rectangle,
text=white,
chamfered rectangle xsep=2cm,
text width= 30pt,
align=center,
inner ysep=-1pt,
fill=talentcolor,
right=of \alph{talentx}\alph{talenty}.south,
left=-40pt
},
forcepower/.style={
starburst,
starburst points=7,
random starburst=6,
starburst point height=10pt,
fill=talentcolor,
draw=white,
line width=1.5pt,
minimum width=30pt,
minimum height=30pt,
rotate=155
},
ranked/.style={
talentname,
fill=white,
draw = talentcolor,
thick,
inner ysep=0.05cm,
minimum width = 3.36cm,
inner xsep = 0.05cm,
chamfered rectangle xsep = 0.15cm
}
}
\newcounter{talentx}
\newcounter{talenty}
\newcounter{tmpchar}
\newcounter{tmpx}
\newcounter{tmpxp}
\newcounter{tmpy}
\newcounter{tmpyp}
\newcommand{\talentline}[2]{
\StrChar{#1}{2}[\tmpone]
\StrChar{#2}{2}[\tmptwo]
\ifthenelse{\equal{\tmpone}{\tmptwo}}{
\draw[line width=1.5mm] ([xshift=3.57cm,yshift=-0.7cm]#1.north west) -- ([yshift=-0.7cm]#2.north west);
}{
\draw[line width=1.5mm] (#1) -- (#2);
}
}
\newcommand{\swtalent}[5]{%
\addtocounter{talentx}{1}%
\ifthenelse{\equal{\arabic{talentx}}{5}}{%
\addtocounter{talenty}{1}%
\setcounter{talentx}{1}%
}{}
\ifthenelse{\equal{#3}{true}}{%
\definecolor{talentcolor}{HTML}{5f1111}
}{%
\definecolor{talentcolor}{HTML}{1e115f}
}
\node[text=white,text width = 2.6cm] at ($(\arabic{talentx}*4.5,-\arabic{talenty}*4.9) + (0.5,-0.15)$) (tmp\alph{talentx}\alph{talenty}) {\footnotesize \texttn{\uppercase{#1}}};
\getnodedimen{tmp\alph{talentx}\alph{talenty}}
\node[talent] at (\arabic{talentx}*4.5,-\arabic{talenty}*4.9)
(\alph{talentx}\alph{talenty})
{
\settowidth{\textlength}{\footnotesize \texttn{{\uppercase{#1}}}}%
\tabular{p{3cm}}
\rule{0pt}{13pt}\\
\ifdim\nodeheight > 15pt
\rule{0pt}{8pt} \\
\fi
\ifdim\nodeheight > 30pt
\rule{0pt}{8pt} \\
\fi
\scriptsize #2 \\
\endtabular
};
\ifthenelse{\equal{#5}{true}}{%
\node[ranked] at ($(\arabic{talentx}*4.5,-\arabic{talenty}*4.9) + (0.08,-0.08)$) {%
\small \hspace*{-6pt} \checkbox %
\settowidth{\textlength}{\footnotesize \texttn{{\uppercase{#1}}}}%
\ifdim\nodeheight > 15pt
\\ \phantom{t}
\fi
\ifdim\nodeheight > 30pt
\\ \phantom{t}
\fi
};
}{}
\ifthenelse{\equal{#4}{true}}{%
\setforce{}
\node[forcepower] at ($(\arabic{talentx}*4.5,-\arabic{talenty}*4.9) + (0.3,-0.5)$) {};
}{}
\node[talentname] at ($(\arabic{talentx}*4.5,-\arabic{talenty}*4.9) + (0.13,-0.14)$) {%
\small \hspace*{-6pt} \checkbox %
\settowidth{\textlength}{\footnotesize \texttn{{\uppercase{#1}}}}%
\ifdim\nodeheight > 15pt
\\ \phantom{t}
\fi
\ifdim\nodeheight > 30pt
\\ \phantom{t}
\fi
};
\node[cost] {\tiny\texttn{COST \fpeval{5*\arabic{talenty}}}};
\node[text=white,text width = 2.6cm] at ($(\arabic{talentx}*4.5,-\arabic{talenty}*4.9) + (0.5,-0.19)$) (t\alph{talentx}\alph{talenty}) {\footnotesize \texttn{\uppercase{#1}}};
}
\newenvironment{talenttree}[5]{%
\setcounter{talentx}{0}
\setcounter{talenty}{1}
\def\specialization{#1}
\center
\def\bookandpage{#3}
\tabular{p{0.75\textwidth} p{0.15\textwidth}}
\texttn{\Huge{}\career{}:} \textltn{\Huge{}\specialization} & \multirow{4}{*}[0.7cm]{%
\begin{tikzpicture}
\drawforce
\definecolor{talentcolor}{HTML}{000000}
\node[ranked,minimum width = 3.33cm] at (-0.05, -1.34) {\footnotesize{}\texttn{RANKED TALENT}};
\node[talentname] at (0,-1.4) {\footnotesize{}\texttn{RANKED TALENT}};
\definecolor{talentcolor}{HTML}{5f1111}
\node[talentname] at (0,-0.7) {\footnotesize{}\texttn{ACTIVE}};
\definecolor{talentcolor}{HTML}{1e115f}
\node[talentname] at (0,0) {\footnotesize{}\texttn{PASSIVE}};
\end{tikzpicture}
}\\
\ifthenelse{\equal{\careerskills}{}}{
\ifthenelse{\equal{#4}{}}{}{%
\texttn{\footnotesize{}Gain Force Rating #4} \\
}
}{
\texttn{\footnotesize{}Career Skills:} \textltn{\footnotesize{}\careerskills}\\
}
\ifthenelse{\equal{#2}{}}{}{
\texttn{\footnotesize{}Additional Carreer Skills:} \textltn{\footnotesize{}#2}\\
}
\ifthenelse{\equal{#5}{}}{}{%
\texttn{\footnotesize{}Prerequisite: Force Rating #5} \\
}
\endtabular\\
\vspace*{20pt}
\ifthenelse{\equal{\careerskills}{}}{
\vspace{5pt}
\ifthenelse{\equal{#4}{}}{
\vspace{10pt}
}{}
}{}
\tikzpicture
}{%
\endtikzpicture
\vfill
{\ltn\small \bookandpage}
\endcenter
\newpage
}
\newcommand{\talentlines}[2]{
\StrDel{#1}{ }[\tmpvert]
\StrDel{\tmpvert}{/}[\tmpvert]
\setcounter{tmpx}{0}
\setcounter{tmpy}{1}
\setcounter{tmpyp}{2}
\forloop{tmpchar}{1}{\value{tmpchar} < 17}{
\addtocounter{tmpx}{1}%
\ifthenelse{\equal{\arabic{tmpx}}{5}}{%
\addtocounter{tmpyp}{1}%
\addtocounter{tmpy}{1}%
\setcounter{tmpx}{1}%
}{}
\StrChar{\tmpvert}{\value{tmpchar}}[\tmpchar]
\ifthenelse{\equal{\tmpchar}{|}}{
\talentline{\alph{tmpx}\alph{tmpy}}{\alph{tmpx}\alph{tmpyp}}
}{}
}
\StrDel{#2}{ }[\tmphor]
\StrDel{\tmphor}{/}[\tmphor]
\setcounter{tmpx}{0}
\setcounter{tmpxp}{1}
\setcounter{tmpy}{2}
\forloop{tmpchar}{1}{\value{tmpchar} < 13}{
\addtocounter{tmpx}{1}%
\addtocounter{tmpxp}{1}%
\ifthenelse{\equal{\arabic{tmpx}}{4}}{%
\addtocounter{tmpy}{1}%
\setcounter{tmpx}{1}%
\setcounter{tmpxp}{2}%
}{}
\StrChar{\tmphor}{\value{tmpchar}}[\tmpchar]
\ifthenelse{\equal{\tmpchar}{-}}{
\talentline{\alph{tmpx}\alph{tmpy}}{\alph{tmpxp}\alph{tmpy}}
}{}
}
}