SpeedModGenerator 3.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • #1
    Snek
    FFR Simfile Author
    Izzy
    • Jan 2003
    • 9195

    SpeedModGenerator 3.0

    I rewrote the whole thing and fixed a few problems.

    -If you made the cmod increment not pass through the ending cmod value then it would return a speed that was 1 higher then it should be.

    -If you continuously saved your code to the metrics it would add up a bunch of lines at the end of [ScreenOptionsMaster]. While this didn't crash anything I fixed it anyway.

    -If you tried saving the metrics and english.ini into a blank text file it would give an out of bounds exception.

    -The code was ugly spaghetti code with no comments.


    The code is now unnoticeably more efficient, but there you go.


    :You have to fill out both the xmod and cmod values.

    :To save, browse for your metrics.ini file and english.ini file respectively. Or save into a text file. Either will work. If you are saving straight the .ini files it will delete the previous metrics.ini speedmods and replace them at the end. It works, trust me.



    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.IO;
    
    namespace SpeedModGenerator3
    {
        public partial class SpeedMod : Form
        {
            private List<string> _metrics = new List<string>();
            private List<string> _english = new List<string>();
    
            private double _xstart = 0;
            private double _xend = 0;
            private double _xinc = 0;
            private int _cstart = 0;
            private int _cend = 0;
            private int _cinc = 0;
    
            int _count;
    
            public SpeedMod()
            {
                InitializeComponent();
            }
    
            private void Go_Click(object sender, EventArgs e)
            {
    
                _metrics = new List<string>();
                _english = new List<string>();
                metricsList.Items.Clear();
                englishList.Items.Clear();
    
                // Error checking.
                if (xStart.Text == "" || xEnd.Text == "" || xInc.Text == "" || xStart.Text == "" || xEnd.Text == "" || xInc.Text == "")
                {
                    MessageBox.Show("At least one field is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    // sets values to the values in the text boxes.
                    _xstart = Convert.ToDouble(xStart.Text);
                    _xend = Convert.ToDouble(xEnd.Text);
                    _xinc = Convert.ToDouble(xInc.Text);
                    _cstart = Convert.ToInt32(cStart.Text);
                    _cend = Convert.ToInt32(cEnd.Text);
                    _cinc = Convert.ToInt32(cInc.Text);
    
                    getMods(_xstart, _xend, _xinc, _cstart, _cend, _cinc);
    
                    // Displays the metrics list
                    for (int i = 0; i < _metrics.Count; i++)
                    {
                        metricsList.Items.Add(_metrics[i]);
    
                    }
                    // Displays the english list.
                    for (int j = 0; j < _english.Count; j++)
                    {
                        englishList.Items.Add(_english[j]);
    
                    }
                }
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void getMods(double xs, double xe, double xi, int cs, int ce, int ci)
            {
                double _xadd;
                int _cadd;
                _count = 1;
    
                _metrics.Add("# Player options");
                _xadd = xs;
                while (_xadd <= xe)
                {
                    _metrics.Add("Speed," + _count + "=mod," + _xadd + "x;name,x" + _xadd);
                    _english.Add("x" + _xadd + "=x" + _xadd);
                    _count++;
                    _xadd = _xadd + xi;
                }
    
                _cadd = cs;
                while (_cadd <= ce)
                {
                    _metrics.Add("Speed," + _count + "=mod,C" + _cadd + ";name,C" + _cadd);
                    _english.Add("C" + _cadd + "=C" + _cadd);
                    _count++;
                    _cadd = _cadd + ci;
    
                }
                _count--;
                _metrics.Insert(1, "Speed=" + Convert.ToString(_count));
    
    
            }
    
            private void Clear_Click(object sender, EventArgs e)
            {
                // Clears everything
                xStart.Text = "";
                xEnd.Text = "";
                xInc.Text = "";
                cStart.Text = "";
                cEnd.Text = "";
                cInc.Text = "";
                _metrics = new List<string>();
                _english = new List<string>();
                metricsList.Items.Clear();
                englishList.Items.Clear();
    
                _xstart = 0;
                _xend = 0;
                _xinc = 0;
                _cstart = 0;
                _cend = 0;
                _cinc = 0;
    
                _count = 1;
    
    
            }
    
            private void Help_Click(object sender, EventArgs e)
            {
                MessageBox.Show("Created by: Izzy \r\n http://www.youtube.com/user/WTFizzy  \r\n \r\n 1) Don't leave any fields blank \r\n 2) Don't use any letters \r\n 3) Don't make the incriments bigger then the end values \r\n 4) It's a good idea to make your values pass through 1x \r\n 5) Make sure your cmod values are not decimals \r\n 6) You have to fill out both the xmod values and the cmod values \r\n \r\n For any further questions please contact me at wtfizzy@gmail.com or message my aim (wtfizzy) ", "Help", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
    
            private void saveMetrics_Click(object sender, EventArgs e)
            {
    
                // Error checking.
                if (metricsList.Items.Count == 0)
                {
                    MessageBox.Show("No speed mods in metrics.ini list", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    // Selects the file to save to.
                    fileDialog.Title = "Select the metrics.ini File";
                    fileDialog.InitialDirectory = @"C:\Program Files";
                    fileDialog.Filter = "All files (*.*)|*.*";
                    fileDialog.FilterIndex = 1;
                    fileDialog.RestoreDirectory = true;
                    if (fileDialog.ShowDialog() == DialogResult.OK)
                    {
                        string fileName = fileDialog.FileName;
                        StreamReader _file = new StreamReader(fileName);
    
                        int _numLine = 0;
                        string _line;
    
                        // Counts the number of lines in the file and sets _numline to that number.
                        while ((_line = _file.ReadLine()) != null)
                        {
                            _numLine++;
                        }
                        _file.Close();
    
                        // creates an array with the size of the whole text file.
                        string[] _text = new string[_numLine];
                        _file = new StreamReader(fileName);
    
                        int _removeLines = 0;
    
                        // Makes each line of the text file a spot in the array _text.
                        // Gets the number of speeds mods that need to be removed. 
                        for (int i = 0; i < _text.Length; i++)
                        {
                            _line = _file.ReadLine();
                            _text[i] = _line;
    
                            if (_text[i] == "# Player options")
                            {
                                _removeLines = Convert.ToInt32(_file.ReadLine().Substring(6));
                            }
                        }
    
                        _file.Close();
    
                        // Searching the whole array for specific lines that need to be removed.
                        for (int j = 0; j < _text.Length; j++)
                        {
    
    
                            if (_text[j] == "# Player options" || _text[j] == "SpeedDefault=mod,1x")
                            {
                                _text[j] = " ";
                            }
    
                            if (_text[j] == "Speed=" + _removeLines)
                            {
                                _text[j] = " ";
                            }
    
                            if (_text[j] == null)
                            {
                            }
                            else if (_text[j].Contains("Speed,"))
                            {
                                _text[j] = " ";
                            }
                        }
    
                        // Gets rid of the extra screenoptionsmaster at the end of metrics.ini
                        if (_text.Length > 10)
                        {
                            for (int h = _text.Length - (_count + 10) - 1; h < _text.Length; h++)
                            {
                                if (_text[h] == "[ScreenOptionsMaster]")
                                {
                                    _text[h] = " ";
                                }
                            }
                        }
    
                        // Checks for the number of blank lines.
                        int _blank = 0;
                        for (int o = 0; o < _text.Length; o++)
                        {
                            if (_text[o] == " ")
                            {
                                _blank++;
                            }
    
                        }
    
                        // Creates a new _text array with the same length minus the number of blank lines.
                        string[] _textNew = new string[_text.Length - _blank];
    
                        int m = 0;
    
                        // Fills in the new text array leaving out blank lines.
                        for (int l = 0; l < _text.Length; l++)
                        {
                            if (_text[l] != " ")
                            {
                                _textNew[m] = _text[l];
                                m++;
                            }
    
                        }
    
                        //Declarse a new StreamWriter
                        StreamWriter _write = File.CreateText(@fileName);
    
    
                        // Writes the new text array back to the metrics.ini
                        for (int x = 0; x < _textNew.Length - 1; x++)
                        {
                            _write.WriteLine(_textNew[x]);
                        }
                        _write.Close();
    
    
                        // Adds to the end of metrics.ini with the new speedmods.
                        _write = File.AppendText(@fileName);
                        _write.WriteLine("[ScreenOptionsMaster]");
                        for (int q = 0; q < _metrics.Count; q++)
                        {
                            _write.WriteLine(_metrics[q]);
                        }
                        _write.Close();
                        MessageBox.Show("metrics.ini was saved successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
    
                    }
                }
            }
    
            private void saveEnglish_Click(object sender, EventArgs e)
            {
                // Error checking.
                if (metricsList.Items.Count == 0)
                {
                    MessageBox.Show("No speed mods in english.ini list", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    // Selects the file to save to.
                    fileDialog.Title = "Select the english.ini File";
                    fileDialog.InitialDirectory = @"C:\Program Files";
                    fileDialog.Filter = "All files (*.*)|*.*";
                    fileDialog.FilterIndex = 1;
                    fileDialog.RestoreDirectory = true;
                    if (fileDialog.ShowDialog() == DialogResult.OK)
                    {
                        string fileName = fileDialog.FileName;
    
                        // Adds to the end of the english.ini file.
                        StreamWriter _w = File.AppendText(@fileName);
                        _w.WriteLine("[OptionNames]");
                        for (int i = 0; i < _english.Count; i++)
                        {
                            _w.WriteLine(_english[i]);
                        }
    
                        _w.Close();
                        MessageBox.Show("english.ini was saved successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
    
        }
    }


    Download: http://www.flashflashrevolution.com/sims/download.php?songid=40336
    Last edited by Izzy; 11-18-2009, 02:02 PM.
  • #2
    Live a wonderful life~
    FFR Simfile Author
    i love you
    • Oct 2006
    • 7315

    Re: SpeedModGenerator 3.0

    Wow, awesome update on this.
    ===============================
    The idea that RDCP 3 may come out in the future is a fun thought to have~
    ===============================

    Comment

    • #3
      FFR Player
      PhaeL v2
      • Sep 2009
      • 942

      Re: SpeedModGenerator 3.0

      downlording for sure
      Originally posted by Emo_Saur_
      Rapha, you're a cry baby!

      Comment

      • #4
        Snek
        FFR Simfile Author
        Izzy
        • Jan 2003
        • 9195

        Re: SpeedModGenerator 3.0

        I'm not expecting issues, but if there are please let me know. The only thing else I can think of is try no to save the metrics.ini to the english.ini. You might have to fix that manually.

        Comment

        • #5
          tane orb
          FFR Simfile Author
          t-rogdor
          • Jun 2007
          • 2685

          Re: SpeedModGenerator 3.0

          The only problem i've had with this is that after using it I get a "Speedmod "Default" could not be located" error.
          Originally posted by cetaka
          I saw a flyer on a bulletin board at school asking for high-functioning aspergers/autism people to participate in some kind of experiment, and all I could think was, that sounds like a great place to meet girls.

          Comment

          • #6
            FFR Player
            dm47
            • Jun 2007
            • 14

            Re: SpeedModGenerator 3.0

            is there a formula that can convert CMods to their equivalent speed (or, closest speed) in FFR?

            Comment

            • #7
              Enjoy life!
              FFR Simfile Author
              icontrolyourworld
              • Oct 2007
              • 4203

              Re: SpeedModGenerator 3.0

              I think I'll stick to writing my own Cmods and entering them, i havn't had a problem doing that so far

              Comment

              • #8
                Snek
                FFR Simfile Author
                Izzy
                • Jan 2003
                • 9195

                Re: SpeedModGenerator 3.0

                Originally posted by dm47
                is there a formula that can convert CMods to their equivalent speed (or, closest speed) in FFR?
                No, because there is no equivalent.

                Originally posted by icontrolyourworld
                I think I'll stick to writing my own Cmods and entering them, i havn't had a problem doing that so far
                Suit yourself.

                Comment

                • #9
                  Anxiety monster
                  XXXsmittyXXX
                  • Jul 2005
                  • 6924

                  Re: SpeedModGenerator 3.0

                  This is ****ing sick lol, never seen any sort of speed mod generator. Trying =D

                  Comment

                  • #10
                    Enjoy life!
                    FFR Simfile Author
                    icontrolyourworld
                    • Oct 2007
                    • 4203

                    Re: SpeedModGenerator 3.0

                    Originally posted by 0
                    the speedmod generator is usually faster if you want 2000 speedmods
                    Can't argue with that

                    Comment

                    Working...