From be4dbd37f218d219232c3a75ec772b940ad506e0 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 1 Oct 2018 16:27:46 +0200 Subject: sollte funktionieren - modulo gui-Macken --- raetsel.lps | 115 +++++++++++++++++++++++++++----------------------------- raetselunit.inc | 8 +++- raetselunit.pas | 36 ++++++++++++++---- 3 files changed, 91 insertions(+), 68 deletions(-) diff --git a/raetsel.lps b/raetsel.lps index aaeac78..3e553c1 100644 --- a/raetsel.lps +++ b/raetsel.lps @@ -40,19 +40,19 @@ + - - + + - - - + + @@ -93,8 +93,8 @@ - - + + @@ -130,123 +130,120 @@ - + - + - + - - + + - - + + - - + + - + - + - - + + - - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + - - + + - - + - - + + - + - + - - + + - - + + - - + + - + diff --git a/raetselunit.inc b/raetselunit.inc index 3176ade..b3eb1c5 100644 --- a/raetselunit.inc +++ b/raetselunit.inc @@ -653,7 +653,7 @@ begin end; {$IFDEF buchstaben} if inhalt[J+dim*I]=0 then continue; - Rand[dim+I]:=inhalt[J+dim*I]; + Rand[3*dim+I]:=inhalt[J+dim*I]; break; {$ENDIF} {$IFDEF hochhaus} @@ -673,7 +673,7 @@ end; {$IFDEF relativeInhaltsAenderung} // procedure tHochhausRaetsel.relativeInhaltsAenderung(diff: longint); begin - if (cursorPosition<0) or (cursorPosition>=dim*dim) then + if (cursorPosition<0) or (cursorPosition>=dim*dim) or startfeld[cursorPosition] then exit; {$IFDEF hochhaus} if inhalt[cursorPosition]=-1 then @@ -690,6 +690,10 @@ end; {$IFDEF absoluteInhaltsAenderung} // function tHochhausRaetsel.absoluteInhaltsAenderung(key: word): boolean; begin + if (cursorPosition<0) or (cursorPosition>=dim*dim) or startfeld[cursorPosition] then begin + result:=false; + exit; + end; result:=true; {$IFDEF buchstaben} if (key>=ord('A')) and (key<=min(ord('A')+groeszen[0]-1,ord('Z'))) then begin diff --git a/raetselunit.pas b/raetselunit.pas index 19306a8..e5a8cee 100644 --- a/raetselunit.pas +++ b/raetselunit.pas @@ -46,6 +46,7 @@ type function passt(spalte,zeile: integer): boolean; dynamic; abstract; function geloest: boolean; dynamic; abstract; procedure randErzeugen; dynamic; abstract; + procedure startfelderFestlegen; dynamic; abstract; public constructor create(aOwner: tForm); destructor destroy; override; @@ -62,6 +63,8 @@ type cursorPosition: longint; zellGroesze: extended; uebersetze: tAlphabetFunktion; + FeldFarben: array of tColor; + startfeld: array of boolean; procedure anzSEsOnChange(sender: tObject); procedure onKeyDown(sender: tObject; var key: word; shiftState: tShiftState); override; procedure onMouseDown(sender: tObject; button: tMouseButton; shiftState: tShiftState; x,y: longint); override; @@ -75,6 +78,7 @@ type procedure relativeInhaltsAenderung(diff: longint); dynamic; abstract; function absoluteInhaltsAenderung(key: word): boolean; dynamic; abstract; procedure gesamtRaenderErzeugen; dynamic; abstract; + procedure startfelderfestlegen; override; public constructor create(aOwner: tForm; anzInhTypen: longint; alphabetFunktion: tAlphabetFunktion); destructor destroy; override; @@ -265,12 +269,14 @@ begin end; procedure tRaetsel.erzeugeOnClick(sender: tObject); +var + i: longint; begin loeschen; loesen(-1); randErzeugen; leeren; - // TODO: Startfelder setzen + startFelderFestlegen; zeichnen; end; @@ -411,6 +417,8 @@ begin dim:=dim+groeszen[i]; end; setlength(inhalt,dim*dim); + setlength(startfeld,dim*dim); + setlength(feldFarben,dim*dim); setlength(rand,4*dim); NSqrt:=round(sqrt(dim)); @@ -428,8 +436,11 @@ procedure tFelderRaetsel.loeschen; var i: longint; begin - for i:=0 to length(inhalt)-1 do + for i:=0 to length(inhalt)-1 do begin inhalt[i]:=-1; + startFeld[i]:=true; + feldFarben[i]:=$000000; + end; for i:=0 to length(rand)-1 do rand[i]:=-1; end; @@ -519,16 +530,19 @@ var begin s:=uebersetze(i); with zeichenflaeche.canvas do begin - brush.color:=$FFFFFF - $181818*byte(diagonalenCB.checked and ((x=y) or (x+y=dim+1))); + brush.color:=$FFFFFF; + if (x>=0) and (y>=0) and (x=dim) or (y>=dim) then + font.color:=$000000 + else if startFeld[x+y*dim] then + font.color:=$7F7F7F else - font.color:=$000000; - // feldFarben[x+y*dim]; + font.color:=feldFarben[x+y*dim]; br:=textWidth(s); ho:=textHeight(s); @@ -598,6 +612,14 @@ begin schreibeZentriert(i mod dim,i div dim,inhalt[i]); end; +procedure tFelderRaetsel.startfelderfestlegen; +var + i: longint; +begin + for i:=0 to length(inhalt)-1 do + startfeld[i]:=inhalt[i]>=0; +end; + {$DEFINE create} constructor tHochhausRaetsel.create(aOwner: tForm); {$DEFINE hochhaus} -- cgit v1.2.3-54-g00ecf