% Copyright note: This package define a formation title
\ProvidesPackage{formationTitle}[2019/10/01 v.0.4.0 a formation title
Gregory Trolliet]

\RequirePackage[a4paper, landscape]{geometry}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage{enumerate}
\RequirePackage{numprint}
\RequirePackage{graphicx}

\RequirePackage[pdfusetitle]{hyperref}

\RequirePackage[dvipsnames,table]{xcolor}

\definecolor{light-gray}{HTML}{CCCCCC}

\newcommand{\groupTitle}[1]{
	\pause
	&%
	\multicolumn{6}{l}{#1}
}

\newcommand{\dumblang}[2]{{#1}}

\DeclareOption{english}{
	\renewcommand{\dumblang}[2]{#1}
}

\DeclareOption{french}{
	\renewcommand{\dumblang}[2]{#2}
}

\ExecuteOptions{english}
\ProcessOptions\relax

%Set the actual language, #1 for english and #2 for french
\RequirePackage[\dumblang{english}{french}]{babel}

\RequirePackage{graphicx}
\RequirePackage{booktabs}

\RequirePackage{array}
\RequirePackage{longtable}
\RequirePackage{makecell}

\newcommand*{\logo}[1]{\gdef\@logo{#1}%
}
\newcommand*{\@logo}{logo.pdf}
\newcommand*{\context}[1]{\gdef\@context{#1}%
}
\newcommand*{\@context}{\texttt{\string\context} currently
not set, please fix this.}
\title{Workshop plan}
\newcommand*{\subject}[1]{\gdef\@subject{#1}%
}
\newcommand*{\@subject}{Workshop}
\newcommand*{\subtopic}[1]{\gdef\@subtopic{#1}%
}
\newcommand*{\supervisor}[1]{\gdef\@supervisor{#1}%
}
%\newcommand*{\@supervisor}{\texttt{\string\supervisor} currently
%not set, please fix this.}

\newcommand*{\place}[1]{\gdef\@place{#1}%
}
\newcommand*{\room}[1]{\gdef\@room{#1}%
}

\newcommand*{\license}[1]{\gdef\@license{#1}%
}

\newcounter{PartCounter}

\newcommand\partCount{%
	\midrule 
	\stepcounter{PartCounter}%
	\arabic{PartCounter}%
}

\newcommand\partCountNoRule{%
	\stepcounter{PartCounter}%
	\arabic{PartCounter}%
}

\newcommand{\pause}[2]{%
	\midrule 
	\rowcolor{light-gray}%
	\stepcounter{PartCounter}%
	\arabic{PartCounter}%
	& \partDuration{#1}
	& \multicolumn{5}{c}{#2} \\
}

\newcommand{\newDay}[3]{%
	\midrule 
	\rowcolor{light-gray}%
	\stepcounter{PartCounter}%
	\arabic{PartCounter}%
	& \printTime
	& \multicolumn{5}{c}{#3} \startTime{#1}{#2}\\
}

\newcounter{HourCounter}
\newcounter{MinuteCounter}

\newcommand{\startTime}[2]{%
	\setcounter{HourCounter}{#1}%
	\setcounter{MinuteCounter}{#2}%
}

\newcommand*{\printTime}{%
	\ifnum\value{HourCounter}<10%
		{}0%
	\fi%
	\arabic{HourCounter}h%
	\ifnum\value{MinuteCounter}<10%
		{}0%
	\fi%
	\arabic{MinuteCounter}%
}

\newcommand*{\partDuration}[1]{
	\printTime{} (#1')%
	\addtocounter{MinuteCounter}{#1}
	\ifnum\value{MinuteCounter}>59
		\stepcounter{HourCounter}
		\addtocounter{MinuteCounter}{-60}
	\fi
}

\newcommand*{\messagesTitle}[1]{\gdef\@messagesTitle{\textbf{#1}}%
}
\newcommand*{\@messagesTitle}{\textbf{Messages}}
\newcommand*{\messages}[1]{\gdef\@messages{#1}%
}
\newcommand*{\@messages}{
\begin{enumerate}
\item Messages 1
\item Messages 2
\item Messages 3
\end{enumerate}}
\newcommand*{\objectivesTitle}[1]{\gdef\@objectivesTitle{\textbf{#1}}%
}
\newcommand*{\@objectivesTitle}{\textbf{\dumblang{Objectives}{Objectifs}}}
\newcommand*{\objectives}[1]{\gdef\@objectives{#1}%
}
\newcommand*{\@objectives}{
\begin{enumerate}
\item Objective 1
\item Objective 2
\item Objective 3
\end{enumerate}}

\usepackage{contour}
\usepackage{ulem}

\renewcommand{\ULdepth}{1.8pt}
\contourlength{0.8pt}

\newcommand{\myul}[1]{%
	\uline{\phantom{#1}}%
	\llap{\contour{white}{#1}}%
}

%%%%%%%%%%%%%%%%%%%%%%%% TITLE PAGE
\renewcommand*{\maketitle}{%
\begin{titlepage}
{\raggedleft%
	\includegraphics[width=2cm]{\@logo}\par
}
\vspace{-1.25cm}
\centering
{\scshape\Large\@context\unskip\strut\par}
\vspace{1cm}
{\huge\bfseries\@title\unskip\strut\par}
\vspace{1cm}
{\scshape\Large\@subject\unskip\strut\par}
\ifx\@subtopic\undefined
\else
{\itshape\@subtopic\unskip\strut\par}
\fi
\vspace{1cm}
{\Large\itshape\@author\unskip\strut\par}
\vspace{1cm}

\begin{tabular}{p{.5\textwidth}|p{.5\textwidth}}
\toprule
& \\
\@objectivesTitle\unskip\strut\par & \@messagesTitle\unskip\strut\par \\
\@objectives\unskip\strut\par & \@messages\unskip\strut\par \\
\bottomrule
\end{tabular}
\vfill


\ifx\@supervisor\undefined
\else
{
\dumblang{supervised by}{supervisé par}\par
\@supervisor\unskip\strut\par}
\vfill
\fi

{\large \@date}
	\ifnum\value{HourCounter}=0
\else
{
\large\itshape\printTime\unskip\strut}
\fi
\ifx\@place\undefined
\else
{\par
\@place\unskip\strut}
\ifx\@room\undefined
\else
{
\itshape\@room\unskip\strut}
\fi
\fi

\ifx\@license\undefined
\else
{\raggedleft%
	\vspace{-1cm}\includegraphics[width=2cm]{\@license}\par
}
\fi
\end{titlepage}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%% STEP TABLE
\newcommand{\steptable}[1]
{
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength{\heavyrulewidth}{0.2em}
\begin{longtable}{p{0.01\textwidth}p{0.035\textwidth}|p{.09\textwidth}p{.15\textwidth}p{.26\textwidth}p{.21\textwidth}p{.13\textwidth}}
\makecell[l]{
	\textbf{N\ensuremath{^\circ}}
} &
\makecell[l]{
	\textbf{\dumblang{Hour}{Heure}} \\
	(\dumblang{Time}{Durée})
} &
\makecell[l]{
	\textbf{\dumblang{Theme}{Thème}} \\
	(\dumblang{What}{Quoi}?)
} &
\makecell[l]{
	\textbf{\dumblang{Learning goals}{Objectifs pédagogiques}} \\
	{ }
} &
\makecell[l]{
	\textbf{\dumblang{Process}{Processus / Modalités}} \\
	(\dumblang{Instructions, procedure}{Consignes, déroulement})
} &
\makecell[l]{
	\textbf{\dumblang{Content}{Contenu}} \\
	(\dumblang{Elements, references}{Éléments, références})
} &
\makecell[l]{
	\textbf{\dumblang{Methods}{Moyens}} \\
	(\dumblang{With what}{Avec quoi}?)
}\\
\toprule
\endhead
#1
\end{longtable}
}
\endinput
