Inheritance: ISelectable
コード例 #1
0
ファイル: ProtoManager.cs プロジェクト: SnakeSolidNL/tools
 public static bool AddProto(ProtoCritter cr)
 {
     int free = GetFreeNumber();
     cr.Id = free;
     Protos[free] = cr;
     return true;
 }
コード例 #2
0
 public frmProtoCritterEditor(frmCritterProtoList parent, int pcid, bool deleteOnExit)
 {
     this.deleteOnExit = deleteOnExit;
     this.parent = parent;
     this.pc = ProtoManager.Protos[pcid].DeepCopy();
     InitializeComponent();
 }
コード例 #3
0
 public frmProtoCritterEditor(frmCritterProtoList parent, int pcid, bool deleteOnExit)
 {
     this.deleteOnExit = deleteOnExit;
     this.parent       = parent;
     this.pc           = ProtoManager.Protos[pcid].DeepCopy();
     InitializeComponent();
 }
コード例 #4
0
ファイル: ProtoManager.cs プロジェクト: 2cwldys/fodev-tools
        public static bool AddProto(ProtoCritter cr)
        {
            int free = GetFreeNumber();

            cr.Id        = free;
            Protos[free] = cr;
            return(true);
        }
コード例 #5
0
ファイル: ProtoManager.cs プロジェクト: SnakeSolidNL/tools
 public static int AddProto()
 {
     ProtoCritter proto = new ProtoCritter(true);
     int free = GetFreeNumber();
     proto.Id = free;
     proto.Savefile = FileNames[0];
     Protos[free] = proto;
     return free;
 }
コード例 #6
0
ファイル: ProtoCritter.cs プロジェクト: rotators/tools
 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;
 }
コード例 #7
0
ファイル: ProtoManager.cs プロジェクト: 2cwldys/fodev-tools
        public static int AddProto()
        {
            ProtoCritter proto = new ProtoCritter(true);
            int          free  = GetFreeNumber();

            proto.Id       = free;
            proto.Savefile = FileNames[0];
            Protos[free]   = proto;
            return(free);
        }
コード例 #8
0
ファイル: ProtoManager.cs プロジェクト: SnakeSolidNL/tools
 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;
 }
コード例 #9
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();
     }
 }
コード例 #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);
        }
コード例 #11
0
ファイル: ProtoManager.cs プロジェクト: 2cwldys/fodev-tools
        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);
        }
コード例 #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();
            }
        }
コード例 #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;
     }
 }
コード例 #14
0
 public frmProtoCritterRawEditor(frmProtoCritterEditor parent, ProtoCritter pc)
 {
     this.pc = pc;
     this.parent = parent;
     InitializeComponent();
 }
コード例 #15
0
 public frmProtoCritterRawEditor(frmProtoCritterEditor parent, ProtoCritter pc)
 {
     this.pc     = pc;
     this.parent = parent;
     InitializeComponent();
 }
コード例 #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;
     }
 }
コード例 #17
0
ファイル: ProtoManager.cs プロジェクト: 2cwldys/fodev-tools
 public static void SaveProtoAs(ProtoCritter pc, int n)
 {
     Protos[n] = pc;
 }
コード例 #18
0
ファイル: ProtoManager.cs プロジェクト: SnakeSolidNL/tools
        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;
        }
コード例 #19
0
ファイル: ProtoManager.cs プロジェクト: SnakeSolidNL/tools
 public static void SaveProtoAs(ProtoCritter pc, int n)
 {
     Protos[n] = pc;
 }
コード例 #20
0
ファイル: ProtoManager.cs プロジェクト: 2cwldys/fodev-tools
        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);
        }