Can AutoPlay load form data from a file?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Presto
    Forum Member
    • Apr 2006
    • 45

    Can AutoPlay load form data from a file?

    Hello guys,

    I'm not sure if this is possible or not but I'm working on a new project and I hope to use AutoPlay as I have been able to use it in the past with really good outcome.

    1.) I need to create a form with input fields and checkboxes with two buttons Save and Reset.

    2.) Now for the kicker I need this page/form to open a .cfg file and populate the fields with the data from the .cfg file. We can open and edit this file with notepad, this is the content of the file:

    Code:
    g_suitCloakEnergyDrainAdjuster = 0
    g_suitRecoilEnergyCost = 7
    g_suitSpeedEnergyConsumption = 110
    g_suitSpeedMult = 1.85
    g_suitArmorHealthValue = 100.0
    g_playerSuitArmorModeHealthRegenTime = 8
    g_playerSuitArmorModeHealthRegenTimeMoving = 10
    g_playerSuitHealthRegenTime = 12
    g_playerSuitHealthRegenTimeMoving = 15
    g_playerSuitHealthRegenDelay = 2.51
    g_playerSuitEnergyRechargeTimeArmor = 0
    g_playerSuitEnergyRechargeTimeArmorMoving = 0
    g_playerSuitEnergyRechargeTime = 0
    g_playerSuitEnergyRechargeDelay = 0
    g_playerHealthValue = 400.0
    g_difficultyLevel = 1
    v_driverControlledMountedGuns = 1
    i_noweaponlimit = 1
    i_unlimitedammo = 1
    We can open and edit this with notepad but we want to make a slick program to make it easier for others to open and edit, that's why we want to use AutoPlay. So what do you guys think is this possible???
  • HMMurdock
    Forum Member
    • Mar 2005
    • 144

    #2
    It is certainly possible. You would just need to read the .cfg file to a string or table (TextFile.ReadToString or TextFile.ReadToTable) then parse the string for the values that you want and then populate the appropriate fields.

    Reverse the process to save the file.

    You could make life really easy on yourself if you can add a "[main]" at the top of your .cfg file. Then you can treat it as an .INI file and read each value in seperately without having to parse the text.

    Comment

    • Presto
      Forum Member
      • Apr 2006
      • 45

      #3
      Hey HMMurdock thanks for the reply,

      I will test to see if I can add [main] at the top of my .cfg file.

      This is a config file for the game Crysis, a friend of mine came to me with this project the other day so I told him I would help him out, I am not much of a programmer I work full time as a user interface designer I speed most of my time in photoshop cs3 making all of the pretty stuff

      I will do some searching around on here for TextFile.ReadToString and .ini to find out more, have you seen any exsample code around that may get me started?

      Thanks for the point in the right direction HMMurdock

      Comment

      • HMMurdock
        Forum Member
        • Mar 2005
        • 144

        #4
        Ummm... I would probably do something like this...

        1) Read the .cfg file into a string.
        2) Append "[Main]" to the beginning of the string
        3) Write the new string to a temporary Txt file.
        4) Retrieve, from the temp file, the values you need
        5) Populate your form

        To save the file

        1) Read the inputs to get the values you need to save
        2) Save those values in the temp INI file
        3) Read the temp INI file into a string
        4) Remove the [MAIN]
        5) Save the new string to the .cfg file.


        It isn't the most elegant way to accomplish what you want. (parsing the cfg file is the cleanest, but most code intensive)

        If this is just a quick and dirty tool for a friend, I think this would work fine with a minimum amount of code. (be sure to clean up your temp file when you are done)

        I'll see if I can post some code later, but I'm about to start a poker tournament.

        Hope this helps.

        Comment

        • mwreyf1
          Indigo Rose Customer
          • Aug 2004
          • 417

          #5
          Give this a try.

          Doesn't require any temp files.
          Attached Files

          Comment

          • mwreyf1
            Indigo Rose Customer
            • Aug 2004
            • 417

            #6
            Here is another way of displaying it to the end user in a way that makes more sense to the user as to what they are actually setting. Just modify it to say what you want it to display.

            Remember that the label can be anything you want it to say that makes sense to the end user as to what they are setting. That DOES NOT change the settings for each val. Just the way it is presented to the end user.

            Hope this helps.
            Attached Files

            Comment

            • Presto
              Forum Member
              • Apr 2006
              • 45

              #7
              Wow thanks for the code mwreyf1 :yes
              Last edited by Presto; 07-11-2008, 10:22 PM.

              Comment

              • mwreyf1
                Indigo Rose Customer
                • Aug 2004
                • 417

                #8
                one sec...

                Let me take a look

                Comment

                • mwreyf1
                  Indigo Rose Customer
                  • Aug 2004
                  • 417

                  #9
                  I can't imagine what is causing that.

                  I just downloaded the same post and it works fine.

                  Maybe some kind of user rights issues.

                  Comment

                  • Presto
                    Forum Member
                    • Apr 2006
                    • 45

                    #10
                    ya it was my bad, I tride to edit my last post before you read it lol I had [main] at the top of my file, once I took that line out it worked great! I'm working on the graphic design part and website right now wahoo!

                    One more question, how would I make some of these fields checkboxes like field i_noweaponlimit and i_unlimitedammo? Where uncheck = 0 and checked = 1?

                    Comment

                    • mwreyf1
                      Indigo Rose Customer
                      • Aug 2004
                      • 417

                      #11
                      Modified...

                      Remember that the 'filename.cfg' is included with this example.

                      Just rename it and change the code to match the new name.

                      Also change the path to the file where it will eventualy reside.
                      Attached Files

                      Comment

                      • Presto
                        Forum Member
                        • Apr 2006
                        • 45

                        #12
                        Very Nice thank you so much for your help mwreyf1

                        Comment

                        • Presto
                          Forum Member
                          • Apr 2006
                          • 45

                          #13
                          Hey mwreyf1,

                          Is it hard to make a browse field at the top so the user can browse to their file and then load its content in to the form. I will atach a screenshot.
                          Attached Files

                          Comment

                          • Imagine Programming
                            Indigo Rose Customer
                            • Apr 2007
                            • 4252

                            #14
                            How about adding the Apz, instead of the am7

                            File > Export, pick location and voila
                            Bas Groothedde
                            Imagine Programming :: Blog

                            AMS8 Plugins
                            IMXLH Compiler

                            Comment

                            • Presto
                              Forum Member
                              • Apr 2006
                              • 45

                              #15
                              Thanks for the heads up C B programming
                              Attached Files

                              Comment

                              Working...
                              X