📄 scenemultiplayermenuunit.pas
字号:
unit SceneMultiPlayerMenuUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, DXClass, DXSprite, DXInput, DXDraws,
DXSounds, DIB, DXWStatObj, DXWSceneUnit,DXWListBoxUnit,DXWScrollUnit,DirectPlay;
Type
TSceneMultiPlayerMenu1 = class(TScene)
Private
//Label1 : TDXWLabel;
//Edit1 : TDXWEdit;
procedure Edit1Change(Sender: TObject);
procedure BtnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Public
constructor Create; override;
procedure DoDraw; override;
end;
TSceneMultiPlayerMenu2 = class(TScene)
Private
procedure BtnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Connect;
Public
constructor Create; override;
procedure DoDraw; override;
end;
TSceneMultiPlayerMenu3 = class(TScene)
Private
SessionListBox : TDXWListBox;
JoinGameBtn : TDXWButton;
CreateGameBtn : TDXWButton;
procedure BtnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure GetSessions;
Public
constructor Create; override;
procedure DoDraw; override;
end;
implementation
Uses Main,Pathes;
{ TSceneMultiPlayerMenu1 }
procedure TSceneMultiPlayerMenu1.BtnMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Case TDXWObject(Sender).Tag of
1 : MainForm.StartScene(gsMultiPlayerMenu2);
2 : MainForm.StartScene(gsMainMenu);
end;
end;
constructor TSceneMultiPlayerMenu1.Create;
Var
id : Integer;
FileName : string;
begin
inherited Create;
FileName:='SceneMultiPlayerMenu1.dxg';
MainForm.LoadPicData(FImageList,FileName);
MainForm.SavePicData(FImageList,FileName);
DXDraw:=MainForm.DXDraw;
FFonImageID:=0;
// Label1:=TDXWLabel.Create;
// FObjectList.Add(Label1);
// With Label1 do
id:=FObjectList.Add(TDXWLabel.Create(self));
With TDXWLabel(FObjectList[id]) do
begin
Name:='Label1';
Left := 200;
Top := 100;
Font.Style:=[fsItalic,fsbold];
Font.Color := clMaroon;
Font.Size := 14;
Font.Name:='Times New Roman';
Surface:=DXDraw.Surface;
Caption:='Enter your name:';
end;
// Edit1:=TDXWEdit.Create;
// FObjectList.Add(Edit1);
// With Edit1 do
id:=FObjectList.Add(TDXWEdit.Create(self));
With TDXWEdit(FObjectList[id]) do
begin
Name:='Edit1';
Image := FImageList.Items.Find('EditPlayerName');
//Width := Image.Width;
//Height := Image.Height;
Font.Style:=[fsbold];
Font.Color := clMaroon;
Font.Size := 12;
Font.Name:='Times New Roman';
Left := 200;
Top := 150;
Surface:=DXDraw.Surface;
OnChange:=Edit1Change;
if PlayerName=''then Text:='Player1' else Text:=PlayerName;
end;
id:=FObjectList.Add(TDXWButton.Create(self));
With TDXWButton(FObjectList[id]) do
begin
Image := FImageList.Items.Find('Btn50x28x2');
//Width := Image.Width;
//Height := Image.Height;
Left := 200;
Top := 200;
Surface:=DXDraw.Surface;
Caption:='OK';
Name:='BtnOK';
Tag:=1;
OnMouseUp:=BtnMouseUp;
end;
id:=FObjectList.Add(TDXWButton.Create(self));
With TDXWButton(FObjectList[id]) do
begin
Image := FImageList.Items.Find('Btn100x28x2');
//Width := Image.Width;
//Height := Image.Height;
Left := 324;
Top := 200;
Surface:=DXDraw.Surface;
Caption:='Cancel';
Name:='BtnCancel';
Tag:=2;
OnMouseUp:=BtnMouseUp;
end;
end;
procedure TSceneMultiPlayerMenu1.DoDraw;
begin
inherited DoDraw;
end;
procedure TSceneMultiPlayerMenu1.Edit1Change(Sender: TObject);
begin
PlayerName:=TDXWedit(Sender).Text;
end;
{ TSceneMultiPlayerMenu2 }
procedure TSceneMultiPlayerMenu2.BtnMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Case TDXWObject(Sender).Tag of
//1:
//2:
//3:
4: begin
Connect;
MainForm.StartScene(gsMultiPlayerMenu3);
end;
5: MainForm.StartScene(gsMultiPlayerMenu1);
end;
end;
procedure TSceneMultiPlayerMenu2.Connect;
begin
With MainForm.DXPlay do
ProviderName:=GetProviderNameFromGUID(DPSPGUID_IPX);
end;
constructor TSceneMultiPlayerMenu2.Create;
Var
id : Integer;
FileName : string;
begin
inherited Create;
FileName:='SceneMultiPlayerMenu2.dxg';
MainForm.LoadPicData(FImageList,FileName);
MainForm.SavePicData(FImageList,FileName);
DXDraw:=MainForm.DXDraw;
FFonImageID:=0;
id:=FObjectList.Add(TDXWLabel.Create(self));
With TDXWLabel(FObjectList[id]) do
begin
Left := 200;
Top := 100;
Font.Style:=[fsItalic,fsbold];
Font.Color := clMaroon;
Font.Size := 14;
Font.Name:='Times New Roman';
Surface:=DXDraw.Surface;
Caption:='Select connection method:';
Name:='Label1';
end;
{
id:=FObjectList.Add(TDXWButton.Create(self));
With TDXWButton(FObjectList[id]) do
begin
Image := FImageList.Items.Find('Btn224x28x2');
//Width := Image.Width;
//Height := Image.Height;
Left := 200;
Top := 200;
Surface:=DXDraw.Surface;
Caption:='Direct connect';
Name:='BtnDirect';
Tag:=1;
OnMouseUp:=BtnMouseUp;
end;
id:=FObjectList.Add(TDXWButton.Create(self));
With TDXWButton(FObjectList[id]) do
begin
Image := FImageList.Items.Find('Btn224x28x2');
//Width := Image.Width;
//Height := Image.Height;
Left := 200;
Top := 228;
Surface:=DXDraw.Surface;
Caption:='Modem';
Name:='BtnModem';
Tag:=2;
OnMouseUp:=BtnMouseUp;
end;
}
id:=FObjectList.Add(TDXWButton.Create(self));
With TDXWButton(FObjectList[id]) do
begin
Image := FImageList.Items.Find('Btn224x28x2');
//Width := Image.Width;
//Height := Image.Height;
Left := 200;
Top := 256;
Surface:=DXDraw.Surface;
Caption:='IPX network';
Name:='BtnIPX';
Tag:=3;
OnMouseUp:=BtnMouseUp;
end;
id:=FObjectList.Add(TDXWButton.Create(self));
With TDXWButton(FObjectList[id]) do
begin
Image := FImageList.Items.Find('Btn100x28x2');
//Width := Image.Width;
//Height := Image.Height;
Left := 200;
Top := 300;
Surface:=DXDraw.Surface;
Caption:='Connect';
Name:='BtnConnect';
Tag:=4;
OnMouseUp:=BtnMouseUp;
end;
id:=FObjectList.Add(TDXWButton.Create(self));
With TDXWButton(FObjectList[id]) do
begin
Image := FImageList.Items.Find('Btn100x28x2');
//Width := Image.Width;
//Height := Image.Height;
Left := 324;
Top := 300;
Surface:=DXDraw.Surface;
Caption:='Previous Menu';
Name:='BtnPrevious';
Tag:=5;
OnMouseUp:=BtnMouseUp;
end;
end;
procedure TSceneMultiPlayerMenu2.DoDraw;
begin
inherited DoDraw;
end;
{ TSceneMultiPlayerMenu3 }
procedure TSceneMultiPlayerMenu3.BtnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Case TDXWObject(Sender).Tag of
1: begin//JoinGame
MainForm.DXPlay.Open2(false,SessionName,PlayerName);
end;
2: begin//CreateGame : Make Host
SessionName:='Game created by '+PlayerName;
MainForm.DXPlay.Open2(True, SessionName,PlayerName);
end;
3: MainForm.StartScene(gsMainMenu);
4: GetSessions;
//5:
end;
end;
constructor TSceneMultiPlayerMenu3.Create;
Var
id : Integer;
FileName : string;
begin
inherited Create;
FileName:='SceneMultiPlayerMenu3.dxg';
MainForm.LoadPicData(FImageList,FileName);
MainForm.SavePicData(FImageList,FileName);
DXDraw:=MainForm.DXDraw;
FFonImageID:=0;
{
id:=FObjectList.Add(TDXWPanel.Create(self));
With TDXWPanel(FObjectList[id]) do
begin
Image := FImageList.Items.Find('Panel260x180');
//Width := Image.Width;
//Height := Image.Height;
Left := 50;
Top := 200;
Surface:=DXDraw.Surface;
Name:='Panel1';
end;
}
{
id:=FObjectList.Add(TDXWScroll.Create(self));
With TDXWScroll(FObjectList[id]) do
begin
Name:='ScrollBox1';
Image := FImageList.Items.Find('Scroll15x180');
Btn1Image := FImageList.Items.Find('Btn15x20x2');
Btn2Image := FImageList.Items.Find('Btn15x20x2');
ThumbImage := FImageList.Items.Find('Thumb15x20x2_t');
Left := 460+10;
Top := 10;
Surface:=DXDraw.Surface;
end;
}
// id:=FObjectList.Add(TDXWListBox.Create(self));
// With TDXWListBox(FObjectList[id]) do
SessionListBox:=TDXWListBox.Create(self);
FObjectList.Add(SessionListBox);
With SessionListBox do
begin
Name:='SessionListBox';
Image := FImageList.Items.Find('Panel260x180');
//Width := Image.Width;
//Height:= Image.Height;
Left := 50;
Top := 200;
Font.Color := clYellow;
Font.Size := 12;
Font.Name:='Times New Roman';
Surface:=DXDraw.Surface;
LineHeight:=26;
//Strings.LoadFromFile(GetName('Data\Common.txt'));
{
Strings.BeginUpdate;
Strings.Add('When focused,');
Strings.Add('press Up/Down to scroll');
Strings.Add('11111111111111111');
Strings.Add('22222222222222222');
Strings.Add('33333333333333333');
Strings.Add('44444444444444444');
Strings.Add('55555555555555555');
Strings.Add('66666666666666666');
Strings.Add('77777777777777777');
Strings.Add('88888888888888888');
Strings.Add('99999999999999999');
Strings.Add(' aaaaaaaa');
Strings.Add('AAAAAAAAAAAAAAAAA');
Strings.Add('BBBBBBBBBBBBBBBBB');
Strings.EndUpdate;
}
//ScrollBar:=TDXWScroll(FObjectList[id-1]);
end;
{
id:=FObjectList.Add(TDXWLabel.Create(self));
With TDXWLabel(FObjectList[id]) do
begin
Left := 55;
Top := 170;
Font.Style:=[fsItalic,fsbold];
Font.Color := clWhite;
Font.Size := 14;
Font.Name:='Times New Roman';
Surface:=DXDraw.Surface;
Caption:='Current Games:';
Name:='Label1';
end;
}
// id:=FObjectList.Add(TDXWButton.Create(self));
// With TDXWButton(FObjectList[id]) do
JoinGameBtn:=TDXWButton.Create(self);
FObjectList.Add(JoinGameBtn);
With JoinGameBtn do
begin
Name:='JoinGameBtn';
Image := FImageList.Items.Find('Btn224x28x2');
//Width := Image.Width;
//Height := Image.Height;
Left := 350;
Top := 200;
Surface:=DXDraw.Surface;
Caption:='Join Game';
Tag:=1;
Enabled:=false;
OnMouseUp:=BtnMouseUp;
end;
// id:=FObjectList.Add(TDXWButton.Create(self));
// With TDXWButton(FObjectList[id]) do
CreateGameBtn:=TDXWButton.Create(self);
FObjectList.Add(CreateGameBtn);
With CreateGameBtn do
begin
Image := FImageList.Items.Find('Btn224x28x2');
//Width := Image.Width;
//Height := Image.Height;
Left := 350;
Top := 240;
Surface:=DXDraw.Surface;
Caption:='Create Game';
Name:='BtnCreate';
Tag:=2;
OnMouseUp:=BtnMouseUp;
end;
id:=FObjectList.Add(TDXWButton.Create(self));
With TDXWButton(FObjectList[id]) do
begin
Image := FImageList.Items.Find('Btn224x28x2');
//Width := Image.Width;
//Height := Image.Height;
Left := 350;
Top := 280;
Surface:=DXDraw.Surface;
Caption:='Disconnect';
Name:='BtnDisconnect';
Tag:=3;
OnMouseUp:=BtnMouseUp;
end;
id:=FObjectList.Add(TDXWButton.Create(self));
With TDXWButton(FObjectList[id]) do
begin
Name:='BtnReNew';
Image := FImageList.Items.Find('Btn224x28x2');
Left := 68;
Top := 385;
Surface:=DXDraw.Surface;
Caption:='ReNew Current Games';
Tag:=4;
OnMouseUp:=BtnMouseUp;
end;
id:=FObjectList.Add(TDXWButton.Create(self));
With TDXWButton(FObjectList[id]) do
begin
Name:='CurGameLabel';
Image := FImageList.Items.Find('CurrentGame244x40');
Left := 58;
Top := 150;
Surface:=DXDraw.Surface;
Enabled:=false;
end;
GetSessions;
end;
procedure TSceneMultiPlayerMenu3.DoDraw;
begin
inherited DoDraw;
end;
procedure TSceneMultiPlayerMenu3.GetSessions;
begin
with MainForm.DXPlay do
begin
GetSessions;
SessionListBox.Strings.Assign(Sessions);
end;
JoinGameBtn.Enabled := SessionListBox.Strings.Count>0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -