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(); }
private void frmProtoCritterEditor_Load(object sender, EventArgs e) { this.Text = "Critter Proto Editor: PID " + pc.Id; PrepareUpDown(hpBaseNum); PrepareUpDown(apBaseNum); PrepareUpDown(acBaseNum); PrepareUpDown(mdBaseNum); PrepareUpDown(cwBaseNum); PrepareUpDown(seqBaseNum); PrepareUpDown(hrBaseNum); PrepareUpDown(critBaseNum); PrepareUpDown(hpFullNum); PrepareUpDown(apFullNum); PrepareUpDown(acFullNum); PrepareUpDown(mdFullNum); PrepareUpDown(cwFullNum); PrepareUpDown(seqFullNum); PrepareUpDown(hrFullNum); PrepareUpDown(critFullNum); PrepareUpDown(poisonBaseNum); PrepareUpDown(radBaseNum); PrepareUpDown(poisonFullNum); PrepareUpDown(radFullNum); ParamsDefines.FillBodytypes(bodytypeBox); ParamsDefines.FillModes(modesBox); ParamsDefines.FillTraits(traitsBox); ParamsDefines.FillPerks(perksBox); ProtoManager.FillFilenames(savefileBox); GroupStatNums(); GroupSkillsNums(); GroupDamageNums(); PrepareUpDowns(SkillBaseNums); PrepareUpDowns(skillFullNums); LoadProto(); perksList.DataSource = Perks; modesList.DataSource = Modes; traitsList.DataSource = Traits; this.Refresh(); }
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(); } }
public bool Parse(List <string> lines, string _savefile) { Id = 0; for (int i = 0, j = Params.Length; i < j; i++) { Params[i] = 0; } Savefile = ""; foreach (string line in lines) { if (line == "") { continue; } string[] splittedLine = line.Split('='); if (splittedLine.Length != 2) { MessageBox.Show("ProtoCritter::Parse: failed to parse a line: " + line + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (splittedLine[0] == "Pid") { this.Id = int.Parse(splittedLine[1]); continue; } int param = ParamsDefines.GetParam(splittedLine[0]); if (param == -1) { MessageBox.Show("ProtoCritter::Parse: failed to parse a line: " + line + ". No param found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } Params[param] = int.Parse(splittedLine[1]); } this.Savefile = _savefile; return(true); }