%!TEX TS-program = pdflatexmk

% Copyright 2019 Martin Scheidt (Attribution 4.0 International, CC-BY 4.0)
% You are free to copy and redistribute the material in any medium or format. You are free to remix, transform, and build upon the material for any purpose, even commercially. You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. No warranties are given.

\documentclass{beamer}
\usepackage[
  size=a4,
]{beamerposter}
\beamertemplatenavigationsymbolsempty

\def\ROOT{./..}

\input{\ROOT/src/material_header.tex}
\input{\ROOT/src/colors.tex}
\input{\ROOT/src/signal_aspects.tikz}

\newlength{\trainlength}\setlength{\trainlength}{12cm}
\newlength{\trainheight}\setlength{\trainheight}{3cm}
\newlength{\trainwidth}\setlength{\trainwidth}{4cm}

\tikzset{
  lever_positions/.pic={
    % arrows
    \draw[->,>=latex,line width=1.5pt,green] ( 1.5,0)  .. controls ( 2,-0.5) and ( 3,-0.5) .. ( 3.5,0);
    \draw[->,>=latex,line width=1.5pt,green] ( 1.0,0)  .. controls ( 2,-1.0) and ( 6,-1.0) .. ( 7.0,0);
    \draw[->,>=latex,line width=1.5pt,green] ( 4.5,0)  .. controls ( 5,-0.5) and ( 6,-0.5) .. ( 6.5,0);
    \draw[->,>=latex,line width=1.5pt,green] ( 7.5,0)  .. controls ( 8,-0.5) and ( 9,-0.5) .. ( 9.5,0);
    \draw[->,>=latex,line width=1.5pt,green] (10.5,0)  .. controls (11,-0.5) and (12,-0.5) .. (12.5,0);
    %
    \draw[<-,>=latex,line width=1.5pt,green] ( 1.5,2)  .. controls ( 2,2.5) and ( 3,2.5) .. ( 3.5,2);
    \draw[<-,>=latex,line width=1.5pt,green] ( 4.5,2)  .. controls ( 5,2.5) and ( 6,2.5) .. ( 6.5,2);
    \draw[<-,>=latex,line width=1.5pt,green] ( 7.5,2)  .. controls ( 8,2.5) and ( 9,2.5) .. ( 9.5,2);
    \draw[<-,>=latex,line width=1.5pt,green] (10.5,2)  .. controls (11,2.5) and (12,2.5) .. (12.5,2);
    % lever positiions
    \foreach \x in {0,3,6,9,12}
      \draw [fill=white] (\x,0) rectangle ++(2,2);
    % labels
    \node[align=center] at ( 1,1.6) {\si{\kilo\metre\per\hour}};
    \node[align=center] at ( 1,1  ) {\Huge $0$};
    \node[align=center] at ( 1,0.3) {\Large \color{blue} $0$
      \IfLanguage{english}{fields}
      \IfLanguage{ngerman}{Felder}
    };
    \node[align=center] at ( 4,1.6) {\si{\kilo\metre\per\hour}};
    \node[align=center] at ( 4,1  ) {\Huge $40$};
    \node[align=center] at ( 4,0.3) {\Large \color{blue} $1$
      \IfLanguage{english}{field}
      \IfLanguage{ngerman}{Feld}
    };
    \node[align=center] at ( 7,1.6) {\si{\kilo\metre\per\hour}};
    \node[align=center] at ( 7,1  ) {\Huge $80$};
    \node[align=center] at ( 7,0.3) {\Large \color{blue} $2$
      \IfLanguage{english}{fields}
      \IfLanguage{ngerman}{Felder}
    };
    \node[align=center] at (10,1.6) {\si{\kilo\metre\per\hour}};
    \node[align=center] at (10,1  ) {\Huge $120$};
    \node[align=center] at (10,0.3) {\Large \color{blue} $3$
      \IfLanguage{english}{fields}
      \IfLanguage{ngerman}{Felder}
    };
    \node[align=center] at (13,1.6) {\si{\kilo\metre\per\hour}};
    \node[align=center] at (13,1  ) {\Huge $160$};
    \node[align=center] at (13,0.3) {\Large \color{blue} $4$
      \IfLanguage{english}{fields}
      \IfLanguage{ngerman}{Felder}
    };
  };
}

