private void LoadData(EvilPlug.Filetypes.Lay.LayFile layFile) { try { m_Map = new LayMap(layFile); } catch { lblStatus.Text = "Status: Error loading map data!"; m_Loaded = false; m_Loading = false; return; } for (int y = 0; y < m_Map.Size.Height; y++) { for (int x = 0; x < m_Map.Size.Width; x++) { LayMapTile tile = m_Map.Tiles[x, y]; tile.Tag = new ExtraTileInfo(tile, Textures); } } WindowState = FormWindowState.Normal; Application.DoEvents(); WindowState = FormWindowState.Maximized; m_Loaded = true; m_Loading = false; MapTools = new LayMapTool(Plugin.LayFile, m_Map); }
public LayMap(LayFile lf) { bool foundMap = false; string[] tempStrings; // Load the map for (int i = 0; i < lf.Properties.Count; i++) { LayProperty prop = lf.Properties[i]; if (prop.Key == "GridDimensions") { tempStrings = prop.Value.Explode(","); if (tempStrings.Length != 2) throw new Exception("Invalid map: size incorrect"); Size = new Size(int.Parse(tempStrings[0]), int.Parse(tempStrings[1])); Tiles = new LayMapTile[Size.Width, Size.Height]; m_tmpTiles = new LayMapTile[Size.Width, Size.Height]; foundMap = true; continue; } if (!foundMap) continue; if (prop.Key == "") continue; if (prop.Key == "DynamicATNData") { break; } m_Y++; string[] parts = prop.Key.Explode(","); m_X = 0; try { foreach (string part in parts) { Tiles[m_X, m_Y] = new LayMapTile(part, m_X, m_Y); m_tmpTiles[m_X, m_Y] = Tiles[m_X, m_Y]; m_X++; LayEntity le = lf.FindEntityByGridLocation(m_X-1, m_Y); if (le != null) { le.TilesGrid.Tiles.Add(Tiles[m_X-1, m_Y]); } } } catch (Exception ex) { ex = ex; } m_TileProperties.Add(prop); string mapPart = prop.Key; mapPart = mapPart.Replace("20006A", "20000A"); prop.Key = mapPart; } if (!foundMap) throw new Exception("No map data found!"); for (int x = 0; x < Size.Width; x++) { for (int y = 0; y < Size.Height; y++) { // Tiles[x, y] = m_tmpTiles[Size.Width - x - 1, y]; // something for later :P } } }
public LayMap(LayFile lf) { bool foundMap = false; string[] tempStrings; // Load the map for (int i = 0; i < lf.Properties.Count; i++) { LayProperty prop = lf.Properties[i]; if (prop.Key == "GridDimensions") { tempStrings = prop.Value.Explode(","); if (tempStrings.Length != 2) { throw new Exception("Invalid map: size incorrect"); } Size = new Size(int.Parse(tempStrings[0]), int.Parse(tempStrings[1])); Tiles = new LayMapTile[Size.Width, Size.Height]; m_tmpTiles = new LayMapTile[Size.Width, Size.Height]; foundMap = true; continue; } if (!foundMap) { continue; } if (prop.Key == "") { continue; } if (prop.Key == "DynamicATNData") { break; } m_Y++; string[] parts = prop.Key.Explode(","); m_X = 0; try { foreach (string part in parts) { Tiles[m_X, m_Y] = new LayMapTile(part, m_X, m_Y); m_tmpTiles[m_X, m_Y] = Tiles[m_X, m_Y]; m_X++; LayEntity le = lf.FindEntityByGridLocation(m_X - 1, m_Y); if (le != null) { le.TilesGrid.Tiles.Add(Tiles[m_X - 1, m_Y]); } } } catch (Exception ex) { ex = ex; } m_TileProperties.Add(prop); string mapPart = prop.Key; mapPart = mapPart.Replace("20006A", "20000A"); prop.Key = mapPart; } if (!foundMap) { throw new Exception("No map data found!"); } for (int x = 0; x < Size.Width; x++) { for (int y = 0; y < Size.Height; y++) { // Tiles[x, y] = m_tmpTiles[Size.Width - x - 1, y]; // something for later :P } } }
public LayMapTool(LayFile lf, LayMap lm) { Lay = lf; Map = lm; }
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; } }