unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IniFiles, ClipBrd;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    FileNameEdt: TEdit;
    Label2: TLabel;
    Id1Edt: TEdit;
    Id2Edt: TEdit;
    Label4: TLabel;
    Hard1Edt: TEdit;
    Hard2Edt: TEdit;
    Label5: TLabel;
    Real1Edt: TEdit;
    Real2Edt: TEdit;
    Button1: TButton;
    CodeMemo: TMemo;
    Label3: TLabel;
    Hard3Edt: TEdit;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;



implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var i,j:byte; cm:string; v:TIniFile; up,down,left,right:string;
begin
 v := TIniFile.Create('.\values.ini');
 CodeMemo.Lines.Clear;
 CodeMemo.Lines.BeginUpdate;
 CodeMemo.Lines.Add('// This has been generated by GigClbt by LolSoft');
 for i := 0 to 3 do begin
  for j := 0 to 3 do begin
   cm := 'TerrainMaterial ';
   if (i=0) and (j=0) then cm := cm+'id='+Id1Edt.text+' ' else
   if (i=3) and (j=3) then cm := cm+'id='+Id2Edt.text+' ' else
    cm := cm+'     ';
   cm := cm+'image="'+FileNameEdt.Text+'" ';
   cm := cm+'u=0.'+IntToStr(j*25)+' v=0.'+IntToStr(i*25)+' ';
   if v.ReadInteger('val_'+IntToStr(i)+'_'+IntToStr(j), 'up', 1)=1 then
    up := Real1Edt.Text else up := Real2Edt.Text;
   if v.ReadInteger('val_'+IntToStr(i)+'_'+IntToStr(j), 'down', 1)=1 then
    down := Real1Edt.Text else down := Real2Edt.Text;
   if v.ReadInteger('val_'+IntToStr(i)+'_'+IntToStr(j), 'left', 1)=1 then
    left := Real1Edt.Text else left := Real2Edt.Text;
   if v.ReadInteger('val_'+IntToStr(i)+'_'+IntToStr(j), 'right', 1)=1 then
    right := Real1Edt.Text else right := Real2Edt.Text;
   cm := cm+'up='+up+' down='+down+' left='+left+' right='+right+' ';

   if (i=0) and (j=0) then cm := cm+'hard='+Hard1Edt.text else
   if (i=3) and (j=3) then cm := cm+'hard='+Hard2Edt.text else
    cm := cm+'hard='+Hard3Edt.text;
   CodeMemo.Lines.Add(cm);
  end;
 end;
 v.Free;
 CodeMemo.Lines.EndUpdate;
 CodeMemo.SelectAll;
 Form1.ActiveControl := CodeMemo;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 Clipboard.SetTextBuf(PChar(CodeMemo.Lines.Text));
end;

end.
