More fixes to the new menu engine. Should hopefully be pretty solid now.

This commit is contained in:
mysticbbs 2012-07-24 17:54:01 -04:00
parent d806eec5cf
commit 1292933785
4 changed files with 143 additions and 111 deletions

View File

@ -4313,7 +4313,8 @@
+ Added new ANSI menu editor to replace the old outdated crap. The new
editor has references to all of the menu commands as well as the special
functional hotkeys.
functional hotkeys. It still maintains the ability to "simulate" menus
as well.
+ Revamped the entire menu system. Menu files must be converted if you are
any version pre 1.10 alpha 15 using the CvtMenus program. Simply copy
@ -4336,7 +4337,9 @@
approach this way, and it allows for more options!
+ Each menu command now has the option to redraw the menu or not after its
command list executes.
command list executes. This defaults to on to mimic previous menu system
however for some advanced stuff, like TIMER, you may will to turn them
off.
+ Menus can now be internally generated from 1 to 4 columns (up from 3)
@ -4423,10 +4426,21 @@
counter used to fire off TIMER commands. It represents the number of
seconds that have passed since the menu was loaded.
+ TIMER commands also have 3 types, configurable per each menu option:
Interval - Always execute at the configured timed interval
OnlyOnce - Execute at interval ONLY ONCE per menu being loaded
PerRedraw - Execute after each menu redraw as per timer interval
+ When using hotkey-style menu input, extended hotkeys are no longer
required to have a / first. You can make a hotkey command named QUIT
for example, and it will execute immediately when QUIT is entered.
Keep in mind it is still a hot-key styled input. So you cannot have
one hotkey named QUIT and one named QUITNOW. The QUIT command will
always get the hotkey. If you need functionality like that, hotkeys
can be disabled on the menu.
+ Similar to the display file and menu systems, the MPL scripts directory
will now also fallback from the theme scripts path to the default
scripts directory if the feature is enabled in the selected theme.

View File

