{
Defjamz emag menuing routines written 100% by skaboy101 (Grant Passmore)
in 30 minutes on Oct 13th, 1998.
These are some NICE ass menuing routines I wrote specially for defjamz,
but I like them so much that im gonna use them from here on out :) If
you use these at least greet skaboy101 (me) somewhere :). hell, they even
allow scrolling AND have FULL mouse support!
-skaboy101 (skaboy101@mindless.com)
}
unit menusys;
interface uses crt,dos,skashit,skamouse;
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
type
sMenuType = record
MenuID : byte;
MenuOn : string[100];
MenuOff : string[100];
end;
sBarType = record
BarShown : byte;
BarStart : byte;
BarXPos : byte;
BarYPos : byte;
BarReal : byte;
BarPos : byte;
BarTotal : byte;
end;
sMenuArray = array[1..50] of sMenuType;
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
Procedure sInitMenuSys(init : boolean);
Procedure sAddMenuSelection(id : byte; on,off : string);
Function sMenuSelection : byte;
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
var sMenuData : ^sMenuArray;
sBarData : ^sBarType;
sDisplayed : boolean;
sCurrentMenu : byte;
Implementation
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
Procedure sInitMenuSys(init : boolean);
begin
if (init=true) then
begin
new(sMenuData);
new(sBarData);
fillChar(sMenuData^,sizeOf(sMenuData^),0);
fillChar(sBarData^,sizeOf(sBarData^),0);
sBarData^.BarPos := 1;
sBarData^.BarReal := 1;
sBarData^.BarTotal := 0;
sDisplayed := false;
end else
begin
dispose(sMenuData);
if (sBarData<>nil) then dispose(sBarData);
end;
end;
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
Procedure sAddMenuSelection(id : byte; on,off : string);
begin
inc(sBarData^.BarTotal);
sMenuData^[sBarData^.BarTotal].MenuID := id;
sMenuData^[sBarData^.BarTotal].MenuOn := on;
sMenuData^[sBarData^.BarTotal].MenuOff := off;
end;
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
Function sMenuSelection : byte;
var sInKey : string[2];
sCount : word;
sDone : boolean;
Procedure sUpdateBars;
var sCount : word;
begin
if (sBarData^.BarTotal>sBarData^.BarShown) then
begin
for sCount := sBarData^.BarStart to (sBarData^.BarStart+sBarData^.BarShown-1) do
begin
gotoXY(sBarData^.BarXPos,sCount-sBarData^.BarStart+sBarData^.BarYPos);
if (sCount=sBarData^.BarReal) then skaWrite(sMenuData^[sCount].MenuOn) else
skaWrite(sMenuData^[sCount].MenuOff);
end;
end else
begin
for sCount := 1 to sBarData^.BarTotal do
begin
gotoXY(sBarData^.BarXPos,sCount-sBarData^.BarStart+sBarData^.BarYPos);
if (sCount=sBarData^.BarReal) then skaWrite(sMenuData^[sCount].MenuOn) else
skaWrite(sMenuData^[sCount].MenuOff);
end;
end;
end;
begin
asm mov ah,1; mov cx,2000h; int 10h end;
if (sBarData^.BarStart=0) then sBarData^.BarStart := 1;
if (sBarData^.BarReal=0) then sBarData^.BarReal := 1;
if (sBarData^.BarTotal=0) then exit;
sUpdateBars;
sDone := false;
repeat
repeat sInKey := eReadKey until (sInKey[1] in [#72,#80,#75,#77,#13,#27,'B','Q','8','2']);
case sInKey[1] of
'B' : if (eMouseUsed=true) then begin
sMenuSelection := sBarData^.BarReal;
sDone := true;
end;
#13 : begin
sMenuSelection := sBarData^.BarReal;
sDone := true;
end;
'Q' : if (eMouseUsed=true) then begin
sMenuSelection := 0;
sDone := true;
end;
#27 : begin
sMenuSelection := 0;
sDone := true;
end;
'8' : if (eMouseUsed=true) and
(sBarData^.BarReal>1) then
begin
if (sBarData^.BarPos=1) then dec(sBarData^.BarStart) else
dec(sBarData^.BarPos);
dec(sBarData^.BarReal);
sUpdateBars;
end;
#72 : if (sBarData^.BarReal>1) then
begin
if (sBarData^.BarPos=1) then dec(sBarData^.BarStart) else
dec(sBarData^.BarPos);
dec(sBarData^.BarReal);
sUpdateBars;
end;
'2' : if (eMouseUsed=true) and
(sBarData^.BarReal<sBarData^.BarTotal) then
begin
if (sBarData^.BarPos=sBarData^.BarShown) then inc(sBarData^.BarStart) else
inc(sBarData^.BarPos);
inc(sBarData^.BarReal);
sUpdateBars;
end;
#80 : if (sBarData^.BarReal<sBarData^.BarTotal) then
begin
if (sBarData^.BarPos=sBarData^.BarShown) then inc(sBarData^.BarStart) else
inc(sBarData^.BarPos);
inc(sBarData^.BarReal);
sUpdateBars;
end;
end;
if (eMouseUsed=true) then eMouseUsed := false;
until (sDone=true);
eClearMouse;
end;
{:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
end.