| 1 |
% \iffalse |
| 2 |
% -------------------------------------------------------------------- |
| 3 |
%<*utils> |
| 4 |
% \fi |
| 5 |
% |
| 6 |
% \subsubsection{Miscellaneous macros} |
| 7 |
% \begin{Macro}{\wargamelogo} |
| 8 |
% |
| 9 |
% This will produce the logo for this package. |
| 10 |
% |
| 11 |
% |
| 12 |
% \begin{center} |
| 13 |
% \tikz{\wargamelogo} |
| 14 |
% \end{center} |
| 15 |
% |
| 16 |
% \begin{macrocode} |
| 17 |
\tikzset{ |
| 18 |
wargame logo text/.style={ |
| 19 |
font=\sffamily\bfseries\fontsize{12}{14}\selectfont, |
| 20 |
scale=2.8, |
| 21 |
inner sep=0, |
| 22 |
text width=1.8cm, |
| 23 |
transform shape, |
| 24 |
align=center}, |
| 25 |
wargame logo text content/.store in=\wg@logo@text@content, |
| 26 |
wargame logo text content={{\huge\LaTeX} wargame}, |
| 27 |
wargame logo chit/.style={ |
| 28 |
chit={symbol={[ |
| 29 |
faction=friendly, |
| 30 |
command=land, |
| 31 |
echelon=division, |
| 32 |
main=infantry]}, |
| 33 |
factors={chit/2 factors={4,3}}, |
| 34 |
left={chit/identifier=III}, |
| 35 |
right={chit/small identifier={10\textsuperscript{th}}}, |
| 36 |
color=white, |
| 37 |
fill=red!50!black |
| 38 |
} |
| 39 |
}, |
| 40 |
wargame logo/.style={ |
| 41 |
transform shape, |
| 42 |
every hex/.style={fill=gray!5!white,draw=gray!75!black}, |
| 43 |
hex/first row is=0, |
| 44 |
hex/first column is=0, |
| 45 |
hex/short top columns=none, |
| 46 |
hex/short bottom columns=none, |
| 47 |
hex/row direction is=normal, |
| 48 |
hex/column direction is=normal |
| 49 |
} |
| 50 |
} |
| 51 |
\newcommand\wargamelogo[1][]{% |
| 52 |
\begin{scope}[wargame logo,#1] |
| 53 |
\node[hex={fill=gray!30!white}] (logo center) at (hex cs:c=0,r=0) {}; |
| 54 |
\node[hex={terrain=light woods}](logo light woods) at (hex cs:c=0,r=1) {}; |
| 55 |
\node[hex={terrain=city}] (logo city) at (hex cs:c=0,r=-1){}; |
| 56 |
\node[hex={terrain=woods}] (logo woods) at (hex cs:c=-1,r=0){}; |
| 57 |
\node[hex={terrain=mountains}] (logo mountains) at (hex cs:c=-1,r=1){}; |
| 58 |
\node[hex={terrain=beach}] (logo beach) at (hex cs:c=1,r=1) {}; |
| 59 |
\node[hex={terrain=swamp}] (logo swamp) at (hex cs:c=1,r=0) {}; |
| 60 |
\node[wargame logo chit] (logo chit) at (hex cs:) {}; |
| 61 |
\node[wargame logo text] (logo text) {\wg@logo@text@content}; |
| 62 |
\end{scope}} |
| 63 |
% \end{macrocode} |
| 64 |
% |
| 65 |
% \end{Macro} |
| 66 |
% \begin{Macro}{\wg@dbg} |
| 67 |
% Debugging support. The counter \cs{wargamedbglvl} sets the debug |
| 68 |
% level. The package code then uses \cs{wg@dbg} to print out |
| 69 |
% debugging messages. This macro takes two arguments --- the first |
| 70 |
% is the \emph{least} debug level at which the message is printed, and |
| 71 |
% the second is the message it self. |
| 72 |
% |
| 73 |
% \begin{macrocode} |
| 74 |
\newcount\wargamedbglvl\wargamedbglvl=0 |
| 75 |
\def\wg@dbg#1#2{% |
| 76 |
\ifnum#1>\wargamedbglvl\relax\else\message{^^J#2}\fi} |
| 77 |
% \end{macrocode} |
| 78 |
% \end{Macro} |
| 79 |
% |
| 80 |
% \begin{Macro}{\wg@addto@macro} |
| 81 |
% |
| 82 |
% The macro \cs{wg@addto@macro}\marg{macro}\marg{other} adds the |
| 83 |
% definition of the macro \meta{other} to the macro \meta{macro}. |
| 84 |
% This uses the \cs{toks} trick of storing the \emph{tokens} of the |
| 85 |
% definition of a \meta{macro} and \meta{other} into \spec{@} and |
| 86 |
% expanding that token into the definition of \meta{macro}. |
| 87 |
% Effectively, this means that the top-level definition of |
| 88 |
% \meta{macro} and \meta{other} are expanded (i.e., macros used in |
| 89 |
% the definition of either macro is \emph{not} expanded) and then |
| 90 |
% that becomes the new definition of \meta{macro}. |
| 91 |
% |
| 92 |
% We will use this macro to do \emph{shallow} definitions of macros |
| 93 |
% to contain keys and such. |
| 94 |
% |
| 95 |
% \begin{macrocode} |
| 96 |
\long\def\wg@addto@macro#1#2{% |
| 97 |
\begingroup |
| 98 |
\toks@\expandafter\expandafter\expandafter{\expandafter#1#2}% |
| 99 |
\xdef#1{\the\toks@}% |
| 100 |
\endgroup} |
| 101 |
% \end{macrocode} |
| 102 |
% \end{Macro} |
| 103 |
% |
| 104 |
% \begin{Macro}{\wg@nchor} |
| 105 |
% \begin{macrocode} |
| 106 |
\def\wg@nchor#1#2{% shape name, anchor |
| 107 |
\wg@dbg{10}{Get `#2' in `#1'}% |
| 108 |
\expandafter\csname pgf@anchor@#1@#2\endcsname% |
| 109 |
\wg@dbg{10}{Got `\pgf@x',`\pgf@y'} |
| 110 |
} |
| 111 |
% \end{macrocode} |
| 112 |
% \end{Macro} |
| 113 |
% |
| 114 |
% \begin{Macro}{\wg@sub@nchor} |
| 115 |
% Get anchor from sub node. We cannot use \cs{pgfpointanchor} since |
| 116 |
% that returns the anchor coordinates in the global coordinate |
| 117 |
% system. |
| 118 |
% |
| 119 |
% \begin{macrocode} |
| 120 |
\newif\ifwg@ignore@sub@nchor\wg@ignore@sub@nchorfalse% |
| 121 |
\def\wg@sub@nchor#1#2{% |
| 122 |
\wg@dbg{10}{^^JGet `#2' in `#1'}% |
| 123 |
\@ifundefined{pgf@sh@ns@#1}{% |
| 124 |
\ifwg@ignore@sub@nchor% |
| 125 |
\wg@dbg{0}{WARNING: Shape `#1' not defined, anchor `#2' unknown} |
| 126 |
\fi |
| 127 |
\pgf@x=0cm\pgf@y=0cm}{% |
| 128 |
\pgf@process{% |
| 129 |
\csname pgf@sh@ma@#1\endcsname% MW |
| 130 |
\csname pgf@sh@np@#1\endcsname% |
| 131 |
\pgf@sh@reanchor{\csname pgf@sh@ns@#1\endcsname}{#2}}}% |
| 132 |
\wg@dbg{10}{-> \the\pgf@x,\the\pgf@y}% |
| 133 |
} |
| 134 |
% \end{macrocode} |
| 135 |
% \end{Macro} |
| 136 |
% |
| 137 |
% |
| 138 |
% Scratch dimensions |
| 139 |
% |
| 140 |
% \begin{macrocode} |
| 141 |
\newdimen\wg@tmpa |
| 142 |
\newdimen\wg@tmpb |
| 143 |
\newdimen\wg@tmpc |
| 144 |
\newdimen\wg@tmpd |
| 145 |
% \end{macrocode} |
| 146 |
% |
| 147 |
% |
| 148 |
% Macro to easy restore a saved path |
| 149 |
% |
| 150 |
% \begin{macrocode} |
| 151 |
\def\settosave#1{ |
| 152 |
\pgfsyssoftpath@setcurrentpath{#1}} |
| 153 |
% \end{macrocode} |
| 154 |
% |
| 155 |
% \iffalse |
| 156 |
% -------------------------------------------------------------------- |
| 157 |
% </utils> |
| 158 |
% \fi |