program OniUnPacker;

uses
  Forms, Windows,
  Main in 'Main.pas' {Form_Main},
  Data in 'Data.pas',
  Helper_LevelDB in 'Helper_LevelDB.pas' {Form_LevelDB},
  Helper_ValueEdit in 'Helper_ValueEdit.pas' {Form_ValueEdit},
  Settings in 'Settings.pas' {Form_Settings},
  FTypeReg in 'FTypeReg.pas',
  Functions in 'Code\Functions.pas',
  Exporters in 'Code\Exporters.pas',
  OniImgClass in 'Code\OniImgClass.pas',
  DataStructures in 'Code\DataStructures.pas',
  OniDataClass in 'Code\OniDataClass.pas',
  Template in 'Tools\Template.pas' {Form_ToolTemplate},
  Preview in 'Tools\Preview.pas' {Form_Preview},
  BinEdit in 'Tools\BinEdit.pas' {Form_ToolTemplate2},
  Extractor in 'Tools\Extractor.pas' {Form_ToolTemplate3},
  RawEdit in 'Tools\RawEdit.pas' {Form_ToolTemplate4},
  TxmpReplace in 'Tools\TxmpReplace.pas' {Form_ToolTemplate5},
  FolderBrowser in 'Code\FolderBrowser.pas';

{$R *.res}
{$R ExtraIcos.res}
const
  MutexName = 'Oni Un/Packer';
var
  hMutex: THandle;

begin
  hMutex := CreateMutex(nil, True, MutexName);
  if (hMutex = 0) or (GetLastError = ERROR_ALREADY_EXISTS) then
  begin
    PostMessage(HWND_BROADCAST, 0, 0, 0);
  end
  else
  begin
    Application.Initialize;
    Application.Title := 'Oni Un/Packer';
    Application.CreateForm(TForm_Main, Form_Main);
    Application.CreateForm(TForm_LevelDB, Form_LevelDB);
    Application.CreateForm(TForm_ValueEdit, Form_ValueEdit);
    Application.CreateForm(TForm_Settings, Form_Settings);
    Application.Run;
  end;
  CloseHandle(hMutex);
end.