summaryrefslogtreecommitdiff
path: root/raetselunit.pas
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-10-01 22:27:14 +0200
committerErich Eckner <git@eckner.net>2018-10-01 22:27:14 +0200
commit717b9418c82503d4eea96b2e736ba23e7134a1e3 (patch)
treeb5734efe15f4628cb64136aa5a2cfb5037a8450c /raetselunit.pas
parentf6e4306d5b6faa060b89e46f3a79636270b49359 (diff)
downloadRaetsel-717b9418c82503d4eea96b2e736ba23e7134a1e3.tar.xz
Spielnummern neu
Diffstat (limited to 'raetselunit.pas')
-rw-r--r--raetselunit.pas24
1 files changed, 21 insertions, 3 deletions
diff --git a/raetselunit.pas b/raetselunit.pas
index 4e0ffae..04052b9 100644
--- a/raetselunit.pas
+++ b/raetselunit.pas
@@ -4,8 +4,6 @@ unit raetselunit;
interface
-// TODO: Spielnummernzufall
-
// TODO: Cross-Compilieren
uses
@@ -32,6 +30,8 @@ type
vorherMalFarbe: TColor;
end;
+ tOnSetCaption = procedure(c: string) of object;
+
tRaetsel = class
private
besitzer: tForm;
@@ -40,6 +40,7 @@ type
erzeugeBtn,
speichernBtn,
ladenBtn: tButtonWithArrowKeys;
+ zufallSE: tSpinEdit;
progressbar1: tProgressBar;
aktuelleFarbe: tColor;
function besitzerHoehe: longint; dynamic;
@@ -66,6 +67,7 @@ type
procedure speichern(var datei: file); dynamic;
procedure laden(var datei: file); dynamic;
public
+ onSetCaption: tOnSetCaption;
constructor create(aOwner: tForm);
destructor destroy; override;
procedure zeichnen; dynamic; abstract;
@@ -230,6 +232,16 @@ begin
ladenBtn.caption:='Laden!';
ladenBtn.onClick:=@ladenOnClick;
ladenBtn.onKeyDown:=@onKeyDown;
+ zufallSE:=tSpinEdit.create(besitzer);
+ zufallSE.parent:=besitzer;
+ zufallSE.top:=erzeugeBtn.top+erzeugeBtn.height+spacing;
+ zufallSE.left:=spacing;
+ zufallSE.width:=64;
+ zufallSE.minValue:=0;
+ zufallSE.maxValue:=99999;
+ zufallSE.value:=random(zufallSE.maxValue+1);
+ zufallSE.showHint:=true;
+ zufallSE.hint:='Nummer';
progressbar1:=tProgressBar.create(besitzer);
progressbar1.visible:=false;
progressbar1.parent:=besitzer;
@@ -312,6 +324,10 @@ end;
procedure tRaetsel.erzeugeOnClick(sender: tObject);
begin
loeschen;
+ randSeed:=zufallSE.value;
+ if assigned(onSetCaption) then
+ onSetCaption(intToStr(zufallSE.value));
+ zufallSE.value:=random(zufallSE.maxValue+1);
loesen(-1);
randErzeugen;
leeren;
@@ -396,7 +412,9 @@ begin
with spinEdits[i] do begin
parent:=besitzer;
top:=erzeugeBtn.top+erzeugeBtn.height+spacing;
- if i>0 then begin
+ if i=0 then
+ left:=zufallSE.left + zufallSE.width
+ else begin
left:=spinEdits[i-1].left + spinEdits[i-1].width;
value:=groeszen[i-1];
end;