unit cde_SettingsForm;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls, ExtCtrls, Buttons, cde_dir,
     cde_lang;
type
  { Tcde_Settings }
  Tcde_Settings = class(TForm)
    FlagsList: TImageList;
    LanguageBox: TListView;
    OkBtn: TBitBtn;
    CancelBtn: TBitBtn;
    ButtonsSep: TBevel;
    Browse: TLabel;
    ButtonsPanel: TPanel;
    SettingsPages: TPageControl;
    LanguageSht: TTabSheet;
    BrowseSht: TTabSheet;
    TabsImages: TImageList;
    SettingsTree: TTreeView;
    procedure SettingsTreeChange(Sender: TObject; Node: TTreeNode);
  private
    procedure FillLanguageList;
  public
  end;
var
  cde_Settings: Tcde_Settings;
implementation
{$R *.lfm}
{ Tcde_Settings }
procedure Tcde_Settings.FillLanguageList;
var SR: TSearchRec;
    LI: TListItem;
    Indx: IntEx;
    FLanguage: String;
begin
Indx:= -1;
LanguageBox.Items.Clear;
if FindFirstUTF8(IncludeTrailingBackslash(GetC) + 'Languages\*.json', faAnyFile, SR) = 0 then
  repeat
  if (not ((SR.Name = '.') or (SR.Name = '..'))) and FileExistsUTF8(SFPPath + 'Languages\' + SR.Name) then
   begin
   LI:= LanguageList.Items.Add;
   FLanguage:= ExtractFileNameWithoutExt(SR.Name);
   LI.Caption:= FLanguage;
   UpdateLanguageInfo(LI, FLanguage);
   if FLanguage = GetLanguage(LoadingFrm.SessionID) then
    Indx:= LI.Index;
   end;
  until FindNextUTF8(SR) <> 0;
 FindCloseUTF8(SR);
 LanguageList.Items.Item[Indx].Selected:= True;
 end;
end;
procedure Tcde_Settings.SettingsTreeChange(Sender: TObject; Node: TTreeNode);
begin
SettingsPages.ActivePageIndex:= Node.StateIndex;
end;
end.
