Inheritance: ISelectable
Esempio n. 1
0
 public static bool AddProto(ProtoCritter cr)
 {
     int free = GetFreeNumber();
     cr.Id = free;
     Protos[free] = cr;
     return true;
 }
 public frmProtoCritterEditor(frmCritterProtoList parent, int pcid, bool deleteOnExit)
 {
     this.deleteOnExit = deleteOnExit;
     this.parent = parent;
     this.pc = ProtoManager.Protos[pcid].DeepCopy();
     InitializeComponent();
 }
 public frmProtoCritterEditor(frmCritterProtoList parent, int pcid, bool deleteOnExit)
 {
     this.deleteOnExit = deleteOnExit;
     this.parent       = parent;
     this.pc           = ProtoManager.Protos[pcid].DeepCopy();
     InitializeComponent();
 }
Esempio n. 4
0
        public static bool AddProto(ProtoCritter cr)
        {
            int free = GetFreeNumber();

            cr.Id        = free;
            Protos[free] = cr;
            return(true);
        }
Esempio n. 5
0
 public static int AddProto()
 {
     ProtoCritter proto = new ProtoCritter(true);
     int free = GetFreeNumber();
     proto.Id = free;
     proto.Savefile = FileNames[0];
     Protos[free] = proto;
     return free;
 }
Esempio n. 6
0
 public ProtoCritter DeepCopy()
 {
     ProtoCritter newpc = new ProtoCritter();
     newpc.Id = this.Id;
     for (int i = 0, j = Params.Length; i < j; i++) newpc.Params[i] = this.Params[i];
     newpc.Name = this.Name;
     newpc.Desc = this.Desc;
     newpc.Savefile = this.Savefile;
     return newpc;
 }
Esempio n. 7
0
        public static int AddProto()
        {
            ProtoCritter proto = new ProtoCritter(true);
            int          free  = GetFreeNumber();

            proto.Id       = free;
            proto.Savefile = FileNames[0];
            Protos[free]   = proto;
            return(free);
        }
Esempio n. 8
0
 public static bool AddProto(int n)
 {
     if (Protos.ContainsKey(n))
     {
         MessageBox.Show("ProtoManager::AddProto: failed to save PID " + n + ": already exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     ProtoCritter proto = new ProtoCritter(true);
     proto.Id = n;
     proto.Savefile = FileNames[0];
     Protos[n] = proto;
     return true;
 }
 private void button1_Click(object sender, EventArgs e)
 {
     ProtoCritter newpc = this.pc.DeepCopy();
     if (newpc.Parse(this.rtbData.Lines.ToList(), ProtoManager.CorrectFile(newpc.Savefile)))
     {
         newpc.Id = pc.Id;
         this.pc = newpc;
         parent.pc = newpc;
         ProtoManager.Protos[newpc.Id] = newpc;
         this.parent.LoadProto();
         this.parent.parent.RefreshList();
         this.Close();
     }
 }
Esempio n. 10
0
        public ProtoCritter DeepCopy()
        {
            ProtoCritter newpc = new ProtoCritter();

            newpc.Id = this.Id;
            for (int i = 0, j = Params.Length; i < j; i++)
            {
                newpc.Params[i] = this.Params[i];
            }
            newpc.Name     = this.Name;
            newpc.Desc     = this.Desc;
            newpc.Savefile = this.Savefile;
            return(newpc);
        }
Esempio n. 11
0
        public static bool AddProto(int n)
        {
            if (Protos.ContainsKey(n))
            {
                MessageBox.Show("ProtoManager::AddProto: failed to save PID " + n + ": already exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            ProtoCritter proto = new ProtoCritter(true);

            proto.Id       = n;
            proto.Savefile = FileNames[0];
            Protos[n]      = proto;
            return(true);
        }
Esempio n. 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            ProtoCritter newpc = this.pc.DeepCopy();

            if (newpc.Parse(this.rtbData.Lines.ToList(), ProtoManager.CorrectFile(newpc.Savefile)))
            {
                newpc.Id  = pc.Id;
                this.pc   = newpc;
                parent.pc = newpc;
                ProtoManager.Protos[newpc.Id] = newpc;
                this.parent.LoadProto();
                this.parent.parent.RefreshList();
                this.Close();
            }
        }
Esempio n. 13
0
 private void protoList_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.Control && e.KeyCode == Keys.C)
     {
         Object obj = protoList.SelectedObject;
         if (obj != null)
         {
             var kvp = (KeyValuePair <int, ProtoCritter>)obj;
             copiedCritter  = (ProtoCritter)kvp.Value;
             lblCopied.Text = getCopiedText();
         }
         e.Handled = true;
     }
     else if (e.Control && e.KeyCode == Keys.V)
     {
         ProtoCritter cr = copiedCritter.DeepCopy();
         ProtoManager.AddProto(cr);
         RefreshList();
         lblCopied.Text     = getCopiedText() + " Cloned into PID " + cr.Id;
         e.SuppressKeyPress = true;
     }
 }
 public frmProtoCritterRawEditor(frmProtoCritterEditor parent, ProtoCritter pc)
 {
     this.pc = pc;
     this.parent = parent;
     InitializeComponent();
 }
Esempio n. 15
0
 public frmProtoCritterRawEditor(frmProtoCritterEditor parent, ProtoCritter pc)
 {
     this.pc     = pc;
     this.parent = parent;
     InitializeComponent();
 }
Esempio n. 16
0
 private void protoList_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.Control && e.KeyCode == Keys.C)
     {
         Object obj = protoList.SelectedObject;
         if (obj != null)
         {
             var kvp = (KeyValuePair<int, ProtoCritter>)obj;
             copiedCritter = (ProtoCritter)kvp.Value;
             lblCopied.Text = getCopiedText();
         }
         e.Handled = true;
     }
     else if (e.Control && e.KeyCode == Keys.V)
     {
         ProtoCritter cr = copiedCritter.DeepCopy();
         ProtoManager.AddProto(cr);
         RefreshList();
         lblCopied.Text = getCopiedText() + " Cloned into PID " + cr.Id;
         e.SuppressKeyPress = true;
     }
 }
