コード例 #1
0
        void setTileToBlock(int x, int y, int block, int spr_id, bool write_to_history)
        {
            Scena scn = Gl.curr_scena;

            if (scn.blocks[block][x, y].SpriteId != spr_id)
            {
                if (write_to_history)
                {
                    History.History.AddBlockEvent(x, y, block, scn.blocks[block][x, y].SpriteId, spr_id);
                }
                if (spr_id != -1)
                {
                    scn.blocks[block][x, y] = scn.spriteSet[spr_id];
                    bitmaps[block][x, y]    = scn.blocks[block][x, y].Sprite;
                }
                else
                {
                    scn.blocks[block][x, y] = blank_Tile;
                    bitmaps[block][x, y]    = scn.ground_sprites.getBitmapImage(-1, 0);
                }

                blocksList[lastBlock_image].ChangeBlock(bitmaps[lastBlock_image]);
                //UpdateBlockImages();
            }
        }
コード例 #2
0
        private void Divide_Map_button_Click(object sender, RoutedEventArgs e)
        {
            Scena scn = Gl.curr_scena;

            string folder = System.IO.Path.GetDirectoryName(scn.scena_path) + "\\";

            int x = -1;
            int y = -1;
            int w = 128;
            int h = 128;

            x = 0; y = 0;
            Export_Part_MegaMap(folder + "scena_01.scn", x, y, w, h);
            x = 128; y = 0;
            Export_Part_MegaMap(folder + "scena_02.scn", x, y, w, h);
            x = 256; y = 0;
            Export_Part_MegaMap(folder + "scena_03.scn", x, y, w, h);
            x = 0; y = 128;
            Export_Part_MegaMap(folder + "scena_04.scn", x, y, w, h);
            x = 128; y = 128;
            Export_Part_MegaMap(folder + "scena_05.scn", x, y, w, h);
            x = 256; y = 128;
            Export_Part_MegaMap(folder + "scena_06.scn", x, y, w, h);
            x = 0; y = 256;
            Export_Part_MegaMap(folder + "scena_07.scn", x, y, w, h);
            x = 128; y = 256;
            Export_Part_MegaMap(folder + "scena_08.scn", x, y, w, h);
            x = 256; y = 256;
            Export_Part_MegaMap(folder + "scena_09.scn", x, y, w, h);
            x = 384; y = 128;
            Export_Part_MegaMap(folder + "scena_10.scn", x, y, w, h);

            System.Windows.MessageBox.Show("MEGA MAP divided", "Divide MEGA MAP", MessageBoxButton.OK, MessageBoxImage.Information);
        }
コード例 #3
0
        private void move_right_block_button_Click(object sender, RoutedEventArgs e)
        {
            if (lastBlock < 0 || lastBlock >= bitmaps.Count - 1)
            {
                return;
            }

            int tmp = widths[lastBlock + 1];

            widths[lastBlock + 1] = widths[lastBlock];
            widths[lastBlock]     = tmp;

            tmp = heights[lastBlock + 1];
            heights[lastBlock + 1] = heights[lastBlock];
            heights[lastBlock]     = tmp;

            Scena scn = Gl.curr_scena;

            Tile[,] tmp_block         = scn.blocks[lastBlock + 1];
            scn.blocks[lastBlock + 1] = scn.blocks[lastBlock];
            scn.blocks[lastBlock]     = tmp_block;

            ImageSource[,] tmp_i   = bitmaps[lastBlock + 1];
            bitmaps[lastBlock + 1] = bitmaps[lastBlock];
            bitmaps[lastBlock]     = tmp_i;

            lastBlock++;

            updateLabelInfo();
            UpdateBlocks();
            UpdateBlockInMain();
        }
