summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-10-01 11:07:30 +0200
committerErich Eckner <git@eckner.net>2018-10-01 11:07:30 +0200
commit0c70d338a4157e59cb25f4881a349105957486a0 (patch)
treebce254114161df601b421bf2f27baae965b32092
parent70362e17027b8ad55d2f581f4712be3eabaa6256 (diff)
downloadRaetsel-0c70d338a4157e59cb25f4881a349105957486a0.tar.xz
buchstabenunit.pas,hochhausunit.pas -> raetselunit.inc
-rw-r--r--buchstabenunit.pas120
-rw-r--r--hochhausunit.pas88
-rw-r--r--raetsel.lpi9
-rw-r--r--raetsel.lpr3
-rw-r--r--raetsel.lps205
-rw-r--r--raetselunit.inc439
-rw-r--r--raetselunit.pas271
-rw-r--r--unit1.lfm4
-rw-r--r--unit1.pas11
-rw-r--r--unit2.lfm6
10 files changed, 681 insertions, 475 deletions
diff --git a/buchstabenunit.pas b/buchstabenunit.pas
deleted file mode 100644
index 42d7f33..0000000
--- a/buchstabenunit.pas
+++ /dev/null
@@ -1,120 +0,0 @@
-unit buchstabenunit;
-
-{$mode objfpc}{$H+}
-
-interface
-
-uses
- Classes, SysUtils, raetselunit, Forms;
-
-type
- tBuchstabenRaetsel = class(tFelderRaetsel)
- private
- procedure relativeInhaltsAenderung(diff: longint); override;
- function absoluteInhaltsAenderung(key: word): boolean; override;
- public
- constructor create(aOwner: tForm);
- destructor destroy; override;
- function gleichzeitigMoeglich(num: longint): longint; override;
- function _loesen(lm: tFelderLoesMeta): longint; override;
- end;
-
-function buchstabenAlphabetFunktion(i: longint): string;
-
-implementation
-
-uses
- math;
-
-function buchstabenAlphabetFunktion(i: longint): string;
-begin
- if i<0 then
- result:=''
- else if i=0 then
- result:='-'
- else begin
- result:='';
- while i>0 do begin
- dec(i);
- result:=char(ord('A')+(i mod 26))+result;
- i:=i div 26;
- end;
- end;
-end;
-
-// tBuchstabenRaetsel **********************************************************
-
-constructor tBuchstabenRaetsel.create(aOwner: tForm);
-begin
- inherited create(aOwner,2,@buchstabenAlphabetFunktion);
- spinEdits[1].showHint:=true;
- spinEdits[1].hint:='Anzahl Buchstaben';
- spinEdits[1].value:=5;
- spinEdits[2].showHint:=true;
- spinEdits[2].hint:='Anzahl Leerfelder';
- spinEdits[2].value:=1;
- aktualisiereGroesze;
-end;
-
-destructor tBuchstabenRaetsel.destroy;
-begin
- inherited destroy;
-end;
-
-procedure tBuchstabenRaetsel.relativeInhaltsAenderung(diff: longint);
-begin
- if (cursorPosition<0) or (cursorPosition>=dim*dim) then exit;
- inhalt[cursorPosition]:=min(max(-1,inhalt[cursorPosition]+diff),groeszen[0]);
-end;
-
-function tBuchstabenRaetsel.absoluteInhaltsAenderung(key: word): boolean;
-begin
- result:=true;
- if (key>=ord('A')) and (key<=min(ord('A')+groeszen[0]-1,ord('Z'))) then begin
- inhalt[cursorPosition]:=key-ord('A')+1;
- exit;
- end;
- if (key=ord(' ')) or (key=46) or (key=8) then begin
- inhalt[cursorPosition]:=-1;
- exit;
- end;
- if (key=189) then begin
- inhalt[cursorPosition]:=0;
- exit;
- end;
- result:=false;
-end;
-
-function tBuchstabenRaetsel.gleichzeitigMoeglich(num: longint): longint;
-begin
- if num=0 then
- result:=groeszen[0] // so viele Leerzeichen
- else
- result:=1; // jeder Buchstabe nur ein Mal
-end;
-
-function tBuchstabenRaetsel._loesen(lm: tFelderLoesMeta): longint;
-var
- w: longint;
-begin
- if not lm.fwd then begin
- result:=1;
- exit;
- end;
- if inhalt[lm.posi]>=0 then begin
- result:=_loesen(lm);
- exit;
- end;
-
- result:=0;
- //for
-
- if not lm.inhaltBehalten then begin
- w:=inhalt[lm.posi];
- inhalt[lm.posi]:=-1;
- lm.aktualisiereInhalt(lm.posi,w);
- end;
-end;
-
-end.
-
diff --git a/hochhausunit.pas b/hochhausunit.pas
deleted file mode 100644
index f53270c..0000000
--- a/hochhausunit.pas
+++ /dev/null
@@ -1,88 +0,0 @@
-unit hochhausunit;
-
-{$mode objfpc}{$H+}
-
-interface
-
-uses
- Classes, SysUtils, raetselunit, Forms;
-
-type
- tHochhausRaetsel = class(tFelderRaetsel)
- private
- procedure relativeInhaltsAenderung(diff: longint); override;
- function absoluteInhaltsAenderung(key: word): boolean; override;
- public
- constructor create(aOwner: tForm);
- destructor destroy; override;
- function gleichzeitigMoeglich(num: longint): longint; override;
- function _loesen(lm: tFelderLoesMeta): longint; override;
- end;
-
-function zahlenAlphabetFunktion(i: longint): string;
-
-implementation
-
-uses
- math;
-
-function zahlenAlphabetFunktion(i: longint): string;
-begin
- if i<0 then
- result:=''
- else if i=0 then
- result:='-'
- else
- result:=inttostr(i);
-end;
-
-// tHochhausRaetsel ************************************************************
-
-constructor tHochhausRaetsel.create(aOwner: tForm);
-begin
- inherited create(aOwner,1,@zahlenAlphabetFunktion);
- spinEdits[1].showHint:=true;
- spinEdits[1].hint:='Anzahl Spalten';
- spinEdits[1].value:=5;
- aktualisiereGroesze;
-end;
-
-destructor tHochhausRaetsel.destroy;
-begin
- inherited destroy;
-end;
-
-procedure tHochhausRaetsel.relativeInhaltsAenderung(diff: longint);
-begin
- if (cursorPosition<0) or (cursorPosition>=dim*dim) then exit;
- if inhalt[cursorPosition]=-1 then inhalt[cursorPosition]:=0;
- inhalt[cursorPosition]:=min(max(0,inhalt[cursorPosition]+diff),groeszen[0]);
- if inhalt[cursorPosition]=0 then inhalt[cursorPosition]:=-1;
-end;
-
-function tHochhausRaetsel.absoluteInhaltsAenderung(key: word): boolean;
-begin
- result:=true;
- if (key>=ord('1')) and (key<=min(ord('1')+groeszen[0]-1,ord('9'))) then begin
- inhalt[cursorPosition]:=key-ord('1')+1;
- exit;
- end;
- if (key=ord(' ')) or (key=46) or (key=8) then begin
- inhalt[cursorPosition]:=-1;
- exit;
- end;
- result:=false;
-end;
-
-function tHochhausRaetsel.gleichzeitigMoeglich(num: longint): longint;
-begin
- result:=1; // jede Höhe nur ein Mal
-end;
-
-function tHochhausRaetsel._loesen(lm: tFelderLoesMeta): longint;
-begin
-
-end;
-
-end.
-
diff --git a/raetsel.lpi b/raetsel.lpi
index 0b62fb2..3c68587 100644
--- a/raetsel.lpi
+++ b/raetsel.lpi
@@ -29,7 +29,7 @@
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
- <Units Count="6">
+ <Units Count="5">
<Unit0>
<Filename Value="raetsel.lpr"/>
<IsPartOfProject Value="True"/>
@@ -54,13 +54,9 @@
<IsPartOfProject Value="True"/>
</Unit3>
<Unit4>
- <Filename Value="buchstabenunit.pas"/>
+ <Filename Value="raetselunit.inc"/>
<IsPartOfProject Value="True"/>
</Unit4>
- <Unit5>
- <Filename Value="hochhausunit.pas"/>
- <IsPartOfProject Value="True"/>
- </Unit5>
</Units>
</ProjectOptions>
<CompilerOptions>
@@ -70,6 +66,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
+ <OtherUnitFiles Value="../units"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
diff --git a/raetsel.lpr b/raetsel.lpr
index 92f798f..a9538ec 100644
--- a/raetsel.lpr
+++ b/raetsel.lpr
@@ -7,8 +7,7 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
- Forms, unit1, Unit2, raetselunit, buchstabenunit, hochhausunit
- { you can add units after this };
+ Forms, unit1, Unit2, raetselunit;
{$R *.res}
diff --git a/raetsel.lps b/raetsel.lps
index c9d11fe..df267c7 100644
--- a/raetsel.lps
+++ b/raetsel.lps
@@ -3,13 +3,14 @@
<ProjectSession>
<Version Value="10"/>
<BuildModes Active="Default"/>
- <Units Count="13">
+ <Units Count="14">
<Unit0>
<Filename Value="raetsel.lpr"/>
<IsPartOfProject Value="True"/>
- <EditorIndex Value="-1"/>
- <CursorPos Y="18"/>
- <UsageCount Value="40"/>
+ <EditorIndex Value="2"/>
+ <CursorPos X="35" Y="10"/>
+ <UsageCount Value="43"/>
+ <Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
@@ -18,8 +19,8 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<TopLine Value="10"/>
- <CursorPos X="38" Y="34"/>
- <UsageCount Value="40"/>
+ <CursorPos X="38" Y="21"/>
+ <UsageCount Value="43"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@@ -30,212 +31,216 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit2"/>
- <EditorIndex Value="4"/>
+ <EditorIndex Value="6"/>
<CursorPos X="20" Y="12"/>
- <UsageCount Value="39"/>
+ <UsageCount Value="42"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit2>
<Unit3>
<Filename Value="raetselunit.pas"/>
<IsPartOfProject Value="True"/>
- <IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
- <TopLine Value="148"/>
- <CursorPos X="64" Y="181"/>
- <UsageCount Value="34"/>
+ <TopLine Value="4"/>
+ <CursorPos X="35" Y="9"/>
+ <UsageCount Value="37"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
+ <Filename Value="buchstabenunit.pas"/>
+ <EditorIndex Value="4"/>
+ <CursorPos Y="18"/>
+ <UsageCount Value="23"/>
+ <Loaded Value="True"/>
+ </Unit4>
+ <Unit5>
+ <Filename Value="hochhausunit.pas"/>
+ <EditorIndex Value="5"/>
+ <CursorPos Y="18"/>
+ <UsageCount Value="23"/>
+ <Loaded Value="True"/>
+ </Unit5>
+ <Unit6>
<Filename Value="Unit1.pas"/>
<EditorIndex Value="-1"/>
<CursorPos X="3" Y="17"/>
<UsageCount Value="9"/>
- </Unit4>
- <Unit5>
+ </Unit6>
+ <Unit7>
<Filename Value="RaetselFileUnit.pas"/>
<UnitName Value="raetselFileUnit"/>
<EditorIndex Value="-1"/>
<UsageCount Value="9"/>
- </Unit5>
- <Unit6>
+ </Unit7>
+ <Unit8>
<Filename Value="raetselFileUnit.pas"/>
<EditorIndex Value="-1"/>
<CursorPos X="28" Y="11"/>
<UsageCount Value="9"/>
- </Unit6>
- <Unit7>
+ </Unit8>
+ <Unit9>
<Filename Value="ori_Unit1.pas"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
- <EditorIndex Value="-1"/>
- <CursorPos X="15" Y="13"/>
- <UsageCount Value="9"/>
- </Unit7>
- <Unit8>
+ <EditorIndex Value="7"/>
+ <CursorPos X="34" Y="93"/>
+ <UsageCount Value="12"/>
+ <Loaded Value="True"/>
+ </Unit9>
+ <Unit10>
<Filename Value="/usr/share/lazarus/lcl/stdctrls.pp"/>
<UnitName Value="StdCtrls"/>
<EditorIndex Value="-1"/>
<TopLine Value="1255"/>
<CursorPos X="3" Y="1277"/>
<UsageCount Value="9"/>
- </Unit8>
- <Unit9>
+ </Unit10>
+ <Unit11>
<Filename Value="/usr/share/lazarus/lcl/dialogs.pp"/>
<UnitName Value="Dialogs"/>
<EditorIndex Value="-1"/>
<TopLine Value="487"/>
<CursorPos X="10" Y="509"/>
<UsageCount Value="10"/>
- </Unit9>
- <Unit10>
+ </Unit11>
+ <Unit12>
<Filename Value="../units/lowlevelunit.pas"/>
<EditorIndex Value="-1"/>
- <TopLine Value="1187"/>
- <CursorPos Y="1209"/>
<UsageCount Value="10"/>
- </Unit10>
- <Unit11>
- <Filename Value="buchstabenunit.pas"/>
+ </Unit12>
+ <Unit13>
+ <Filename Value="raetselunit.inc"/>
<IsPartOfProject Value="True"/>
+ <IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
- <TopLine Value="60"/>
- <CursorPos X="55" Y="93"/>
- <UsageCount Value="21"/>
- <Loaded Value="True"/>
- </Unit11>
- <Unit12>
- <Filename Value="hochhausunit.pas"/>
- <IsPartOfProject Value="True"/>
- <EditorIndex Value="2"/>
- <TopLine Value="45"/>
- <CursorPos X="22" Y="19"/>
- <UsageCount Value="21"/>
+ <TopLine Value="341"/>
+ <CursorPos X="26" Y="360"/>
+ <UsageCount Value="23"/>
<Loaded Value="True"/>
- </Unit12>
+ </Unit13>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
- <Filename Value="buchstabenunit.pas"/>
- <Caret Line="91" Column="20" TopLine="62"/>
+ <Filename Value="ori_Unit1.pas"/>
+ <Caret Line="1027" Column="63" TopLine="1013"/>
</Position1>
<Position2>
- <Filename Value="buchstabenunit.pas"/>
- <Caret Line="19"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="150" TopLine="131"/>
</Position2>
<Position3>
- <Filename Value="hochhausunit.pas"/>
- <Caret Line="26" Column="8"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="493" TopLine="454"/>
</Position3>
<Position4>
- <Filename Value="hochhausunit.pas"/>
- <Caret Line="8" Column="36"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="210" Column="31" TopLine="191"/>
</Position4>
<Position5>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="135" Column="18" TopLine="92"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="494" Column="9" TopLine="455"/>
</Position5>
<Position6>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="22" Column="27" TopLine="7"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="211" Column="30" TopLine="191"/>
</Position6>
<Position7>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="98" TopLine="82"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="23" Column="3"/>
</Position7>
<Position8>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="335" Column="18" TopLine="299"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="488" TopLine="449"/>
</Position8>
<Position9>
<Filename Value="raetselunit.pas"/>
- <Caret Line="132" Column="36" TopLine="115"/>
+ <Caret Line="372" Column="8" TopLine="351"/>
</Position9>
<Position10>
<Filename Value="raetselunit.pas"/>
- <Caret Line="30" Column="33" TopLine="8"/>
+ <Caret Line="467" TopLine="435"/>
</Position10>
<Position11>
<Filename Value="raetselunit.pas"/>
- <Caret Line="132" Column="45" TopLine="96"/>
+ <Caret Line="471" Column="30" TopLine="435"/>
</Position11>
<Position12>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="372" Column="34" TopLine="339"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="224" Column="3" TopLine="198"/>
</Position12>
<Position13>
<Filename Value="raetselunit.pas"/>
- <Caret Line="357" Column="34" TopLine="335"/>
+ <Caret Line="85" Column="7"/>
</Position13>
<Position14>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="31" Column="37" TopLine="8"/>
+ <Filename Value="raetsel.lpr"/>
+ <Caret Line="10" Column="35"/>
</Position14>
<Position15>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="132" Column="51" TopLine="110"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="219" Column="28" TopLine="199"/>
</Position15>
<Position16>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="144" Column="49" TopLine="122"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="225" Column="38" TopLine="205"/>
</Position16>
<Position17>
- <Filename Value="buchstabenunit.pas"/>
- <Caret Line="106" Column="36" TopLine="65"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="229" Column="23" TopLine="209"/>
</Position17>
<Position18>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="143" Column="38" TopLine="113"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="230" Column="18" TopLine="210"/>
</Position18>
<Position19>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="132" Column="36" TopLine="121"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="236" Column="32" TopLine="216"/>
</Position19>
<Position20>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="30" Column="33" TopLine="8"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="242" Column="34" TopLine="221"/>
</Position20>
<Position21>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="132" Column="45" TopLine="96"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="249" Column="17" TopLine="229"/>
</Position21>
<Position22>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="372" Column="26" TopLine="336"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="263" Column="13" TopLine="241"/>
</Position22>
<Position23>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="375" Column="28" TopLine="339"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="396" Column="20" TopLine="364"/>
</Position23>
<Position24>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="58" Column="14"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="231" Column="3" TopLine="211"/>
</Position24>
<Position25>
- <Filename Value="raetselunit.pas"/>
- <Caret Line="143" Column="14" TopLine="121"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="309" Column="29" TopLine="280"/>
</Position25>
<Position26>
- <Filename Value="buchstabenunit.pas"/>
- <Caret Line="106" Column="35" TopLine="68"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="85" Column="7"/>
</Position26>
<Position27>
- <Filename Value="buchstabenunit.pas"/>
- <Caret Line="19"/>
+ <Filename Value="raetselunit.inc"/>
+ <Caret Line="450" TopLine="259"/>
</Position27>
<Position28>
- <Filename Value="buchstabenunit.pas"/>
- <Caret Line="93" Column="55" TopLine="60"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="85" Column="16" TopLine="65"/>
</Position28>
<Position29>
- <Filename Value="hochhausunit.pas"/>
- <Caret Line="79" Column="39" TopLine="40"/>
+ <Filename Value="raetselunit.pas"/>
+ <Caret Line="24" Column="34" TopLine="10"/>
</Position29>
<Position30>
<Filename Value="raetselunit.pas"/>
- <Caret Line="171" TopLine="133"/>
+ <Caret Line="9" Column="35" TopLine="4"/>
</Position30>
</JumpHistory>
</ProjectSession>
diff --git a/raetselunit.inc b/raetselunit.inc
new file mode 100644
index 0000000..57e68fd
--- /dev/null
+++ b/raetselunit.inc
@@ -0,0 +1,439 @@
+{$IFDEF interface}
+
+type
+{$IFDEF hochhaus}
+ tHochhausRaetsel = class(tFelderRaetsel)
+{$ENDIF}
+{$IFDEF buchstaben}
+ tBuchstabenRaetsel = class(tFelderRaetsel)
+{$ENDIF}
+ private
+// procedure relativeInhaltsAenderung(diff: longint); override;
+// function absoluteInhaltsAenderung(key: word): boolean; override;
+ public
+ {$IFDEF buchstaben}
+ NBuchst,
+ NLeer,
+ {$ENDIF}
+ NSqrt: integer;
+ AMoeglich,EMoeglich: array of boolean;
+ constructor create(aOwner: tForm);
+ destructor destroy; override;
+ procedure gesamtRaenderErzeugen;
+(* function passtZumZeichnen(Spalte,Zeile: integer): boolean;
+ procedure Zeichnen;
+ procedure schreibe(was: String; Spalte,Zeile: integer); *)
+ function passt(spalte,zeile: integer): boolean; override;
+// function Loesen(lPos: integer): boolean;
+ function geloest: boolean;
+(* procedure leeren;
+ procedure RandErzeugen;
+ function anzLoesungen(lPos: integer): integer;
+ procedure Image2Bemalen; *)
+ end;
+
+{$IFDEF hochhaus}
+function zahlenAlphabetFunktion(i: longint): string;
+{$ENDIF}
+{$IFDEF buchstaben}
+function buchstabenAlphabetFunktion(i: longint): string;
+{$ENDIF}
+
+{$ENDIF}
+
+{$IFDEF alphabetFunktion}
+// function *AlphabetFunktion(i: longint): string;
+begin
+ if i<0 then
+ result:=''
+ else if i=0 then
+ result:='-'
+{$IFDEF hochhaus}
+ else
+ result:=inttostr(i);
+{$ENDIF}
+{$IFDEF buchstaben}
+ else begin
+ result:='';
+ while i>0 do begin
+ dec(i);
+ result:=char(ord('A')+(i mod 26))+result;
+ i:=i div 26;
+ end;
+ end;
+{$ENDIF}
+end;
+{$ENDIF}
+
+{$IFDEF create}
+// constructor tHochhausRaetsel.create(aOwner: tForm);
+begin
+{$IFDEF hochhaus}
+ inherited create(aOwner,1,@zahlenAlphabetFunktion);
+ spinEdits[1].showHint:=true;
+ spinEdits[1].hint:='Anzahl Spalten';
+ spinEdits[1].value:=5;
+{$ENDIF}
+{$IFDEF buchstaben}
+ inherited create(aOwner,2,@buchstabenAlphabetFunktion);
+ spinEdits[1].showHint:=true;
+ spinEdits[1].hint:='Anzahl Buchstaben';
+ spinEdits[1].value:=5;
+ spinEdits[2].showHint:=true;
+ spinEdits[2].hint:='Anzahl Leerfelder';
+ spinEdits[2].value:=1;
+{$ENDIF}
+ aktualisiereGroesze;
+end;
+{$ENDIF}
+
+{$IFDEF destroy}
+// destructor tHochhausRaetsel.destroy;
+begin
+ inherited destroy;
+end;
+{$ENDIF}
+
+{$IFDEF passt}
+// function tHochhausRaetsel.passt(spalte,zeile: integer): boolean;
+var
+ I,KZ,KS: Integer;
+ W,S,K: Longint;
+begin
+ W:=0;
+ S:=0;
+ K:=0;
+ if sudokuCB.checked then begin
+ KZ:=(Zeile div dim)*dim;
+ KS:=(Spalte div dim)*dim;
+ for I:=0 to dim-1 do begin
+ {$IFDEF buchstaben}
+ W:=W*(NBuchst+2)+inhalt[Zeile*dim+I]+1;
+ S:=S*(NBuchst+2)+inhalt[I*dim+Spalte]+1;
+ K:=K*(NBuchst+2)+inhalt[(KZ+(I div NSqrt))*dim+KS+(I mod NSqrt)]+1;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ W:=W*(dim+1)+inhalt[Zeile*dim+I];
+ S:=S*(dim+1)+inhalt[I*dim+Spalte];
+ K:=K*(dim+1)+inhalt[(KZ+(I div NSqrt))*dim+KS+(I mod NSqrt)];
+ {$ENDIF}
+ end;
+ result:=
+ {$IFDEF buchstaben}
+ AMoeglich[K*(NBuchst+1)] and
+ EMoeglich[S*(NBuchst+1)+Rand[Spalte]] and
+ AMoeglich[W*(NBuchst+1)+Rand[dim+Zeile]] and
+ AMoeglich[S*(NBuchst+1)+Rand[2*dim+Spalte]] and
+ EMoeglich[W*(NBuchst+1)+Rand[3*dim+Zeile]];
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ AMoeglich[K*(dim+1)] and
+ EMoeglich[S*(dim+1)+Rand[Spalte]] and
+ AMoeglich[W*(dim+1)+Rand[dim+Zeile]] and
+ AMoeglich[S*(dim+1)+Rand[2*dim+Spalte]] and
+ EMoeglich[W*(dim+1)+Rand[3*dim+Zeile]];
+ {$ENDIF}
+ end
+ else begin
+ for I:=0 to dim-1 do begin
+ {$IFDEF buchstaben}
+ W:=W*(NBuchst+2)+inhalt[Zeile*dim+I]+1;
+ S:=S*(NBuchst+2)+inhalt[I*dim+Spalte]+1;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ W:=W*(dim+1)+inhalt[Zeile*dim+I];
+ S:=S*(dim+1)+inhalt[I*dim+Spalte];
+ {$ENDIF}
+ end;
+ result:=
+ {$IFDEF buchstaben}
+ EMoeglich[S*(NBuchst+1)+Rand[Spalte]] and
+ AMoeglich[W*(NBuchst+1)+Rand[dim+Zeile]] and
+ AMoeglich[S*(NBuchst+1)+Rand[2*dim+Spalte]] and
+ EMoeglich[W*(NBuchst+1)+Rand[3*dim+Zeile]];
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ EMoeglich[S*(dim+1)+Rand[Spalte]] and
+ AMoeglich[W*(dim+1)+Rand[dim+Zeile]] and
+ AMoeglich[S*(dim+1)+Rand[2*dim+Spalte]] and
+ EMoeglich[W*(dim+1)+Rand[3*dim+Zeile]];
+ {$ENDIF}
+ end;
+ if diagonalenCB.checked then begin
+ if Zeile=Spalte then begin
+ W:=0;
+ {$IFDEF buchstaben}
+ for I:=0 to dim-1 do
+ W:=W*(NBuchst+2)+inhalt[I*(dim+1)]+1;
+ Result:=Result and AMoeglich[W*(NBuchst+1)];
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ for I:=0 to dim-1 do
+ W:=W*(dim+1)+inhalt[I*(dim+1)];
+ result:=result and AMoeglich[W*(dim+1)];
+ {$ENDIF}
+ end;
+ if Zeile+Spalte=dim-1 then begin
+ W:=0;
+ {$IFDEF buchstaben}
+ for I:=0 to dim-1 do
+ W:=W*(NBuchst+2)+inhalt[(I+1)*(dim-1)]+1;
+ Result:=Result and AMoeglich[W*(NBuchst+1)];
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ for I:=0 to dim-1 do
+ W:=W*(dim+1)+inhalt[(I+1)*(dim-1)];
+ Result:=Result and AMoeglich[W*(dim+1)];
+ {$ENDIF}
+ end;
+ end;
+end;
+{$ENDIF}
+
+{$IFDEF geloest}
+// function tHochhausRaetsel.geloest: boolean;
+var
+ i,j: integer;
+begin
+ result:=false;
+ for i:=0 to dim-1 do
+ for j:=0 to dim-1 do
+ if (not passt(i,j)) or (inhalt[i+dim*j]<0)
+ {$IFDEF hochhaus}
+ or (inhalt[I+dim*j]=0)
+ {$ENDIF}
+ then exit;
+ result:=true;
+end;
+{$ENDIF}
+
+{$IFDEF gesamtRaenderErzeugen}
+// procedure tHochhausRaetsel.gesamtRaenderErzeugen;
+var
+ I,J,K,Nullen: Integer;
+ {$IFNDEF buchstaben}
+ AZ,
+ {$ENDIF}
+ AR: Integer;
+ AK,EK,NAK,NEK: Longint;
+ Nums: tLongintArray;
+ B: Boolean;
+ Basis,Faktor: Integer;
+ Schritt: Longint;
+ dat: File of Cardinal;
+ lw1,lw2,L: Cardinal;
+
+const dat_name =
+{$IFDEF buchstaben}
+ 'Buchstabenraetsel.dat';
+{$ENDIF}
+{$IFDEF hochhaus}
+ 'Hochhausraetsel.dat';
+{$ENDIF}
+
+function calcNums(I: Longint): tLongintArray;
+var
+ J: Integer;
+begin
+ Setlength(Result,dim);
+ For J:=0 to dim-1 do begin
+ Result[J]:=I mod Basis;
+ I:=I div Basis;
+ end;
+end;
+
+function calcIndex(Nums: TLongintArray): Longint;
+var
+ j: integer;
+begin
+ Result:=0;
+ For j:=0 to dim-1 do
+ Result:=Result*Basis + Nums[dim-J-1];
+end;
+
+function swapIndex(I: Longint): Longint;
+var
+ j: integer;
+begin
+ Result:=0;
+ for J:=0 to dim-1 do begin
+ Result:=Result*Basis+(I mod Basis);
+ I:=I div Basis;
+ end;
+end;
+
+begin
+ {$IFDEF buchstaben}
+ Basis:=NBuchst+2;
+ Faktor:=NBuchst+1;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ Basis:=dim+1;
+ Faktor:=dim+1;
+ {$ENDIF}
+ AK:=round(power(Basis,dim)*Faktor);
+
+ if (length(AMoeglich) = AK) and
+ (length(EMoeglich) = AK) then
+ exit;
+
+ if fileexists(extractfilepath(application.exename)+dat_name) then begin
+ assignfile(dat,extractfilepath(application.exename)+dat_name);
+ reset(dat);
+ while not eof(dat) do begin
+ read(dat,lw1);
+ if lw1=AK then begin
+ Setlength(AMoeglich,AK);
+ Setlength(EMoeglich,AK);
+ for L:=0 to length(AMoeglich)-1 do begin
+ if L mod 32 = 0 then
+ if not eof(dat) then
+ read(dat,lw2)
+ else begin
+ messageDlg('Frühzeitiges Dateiende!',mterror,[mbOk],0);
+ exit;
+ end;
+ AMoeglich[L]:=odd(lw2 shr (L mod 32));
+ end;
+ For L:=0 to length(EMoeglich)-1 do begin
+ if L mod 32 = 0 then
+ if not eof(dat) then
+ read(dat,lw2)
+ else begin
+ messageDlg('Frühzeitiges Dateiende!',mterror,[mbOk],0);
+ exit;
+ end;
+ EMoeglich[L]:=odd(lw2 shr (L mod 32));
+ end;
+ exit;
+ end
+ else
+ Seek(dat,Filepos(dat)+((lw1-1) div 32 +1)*2);
+ end;
+ closefile(dat);
+ end;
+
+ Progressbar1.Visible:=true;
+ Progressbar1.Min:=0;
+ Progressbar1.Max:=1000;
+ Progressbar1.Position:=0;
+
+ Setlength(AMoeglich,AK);
+ Setlength(EMoeglich,AK);
+ For AK:=0 to length(AMoeglich)-1 do begin
+ AMoeglich[AK]:=False;
+ EMoeglich[AK]:=False;
+ end;
+ Setlength(Nums,0);
+
+ Schritt:=max(1,round((length(AMoeglich) div Faktor) / Progressbar1.Max));
+ For AK:=0 to length(AMoeglich) div Faktor -1 do begin
+ if AK mod Schritt = 0 then
+ Progressbar1.StepIt;
+ Nums:=calcNums(AK);
+ B:=true;
+ {$IFDEF buchstaben}
+ Nullen:=NLeer;
+ For I:=0 to length(Nums)-1 do
+ begin
+ B:=B and (Nums[I]<>0);
+ if Nums[I]=1 then dec(Nullen)
+ else
+ For J:=0 to I-1 do
+ B:=B and (Nums[I]<>Nums[J]);
+ end;
+ B:=B and (Nullen>=0);
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ For I:=0 to length(Nums)-1 do begin
+ B:=B and (Nums[I]<>0);
+ For J:=0 to I-1 do
+ B:=B and (Nums[I]<>Nums[J]);
+ end;
+ {$ENDIF}
+ if B then begin
+ EK:=swapIndex(AK);
+ AR:=0;
+ {$IFNDEF buchstaben}
+ AZ:=0;
+ {$ENDIF}
+ For I:=0 to dim-1 do begin
+ {$IFDEF buchstaben}
+ if Nums[I]>1 then begin
+ AR:=Nums[I]-1;
+ break;
+ end;
+ {$ENDIF}
+ {$IFDEF hochhaus}
+ if Nums[I]>AZ then begin
+ inc(AR);
+ AZ:=Nums[I];
+ end;
+ {$ENDIF}
+ end;
+
+ AMoeglich[AK*Faktor+AR]:=true;
+ EMoeglich[EK*Faktor+AR]:=true;
+ AMoeglich[AK*Faktor]:=true;
+ EMoeglich[EK*Faktor]:=true;
+ end;
+ end;
+
+ Progressbar1.Position:=0;
+ Schritt:=Max(round(((length(AMoeglich) div Faktor)*dim) / Progressbar1.Max),1);
+ For Nullen:=1 to dim do
+ For AK:=0 to length(AMoeglich) div Faktor -1 do begin
+ if AK mod Schritt = 0 then
+ Progressbar1.StepIt;
+ Nums:=calcNums(AK);
+ J:=Nullen;
+ For I:=0 to dim-1 do
+ if Nums[I]=0 then
+ dec(J);
+ if J<>0 then
+ continue;
+ EK:=swapIndex(AK);
+ For I:=0 to dim-1 do
+ if Nums[I]=0 then begin
+ For J:=1 to Basis-1 do begin
+ Nums[I]:=J;
+ NAK:=calcIndex(Nums);
+ NEK:=swapIndex(NAK);
+ For K:=0 to Faktor-1 do begin
+ AMoeglich[AK*Faktor+K]:=AMoeglich[AK*Faktor+K] or AMoeglich[NAK*Faktor+K];
+ EMoeglich[EK*Faktor+K]:=EMoeglich[EK*Faktor+K] or EMoeglich[NEK*Faktor+K];
+ end;
+ end;
+ break;
+ end;
+ end;
+ Progressbar1.Visible:=False;
+
+ assignfile(dat,extractfilepath(application.exename)+dat_name);
+ if Fileexists(extractfilepath(application.exename)+dat_name) then begin
+ reset(dat);
+ Seek(dat,Filesize(dat));
+ end
+ else
+ Rewrite(dat);
+
+ lw1:=length(AMoeglich);
+ write(dat,lw1);
+ lw1:=0;
+ For I:=0 to length(AMoeglich)-1 do begin
+ lw1:=lw1 or (Byte(AMoeglich[I]) shl (I mod 32));
+ if ((I mod 32) = 31) or (I = length(AMoeglich)-1) then begin
+ write(dat,lw1);
+ lw1:=0;
+ end;
+ end;
+ For I:=0 to length(EMoeglich)-1 do begin
+ lw1:=lw1 or (Byte(EMoeglich[I]) shl (I mod 32));
+ if ((I mod 32) = 31) or (I = length(EMoeglich)-1) then begin
+ write(dat,lw1);
+ lw1:=0;
+ end;
+ end;
+ closefile(dat);
+end;
+{$ENDIF}
diff --git a/raetselunit.pas b/raetselunit.pas
index dc6741c..5f1033b 100644
--- a/raetselunit.pas
+++ b/raetselunit.pas
@@ -6,36 +6,22 @@ interface
uses
Classes, SysUtils, Forms, Spin, Controls, StdCtrls, ExtCtrls, LCLType,
- lowlevelunit;
+ lowlevelunit, Messages, ComCtrls;
type
tAlphabetFunktion = function(i: longint): string;
- tFelderRaetsel = class;
-
- tFelderLoesMeta = class
+ tButtonWithArrowKeys = class(tButton)
private
- _inh: boolean;
- _perm: tLongintArray;
- _mgl: tInt64Array;
- _posi: longint;
- _fr: tFelderRaetsel;
- public
- constructor create(ib: boolean; fr: tFelderRaetsel);
- destructor destroy;
- function posi: longint;
- function fwd: boolean;
- procedure rev;
- property inhaltBehalten: boolean read _inh;
- procedure aktualisiereInhalt(p,alt: longint);
- procedure aktualisiereRand(p,alt: longint);
+ procedure WMGetDlgCode(var Msg: TWMGetDlgCode); message WM_GETDLGCODE;
end;
tRaetsel = class
private
besitzer: tForm;
zeichenflaeche: tImage;
- erzeugeBtn: tButton;
+ erzeugeBtn: tButtonWithArrowKeys;
+ progressbar1: tProgressBar;
function besitzerHoehe: longint; dynamic;
function besitzerBreite: longint; dynamic;
procedure zeichenFlaecheNeuKreieren;
@@ -43,19 +29,19 @@ type
procedure onMouseDown(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint); dynamic; abstract;
procedure erzeugeOnClick(sender: tObject);
procedure loeschen; dynamic; abstract;
- function loesen(inhaltBehalten: boolean): longint; dynamic; abstract;
procedure leeren; dynamic; abstract;
public
constructor create(aOwner: tForm);
destructor destroy; override;
- function gleichzeitigMoeglich(num: longint): longint; dynamic; abstract;
- function _loesen(lm: tFelderLoesMeta): longint; dynamic; abstract;
+ function loesen(inhaltBehalten: boolean; lPos: longint): longint; dynamic; abstract;
+ function passt(spalte,zeile: integer): boolean; dynamic; abstract;
+ function geloest: boolean; dynamic; abstract;
procedure zeichnen; dynamic; abstract;
end;
tFelderRaetsel = class(tRaetsel)
spinEdits: array of tSpinEdit;
- diagonalenCB: tCheckBox;
+ diagonalenCB,sudokuCB: tCheckBox;
groeszen,inhalt,rand: array of longint;
moeglich: array of int64;
dim,schriftGroesze,cursorPosition: longint;
@@ -66,7 +52,6 @@ type
procedure onMouseDown(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint); override;
procedure aktualisiereGroesze;
procedure loeschen; override;
- function loesen(inhaltBehalten: boolean): longint; override;
procedure leeren; override;
procedure aktualisiereZeichenflaechenGroesze;
function besitzerHoehe: longint; override;
@@ -80,114 +65,43 @@ type
procedure zeichnen; override;
end;
-const
- spacing = 2;
-
-implementation
-
-uses
- math;
-
-// tFelderLoesMeta *************************************************************
-
-constructor tFelderLoesMeta.create(ib: boolean; fr: tFelderRaetsel);
-var
- i: longint;
-begin
- inherited create;
- _fr:=fr;
- _inh:=ib;
- _perm:=permutation(length(fr.inhalt));
- setlength(_perm,length(_perm)+1);
- for i:=length(_perm)-1 downto 1 do
- _perm[i]:=_perm[i-1];
- _perm[0]:=-1;
- setlength(_mgl,length(fr.inhalt));
- _posi:=0;
-end;
+{$DEFINE interface}
-destructor tFelderLoesMeta.destroy;
-begin
- setlength(_perm,0);
- setlength(_mgl,0);
- inherited destroy;
-end;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
-function tFelderLoesMeta.posi: longint;
-begin
- result:=_perm[_posi];
-end;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
-function tFelderLoesMeta.fwd: boolean;
-begin
- result:=_posi<length(_perm);
- if result then
- inc(_posi);
-end;
+{$UNDEF interface}
-procedure tFelderLoesMeta.rev;
-begin
- dec(_posi);
-end;
+const
+ spacing = 2;
-procedure tFelderLoesMeta.aktualisiereInhalt(p,alt: longint);
-var
- i,j,x,y,cnt,neu: longint;
- maske: int64;
-begin
- // hier sollte die Zeile und Spalte von _mgl[p] aktualisiert werden
- x:=p mod _fr.dim;
- y:=p div _fr.dim;
- neu:=_fr.inhalt[p];
- if neu<>-1 then begin
- if alt<>-1 then begin
- _fr.inhalt[p]:=-1;
- aktualisiereInhalt(p,alt);
- _fr.inhalt[p]:=neu;
- alt:=-1;
- end;
- cnt:=_fr.gleichzeitigMoeglich(p);
- maske:=1 shr _fr.inhalt[p];
- _mgl[p]:=maske;
- if cnt>1 then begin
- j:=0;
- for i:=0 to _fr.dim-1 do
- j:=j+byte(_fr.inhalt[y*_fr.dim+i]=neu);
- if j>=cnt then
- for i:=0 to _fr.dim-2 do
- _mgl[i*_fr.dim+i+byte(i>=x)]:=_mgl[i*_fr.dim+i+byte(i>=x)] and not maske;
- j:=0;
- for i:=0 to _fr.dim-1 do
- j:=j+byte(_fr.inhalt[i*_fr.dim+x]=neu);
- if j>=cnt then
- for i:=0 to _fr.dim-2 do
- _mgl[(i+byte(i>=y))*_fr.dim+x]:=_mgl[(i+byte(i>=y))*_fr.dim+x] and not maske;
- // TODO: Diagonalen
- end
- else begin
- for i:=0 to _fr.dim-2 do begin
- _mgl[y*_fr.dim+i+byte(i>=x)]:=_mgl[y*_fr.dim+i+byte(i>=x)] and not maske;
- _mgl[(i+byte(i>=y))*_fr.dim+x]:=_mgl[(i+byte(i>=y))*_fr.dim+x] and not maske;
- end;
- // TODO: Diagonalen
- end;
- end
- else begin
- if alt=-1 then
- exit;
- maske:=1 shr alt;
- for i:=0 to _fr.dim-2 do begin
- _mgl[(i+byte(i>=y))*_fr.dim+x]:=_mgl[(i+byte(i>=y))*_fr.dim+x] or maske;
- _mgl[y*_fr.dim+x+byte(i>=x)]:=_mgl[y*_fr.dim+x+byte(i>=x)] or maske;
- end;
- // TODO: Diagonalen
- // TODO: _mgl[p]
- end;
-end;
+implementation
-procedure tFelderLoesMeta.aktualisiereRand(p,alt: longint);
+uses
+ math, dialogs;
+
+{$DEFINE alphabetFunktion}
+function zahlenAlphabetFunktion(i: longint): string;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+function buchstabenAlphabetFunktion(i: longint): string;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF alphabetFunktion}
+
+// tButtonWithArrowkeys ********************************************************
+
+procedure tButtonWithArrowkeys.WMGetDlgCode(var msg: tWMGetDLGCODE);// message WM_GETDLGCODE;
begin
- // hier sollte die Zeile bzw. Spalte von _rand[p] aktualisiert werden
+ inherited;
+ msg.Result := msg.Result or DLGC_WANTARROWS;
end;
// tRaetsel ********************************************************************
@@ -199,7 +113,7 @@ begin
zeichenflaeche:=tImage.create(besitzer);
zeichenflaeche.parent:=besitzer;
zeichenflaeche.onMouseDown:=@onMouseDown;
- erzeugeBtn:=tButton.create(besitzer);
+ erzeugeBtn:=tButtonWithArrowKeys.create(besitzer);
erzeugeBtn.parent:=besitzer;
erzeugeBtn.left:=spacing;;
erzeugeBtn.top:=spacing;;
@@ -243,7 +157,7 @@ end;
procedure tRaetsel.erzeugeOnClick(sender: tObject);
begin
loeschen;
- loesen(true);
+ loesen(true,-1);
leeren;
end;
@@ -285,6 +199,11 @@ begin
diagonalenCB.caption:='Diagonalen';
diagonalenCB.top:=erzeugeBtn.top+erzeugeBtn.height+spacing;
diagonalenCB.left:=spinEdits[length(spinEdits)-1].left+spinEdits[length(spinEdits)-1].width+spacing;
+ sudokuCB:=tCheckBox.create(besitzer);
+ sudokuCB.parent:=besitzer;
+ sudokuCB.caption:='Sudoku';
+ sudokuCB.top:=erzeugeBtn.top+erzeugeBtn.height+spacing;
+ sudokuCB.left:=diagonalenCB.left+diagonalenCB.width+spacing;
zeichenflaeche.left:=spacing;
zeichenflaeche.top:=diagonalenCB.top+diagonalenCB.height+spacing;
aktualisiereGroesze;
@@ -375,34 +294,19 @@ begin
rand[i]:=-1;
end;
-function tFelderRaetsel.loesen(inhaltBehalten: boolean): longint;
-var
- lm: tFelderLoesMeta;
-begin
- lm:=tFelderLoesMeta.create(inhaltBehalten,self);
- result:=_loesen(lm);
- lm.free;
-end;
-
procedure tFelderRaetsel.leeren;
var
p: tLongintArray;
i,w: longint;
-var
- lm: tFelderLoesMeta;
begin
- lm:=tFelderLoesMeta.create(false,self);
-
p:=permutation(dim*dim);
for i:=0 to length(p)-1 do begin
- if inhalt[p[i]]<0 then continue;
+ if inhalt[p[i]]<0 then
+ continue;
w:=inhalt[p[i]];
inhalt[p[i]]:=-1;
- lm.aktualisiereInhalt(p[i],w);
- if _loesen(lm)<>1 then begin
+ if loesen(false,-1)<>1 then
inhalt[p[i]]:=w;
- lm.aktualisiereInhalt(p[i],-1);
- end;
end;
p:=permutation((dim+1)*4);
@@ -410,13 +314,9 @@ begin
if rand[p[i]]<0 then continue;
w:=rand[p[i]];
rand[p[i]]:=-1;
- lm.aktualisiereRand(p[i],w);
- if _loesen(lm)<>1 then begin
+ if loesen(false,-1)<>1 then
rand[p[i]]:=w;
- lm.aktualisiereRand(p[i],-1);
- end;
end;
- lm.free;
end;
procedure tFelderRaetsel.aktualisiereZeichenflaechenGroesze;
@@ -456,11 +356,22 @@ end;
procedure tFelderRaetsel.schreibeZentriert(x,y,i: longint);
var
- br,ho: longint;
- s: string;
+ br,ho: longint;
+ s: string;
begin
s:=uebersetze(i);
with zeichenflaeche.canvas do begin
+ brush.color:=$FFFFFF - $181818*byte(diagonalenCB.checked and ((x=y) or (x+y=dim+1)));
+ if not passt(x,y) then
+ font.color:=$0000FF
+ else if geloest then
+ font.color:=$007F00
+// else if startFeld[x+y*dim] then
+// font.color:=$7F7F7F
+ else
+ font.color:=$000000;
+ // feldFarben[x+y*dim];
+
br:=textWidth(s);
ho:=textHeight(s);
textOut(
@@ -504,5 +415,61 @@ begin
schreibeZentriert(i mod dim,i div dim,inhalt[i]);
end;
+{$DEFINE create}
+constructor tHochhausRaetsel.create(aOwner: tForm);
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+
+constructor tBuchstabenRaetsel.create(aOwner: tForm);
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF create}
+
+{$DEFINE destroy}
+destructor tHochhausRaetsel.destroy;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+destructor tBuchstabenRaetsel.destroy;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF destroy}
+
+{$DEFINE passt}
+function tHochhausRaetsel.passt(spalte,zeile: integer): boolean;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+function tBuchstabenRaetsel.passt(spalte,zeile: integer): boolean;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF passt}
+
+{$DEFINE geloest}
+function tHochhausRaetsel.geloest: boolean;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+function tBuchstabenRaetsel.geloest: boolean;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF geloest}
+
+{$DEFINE gesamtRaenderErzeugen}
+procedure tHochhausRaetsel.gesamtRaenderErzeugen;
+{$DEFINE hochhaus}
+{$I raetselunit.inc}
+{$UNDEF hochhaus}
+procedure tBuchstabenRaetsel.gesamtRaenderErzeugen;
+{$DEFINE buchstaben}
+{$I raetselunit.inc}
+{$UNDEF buchstaben}
+{$UNDEF gesamtRaenderErzeugen}
+
end.
diff --git a/unit1.lfm b/unit1.lfm
index e06801d..c16f297 100644
--- a/unit1.lfm
+++ b/unit1.lfm
@@ -1,7 +1,7 @@
object Form1: TForm1
- Left = 1722
+ Left = 740
Height = 313
- Top = 389
+ Top = 407
Width = 426
BorderStyle = bsSingle
Caption = 'Rätsel'
diff --git a/unit1.pas b/unit1.pas
index d9e333a..27ec7c2 100644
--- a/unit1.pas
+++ b/unit1.pas
@@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
- raetselunit;
+ raetselunit, StdCtrls, Messages, LCLType;
type
@@ -18,6 +18,7 @@ type
procedure FormShow(Sender: TObject);
private
{ private declarations }
+ procedure WMGetDlgCode(var msg: tMessage); message WM_GETDLGCODE;
public
{ public declarations }
raetsel: tRaetsel;
@@ -31,10 +32,16 @@ implementation
{$R *.lfm}
uses
- unit2, hochhausunit, buchstabenunit;
+ unit2;
// tForm1 **********************************************************************
+procedure tForm1.WMGetDlgCode(var msg: tMessage);// message WM_GETDLGCODE;
+begin
+ inherited;
+ msg.result := msg.result or DLGC_WANTARROWS;
+end;
+
procedure tForm1.formCreate(sender: tObject);
begin
application.createForm(tForm2, form2);
diff --git a/unit2.lfm b/unit2.lfm
index 42ae4b3..58ec92f 100644
--- a/unit2.lfm
+++ b/unit2.lfm
@@ -1,12 +1,12 @@
object Form2: TForm2
- Left = 1690
+ Left = 820
Height = 94
- Top = 197
+ Top = 493
Width = 192
Caption = 'Rätsel'
ClientHeight = 94
ClientWidth = 192
- LCLVersion = '1.6.0.4'
+ LCLVersion = '1.8.4.0'
object Button1: TButton
Left = 16
Height = 25