More fixes for new menu engine. Timer events now have additional execution options
This commit is contained in:
parent
2d67b42fa6
commit
3f217b6262
|
@ -276,7 +276,7 @@ Begin
|
|||
|
||||
Form.AddNone ('C', ' Command ', 15, 11, 9, Topic + 'Menu command function');
|
||||
Form.AddStr ('A', ' Access ' , 16, 12, 26, 12, 8, 30, 30, @Menu.Item[Num]^.CmdData[CmdNum]^.Access, Topic + 'Access level to run this command');
|
||||
Form.AddStr ('D', ' Data ' , 18, 13, 26, 13, 6, 40, 80, @Menu.Item[Num]^.CmdData[CmdNum]^.Data, Topic + 'Menu command optional data');
|
||||
Form.AddStr ('D', ' Data ' , 18, 13, 26, 13, 6, 40, 160, @Menu.Item[Num]^.CmdData[CmdNum]^.Data, Topic + 'Menu command optional data');
|
||||
Form.AddTog ('G', ' Execute ', 15, 14, 26, 14, 9, 6, 0, 10, 'Selected Up Down Left Right Tab Escape PgUp PgDn Home End', @Menu.Item[Num]^.CmdData[CmdNum]^.JumpID, Topic + '(Grid) Execute command on what Grid event?');
|
||||
|
||||
Repeat
|
||||
|
@ -346,6 +346,7 @@ Begin
|
|||
|
||||
VerticalLine (18, 6, 14);
|
||||
VerticalLine (60, 10, 14);
|
||||
VerticalLine (41, 14, 14);
|
||||
VerticalLine (73, 10, 14);
|
||||
|
||||
WriteXY (4, 15, 112, 'Command ' + strRep(#196, 18) + ' Access ' + strRep(#196, 5) + ' Data ' + strRep(#196, 29));
|
||||
|
@ -365,7 +366,9 @@ Begin
|
|||
Form.AddByte ('X', 'X' , 14, 12, 20, 12, 1, 2, 0, 80, @Menu.Item[Num]^.X, Topic + 'X coordinate of lightbar');
|
||||
Form.AddByte ('Y', 'Y' , 16, 12, 23, 12, 1, 2, 0, 50, @Menu.Item[Num]^.Y, Topic + 'Y coordinate of lightbar');
|
||||
Form.AddWord ('M', ' Timer ' , 11, 13, 20, 13, 7, 5, 0, 65535, @Menu.Item[Num]^.Timer, Topic + 'Timer interval (seconds)');
|
||||
Form.AddBol ('W', ' Redraw ' , 10, 14, 20, 14, 8, 3, @Menu.Item[Num]^.ReDraw, Topic + 'Redraw menu after running this command?');
|
||||
Form.AddTog ('X', ' Exec Type' , 7, 14, 20, 14, 11, 9, 0, 2, 'Interval OnlyOnce PerRedraw', @Menu.Item[Num]^.TimerType, Topic + 'TIMER event execution type');
|
||||
|
||||
Form.AddBol ('W', ' Redraw ' , 33, 14, 43, 14, 8, 3, @Menu.Item[Num]^.ReDraw, Topic + 'Redraw menu after running this command?');
|
||||
|
||||
Form.AddByte ('U', ' Up ' , 56, 10, 62, 10, 4, 3, 0, 255, @Menu.Item[Num]^.JumpUp, Topic + '(Grid) Item # to jump to when UP is pressed');
|
||||
Form.AddByte ('D', ' Down ' , 54, 11, 62, 11, 6, 3, 0, 255, @Menu.Item[Num]^.JumpDown, Topic + '(Grid) Item # to jump to when DOWN is pressed');
|
||||
|
@ -379,12 +382,12 @@ Begin
|
|||
Form.AddByte ('G', ' PageDn ' , 65, 13, 75, 13, 8, 3, 0, 255, @Menu.Item[Num]^.JumpPgDn, Topic + '(Grid) Item # to jump to when PGDN is pressed');
|
||||
Form.AddByte ('N', ' End ' , 68, 14, 75, 14, 5, 3, 0, 255, @Menu.Item[Num]^.JumpEnd, Topic + '(Grid) Item # to jump to when END is pressed');
|
||||
|
||||
WriteXY (25, 21, 113, Status1);
|
||||
WriteXY (26, 21, 120, Status1);
|
||||
|
||||
Repeat
|
||||
Case Form.Execute of
|
||||
#09 : Begin
|
||||
WriteXY (25, 21, 113, Status2);
|
||||
WriteXY (26, 21, 120, Status2);
|
||||
|
||||
Repeat
|
||||
MakeList;
|
||||
|
@ -394,8 +397,8 @@ Begin
|
|||
List.Open (2, 15, 79, 21);
|
||||
|
||||
Case List.ExitCode of
|
||||
'/' : Case GetCommandOption(10, 'A-Add|D-Delete|') of
|
||||
'A' : Begin
|
||||
'/' : Case GetCommandOption(10, 'I-Insert|D-Delete|') of
|
||||
'I' : Begin
|
||||
Menu.InsertCommand(Num, List.Picked);
|
||||
Changed := True;
|
||||
End;
|
||||
|
@ -414,7 +417,7 @@ Begin
|
|||
End;
|
||||
Until False;
|
||||
|
||||
WriteXY (25, 21, 113, Status1);
|
||||
WriteXY (26, 21, 120, Status1);
|
||||
|
||||
If List.ExitCode = #27 Then Break;
|
||||
End;
|
||||
|
@ -521,8 +524,8 @@ Begin
|
|||
List.Open (9, 7, 72, 19);
|
||||
|
||||
Case List.ExitCode of
|
||||
'/' : Case GetCommandOption(10, 'F-Flags|A-Add|D-Delete|C-Copy|P-Paste|V-View|') of
|
||||
'A' : Begin
|
||||
'/' : Case GetCommandOption(10, 'F-Flags|I-Insert|D-Delete|C-Copy|P-Paste|V-View|') of
|
||||
'I' : Begin
|
||||
Menu.InsertItem(List.Picked);
|
||||
Changed := True;
|
||||
End;
|
||||
|
|
|
@ -1271,14 +1271,14 @@ Begin
|
|||
Repeat
|
||||
If LastSecond <> TimerSeconds Then Begin
|
||||
|
||||
LastSecond := TimerSeconds;
|
||||
|
||||
If Assigned(GetKeyCallBack) Then
|
||||
If GetKeyCallBack(False) Then Begin
|
||||
Result := #02;
|
||||
Exit;
|
||||
End;
|
||||
|
||||
LastSecond := TimerSeconds;
|
||||
|
||||
If InMacro Then
|
||||
If InMacroPos <= Length(InMacroStr) Then Begin
|
||||
Result := InMacroStr[InMacroPos];
|
||||
|
|
|
@ -21,7 +21,6 @@ Type
|
|||
UseHotKeys : Boolean;
|
||||
ReDraw : Boolean;
|
||||
SetAction : Boolean;
|
||||
UseLongKey : Boolean;
|
||||
UseTimer : Boolean;
|
||||
TimerCount : LongInt;
|
||||
TimerReload : Boolean;
|
||||
|
@ -38,6 +37,7 @@ Type
|
|||
Function ExecuteByHotkey (Key: String; Interval: LongInt) : Byte;
|
||||
Function ExecuteCommand (Cmd, CmdData: String) : Boolean;
|
||||
Function SpecialKey (Str: String) : Boolean;
|
||||
Function MenuGetKey : Char;
|
||||
Function ShowMenu : Boolean;
|
||||
Procedure GenerateMenu;
|
||||
Procedure DoStandardMenu;
|
||||
|
@ -48,7 +48,9 @@ Implementation
|
|||
|
||||
Uses
|
||||
m_Strings,
|
||||
m_DateTime,
|
||||
BBS_Core,
|
||||
BBS_IO,
|
||||
BBS_NodeInfo,
|
||||
BBS_General,
|
||||
BBS_Doors,
|
||||
|
@ -379,17 +381,30 @@ Begin
|
|||
Key := strUpper(Key);
|
||||
|
||||
For Count := 1 to Data.NumItems Do Begin
|
||||
|
||||
If Data.Item[Count] = Nil Then Begin
|
||||
Result := 2;
|
||||
Exit;
|
||||
Break;
|
||||
End;
|
||||
|
||||
If Data.Item[Count]^.HotKey = Key Then
|
||||
If (Key <> 'TIMER') or ((Key = 'TIMER') And (Interval MOD Data.Item[Count]^.Timer = 0)) Then Begin
|
||||
Result := ExecuteCommandList(Count, -1);
|
||||
If Data.Item[Count]^.HotKey = Key Then Begin
|
||||
If Key <> 'TIMER' Then
|
||||
Result := ExecuteCommandList(Count, -1)
|
||||
Else
|
||||
If (Interval MOD Data.Item[Count]^.Timer <> 0) Then
|
||||
Continue
|
||||
Else Begin
|
||||
|
||||
If Result = 2 Then Exit;
|
||||
Case Data.Item[Count]^.TimerType of
|
||||
0 : Result := ExecuteCommandList(Count, -1);
|
||||
1,
|
||||
2 : If Data.Item[Count]^.TimerShow Then Begin
|
||||
Result := ExecuteCommandList(Count, -1);
|
||||
Data.Item[Count]^.TimerShow := False;
|
||||
End;
|
||||
End;
|
||||
End;
|
||||
|
||||
If Result = 2 Then Break;
|
||||
End;
|
||||
End;
|
||||
End;
|
||||
|
@ -420,6 +435,12 @@ Var
|
|||
Listed : Word;
|
||||
Count : LongInt;
|
||||
Begin
|
||||
If UseTimer Then Begin
|
||||
For Count := 1 to Data.NumItems Do
|
||||
If Data.Item[Count]^.TimerType = 2 Then
|
||||
Data.Item[Count]^.TimerShow := True;
|
||||
End;
|
||||
|
||||
If ShowMenu Then Begin
|
||||
Case Data.Info.DispCols of
|
||||
1 : Format := 79;
|
||||
|
@ -531,7 +552,7 @@ Begin
|
|||
Temp := '';
|
||||
|
||||
While Not TBBSCore(Owner).ShutDown Do Begin
|
||||
Ch := Session.io.GetKey;
|
||||
Ch := MenuGetKey;
|
||||
|
||||
If TBBSCore(Owner).ShutDown Then Exit;
|
||||
|
||||
|
@ -602,6 +623,42 @@ Begin
|
|||
End;
|
||||
End;
|
||||
|
||||
Function TMenuEngine.MenuGetKey : Char;
|
||||
Var
|
||||
Current : LongInt;
|
||||
LastSec : LongInt;
|
||||
Begin
|
||||
LastSec := TimerSeconds;
|
||||
|
||||
While Not TBBSCore(Owner).ShutDown Do Begin
|
||||
Result := TBBSCore(Owner).io.InKey(1000);
|
||||
|
||||
If TBBSCore(Owner).ShutDown Then Exit;
|
||||
|
||||
If UseTimer And (TimerSeconds <> LastSec) Then Begin
|
||||
LastSec := TimerSeconds;
|
||||
|
||||
Inc (TimerCount);
|
||||
|
||||
Case ExecuteByHotkey('TIMER', TimerCount) of
|
||||
1 : If ReDraw Then Begin
|
||||
Result := #02;
|
||||
Exit;
|
||||
End;
|
||||
2 : Begin
|
||||
TimerReload := True;
|
||||
Result := #02;
|
||||
Exit;
|
||||
End;
|
||||
End;
|
||||
|
||||
If TimerCount = 1000000000 Then TimerCount := 0;
|
||||
End;
|
||||
|
||||
If Result <> #255 Then Break;
|
||||
End;
|
||||
End;
|
||||
|
||||
Procedure TMenuEngine.DoLightBarMenu;
|
||||
Var
|
||||
TempStr : String;
|
||||
|
@ -703,9 +760,14 @@ Begin
|
|||
Set_Node_Action(TBBSCore(Owner).GetPrompt(346));
|
||||
|
||||
If ReDraw Then Begin
|
||||
If UseTimer Then Begin
|
||||
For Count := 1 to Data.NumItems Do
|
||||
If Data.Item[Count]^.TimerType = 2 Then
|
||||
Data.Item[Count]^.TimerShow := True;
|
||||
End;
|
||||
|
||||
ShowMenu;
|
||||
|
||||
// If Data.Info.Header <> '' Then
|
||||
TBBSCore(Owner).io.OutFullLn(Data.Info.Header);
|
||||
|
||||
If Data.Info.Footer <> '' Then
|
||||
|
@ -734,7 +796,7 @@ Begin
|
|||
TempStr := '';
|
||||
|
||||
While Not TBBSCore(Owner).ShutDown Do Begin
|
||||
Ch := Session.io.GetKey;
|
||||
Ch := MenuGetKey;
|
||||
|
||||
If UseTimer And (Ch = #02) Then Begin
|
||||
If TimerReload Then Exit;
|
||||
|
@ -927,23 +989,6 @@ Begin
|
|||
End;
|
||||
|
||||
Procedure TMenuEngine.ExecuteMenu (Load, Forced, View, Action: Boolean);
|
||||
|
||||
Function TimerController (Forced: Boolean) : Boolean;
|
||||
Begin
|
||||
Inc (TimerCount);
|
||||
|
||||
Case ExecuteByHotkey('TIMER', TimerCount) of
|
||||
0 : Result := False;
|
||||
1 : Result := True;
|
||||
2 : Begin
|
||||
TimerReload := True;
|
||||
Result := True;
|
||||
End;
|
||||
End;
|
||||
|
||||
If TimerCount = 1000000000 Then TimerCount := 0;
|
||||
End;
|
||||
|
||||
Var
|
||||
Count : LongInt;
|
||||
Begin
|
||||
|
@ -983,12 +1028,9 @@ Begin
|
|||
Else
|
||||
UseHotKeys := Not Boolean(Data.Info.InputType - 1);
|
||||
|
||||
// Run FIRSTCMD commands and setup valid extended keys
|
||||
|
||||
ExtKeys := '';
|
||||
UseTimer := False;
|
||||
ReDraw := True;
|
||||
UseLongKey := False;
|
||||
TimerCount := 0;
|
||||
TimerReload := False;
|
||||
|
||||
|
@ -1010,13 +1052,9 @@ Begin
|
|||
If Data.Item[Count]^.HotKey = 'PAGEDOWN' Then ExtKeys := ExtKeys + #81 Else
|
||||
If Data.Item[Count]^.HotKey = 'HOME' Then ExtKeys := ExtKeys + #71 Else
|
||||
If Data.Item[Count]^.HotKey = 'END' Then ExtKeys := ExtKeys + #79 Else
|
||||
If Data.Item[Count]^.HotKey = 'TIMER' Then UseTimer := True Else
|
||||
If Byte(Data.Item[Count]^.HotKey[0]) > 1 Then UseLongKey := True;
|
||||
If Data.Item[Count]^.HotKey = 'TIMER' Then UseTimer := True;
|
||||
End;
|
||||
|
||||
If UseTimer Then
|
||||
Session.io.GetKeyCallBack := TimerController;
|
||||
|
||||
Case Data.Info.MenuType of
|
||||
0 : DoStandardMenu;
|
||||
1,
|
||||
|
@ -1025,8 +1063,6 @@ Begin
|
|||
Else
|
||||
DoStandardMenu;
|
||||
End;
|
||||
|
||||
Session.io.GetKeyCallback := NIL;
|
||||
End;
|
||||
|
||||
End.
|
||||
|
|
|
@ -47,7 +47,7 @@ Const
|
|||
mysMaxVoteQuestion = 20; // Max number of voting questions
|
||||
mysMaxMenuNameLen = 20; // menu name size
|
||||
mysMaxMenuItems = 75; // Maximum menu items per menu
|
||||
mysMaxMenuCmds = 20; // Max menu commands per item
|
||||
mysMaxMenuCmds = 25; // Max menu commands per item
|
||||
mysMaxMenuInput = 12;
|
||||
mysMaxMenuStack = 8;
|
||||
mysMaxThemeText = 493; // Total prompts in theme file
|
||||
|
@ -525,7 +525,7 @@ Type
|
|||
RecMenuCmd = Packed Record
|
||||
MenuCmd : String[2];
|
||||
Access : String[mysMaxAcsSize];
|
||||
Data : String[80];
|
||||
Data : String[160];
|
||||
JumpID : Byte;
|
||||
End;
|
||||
|
||||
|
@ -553,6 +553,8 @@ Type
|
|||
X : Byte;
|
||||
Y : Byte;
|
||||
Timer : Word;
|
||||
TimerType : Byte;
|
||||
TimerShow : Boolean;
|
||||
End;
|
||||
|
||||
RecMenuInfo = Packed Record
|
||||
|
|
Loading…
Reference in New Issue