SRL Archive - General

Semi finished form


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:

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:

Sir R. M8gic1an

2010-02-06 10:30:21

Small update.

Simba now compiles with SRL 4, suggesting that it will soon be out and usable. I don't think the form is a necessity but rather a very nice addition. How is the rest of MSI? Are we ready to release it? Does it compile? Has anyone had a test run with it?

~RM

Naum

2010-02-06 13:57:34

From: Rasta Magician
Small update.

Simba now compiles with SRL 4, suggesting that it will soon be out and usable. I don't think the form is a necessity but rather a very nice addition. How is the rest of MSI? Are we ready to release it? Does it compile? Has anyone had a test run with it?

~RM


Great! Will simba be able to support forms or not, or will it be a possibility in the future?
If SRL is compiling nice and smooth along with MSI, I'll ask everyone where they are, and what we need to do.

NCDS

2010-02-06 14:28:37

As posted in another thread the walking works.

Nava2

2010-02-06 15:14:02

Simba will more than likely never *fully* support forms.

Coh3n

2010-02-09 12:05:28

From: Nava2
Simba will more than likely never *fully* support forms.

How hard is it to fully implement it? I may have asked you this before…

I think all we need is someone to write the mainloop and progress report. If we aren't using a form we'll need DeclarePlayers, etc.

mastaraymond

2010-02-09 12:59:58

Actually they have been supported by Simba since the first release.. However it's not really an official support ^_^

Sir R. M8gic1an

2010-02-09 13:18:20

Progress reprot is fully done as far as I remember, we jsut need to increment the report variables.

~RM

Coh3n

2010-02-09 13:48:42

From: mastaraymond
Actually they have been supported by Simba since the first release.. However it's not really an official support ^_^

Oh, so they work? I was under the impression they didn't work at all. *cough* Nava *cough*

From: Rasta Magician
Progress reprot is fully done as far as I remember, we jsut need to increment the report variables.

~RM

Oh, great! I didn't realize it was started at all. :duh:

Sir R. M8gic1an

2010-02-09 14:07:35

http://srl-msi.googlecode.com/svn/trunk/Debug.scar

~RM ;)

Coh3n

2010-02-09 14:08:29

From: Rasta Magician
http://srl-msi.googlecode.com/svn/trunk/Debug.scar

~RM ;)

Yeah, I found it after you said it was done. :p