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.

Download: http://www.flashflashrevolution.com/sims/download.php?songid=40336
-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 [email protected] 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

Comment