diff options
-rw-r--r-- | raetsel.lps | 129 | ||||
-rw-r--r-- | raetselunit.inc | 12 | ||||
-rw-r--r-- | raetselunit.pas | 45 |
3 files changed, 114 insertions, 72 deletions
diff --git a/raetsel.lps b/raetsel.lps index f3f7fdc..f45239f 100644 --- a/raetsel.lps +++ b/raetsel.lps @@ -9,7 +9,7 @@ <IsPartOfProject Value="True"/> <EditorIndex Value="2"/> <CursorPos X="35" Y="10"/> - <UsageCount Value="53"/> + <UsageCount Value="55"/> <Loaded Value="True"/> </Unit0> <Unit1> @@ -18,9 +18,9 @@ <ComponentName Value="Form1"/> <HasResources Value="True"/> <ResourceBaseClass Value="Form"/> - <TopLine Value="32"/> + <TopLine Value="28"/> <CursorPos Y="52"/> - <UsageCount Value="53"/> + <UsageCount Value="55"/> <Loaded Value="True"/> <LoadedDesigner Value="True"/> </Unit1> @@ -31,28 +31,26 @@ <HasResources Value="True"/> <ResourceBaseClass Value="Form"/> <UnitName Value="Unit2"/> - <EditorIndex Value="4"/> - <CursorPos X="20" Y="12"/> - <UsageCount Value="52"/> - <Loaded Value="True"/> - <LoadedDesigner Value="True"/> + <EditorIndex Value="-1"/> + <CursorPos Y="17"/> + <UsageCount Value="54"/> </Unit2> <Unit3> <Filename Value="raetselunit.pas"/> <IsPartOfProject Value="True"/> <IsVisibleTab Value="True"/> <EditorIndex Value="1"/> - <CursorPos X="27" Y="9"/> - <UsageCount Value="47"/> + <CursorPos Y="7"/> + <UsageCount Value="49"/> <Loaded Value="True"/> </Unit3> <Unit4> <Filename Value="raetselunit.inc"/> <IsPartOfProject Value="True"/> <EditorIndex Value="3"/> - <TopLine Value="698"/> - <CursorPos X="40" Y="723"/> - <UsageCount Value="33"/> + <TopLine Value="704"/> + <CursorPos X="46" Y="725"/> + <UsageCount Value="35"/> <Loaded Value="True"/> </Unit4> <Unit5> @@ -91,10 +89,10 @@ <HasResources Value="True"/> <ResourceBaseClass Value="Form"/> <UnitName Value="Unit1"/> - <EditorIndex Value="5"/> - <TopLine Value="655"/> - <CursorPos X="62" Y="688"/> - <UsageCount Value="17"/> + <EditorIndex Value="4"/> + <TopLine Value="2341"/> + <CursorPos X="13" Y="2380"/> + <UsageCount Value="19"/> <Loaded Value="True"/> </Unit10> <Unit11> @@ -128,121 +126,124 @@ </Units> <JumpHistory Count="30" HistoryIndex="29"> <Position1> - <Filename Value="raetselunit.pas"/> - <Caret Line="346" Column="34" TopLine="344"/> + <Filename Value="ori_Unit1.pas"/> + <Caret Line="98" Column="16" TopLine="63"/> </Position1> <Position2> - <Filename Value="raetselunit.pas"/> - <Caret Line="48" Column="27" TopLine="30"/> + <Filename Value="ori_Unit1.pas"/> + <Caret Line="405" Column="13" TopLine="370"/> </Position2> <Position3> - <Filename Value="raetselunit.pas"/> - <Caret Line="271" Column="15" TopLine="239"/> + <Filename Value="ori_Unit1.pas"/> + <Caret Line="690" Column="17" TopLine="654"/> </Position3> <Position4> - <Filename Value="raetselunit.inc"/> - <Caret Line="548" Column="50" TopLine="513"/> + <Filename Value="ori_Unit1.pas"/> + <Caret Line="712" Column="56" TopLine="676"/> </Position4> <Position5> - <Filename Value="raetselunit.inc"/> - <Caret Line="556" Column="21" TopLine="554"/> + <Filename Value="ori_Unit1.pas"/> + <Caret Line="715" Column="17" TopLine="680"/> </Position5> <Position6> - <Filename Value="raetselunit.pas"/> - <Caret Line="668" Column="22" TopLine="630"/> + <Filename Value="ori_Unit1.pas"/> + <Caret Line="730" Column="56" TopLine="695"/> </Position6> <Position7> - <Filename Value="raetselunit.pas"/> + <Filename Value="ori_Unit1.pas"/> + <Caret Line="749" Column="60" TopLine="714"/> </Position7> <Position8> - <Filename Value="raetselunit.pas"/> - <Caret Line="48" Column="27" TopLine="15"/> + <Filename Value="ori_Unit1.pas"/> + <Caret Line="752" Column="21" TopLine="717"/> </Position8> <Position9> - <Filename Value="raetselunit.pas"/> - <Caret Line="273" Column="4" TopLine="242"/> + <Filename Value="ori_Unit1.pas"/> + <Caret Line="765" Column="61" TopLine="730"/> </Position9> <Position10> <Filename Value="ori_Unit1.pas"/> - <Caret Line="76" Column="14" TopLine="44"/> + <Caret Line="768" Column="22" TopLine="733"/> </Position10> <Position11> <Filename Value="ori_Unit1.pas"/> - <Caret Line="393" Column="21" TopLine="361"/> + <Caret Line="779" Column="61" TopLine="744"/> </Position11> <Position12> <Filename Value="ori_Unit1.pas"/> - <Caret Line="443" Column="21" TopLine="410"/> + <Caret Line="782" Column="22" TopLine="747"/> </Position12> <Position13> <Filename Value="ori_Unit1.pas"/> - <Caret Line="474" Column="21" TopLine="466"/> + <Caret Line="1869" Column="13" TopLine="1833"/> </Position13> <Position14> - <Filename Value="ori_Unit1.pas"/> - <Caret Line="483" Column="13" TopLine="466"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="391" TopLine="370"/> </Position14> <Position15> - <Filename Value="raetselunit.pas"/> - <Caret Line="65" Column="6" TopLine="37"/> + <Filename Value="raetselunit.inc"/> + <Caret Line="703" Column="41" TopLine="698"/> </Position15> <Position16> - <Filename Value="raetselunit.pas"/> - <Caret Line="45" Column="31" TopLine="38"/> + <Filename Value="raetselunit.inc"/> + <Caret Line="11" Column="39"/> </Position16> <Position17> - <Filename Value="ori_Unit1.pas"/> - <Caret Line="574" Column="28" TopLine="541"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="391" TopLine="355"/> </Position17> <Position18> - <Filename Value="ori_Unit1.pas"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="661" TopLine="640"/> </Position18> <Position19> - <Filename Value="ori_Unit1.pas"/> - <Caret Line="108" Column="31" TopLine="38"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="49" Column="24" TopLine="27"/> </Position19> <Position20> - <Filename Value="ori_Unit1.pas"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="85" Column="24" TopLine="49"/> </Position20> <Position21> <Filename Value="raetselunit.pas"/> - <Caret Line="531" Column="19" TopLine="504"/> + <Caret Line="212" Column="35" TopLine="177"/> </Position21> <Position22> - <Filename Value="raetselunit.inc"/> - <Caret Line="633" Column="42" TopLine="621"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="325" Column="39" TopLine="290"/> </Position22> <Position23> - <Filename Value="raetselunit.inc"/> - <Caret Line="11" Column="39"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="339" Column="33" TopLine="304"/> </Position23> <Position24> <Filename Value="raetselunit.pas"/> - <Caret Line="66" Column="50" TopLine="109"/> + <Caret Line="351" Column="37" TopLine="317"/> </Position24> <Position25> <Filename Value="raetselunit.pas"/> - <Caret Line="67" Column="14" TopLine="47"/> + <Caret Line="357" Column="33" TopLine="323"/> </Position25> <Position26> <Filename Value="raetselunit.pas"/> - <Caret Line="420" Column="22" TopLine="394"/> + <Caret Line="382" Column="35" TopLine="369"/> </Position26> <Position27> <Filename Value="raetselunit.pas"/> - <Caret Line="441" Column="14" TopLine="421"/> + <Caret Line="389" Column="59" TopLine="368"/> </Position27> <Position28> <Filename Value="raetselunit.pas"/> - <Caret Line="524" Column="20" TopLine="515"/> + <Caret Line="660" Column="56" TopLine="625"/> </Position28> <Position29> - <Filename Value="ori_Unit1.pas"/> - <Caret Line="29" Column="21" TopLine="10"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="35" Column="12" TopLine="12"/> </Position29> <Position30> - <Filename Value="ori_Unit1.pas"/> - <Caret Line="31" Column="22" TopLine="10"/> + <Filename Value="raetselunit.pas"/> + <Caret Line="655" Column="42" TopLine="640"/> </Position30> </JumpHistory> </ProjectSession> diff --git a/raetselunit.inc b/raetselunit.inc index 634a672..b0d85d1 100644 --- a/raetselunit.inc +++ b/raetselunit.inc @@ -675,6 +675,7 @@ end; begin if (cursorPosition<0) or (cursorPosition>=dim*dim) or startfeld[cursorPosition] then exit; + alsZugSpeichern; {$IFDEF hochhaus} if inhalt[cursorPosition]=-1 then inhalt[cursorPosition]:=0; @@ -684,10 +685,7 @@ begin if inhalt[cursorPosition]=0 then inhalt[cursorPosition]:=-1; {$ENDIF} - if inhalt[cursorPosition]=-1 then - feldFarben[cursorPosition]:=$000000 - else - feldFarben[cursorPosition]:=aktuelleFarbe; + feldFarben[cursorPosition]:=aktuelleFarbe; end; {$ENDIF} @@ -701,11 +699,13 @@ begin result:=true; {$IFDEF buchstaben} if (key>=ord('A')) and (key<=min(ord('A')+groeszen[0]-1,ord('Z'))) then begin + alsZugSpeichern; inhalt[cursorPosition]:=key-ord('A')+1; feldFarben[cursorPosition]:=aktuelleFarbe; exit; end; if (key in [109,189]) then begin + alsZugSpeichern; inhalt[cursorPosition]:=0; feldFarben[cursorPosition]:=aktuelleFarbe; exit; @@ -713,14 +713,16 @@ begin {$ENDIF} {$IFDEF hochhaus} if (key>=ord('1')) and (key<=min(ord('1')+groeszen[0]-1,ord('9'))) then begin + alsZugSpeichern; inhalt[cursorPosition]:=key-ord('1')+1; feldFarben[cursorPosition]:=aktuelleFarbe; exit; end; {$ENDIF} if (key=ord(' ')) or (key=46) or (key=8) then begin + alsZugSpeichern; inhalt[cursorPosition]:=-1; - feldFarben[cursorPosition]:=$000000; + feldFarben[cursorPosition]:=aktuelleFarbe; exit; end; result:=false; diff --git a/raetselunit.pas b/raetselunit.pas index 4615ddd..c43d0f0 100644 --- a/raetselunit.pas +++ b/raetselunit.pas @@ -4,7 +4,9 @@ unit raetselunit; interface -// TODO: Rückgängig +// TODO: Speichern/Laden + +// TODO: Spielnummernzufall // TODO: Cross-Compilieren @@ -24,6 +26,14 @@ type function width: longint; end; + tZug = record + Position: integer; + Vorher: integer; + vorherFarbe, + nachherFarbe, + vorherMalFarbe: TColor; + end; + tRaetsel = class private besitzer: tForm; @@ -69,6 +79,7 @@ type uebersetze: tAlphabetFunktion; FeldFarben: array of tColor; startfeld: array of boolean; + zuege: array of tZug; 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; @@ -83,6 +94,7 @@ type function absoluteInhaltsAenderung(key: word): boolean; dynamic; abstract; procedure gesamtRaenderErzeugen; dynamic; abstract; procedure startfelderfestlegen; override; + procedure alsZugSpeichern; public constructor create(aOwner: tForm; anzInhTypen: longint; alphabetFunktion: tAlphabetFunktion); destructor destroy; override; @@ -273,8 +285,6 @@ begin end; procedure tRaetsel.erzeugeOnClick(sender: tObject); -var - i: longint; begin loeschen; loesen(-1); @@ -370,6 +380,19 @@ end; procedure tFelderRaetsel.onKeyDown(sender: tObject; var key: word; shiftState: tShiftState); begin + if ssCtrl in shiftState then begin + if (Key=ord('Z')) and (length(Zuege)>0) then begin + cursorPosition:=Zuege[length(Zuege)-1].Position; + inhalt[cursorPosition]:=Zuege[length(Zuege)-1].Vorher; + FeldFarben[cursorPosition]:=Zuege[length(Zuege)-1].VorherFarbe; + aktuelleFarbe:=Zuege[length(Zuege)-1].VorherMalFarbe; + setlength(Zuege,length(Zuege)-1); + farbWahlFlaecheBemalen; + end; + Zeichnen; + exit; + end; + if not absoluteInhaltsAenderung(key) then case key of VK_DOWN: @@ -440,6 +463,8 @@ procedure tFelderRaetsel.loeschen; var i: longint; begin + aktuelleFarbe:=$000000; + setlength(zuege,0); for i:=0 to length(inhalt)-1 do begin inhalt[i]:=-1; startFeld[i]:=true; @@ -447,6 +472,7 @@ begin end; for i:=0 to length(rand)-1 do rand[i]:=-1; + farbWahlFlaecheBemalen; end; procedure tFelderRaetsel.leeren; @@ -624,6 +650,19 @@ begin startfeld[i]:=inhalt[i]>=0; end; +procedure tFelderRaetsel.alsZugSpeichern; +begin + setLength(zuege,length(zuege)+1); + zuege[length(zuege)-1].position:=cursorPosition; + zuege[length(zuege)-1].vorher:=inhalt[cursorPosition]; + zuege[length(zuege)-1].vorherFarbe:=feldFarben[cursorPosition]; + zuege[length(zuege)-1].nachherFarbe:=aktuelleFarbe; + if length(zuege)=1 then + zuege[length(zuege)-1].vorherMalFarbe:=$000000 + else + zuege[length(zuege)-1].vorherMalFarbe:=zuege[length(zuege)-2].nachherFarbe; +end; + {$DEFINE create} constructor tHochhausRaetsel.create(aOwner: tForm); {$DEFINE hochhaus} |