Skip to content

Commit

Permalink
Now confirms for registry read game paths. #2
Browse files Browse the repository at this point in the history
  • Loading branch information
forcecore committed Apr 27, 2016
1 parent ca16a78 commit 16cf8ae
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions src/settings.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
interface

uses
Classes, SysUtils, Registry, jsonConf, Dialogs,
Classes, SysUtils, Registry, jsonConf, Dialogs, Controls,
Common;

// Class to hold user settings and reading registry.
Expand All @@ -22,7 +22,7 @@ TSettings = class

//function GetMyDoc(): string;
function GenReg( t: string ): string;
function GetInstallDir(): string;
function GetInstallDir: string;

// Property getter setters
function GetGameDir(): string;
Expand Down Expand Up @@ -73,7 +73,7 @@ procedure TSettings.LoadConf();
conf.Filename := json_fname; // created if NE. loads if E.
end;

function TSettings.GetInstallDir(): string;
function TSettings.GetInstallDir: string;
var
filename: string;
diag: TOpenDialog;
Expand All @@ -86,26 +86,32 @@ function TSettings.GetInstallDir(): string;
// If dir, returns False.
if( FileExists( result ) ) then
begin
result := ExtractFilePath( result );
// Ask user confirmation
if MessageDlg( '확인', '다음 제로아워 경로가를 사용하겠습니까?:' + sLineBreak + result,
mtConfirmation, [mbYes, mbNo],0) = mrYes
then
begin
result := ExtractFilePath( result );
exit;
end
else
result := ''; // forget what we got
end;

// Still, we might have failed to find Generals.
// Then, let the user decide.
if( result = '' ) then
begin
try
diag := TOpenDialog.create( nil );
diag.Options := [ofFileMustExist];
diag.Filter := 'Exe파일|*.exe';
if diag.Execute then
begin
filename := diag.Filename;
result := ExtractFilePath( filename );
end;
finally
diag.free;
// Then, let the user find int.
try
diag := TOpenDialog.create( nil );
diag.Options := [ofFileMustExist];
diag.Filter := 'Exe파일|*.exe';
if diag.Execute then
begin
filename := diag.Filename;
result := ExtractFilePath( filename );
end;
end;
finally
diag.free;
end;
end;

procedure TSettings.SetGameDir(AValue: string);
Expand Down

0 comments on commit 16cf8ae

Please sign in to comment.