Esempio n. 17
0
 public static void SaveProtoAs(ProtoCritter pc, int n)
 {
     Protos[n] = pc;
 }
Esempio n. 18
0
        private static bool LoadFile(string filename)
        {
            List<string> lines = new List<string>(File.ReadAllLines(Config.PathCritterProtoDir+filename));
            int len = lines.Count;

            int current = 0;
            while (current < len && String.Compare(lines[current],0, CritterProtoString,0,CritterProtoString.Length) != 0)
                current++;

            if (current == len) return true;
            current++;
            List<string> block = new List<string>();
            int id=0;
            while (current < len)
            {
                block.Add(lines[current]);
                current++;
                if (current<len && String.Compare(lines[current],0, CritterProtoString,0,CritterProtoString.Length) == 0)
                {
                    id++;
                    int pid = 0;
                    foreach (string line in block)
                    {
                        if (line.Substring(0, 4) == "Pid=")
                        {
                            pid = int.Parse(line.Substring(4,line.Length-4));
                            break;
                        }
                    }
                    if (pid == 0)
                    {
                        Message.Show("ProtoManager::LoadFile: failed to parse block number " + id+" (no PID)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return false;
                    }
                    if (!Protos.ContainsKey(pid))
                    {
                        ProtoCritter pc = new ProtoCritter();
                        pc.Name = ProtoNames[pid * 10];
                        if(ProtoNames.ContainsKey((pid * 10)+1))
                             pc.Desc=ProtoNames[(pid * 10)+1];
                        Protos.Add(pid, pc);
                    }
                    if (!Protos[pid].Parse(block, filename))
                    {
                        Message.Show("ProtoManager::LoadFile: failed to parse block with PID " + pid, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return false;
                    }
                    block.Clear();
                    current++;
                }
            }

            int rpid = 0;
            foreach (string line in block)
            {
                if (line.Substring(0, 4) == "Pid=")
                {
                    rpid = int.Parse(line.Substring(4, line.Length - 4));
                    break;
                }
            }
            if (rpid == 0)
            {
                MessageBox.Show("ProtoManager::LoadFile: failed to parse block number " + id + " (no PID)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            if (!Protos.ContainsKey(rpid))
            {
                ProtoCritter pc = new ProtoCritter();
                Protos.Add(rpid, pc);
            }
            if (!Protos[rpid].Parse(block, filename))
            {
                MessageBox.Show("ProtoManager::LoadFile: failed to parse block with PID " + rpid, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            return true;
        }
Esempio n. 19
0
 public static void SaveProtoAs(ProtoCritter pc, int n)
 {
     Protos[n] = pc;
 }
Esempio n. 20
0
        private static bool LoadFile(string filename)
        {
            List <string> lines = new List <string>(File.ReadAllLines(Config.PathCritterProtoDir + filename));
            int           len   = lines.Count;

            int current = 0;

            while (current < len && String.Compare(lines[current], 0, CritterProtoString, 0, CritterProtoString.Length) != 0)
            {
                current++;
            }

            if (current == len)
            {
                return(true);
            }
            current++;
            List <string> block = new List <string>();
            int           id    = 0;

            while (current < len)
            {
                block.Add(lines[current]);
                current++;
                if (current < len && String.Compare(lines[current], 0, CritterProtoString, 0, CritterProtoString.Length) == 0)
                {
                    id++;
                    int pid = 0;
                    foreach (string line in block)
                    {
                        if (line.Substring(0, 4) == "Pid=")
                        {
                            pid = int.Parse(line.Substring(4, line.Length - 4));
                            break;
                        }
                    }
                    if (pid == 0)
                    {
                        Message.Show("ProtoManager::LoadFile: failed to parse block number " + id + " (no PID)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    if (!Protos.ContainsKey(pid))
                    {
                        ProtoCritter pc = new ProtoCritter();
                        pc.Name = ProtoNames[pid * 10];
                        if (ProtoNames.ContainsKey((pid * 10) + 1))
                        {
                            pc.Desc = ProtoNames[(pid * 10) + 1];
                        }
                        Protos.Add(pid, pc);
                    }
                    if (!Protos[pid].Parse(block, filename))
                    {
                        Message.Show("ProtoManager::LoadFile: failed to parse block with PID " + pid, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    block.Clear();
                    current++;
                }
            }


            int rpid = 0;

            foreach (string line in block)
            {
                if (line.Substring(0, 4) == "Pid=")
                {
                    rpid = int.Parse(line.Substring(4, line.Length - 4));
                    break;
                }
            }
            if (rpid == 0)
            {
                MessageBox.Show("ProtoManager::LoadFile: failed to parse block number " + id + " (no PID)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (!Protos.ContainsKey(rpid))
            {
                ProtoCritter pc = new ProtoCritter();
                Protos.Add(rpid, pc);
            }
            if (!Protos[rpid].Parse(block, filename))
            {
                MessageBox.Show("ProtoManager::LoadFile: failed to parse block with PID " + rpid, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }