diff options
Diffstat (limited to 'macros/latex/contrib/wargame/source/chit')
-rw-r--r-- | macros/latex/contrib/wargame/source/chit/battle.dtx | 2 | ||||
-rw-r--r-- | macros/latex/contrib/wargame/source/chit/misc.dtx | 52 | ||||
-rw-r--r-- | macros/latex/contrib/wargame/source/chit/modifiers.dtx | 2 | ||||
-rw-r--r-- | macros/latex/contrib/wargame/source/chit/oob.dtx | 197 | ||||
-rw-r--r-- | macros/latex/contrib/wargame/source/chit/shape.dtx | 13 | ||||
-rw-r--r-- | macros/latex/contrib/wargame/source/chit/table.dtx | 58 |
6 files changed, 306 insertions, 18 deletions
diff --git a/macros/latex/contrib/wargame/source/chit/battle.dtx b/macros/latex/contrib/wargame/source/chit/battle.dtx index 5057d620a5..381f4e4aba 100644 --- a/macros/latex/contrib/wargame/source/chit/battle.dtx +++ b/macros/latex/contrib/wargame/source/chit/battle.dtx @@ -41,7 +41,7 @@ minimum size=8mm, draw=black, fill=#2, - every odds marker/.try] at (.2,-.2) {#1}; + every odds marker/.try] at (.16,-.16) {#1}; } }, odds marker/.style args={#1,#2}{ diff --git a/macros/latex/contrib/wargame/source/chit/misc.dtx b/macros/latex/contrib/wargame/source/chit/misc.dtx index a5b9a79b24..e5d4b4b708 100644 --- a/macros/latex/contrib/wargame/source/chit/misc.dtx +++ b/macros/latex/contrib/wargame/source/chit/misc.dtx @@ -4,6 +4,58 @@ % \fi % \subsubsection{Some utilities} % +% This style allows us to add a fading drop-shadow to chits. +% +% \begin{macrocode} +\usetikzlibrary{shadows.blur} +\newif\ifwg@chit@drop\wg@chit@dropfalse +\tikzset{ + chit has drop/.is if=wg@chit@drop, + chit has drop/.default=true, + chit has drop/.initial=false, + /tikz/render blur shadow/.add code={% + \chit@dbg{2}{Number of blur steps: \pgfbs@steps}% + \ifnum\pgfbs@steps=0\else + \chit@dbg{2}{Making shadow blur}% + }{\fi}} +\tikzset{% + chit drop/.code={% + %% \message{^^J Args `#1'}% + \pgfkeysalso{% + chit has drop=true, + /tikz/blur shadow={shadow blur steps=5, + shadow opacity=25, + shadow xshift=.05cm, + shadow yshift=-.05cm, + shadow blur radius=.05cm, + #1}}% + \ifnum\pgfbs@steps=0% + \gdef\wg@drop@margin{0pt}% + \else% + \ifwg@chit@drop% + \pgfmathparse{ + \pgfbs@radius+ + veclen( + \pgfkeysvalueof{/tikz/shadow xshift}, + \pgfkeysvalueof{/tikz/shadow yshift})} + \xdef\wg@drop@margin{\pgfmathresult pt}% + \else% + \gdef\wg@drop@margin{0pt}% + \fi + %% \message{^^J Drop margin is `\wg@drop@margin' + %% `\pgfbs@radius' + %% `\pgfkeysvalueof{/tikz/shadow xshift}', + %% `\pgfkeysvalueof{/tikz/shadow yshift}'}% + \fi% + },% + chit drop/.default=,% + no chit drop/.code={% + \pgfkeysalso{ + /tikz/blur shadow={shadow blur steps=0}} + \gdef\wg@drop@margin{0pt}% + } +}% +% \end{macrocode} % % Game turn marker % diff --git a/macros/latex/contrib/wargame/source/chit/modifiers.dtx b/macros/latex/contrib/wargame/source/chit/modifiers.dtx index b42ee5790f..f2f47ee3a8 100644 --- a/macros/latex/contrib/wargame/source/chit/modifiers.dtx +++ b/macros/latex/contrib/wargame/source/chit/modifiers.dtx @@ -14,7 +14,7 @@ code={% \path[fill=white,opacity=#1,pic actions] (-.6,-.6) rectangle(.6,.6);}}, pics/chit/eliminate/.style={ - code={% + code={% \path[fill=red,opacity=#1,pic actions] (-.6,-.6) rectangle(.6,.6);}}, pics/chit/shade/.default=0.5, pics/chit/eliminate/.default=0.25, diff --git a/macros/latex/contrib/wargame/source/chit/oob.dtx b/macros/latex/contrib/wargame/source/chit/oob.dtx index d640dadebf..9e5f0c4f93 100644 --- a/macros/latex/contrib/wargame/source/chit/oob.dtx +++ b/macros/latex/contrib/wargame/source/chit/oob.dtx @@ -37,8 +37,9 @@ \def\chit@oob@rowupdate(#1,#2)#3#4{% \chit@dbg{2}{ Row update c=`#1',r=`#2',s=`#3',e=`#4'} %\pgfmathparse{ifthenelse(#1>0,#2-#3,#2)}% - \pgfmathparse{#2-#3)}% + \pgfmathparse{#2-#3-#4}% \xdef#2{\pgfmathresult}% + \xdef#1{0}%\pgfmathresult}% %\xdef#1{0} \chit@dbg{2}{ \space\space-> update `\string#2'=#2} } @@ -71,6 +72,7 @@ % \begin{macrocode} \newif\ifwg@oob@inv\wg@oob@invfalse \def\chit@oob@spacer{hspace} +\def\chit@oob@vspacer{vspace} \def\wg@star@oob{\wg@oob@invtrue\wg@oob} \def\wg@nostar@oob{\wg@oob@invfalse\wg@oob} \def\oob{% @@ -91,6 +93,8 @@ % \begin{macrocode} \def\wg@oob#1#2#3#4{ \def\r{0} + \pgfmathparse{#3*(#2-1)}% + \edef\a{\pgfmathresult} \chit@dbg{2}{OOB: `#1'} \foreach[count=\ti from 0] \t/\y in #1{ \xdef\o{\r} @@ -109,20 +113,28 @@ \ifx\m\@empty\def\m{1}\fi \ifx\u\m\def\m{1}\fi \foreach \n in {1,...,\m}{% - \chit@dbg{2}{OOB Chit is `\u'}% + \chit@dbg{2}{OOB Chit is `\u' `\chit@oob@spacer'}% \ifx\u\chit@oob@spacer% \chit@dbg{3}{Chit `\u' is spacer `\chit@oob@spacer'} \pgfmathparse{\c+#4}% \xdef\c{\pgfmathresult}% - \else - \ifnum\chitdbglvl>2% - \node[minimum width=#3cm,minimum height=#3cm, - draw,transform shape] at (\c,\r) {}; + \else% + \ifx\u\chit@oob@vspacer% + \chit@dbg{3}{Chit `\u' is vspacer `\chit@oob@vspacer'} + \pgfmathparse{ifthenelse(abs(\c)<0.0001,0,#3)} + \xdef\ll{\pgfmathresult} + \chit@dbg{2}{\string\ll=`\ll'} + \chit@oob@rowupdate(\c,\r){\ll}{#4} + \else + \ifnum\chitdbglvl>2% + \node[minimum width=#3cm,minimum height=#3cm, + draw,transform shape] at (\c,\r) {}; + \fi + \ifx\u\chit@blank\else% + \chit[\u=\ti,zone oob point={\u}{\c}{\r}](\c,\r);% + \fi% + \chit@oob@cellupdate(\c,\r){#2}{#3}{\y} \fi - \ifx\u\chit@blank\else% - \chit[\u=\ti,zone oob point={\u}{\c}{\r}](\c,\r);% - \fi% - \chit@oob@cellupdate(\c,\r){#2}{#3}{\y} \fi } \fi @@ -153,7 +165,7 @@ % \chit@dbg{2}{ \space Breaking loop \rr\space > \y}% % \breakforeach% %\else% - \chit@oob@rowupdate(\c,\r){#3}{#4} + \chit@oob@rowupdate(\c,\r){#3}{0}% Extra spacing? %\fi } \fi @@ -166,6 +178,169 @@ \@ifnextchar;{\@gobble}{}} % \end{macrocode} % +% Horizontal flow OOB +% +% \begin{macrocode} +\def\wg@star@hoob{\wg@oob@invtrue\wg@hoob} +\def\wg@nostar@hoob{\wg@oob@invfalse\wg@hoob} +\def\hoob{% + \@ifstar{\wg@star@hoob% + }{\wg@nostar@hoob% + }% +} +% \end{macrocode} +% +% The inner macro of \cs{hoob}. The arguments are +% \begin{enumerate} +% \item The list of lists of chits styles +% \item The maximum number of columns +% \item The width of each cell +% \item Additional row spacing between turns +% \end{enumerate} +% +% \begin{macrocode} +\def\wg@hoob#1#2#3#4{ + \def\r{0} + \def\c{0} + \pgfmathparse{#3*(#2-1)}% + \edef\a{\pgfmathresult} + \chit@dbg{2}{OOB: `#1'} + \foreach[count=\ti from 0] \t/\y in #1{ + \xdef\o{\r} + % \def\c{0} + \ifx\t\y\def\y{0}\fi + \chit@dbg{2}{Turn \ti\space(\r,\t,y=\y):'} + \ifx\t\empty\else + % Count how many are left for this turn + \chit@dbg{2}{At start of turn \t\space\string\c=\c} + \def\l{\c}% + \let\ig\empty + \foreach \u/\m in \t{ + \ifx\ig\empty + \ifx\u\empty\else + \ifx\u\m\def\m{1}\fi + \ifx\u\chit@oob@spacer% + \pgfmathparse{\l+\m*#4}\xdef\l{\pgfmathresult} + \chit@dbg{2}{Got \m\space hspace (#4) -> \l} + \else + \ifx\u\chit@oob@vspace% + \xdef\ig{1} + \chit@dbg{2}{Got vspace -> \l (\ig)} + \else + \pgfmathparse{\l+\m*#3} + \xdef\l{\pgfmathresult} + \chit@dbg{2}{Got \m\space units -> \l} + \fi + \fi + \fi + \fi} + % Check if there's enough room + \chit@dbg{2}{To fill the rest of turn needs `\l' compared to + `\a' (#3*(#2-1))} + \pgfmathparse{ifthenelse(abs(\l)>=#3*(#2-1),0,1}% + \xdef\l{\pgfmathresult}% + \chit@dbg{2}{Break or not `\l'} + \ifnum\l=0\chit@oob@turnupdate(\c,\r){#3}{#4}\fi + \fi + \ifwg@oob@inv% + \pic[transform shape] at (\c+.5*#3,\r) {chit/oob turn=\ti};% was dx=0.5 + \else + \pic[transform shape] at (\c+-.5*#3,\r) {chit/oob turn=\ti};% was dx=-0.5 + \fi% + %\chit@oob@cellupdate(\c,\r){#2}{#3}{\y} + \ifx\t\empty\else% + \def\lv{0} + \foreach \u/\m in \t{ + %% \chit@dbg{2}{ `\u'=`\m'} + \ifx\u\empty\else + \ifx\m\@empty\def\m{1}\fi + \ifx\u\m\def\m{1}\fi + \foreach \n in {1,...,\m}{% + \chit@dbg{2}{OOB Chit is `\u' `\chit@oob@spacer'}% + \ifx\u\chit@oob@spacer% + \chit@dbg{3}{Chit `\u' is spacer `\chit@oob@spacer'} + \pgfmathparse{\c+#4}% + \xdef\c{\pgfmathresult}% + \else% + \ifx\u\chit@oob@vspacer% + \chit@dbg{3}{Chit `\u' is vspacer `\chit@oob@vspacer'} + \pgfmathparse{ifthenelse(abs(\c)<0.0001,0,#3)} + \xdef\ll{\pgfmathresult} + \chit@dbg{2}{\string\ll=`\ll'} + \chit@oob@rowupdate(\c,\r){\ll}{#4} + \xdef\lv{1} + \else + \ifnum\chitdbglvl>2% + \node[minimum width=#3cm,minimum height=#3cm, + draw,transform shape] at (\c,\r) {}; + \fi + \ifx\u\chit@blank\else% + \chit[\u=\ti,zone oob point={\u}{\c}{\r}](\c,\r);% + \fi% + \chit@oob@cellupdate(\c,\r){#2}{#3}{\y} + \fi + \fi + } + \fi + } + \fi + \chit@dbg{2}{ End of chits in turn + \ti\space(c=`\c',r=`\r',o='\o',y='\y')} + % --- Not relevant, I think + % IF no units where given, then we force \c to be non-zero so that + % \chit@oob@turnupdate increments the row + % \ifx\t\@empty + % \def\c{#3} + % \chit@dbg{2}{ Turn is empty, set c=`\c'} + % \fi + % --- + %\ifnum\y<0% No explicit number of rows given + % \def\c{#3} + % \chit@dbg{2}{ No explicit number of rows given, set c=`\c'} + %\fi + % In case the user gave and explicit number of rows, add the rows + % that are missing. \y is initially set to the number of + % requested rows, and then decremented every time we go down one + % row. So if the number of rows we did so far is N, and the + % requested number of rows is M, then the loop below adds M-N + % rows. + \ifnum\y>0% + \chit@dbg{2}{ Looping rows from 2 to \y, break when row > \y}% + \foreach \rr in {2,...,\y}{ + %\ifnum\rr>\y% A little funny, but \y can be negative! + % \chit@dbg{2}{ \space Breaking loop \rr\space > \y}% + % \breakforeach% + %\else% + \chit@oob@rowupdate(\c,\r){#3}{0}% Extra spacing? + %\fi + } + \fi + % --- Not relevant I think + % This will zero \c. However, if on entry |\c|>0, then we also + % increment the row + % \chit@oob@turnupdate(\c,\r){#3}{#4} + % --- + % Horizontal spacer + + %\pgfmathparse{ifthenelse(abs(\c)>=\a,1,0)}\xdef\l{\pgfmathresult} + \pgfmathparse{\c+1.5*#4}% + \xdef\c{\pgfmathresult}% + \ifnum\lv=1% + \pgfmathparse{\r-#4} + \chit@oob@rowupdate(\c,\r){0}{#4} + \else + \chit@oob@cellupdate(\c,\r){#2}{#3}{\y} + \ifnum\y<0 + \chit@oob@turnupdate(\c,\r){#3}{#4} + \else + \fi + \fi + % \xdef\y{0} + \chit@dbg{2}{End of turn \ti\space(c=`\c',r=`\r',o='\o',y='\y')} + } + \chit@dbg{3}{End of OOB (c=`\c',r=`\r',y=`\y')} + \@ifnextchar;{\@gobble}{}} +% \end{macrocode} % \iffalse % </chit> % -------------------------------------------------------------------- diff --git a/macros/latex/contrib/wargame/source/chit/shape.dtx b/macros/latex/contrib/wargame/source/chit/shape.dtx index 8a3d70fbd0..f68ea25a44 100644 --- a/macros/latex/contrib/wargame/source/chit/shape.dtx +++ b/macros/latex/contrib/wargame/source/chit/shape.dtx @@ -92,7 +92,7 @@ chit/symbol/.style={scale=.4,transform shape}, chit/parts/.style={shape=rectangle,transform shape}, chit/factors/.style={chit/parts,anchor=south}, - chit/left/.style={chit/parts,anchor=south,rotate=90}, + chit/left/.style={chit/parts,anchor=base,rotate=90},%Anchor was south chit/right/.style={chit/parts,anchor=north,rotate=90}, chit/upper left/.style={chit/parts,anchor=north west}, chit/upper right/.style={chit/parts,anchor=north east}, @@ -141,7 +141,8 @@ % \begin{macrocode} \tikzset{% chit/.code={% - \pgfkeys{/tikz/transform shape,/tikz/shape=chit} + \chit@dbg{2}{chit arguments are `#1'}% + \pgfkeys{/tikz/transform shape,/tikz/shape=chit}% \pgfkeys{/chit/.cd,#1}}} % \end{macrocode} % \end{TikzKey} @@ -657,7 +658,11 @@ % % The work horse. This simply makes a \cs{node} with the shape % \texttt{chit}. Note, we allow for a trailing semi-colon -% (\texttt{;}) to have a similar feel to other \TikZ{} macros. +% (\texttt{;}) to have a similar feel to other \TikZ{} macros. +% +% The macro will execute the style \texttt{/tikz/every chit} if +% defined. Note that this will be executed \emph{before} the usual +% \texttt{every chip node} style. % % \begin{macrocode} \def\chit@@@#1#2(#3){% @@ -667,7 +672,7 @@ ^^J Name: `#3'} \let\name\pgfutil@empty% \chit@dbg{1}{=== Before chit node}% - \node[chit={every chit/.try,id=#3,#1}] (tmp) at (#2) {}; + \node[chit={/tikz/every chit/.try,id=#3,#1}] (tmp) at (#2) {}; \chit@dbg{2}{=== After chit node}% \ifx|#3|\relax% \else% diff --git a/macros/latex/contrib/wargame/source/chit/table.dtx b/macros/latex/contrib/wargame/source/chit/table.dtx index 7094e436ed..f99236119e 100644 --- a/macros/latex/contrib/wargame/source/chit/table.dtx +++ b/macros/latex/contrib/wargame/source/chit/table.dtx @@ -7,7 +7,9 @@ % \begin{macrocode} \tikzset{ chit/cell background/.style={fill=black}, + %chit/cell background flipped/.style={fill=black}, blank chit/.style={/chit/frame={draw=none,fill=none}}, + chit/grid lines/.style={dashed}, } % \end{macrocode} % @@ -20,6 +22,10 @@ \def\chit@cellbg(#1,#2)#3{% \draw[chit/cell background](#1-#3/2,#2-#3/2) rectangle++(#3,#3); } +\def\chit@celldblbg(#1,#2)#3{% + \draw[chit/cell background,chit/cell background flipped/.try]% + (#1-#3/2,#2-#3/2) rectangle++(#3,#3); +} % \end{macrocode} % % \begin{Macro}{\ifchits@reset} @@ -83,6 +89,27 @@ \@ifnextchar;{\@gobble}{}} % \end{macrocode} % \end{Macro} +% \begin{Macro}{\chitgrid} +% \begin{enumerate} +% \item columns +% \item rows +% \item cell-size +% \end{enumerate} +% +% \begin{macrocode} +\def\chitgrid#1#2#3{% + \pgfmathparse{#3/2}\edef\rmin{\pgfmathresult}% + \pgfmathparse{#2*#3-#3/2}\edef\rmax{\pgfmathresult}% + %\draw[red](-#3/2,\rmin)rectangle(#3*#1-#3/2,-\rmax); + \foreach \cc in {0,...,#1}{ + \draw[chit/grid lines] (\cc*#3-#3/2,3*#3/4)--(\cc*#3-#3/2,-\rmax-#3/4);} + %\chit@dbg{0}{Drawing horizontal lines from `\rmin, `-\rmin', ..., `-\rmax'} + \foreach \rr in {\rmin,-\rmin,...,-\rmax}{ + %\chit@dbg{0}{Horizontal line at `\rr'} + \draw[chit/grid lines] (-3*#3/4,\rr)--(#1*#3-#3/4,\rr);} +} +% \end{macrocode} +% \end{Macro} % % \begin{Macro}{\doublechits, % \@doublechits, @@ -154,7 +181,7 @@ \chit@cellbg(\c,\r){#3} \chit[\u=\ti](\c,\r) \chit@dbl@flip(\c,\r){#3} - \chit@cellbg(\mc,\r){#3} + \chit@celldblbg(\mc,\r){#3} \chit[\u\space flipped=\ti,zone turn=\t,zone mult=\n](\mc,\r) \chit@dbl@cellupdate(\c,\r){#2}{#3} \fi @@ -166,10 +193,39 @@ \draw[dashed](0,-3*#3/4)--(0,\r-#3/4);% \draw[dashed,<-] (#3/5,-2*#3/3)--(#3/2,-2*#3/3) node[transform shape,anchor=west]{Back};% \draw[dashed,<-] (-#3/5,-2*#3/3)--(-#3/2,-2*#3/3) node[transform shape,anchor=east]{Front};% + % \foreach \cc in {0,...,#2}{ + % \draw[dashed] (\cc*#3,-3*#3/4)--(\cc*#3,\r-#3/4); + % \draw[dashed] (-\cc*#3,-3*#3/4)--(-\cc*#3,\r-#3/4);} + % \pgfmathparse{#3/2}\edef\rmin{\pgfmathresult}% + % \chit@dbg{0}{Drawing horizontal lines from `-\rmin, `\rmin', ..., `\r'} + % \foreach \rr in {-\rmin,\rmin,...,\r}{ + % \chit@dbg{0}{Horizontal line at `\rr'} + % \draw[dashed] (-#2*#3-#3/4,\rr)--(#2*#3+#3/4,\rr);} \@ifnextchar;{\@gobble}{}} % \end{macrocode} % \end{Macro} % +% \begin{Macro}{\doublechitgrid} +% \begin{enumerate} +% \item columns +% \item rows +% \item cell-size +% \end{enumerate} +% +% \begin{macrocode} +\def\doublechitgrid#1#2#3{% + \pgfmathparse{#3/2}\edef\rmin{\pgfmathresult}% + \pgfmathparse{#2*#3-#3/2}\edef\rmax{\pgfmathresult}% + \foreach \cc in {0,...,#1}{ + \draw[chit/grid lines] (\cc*#3,-3*#3/4)--(\cc*#3,\rmax+#3/4); + \draw[chit/grid lines] (-\cc*#3,-3*#3/4)--(-\cc*#3,\rmax+#3/4);} + %\chit@dbg{0}{Drawing horizontal lines from `-\rmin, `\rmin', ..., `\rmax'} + \foreach \rr in {-\rmin,\rmin,...,\rmax}{ + %\chit@dbg{0}{Horizontal line at `\rr'} + \draw[chit/grid lines] (-#1*#3-#3/4,\rr)--(#1*#3+#3/4,\rr);} +} +% \end{macrocode} +% \end{Macro} % \iffalse % </chit> % -------------------------------------------------------------------- |