Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. unit LRLMainMenu;
  2.  
  3.  
  4. interface
  5.  
  6.  
  7. uses
  8.   LRLRoutines, LRLSprites;
  9.  
  10.  
  11. procedure LRLSelectItem(var Item: Word);
  12.  
  13.  
  14. implementation
  15.  
  16.  
  17. var
  18.   MainScreen: Pointer;
  19.   Selection:  array[1..4] of Pointer;
  20.   SelectionDark: array[1..4] of Pointer;
  21.   SelectionSize: array[1..4] of Word;
  22.   SelectionDarkSize: array[1..4] of Word;
  23.  
  24.  
  25. procedure LoadData;
  26. var
  27.   j: Word;
  28.   i: Integer;
  29. begin
  30.   GetMem(MainScreen, 64004);
  31.   Seek(ImageFile, LRLImagesFilePosition + 7940);
  32.   BlockRead(ImageFile, MainScreen^, 64004, j);
  33.   for i := 1 to 4 do
  34.   begin
  35.     BlockRead(ImageFile, SelectionSize[i], 2, j);
  36.     GetMem(Selection[i], SelectionSize[i]);
  37.     BlockRead(ImageFile, Selection[i]^, SelectionSize[i], j);
  38.     BlockRead(ImageFile, SelectionDarkSize[i], 2, j);
  39.     GetMem(SelectionDark[i], SelectionDarkSize[i]);
  40.     BlockRead(ImageFile, SelectionDark[i]^, SelectionDarkSize[i], j);
  41.   end;
  42. end;
  43.  
  44.  
  45. procedure DisposeData;
  46. var
  47.   i: Integer;
  48. begin
  49.   FreeMem(MainScreen, 64004);
  50.   for i := 1 to 4 do
  51.   begin
  52.     FreeMem(Selection[i], SelectionSize[i]);
  53.     FreeMem(SelectionDark[i], SelectionDarkSize[i]);
  54.   end;
  55. end;
  56.  
  57.  
  58. procedure LRLSelectItem(var Item: Word);
  59. var
  60.   Keypress: Word;
  61.   RedrawAll: Boolean;
  62.   NeedToFade: Boolean;
  63.   p: Pointer;
  64.   i: Integer;
  65. begin
  66.   GetMem(p, 768);
  67.   DataFill(p^, 768, 0, 0);
  68.   Palette256Set(p^);
  69.   FreeMem(p, 768);
  70.  
  71.   LoadData;
  72.   NeedToFade := True;
  73.   ImagePut(LRLScreen^, MainScreen^, 0, 0, 0, 0, 319, 199);
  74.   RedrawAll := True;
  75.   KeyboardFlush;
  76.  
  77.   repeat
  78.     if RedrawAll then
  79.     begin
  80.       for i := 1 to 4 do
  81.       if i = Item then
  82.         ImagePutTransparent(LRLScreen^, Selection[i]^, 63, 66 + (i - 1) * 30, 0, 0, 319, 199) else
  83.         ImagePutTransparent(LRLScreen^, SelectionDark[i]^, 63, 66 + (i - 1) * 30, 0, 0, 319, 199);
  84.  
  85.       ScreenApply(LRLScreen^);
  86.  
  87.       if NeedToFade then
  88.       begin
  89.         FadeTo(LRLMenuPalette);
  90.         NeedToFade := False;
  91.       end;
  92.  
  93.       RedrawAll := False;
  94.     end;
  95.  
  96.     Keypress := ReadKey;
  97.  
  98.     if (Keypress = KEY_DOWN) and (Item < 4) then
  99.     begin
  100.       Inc(Item);
  101.       RedrawAll := True;
  102.     end else
  103.     if (Keypress = KEY_UP) and (Item > 1) then
  104.     begin
  105.       Dec(Item);
  106.       RedrawAll := True;
  107.     end;
  108.   until Keypress = KEY_ENTER;
  109.  
  110.   FadeClear;
  111.   ImageClear(LRLScreen^);
  112.   ScreenApply(LRLScreen^);
  113.   DisposeData;
  114. end;
  115.  
  116.  
  117. end.
  118.