unit uMapForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, GR32_Image, GR32, GR32_Layers, uMap, uSEditorForm, StdCtrls, StrLib;

type
  TMapForm = class(TForm)
    MapImage: TImage32;
    eX: TEdit;
    btnGo: TButton;
    lX: TLabel;
    lY: TLabel;
    eY: TEdit;
    procedure FormShow(Sender: TObject);
    procedure MapImageMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer);
    procedure btnGoClick(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure eXChange(Sender: TObject);
  private
    { Private declarations }
    procedure ZeichneMap;
  public
    { Public declarations }
  end;

var
  MapForm: TMapForm;

implementation

uses uMulpatcher;

{$R *.dfm}

procedure TMapForm.ZeichneMap;
var     Bitmap : TBitmap32;
begin
        Bitmap := Map.GesamtMap;

        MapImage.Bitmap.SetSize( 384, 256 );
        MapImage.Bitmap.Clear( Color32( clBtnFace ) );
        MapImage.Bitmap.Draw( 0, 0, Bitmap );
end;

procedure TMapForm.FormShow(Sender: TObject);
begin
        ZeichneMap;
end;

procedure TMapForm.MapImageMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer);
begin
        SEditorForm.ChangePos( X*16, Y*16 );
end;

procedure TMapForm.btnGoClick(Sender: TObject);
begin
        SEditorForm.ChangePos( StrToInt( eX.Text ), StrToInt( eY.Text ) );
end;

procedure TMapForm.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
        if Key = VK_RETURN then
                btnGoClick( Sender );
end;

procedure TMapForm.eXChange(Sender: TObject);
var     Liste : TStringList;
begin
        if Pos( ',', eX.Text ) > 0 then begin
                Liste := TStringList.Create;
                StrLib.Split( eX.Text, ',', Liste );
                eX.Text := Liste.Strings[ 0 ];
                eY.Text := Liste.Strings[ 1 ];
                Liste.Free;
        end;
end;

end.