@ -307,6 +307,7 @@ Procedure EditItem (Num: Word);
Const
Status1 = ' (TAB) to edit menu commands ';
Status2 = ' (TAB) Switch (/) Commands ';
Grid = '(Grid) Item # to jump to on keypress ';
Var
Box : TAnsiMenuBox;
List : TAnsiMenuList;
@ -366,21 +367,21 @@ 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.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.AddTog ('X', ' Timer Type' , 6, 14, 20, 14, 12, 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');
Form.AddByte ('L', ' Left ' , 54, 12, 62, 12, 6, 3, 0, 255, @Menu.Item[Num]^.JumpLeft, Topic + '(Grid) Item # to jump to when LEFT is pressed');
Form.AddByte ('R', ' Right ' , 53, 13, 62, 13, 7, 3, 0, 255, @Menu.Item[Num]^.JumpRight, Topic + '(Grid) Item # to jump to when RIGHT is pressed');
Form.AddByte ('E', ' Home ' , 54, 14, 62, 14, 6, 3, 0, 255, @Menu.Item[Num]^.JumpHome, Topic + '(Grid) Item # to jump to when HOME is pressed');
Form.AddByte ('U', ' Up' , 56, 10, 62, 10, 4, 3, 0, 255, @Menu.Item[Num]^.JumpUp, Topic + Grid + 'UP');
Form.AddByte ('D', ' Down' , 54, 11, 62, 11, 6, 3, 0, 255, @Menu.Item[Num]^.JumpDown, Topic + Grid + 'DOWN');
Form.AddByte ('L', ' Left' , 54, 12, 62, 12, 6, 3, 0, 255, @Menu.Item[Num]^.JumpLeft, Topic + Grid + 'LEFT');
Form.AddByte ('R', ' Right' , 53, 13, 62, 13, 7, 3, 0, 255, @Menu.Item[Num]^.JumpRight, Topic + Grid + 'RIGHT');
Form.AddByte ('E', ' Home' , 54, 14, 62, 14, 6, 3, 0, 255, @Menu.Item[Num]^.JumpHome, Topic + Grid + 'HOME');
Form.AddByte ('C', ' Escape ' , 65, 10, 75, 10, 8, 3, 0, 255, @Menu.Item[Num]^.JumpEscape, Topic + '(Grid) Item # to jump to when ESCAPE is pressed');
Form.AddByte ('T', ' Tab ' , 68, 11, 75, 11, 5, 3, 0, 255, @Menu.Item[Num]^.JumpTab, Topic + '(Grid) Item # to jump to when TAB is pressed');
Form.AddByte ('P', ' PageUp ' , 65, 12, 75, 12, 8, 3, 0, 255, @Menu.Item[Num]^.JumpPgUp, Topic + '(Grid) Item # to jump to when PGUP is pressed');
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');
Form.AddByte ('C', ' Escape' , 65, 10, 75, 10, 8, 3, 0, 255, @Menu.Item[Num]^.JumpEscape, Topic + Grid + 'ESCAPE');
Form.AddByte ('T', ' Tab' , 68, 11, 75, 11, 5, 3, 0, 255, @Menu.Item[Num]^.JumpTab, Topic + Grid + 'TAB');
Form.AddByte ('P', ' PageUp' , 65, 12, 75, 12, 8, 3, 0, 255, @Menu.Item[Num]^.JumpPgUp, Topic + Grid + 'PGUP');
Form.AddByte ('G', ' PageDn' , 65, 13, 75, 13, 8, 3, 0, 255, @Menu.Item[Num]^.JumpPgDn, Topic + Grid + 'PGDN');
Form.AddByte ('N', ' End' , 68, 14, 75, 14, 5, 3, 0, 255, @Menu.Item[Num]^.JumpEnd, Topic + Grid + 'END');
WriteXY (26, 21, 120, Status1);

View File

@ -95,6 +95,7 @@ Type
Function InXY (X, Y, Field, Max, Mode: Byte; Default: String) : String;
Function InKey (Wait: LongInt) : Char;
Function GetYNL (Str: String; Yes: Boolean) : Boolean;
Function DoInputEvents (Var Ch: Char) : Boolean;
Function GetKey : Char;
Function GetYN (Str: String; Yes: Boolean) : Boolean;
Function GetPW (Str : String; BadStr : String; PW : String) : Boolean;
@ -1258,30 +1259,17 @@ Begin
End;
{$ENDIF}
Function TBBSIO.GetKey : Char;
Function TBBSIO.DoInputEvents (Var Ch: Char) : Boolean;
Var
TimeCount : LongInt;
Begin
Result := #255;
TBBSCore(Core).TimeOut := TimerSeconds;
BufFlush;
Repeat
If LastSecond <> TimerSeconds Then Begin
LastSecond := TimerSeconds;
If Assigned(GetKeyCallBack) Then
If GetKeyCallBack(False) Then Begin
Result := #02;
Exit;
End;
Result := False;
If InMacro Then
If InMacroPos <= Length(InMacroStr) Then Begin
Result := InMacroStr[InMacroPos];
Ch := InMacroStr[InMacroPos];
Result := True;
Inc (InMacroPos);
Exit;
End Else
@ -1340,6 +1328,27 @@ Begin
End;
End;
Function TBBSIO.GetKey : Char;
Begin
Result := #255;
TBBSCore(Core).TimeOut := TimerSeconds;
BufFlush;
Repeat
If LastSecond <> TimerSeconds Then Begin
LastSecond := TimerSeconds;
If Assigned(GetKeyCallBack) Then
If GetKeyCallBack(False) Then Begin
Result := #02;
Exit;
End;
If DoInputEvents(Result) Then Exit;
End;
Result := InKey(1000);
Until Result <> #255;
End;

View File

@ -237,7 +237,10 @@ Begin
MenuName := CmdData;
Result := True;
End;
'T' : Session.io.OutFull (CmdData);
'T' : Begin
Session.io.OutFull (CmdData);
Session.io.BufFlush;
End;
'U' : ShowUserList (strUpper(CmdData));
'X' : Result := ExecuteMPL(NIL, CmdData) = 2;
'?' : Begin
@ -625,9 +628,10 @@ End;
Function TMenuEngine.MenuGetKey : Char;
Var
Current : LongInt;
LastSec : LongInt;
Begin
Session.io.BufFlush;
LastSec := TimerSeconds;
While Not TBBSCore(Owner).ShutDown Do Begin
@ -635,9 +639,12 @@ Begin
If TBBSCore(Owner).ShutDown Then Exit;
If UseTimer And (TimerSeconds <> LastSec) Then Begin
If TimerSeconds <> LastSec Then Begin
LastSec := TimerSeconds;
If Session.io.DoInputEvents(Result) Then Exit;
If UseTimer Then Begin
Inc (TimerCount);
Case ExecuteByHotkey('TIMER', TimerCount) of
@ -654,6 +661,7 @@ Begin
If TimerCount = 1000000000 Then TimerCount := 0;
End;
End;
If Result <> #255 Then Break;
End;