Naum
2010-02-05 02:50:43
Discussed this with RM, parents limiting my computer down, so an error takes up my whole slot to fix. lol.
Hopefully someone can finish it off, this code is a great example of ripping code from other scripts (marpis :p), I got the add/delete button working - the tab's tend to crash now and then..
So if anyone's interested:
I'm really sorry.:redface:
Hopefully someone can finish it off, this code is a great example of ripping code from other scripts (marpis :p), I got the add/delete button working - the tab's tend to crash now and then..
So if anyone's interested:
program New;
{.Include SRL/SRL.scar}
Const B_Add = 0;
B_Del = 1;
B_Clear = 2;
L_User = 3;
L_Pass = 4;
L_Nick = 5;
L_Active = 6;
E_User = 7;
E_Pass = 8;
E_Nick = 9;
C_Active = 10;
Type TTabSheetArray = Array Of TTabSheet;
Var
MSIPlayerForm : TForm;
Buttons : Array [B_Add..B_Clear] Of TButton;
Labels : Array [L_User..L_Active] Of TLabel;
Edits : Array [E_User..E_Nick] Of TEdit;
ComboBox : Array [C_Active..C_Active] Of TComboBox;
Captions : TStringArray;
TabPages : TTabSheetArray;
PageControl : TPageControl;
I : Integer;
Procedure OnMouseDown(Sender6: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Begin
If (ssCtrl In Shift) Then PageControl.BeginDrag(False);
End;
Procedure OnDragDrop(Sender7, Source: TObject; X, Y: Integer);
Begin
PageControl.ActivePage.PageIndex := PageControl.IndexOfTabAt(X, Y);
End;
Procedure OnDragOver(Sender8, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean) ;
Begin
Accept := (Sender8 Is TPageControl);
End;
Procedure DeclarePlayers;
Begin
NumberOfPlayers(1);
CurrentPlayer := 0;
With Players[0] Do
Begin
Name := '';
Pass := '';
Strings[0] := 'tuna';
Active := True;
End;
End;
Procedure AddPage(P_Add : TObject);
Begin
Inc(HowManyPlayers);
SetLength(TabPages, HowManyPlayers);
NumberOfPlayers(HowManyPlayers);
Players[HowManyPlayers - 1].Name := 'Player '+IntToStr(HowManyPlayers - 1);
Players[HowManyPlayers - 1].Pass := 'password';
Players[HowManyPlayers - 1].Nick := 'lay';
Players[HowManyPlayers - 1].Pin := '1234';
Players[HowManyPlayers - 1].Strings[0] := 'Anchovies';
Players[HowManyPlayers - 1].Active := True;
TabPages[HowManyPlayers - 1] := TTabSheet.Create(MSIPlayerForm);
TabPages[HowManyPlayers - 1].PageControl := PageControl;
If (Players[HowManyPlayers - 1].Name <> '') Then
TabPages[HowManyPlayers - 1].Caption := Players[HowManyPlayers - 1].Name
Else
TabPages[HowManyPlayers - 1].Caption := 'Player ' + IntToStr(HowManyPlayers - 1);
End;
Procedure DeletePage(P_Delete : TObject);
Begin
Try
Dec(HowManyPlayers);
WriteLn('Swapping Players...');
Swap(Players[PageControl.ActivePageIndex], Players[HowManyPlayers]);
WriteLn('Swapping PlayerInfoEdits...');
Swap(Players[PageControl.ActivePageIndex], Players[HowManyPlayers]);
TabPages[PageControl.ActivePageIndex].Free;
SetLength(TabPages, HowManyPlayers);
NumberOfPlayers(HowManyPlayers);
For I := 0 To HowManyPlayers Do
TabPages[I].Caption := 'Player '+IntToStr(I);
Except WriteLn('Cannot delete your own player')
Finally End;
End;
// This form was parsed using DFM Form Parser v.26c Beta by Ron.
// Generated from msiform.dfm.
procedure MSIForm;
var
TimeMSIForm : Integer;
begin
TimeMSIForm := GetSystemTime;
MSIPlayerForm := CreateForm;
SetLength(TabPages, 1);
PageControl := TPageControl.Create(MSIPlayerForm);
PageControl.Parent := MSIPlayerForm;
PageControl.Align := ALClient;
PageControl.OnMouseDown := @OnMouseDown;
PageControl.OnDragDrop := @OnDragDrop;
PageControl.OnDragOver := @OnDragOver;
PageControl.Visible := True;
TabPages[0] := TTabSheet.Create(MSIPlayerForm);
TabPages[0].PageControl := PageControl;
TabPages[0].Caption := 'Player 0';
with MSIPlayerForm do
begin
Position := poScreenCenter;
BorderStyle := bsSingle;
BorderIcons := [biMinimize,biSystemMenu];
ClientWidth := 471;
ClientHeight := 402;
Caption := 'frmDesign';
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
PixelsPerInch := 96;
end;
SetLength(Captions, C_Active);
Captions := ['Add Player', 'Delete Player', 'Clear Player Info',
'Name', 'Password', 'Nick', 'Active'];
For I := B_Add To B_Clear Do
Begin
Buttons[I] := TButton.Create(MSIPlayerForm);
with Buttons[I] do
begin
Parent := MSIPlayerForm;
Left := 50+ 120*I;
Top := 300;
Width := 92;
Height := 29;
Caption := Captions[I];
TabOrder := 0;
end;
End;
Buttons[B_Add].OnClick := @AddPage;
Buttons[B_Del].OnClick := @DeletePage;
For I := L_User To L_Active Do
Begin
Labels[I] := TLabel.Create(MSIPlayerForm);
with Labels[I] do
begin
Parent := MSIPlayerForm;
Left := 500;
Top := 300;
Width := Length(Captions[I])*4;
Height := 9;
Caption := Captions[I];
Visible := True;
end;
writeln(Labels[I].Caption);
End;
WriteLn('MSIForm compiled in ' + IntToStr(GetSystemTime - TimeMSIForm) + ' milliseconds!');
end;
procedure SafeMSIForm;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('MSIForm', v);
end;
procedure ShowMSIFormModal;
begin
MSIPlayerForm.ShowModal;
end;
procedure SafeShowMSIFormModal;
var
v : TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('ShowMSIFormModal', v);
end;
procedure MainMSIForm;
begin
try
SafeMSIForm;
SafeShowMSIFormModal;
finally
FreeForm(MSIPlayerForm);
except
WriteLn('An error seems to have occurred in: MSIForm');
end;
end;
begin
ClearDebug;
DeclarePlayers;
GetSelf.WindowState := wsMinimized;
MainMSIForm;
GetSelf.WindowState := wsNormal;
end.I'm really sorry.:redface: