public EditLevelTextForm(LevelDoc lvld) { // // Required for Windows Form Designer support // InitializeComponent(); m_lvld = lvld; m_strLevelText = m_lvld.GetLevelText(); richTextBox1.Text = m_strLevelText; }
public UnitGroupsForm(LevelDoc lvld, UnitGroupManager ugm) { // // Required for Windows Form Designer support // InitializeComponent(); // m_ugm = ugm; m_lvld = lvld; m_ugm.ClearModified(); InitUnitGroupsListBox(); InitSideComboBox(); InitAggressivenessComboBox(); InitSpawnAreaComboBox(); }
public void ImportMap(LevelDoc lvld) { TemplatePos[] atpos = GetTemplatePositions(); ArrayList alsTiles = new ArrayList(); foreach (TemplatePos tpos in atpos) { int txOrigin = 64 - tpos.m_mixt.XTileCount - tpos.m_txOrigin; int tyOrigin = tpos.m_tyOrigin; bool[,] afDraw = new bool[tpos.m_mixt.YTileCount, tpos.m_mixt.XTileCount]; for (int ty = 0; ty < tpos.m_mixt.YTileCount; ty++) { for (int tx = 0; tx < tpos.m_mixt.XTileCount; tx++) { afDraw[ty, tx] = tpos.m_afMapped[ty, tpos.m_mixt.XTileCount - tx - 1]; } } Tile tile = new Tile(tpos.m_mixt.Index.ToString(), txOrigin, tyOrigin, afDraw, null); alsTiles.Add(tile); } lvld.AddMapItems((IMapItem[])alsTiles.ToArray(typeof(IMapItem))); }
void LevelDoc_NameChanged(LevelDoc lvld) { SetTitle(); }
public static void Error(LevelDoc lvld, object ob, string strFormat, params object[] aob) { string str = String.Format(strFormat, aob); s_frm.AddError(lvld, ob, str); }
public static string ImportExportMixMap(string strFile, LevelDoc lvld) { // Load ini Ini ini = new Ini(strFile); // Get name of level String strName = strFile; Ini.Section secBasic = ini["Basic"]; if (secBasic != null) { Ini.Property propName = secBasic["Name"]; if (propName != null) { strName = propName.Value; } else { Ini.Property propBrief = secBasic["Brief"]; if (propBrief != null) strName = propBrief.Value; } } // Get theater Ini.Section secMap = ini["MAP"]; if (secMap == null) { MessageBox.Show("Could not load " + strFile); return null; } Theater theater; switch (secMap["Theater"].Value) { case "DESERT": theater = Theater.Desert; break; case "TEMPERATE": theater = Theater.Temperate; break; case "WINTER": theater = Theater.Winter; break; default: MessageBox.Show("Could not load " + strFile); return null; } // Get bounds & invert int xLeft = Int32.Parse(secMap["X"].Value); int yTop = Int32.Parse(secMap["Y"].Value); int cxWidth = Int32.Parse(secMap["Width"].Value); int cyHeight = Int32.Parse(secMap["Height"].Value); Rectangle rcBounds = new Rectangle(64 - (xLeft + cxWidth), yTop, cxWidth, cyHeight); // We're ready to go lvld.Title = strName; //fixme //lvld.TileCollectionFileName = theater.ToString() + ".tc"; lvld.Bounds = rcBounds; // Load up MixTemplate[] amixt = MixSuck.LoadTemplates(theater); MixSuck.ImportTemplates(amixt, lvld.GetTemplateDoc()); Stream stm = (Stream)new FileStream(strFile.ToLower().Replace(".ini", ".bin"), FileMode.Open, FileAccess.Read, FileShare.Read); MixMap map = MixSuck.LoadMap(stm, amixt); stm.Close(); map.ImportMap(lvld); //fixme //lvld.SetBackgroundTemplate(lvld.GetTemplateDoc()FindTemplate(0)); // Save string strFileLvld = strName + "_" + Path.GetFileName(strFile).Replace(".ini", ".ld"); lvld.SaveAs(strFileLvld); // Also save a scaled image for reference TemplateDoc tmpd = lvld.GetTemplateDoc(); Bitmap bm = lvld.GetMapBitmap(tmpd.TileSize, tmpd, true); int cx; int cy; if (bm.Width > bm.Height) { cx = 128; cy = bm.Height * 128 / bm.Width; } else { cx = bm.Width * 128 / bm.Height; cy = 128; } bm = (Bitmap)bm.GetThumbnailImage(cx, cy, null, IntPtr.Zero); bm.Save(strFileLvld.Replace(".ld", ".png"), ImageFormat.Png); bm.Dispose(); // Save a full 24x24 original map image for reference map.SaveMapBitmap("cc_" + strFileLvld.Replace(".ld", ".png")); return strFileLvld; }
public void AddError(LevelDoc lvld, object ob, string str) { int i = m_alLevelErrors.Add(new LevelError(lvld, ob)); tbcOutput.AppendText(i.ToString() + "> " + str); }
public LevelError(LevelDoc lvld, object ob) { m_lvld = lvld; m_ob = ob; }
//c:\code\ht\m\outputform.cs(21,15): error CS0111: private void ValidateCallback(LevelDoc lvld, LevelDoc.ValidateError ve, int tx, int ty, object ob, string str) { OutputForm.ShowIt(); #if false OutputForm.Error(lvld, ob, "({0},{1},{2}): {3}: {4}\n", tx, ty, ob == null ? "" : ob.GetHashCode().ToString(), ve.ToString(), str); #else if (ob is Unit) { OutputForm.Error(lvld, ob, "({0},{1}): {2}: Side {3} {4}\n", tx, ty, ve.ToString(), ((Unit)ob).Side, str); } else { OutputForm.Error(lvld, ob, "({0},{1}): {2}: {3}\n", tx, ty, ve.ToString(), str); } #endif }
public LevelView() { m_lvld = null; }
public void SetDocument(Document doc) { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); // Add any initialization after the InitForm call m_lvld = (LevelDoc)doc; // Create the bitmap AutoScroll = true; VScroll = true; HScroll = true; CreateBitmap(); // Init view position InitPosition(); // Draw it initially m_lvld.Draw(m_bm, null, GetTileSize(), GetTemplateDoc(), m_lyrf); // Need to know these events m_lvld.ImageChanged += new LevelDoc.ImageChangedHandler(LevelDoc_ImageChanged); m_lvld.ItemsRemoved += new LevelDoc.ItemsRemovedHandler(LevelDoc_ItemsRemoved); // Check size CheckSize(); }
static void ImportWalls(TerrainMap trmap, LevelDoc lvld) { ArrayList alsmi = new ArrayList(); for (int ty = 0; ty < trmap.Map.GetLength(0); ty++) { for (int tx = 0; tx < trmap.Map.GetLength(1); tx++) { if (trmap.Map[ty, tx] == TerrainTypes.Wall) { IMapItem mi = new Wall(100, lvld.Bounds.Left + tx, lvld.Bounds.Top + ty); alsmi.Add(mi); } } } lvld.AddMapItems((IMapItem[])alsmi.ToArray(typeof(IMapItem))); }
static void ImportTileMap(TileMap tmap, TileSet tset, TemplateDoc tmpd, LevelDoc lvld) { // The TileMap is a list of indexes into a tile set. A Tileset is a list of tiles compiled // from Templates. Reverse the tilemap into Templates, and set into lvld. bool[,] afCellTaken = new bool[64, 64]; ArrayList alsTemplPos = new ArrayList(); Template[] atmpl = tmpd.GetTemplates(); for (int ty = 0; ty < tmap.Height; ty++) { for (int tx = 0; tx < tmap.Width; tx++) { // Cell mapped already? if (afCellTaken[ty, tx]) { continue; } // Cell not mapped. Create TemplatePos. int iTile = tmap.GetTileIndex(tx, ty); TileData tdata = tset.GetTileData(iTile); Template tmpl = atmpl[tdata.iTemplate]; // Don't bother with background tiles if (tmpl == tmpd.GetBackgroundTemplate()) { continue; } int txOrigin = tx - tdata.txTemplate; int tyOrigin = ty - tdata.tyTemplate; bool[,] afMapped = new bool[tmpl.Cty, tmpl.Ctx]; for (int tyTmpl = 0; tyTmpl < tmpl.Cty; tyTmpl++) { for (int txTmpl = 0; txTmpl < tmpl.Ctx; txTmpl++) { int txT = txOrigin + txTmpl; int tyT = tyOrigin + tyTmpl; if (txT < 0 || txT >= 64 || tyT < 0 || tyT >= 64) { continue; } if (afCellTaken[tyT, txT]) { continue; } int iTileT = tmap.GetTileIndex(txT, tyT); if (iTileT != -1) { TileData tdataT = tset.GetTileData(iTileT); if (tdataT.iTemplate != tdata.iTemplate) { continue; } if (tdataT.txTemplate != txTmpl || tdataT.tyTemplate != tyTmpl) { continue; } } afMapped[tyTmpl, txTmpl] = true; afCellTaken[tyT, txT] = true; } } alsTemplPos.Add(new TemplatePos(tmpl, txOrigin, tyOrigin, afMapped)); } } // Figure out the bounds. Rectangle rcBounds = new Rectangle((64 - tmap.Width) / 2, (64 - tmap.Height) / 2, tmap.Width, tmap.Height); lvld.Bounds = rcBounds; // The list of TemplatePos's has been created. Add to LevelDoc. ArrayList alsTiles = new ArrayList(); foreach (TemplatePos tpos in alsTemplPos) { Tile tile = new Tile(tpos.tmpl.Name, tpos.txOrigin + rcBounds.Left, tpos.tyOrigin + rcBounds.Top, tpos.afMapped, tpos.tmpl.OccupancyMap); alsTiles.Add(tile); } lvld.AddMapItems((IMapItem[])alsTiles.ToArray(typeof(IMapItem))); }