コード例 #4
0
        public void Zmiana(Scena scena)
        {
            /*
             * //Czyszczenie. Garbage Collector powinien (?????!!!!) zwolnić pamięć
             * switch (this.scena)
             * {
             *  case Scena.Title:
             *      title = null; //title.UnloadContent(); -- narazie ni ma!!!!!
             *      break;
             *  case Scena.Creator:
             *      charCreator = null;
             *      break;
             * }
             *
             * //Utworzenie sceny
             * switch (scena)
             * {
             *  case Scena.Creator:
             *      charCreator = new CharCreator(spriteBatch, this);
             *      break;
             *  case Scena.MainGame:
             *      mainScreen = new MainScreen(spriteBatch, this);
             *      break;
             * }
             */

            //Własciwa zmiana sceny
            if (scena == Scena.Creator)
            {
                charCreator.Reload();
            }
            this.scena = scena;
        }
コード例 #5
0
        private void StressTest2_Button_Click(object sender, RoutedEventArgs e)
        {
            /*
             * Нагрузочный тест на Орду
             */

            Scena scn = Gl.curr_scena;

            if ((bool)comboBox_Rows.IsChecked)
            {
                for (int i = 0; i < scn.size_map_x; i++)
                {
                    for (int j = 0; j < scn.size_map_y; j++)
                    {
                        scn.set_Ground_region_tile(j, i, 1, scn.spriteSet[(i * scn.size_map_y + j) % scn.spriteSet.Count].SpriteId, true);
                    }
                }
            }
            else if ((bool)comboBox_Columns.IsChecked)
            {
                for (int i = 0; i < scn.size_map_x; i++)
                {
                    for (int j = 0; j < scn.size_map_y; j++)
                    {
                        scn.set_Ground_region_tile(i, j, 1, scn.spriteSet[(i * scn.size_map_y + j) % scn.spriteSet.Count].SpriteId, true);
                    }
                }
            }

            Gl.main.HistoryWrite();
        }
コード例 #6
0
        private void Clear_Tiles_Click(object sender, RoutedEventArgs e)
        {
            Scena scn = Gl.curr_scena;

            int[] count   = new int[scn.tileSet.Count];
            int   deleted = 0;

            for (int i = 0; i < scn.size_map_x; i++)
            {
                for (int j = 0; j < scn.size_map_y; j++)
                {
                    count[scn.map[i, j].TileId]++;
                }
            }

            for (int i = scn.tileSet.Count - 1; i >= 0; i--)
            {
                if (count[i] == 0)
                {
                    Gl.tiles_window.DeleteTile(i);
                    deleted++;
                }
            }

            // генерируем палитру.
            Gl.palette.InitLandPalette(scn);

            System.Windows.MessageBox.Show("Deleted " + deleted + " tiles.", "Clearing", MessageBoxButton.OK, MessageBoxImage.Information);
        }
コード例 #7
0
        // добавление информации о блоке(набор тайлов)
        public void AddBlock(Tile[,] tiles)
        {
            int x = tiles.GetLength(0);
            int y = tiles.GetLength(1);

            widths.Add(x);
            heights.Add(y);

            Scena scn = Gl.curr_scena;

            ImageSource[,] bmp = new ImageSource[x, y];
            bitmaps.Add(bmp);

            //bi.Width = x * 32;
            //bi.Height = y * 32;

            for (int j = 0; j < y; j++)
            {
                for (int i = 0; i < x; i++)
                {
                    bmp[i, j] = scn.ground_sprites.getBitmapImage(tiles[i, j].SpriteId, 0);
                }
            }

            BlockSlider.Maximum = bitmaps.Count;
        }
コード例 #8
0
        private void copy_block_button_Click(object sender, RoutedEventArgs e)
        {
            if (lastBlock < 0 || lastBlock >= widths.Count)
            {
                return;
            }

            int w = widths[lastBlock];
            int h = heights[lastBlock];

            InsertBlock(lastBlock + 1, w, h);

            Scena scn = Gl.curr_scena;

            Tile[,] block_new = scn.blocks[lastBlock + 1];
            Tile[,] block_old = scn.blocks[lastBlock];

            for (int i = 0; i < w; i++)
            {
                for (int j = 0; j < h; j++)
                {
                    bitmaps[lastBlock + 1][i, j] = bitmaps[lastBlock][i, j];
                    block_new[i, j] = block_old[i, j];
                }
            }
            //AddBlock(Tile[,] tiles)

            UpdateBlockImages();
        }
