Santa_Clause
2007-10-01 10:22:27
Please…enlighten me on why it's so screwed up. Don't tell me to use the SRL one because I don't want to. Oh, and thanks to Bullzeye for the previous help in the other thread :)
program New;
{.include SRL/SRL.scar}
var
// GuildMinerMain variables.
SantyFormMain : TForm;
PlayerFormLabel, lblUser : TLabel;
UsernameEdit, PasswordEdit, NicknameEdit, BankPinEdit : TEdit;
Booleans1Combo, ActiveCombo, ComboBox1, Booleans0Combo : TComboBox;
BackButton, DeleteButton, CreateButton, ForwardButton, StartButton, CancelButton : TButton;
FormOption : array [0..14] of Boolean;
cUser : Integer;
function GetNumbersBool(S : string) : Boolean;
begin
Result := (Length(GetNumbers(S)) = Length(S));
end;
procedure SaveUs2;
var
f, CharsFile: Integer;
begin
if (FileName = '') then FileName := 'Chars';
CharsFile := RewriteFile(AppPath + FileName + '.dat', False);
for f := 0 to GetArrayLength(players) - 1 do
begin
WriteFileString(charsfile, 'name' + IntToStr(f) + '=' + players[f].name +
Chr(13));
WriteFileString(charsfile, 'pass' + IntToStr(f) + '=' + players[f].pass
+ Chr(13));
WriteFileString(charsfile, 'nick' + IntToStr(f) + '=' + players[f].nick
+ Chr(13));
WriteFileString(charsfile, 'active' + IntToStr(f) + '=' +
BoolToStr(players[f].active) + Chr(13));
if (FormOption[0]) then
WriteFileString(charsfile, 'loc' + IntToStr(f) + '=' +
players[f].loc + Chr(13));
if (FormOption[1]) then
WriteFileString(charsfile, 'skill' + IntToStr(f) + '=' +
players[f].skill + Chr(13));
if (FormOption[2]) then
WriteFileString(charsfile, 'boolean1' + IntToStr(f) + '=' +
BoolToStr(players[f].booleans[0]) + Chr(13));
if (FormOption[3]) then
WriteFileString(charsfile, 'boolean2' + IntToStr(f) + '=' +
BoolToStr(players[f].booleans[1]) + Chr(13));
if (FormOption[4]) then
WriteFileString(charsfile, 'boolean3' + IntToStr(f) + '=' +
BoolToStr(players[f].booleans[2]) + Chr(13));
if (FormOption[5]) then
WriteFileString(charsfile, 'integer1' + IntToStr(f) + '='
+ IntToStr(players[f].integers[0]) + Chr(13));
if (FormOption[6]) then
WriteFileString(charsfile, 'integer2' + IntToStr(f) + '='
+ IntToStr(players[f].integers[1]) + Chr(13));
if (FormOption[7]) then
WriteFileString(charsfile, 'integer3' + IntToStr(f) +
'=' + IntToStr(players[f].integers[2]) +
Chr(13));
if (FormOption[8]) then
WriteFileString(charsfile, 'integer4' + IntToStr(f)
+
'=' + IntToStr(players[f].integers[3]) +
Chr(13));
if (FormOption[9]) then
WriteFileString(charsfile, 'string1' + IntToStr(f)
+ '=' + players[f].strings[0] + Chr(13));
if (FormOption[10]) then
WriteFileString(charsfile, 'string2' +
IntToStr(f) + '=' +
players[f].strings[1] + Chr(13));
if (FormOption[11]) then
WriteFileString(charsfile, 'string3' +
IntToStr(f) + '=' +
players[f].strings[2] + Chr(13));
if (FormOption[12]) then
WriteFileString(charsfile, 'extended1' +
IntToStr(f) + '=' +
FloatToStr(players[f].extendeds[0])
+ Chr(13));
if (FormOption[13]) then
WriteFileString(charsfile, 'extended2' +
IntToStr(f) + '=' +
FloatToStr(players[f].extendeds[1]) + Chr(13));
if (FormOption[14]) then
WriteFileString(charsfile, 'extended3' +
IntToStr(f) + '=' +
FloatToStr(players[f].extendeds[2]) + Chr(13))
WriteFileString(charsfile, Chr(13));
end;
CloseFile(CharsFile);
end;
procedure SaveLastPlayerInfo;
begin
//saves current info
try
if GetArrayLength(Players) <= 0 then
begin
lblUser.Caption := 'No Players Added!';
Exit;
end;
if GetArrayLength(Players) <= cUser then cUser := 0;
if (Booleans0Combo.Text <> 'True') or (Booleans0Combo.Text <> 'False') or
(Booleans1Combo.Text <> 'True') or (Booleans1Combo.Text <> 'False') or
(ActiveCombo.Text <> 'True') or (ActiveCombo.Text <> 'False') then
begin
ShowMessage('Invalid Booleans...Reverting To Default');
Booleans0Combo.Text := 'True';
Booleans1Combo.Text := 'True';
ActiveCombo.Text := 'True';
Exit;
end;
if not(GetNumbersBool(BankPinEdit.Text)) then
begin
ShowMessage('Invalid Bank Pin...Reverting To Default');
BankPinEdit.Text := '0000';
end;
Players[cUser].Name := UsernameEdit.Text;
Players[cUser].Pass := PasswordEdit.Text;
Players[cUser].Nick := NicknameEdit.Text;
Players[cUser].Pin := StrToInt(BankPinEdit.Text);
Players[cUser].Booleans[0] := StrToBool(Booleans0Combo.Text);
Players[cUser].Booleans[1] := StrToBool(Booleans1Combo.Text);
Players[cUser].Active := StrToBool(ActiveCombo.Text);
except WriteLn('SaveLastPlayerInfo error')
end;
end;
{*******************************************************************************
procedure CreateUser(Sender : TObject);
By: The_Rs_Monkey
*******************************************************************************}
procedure CreateUser(Sender: TObject);
var
i, c: Integer;
begin
try
SaveLastPlayerInfo;
c := Length(Players);
SetArrayLength(Players, c + 1);
cUser := c;
SetLength(Players[cUser].Integers, 5);
SetLength(Players[cUser].Strings, 4);
SetLength(Players[cUser].Extendeds, 4);
UsernameEdit.Text := 'Username';
PasswordEdit.Text := 'Password';
NicknameEdit.Text := 'Nickname';
ActiveCombo.Text := 'Active?';
Booleans0Combo.Text := 'Pick Equipped?';
Booleans1Combo.Text := 'Mine Mith Ores?';
BankPinEdit.Text := 'Bank Pin?';
lblUser.Caption := 'Player # ' + IntToStr(cUser);
except WriteLn('CreateUser error') end;
end;
{*******************************************************************************
procedure LoadUserInfo;
By: The_Rs_Monkey
Description: Making player forms easier
*******************************************************************************}
procedure LoadUserInfo;
begin
try
if GetArrayLength(Players) <= 0 then
begin
CreateUser(nil);
Exit;
end;
if GetArrayLength(Players) <= cUser then cUser := 0
lblUser.Caption := 'Player # ' + IntToStr(cUser);
UsernameEdit.Text := Players[cUser].Name;
PasswordEdit.Text := Players[cUser].Pass;
NicknameEdit.Text := Players[cUser].Nick;
ActiveCombo.Text := BoolToStr(Players[cUser].Active);
if Length(Players[cUser].Booleans) >= 2 then
begin
Booleans0Combo.Text := BoolToStr(Players[cUser].Booleans[0]);
Booleans1Combo.Text := BoolToStr(Players[cUser].Booleans[1]);
end;
BankPinEdit.Text := IntToStr(Players[cUser].Pin);
except WriteLn('LoadUserInfo error') end;
end;
{*******************************************************************************
procedure ForwardUser(Sender : TObject);
By: The_Rs_Monkey
*******************************************************************************}
procedure ForwardUser(Sender: TObject);
begin
SaveLastPlayerInfo;
if GetArrayLength(Players) = 0 then Exit;
if GetArraylength(Players) - 1 = cUser then
cUser := 0
else
cUser := cUser + 1;
LoadUserInfo;
end;
{*******************************************************************************
procedure BackUser(Sender : TObject);
By: The_Rs_Monkey
*******************************************************************************}
procedure BackUser(Sender: TObject);
begin
SaveLastPlayerInfo;
if GetArrayLength(Players) = 0 then Exit;
if cUser = 0 then
cUser := GetArrayLength(Players) - 1
else
cUser := cUser - 1;
LoadUserInfo;
end;
{*******************************************************************************
procedure DeleteUser(Sender : TObject);
By: The_Rs_Monkey
*******************************************************************************}
procedure DeleteUser(Sender: TObject);
var
monkey, orgcUser : Integer;
begin
SaveLastPlayerInfo;
if (GetArrayLength(Players) = 1) or (GetArrayLength(Players) = 0) then
begin
SetArrayLength(Players, 0);
ShowMessage('No Players');
lblUser.Caption := 'No Players Added!';
Exit;
end;
orgcUser := cUser;
if orgcUser < GetArrayLength(Players) - 1 then
for monkey := orgcUser to GetArrayLength(Players) - 2 do
begin
cUser := monkey + 1;
LoadUserInfo;
cUser := monkey;
SaveLastPlayerInfo;
end;
if cUser <= GetArrayLength(Players) - 1 then
cUser := orgcUser;
SetArrayLength(Players, GetArrayLength(Players) - 1);
if (cUser > GetArrayLength(Players) - 1) then
cUser := GetArrayLength(Players) - 1
LoadUserInfo;
end;
{*******************************************************************************
procedure Start(Sender : TObject);
By: The_Rs_Monkey
*******************************************************************************}
procedure Start(Sender: TObject);
begin
SaveLastPlayerInfo;
cUser := 0;
SantyFormMain.ModalResult := mrOk;
if GetArrayLength(Players) <= 0 then
begin
ShowMessage('No Players!');
end;
end;
procedure GuildMinerMain;
begin
SantyFormMain := CreateForm;
with SantyFormMain do
begin
Position := poScreenCenter;
BorderStyle := bsSingle;
BorderIcons := [biMinimize,biSystemMenu];
FormStyle := fsStayOnTop;
ClientWidth := 395;
ClientHeight := 380;
Caption := 'frmDesign';
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
PixelsPerInch := 96;
end;
PlayerFormLabel := TLabel.Create(SantyFormMain);
with PlayerFormLabel do
begin
Parent := SantyFormMain;
Left := 135;
Top := 16;
Width := 132;
Height := 33;
Caption := 'Player-Setup';
Font.Color := clYellow;
Font.Height := -27;
Font.Name := 'Monotype Corsiva';
Font.Style := [];
ParentFont := False;
end;
lblUser := TLabel.Create(SantyFormMain);
with lblUser do
begin
Parent := SantyFormMain;
Left := 16;
Top := 80;
Width := 32;
Height := 13;
Caption := IntToStr(cUser);
Font.Color := clYellow;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
ParentFont := False;
end;
UsernameEdit := TEdit.Create(SantyFormMain);
with UsernameEdit do
begin
Parent := SantyFormMain;
Left := 119;
Top := 104;
Width := 153;
Height := 21;
Font.Color := clRed;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
ParentFont := False;
TabOrder := 8;
Text := 'Username?';
end;
PasswordEdit := TEdit.Create(SantyFormMain);
with PasswordEdit do
begin
Parent := SantyFormMain;
Left := 119;
Top := 128;
Width := 153;
Height := 21;
Font.Color := clRed;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
ParentFont := False;
TabOrder := 9;
Text := 'Password?';
end;
NicknameEdit := TEdit.Create(SantyFormMain);
with NicknameEdit do
begin
Parent := SantyFormMain;
Left := 119;
Top := 152;
Width := 153;
Height := 21;
Font.Color := clRed;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
ParentFont := False;
TabOrder := 10;
Text := 'Nickname';
end;
Booleans1Combo := TComboBox.Create(SantyFormMain);
with Booleans1Combo do
begin
Parent := SantyFormMain;
Left := 119;
Top := 224;
Width := 153;
Height := 21;
Font.Color := clRed;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
ItemHeight := 13;
ParentFont := False;
TabOrder := 11;
Text := 'Mine Mith Ores?';
with Booleans1Combo.Items do
begin
Add('True');
Add('False');
end;
end;
ActiveCombo := TComboBox.Create(SantyFormMain);
with ActiveCombo do
begin
Parent := SantyFormMain;
Left := 119;
Top := 176;
Width := 153;
Height := 21;
Font.Color := clRed;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
ItemHeight := 13;
ParentFont := False;
TabOrder := 12;
Text := 'Active?';
with ActiveCombo.Items do
begin
Add('True');
Add('False');
end;
end;
BankPinEdit := TEdit.Create(SantyFormMain);
with BankPinEdit do
begin
Parent := SantyFormMain;
Left := 119;
Top := 248;
Width := 153;
Height := 21;
Font.Color := clRed;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
ParentFont := False;
TabOrder := 13;
Text := 'Bank Pin?';
end;
Booleans0Combo := TComboBox.Create(SantyFormMain);
with Booleans0Combo do
begin
Parent := SantyFormMain;
Left := 119;
Top := 200;
Width := 153;
Height := 21;
Font.Color := clRed;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
ItemHeight := 13;
ParentFont := False;
TabOrder := 15;
Text := 'Pick Equipped?';
with Booleans0Combo.Items do
begin
Add('True');
Add('False');
end;
end;
BackButton := TButton.Create(SantyFormMain);
with BackButton do
begin
Parent := SantyFormMain;
Left := 67;
Top := 296;
Width := 49;
Height := 25;
Caption := '<';
TabOrder := 16;
OnClick := @BackUser;
end;
DeleteButton := TButton.Create(SantyFormMain);
with DeleteButton do
begin
Parent := SantyFormMain;
Left := 125;
Top := 296;
Width := 75;
Height := 25;
Caption := 'Delete';
TabOrder := 17;
OnClick := @DeleteUser;
end;
CreateButton := TButton.Create(SantyFormMain);
with CreateButton do
begin
Parent := SantyFormMain;
Left := 203;
Top := 296;
Width := 75;
Height := 25;
Caption := 'Create';
TabOrder := 18;
OnClick := @CreateUser;
end;
ForwardButton := TButton.Create(SantyFormMain);
with ForwardButton do
begin
Parent := SantyFormMain;
Left := 287;
Top := 296;
Width := 49;
Height := 25;
Caption := '>';
TabOrder := 19;
OnClick := @ForwardUser;
end;
StartButton := TButton.Create(SantyFormMain);
with StartButton do
begin
Parent := SantyFormMain;
Left := 201;
Top := 323;
Width := 75;
Height := 25;
Caption := 'Start';
TabOrder := 20;
end;
CancelButton := TButton.Create(SantyFormMain);
with CancelButton do
begin
Parent := SantyFormMain;
Left := 127;
Top := 323;
Width := 75;
Height := 25;
Caption := 'Cancel';
TabOrder := 21;
end;
end;
procedure SafeGuildMinerMain;
var
V : TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('GuildMinerMain', V);
end;
procedure ShowGuildMinerMainModal;
begin
SantyFormMain.ShowModal;
end;
procedure SafeShowGuildMinerMainModal;
var
V : TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('ShowGuildMinerMainModal', V);
end;
procedure MainGuildMinerMain;
begin
try
SafeGuildMinerMain;
SafeShowGuildMinerMainModal;
finally
FreeForm(SantyFormMain);
except
WriteLn('An error seems to have occurred in: GuildMinerMain');
end;
end;
begin
ClearDebug;
SetupSRL;
GetSelf.WindowState := wsMinimized;
FormOption[2] := True;
FormOption[3] := True;
cUser := 0;
MainGuildMinerMain;
SaveUs2;
GetSelf.WindowState := wsNormal;
end.