///////////////////////////////////////////////////////////////////////
// Copyright (C) Andru 2007                                          //
// mail: dr.andru@gmail.com                                          //
// site: http://andru.2x4.ru                                         //
//                                                                   //
// OMEGA Engine is free software.                                    //
//                                                                   //
// You may redistribute it and/or modify it under the terms of the   //
// GNU General Public License, as published by the Free Software     //
// Foundation; either version 2 of the License, or (at your option)  //
// any later version.                                                //
//                                                                   //
// this module 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 this module.  If not, write to:                        //
// 	The Free Software Foundation, Inc.,                              //
// 	51 Franklin Street, Fifth Floor                                  //
// 	Boston, MA  02110-1301, USA.                                     //
///////////////////////////////////////////////////////////////////////
unit ENGINE_UTILS;

{$I DEFINES.pas}

interface
uses
  Windows,
  OpenGL,

  ENGINE_VAR
  ;

procedure Mem_Get( var p : Pointer; Size : Integer ); stdcall;
procedure Mem_Realloc( var p : Pointer; Size : Integer ); stdcall;
procedure Mem_Free( var p ); stdcall;
procedure Mem_Move( const Source; var Dest; Size : Integer  ); stdcall;

procedure E_Error  ( Mess : String );
procedure E_Warning( Mess : String );

// В каком режиме загружена система
// 0    - нормальный
// 1, 2 - безопасный режим
function WinBoot : Byte;

function StrUp( Str : String ) : String;

//----------------------------------------------------------------------------//
                                 IMPLEMENTATION
//----------------------------------------------------------------------------//
uses ENGINE_LOG, UTILS;

procedure E_Error;
Begin

if app_ShowErrors Then
MessageBox(
            wnd_HWND,
            PChar( Mess ),
            {$IFDEF RUS} 'ОШИБКА!' {$ELSE} 'ERROR!' {$ENDIF},
            MB_OK or MB_ICONERROR
          );

if app_Log Then
  LOG_AddMessage( LOGT_ERROR, PChar( Mess ) );

End;

procedure E_Warning;
Begin

if app_ShowWarnings Then
MessageBox(
            wnd_HWND,
            PChar( Mess ),
            {$IFDEF RUS} 'ПРЕДУПРЕЖДЕНИЕ!' {$ELSE} 'WARNING!' {$ENDIF},
            MB_OK or MB_ICONWARNING
          );

if app_Log Then
  LOG_AddMessage( LOGT_WARNING, PChar( Mess ) );

End;

function WinBoot : Byte;
Begin

Result := GetSystemMetrics( SM_CLEANBOOT );

End;

function StrUp;
  var
    i, l : Integer;
Begin
l := length( Str );
for i := 1 to l do
  if ( ( Byte( Str[ i ] ) >= 97 ) and ( Byte( Str[ i ] ) <= 122 ) ) or
     ( ( Byte( Str[ i ] ) >= 224 ) and ( Byte( Str[ i ] ) <= 255 ) ) Then
    Str[ i ] := Chr( Byte( Str[ i ] ) - 32 );
Result := Str;
End;

procedure Mem_Get;
Begin
GetMem( p, Size );
End;

procedure Mem_Realloc;
Begin
ReallocMem( p, Size );
End;

procedure Mem_Free;
Begin
FreeMem( Pointer( p ) );
End;

procedure Mem_Move;
Begin
End; 

end.
