\ProvidesPackage{mechanics-packet}
%
% This package is not meant to be used directly by .tex files; it provides
% a base package for some particularly common styles of mechanics packets
% on top of which specific ones may be defined.  (The base Template uses
% it for memory.sty and ingestible.sty.)
%
% This is not a cards package, nor do you want to use both this and cards
% in the same package.  It's a different general format.
%
% We do not anticipate that you'll want to edit this package much.
% However, specific packages that use this may want to themselves
% redefine margins and other dimensions used here.
%
%% \mechanic@envelope{first header}{second header}{content}
% produces two boxes.  The first has only the header lines on it
% and is suitable for taping to the outside of an envelope.
% The second repeats the headers (so that you don't get sets of boxes
% mixed up after cutting them out) and also includes the content.
% For consistency, we recommend that macros wrapped around this one
% be called \(something)packet.  
%
%% \mechanic@folded{outside header}{outside description}{inside description}
% produces a single box with dotted lines and instructions on it which
% should make it appallingly obvious how it gets put together; after
% that is done, the outside header and outside description are the only 
% parts visible.  Only the inside description is put inside; we don't
% automatically repeat any outside stuff since there aren't multiple
% parts here to get separated.  (Of course a more specific style can
% do some duplication --- memory packets put the trigger both outside
% and inside.)
% For consistency, we recommend that macros wrapped around this one
% be called \(something)fold.
%
% For examples please see the base Template memory.sty (\mempacket, \memfold)
% and ingestible.sty (\ingestpacket, \ingestfold).
%
% If you find yourself wanting to do serious fiddling with the formatting,
% you probably want to copy this to mypacket.sty and edit that.


% Styles that use this should \RequirePackage{extractable} or not as they wish.
\RequirePackage{graphicx}

\special{header=simplex}  % duplex'ing mechanics packets by accident sucks...

% page layout, should interact OK with \geometry frobbing by other styles
\geometry{margin=.75in}
\geometry{headsep=0pt}

% other spacing
\topskip=0pt
\parindent=0pt

\newbox\inner@box
\newbox\outer@box


% Envelope-style macro.
%
% Since we don't need to do arithmetic on these widths, we make them 
% macros rather than \newdimen's to avoid using those up.
\def\outer@envelope{1.7in}
\def\inner@envelope{6.0in}
%
\newdef\mechanic@envelope[3]{%
  \def\mechanic@header{#1\par#2}%
  \setbox\outer@box=\vbox{\hsize=\outer@envelope \mechanic@header}%
  \setbox\inner@box=\vbox{\hsize=\inner@envelope \mechanic@header\par #3}%
  \begingroup
    \lineskip=0pt
    \lineskiplimit=12in
    \vbox{\fbox{\box\outer@box}\break\fbox{\box\inner@box}}%
  \endgroup
}



% Now the fold-and-staple-style macro.  The output should make
% it obvious how it goes together.
%
\newdimen\white@space	\white@space 25pt
\newdimen\part@width	\part@width 3.5in
\newdimen\tot@ht
\newdimen\temp@dim
\newdef\mechanic@folded[3]{%
  \setbox\inner@box=\vtop{\hsize=\part@width
    \leftskip \white@space
    \rightskip \white@space
    \vskip\white@space
    {\small \gamename\hfill\gamedate}%
    \vskip\baselineskip
    #3\relax
    \vskip\white@space
  }%
  \setbox\outer@box=\vtop{\hsize=.5\part@width
    \leftskip 1em plus1fil
    \rightskip 1em plus1fil
    \vskip\white@space
    #1\leavevmode\par
    \hfill\smash{\rotatebox{90}{\scriptsize staple here}}%
    \break
    #2\relax
    \vskip\baselineskip
  }%
  \tot@ht=\ht\inner@box \advance\tot@ht by \dp\inner@box
  \temp@dim=\ht\outer@box \advance\temp@dim by \dp\outer@box 
  \ifdim2\temp@dim>\tot@ht \tot@ht=2\temp@dim \fi
  \begingroup
    \fboxsep 0pt
    \lineskip=0pt \lineskiplimit=12in
    \fbox{%
      \vtop to \tot@ht{\unvbox\inner@box\vfill}%
      \vtop to \tot@ht{\leaders\hbox{.\strut}\vfil}%
      \hskip -\baselineskip
      \rotatebox{90}{\hskip-.5\tot@ht \emph{FIRST FOLD}}%
      \vtop to \tot@ht{\hsize=\part@width
        \hbox to \hsize{%
          \hbox to .5\hsize{%
            \hfil \rotatebox{-90}{\hskip+.5\tot@ht \llap{\emph{THIRD FOLD}}}%
          }%
          \vtop to .5\tot@ht{\leaders\hbox{.\strut}\vfil}%
          \vtop to .5\tot@ht{\unvbox\outer@box}%
        }%
        \hbox to \hsize{\leaders\hbox{.}\hfill}%
        \hfil \emph{SECOND FOLD}%
        \vfill
      }%
    }\par
  \endgroup
}

\vfuzz=10in      % shut up about overfull \vbox's!
\vbadness=10000  % and underfull ones
\hfuzz=10in      % and overfull \hbox's
\hbadness=10000  % and underfull ones
