%%  Based on sides package Copyright (c) 2005 Wing L. Mui
%%    This class package was based on the package ``plari'' written by
%%    Antti-Juhani Kaijanaho in 1998.

%%    This program is free software; you can redistribute it and/or modify
%%    it under the terms of the GNU General Public License as published by
%%    the Free Software Foundation; either version 2 of the License, or
%%    (at your option) any later version.
%%
%%    This program is distributed in the hope that it will be useful,
%%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%%    GNU General Public License for more details.
%%
%%    You should have received a copy of the GNU General Public License
%%    along with this program; see the file COPYING.  If not, write to
%%    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
%%    Boston, MA 02111-1307, USA.

\def\filedate{2005/04/21}
\def\fileversion{20050421-CTAN}

\NeedsTeXFormat{LaTeX2e}
\typeout{plari_prime <\filedate:\fileversion> - typesetting stageplay scripts}

\newif\if@Fullpage
\@Fullpagetrue

\DeclareOption{nofullpage}{\global\@Fullpagefalse}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{extreport}}
\ProcessOptions

% We will be basing this class on the report class.

\LoadClass{report}

% Now we initialize the counters.
\newcounter{act}
\newcounter{scene}[act]
\renewcommand{\theact}{\Roman{act}}
\renewcommand{\thescene}{\Roman{act}:\arabic{scene}}

% The newact commands create new pages and a huge heading.
% Change the vspace parameters if you want to change the spacing after
% an act title.
\newcommand{\actdef}[1]{
	\newpage{\centering \mdseries \Huge #1\par}
	\vspace{1.5em plus .5em minus .5em}%
}

\newcommand{\newact}{
	\refstepcounter{act}
	\actdef{\MakeUppercase{Акт} \Roman{act}}
}
\newcommand{\newactnamed}[1]{
  \actdef{#1}
}

% We are going to make each scene a section so scenes do not
% get orphaned from their tltles.
% To modify spacing before and after scene titles, modify this:
\newcommand{\scenedef}{\@startsection {scene}{1}{0pt}%
                                   {3em} % space before title
                                   {2em} % space after title
                                   {\centering\mdseries\Large}}

% These are the new scene commands.
\newcommand{\newscene}{
	\refstepcounter{scene}
	{\scenedef*{\MakeUppercase{Сцена} \arabic{scene}}}
}  

\newcommand{\newscenenamed}[1]{%
	\refstepcounter{scene}
  {\scenedef*{\MakeUppercase{#1}}}
  }

\newcommand{\newscenenamednocnt}[1]{%
  {\scenedef*{\MakeUppercase{#1}}}
  }

% Similarly, we use sections for the dialogue to avoid orphans.
% Once again, if you wish to change the skip amounts, do so here.
\newcommand{\repldef}{
	\@startsection {diag}{2}{0pt}{1em}{0.25pt}{\centering\normalsize\mdseries\scshape}
}
\newcommand{\repl}{\repldef*}

% Now for something simple...
\newcommand{\paren}[1]{(\textit{#1})}
\newcommand{\pause}{\paren{Пауза.} }
\newcommand{\chara}[1]{\textsc{#1}}

% And now some stage directions...
\newcommand{\stagedir}[1]{%
  \begingroup%
    \list{}{%
      \listparindent=\parindent%
      \parsep=\parskip%
      \topsep=\z@%
      \rightmargin=\leftmargin%
      }%
    \item%
    \let\item\@undefined%
    {\vspace{1em}\normalsize \scshape \mdseries#1\vspace{1ex}}%
    \endlist%
  \endgroup%
  }
  
% Now comes the cast list and stage notes...
\newcommand{\castpage}{\newscenenamednocnt{\MakeUppercase{Действующие лица}}}
\newcommand{\notes}{
	\newscenenamed{Примечания}
	\setlength{\parindent}{2em}
}

\newcommand{\cast}[2]{
	\textsc{#1}, #2. \par
}

\newcounter{note}
\newcommand{\newnote}[1]{
	\refstepcounter{scene}
	\@startsection {scene}{1}{0pt}{1em}{1em}{\centering\mdseries\normalsize}*{#1}
}

\newenvironment{authortext}{\setlength{\parindent}{2em}}{\setlength{\parindent}{0em}}

% We also want there to be no indents and a medskip between long paragraphs
% of text. If you do not want there to be a skip, comment out the second line.
\setlength{\parindent}{0in} 
\parskip=\medskipamount\relax

% Now we make our formatting pretty. These options can be overrided easily.
\evensidemargin 0in
\topmargin 0in
\textheight 8.5in
\baselineskip 14pt
\oddsidemargin 0.25in
\textwidth 6in

% And we're done!

\RequirePackage{fontspec}
\RequirePackage{xunicode}
\RequirePackage{xltxtra}
\RequirePackage{polyglossia}
\setdefaultlanguage{russian}
\defaultfontfeatures{Mapping=tex-text, Scale=MatchLowercase}
\setmainfont{PT Serif}
\setmonofont{PT Mono}
\setmathrm{PT Serif}
\newfontfamily{\cyrillicfont}{PT Serif}
\newfontinstance\scshape[Letters=SmallCaps, Numbers=Uppercase]{PT Serif Caption}
\RequirePackage{hyperref}
\RequirePackage{indentfirst}

\if@Fullpage
  \RequirePackage[cm]{fullpage}
\fi
\pagestyle{empty}
\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{2}
\author{Александр Яковлев}
\endinput
