Sk1nyNerd
2013-10-23 01:21:18
K… so the code below is basically outlined from MasterKill's "THE big form tutorial" on how to add a player to a listbox and if said player is clicked on in the list box it will load the saved settings of that player WHILE IN THE SAME INSTANCE so once the form is closed it will no longer remember that player or that players data. You now know my problem:) ha
My first question is how can i save and index a player and their info into a Data File when an Add Player button is clicked on. even if they dont enter data in one of the fields
My second question is how can i load ALL of the players and their info into the list box from the Data File when a Load Players button is clicked
My third question is when a Delete Player button is clicked on how can u remove that player and their info from the Data File without messing up the index
ideas/help/examples!?!?
Thanks:)
My second question is how can i load ALL of the players and their info into the list box from the Data File when a Load Players button is clicked
My third question is when a Delete Player button is clicked on how can u remove that player and their info from the Data File without messing up the index
ideas/help/examples!?!?
Thanks:)
Procedure LoadFP(WhatPlayer: Integer; SaveCurrentInfo: Boolean);
Var
I: Integer;
Begin
If SaveCurrentInfo Then
Begin
FP[CurFP].Name := Edits[0].Text;
FP[CurFP].Pass := Edits[1].Text;
FP[CurFP].Nick := Edits[2].Text;
FP[CurFP].Pin := Edits[3].Text;
FP[CurFP].NPC := ComboBoxes[0].Text;
FP[CurFP].Health := ComboBoxes[1].Text;
FP[CurFP].Food := ComboBoxes[2].Text;
End;
ListPlayers.Clear;
For I := 0 To High(FP) Do
If (FP[I].Name = '') Then
ListPlayers.Items.Add(IntToStr(I) + ': ?')
Else
ListPlayers.Items.Add(IntToStr(I) + ': ' + FP[I].Name);
CurFP := WhatPlayer;
ListPlayers.ItemIndex := CurFP;
Edits[0].Text := FP[CurFP].Name;
Edits[1].Text := FP[CurFP].Pass;
Edits[2].Text := FP[CurFP].Nick;
Edits[3].Text := FP[CurFP].Pin;
ComboBoxes[0].Text := FP[CurFP].NPC;
ComboBoxes[1].Text := FP[CurFP].Health;
ComboBoxes[2].Text := FP[CurFP].Food;
Buttons[3].Enabled := (GetArrayLength(FP) > 1); //this prevents the listbox from being empty, always 1 player in it
End;