コード例 #9
0
        public void InsertBlock(int n, int x, int y)
        {
            widths.Insert(n, x);
            heights.Insert(n, y);

            Scena scn = Gl.curr_scena;

            ImageSource[,] bmp = new ImageSource[x, y];
            bitmaps.Insert(n, bmp);

            Tile[,] block = new Tile[x, y];
            for (int j = 0; j < y; j++)
            {
                for (int i = 0; i < x; i++)
                {
                    block[i, j] = blank_Tile;
                }
            }

            Gl.curr_scena.blocks.Insert(n, block);

            for (int j = 0; j < y; j++)
            {
                for (int i = 0; i < x; i++)
                {
                    bmp[i, j] = scn.ground_sprites.getBitmapImage(-1, 0);
                }
            }

            BlockSlider.Maximum = bitmaps.Count;
        }
コード例 #10
0
        private void Export_map_in_universal(string path)
        {
            if (!uni_indexes_check())
            {
                return;
            }

            Scena scn = Gl.curr_scena;


            if (!Directory.Exists(Gl.running_dir + "\\resources\\universal\\maps"))
            {
                Directory.CreateDirectory(Gl.running_dir + "\\resources\\universal\\maps");
            }

            FileStream outStream = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Read);

            byte[] spr_index = new byte[4];

            for (int i = 0; i < scn.size_map_x; i++)     // y
            {
                for (int j = 0; j < scn.size_map_y; j++) // x
                {
                    spr_index = Utils.i2b(scn.map[i, j].TileId_inUniversal, 4);
                    outStream.WriteByte(spr_index[0]);
                    outStream.WriteByte(spr_index[1]);
                    outStream.WriteByte(spr_index[2]);
                    outStream.WriteByte(spr_index[3]);
                }
            }
        }
コード例 #11
0
ファイル: MainWindow.cs プロジェクト: matiyas/LGiM_Mono
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();

        stan                  = global::State.none;
        czuloscMyszy          = 0.3;
        labelTrybEdycji.Text  = tryb.ToString();
        comboboxModele.Active = 0;
        string sciezkaTlo = @"background.jpg";

        scena = new Scena(sciezkaTlo, System.Drawing.Image.FromFile(sciezkaTlo).Size, 1000, 100)
        {
            KolorPedzla = Green,
            KolorTla    = Black,
        };

        WczytajModel(@"modele/sphere.obj", @"tekstury/sun.jpg");
        WczytajModel(@"modele/smoothMonkey.obj", @"tekstury/mercury.jpg");
        scena.Swiat[1].Przesun(new Vector3D(500, 0, 0));
        scena.Swiat[1].Skaluj(new Vector3D(-50, -50, -50));
        scena.ZrodloSwiatlaIndeks = 0;

        GLib.Timeout.Add(50, new GLib.TimeoutHandler(OnUpdate));

        eventboxEkran.AddEvents((int)(EventMask.PointerMotionMask
                                      | EventMask.Button1MotionMask
                                      | EventMask.Button2MotionMask
                                      | EventMask.ScrollMask));
    }
コード例 #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            Scena scena = db.Sceny.Find(id);

            db.Sceny.Remove(scena);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #13
0
 public ActionResult Edit([Bind(Include = "scena_id,nazwa,wielkosc,numer")] Scena scena)
 {
     if (ModelState.IsValid)
     {
         db.Entry(scena).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(scena));
 }
コード例 #14
0
        public ActionResult Create([Bind(Include = "scena_id,nazwa,wielkosc,numer")] Scena scena)
        {
            if (ModelState.IsValid)
            {
                db.Sceny.Add(scena);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(scena));
        }
コード例 #15
0
        private void UpdatePlayerPalette()
        {
            Scena scn    = Gl.curr_scena;
            int   number = comboBox_Player.SelectedIndex;

            Gl.curr_scena.players[number].army_type = combobox_army.SelectedIndex;
            Player p = scn.players[number];

            byte[] pixels16 = p.colors;

            player_palette.Source = bmp16to32bit(16, 16, 8, pixels16);
        }
