unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg, XPMan, StdCtrls, ComCtrls, Menus, ToolWin,
Buttons, Contnrs, JvGIF, JvComponent, JvRollOut, ActnList, StdActns,
ActnMan, ActnCtrls, ActnMenus, ActnColorMaps, ImgList, XPStyleActnCtrls;
type
TForm1 =
class(TForm)
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Panel2: TPanel;
CoolBar1: TCoolBar;
ComboBox1: TComboBox;
StaticText1: TStaticText;
Panel1: TPanel;
Image2: TImage;
CoolBar2: TCoolBar;
Panel3: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Bevel1: TBevel;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Panel4: TPanel;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Button15: TButton;
Button16: TButton;
Button17: TButton;
Button11: TButton;
Panel5: TPanel;
Button19: TButton;
Button20: TButton;
Button21: TButton;
Button22: TButton;
Button23: TButton;
Button24: TButton;
Button25: TButton;
Shilka_rot: TImage;
Panel6: TPanel;
Button26: TButton;
Button27: TButton;
Button28: TButton;
Button29: TButton;
Button30: TButton;
Shilka_gruen: TImage;
Tank_rot: TImage;
Tank_gruen: TImage;
Bmp_rot: TImage;
Bmp_gruen: TImage;
CoolBar3: TCoolBar;
ActionManager1: TActionManager;
ImageList1: TImageList;
XPColorMap1: TXPColorMap;
ActionMainMenuBar1: TActionMainMenuBar;
FileOpen1: TFileOpen;
ChangeSide: TAction;
Label3: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Button10Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ChangeSideExecute(Sender: TObject);
procedure ComboBox1Select(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
TMapObject =
class(TControl)
private
image: TImage;
// Für das entsprechende Einheitenbild besser vielleicht Imagelist, kann imagelist nur bmp ich brauch aber gif?
Edit: TEdit;
// Eingabefeld für Einheitenname
Einheitenname: TStaticText;
// Anzeige des Einheitennamens
X,Y: Integer;
// Position der Einheit auf Karte Y
Typ:
String;
// z.B. "Infantry", Image ist abhaengig vom Einheitentyp wo kann ich diese Abhaengigkeit berechnen oder festlegen z.B wenn Einheitentyp = 2 dann image.picture.'Panzer.bmp"
Einheitenstatus:
String;
//draggen ermoeglichen und draggingstatus
procedure EditKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
procedure DblClick(Sender: TObject);
reintroduce;
virtual;
procedure ImageClick(Sender: TObject);
procedure MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
reintroduce;
virtual;
// procedure UpdateStatus(Einheitentyp: String; Status: String);
published
property Status :
String read Einheitenstatus
write Einheitenstatus;
property Einheitentyp :
String read Typ
write Typ;
property MapX :Integer
read x
write x;
property MapY :Integer
read y
write y;
// procedure zeichnen(Mapx,Mapy:integer);
public
constructor Create(Owner: TComponent; MapX: Integer; MapY: Integer; Einheitentyp:
String; Status:
String);
reintroduce;
virtual;
{ Public-Deklarationen }
end;
Const
NamePrefix='
mapobject';
var
Form1: TForm1;
mapobject:tmapobject;
i,
index:integer;
muell,side,auswahl:
string;
Liste:TObjectList;
cool:tobject;
implementation
{$R *.dfm}
constructor TMapObject.Create(Owner: TComponent; MapX: Integer; MapY: Integer; Einheitentyp:
String; Status:
String);
begin
//inherited; [b]<--- Hier Fehler wenn nicht auskommentiret dann meldung "inkompatible Typen"[/b]
Image := TImage.Create(self);
// So muss das heißen
Image.Left:=mapx;
Image.Top:=mapy;
Image.showhint:=true;
image.autosize:=true;
Image.Transparent:=true;
if (auswahl = '
M1A1')
and (Status='
Enemy')
then image.Picture:=Form1.Tank_rot.picture;
if (auswahl = '
M1A1')
and (Status='
Friendly')
then image.Picture:=Form1.Tank_gruen.picture;
if (auswahl = '
M2A2')
and (Status='
Enemy')
then image.Picture:=Form1.Bmp_rot.picture;
if (auswahl = '
M2A2')
and (Status='
Friendly')
then image.Picture:=Form1.Bmp_gruen.picture;
if (auswahl = '
M60')
and (Status='
Enemy')
then image.Picture:=Form1.Tank_rot.picture;
if (auswahl = '
M60')
and (Status='
Friendly')
then image.Picture:=Form1.Tank_gruen.picture;
if (auswahl = '
Vulcan')
and (Status='
Enemy')
then image.Picture:=Form1.Shilka_rot.picture;
if (auswahl = '
Vulcan')
and (Status='
Friendly')
then image.Picture:=Form1.Shilka_gruen.picture;
if (auswahl = '
M113')
and (Status='
Enemy')
then image.Picture:=Form1.Bmp_rot.picture;
if (auswahl = '
M113')
and (Status='
Friendly')
then image.Picture:=Form1.Bmp_gruen.picture;
if (auswahl = '
T-80')
and (Status='
Enemy')
then image.Picture:=Form1.Tank_rot.picture;
if (auswahl = '
T-80')
and (Status='
Friendly')
then image.Picture:=Form1.Tank_gruen.picture;
if (auswahl = '
T-72')
and (Status='
Enemy')
then image.Picture:=Form1.Tank_rot.picture;
if (auswahl = '
T-72')
and (Status='
Friendly')
then image.Picture:=Form1.Tank_gruen.picture;
if (auswahl = '
BMP2')
and (Status='
Enemy')
then image.Picture:=Form1.Bmp_rot.picture;
if (auswahl = '
BMP2')
and (Status='
Friendly')
then image.Picture:=Form1.Bmp_gruen.picture;
if (auswahl = '
BMP')
and (Status='
Enemy')
then image.Picture:=Form1.Bmp_rot.picture;
if (auswahl = '
BMP')
and (Status='
Friendly')
then image.Picture:=Form1.Bmp_gruen.picture;
if (auswahl = '
Shilka')
and (Status='
Enemy')
then image.Picture:=Form1.Shilka_rot.picture;
if (auswahl = '
Shilka')
and (Status='
Friendly')
then image.Picture:=Form1.Shilka_gruen.picture;
if auswahl = '
Test'
then Image.Picture.loadfromfile('
unbenannt-3.gif');
Image.Parent := TWinControl(owner);
Edit := TEdit.Create(self);
Edit.Left:=MapX+50;
// Positionberechnung
Edit.Top:=mapy+25;
//
Edit.Parent := TWinControl(owner);
Edit.SetFocus;
Einheitenname := TStaticText.Create(self);
Einheitenname.Left:=mapx+50;
Einheitenname.Top:=mapy+25;
Einheitenname.Height:= 20;
Einheitenname.color:= clBtnface;
Einheitenname.BevelInner:= bvLowered;
Einheitenname.BevelKind:= bkSoft;
Einheitenname.BevelOuter:= bvRaised;
Einheitenname.Font.Charset:= DEFAULT_CHARSET;
Einheitenname.Font.Color:= clWindowtext;
Einheitenname.Font.Height:= -13;
Einheitenname.Font.
Name:= '
MS Sans Serif';
Einheitenname.Font.Style:= [fsBold];
Einheitenname.ParentFont:= False;
Einheitenname.TabOrder:= 1;
Einheitenname.Transparent:= False;
Einheitenname.Visible:= False;
Einheitenname.Parent := TWinControl(owner);
Edit.OnKeyDown := EditKeyDown;
Image.OnClick := Imageclick;
Image.OnDblClick:=Dblclick;
Image.Onmousedown:=mousedown;
Einheitenname.OnDblClick:=DblClick;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
Const NamePrefix='
Mapobject';
var AMapObject : TMapObject;
begin
if ssleft
in shift
then
begin
//TMapObject.Create(self,X,Y,auswahl).Name := NamePrefix+inttostr(i); //object erstellen
AMapObject := TMapObject.Create(self,X,Y,auswahl,muell);
amapobject.
Name := NamePrefix+inttostr(i);
amapobject.image.hint:=side;
Liste.add(AMapObject);
Label1.caption:=inttostr(Liste.count);
Label2.Caption:=inttostr(x)+'
, '+inttostr(y);
Form1.Image1.OnMouseDown:=nil;
inc(i);
end;
end;
procedure tmapobject.DblClick(Sender: TObject);
begin
Form1.Image1.OnMouseDown:=nil;
Einheitenname.Hide;
Edit.show;
Edit.SetFocus;
end;
procedure tmapobject.ImageClick(Sender: TObject);
//nur für test
begin
with sender
do
begin
einheitenname.caption:=name;
end
end;
procedure TMapObject.EditKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
if (Key=VK_Return)
And (edit.text<>'
')
then
begin
Einheitentyp:=auswahl;
Status:=muell;
Einheitenname.caption:=auswahl+'
:' +'
'+edit.text+'
';
Edit.Hide;
Einheitenname.Show;
Form1.Image1.OnMouseDown:=form1.image1MouseDown;
end;
if (Key=VK_Return)
And (edit.text='
')
then
begin
form1.Label1.caption:='
Fehler Sie muessen einen Namen Vergeben!';
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
form1.DoubleBuffered:=true;
i:=1;
Statictext1.doublebuffered:=true;
Liste := TObjectList.create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Liste.free;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
form1.StaticText1.caption:='
Map X = '+inttostr(x)+'
Map Y = '+inttostr(y);
end;
procedure TForm1.FormShow(Sender: TObject);
var
f:TForm;
begin
// 2 Buttons erzeugen, deren Beschriftung man dann anpasst
f := CreateMessageDialog('
Wählen Sie Ihre Seite aus ', mtInformation, [mbOk, mbCancel]);
//Beschriftung anpassen
(f.FindComponent('
Cancel')
as TButton).Caption := '
Russen';
(f.FindComponent('
OK')
as TButton).Caption := '
Allierte';
//Dialog anzeiegn
if ispositiveresult(f.ShowModal) = True
then side:='
Allierte'
else side:='
Russen';
f.Free;
end;
procedure TMapobject.MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
form1.label1.caption:='
fucking';
//ReleaseCapture;
//Perform(wm_syscommand,$f012, 0);
end;
procedure TForm1.ChangeSideExecute(Sender: TObject);
var
Item: TMapobject;
Obj : TObject;
i:integer;
begin
for i:=0
to liste.count-1
do
begin
Obj := liste[i];
// 1. Eintrag in der Liste (Index 0)
Item := Tmapobject(Obj);
// Obj wird nach TOpenDialogEntity "umgewandelt"
// dateinamen ausgeben
if item.Status='
Friendly'
then item.status:='
Enemy'
else item.Status:='
Friendly';
if (item.einheitentyp = '
M1A1')
and (item.Status='
Enemy')
then item.image.Picture:=Form1.Tank_rot.picture;
if (item.einheitentyp = '
M1A1')
and (item.Status='
Friendly')
then item.image.Picture:=Form1.Tank_gruen.picture;
if (item.einheitentyp = '
M2A2')
and (item.Status='
Enemy')
then item.image.Picture:=Form1.Bmp_rot.picture;
if (item.einheitentyp = '
M2A2')
and (item.Status='
Friendly')
then item.image.Picture:=Form1.Bmp_gruen.picture;
if (item.einheitentyp = '
M60')
and (item.Status='
Enemy')
then item.image.Picture:=Form1.Tank_rot.picture;
if (item.einheitentyp = '
M60')
and (item.Status='
Friendly')
then item.image.Picture:=Form1.Tank_gruen.picture;
if (item.einheitentyp = '
Vulcan')
and (item.Status='
Enemy')
then item.image.Picture:=Form1.Shilka_rot.picture;
if (item.einheitentyp = '
Vulcan')
and (item.Status='
Friendly')
then item.image.Picture:=Form1.Shilka_gruen.picture;
if (item.einheitentyp = '
M113')
and (item.Status='
Enemy')
then item.image.Picture:=Form1.Bmp_rot.picture;
if (item.einheitentyp = '
M113')
and (item.Status='
Friendly')
then item.image.Picture:=Form1.Bmp_gruen.picture;
if (item.einheitentyp = '
T-80')
and (item.Status='
Enemy')
then item.image.Picture:=Form1.Tank_rot.picture;
if (item.einheitentyp = '
T-80')
and (item.Status='
Friendly')
then item.image.Picture:=Form1.Tank_gruen.picture;
if (item.einheitentyp = '
T-72')
and (item.Status='
Enemy')
then item.image.Picture:=Form1.Tank_rot.picture;
if (item.einheitentyp = '
T-72')
and (item.Status='
Friendly')
then item.image.Picture:=Form1.Tank_gruen.picture;
if (item.einheitentyp = '
BMP2')
and (item.Status='
Enemy')
then item.image.Picture:=Form1.Bmp_rot.picture;
if (item.einheitentyp = '
BMP2')
and (item.Status='
Friendly')
then item.image.Picture:=Form1.Bmp_gruen.picture;
if (item.einheitentyp = '
BMP')
and (item.Status='
Enemy')
then item.image.Picture:=Form1.Bmp_rot.picture;
if (item.einheitentyp = '
BMP')
and (item.Status='
Friendly')
then item.image.Picture:=Form1.Bmp_gruen.picture;
if (item.einheitentyp = '
Shilka')
and (item.Status='
Enemy')
then item.image.Picture:=Form1.Shilka_rot.picture;
if (item.einheitentyp = '
Shilka')
and (item.Status='
Friendly')
then item.image.Picture:=Form1.Shilka_gruen.picture;
label3.Caption:=item.Einheitentyp;
//item.image.picture:=form1.Tank_rot.picture;
end;
end;
procedure TForm1.ComboBox1Select(Sender: TObject);
begin
if combobox1.itemindex=0
then image1.picture.loadfromfile('
karteend.jpg');
end;
{procedure UpdateStatus(Einheitentyp: String; Status: String);
begin
if (auswahl = 'M1A1') and (Status='Enemy') then image.Picture:=Form1.Tank_rot.picture;
if (auswahl = 'M1A1') and (Status='Friendly') then image.Picture:=Form1.Tank_gruen.picture;
if (auswahl = 'M2A2') and (Status='Enemy') then image.Picture:=Form1.Bmp_rot.picture;
if (auswahl = 'M2A2') and (Status='Friendly') then image.Picture:=Form1.Bmp_gruen.picture;
if (auswahl = 'M60') and (Status='Enemy') then image.Picture:=Form1.Tank_rot.picture;
if (auswahl = 'M60') and (Status='Friendly') then image.Picture:=Form1.Tank_gruen.picture;
if (auswahl = 'Vulcan') and (Status='Enemy') then image.Picture:=Form1.Shilka_rot.picture;
if (auswahl = 'Vulcan') and (Status='Friendly') then image.Picture:=Form1.Shilka_gruen.picture;
if (auswahl = 'M113') and (Status='Enemy') then image.Picture:=Form1.Bmp_rot.picture;
if (auswahl = 'M113') and (Status='Friendly') then image.Picture:=Form1.Bmp_gruen.picture;
if (auswahl = 'T-80') and (Status='Enemy') then image.Picture:=Form1.Tank_rot.picture;
if (auswahl = 'T-80') and (Status='Friendly') then image.Picture:=Form1.Tank_gruen.picture;
if (auswahl = 'T-72') and (Status='Enemy') then image.Picture:=Form1.Tank_rot.picture;
if (auswahl = 'T-72') and (Status='Friendly') then image.Picture:=Form1.Tank_gruen.picture;
if (auswahl = 'BMP2') and (Status='Enemy') then image.Picture:=Form1.Bmp_rot.picture;
if (auswahl = 'BMP2') and (Status='Friendly') then image.Picture:=Form1.Bmp_gruen.picture;
if (auswahl = 'BMP') and (Status='Enemy') then image.Picture:=Form1.Bmp_rot.picture;
if (auswahl = 'BMP') and (Status='Friendly') then image.Picture:=Form1.Bmp_gruen.picture;
if (auswahl = 'Shilka') and (Status='Enemy') then image.Picture:=Form1.Shilka_rot.picture;
if (auswahl = 'Shilka') and (Status='Friendly') then image.Picture:=Form1.Shilka_gruen.picture;
end: }
procedure TForm1.Button1Click(Sender: TObject);
begin
auswahl:='
M1A1';
if side='
Russen'
then muell:='
Enemy';
if side='
Allierte'
then muell:='
Friendly';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
auswahl:='
M2A2';
if side='
Russen'
then muell:='
Enemy';
if side='
Allierte'
then muell:='
Friendly';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
auswahl:='
M60';
if side='
Russen'
then muell:='
Enemy';
if side='
Allierte'
then muell:='
Friendly';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
auswahl:='
Vulcan';
if side='
Russen'
then muell:='
Enemy';
if side='
Allierte'
then muell:='
Friendly';
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
auswahl:='
M113';
if side='
Russen'
then muell:='
Enemy';
if side='
Allierte'
then muell:='
Friendly';
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
auswahl:='
T-80';
if side='
Russen'
then muell:='
Friendly';
if side='
Allierte'
then muell:='
Enemy';
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
auswahl:='
T-72';
if side='
Russen'
then muell:='
Friendly';
if side='
Allierte'
then muell:='
Enemy';
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
auswahl:='
BMP2';
if side='
Russen'
then muell:='
Friendly';
if side='
Allierte'
then muell:='
Enemy';
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
auswahl:='
BMP';
if side='
Russen'
then muell:='
Friendly';
if side='
Allierte'
then muell:='
Enemy';
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
auswahl:='
Shilka';
if side='
Russen'
then muell:='
Friendly';
if side='
Allierte'
then muell:='
Enemy';
end;
end.