Results 1 to 8 of 8

Thread: The New SRL Player Form

  1. #1
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default The New SRL Player Form

    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:


    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:

    1. Download the attached include file to whatever file location you wish (just make sure you reference it right in your test script).
    2. Use the following script to test. You can change whatever you want in "initPlayerForm()".
      Simba Code:
      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
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

  3. #3
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Keep in mind I haven't done a ton of testing, so there are likely to be some errors.

  4. #4
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Very nice work Coh3n!

    Just been playing around with it, and I managed to get this after a little while:
    Code:
    Program exception! 
    Stacktrace:
    
    Exception class: lpException
    Message: Runtime error: "Access violation" at line 317, column 36 in file "C:\Users\Richard\Documents\Simba\srlplayerform.simba"
      $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?
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  5. #5
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Rich View Post
    Very nice work Coh3n!

    Just been playing around with it, and I managed to get this after a little while:
    Code:
    Program exception! 
    Stacktrace:
    
    Exception class: lpException
    Message: Runtime error: "Access violation" at line 317, column 36 in file "C:\Users\Richard\Documents\Simba\srlplayerform.simba"
      $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.

  6. #6
    Join Date
    Jun 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Greattttttttttttttttttttt

  7. #7
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Rich View Post
    Very nice work Coh3n!

    Just been playing around with it, and I managed to get this after a little while:
    Code:
    Program exception! 
    Stacktrace:
    
    Exception class: lpException
    Message: Runtime error: "Access violation" at line 317, column 36 in file "C:\Users\Richard\Documents\Simba\srlplayerform.simba"
      $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.

  8. #8
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Rich View Post
    Just been playing around with it, and I managed to get this after a little while:
    Code:
    Program exception! 
    Stacktrace:
    
    Exception class: lpException
    Message: Runtime error: "Access violation" at line 317, column 36 in file "C:\Users\Richard\Documents\Simba\srlplayerform.simba"
      $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.
    Last edited by Coh3n; 01-12-2014 at 05:53 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •