Files
Star-Wars-ffg/star-wars-formatting.sty
2023-01-23 13:48:53 +01:00

280 lines
7.2 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}
\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}
\makeatother
\newlength{\textlength}
\pagestyle{empty}
\def\career{}
\def\careerskills{}
\newcommand{\setcareer}[2]{%
\def\career{#1}%
\def\careerskills{#2}%
}
%%%%
% Provide the command \fpeval as a copy of the code-level \fp_eval:n.
\usepackage{expl3}[2012-07-08]
\ExplSyntaxOn
\cs_new_eq:NN \fpeval \fp_eval:n
\ExplSyntaxOff
%%%%
\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=1pt
},
talentname/.style={
chamfered rectangle,
chamfered rectangle corners={north east, south east},
inner ysep=0pt,
text width = 2.85cm,
align=left,
text=white,
fill=talentcolor
},
talentnamedouble/.style={
chamfered rectangle,
chamfered rectangle corners={north east, south east},
inner ysep=0pt,
text width = 2.85cm,
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=150,
starburst point height=10pt,
fill=talentcolor,
draw=white,
line width=1.5pt,
minimum width=30pt,
minimum height=30pt,
rotate=155
}
}
\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}[4]{%
\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}{10pt}\\
\ifdim\nodeheight > 15pt
\rule{0pt}{8pt} \\
\fi
\ifdim\nodeheight > 30pt
\rule{0pt}{8pt} \\
\fi
\scriptsize #2 \\
\endtabular
};
\ifthenelse{\equal{#4}{true}}{%
\node[forcepower] at ($(\arabic{talentx}*4.5,-\arabic{talenty}*4.9) + (0.3,-0.6)$) {};
}{}
\node[talentname] at ($(\arabic{talentx}*4.5,-\arabic{talenty}*4.9) + (0.1,-0.1)$) {%
\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.15)$) (t\alph{talentx}\alph{talenty}) {\footnotesize \texttn{\uppercase{#1}}};
}
\newenvironment{talenttree}[5]{%
\setcounter{talentx}{0}
\setcounter{talenty}{1}
\center
\def\bookandpage{#3}
\tabular{p{0.75\textwidth} p{0.15\textwidth}}
\texttn{\Huge{}\career{}:} \textltn{\Huge{}#1} & \multirow{4}*{
\begin{tikzpicture}
% \ifthenelse{\equal{#4}{}}{}{%
\definecolor{talentcolor}{HTML}{000000}
\node[forcepower] at (0.2,-2.1) {};
\node[talentname] at (0,-1.6) {\footnotesize{}\texttn{FORCE TALENT}};
% }
\definecolor{talentcolor}{HTML}{1e115f}
\node[talentname] at (0,0) {\footnotesize{}\texttn{PASSIVE}};
\definecolor{talentcolor}{HTML}{5f1111}
\node[talentname] at (0,-0.8) {\footnotesize{}\texttn{ACTIVE}};
\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}}
}{}
}
}