Skip to content

Commit

Permalink
Replace default chart by the first loaded file
Browse files Browse the repository at this point in the history
  • Loading branch information
pchev committed Oct 26, 2021
1 parent a369c96 commit 3328b71
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
24 changes: 20 additions & 4 deletions skychart/pu_main.pas
Expand Up @@ -1363,8 +1363,9 @@ procedure Tf_main.InitDS2000;

procedure Tf_main.Init;
var
i: integer;
i,p: integer;
firstuse: boolean;
cname: string;
begin
firstuse := False;
try
Expand Down Expand Up @@ -1530,7 +1531,17 @@ procedure Tf_main.Init;
end;
if VerboseMsg then
WriteTrace('Create default chart');
CreateChild(GetUniqueName(rsChart_, True), True, def_cfgsc, def_cfgplot, True);
if FirstChart<>'' then begin
ReadChartConfig(SafeUTF8ToSys(ExpandFileNameUTF8(FirstChart)), True, false, def_cfgplot, def_cfgsc);
cname := stringreplace(extractfilename(FirstChart), blank, '_', [rfReplaceAll]);
p := pos('.', cname);
if p > 0 then
cname := copy(cname, 1, p - 1);
end
else begin
cname:=GetUniqueName(rsChart_, True);
end;
CreateChild(cname, True, def_cfgsc, def_cfgplot, True);
if InitialChartNum > 1 then
begin
if VerboseMsg then
Expand Down Expand Up @@ -2497,6 +2508,7 @@ procedure Tf_main.FormCreate(Sender: TObject);
ConfigAppdir := '';
ConfigPrivateDir := '';
CurrentTheme := 'default';
FirstChart := '';
ProcessParams1;
step := 'Init';
if VerboseMsg then
Expand Down Expand Up @@ -10780,7 +10792,10 @@ procedure Tf_main.ProcessParams1;
cmd := trim(parms);
parm := '';
end;
if cmd = '--config' then
if (ExtractFileExt(cmd) = '.cdc3') and (parm = '') and (FirstChart = '') then begin
FirstChart:=cmd;
end
else if cmd = '--config' then
begin // specify .ini file
if parm <> '' then
begin
Expand Down Expand Up @@ -10845,6 +10860,7 @@ procedure Tf_main.ProcessParams2;
end;
if (ExtractFileExt(cmd) = '.cdc3') and (parm = '') then
begin
if cmd = FirstChart then Continue;
parm := cmd;
cmd := '--load';
end;
Expand All @@ -10862,7 +10878,7 @@ procedure Tf_main.ProcessParams2;
if cmd = '--load' then
begin
pp.Add('LOAD');
pp.Add(parm);
pp.Add(ExpandFileNameUTF8(parm));
for p := pp.Count to MaxCmdArg do
pp.add('');
resp := ExecuteCmd('', pp);
Expand Down
1 change: 1 addition & 0 deletions skychart/u_constant.pas
Expand Up @@ -1485,6 +1485,7 @@ Tinit_object = record
ConfigAppdir, ConfigPrivateDir, Appdir, PrivateDir, SampleDir,
SatDir, SatArchiveDir, ArchiveDir, TempDir, ZoneDir, HomeDir, VODir,
ScriptDir, PrivateScriptDir: string;
FirstChart: string;
VarObs, CdC, MPCDir, DBDir, PictureDir, SPKdir: string;
ForceConfig, ForceUserDir, Configfile, Lang: string;
compile_time, compile_version, compile_system, compile_cpu, lclver, cpydate: string;
Expand Down

0 comments on commit 3328b71

Please sign in to comment.