\begin{document}
  \selectlanguage{ngerman} % currently supported: english, ngerman
  \tikzset{every path/.style={ultra thick}}
  \begin{frame}
    \begin{tikzpicture}[font=\sffamily]
      \coordinate (base) at (0,0);
      % coordinates
      \path ([shift={(base)}] 0,0) coordinate (A3)
            -- ++(0,-\trainheight) coordinate (A4)
            -- ++(\trainlength, 0) coordinate (A1)
            -- ++(0, \trainheight) coordinate (A2);
      \path (A2) -- ++ ( 1,-1) coordinate (A5);
      \path (A1) -- ++ ( 1, 1) coordinate (A6);
      \path ([shift={(base)}] 0,0) coordinate (B3)
            -- ++(0, \trainwidth)  coordinate (B4)
            -- ++(-\trainheight,0) coordinate (B7)
            -- ++(0,-\trainwidth)  coordinate (B8);
      \path (B4) -- ++ (-1, 1) coordinate (B5);
      \path (B7) -- ++ ( 1, 1) coordinate (B6);
      \path (B8) -- ++ ( 1,-1) coordinate (B1);
      \path (B3) -- ++ (-1,-1) coordinate (B2);
      \path ([shift={(base)}] 0,0) coordinate (C3)
            -- ++(0, \trainwidth)  coordinate (C4)
            -- ++(\trainlength, 0) coordinate (C1)
            -- ++( 0.375\trainwidth,-0.5\trainwidth) coordinate (C5)
            -- ++(-0.375\trainwidth,-0.5\trainwidth) coordinate (C2);
      \path (C4)                    coordinate (D4)
            -- ++(0, \trainheight)  coordinate (D3)
            -- ++(\trainlength, 0)  coordinate (D2)
            -- ++(0,-\trainheight)  coordinate (D1);
      \path (D1)                    coordinate (E1)
            -- ++(0, \trainheight)  coordinate (E2)
            -- ++(0.625\trainwidth, 0) coordinate (E3)
            -- ++(0,-\trainheight)  coordinate (E4)
            -- ++(-1,-1)       coordinate (E5);
      \path (E1) -- ++ ( 1,-1) coordinate (E6);
      \path (E4)                    coordinate (F4)
            -- ++(0, \trainheight)  coordinate (F3)
            -- ++(0.625\trainwidth, 0) coordinate (F2)
            -- ++(0,-\trainheight)  coordinate (F1)
            -- ++(-1,-1)       coordinate (F6);
      \path (F4) -- ++ ( 1,-1) coordinate (F5);
      % drawing
      \draw (A2) rectangle (A4);
      \draw (B4) rectangle (B8);
      \draw (C2) -- (C3) -- (C4) -- (C1) -- (C5) -- cycle;
      \draw (D1) rectangle (D3);
      \draw (E2) rectangle (E4);
      \draw (F2) rectangle (F4);
      % labels
      \pic[scale=0.75] at (0.1\trainlength,0.35\trainwidth) {lever_positions};
      \pic at (-0.5\trainheight,0.5\trainwidth) {end_of_train};
      % adhesive edge
      \tikzset{every path/.style={thin,base1}}
      \draw (A2) -- (A5) -- (A6) -- (A1);
      \draw (B4) -- (B5) -- (B6) -- (B7);
      \draw (B8) -- (B1) -- (B2) -- (B3);
      \draw (E1) -- (E6) -- (E5) -- (E4);
      \draw (F1) -- (F6) -- (F5) -- (F4);
      %
    \end{tikzpicture}
    \input{\ROOT/frontmatter/copyright.tex}
  \end{frame}
  \begin{frame}
    \IfLanguage{english}{\Huge \textcolor{blue}{Control Lever:}}
    \IfLanguage{ngerman}{\Huge \textcolor{blue}{Schalthebelpositionen:}}\\
    \begin{tikzpicture}[font=\sffamily]
      \begin{scope}[scale=1.5,transform shape]
        \pic at (0,0) {lever_positions};
      \end{scope}
    \end{tikzpicture}
    \vfill
    \input{\ROOT/src/game_procedure.tex}
  \end{frame}
\end{document}