Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Krabourn,
I nearly forgot that I did something similar once in a subform regarding Highscores (The script is not published yet because of some missing functionality in kixforms regarding ImageLists)
Just hacked together the parts so that it will work ... The 3 columns there are a ListView (Data is stored in an ini file) as soon the actual score is below a HighScore for that specific level it lets you edit your name (A TextBox over the ListView SubItem) ... Maybe not exactly what you try but a start anyway ?
break on
$ini = @scriptdir + '\test.ini' $moves = 45 $Pieces = 9
$HS = 50,Anonymus,100,Anonymus,150,Anonymus
dim $highscore, $frmWin, $s, $txt, $pos, $top Global $item0, $item1, $item2
$frmWin = createobject("Kixtart.Form") $frmWin.Size = 250,135 $frmWin.Left = $frm.CLientWidth /2 - $frmWin.ClientWidth /2 $frmWin.Top = $frm.CLientHeight/2 - $frmWin.ClientHeight/2
$btnOK = $frmWin.Button("OK",$frmWin.ClientWidth/2+15,$frmWin.Clientheight-30,75,20) $btnOK.onclick = "$$frmWin.Hide"
$btnReset = $frmWin.Button("Reset Highscore",$frmWin.ClientWidth/2-90,$frmWin.Clientheight-30,90,20) $btnReset.onclick = "ResetHighScores(1)"
$lbl = $frmWin.Label("",140,5,100,15) $lbl.ForeColor = KiXtart
$lvw = $frmWin.ListView("",20,20,210,45) $lvw.enabled = 0 $lvw.View = 3 $lvw.BorderStyle = 0 $lvw.HeaderStyle = 0 $lvw.BackColor = $frmWin.BackColor $ = $lvw.Columns.add("",75,1) $ = $lvw.Columns.add("",45,1) $ = $lvw.Columns.add("",90,0) $item0 = $lvw.Items.Add("9 Pieces") $item1 = $lvw.Items.Add("16 Pieces") $item2 = $lvw.Items.Add("25 Pieces")
for $i = 0 to 4 step 2 $ = execute("$$item"+($i-$s)+".SubItems(1).Text = " + $HS[$i]) $ = execute("$$item"+($i-$s)+".SubItems(2).Text = " + $HS[$i+1]) $s = $s + 1 next
$highscore = CheckHighScore($moves,$Pieces) if $highscore $btnReset.Enabled = 0 $frmWin.Caption = "Highscore - $pieces Pieces" select case $Pieces = 9 $pos = 0 $top = 20 $HS[0] = $moves case $Pieces = 16 $pos = 1 $top = 35 $HS[2] = $moves case $Pieces = 25 $pos = 2 $top = 50 $HS[4] = $moves endselect $lbl.Caption = "Enter your name ..." $txtName = $frmWin.TextBox("",144,$top,100,18) $txtName.BorderStyle = 0 $txtName.BackColor = $frmWin.BackColor $txtName.OnLostFocus = "UpdateHighscores($$pieces)" $txtName.OnKeyDown = "if $$txtName.KeyCode=13 UpdateHighscores($$pieces) endif" $ = execute("$$item$pos.SubItems(1).Text = $$moves") $ = execute("$$item$pos.SubItems(2).Text = ''") $txtName.SetFocus else $frmWin.Caption = "Your Score : $moves moves" $btnOk.Default = 1 endif
$frmWin.Show while $frmWin.Visible $ = execute($frmWin.DoEvents)
function CheckHighScore($m,$p) select case $p = 9 and $m < $HS[0] $CheckHighScore = 1 case $p = 16 and $m < $HS[2] $CheckHighScore = 1 case $p = 25 and $m < $HS[4] $CheckHighScore = 1 endselect endfunction
function UpdateHighscores($p) dim $o $txtName.Hide select case $p = 9 $HS[1] = $txtName.Text $item0.SubItems(2).Text = $HS[1] case $p = 16 $HS[3] = $txtName.Text $item1.SubItems(2).Text = $HS[3] case $p = 25 $HS[5] = $txtName.Text $item2.SubItems(2).Text = $HS[5] endselect $o = join($HS,',') $ = writeprofilestring($ini,'Global','HighScores',$o) $btnReset.Enabled = 1 $btnOK.Default = 1 $lbl.Caption = "" endfunction
function ResetHighscores(optional $display) $ = writeprofilestring($ini,'Global','HighScores','50,Anonymus,100,Anonymus,150,Anonymus') $HS = split(readprofilestring($ini,'Global','HighScores'),',') for $i = 0 to ubound($HS) if not $HS[$i] $HS[$i] = "Anonymus" endif next if $display dim $s for $i = 0 to 4 step 2 $ = execute("$$item"+($i-$s)+".SubItems(1).Text = " + $HS[$i]) $ = execute("$$item"+($i-$s)+".SubItems(2).Text = " + $HS[$i+1]) $s = $s + 1 next endif endfunction
_________________________
|