mysticbbs/mystic/mutil_status.pas

148 lines
3.9 KiB
ObjectPascal
Raw Normal View History

// ====================================================================
// Mystic BBS Software Copyright 1997-2013 By James Coyle
// ====================================================================
//
// This file is part of Mystic BBS.
//
// Mystic BBS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Mystic BBS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Mystic BBS. If not, see <http://www.gnu.org/licenses/>.
//
// ====================================================================
2012-02-29 17:45:16 -08:00
Unit MUTIL_Status;
{$I M_OPS.PAS}
Interface
Type
TStatusBar = Class
LastPercent : Byte;
LinePosition : Byte;
Constructor Create (LinePos: Byte);
Destructor Destroy; Override;
Procedure Reset;
Procedure Update (Part, Whole: LongInt);
End;
TProcessResult = (rDONE, rWARN, rWORKING, rFATAL);
Procedure ProcessName (Str: String; Start: Boolean);
2012-09-24 20:57:45 -07:00
Procedure ProcessStatus (Str: String; Last: Boolean);
2012-02-29 17:45:16 -08:00
Procedure ProcessResult (Res: TProcessResult; Done: Boolean);
Implementation
Uses
m_Strings,
BBS_DataBase,
mUtil_Common;
2012-02-29 17:45:16 -08:00
Procedure ProcessName (Str: String; Start: Boolean);
Begin
Console.WriteXYPipe (5, Console.CursorY, 7, 26, Str);
2012-03-01 15:21:16 -08:00
If Start Then Begin
Inc (ProcessPos);
BarOne.Reset;
2012-09-24 20:57:45 -07:00
2013-03-18 22:48:11 -07:00
Console.WriteXY (71, 10, 8, strPadL('(' + strI2S(ProcessPos) + '/' + strI2S(ProcessTotal) + ')', 7, ' '));
2012-09-24 20:57:45 -07:00
Log (1, '+', 'Process: ' + Str);
2012-03-01 15:21:16 -08:00
End;
2012-02-29 17:45:16 -08:00
End;
2012-09-24 20:57:45 -07:00
Procedure ProcessStatus (Str: String; Last: Boolean);
2012-02-29 17:45:16 -08:00
Begin
Console.WriteXYPipe (33, Console.CursorY, 7, 31, Str);
2012-09-24 20:57:45 -07:00
If Last Then
2012-09-28 15:24:50 -07:00
Log (1, '+', 'Results: ' + strStripPipe(Str))
2012-09-24 20:57:45 -07:00
Else
Log (2, '+', ' ' + Str);
2012-02-29 17:45:16 -08:00
End;
Procedure ProcessResult (Res: TProcessResult; Done: Boolean);
Begin
Case Res of
rDONE : Console.WriteXYPipe(66, Console.CursorY, 10, 11, 'DONE');
2012-09-24 20:57:45 -07:00
rWARN : Begin
Console.WriteXYPipe(66, Console.CursorY, 12, 11, 'WARNING');
Log (2, '!', 'Status: WARNING');
End;
2012-02-29 17:45:16 -08:00
rWORKING : Console.WriteXYPipe(66, Console.CursorY, 15, 11, 'WORKING');
2012-09-24 20:57:45 -07:00
rFATAL : Begin
Console.WriteXYPipe(66, Console.CursorY, 12, 11, 'FATAL');
Log (1, '!', 'Status: FATAL');
End;
2012-02-29 17:45:16 -08:00
End;
2012-03-01 15:21:16 -08:00
If Done Then Begin
2012-11-18 05:51:32 -08:00
If ProcessPos < ProcessTotal Then Console.WriteLine('');
2012-03-01 15:21:16 -08:00
BarOne.Update (100, 100);
BarAll.Update (ProcessPos, ProcessTotal);
End;
2012-02-29 17:45:16 -08:00
End;
Procedure TStatusBar.Reset;
Begin
Console.WriteXY (24, LinePosition, 8, strRep(#176, 50));
Console.WriteXY (24, LinePosition + 1, 8, strRep(#176, 50));
Console.WriteXY (75, LinePosition + 1, 7, '0 ');
LastPercent := 0;
End;
Procedure TStatusBar.Update (Part, Whole: LongInt);
Var
Percent : Byte;
PerStr : String;
Begin
Percent := Round(Part / Whole * 100);
If Percent <> LastPercent Then Begin
LastPercent := Percent;
If Percent >= 2 Then Begin
PerStr := strRep(' ', (Percent DIV 2) - 1) + #222;
Console.WriteXY (24, LinePosition, 25, PerStr);
Console.WriteXY (24, LinePosition + 1, 25, PerStr);
End;
2012-03-17 11:11:50 -07:00
Console.WriteXY (75, LinePosition + 1, 15, strPadR(strI2S(Percent), 3, ' '));
2012-02-29 17:45:16 -08:00
End;
End;
Constructor TStatusBar.Create (LinePos: Byte);
Begin
Inherited Create;
LinePosition := LinePos;
Reset;
End;
Destructor TStatusBar.Destroy;
Begin
Inherited Destroy;
End;
End.