%%
%% Copyright (C) 2013 by:
%% Josef Kleber
%% <josef.kleber@gmx.de>
%%
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of LaTeX version
%% 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "author-maintained".
%%
%% The Current Maintainer of this work is Josef Kleber.
%%
%% This work consists of all files listed in manifest.txt.
%%
%
\ProvidesPackage{chaossudoku}[2013/03/16 chaossudoku.sty v1.0 - Josef Kleber (C) 2013]%
%
\RequirePackage{logicpuzzle}%
%
% options
\newcommand*\LP@CS@width{5.1cm}%
\newcommand*\LP@CS@fontsize\Large%
\newcommand*\LP@CS@rows{5}%
\newcommand*\LP@CS@columns{5}%
\newcommand*\LP@CS@scale{1}%
\newcommand*\LP@CS@bgcolor{}%
\newcommand*\LP@CS@cvoffset{-39pt}%
\newcommand*\LP@CS@title{}%
\newcommand*\LP@CS@titleindent{0cm}%
\newcommand*\LP@CS@titlewidth{5.1cm}%
%
\newcounter{LP@CS@rows}%
\newcounter{LP@CS@columns}%
%
\setcounter{LP@CS@rows}{\LP@CS@rows}%
\setcounter{LP@CS@columns}{\LP@CS@columns}%
\stepcounter{LP@CS@rows}%
\stepcounter{LP@CS@columns}%
%
\define@key{chaossudoku.sty}{rows}[5]%
{%
  \renewcommand*\LP@CS@rows{#1}%
}%
%
\define@key{chaossudoku.sty}{columns}[5]%
{%
  \renewcommand*\LP@CS@columns{#1}%
}%
%
\define@key{chaossudoku.sty}{scale}[1]%
{%
  \renewcommand*\LP@CS@scale{#1}%
}%
%
\define@key{chaossudoku.sty}{counterstyle}[none]%
{%
  \renewcommand*\LP@counterstyle{#1}%
}%
%
\define@key{chaossudoku.sty}{bgcolor}[]%
{%
  \renewcommand*\LP@CS@bgcolor{#1}%
}%
%
\define@choicekey*{chaossudoku.sty}{fontsize}[\LP@CS@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]%
{%
  \ifcase\nr\relax%
    \renewcommand*\LP@CS@fontsize{\tiny}%
  \or%
    \renewcommand*\LP@CS@fontsize{\scriptsize}%
  \or%
    \renewcommand*\LP@CS@fontsize{\footnotesize}%
  \or%
    \renewcommand*\LP@CS@fontsize{\small}%
  \or%
    \renewcommand*\LP@CS@fontsize{\normalsize}%
  \or%
    \renewcommand*\LP@CS@fontsize{\large}%
  \or%
    \renewcommand*\LP@CS@fontsize{\Large}%
  \or%
    \renewcommand*\LP@CS@fontsize{\LARGE}%
  \or%
    \renewcommand*\LP@CS@fontsize{\huge}%
  \or%
    \renewcommand*\LP@CS@fontsize{\Huge}%
  \fi%
}%
%
\define@key{chaossudoku.sty}{width}[5.1cm]%
{%
  \renewcommand*\LP@CS@width{#1}%
}%
%
\define@key{chaossudoku.sty}{title}[]%
{%
  \renewcommand*\LP@CS@title{#1}%
}%
%
\define@key{chaossudoku.sty}{cvoffset}[-22pt]%
{%
  \renewcommand*\LP@CS@cvoffset{#1}%
}%
%
\define@key{chaossudoku.sty}{titleindent}[0cm]%
{%
  \renewcommand*\LP@CS@titleindent{#1}%
}%
%
\define@key{chaossudoku.sty}{titlewidth}[5.1cm]%
{%
  \renewcommand*\LP@CS@titlewidth{#1}%
}%
%
\define@key{chaossudoku}{rows}%
{%
  \renewcommand*\LP@CS@rows{#1}%
}%
%
\define@key{chaossudoku}{columns}%
{%
  \renewcommand*\LP@CS@columns{#1}%
}%
%
\define@key{chaossudoku}{scale}%
{%
  \renewcommand*\LP@CS@scale{#1}%
}%
%
\define@key{chaossudoku}{bgcolor}%
{%
  \renewcommand*\LP@CS@bgcolor{#1}%
}%
%
\define@key{chaossudoku}{counterstyle}%
{%
  \renewcommand*\LP@counterstyle{#1}%
}%
%
\define@choicekey*{chaossudoku}{fontsize}[\LP@CS@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]%
{%
  \ifcase\nr\relax%
    \renewcommand*\LP@CS@fontsize{\tiny}%
  \or%
    \renewcommand*\LP@CS@fontsize{\scriptsize}%
  \or%
    \renewcommand*\LP@CS@fontsize{\footnotesize}%
  \or%
    \renewcommand*\LP@CS@fontsize{\small}%
  \or%
    \renewcommand*\LP@CS@fontsize{\normalsize}%
  \or%
    \renewcommand*\LP@CS@fontsize{\large}%
  \or%
    \renewcommand*\LP@CS@fontsize{\Large}%
  \or%
    \renewcommand*\LP@CS@fontsize{\LARGE}%
  \or%
    \renewcommand*\LP@CS@fontsize{\huge}%
  \or%
    \renewcommand*\LP@CS@fontsize{\Huge}%
  \fi%
}%
%
\define@key{chaossudoku}{width}%
{%
  \renewcommand*\LP@CS@width{#1}%
}%
%
\define@key{chaossudoku}{title}%
{%
  \renewcommand*\LP@CS@title{#1}%
}%
%
\define@key{chaossudoku}{cvoffset}%
{%
  \renewcommand*\LP@CS@cvoffset{#1}%
}%
%
\define@key{chaossudoku}{titleindent}%
{%
  \renewcommand*\LP@CS@titleindent{#1}%
}%
%
\define@key{chaossudoku}{titlewidth}%
{%
  \renewcommand*\LP@CS@titlewidth{#1}%
}%
%
\ExecuteOptionsX{rows,columns,width,fontsize,scale,bgcolor,cvoffset,counterstyle,title,titleindent,titlewidth}%
%
\ProcessOptionsX\relax%
%
\let\chaossudokucell\setcell%
%
\newcommand*\chaossudokusetup[1]%
{%
  \setkeys{chaossudoku.sty}{#1}%
}%
%
\newenvironment{chaossudoku}[1][]%
{%
  \setkeys{chaossudoku}{#1}%
  \LP@set@package{chaossudoku}%
  \LP@set@env@prefix{LP@CS}%
  \setcounter{LP@CS@rows}{\LP@CS@rows}%
  \setcounter{LP@CS@columns}{\LP@CS@columns}%
  \stepcounter{LP@CS@rows}%
  \stepcounter{LP@CS@columns}%
  \begin{minipage}[t]{\LP@CS@width}%
    \ifthenelse{\equal{\LP@CS@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@CS@titleindent}\parbox{\LP@CS@titlewidth}{\strut\LP@titleformat\LP@CS@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[scale=\LP@CS@scale]%
      \LP@drawbackground{1}{1}{\LP@CS@columns}{\LP@CS@rows}{\LP@CS@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@CS@columns}{\LP@CS@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%
\endinput%