コード例 #16
0
        private void button_tile_to_block_Click(object sender, RoutedEventArgs e)
        {
            /*
             *  Из тайлов составляет блоки.
             */

            Scena scn = Gl.curr_scena;
            int   w   = 0;
            int   h   = 0;

            if (!int.TryParse(Width_tile_to_block.Text, out w))
            {
                return;
            }
            if (!int.TryParse(Height_tile_to_block.Text, out h))
            {
                return;
            }

            if (w == 0 || h == 0)
            {
                return;
            }

            Tile[,] new_block = new Tile[w, h];

            if ((bool)comboBox_Rows.IsChecked)
            {
                for (int i = 0; i < w; i++)
                {
                    for (int j = 0; j < h; j++)
                    {
                        new_block[i, j] = scn.tileSet[Gl.palette.selected_tile + j * w + i];
                    }
                }
            }
            else if ((bool)comboBox_Columns.IsChecked)
            {
                for (int i = 0; i < w; i++)
                {
                    for (int j = 0; j < h; j++)
                    {
                        new_block[i, j] = scn.tileSet[Gl.palette.selected_tile + i * w + j];
                    }
                }
            }

            scn.blocks.Add(new_block);
            Gl.blocks_window.AddBlock(new_block);

            Gl.main.HistoryWrite();
        }
コード例 #17
0
        // GET: Scenas/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Scena scena = db.Sceny.Find(id);

            if (scena == null)
            {
                return(HttpNotFound());
            }
            return(View(scena));
        }
コード例 #18
0
        private void Clear_Blocks_Click(object sender, RoutedEventArgs e)
        {
            Scena scn   = Gl.curr_scena;
            int   count = scn.blocks.Count;

            for (int i = 0; i < count; i++)
            {
                Gl.blocks_window.RemoveBlock(0);
            }

            Gl.blocks_window.UpdateBlocks();

            System.Windows.MessageBox.Show("Deleted " + count + " blocks.", "Clearing", MessageBoxButton.OK, MessageBoxImage.Information);
        }
