unit frmInfoUnt;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, Buttons;

type
  TfrmInfo = class(TForm)
    imgScreenShot: TImage;
    imgBoxFrontScan: TImage;
    imgCartScan: TImage;
    imgBoxBackScan: TImage;
    btnManual: TBitBtn;
    imgBoxSideScan: TImage;
    imgOverlayScan: TImage;
    procedure FormClick(Sender: TObject);
    procedure btnManualClick(Sender: TObject);
  private
    { Private declarations }
    Cap   : String;
    FName : String;
    Procedure ClearImage(Var Img: TImage; Stretch: Boolean);
    Procedure OpenFile(Const Filename: String; Img: TImage);
  public
    { Public declarations }
    Procedure LoadImages(FileName: String);
  end;

var
  frmInfo: TfrmInfo;

implementation

{$R *.DFM}

Uses Base,JPEG, frmManualUnt;

Procedure TfrmInfo.OpenFile(Const Filename: String; Img: TImage);
Begin
  Try
    Img.Picture.LoadFromFile(Filename);
  Except
    On EInvalidGraphic Do Img.Picture.Graphic := Nil;
  End;
End; // TfrmInfo.OpenFile

Procedure TfrmInfo.ClearImage(Var Img: TImage; Stretch: Boolean);
Var R: TRect;
Begin
  R.Left   := Img.Left;
  R.Top    := Img.Top;
  R.Right  := Img.Width;
  R.Bottom := Img.Height;
  Img.Free;
  Img := TImage.Create(Self);
  Img.Parent      := Self;
  Img.Left        := R.Left;
  Img.Top         := R.Top;
  Img.Width       := R.Right;
  Img.Height      := R.Bottom;
  Img.Stretch     := Stretch;
  Img.Visible     := True;
  Img.Enabled     := True;
  Img.AutoSize    := False;
  Img.Transparent := False;
  Img.OnClick     := FormClick;
End; // TfrmInfo.ClearImage

Procedure TfrmInfo.LoadImages(FileName: String);
Var
  St : String;
  I  : Integer;
  SS : String;
  BF : String;
  BB : String;
  BS : String;
  CS : String;
  OS : String;

begin
  ClearImage(imgScreenShot,False);
  ClearImage(imgBoxFrontScan,True);
  ClearImage(imgBoxBackScan,True);
  ClearImage(imgBoxSideScan,True);
  ClearImage(imgCartScan,True);
  ClearImage(imgOverlayScan,True);
  Cap   := Caption;
  St    := FileName;
  FName := St;
//  I := Pos('.',St);
  I := Length(St);
  While (St[I] <> '.') And (I > 0) Do Dec(I);
  If I <> 0 Then St := Copy(St,1,I - 1);
  SS := Config.ScreenShotPath;
  BF := Config.BoxFrontScanPath;
  BB := Config.BoxBackScanPath;
  BS := Config.BoxSideScanPath;
  CS := Config.CartScanPath;
  OS := Config.OverlayScanPath;
  If (SS <> '') And Not (SS[Length(SS)] In [':','\']) Then SS := SS + '\';
  If (BF <> '') And Not (BF[Length(BF)] In [':','\']) Then BF := BF + '\';
  If (BB <> '') And Not (BB[Length(BB)] In [':','\']) Then BB := BB + '\';
  If (BS <> '') And Not (BS[Length(BS)] In [':','\']) Then BS := BS + '\';
  If (CS <> '') And Not (CS[Length(CS)] In [':','\']) Then CS := CS + '\';
  If (OS <> '') And Not (OS[Length(OS)] In [':','\']) Then OS := OS + '\';

  If FileExists(SS + St + '.BMP') Then OpenFile(SS + St + '.BMP',imgScreenShot) Else
   If FileExists(SS + St + '.JPG') Then OpenFile(SS + St + '.JPG',imgScreenShot);

  If FileExists(BF + St + '.BMP') Then OpenFile(BF + St + '.BMP',imgBoxFrontScan) Else
   If FileExists(BF + St + '.JPG') Then OpenFile(BF + St + '.JPG',imgBoxFrontScan);

  If FileExists(BB + St + '.BMP') Then OpenFile(BB + St + '.BMP',imgBoxBackScan) Else
   If FileExists(BB + St + '.JPG') Then OpenFile(BB + St + '.JPG',imgBoxBackScan);

  If FileExists(BS + St + '.BMP') Then OpenFile(BS + St + '.BMP',imgBoxSideScan) Else
   If FileExists(BS + St + '.JPG') Then OpenFile(BS + St + '.JPG',imgBoxSideScan);

  If FileExists(CS + St + '.BMP') Then OpenFile(CS + St + '.BMP',imgCartScan) Else
   If FileExists(CS + St + '.JPG') Then OpenFile(CS + St + '.JPG',imgCartScan);

  If FileExists(OS + St + '.BMP') Then OpenFile(OS + St + '.BMP',imgOverlayScan) Else
   If FileExists(OS + St + '.JPG') Then OpenFile(OS + St + '.JPG',imgOverlayScan);
end; // TfrmInfo.LoadImages

procedure TfrmInfo.FormClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmInfo.btnManualClick(Sender: TObject);
Var
  MP : String;
  St : String;
  I  : Integer;

  Procedure OpenManual(FileName: String; RTF: Boolean);
  Var Flags: OLEVariant;
  Begin
//    frmManual.reManual.PlainText := Not RTF;
//    frmManual.reManual.Lines.Clear;
//    frmManual.reManual.Lines.LoadFromFile(FileName);
    Flags := 0;
    frmManual.wbManual.Navigate('file://' + FileName, Flags, Flags, Flags, Flags);
    frmManual.ShowModal;
  End; // OpenManual

begin
  St   := FName;
  I    := Length(St);
  While (St[I] <> '.') And (I > 0) Do Dec(I);
  If I <> 0 Then St := Copy(St,1,I - 1);

  MP := Config.ManualPath;
  If (MP <> '') And Not (MP[Length(MP)] In [':','\']) Then MP := MP + '\';

       If FileExists(MP + St + '.TXT')  Then OpenManual(MP + St + '.TXT',False)
  Else If FileExists(MP + St + '.RTF')  Then OpenManual(MP + St + '.RTF',True)
  Else If FileExists(MP + St + '.PDF')  Then OpenManual(MP + St + '.PDF',True)
  Else If FileExists(MP + St + '.HTM')  Then OpenManual(MP + St + '.HTM',True)
  Else If FileExists(MP + St + '.HTML') Then OpenManual(MP + St + '.HTML',True);
end;

end.

// ----------------------------------------------------------------------
// IntvWin - Mattel Intellivision Emulator
// Copyright (C) 2000 John Dullea
//
//  This program 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 2 of the License, or
//  (at your option) any later version.
//
//  This program 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 program; if not, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// ----------------------------------------------------------------------
