Вот как делал я:
Сначала в какой-нибудь процедуре типа init пишешь
ScrW:=GetWidth;
ScrH:=GetHeight;
scores_rs:=OpenRecordStore('scores');
//Если нет Highscores, то заполняем таблицу Романами
if GetRecordStoreSize(scores_rs)=0 then
begin
for i:=1 to 10 do h:=AddRecordStoreEntry(scores_rs,'Roman$'+IntegerToString((11-i)*5000));
end;
Процедура для записи нового рекорда:
procedure AddHighscore; //Запрос имени игрока для занесения в таблицу рекордов
var
i,place: integer;
scores: array[1..10] of integer;
TextId: integer;
ok: command;
begin
for i:=1 to 10 do scores[i]:=StringToInteger(Copy(ReadRecordStoreEntry(scores_rs,i),
Pos(ReadRecordStoreEntry(scores_rs,i),'$')+1,
Length(ReadRecordStoreEntry(scores_rs,i)))); //Считываем таблицу из Record store
if player1.score>scores[10] then //Если место выше 10-го
begin
ClearForm;
ShowForm;
SetFormTitle('Круто!');
TextId:=FormAddImage(LoadImage('/ThumbUp.png'));
TextId:=FormAddTextField('Введите ваше имя:','',5,TF_ANY);
ok:=CreateCommand('OK',CM_OK,1);
AddCommand(ok);
while GetClickedCommand<>ok do Delay(100);
for i:=10 downto 1 do if player1.score>scores[i] then place:=i; //Вычисляем занятое место
for i:=9 downto place do //Переносим часть таблицы вниз
ModifyRecordStoreEntry(scores_rs,ReadRecordStoreEntry(scores_rs,i),i+1);
//И вписываем имя игрока!
ModifyRecordStoreEntry(scores_rs,FormGetText(TextId)+'$'+IntegerToString(player1.score),place);
ShowCanvas;
end;
RemoveCommand(ok);
HighScores; //Показываем рекорды
end;
Процедура для считывания и отображения рекордов:
procedure Highscores; //Рекорды
var
i:integer;
WinX,WinY,WinW,WinH: integer; //Координаты "окна" рекордов
s: string;
back: command;
begin
Font(0);
WinW:=128;
WinH:=font32.TextHeight*10+6;
WinX:=(ScrW-WinW) div 2;
WinY:=(ScrH-WinH) div 2;
SetColor(200,200,0);
FillRect(0,0,ScrW,ScrH);
SetColor(200,200,200);
FillRoundRect(WinX,WinY,WinW,WinH,6,6);
SetColor(0,0,0);
DrawRoundRect(WinX,WinY,WinW,WinH,6,6);
for i:=1 to 10 do //Рисуем таблицу рекордов
begin
s:=ReadRecordStoreEntry(scores_rs,i);
font32.DrawString(IntegerToString(i)+'. '+Copy(s,0,Pos(s,'$')),
WinX+3,WinY+3+(i-1)*font32.TextHeight);
font32.DrawString(Copy(s,Pos(s,'$')+1,Length(s)),WinX+WinW-3-
font32.TextWidth(Copy(s,Pos(s,'$')+1,
Length(s))),WinY+3+(i-1)*font32.TextHeight);
end;
back:=CreateCommand('Back',CM_CANCEL,1);
AddCommand(back);
Repaint;
while GetClickedCommand<>back do Delay(100);
RemoveCommand(back);
Menu;
end;
Если здесь че непонятно, спрашивай.