Пример #1
0
        private void LoadFields(EvilPlug.Filetypes.Lay.LayFile layObject)
        {
            try
            {
                txtMoney.Text = layObject.FindProperty("Cash").Value;
                if (layObject.FindProperty("GeniusEntityID") == null)
                    throw new Exception("Invalid savegame.");

                m_GeniusEntityID = layObject.FindProperty("GeniusEntityID").Value;

                cmbAlertState.SelectedIndex = int.Parse(layObject.FindProperty("AlertStatus").Value);
                cmbDifficulty.SelectedIndex = int.Parse(layObject.FindProperty("DifficultyLevel").Value);

                // Find the evil genius entry
                m_EvilGenius = layObject.FindEntityById(m_GeniusEntityID);

                txtEGHealth.Text = m_EvilGenius.Stats.Health;
                txtEGName.Text = m_EvilGenius.Name;
                txtEGID.Text = m_EvilGenius.EntityDescriptionID;
                txtEGLoyalty.Text = m_EvilGenius.Stats.Loyalty;
                txtEGSmarts.Text = m_EvilGenius.Stats.Smarts;
                txtEGAttention.Text = m_EvilGenius.Stats.Attention;
                txtEGEndurance.Text = m_EvilGenius.Stats.Endurance;

                // Load the minion recruitment fields
                for (int c = 0; c < grpRec.Controls.Count; c++)
                {
                    Control ctrl = grpRec.Controls[c];

                    if (ctrl.GetType() == typeof(TextBox))
                    {
                        string minID = (string)((TextBox)ctrl).Tag;

                        // Load minion stuff
                        List<LayProperty> props = SaveGamePlugin.LayFile.FindProperties("DesiredMinionCount");

                        for (int i = 0; i < props.Count; i++)
                        {
                            LayProperty prop = props[i];

                            try
                            {
                                if (prop.Value.Substring(0, 4) == minID + ",")
                                {
                                    ((TextBox)ctrl).Text = prop.Value.Substring(prop.Value.IndexOf(",") + 1);
                                    break;
                                }
                            }
                            catch { }
                        }

                    }
                }

                txtRecCost.Text = layObject.FindProperty("MinionRecruitmentCost").Value;
                txtRecRate.Text = layObject.FindProperty("MinionRecruitmentRate").Value;
                txtRecTime.Text = layObject.FindProperty("SecondsSinceLastAutoSpawned").Value;

                txtBasePower.Text = layObject.FindProperty("BasePowerSupply").Value;

                #region Load henchmen tab
                string[] henchmenIds = new string[] { "500", "501", "502", "503", "504", "505", "507", "508", "509", "510", "511" };
                string[] henchNames = new string[] { "Moko the big strong dumb one.", "Jubei the Samurai swordsman and sushi master.", "Eli the hard-hitting, fast-talking gangster.", "Red Ivan, always ready for action.", "Montezuma, the dark and sinister voodoo man.", "The Matron - isn't it past your bedtime?", "Lord Kane, the arch-conspirator himself.", "That looks nasty, would you like me to take a closer look?", "Look into my eye, you are feeling sleepy...", "The charming Dr Neurocide, insane or genius ahead of her time?", "Colonel Blackheart, he has your trail." };

                bool found = false;
                int locModifier = 0;

                GroupBox baseBox = null;

                for (int c = 0; c < tabHenchman.Controls.Count; c++)
                {
                    Control ctrl = tabHenchman.Controls[c];

                    if (ctrl.GetType() != typeof(GroupBox))
                        continue;

                    baseBox = (GroupBox)ctrl;
                    break;
                }
                int ix = 0;

                // evilHench1
                int cntx = -1;
                foreach (string hID in henchmenIds)
                {
                    LayEntity hench = SaveGamePlugin.LayFile.FindEntity(hID);
                    cntx++;
                    if (hench == null)
                    {
                        continue;
                    }
                    string henchName = henchNames[cntx];
                    EvilHenchControl ectrl = new EvilHenchControl();
                    tabHenchman.SuspendLayout();
                    tabHenchman.Controls.Add(ectrl);
                    ectrl.Tag = hID;
                    ectrl.Left = 0;
                    ectrl.Top = 0 + (ectrl.Height * ix);
                    ectrl.BringToFront();
                    ectrl.Text = henchName;
                    tabHenchman.ResumeLayout();
                    tabHenchman.PerformLayout();
                    tabHenchman.Refresh();
                    ix++;
                }

                foreach (string hID in henchmenIds)
                {
                    // See if we have the henchman
                    LayEntity hench = SaveGamePlugin.LayFile.FindEntity(hID);
                    if (hench == null)
                        found = false;
                    else
                        found = true;


                    for (int c = 0; c < tabHenchman.Controls.Count; c++)
                    {
                        Control ctrl = tabHenchman.Controls[c];

                        if (ctrl.GetType() != typeof(EvilHenchControl))
                            continue;

                        EvilHenchControl evilHench = (EvilHenchControl)ctrl;

                        GroupBox hBox = evilHench.groupBox2;

                        if ((string)evilHench.Tag == hID)
                        {
                            evilHench.Entity = hench;
                        }
                    }
                }
                #endregion


                #region Load regions tab
                string[] regionIds = new string[] { "1550", "1551", "1552", "1553", "1554" }; // TODO order alphabetical

                cntx = -1;
                ix = 0;
                int regHeight = lblTotalNotoriety.Height;

                foreach (string rID in regionIds)
                {
                    LayEntity region = SaveGamePlugin.LayFile.FindEntity(rID);
                    cntx++;
                    if (region == null)
                    {
                        continue;
                    }
                    EvilRegionControl ectrl = new EvilRegionControl();
                    tabRegions.SuspendLayout();
                    tabRegions.Controls.Add(ectrl);
                    ectrl.Tag = rID;
                    ectrl.Left = 0;
                    ectrl.Top = regHeight + (ectrl.Height * ix);
                    ectrl.BringToFront();
                    tabRegions.ResumeLayout();
                    tabRegions.PerformLayout();
                    tabRegions.Refresh();
                    m_Regions.Add(ectrl);
                    ix++;
                }

                foreach (string rID in regionIds)
                {
                    // See if we have the henchman
                    LayEntity region = SaveGamePlugin.LayFile.FindEntity(rID);
                    if (region == null)
                        found = false;
                    else
                        found = true;


                    for (int c = 0; c < tabRegions.Controls.Count; c++)
                    {
                        Control ctrl = tabRegions.Controls[c];

                        if (ctrl.GetType() != typeof(EvilRegionControl))
                            continue;

                        EvilRegionControl evilRegion = (EvilRegionControl)ctrl;


                        if ((string)evilRegion.Tag == rID)
                        {
                            evilRegion.Entity = region;
                        }
                    }
                }
                #endregion

            }
            catch (Exception ex)
            {
                lblStatus.Text = "Error loading saved game: " + ex.Message;
                tmrLoadProgress.Enabled = false;
                tabEditor.Enabled = false;
            }
        }
