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
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