| 1 |
{ |
| 2 |
Copyright 2007-2018 Michalis Kamburelis. |
| 3 |
|
| 4 |
This file is part of "Castle Game Engine". |
| 5 |
|
| 6 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 7 |
included in this distribution, for details about the copyright. |
| 8 |
|
| 9 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 |
|
| 13 |
---------------------------------------------------------------------------- |
| 14 |
} |
| 15 |
|
| 16 |
{ Reporting warnings (OnWarning). |
| 17 |
@deprecated @exclude } |
| 18 |
unit CastleWarnings |
| 19 |
deprecated 'use WritelnWarning from CastleLog unit, instead of this unit'; |
| 20 |
|
| 21 |
{$I castleconf.inc} |
| 22 |
|
| 23 |
interface |
| 24 |
|
| 25 |
type |
| 26 |
{ Types of warnings. } |
| 27 |
TWarningType = ( |
| 28 |
{ Something failed (like URL not available), but still the data |
| 29 |
is semantically correct. For data formats that have a precise specification |
| 30 |
(like VRML/X3D or Collada), this means that the file satisfies the specification, |
| 31 |
but there is a minor problem (like one of the referred URLs is not available). } |
| 32 |
wtMinor, |
| 33 |
|
| 34 |
{ The data is invalid. For data formats that have a precise specification |
| 35 |
(like VRML/X3D or Collada), this means that the file is incorrect |
| 36 |
with respect to this specification. We can handle it, |
| 37 |
but other (less forgiving but still correct) software may reject it. |
| 38 |
|
| 39 |
It's strongly suggested to report this to the author of the file, |
| 40 |
as the file should really be corrected. } |
| 41 |
wtMajor); |
| 42 |
|
| 43 |
{ Assign this to OnWarning to report warnings using WarningWrite, and log them too. |
| 44 |
For Windows programs with no console available, |
| 45 |
WarningWrite will make a message box, |
| 46 |
in all other cases the warning just goes to ErrOutput. |
| 47 |
The warning is also logged using CastleLog. } |
| 48 |
procedure OnWarningWrite(const AType: TWarningType; const Category, S: string); |
| 49 |
|
| 50 |
{ Assign this to OnWarning to only log warnings using CastleLog. } |
| 51 |
procedure OnWarningLog(const AType: TWarningType; const Category, S: string); |
| 52 |
|
| 53 |
type |
| 54 |
TWarningProc = procedure (const AType: TWarningType; const Category, S: string); |
| 55 |
|
| 56 |
var |
| 57 |
{ Reporting warnings. Used by other units to report |
| 58 |
warnings about various data (images, sound files, 3D models), |
| 59 |
indicating that data is invalid in some way but we can continue. |
| 60 |
|
| 61 |
You can assign any procedure here. You can ignore, or report this warning |
| 62 |
in any way. If you want to be really strict about the data correctness, |
| 63 |
you can also raise an exception (or raise it only when type is wtMajor). |
| 64 |
|
| 65 |
The default behavior is to ignore possible warnings |
| 66 |
(as there is no safe cross-platform default place where they can be reported). |
| 67 |
Actually, you can initialize CastleLog to see warnings in the log. |
| 68 |
You can also assign your own callback to OnWarning to record and show |
| 69 |
warnings in any way. } |
| 70 |
OnWarning: TWarningProc = @OnWarningLog; |
| 71 |
|
| 72 |
implementation |
| 73 |
|
| 74 |
uses CastleUtils, SysUtils, CastleLog; |
| 75 |
|
| 76 |
procedure OnWarningWrite(const AType: TWarningType; const Category, S: string); |
| 77 |
begin |
| 78 |
WritelnWarning(Category, S); |
| 79 |
WarningWrite(ApplicationName + ': ' + Category + ' warning: ' + S); |
| 80 |
end; |
| 81 |
|
| 82 |
procedure OnWarningLog(const AType: TWarningType; const Category, S: string); |
| 83 |
begin |
| 84 |
WritelnWarning(Category, S); |
| 85 |
end; |
| 86 |
|
| 87 |
end. |