コード例 #1
0
        public static void ExportMixMaps(string[] astr)
        {
            // Expand filespecs
            ArrayList alsFiles = new ArrayList();

            for (int n = 1; n < astr.Length; n++)
            {
                string strFileT = Path.GetFileName(astr[n]);
                string strDirT  = Path.GetDirectoryName(astr[n]);
                if (strDirT == "")
                {
                    strDirT = ".";
                }
                string[] astrFiles = Directory.GetFiles(strDirT, strFileT);
                alsFiles.AddRange(astrFiles);
            }

            foreach (string strFile in alsFiles)
            {
                LevelDoc lvld = (LevelDoc)DocManager.NewDocument(typeof(LevelDoc), null);
                Console.Write("Exporting " + strFile + " as ");
                string strFileExport = MixSuck.ImportExportMixMap(strFile, lvld);
                if (strFileExport == null)
                {
                    Console.Write("Error exporting!\n");
                }
                else
                {
                    Console.Write(strFileExport + "\n");
                }
                lvld.Dispose();
            }
        }
コード例 #2
0
        public static void MixMapImportSpecial(Theater theater, TemplateDoc tmpdCopyTerrain, string strFileSave)
        {
            TemplateDoc tmpd24 = (TemplateDoc)DocManager.NewDocument(typeof(TemplateDoc), new Object[] { new Size(24, 24) });

            MixTemplate[] amixt = MixSuck.LoadTemplates(theater);
            MixSuck.ImportTemplates(amixt, tmpd24);

            Template[] atmpl24 = tmpd24.GetTemplates();
            Template[] atmpl16 = tmpdCopyTerrain.GetTemplates();

            for (int n = 0; n < atmpl24.Length; n++)
            {
                Template tmpl24 = atmpl24[n];
                Template tmpl16 = atmpl16[n];
                tmpl24.TerrainMap = tmpl16.TerrainMap;
            }

            tmpd24.SetBackgroundTemplate(atmpl24[0]);
            tmpd24.SaveAs(strFileSave);
        }
コード例 #3
0
        public static TemplateDoc CloneTemplateDoc(TemplateDoc tmpdSrc)
        {
            // This should probably be on ICloneable::Clone() on TemplateDoc

            TemplateDoc tmpdDst = (TemplateDoc)DocManager.NewDocument(typeof(TemplateDoc), new Object[] { tmpdSrc.TileSize });

            DocManager.SetActiveDocument(typeof(TemplateDoc), tmpdSrc);

            Template[] atmplSrc          = tmpdSrc.GetTemplates();
            Template   tmplSrcBackground = tmpdSrc.GetBackgroundTemplate();
            Template   tmplDstBackground = null;
            ArrayList  alsTmplDst        = new ArrayList();

            foreach (Template tmplSrc in atmplSrc)
            {
                Template tmplDst = new Template(tmpdDst, tmplSrc.Name);
                tmplDst.OccupancyMap = tmplSrc.OccupancyMap;
                tmplDst.TerrainMap   = tmplSrc.TerrainMap;
                tmplDst.Bitmap       = (Bitmap)tmplSrc.Bitmap.Clone();
                alsTmplDst.Add(tmplDst);
                if (tmplSrc == tmplSrcBackground)
                {
                    tmplDstBackground = tmplDst;
                }
            }
            if (tmplDstBackground != null)
            {
                tmpdDst.SetBackgroundTemplate(tmplDstBackground);
            }
            tmpdDst.AddTemplates((Template[])alsTmplDst.ToArray(typeof(Template)));
            Palette palSrc = tmpdSrc.GetPalette();

            if (palSrc != null)
            {
                tmpdDst.SetPalette(palSrc, false);
            }

            return(tmpdDst);
        }
コード例 #4
0
        private void AddTemplates()
        {
            // Get tile filename(s)

            OpenFileDialog frmOpen = new OpenFileDialog();

            frmOpen.Multiselect = true;
            frmOpen.Filter      = "Image Files (*.*)|*.*";
            frmOpen.Title       = "Add Templates";
            if (frmOpen.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            // Load them up. If there is no template doc yet, make a new one

            if (m_tmpdActive == null)
            {
                DocManager.NewDocument(typeof(TemplateDoc), null);
            }
            m_tmpdActive.AddTemplates(frmOpen.FileNames);
        }
コード例 #5
0
        private void toolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            switch (toolBar.Buttons.IndexOf(e.Button))
            {
            case 0:
                DocManager.NewDocument(typeof(TemplateDoc), null);
                break;

            case 1:
                DocManager.OpenDocument(typeof(TemplateDoc));
                break;

            case 2:
                if (m_tmpdActive != null)
                {
                    m_tmpdActive.Save();
                }
                break;

            case 3:
                AddTemplates();
                //Rectangle rc = toolBar.Buttons[toolBar.Buttons.IndexOf(e.Button)].Rectangle;
                //contextMenuToolbar.Show(toolBar, new Point(rc.X, rc.Y + rc.Height));
                break;

            case 4:
                // Separator
                break;

            case 5:
                if (m_tmpdActive == null)
                {
                    return;
                }
                m_tmpdActive.Close();
                break;
            }
        }
コード例 #6
0
        public static void ImportExpansionPdb(string strFile)
        {
            PdbPacker pdbp = new PdbPacker(strFile);

            ArrayList alsTileSets = new ArrayList();

            for (int i = 0; i < pdbp.Count; i++)
            {
                PdbPacker.File file = pdbp[i];
                if (!file.str.EndsWith(".lvl"))
                {
                    continue;
                }

                // Load up the pieces

                Ini     ini = Ini.LoadBinary(new MemoryStream(file.ab));
                string  strTileMapFilename = ini["General"]["TileMap"].Value;
                TileMap tmap = TileMap.Load(new MemoryStream(pdbp[strTileMapFilename].ab));


                // First, tell the active LevelDoc not to switch its templates based on the following
                // template load

                LevelDoc lvldActive = (LevelDoc)DocManager.GetActiveDocument(typeof(LevelDoc));
                if (lvldActive != null)
                {
                    lvldActive.SwitchTemplatesEnabled = false;
                }

                // If the TileSet for this level is not yet available, load it now

                TemplateDoc tmpd = (TemplateDoc)DocManager.OpenDocument(tmap.Filename.Replace(".tset", ".tc"));
                TileSet     tset = null;
                foreach (TileSet tsetT in alsTileSets)
                {
                    if (tsetT.FileName == tmap.Filename)
                    {
                        tset = tsetT;
                        break;
                    }
                }
                if (tset == null)
                {
                    tset = new TileSet(tmpd, tmap.Filename);
                    alsTileSets.Add(tset);
                }

                // Re-enable template switching

                if (lvldActive != null)
                {
                    lvldActive.SwitchTemplatesEnabled = true;
                }

                // Create a new level description, and deduce which templates are in it, with what visibility

                LevelDoc lvld = (LevelDoc)DocManager.NewDocument(typeof(LevelDoc), null);
                lvld.OutputFilename = file.str;
                ImportTileMap(tmap, tset, tmpd, lvld);

                // Walls are stored in the terrain map. Load them.
                string     strTrmapFilename = ini["General"]["TerrainMap"].Value;
                TerrainMap trmap            = TerrainMap.Load(new MemoryStream(pdbp[strTrmapFilename].ab));
                ImportWalls(trmap, lvld);

                // Load everything else
                lvld.LoadIni(ini);
            }
        }