mysticbbs/mystic/bbs_cfg_groups.pas

165 lines
4.1 KiB
ObjectPascal
Raw Normal View History

2012-02-26 03:51:59 -08:00
Unit bbs_Cfg_Groups;
2012-02-13 16:50:48 -08:00
Interface
2012-02-26 03:51:59 -08:00
Procedure Configuration_GroupEditor (Msg: Boolean);
2012-02-13 16:50:48 -08:00
Implementation
Uses
2012-02-26 03:51:59 -08:00
m_FileIO,
2012-02-13 16:50:48 -08:00
m_Strings,
2012-02-26 03:51:59 -08:00
bbs_Ansi_MenuBox,
bbs_Ansi_MenuForm,
bbs_cfg_Common,
bbs_Common;
2012-02-13 16:50:48 -08:00
2012-02-26 03:51:59 -08:00
Procedure EditGroup (Var Group: RecGroup);
Var
Box : TAnsiMenuBox;
Form : TAnsiMenuForm;
Topic : String;
2012-02-13 16:50:48 -08:00
Begin
2012-02-26 03:51:59 -08:00
Topic := '|03(|09Group Editor|03) |01-|09> |15';
Box := TAnsiMenuBox.Create;
Form := TAnsiMenuForm.Create;
2012-02-13 16:50:48 -08:00
2012-02-26 03:51:59 -08:00
Box.Open (14, 10, 67, 16);
VerticalLine (24, 12, 14);
Form.AddStr ('N', ' Name' , 18, 12, 26, 12, 6, 40, 40, @Group.Name, Topic + 'Description of group');
Form.AddStr ('A', ' Access', 16, 13, 26, 13, 8, 30, 30, @Group.ACS, Topic + 'Access level to access this group');
Form.AddBol ('H', ' Hidden', 16, 14, 26, 14, 8, 3, @Group.Hidden, Topic + 'Group is hidden from group listing?');
Form.Execute;
Box.Close;
Form.Free;
Box.Free;
2012-02-13 16:50:48 -08:00
End;
2012-02-26 03:51:59 -08:00
Procedure Configuration_GroupEditor (Msg: Boolean);
Var
Box : TAnsiMenuBox;
List : TAnsiMenuList;
GroupFile : TBufFile;
Group : RecGroup;
Copied : RecGroup;
HasCopy : Boolean = False;
Procedure MakeList;
Begin
List.Clear;
GroupFile.Reset;
While Not GroupFile.EOF Do Begin
GroupFile.Read (Group);
List.Add(strPadR(strI2S(GroupFile.FilePos), 3, ' ') + ' ' + strStripPipe(Group.Name), 0);
End;
List.Add('', 2);
End;
2012-02-13 16:50:48 -08:00
Begin
2012-02-26 03:51:59 -08:00
GroupFile := TBufFile.Create(2048);
2012-02-13 16:50:48 -08:00
2012-02-26 03:51:59 -08:00
If Msg Then Begin
If Not GroupFile.Open(Config.DataPath + 'groups_g.dat', fmOpenCreate, fmReadWrite + fmDenyNone, SizeOf(RecGroup)) Then Begin
GroupFile.Free;
Exit;
End;
End Else Begin
If Not GroupFile.Open(Config.DataPath + 'groups_f.dat', fmOpenCreate, fmReadWrite + fmDenyNone, SizeOf(RecGroup)) Then Begin
GroupFile.Free;
Exit;
End;
2012-02-13 16:50:48 -08:00
End;
2012-02-26 03:51:59 -08:00
Box := TAnsiMenuBox.Create;
List := TAnsiMenuList.Create;
List.NoWindow := True;
List.LoChars := #13#27#47;
If Msg Then
Box.Header := ' Message Group Editor '
Else
Box.Header := ' File Group Editor ';
Box.Open (21, 6, 59, 20);
If Msg Then
WriteXY (23, 8, 112, '### Message Group Name')
Else
WriteXY (23, 8, 112, '### File Group Name');
WriteXY (22, 9, 112, strRep(#196, 37));
WriteXY (22, 18, 112, strRep(#196, 37));
WriteXY (29, 19, 112, cfgCommandList);
Repeat
MakeList;
List.Open (21, 9, 59, 18);
List.Close;
Case List.ExitCode of
'/' : Case GetCommandOption(10, 'I-Insert|D-Delete|C-Copy|P-Paste|') of
'I' : If List.Picked > 1 Then Begin
GroupFile.RecordInsert (List.Picked);
Group.Name := 'New Group';
Group.ACS := '';
Group.Hidden := False;
GroupFile.Write (Group);
MakeList;
End;
'D' : If (List.Picked < List.ListMax) Then
If ShowMsgBox(1, 'Delete this entry?') Then Begin
GroupFile.Seek (List.Picked - 1);
GroupFile.Read (Group);
GroupFile.RecordDelete (List.Picked);
MakeList;
End;
'C' : If List.Picked <> List.ListMax Then Begin
GroupFile.Seek (List.Picked - 1);
GroupFile.Read (Copied);
HasCopy := True;
End;
'P' : If HasCopy Then Begin
GroupFile.RecordInsert (List.Picked);
GroupFile.Write (Copied);
MakeList;
End;
End;
#13 : If List.Picked <> List.ListMax Then Begin
GroupFile.Seek (List.Picked - 1);
GroupFile.Read (Group);
EditGroup(Group);
GroupFile.Seek (List.Picked - 1);
GroupFile.Write (Group);
End;
#27 : Break;
End;
Until False;
Box.Close;
GroupFile.Free;
List.Free;
Box.Free;
2012-02-13 16:50:48 -08:00
End;
End.