コード例 #19
0
        private void Export_Part_MegaMap(string path, int x, int y, int w, int h)
        {
            Scena scn = Gl.curr_scena;

            if (File.Exists(path))
            {
                System.Windows.MessageBoxResult res = System.Windows.MessageBox.Show("File \"" + path + "\" is exist. Replace it?", "Divide MEGA MAP", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (res == MessageBoxResult.No)
                {
                    return;
                }
            }

            scn.Save_Scene_Part(path, x, y, w, h);
        }
コード例 #20
0
        private bool uni_indexes_check()
        {
            Scena        scn      = Gl.curr_scena;
            ComboBoxItem cbi      = (ComboBoxItem)parentScena_comboBox.SelectedItem;
            string       filename = Gl.running_dir + "\\resources\\universal\\" + cbi.Content;

            if (scn.uni_indexes_readed != filename)
            {
                Read_universal_indexes();
            }
            if (scn.uni_indexes_readed != filename)
            {
                return(false);
            }

            return(true);
        }
コード例 #21
0
        private void Clear_units_Button_Click(object sender, RoutedEventArgs e)
        {
            Scena scn = Gl.curr_scena;

            //Thread newWindowThread = Gl.CreateProgressWindow("Clearing...");

            #region get rect
            int sx = 0;
            int sy = 0;
            int ex = scn.size_map_x;
            int ey = scn.size_map_y;

            //if (!(bool)AllMap_toggleButton.IsChecked)
            if (Gl.main.select_land_mode)
            {
                sx = (int)Canvas.GetLeft(Gl.main.rectangle_select_land); //Gl.main.rectangle_select_land. ;
                sy = (int)Canvas.GetTop(Gl.main.rectangle_select_land);;
                ex = (int)(Gl.main.rectangle_select_land.Width - 1);
                ey = (int)(Gl.main.rectangle_select_land.Height - 1);

                sx /= 32;
                sy /= 32;
                ex /= 32;
                ey /= 32;

                ex += sx;
                ey += sy;
            }
            #endregion get rect

            for (int i = sx; i < ex; i++)
            {
                for (int j = sy; j < ey; j++)
                {
                    while (scn.map_units[i, j] != null && scn.map_units[i, j].Count > 0)
                    {
                        scn.unit_delete(scn.map_units[i, j][0], true);
                    }
                }
            }

            Gl.main.HistoryWrite();

            //newWindowThread.Abort();
        }
コード例 #22
0
        private void Read_universal_indexes()
        {
            ComboBoxItem cbi      = (ComboBoxItem)parentScena_comboBox.SelectedItem;
            string       filename = Gl.running_dir + "\\resources\\universal\\" + cbi.Content;


            bool         result = false;
            Scena        scn    = Gl.curr_scena;
            StreamReader str    = new StreamReader(filename);
            string       s      = str.ReadLine();
            int          id;

            for (int i = 0; i < scn.tileSet.Count; i++)
            {
                result = int.TryParse(s, out id);
                if (result == true)
                {
                    for (int j = 0; j < scn.tileSet[i].FramesCount; j++)
                    {
                        scn.spriteSet[scn.tileSet[i].FirstSpriteId + j].TileId_inUniversal = id + j;
                    }
                    s = str.ReadLine();
                }
                else
                {
                    break;
                }
            }

            if (s != null)
            {
                result = false;
            }

            if (result == true)
            {
                scn.uni_indexes_readed = filename;
            }
            else
            {
                scn.uni_indexes_readed = "no";
                System.Windows.MessageBox.Show("Bad indexes file.", "Error", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
コード例 #23
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Rysownik r = new Rysownik();

            r.Sprajty.Add(Bitmap.FromFile("Atlasy/Opis.png"));

            ObiektGry o = new ObiektGry("Tlo", 0, 0);

            o.DodajKomponent(r);

            Scena s = new Scena();

            s.DodajObiekt(o);

            new SilnikGry("Test", 1600, 1200).Graj(s, 30);
        }
コード例 #24
0
        protected override void Initialize()
        {
            ekran = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
            //ekran = new Rectangle(0, 0, 1366, 768);
            float scalaX = (float)ekran.Width / 1920;
            float scalaY = (float)ekran.Height / 1080;

            skala = new Vector2(scalaX, scalaY);

            spriteBatch = new SpriteBatch(GraphicsDevice);
            audio       = new AudioManager(this);

            title       = new TitleScreen(spriteBatch, this);
            charCreator = new CharCreator(spriteBatch, this); //Wszystko incijalizuje się na pocżatku. Pinknie
            mainScreen  = new MainScreen(spriteBatch, this);

            scena = Scena.Title;
            base.Initialize();
        }
コード例 #25
0
ファイル: Palette.cs プロジェクト: el-100/HordeEditor
        public void InitLandPalette(Scena scn)
        {
            int w = tiles_collumns_count;
            int h = scn.tileSet.Count / tiles_collumns_count;

            if (scn.tileSet.Count % tiles_collumns_count != 0)
            {
                h++;
            }
            //w *= 32;
            //h *= 32;

            DrawingGroup imageDrawings = new DrawingGroup();

            scn.Mega_bmp = new DrawingImage(imageDrawings);

            ImageDrawing img_d;

            for (int j = 0; j < h; j++)
            {
                for (int i = 0; i < w; i++)
                {
                    if (scn.tileSet.Count > j * tiles_collumns_count + i)
                    {
                        System.Windows.Rect r = new System.Windows.Rect(i * 32, j * 32, 32, 32);

                        img_d = new ImageDrawing(scn.tileSet[j * tiles_collumns_count + i].Sprite, r);
                        img_d.Freeze();

                        imageDrawings.Children.Add(img_d);
                    }
                }
            }
            Gl.main.Ground_Pallete_Image.Source  = scn.Mega_bmp;
            Gl.main.Ground_Pallete_Canvas.Height = scn.Mega_bmp.Height;
        }
コード例 #26
0
        private void FillMap_tile_Button_Click(object sender, RoutedEventArgs e)
        {
            if (Gl.palette.selected_sprite < 0)
            {
                return;
            }


            Scena scn = Gl.curr_scena;

            //int step = Gl.palette.curr_ground_brush_size;
            int step = 1;

            //if (step == 0)
            //    return;

            Thread newWindowThread = Gl.CreateProgressDetWindow("Filling...");

            Gl.ProgressDetProgressChange(0);
            Gl.ProgressDetStatusChange("Draw map..");

            #region get rect
            int sx = 0;
            int sy = 0;
            int ex = scn.size_map_x + step;
            int ey = scn.size_map_y + step;

            double dp = (double)100 / (double)scn.size_map_x * (double)4;

            //if (!(bool)AllMap_toggleButton.IsChecked)
            if (Gl.main.select_land_mode)
            {
                sx = (int)Canvas.GetLeft(Gl.main.rectangle_select_land); //Gl.main.rectangle_select_land. ;
                sy = (int)Canvas.GetTop(Gl.main.rectangle_select_land);;
                ex = (int)(Gl.main.rectangle_select_land.Width - 1);
                ey = (int)(Gl.main.rectangle_select_land.Height - 1);

                sx /= 32;
                sy /= 32;
                ex /= 32;
                ey /= 32;

                sx += step / 2;
                sy += step / 2;
                //ex += sx;
                //ey += sy;

                dp = (double)100 / (double)(ex - sx) * (double)4;
            }
            #endregion get rect


            for (int i = sx; i < ex; i += step)
            {
                for (int j = sy; j < ey; j += step)
                {
                    scn.set_Ground_region_tile(i, j, step, Gl.palette.selected_sprite, true);
                }

                if (i % (4 * step) == 0)
                {
                    Gl.ProgressDetProgressInc(dp);
                    if (Gl.main.select_land_mode)
                    {
                        Gl.ProgressDetStatusChange("Draw.. (" + (i - sx) + "/" + (ex - sx) + ")");
                    }
                    else
                    {
                        Gl.ProgressDetStatusChange("Draw.. (" + i + "/" + scn.size_map_x + ")");
                    }
                }
            }

            Gl.main.HistoryWrite();

            Gl.CloseProgressDetWindow(newWindowThread);
        }
コード例 #27
0
        private void FillMap_block_Button_Click(object sender, RoutedEventArgs e)
        {
            if (Gl.palette.selected_block < 0 || Gl.palette.selected_block >= Gl.curr_scena.blocks.Count)
            {
                return;
            }

            Scena scn = Gl.curr_scena;

            int step_x = Gl.palette.block_width;
            int step_y = Gl.palette.block_height;

            if (step_x == 0 || step_y == 0)
            {
                return;
            }

            Thread newWindowThread = Gl.CreateProgressDetWindow("Filling...");

            Gl.ProgressDetProgressChange(0);
            Gl.ProgressDetStatusChange("Draw map..");

            #region get rect
            int sx = step_x / 2;
            int sy = step_y / 2;
            int ex = scn.size_map_x + step_x;
            int ey = scn.size_map_y + step_y;

            //if (!(bool)AllMap_toggleButton.IsChecked)
            if (Gl.main.select_land_mode)
            {
                sx = (int)Canvas.GetLeft(Gl.main.rectangle_select_land); //Gl.main.rectangle_select_land. ;
                sy = (int)Canvas.GetTop(Gl.main.rectangle_select_land);;
                ex = (int)(Gl.main.rectangle_select_land.Width - 1);
                ey = (int)(Gl.main.rectangle_select_land.Height - 1);

                sx /= 32;
                sy /= 32;
                ex /= 32;
                ey /= 32;

                sx += step_x / 2;
                sy += step_y / 2;
                ex += sx;
                ey += sy;
            }
            #endregion get rect

            double dp = (double)100 / (double)(ex - sx) * (double)4;

            for (int i = sx; i < ex; i += step_x)
            {
                for (int j = sy; j < ey; j += step_y)
                {
                    Gl.curr_scena.set_Ground_block(i, j, step_x, step_y, Gl.palette.selected_block, true);
                }

                if (i % (4 * step_x) == 0)
                {
                    Gl.ProgressDetProgressInc(dp);
                    if (Gl.main.select_land_mode)
                    {
                        Gl.ProgressDetStatusChange("Draw.. (" + (i - sx) + "/" + (ex - sx) + ")");
                    }
                    else
                    {
                        Gl.ProgressDetStatusChange("Draw.. (" + i + "/" + scn.size_map_x + ")");
                    }
                }
            }

            Gl.main.HistoryWrite();

            Gl.CloseProgressDetWindow(newWindowThread);
        }
コード例 #28
0
        private void Export_blocks_Click(object sender, RoutedEventArgs e)
        {
            if (!uni_indexes_check())
            {
                return;
            }

            Scena scn = Gl.curr_scena;

            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName   = scn.scena_short_name + ".h2b";
            dlg.Title      = "Select blocks file";
            dlg.DefaultExt = "*.h2b";
            dlg.Filter     = "Blocks file|*.h2b";
            Nullable <bool> result = dlg.ShowDialog();

            if (result == false)
            {
                return;
            }



            FileStream outStream = File.Open(dlg.FileName, FileMode.Create, FileAccess.Write, FileShare.Read);


            byte[] spr_index = new byte[4];

            spr_index = Utils.i2b(scn.blocks.Count, 4);
            outStream.WriteByte(spr_index[0]);
            outStream.WriteByte(spr_index[1]);
            outStream.WriteByte(spr_index[2]);
            outStream.WriteByte(spr_index[3]);

            for (int i = 0; i < scn.blocks.Count; i++) // пишем размеры блоков
            {
                outStream.WriteByte((byte)scn.blocks[i].GetLength(0));
                outStream.WriteByte((byte)scn.blocks[i].GetLength(1));
            }
            int cur_w, cur_h;

            for (int i = 0; i < scn.blocks.Count; i++) // пишем сами блоки
            {
                cur_w = scn.blocks[i].GetLength(0);
                cur_h = scn.blocks[i].GetLength(1);

                for (int j2 = 0; j2 < cur_h; j2++)     // y
                {
                    for (int j1 = 0; j1 < cur_w; j1++) // x
                    {
                        if (scn.blocks[i][j1, j2].SpriteId < scn.spriteSet.Count)
                        {
                            spr_index = Utils.i2b(scn.blocks[i][j1, j2].TileId_inUniversal, 4);
                            outStream.WriteByte(spr_index[0]);
                            outStream.WriteByte(spr_index[1]);
                            outStream.WriteByte(spr_index[2]);
                            outStream.WriteByte(spr_index[3]);
                        }
                        else
                        {
                            outStream.WriteByte(0);
                            outStream.WriteByte(0);
                            outStream.WriteByte(0);
                            outStream.WriteByte(0);
                        }
                    }
                }
            }

            System.Windows.MessageBox.Show("Done!", "Export blocks", MessageBoxButton.OK, MessageBoxImage.Information);
        }
コード例 #29
0
        private void Resize_Button_Click(object sender, RoutedEventArgs e)
        {
            int w;
            int h;

            if (!Int32.TryParse(Width_TextBox.Text, out w))
            {
                return;
            }
            if (!Int32.TryParse(Height_TextBox.Text, out h))
            {
                return;
            }
            if (w < 0 || h < 0)
            {
                return;
            }

            // Create a thread
            Thread newWindowThread = Gl.CreateProgressDetWindow("Resizing...");

            Scena scn = Gl.curr_scena;

            Gl.ProgressDetProgressChange(0);
            Gl.ProgressDetStatusChange("Delete excess units..");

            for (int x = 0; x < scn.size_map_x; x++)
            {
                for (int y = 0; y < scn.size_map_y; y++)
                {
                    if (x >= w || y >= h)
                    {
                        while (scn.map_units[x, y] != null && scn.map_units[x, y].Count > 0)
                        {
                            scn.unit_delete(scn.map_units[x, y][0], false);
                        }
                    }
                }
            }

            Gl.ProgressDetProgressInc(2);
            Gl.ProgressDetStatusChange("Resizing arrays..");

            scn.size_map_x        = w;
            scn.size_map_y        = h;
            scn.size_map_x_pixels = w * 32;
            scn.size_map_y_pixels = h * 32;

            scn.map       = Utils.ResizeArray <Tile>(scn.map, w, h, scn.tileSet[0]);
            scn.map_res   = Utils.ResizeArray <int>(scn.map_res, w, h, 0);
            scn.map_units = Utils.ResizeArray <List <Unit> >(scn.map_units, w, h, null);

            Gl.ProgressDetProgressInc(3);
            Gl.ProgressDetStatusChange("Full update..");

            scn.Close_Scene_without_spr();

            scn.FullUpdate();

            Gl.ProgressDetProgressChange(100);
            Gl.ProgressDetStatusChange("All done!");

            Gl.CloseProgressDetWindow(newWindowThread);
        }
コード例 #30
0
        private void Import_blocks_Click(object sender, RoutedEventArgs e)
        {
            Scena        scn = Gl.curr_scena;
            ComboBoxItem cbi = (ComboBoxItem)parentScena_comboBox.SelectedItem;

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Multiselect = true;
            dlg.Title       = "Select blocks file";
            dlg.DefaultExt  = "*.h2b";
            dlg.Filter      = "Blocks file|*.h2b";

            Nullable <bool> result = dlg.ShowDialog();

            if (result == false)
            {
                return;
            }

            foreach (string filename in dlg.FileNames.ToList())
            {
                FileStream inStream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read);

                byte[] tmp_size = new byte[64];
                inStream.Read(tmp_size, 0, 4);
                int count = Utils.b2i(tmp_size, 0, 4);
                int tmp_i2;
                byte[,] blocks_sizes = new byte[count, 2]; // 0 - width; 1 - height

                for (int i = 0; i < count; i++)            // читаем размеры всех блоков
                {
                    inStream.Read(tmp_size, 0, 2);
                    blocks_sizes[i, 0] = tmp_size[0];
                    blocks_sizes[i, 1] = tmp_size[1];
                }


                byte[] block = new byte[16 * 16 * 4]; // максимальный блок состоит из 16x16 тайлов
                //uint whitespace = 0xFFFFFFFF; // пробел в блоке // вроде это -1
                bool flag = true;                     // true если блок пустой

                //Gl.blocks_window.Clear();

                int cur_w, cur_h; // размеры текущего блока
                for (int i = 0; i < count; i++)
                {
                    cur_w             = blocks_sizes[i, 0];
                    cur_h             = blocks_sizes[i, 1];
                    Tile[,] new_block = new Tile[cur_w, cur_h];
                    scn.blocks.Add(new_block); // список блоков в виде номеров тайлов
                    inStream.Read(block, 0, cur_w * cur_h * 4);
                    flag = true;

                    for (int j2 = 0; j2 < cur_h; j2++)     // y
                    {
                        for (int j1 = 0; j1 < cur_w; j1++) // x
                        {
                            tmp_i2 = Utils.b2i(block, j2 * 4 * cur_w + j1 * 4, 4);
                            if (tmp_i2 != -1)
                            {
                                new_block[j1, j2] = scn.spriteSet[tmp_i2]; //!!!!!
                                flag = false;
                            }
                            else
                            {
                                new_block[j1, j2] = Gl.blocks_window.blank_Tile;
                            }
                        }
                    }

                    //if (i < 7)
                    if (!flag)
                    {
                        Gl.blocks_window.AddBlock(new_block);
                    }
                }
            }

            System.Windows.MessageBox.Show("Done!", "Import blocks", MessageBoxButton.OK, MessageBoxImage.Information);
        }