GetParamName() public static method

public static GetParamName ( int n ) : string
n int
return string
Beispiel #1
0
        private void LoadRawData()
        {
            List <string> lines = new List <string>();

            for (int i = 0, j = this.pc.Params.Length; i < j; i++)
            {
                if (this.pc.Params[i] == 0)
                {
                    continue;
                }
                string name = ParamsDefines.GetParamName(i);
                if (name == "")
                {
                    name = "Param" + i;
                }
                lines.Add(name + "=" + this.pc.Params[i]);
            }
            this.rtbData.Lines = lines.ToArray();
        }
Beispiel #2
0
        public static void Save()
        {
            Dictionary <string, List <string> > files = new Dictionary <string, List <string> >();

            foreach (KeyValuePair <int, ProtoCritter> pair in Protos)
            {
                if (CheckFile(pair.Value.Savefile))
                {
                    string savefile = pair.Value.Savefile;
                    if (!files.ContainsKey(savefile))
                    {
                        files[savefile] = new List <string>();
                    }
                    files[savefile].Add("[Critter proto]");
                    files[savefile].Add("Pid=" + pair.Key);
                    for (int i = 0, j = pair.Value.Params.Length; i < j; i++)
                    {
                        if (pair.Value.Params[i] != 0)
                        {
                            string name = ParamsDefines.GetParamName(i);
                            if (name == "")
                            {
                                MessageBox.Show("ProtoManager::Save: failed to save PID " + pair.Key + ": Param " + i + " name unknown. Saving aborted.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                            files[savefile].Add(name + "=" + pair.Value.Params[i]);
                        }
                    }
                    files[savefile].Add("");
                }
            }
            foreach (KeyValuePair <string, List <string> > pair in files)
            {
                StreamWriter sw = new StreamWriter(Config.PathCritterProtoDir + pair.Key);
                foreach (string line in pair.Value)
                {
                    sw.Write(line + "\n");
                }
                sw.Close();
            }
        }