Пример #2
0
        private void LoadFields(EvilPlug.Filetypes.Lay.LayFile layObject)
        {
            try
            {
                txtMoney.Text = layObject.FindProperty("Cash").Value;
                if (layObject.FindProperty("GeniusEntityID") == null)
                {
                    throw new Exception("Invalid savegame.");
                }

                m_GeniusEntityID = layObject.FindProperty("GeniusEntityID").Value;

                cmbAlertState.SelectedIndex = int.Parse(layObject.FindProperty("AlertStatus").Value);
                cmbDifficulty.SelectedIndex = int.Parse(layObject.FindProperty("DifficultyLevel").Value);

                // Find the evil genius entry
                m_EvilGenius = layObject.FindEntityById(m_GeniusEntityID);

                txtEGHealth.Text    = m_EvilGenius.Stats.Health;
                txtEGName.Text      = m_EvilGenius.Name;
                txtEGID.Text        = m_EvilGenius.EntityDescriptionID;
                txtEGLoyalty.Text   = m_EvilGenius.Stats.Loyalty;
                txtEGSmarts.Text    = m_EvilGenius.Stats.Smarts;
                txtEGAttention.Text = m_EvilGenius.Stats.Attention;
                txtEGEndurance.Text = m_EvilGenius.Stats.Endurance;

                // Load the minion recruitment fields
                for (int c = 0; c < grpRec.Controls.Count; c++)
                {
                    Control ctrl = grpRec.Controls[c];

                    if (ctrl.GetType() == typeof(TextBox))
                    {
                        string minID = (string)((TextBox)ctrl).Tag;

                        // Load minion stuff
                        List <LayProperty> props = SaveGamePlugin.LayFile.FindProperties("DesiredMinionCount");

                        for (int i = 0; i < props.Count; i++)
                        {
                            LayProperty prop = props[i];

                            try
                            {
                                if (prop.Value.Substring(0, 4) == minID + ",")
                                {
                                    ((TextBox)ctrl).Text = prop.Value.Substring(prop.Value.IndexOf(",") + 1);
                                    break;
                                }
                            }
                            catch { }
                        }
                    }
                }

                txtRecCost.Text = layObject.FindProperty("MinionRecruitmentCost").Value;
                txtRecRate.Text = layObject.FindProperty("MinionRecruitmentRate").Value;
                txtRecTime.Text = layObject.FindProperty("SecondsSinceLastAutoSpawned").Value;

                txtBasePower.Text = layObject.FindProperty("BasePowerSupply").Value;

                #region Load henchmen tab
                string[] henchmenIds = new string[] { "500", "501", "502", "503", "504", "505", "507", "508", "509", "510", "511" };
                string[] henchNames  = new string[] { "Moko the big strong dumb one.", "Jubei the Samurai swordsman and sushi master.", "Eli the hard-hitting, fast-talking gangster.", "Red Ivan, always ready for action.", "Montezuma, the dark and sinister voodoo man.", "The Matron - isn't it past your bedtime?", "Lord Kane, the arch-conspirator himself.", "That looks nasty, would you like me to take a closer look?", "Look into my eye, you are feeling sleepy...", "The charming Dr Neurocide, insane or genius ahead of her time?", "Colonel Blackheart, he has your trail." };

                bool found       = false;
                int  locModifier = 0;

                GroupBox baseBox = null;

                for (int c = 0; c < tabHenchman.Controls.Count; c++)
                {
                    Control ctrl = tabHenchman.Controls[c];

                    if (ctrl.GetType() != typeof(GroupBox))
                    {
                        continue;
                    }

                    baseBox = (GroupBox)ctrl;
                    break;
                }
                int ix = 0;

                // evilHench1
                int cntx = -1;
                foreach (string hID in henchmenIds)
                {
                    LayEntity hench = SaveGamePlugin.LayFile.FindEntity(hID);
                    cntx++;
                    if (hench == null)
                    {
                        continue;
                    }
                    string           henchName = henchNames[cntx];
                    EvilHenchControl ectrl     = new EvilHenchControl();
                    tabHenchman.SuspendLayout();
                    tabHenchman.Controls.Add(ectrl);
                    ectrl.Tag  = hID;
                    ectrl.Left = 0;
                    ectrl.Top  = 0 + (ectrl.Height * ix);
                    ectrl.BringToFront();
                    ectrl.Text = henchName;
                    tabHenchman.ResumeLayout();
                    tabHenchman.PerformLayout();
                    tabHenchman.Refresh();
                    ix++;
                }

                foreach (string hID in henchmenIds)
                {
                    // See if we have the henchman
                    LayEntity hench = SaveGamePlugin.LayFile.FindEntity(hID);
                    if (hench == null)
                    {
                        found = false;
                    }
                    else
                    {
                        found = true;
                    }


                    for (int c = 0; c < tabHenchman.Controls.Count; c++)
                    {
                        Control ctrl = tabHenchman.Controls[c];

                        if (ctrl.GetType() != typeof(EvilHenchControl))
                        {
                            continue;
                        }

                        EvilHenchControl evilHench = (EvilHenchControl)ctrl;

                        GroupBox hBox = evilHench.groupBox2;

                        if ((string)evilHench.Tag == hID)
                        {
                            evilHench.Entity = hench;
                        }
                    }
                }
                #endregion


                #region Load regions tab
                string[] regionIds = new string[] { "1550", "1551", "1552", "1553", "1554" }; // TODO order alphabetical

                cntx = -1;
                ix   = 0;
                int regHeight = lblTotalNotoriety.Height;

                foreach (string rID in regionIds)
                {
                    LayEntity region = SaveGamePlugin.LayFile.FindEntity(rID);
                    cntx++;
                    if (region == null)
                    {
                        continue;
                    }
                    EvilRegionControl ectrl = new EvilRegionControl();
                    tabRegions.SuspendLayout();
                    tabRegions.Controls.Add(ectrl);
                    ectrl.Tag  = rID;
                    ectrl.Left = 0;
                    ectrl.Top  = regHeight + (ectrl.Height * ix);
                    ectrl.BringToFront();
                    tabRegions.ResumeLayout();
                    tabRegions.PerformLayout();
                    tabRegions.Refresh();
                    m_Regions.Add(ectrl);
                    ix++;
                }

                foreach (string rID in regionIds)
                {
                    // See if we have the henchman
                    LayEntity region = SaveGamePlugin.LayFile.FindEntity(rID);
                    if (region == null)
                    {
                        found = false;
                    }
                    else
                    {
                        found = true;
                    }


                    for (int c = 0; c < tabRegions.Controls.Count; c++)
                    {
                        Control ctrl = tabRegions.Controls[c];

                        if (ctrl.GetType() != typeof(EvilRegionControl))
                        {
                            continue;
                        }

                        EvilRegionControl evilRegion = (EvilRegionControl)ctrl;


                        if ((string)evilRegion.Tag == rID)
                        {
                            evilRegion.Entity = region;
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                lblStatus.Text          = "Error loading saved game: " + ex.Message;
                tmrLoadProgress.Enabled = false;
                tabEditor.Enabled       = false;
            }
        }