Skip to content

Commit f2dff59

Browse files
committed
Show filename when required file not found
1 parent 964ffa1 commit f2dff59

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

src/tracker.pas

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,24 +1450,38 @@ procedure TfrmTracker.InstrumentTypeComboboxChange(Sender: TObject);
14501450
LoadInstrument(CurrentInstrumentBank, InstrumentNumberSpinner.Value);
14511451
end;
14521452

1453+
procedure CheckRequiredFile(FilePath: String; Directory: Boolean = False);
1454+
var
1455+
Exists: Boolean;
1456+
begin
1457+
if Directory then
1458+
Exists := DirectoryExists(Filepath)
1459+
else
1460+
Exists := FileExists(FilePath);
1461+
1462+
if not Exists then begin
1463+
MessageDlg('Error',
1464+
'hUGETracker can''t load '+ExtractFileName(FilePath)+', which is a '+
1465+
IfThen(Directory, 'directory', 'file')+' that comes with '+
1466+
'the tracker. This likely means that you haven''t extracted the program ' +
1467+
'before running it. Please do so, and relaunch. Thanks!',
1468+
mtError, [mbOk], 0);
1469+
Halt;
1470+
end;
1471+
end;
1472+
14531473
procedure TfrmTracker.FormCreate(Sender: TObject);
14541474
var
14551475
PUI: PtrUint;
14561476
SampleSongs: TStringList;
14571477
S: String;
14581478
MenuItem: TMenuItem;
14591479
begin
1460-
if (not FileExists(ConcatPaths([RuntimeDir, 'PixeliteTTF.ttf'])))
1461-
or (not FileExists(ConcatPaths([RuntimeDir, 'halt.gb'])))
1462-
or (not FileExists(ConcatPaths([RuntimeDir, 'halt.sym'])))
1463-
or (not DirectoryExists(ConcatPaths([RuntimeDir, 'hUGEDriver']))) then begin
1464-
MessageDlg('Error',
1465-
'hUGETracker can''t load a required file which comes with '+
1466-
'the tracker. This likely means that you haven''t extracted the program ' +
1467-
'before running it. Please do so, and relaunch. Thanks!',
1468-
mtError, [mbOk], 0);
1469-
Halt;
1470-
end;
1480+
ShowMessage(GetCurrentDir);
1481+
CheckRequiredFile(ConcatPaths([RuntimeDir, 'PixeliteTTF.ttf']));
1482+
CheckRequiredFile(ConcatPaths([RuntimeDir, 'halt.gb']));
1483+
CheckRequiredFile(ConcatPaths([RuntimeDir, 'halt.sym']));
1484+
CheckRequiredFile(ConcatPaths([RuntimeDir, 'hUGEDriver']), True);
14711485

14721486
{$ifdef PRODUCTION}
14731487
Application.OnException := @CustomExceptionHandler;

0 commit comments

Comments
 (0)