Ejemplo n.º 1
0
        public ManagePortals(GraphicsDevice gfx, MainForm mainForm)
        {
            InitializeComponent();

            parentForm = mainForm;

            this.xnaRenderer1.OnDraw += new EventHandler(XnaRender);

            this.sprite_batch = new SpriteBatch(gfx);

            tile_palette = new TilePalette(this);

            assembly = Assembly.GetExecutingAssembly();
            pixel_texture_stream = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.white_pixel.png"));
            tile_texture_stream = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.white_default_tile.png"));

            grid_texture = Texture2D.FromStream(gfx, pixel_texture_stream);
            tile_texture = Texture2D.FromStream(gfx, tile_texture_stream);

            foreach (Portal portal in GLB_Data.portals)
            {
                ListViewItem lvi = new ListViewItem(portal.name);
                lvi.Text = portal.name;
                lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, portal.x.ToString()));
                lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, portal.y.ToString()));

                portalList.Items.Add(lvi);
            }

            this.MouseWheel += new MouseEventHandler(this.xna_renderer_MouseWheel);

            selectedPortal.name = null;
            selectedPortal.x = -1;
            selectedPortal.y = -1;
            selectedLandingSpot.X = -1;
            selectedLandingSpot.Y = -1;
        }
Ejemplo n.º 2
0
        public MainForm()
        {
            InitializeComponent();

            this.xna_renderer.OnInitialize  += new EventHandler(XnaInitialize);
            this.xna_renderer.OnDraw        += new EventHandler(XnaRender);
            Application.Idle                += delegate { xna_renderer.Invalidate(); };

            Camera.InitCamera();

            // Custom Controls
            tile_palette = new TilePalette(this);
            pnl_tile_palette.Controls.Add(tile_palette);

            InitLoadTilesDialog();
            InitLoadMapDialog();
            InitSaveMapDialog();

            // Set default initial map values
            GLB_Data.TileMap        = new Tile[3 + 1, 20, 20]; // 3 depth layers + walk layer
            // Last layer is used for walk grid!
            GLB_Data.MapSize.Depth      = GLB_Data.TileMap.GetLength(0) - 1;
            GLB_Data.MapSize.Width      = GLB_Data.TileMap.GetLength(1);
            GLB_Data.MapSize.Height     = GLB_Data.TileMap.GetLength(2);
            GLB_Data.MapSize.TileSize   = Constants.DEFAULT_TILE_SIZE;
            GLB_Data.TerrainLayout      = new Int32[GLB_Data.MapSize.Width, GLB_Data.MapSize.Height];

            InitTileMap();
            ResetSelectedTiles();

            ShowCurrentLayer();

            MouseOnMe = false;

            // Undo / Redo functionality
            undo_redo = new UndoRedo();

            CheckUndoRedo();

            HideLayers          = false;
            ShowGrid            = false;
            ShowWalkLayer       = true;
            ShowTerrainTypes    = false;

            InitToolbar();

            // Set default paint tool
            SetBrush(PaintTool.Brush);

            assembly                = Assembly.GetExecutingAssembly();
            pixel_texture_stream    = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.white_pixel.png"));
            tile_texture_stream     = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.white_default_tile.png"));

            chest_texture_stream     = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.chest32.png"));
            NPC_texture_stream       = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.NPC32.png"));
            monster_texture_stream   = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.monster32.png"));
            block_texture_stream    = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.block32.png"));
            switch_texture_stream   = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.switch32.png"));

            xml_writer              = new XmlMapWriter(this);

            this.MouseWheel += new MouseEventHandler(this.xna_renderer_MouseWheel);

            InitTerrainData();
            terrain_editor_form = new TerrainEditor(this);

            // combo box drawing events
            this.toolbar_terrain_combo.ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
            this.toolbar_terrain_combo.ComboBox.DrawItem += new DrawItemEventHandler(combo_terrain_DrawItem);

            // Tile Size editor
            frm_tile_size           = new TileSizeEditor();
            frm_tile_size.Visible   = false;
        }