home *** CD-ROM | disk | FTP | other *** search
- program MenuDeCompiler; { menu compiler program }
- {$I-} { turn off I/O checking }
-
- Uses
- STI_STRN;
-
- Const
- MAXSTRLEN = 60;
-
- Type
- Dumm = array[1..2] of byte;
- Head = record
- Name : string[MAXSTRLEN];
- Version : word;
- Mode : byte;
- Save : boolean;
- BackColor : byte;
- InputS : byte;
- NumMenus : word;
- end;
- Sel = record
- Prompt : string[MAXSTRLEN];
- Jump : boolean;
- Value : word;
- end;
- Posy = record
- MenuID : word;
- Position : longint;
- end;
- Ent = record
- MenuID : word;
- MenuTitle : string[MAXSTRLEN];
- MenuType : byte;
- BorderType: byte;
- BodyCol : byte;
- BorderCol : byte;
- TextCol : byte;
- HighLight : byte;
- PromptCol : byte;
- TitleCol : byte;
- Size : array[1..4] of byte;
- SelectNum : word;
- end;
-
- Var
- InputFile : file; { input file }
- Buffer : string; { parse buffer }
- Token : string; { current token }
- Header : Head; { menu file header }
- HeadWRFlag : boolean; { has the header been written }
- Buff : Posy; { position buffer }
- Menu : Ent; { currently processed menu }
- Select : Sel; { currently processed selection }
-
- {---------------------------------------------------------------------------}
-
- procedure Error(Message : string);
-
- begin
- writeln;
- writeln('Error : ',Message);
- writeln;
- halt;
- end;
-
- {---------------------------------------------------------------------------}
-
- procedure Usage;
-
- begin
- writeln;
- writeln('Usage : MENUDCMP <inputfile>');
- writeln;
- halt;
- end;
-
- {---------------------------------------------------------------------------}
-
- procedure Message;
-
- begin
- writeln(';');
- writeln('; MENUDCMP');
- writeln('; The STI Menu DeCompiler');
- writeln('; Copyright (C) 1990,1991,1992 By Sofware Technology International');
- writeln('; All Rights Reserved');
- writeln(';');
- writeln('; DeCompiled File : ',UpCaseStr(ParamStr(1)));
- writeln(';');
- writeln;
- end;
-
- {---------------------------------------------------------------------------}
-
- procedure SetFiles;
-
- begin
- assign(InputFile,ParamStr(1));
- reset(InputFile,1);
- if IOResult <> 0 then
- Error('Could not open '+UpCaseStr(ParamStr(1)));
- end;
-
- {---------------------------------------------------------------------------}
-
- procedure WriteColor(Col : byte);
-
- begin
- Case Col of
- 0 : write('BLACK');
- 1 : write('BLUE');
- 2 : write('GREEN');
- 3 : write('CYAN');
- 4 : write('RED');
- 5 : write('MAGENTA');
- 6 : write('YELLOW');
- 7 : write('WHITE');
- 8 : write('GREYTILED');
- 9 : write('BLACKREVERSE');
- 10 : write('BLUEREVERSE');
- 11 : write('GREENREVERSE');
- 12 : write('CYANREVERSE');
- 13 : write('REDREVERSE');
- 14 : write('MAGENTAREVERSE');
- 15 : write('YELLOWREVERSE');
- 16 : write('WHITEREVERSE');
- else write('UNKNOWN');
- end;
- end;
-
- {---------------------------------------------------------------------------}
-
- procedure WriteBType(InType : byte);
-
- begin
- case InType of
- 0 : write('NOBORDER');
- 1 : write('SPACEBORDER');
- 2 : write('SINGLELINE');
- 3 : write('ROUNDCORNERSINGLE');
- 4 : write('BIGBLOCK');
- 5 : write('THICKTOPTHINSIDES');
- 6 : write('THICKDIAGONALCORNER');
- else write('UNKNOWN');
- end;{case}
- end;
-
- {---------------------------------------------------------------------------}
-
- procedure UnpackHeader;
-
- begin
- seek(InputFile,0);
- BlockRead(InputFile,Header,sizeof(Head));
- Header.Name[0] := char(ord(Header.Name[0])-2);
- WriteLn('%MENUFILE "',Header.Name,'"',#9#9#9,'; name of menu file');
- WriteLn('%VERSION ',lo(Header.Version),' ',hi(Header.Version),#9#9#9,' ; version number');
- Write( '%MODE ');
- if Header.Mode = 1 then
- Write('TEXT')
- else
- Write('GRAPHICS');
- writeln(#9#9#9,'; the menu screen mode');
- write( '%SAVE ');
- if Header.Save then
- write('YES')
- else
- write('NO');
- writeln(#9#9#9,'; shall we save the screen ?');
- write( '%BACKGROUND ');
- WriteColor(Header.BackColor);
- writeln(#9#9#9,'; the background color');
- write( '%INPUT ');
- Case Header.InputS of
- 0 : write('KEYS');
- 1 : write('MOUSE');
- 2 : write('BOTH');
- end;
- writeln(#9#9#9,'; style of input');
- writeln('%NUMBER_MENUS ',Header.NumMenus,#9#9#9,'; number of menus');
- writeln;
- writeln(';',MakeStr(77,ord('-')));
- writeln('; The actual menus begin from here');
- writeln(';',MakeStr(77,ord('-')));
- writeln;
- end;
-
- {---------------------------------------------------------------------------}
-
- procedure UnPackRest;
-
- Var
- Loop : word;
-
- begin
- while not(eof(InputFile)) do
- begin
- BlockRead(InputFile,Menu,sizeof(Ent));
- writeln('%MENU ',Menu.MenuID,' "',Menu.MenuTitle,'"',#9#9#9,'; menu identifier');
- write( '%MENU_TYPE ');
- if Menu.MenuType = 1 then
- write('BAR')
- else
- write('BOX');
- writeln(#9#9#9,'; menu type');
- write( '%BODY_COLOR ');
- WriteColor(Menu.BodyCol);
- writeln(#9#9#9,'; menu body color');
- write( '%BORDER_COLOR ');
- WriteColor(Menu.BorderCol);
- writeln(#9#9#9,'; menu border color');
- write( '%TEXT_COLOR ');
- WriteColor(Menu.TextCol);
- writeln(#9#9#9,'; menu text color');
- write( '%HIGHLIGHT_COLOR ');
- WriteColor(Menu.HighLight);
- writeln(#9#9#9,'; menu highlight color');
- write( '%PROMPT_COLOR ');
- WriteColor(Menu.PromptCol);
- writeln(#9#9#9,'; menu prompt color');
- write( '%TITLE_COLOR ');
- WriteColor(Menu.TitleCol);
- writeln(#9#9#9,'; menu title color');
- write( '%BORDER_TYPE ');
- WriteBType(Menu.BorderType);
- writeln(#9#9#9,'; menu border type ');
- writeln( '%SIZE ',Menu.Size[1]:4,Menu.Size[2]:4,Menu.Size[3]:4,Menu.Size[4]:4,#9#9#9,'; menu size');
- writeln( '%SELECTIONS ',Menu.SelectNum,#9#9#9,'; number of options');
- for Loop := 1 to Menu.SelectNum do
- begin
- BlockRead(InputFile,Select,sizeof(Sel));
- write( '%SELECTION "',Select.Prompt,'" ');
- if Select.Jump then
- write('GOTO')
- else
- write('RETURN');
- writeln(' ',Select.Value,#9#9#9,'; Selection # ',Loop);
- end;
- writeln('%END_MENU');
- writeln;
- writeln(';',MakeStr(78,ord('-')));
- writeln;
- end;
- end;
-
- {---------------------------------------------------------------------------}
-
- procedure UnPackMenu;
-
- begin
- UnpackHeader;
- BlockRead(InputFile,Buff,sizeof(Posy));
- if Buff.MenuID = 1 then
- Seek(InputFile,Buff.Position)
- else
- Error('Could not find first menu entry');
- UnPackRest;
- writeln('%END_MENUFILE');
- close(InputFile);
- end;
-
- {---------------------------------------------------------------------------}
-
- begin
- Message;
- if ParamCount < 1 then
- Usage;
- SetFiles;
- UnpackMenu;
- end.