PDA

View Full Version : [Resolved] The New SRL Player Form



Coh3n
12-23-2013, 01:28 AM
Introduction:


I always liked the player form we had years ago. It made setting up scripts a lot easier for users. So due to the very limited form support offered by Lape, I have completely rewritten the SRL player form from scratch. Before it's added to the include, I would like a few people to test it and provide feedback. Keep in mind that if you suggest something to be added, there is a good chance it isn't supported by Lape.

Here's a screenshot of an example setup:

http://i.imgur.com/1X6s6Xq.png


Features:


The new form has a lot of features and customization options, and more can easily be added.


Automatically loads all user's player files into the "Player File" combo box.
Automatically loads a user's previous settings.
Scripters can have as many TEdits, TComboBoxes, and TCheckBoxes as they wish.
Scripters have the option to set default values for each of the above components.
Scripters setup the form via a initPlayerForm() procedure that edits a "PlayerForm" variable.
The PlayerForm variable has several attributes that can be customized by the scripter.
The user's players settings are set to the PlayerFrom.players.settings attribute.


How to use:


Download the attached include file to whatever file location you wish (just make sure you reference it right in your test script).
Use the following script to test. You can change whatever you want in "initPlayerForm()".

program SRLPlayerFormTest;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$i srlplayerform.simba}

// initiates the SRL player form
procedure initPlayerForm();
begin
with playerForm do
begin
name := 'SRL Player Form ~ Test';
scriptThreadLink := '';
scriptSettingsPath := ''; // if set to '', will save to script's path. Need to include file name and extension.

editBoxLabels := ['Maximum time to run', 'Maximum logs to chop', 'Minutes before breaking'];
editBoxDefaults := ['0', '0', '0'];
checkBoxLabels := ['Hatchet Equipped', 'Save SRL log', 'Draw on SMART'];
checkBoxDefaults := ['True', 'True', 'False'];
comboBoxLabels := ['Tree Type'];
comboBoxDefaults := ['Willow'];

// this needs to be done for every element in the comboBoxLabels array
setLength(comboBoxItems, length(comboBoxLabels));
comboBoxItems[0] := ['Normal', 'Oak', 'Willow', 'Maple', 'Yew', 'Magic'];
end;
end;

// a modified declarePlayers to use with the form
procedure declarePlayers();
var
i: integer;
s: string;
begin
players.setup(playerForm.playerNames, playerForm.playerFile);
currentPlayer := 0;

// set player attributes based on the settings from the form
for i := 0 to high(players) do
with players[i] do
begin
integers[0] := strToInt(playerForm.players[i].settings[0]);
integers[1] := strToInt(playerForm.players[i].settings[1]);
integers[2] := strToInt(playerForm.players[i].settings[2]);
booleans[0] := strToBool(playerForm.players[i].settings[3]);
booleans[1] := strToBool(playerForm.players[i].settings[4]);
booleans[2] := strToBool(playerForm.players[i].settings[5]);
strings[0] := playerForm.players[i].settings[6];
end;
end;

var
i: integer;
begin
clearDebug();
disableSRLLog := true;

initPlayerForm();
runPlayerForm();

// use this so the script doesn't continue if the user exits out of the form
if (not playerForm.isScriptReady) then
exit;

setupSRL();
declarePlayers();

writeln('Player file: ', playerForm.playerFile);

for i := 0 to high(players) do
writeln('Player ', i, ': ', playerForm.players[i].name, ' ', playerForm.players[i].settings);

writeln('Continuing with script...');
end.



Conclusion:


Before adding it to the include I will be adding documentation and more commenting so people can learn from the code. I'll also write a detailed tutorial on how to use it. For now, I want to get as much feedback as I can. :)

Thanks,
Coh3n

Ashaman88
12-23-2013, 01:33 AM
Sweet I'll check it out - looks good!

Coh3n
12-23-2013, 01:34 AM
Keep in mind I haven't done a ton of testing, so there are likely to be some errors.

Rich
12-23-2013, 11:44 AM
Very nice work Coh3n!

Just been playing around with it, and I managed to get this after a little while:

Program exception!
Stacktrace:

Exception class: lpException
Message: Runtime error: "Access violation" at line 317, column 36 in file "C:\Users\Richard\Documents\Simba\srlplayerform.sim ba"
$00740686
Simba Version: 1004

It happens when you double click in the big box on the left.

Also, maybe I'm being thick, but where does the user enter the password and PIN?

Olly
12-23-2013, 03:35 PM
Very nice work Coh3n!

Just been playing around with it, and I managed to get this after a little while:

Program exception!
Stacktrace:

Exception class: lpException
Message: Runtime error: "Access violation" at line 317, column 36 in file "C:\Users\Richard\Documents\Simba\srlplayerform.sim ba"
$00740686
Simba Version: 1004

It happens when you double click in the big box on the left.

Also, maybe I'm being thick, but where does the user enter the password and PIN?

Players are loaded from Rafiki (player manager), and I guess Cohen forgot to add some range checks on clicking the list box. :p

Darth Vader
12-25-2013, 12:31 AM
Greattttttttttttttttttttt

Coh3n
12-25-2013, 03:13 AM
Very nice work Coh3n!

Just been playing around with it, and I managed to get this after a little while:

Program exception!
Stacktrace:

Exception class: lpException
Message: Runtime error: "Access violation" at line 317, column 36 in file "C:\Users\Richard\Documents\Simba\srlplayerform.sim ba"
$00740686
Simba Version: 1004

It happens when you double click in the big box on the left.

Also, maybe I'm being thick, but where does the user enter the password and PIN?Like Olly said, player's are loaded from Rafiki.

There is no double clicking event for the player list box so it was probably triggered after the first click. Can you provide more information? Like how many players were in the list, which player you clicked, etc. If you can reproduce it, explaining the steps would be very helpful.

Coh3n
01-11-2014, 12:23 AM
Just been playing around with it, and I managed to get this after a little while:

Program exception!
Stacktrace:

Exception class: lpException
Message: Runtime error: "Access violation" at line 317, column 36 in file "C:\Users\Richard\Documents\Simba\srlplayerform.sim ba"
$00740686
Simba Version: 1004

It happens when you double click in the big box on the left.I've fixed this. It happened when clicking an empty list. It was trying to fill in the player's settings when the player didn't exist. I've also fixed the default options to actually set the components caption/state.

I'm going to add documentation and do a little more testing before I add it to the include.

Note that I haven't uploaded a new version so the one in the OP will still have the error when you click an empty list.

E: This has been committed and a guide on how to use it will come shortly.