Ejemplo n.º 1
0
 private void frmPortraitEditor_Load(object sender, EventArgs e)
 {
     // Init palettes
     BaseSpritePalettes = Palette.GetBaseSpritePalettes(WorkingDirectory);
     // Init animation pictureboxes
     picCharactersBG.Init(dlgOpen, this);
     picCharactersFG.Init(dlgOpen, this);
     picCharactersBG.PostOnClick = picCharactersFG.PostOnClick = UpdateCharacterPreview;
     picGenericsBG.Init(dlgOpen, this);
     picGenericsFG.Init(dlgOpen, this);
     picGenericsBG.PostOnClick = picGenericsFG.PostOnClick = UpdateGenericPreview;
     // Init base
     lstCharacters.Init(this, () => new PortraitData(), CharacterDataFromUI, CharacterDataToUI, "Portraits");
     lstGenerics.Init(this, () => new GenericPortraitData(), GenericDataFromUI, GenericDataToUI, "GenericPortraits");
     pleGenericsPossibleBGPalettes.Init(null, () => new Palette(), () => new UserControls.PalettePanel(),
                                        (plt) => { plt.Init(null); }, false);
     pltCharactersBGPalette.Init(this, (p) =>
     {
         picCharactersBG.Palette = p;
         UpdateCharacterPreview();
     });
     fgpCharactersFGPalette.Init(this, BaseSpritePalettes, (p) =>
     {
         picCharactersFG.Palette = p;
         UpdateCharacterPreview();
     });
     fgpCharacterAccent.Init(this, BaseSpritePalettes);
     Dirty = false;
     this.ApplyPreferences();
     // Misc
     cmbVoiceType.SelectedIndex = 0;
     dlgOpen.Filter             = "Image files|*.gif;*.png";
     if (WorkingDirectory.CheckFileExist("GenericPortraitsGlobalData.json"))
     {
         GlobalData = WorkingDirectory.LoadFile("GenericPortraitsGlobalData", "", ".json").JsonToObject <GenericPortraitsGlobalData>();
         pleGenericsPossibleBGPalettes.Datas = GlobalData.GenericPossibleBackgroundColors;
     }
     // Set dirty
     txtGenericsTags.TextChanged       += DirtyFunc;
     nudPitch.ValueChanged             += DirtyFunc;
     cmbVoiceType.SelectedIndexChanged += DirtyFunc;
     Dirty = false;
     // Load empty
     btnNew_Click(sender, e);
 }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Find directory
            CurrentDirectory      = new FilesController();
            CurrentDirectory.Path = WorkingDirectory.Path;
            CurrentDirectory.CreateDirectory("Maps", true);
            // Load levels
            CurrentDirectory.DefultFileFormat = ".txt";
            flbFiles.Directory        = CurrentDirectory;
            flbFiles.TopMostDirectory = CurrentDirectory.Path;
            flbFiles.OnFileSelected   = LoadFile;
            flbFiles.ShowDirectories  = true;
            flbFiles.UpdateList();
            // Load tiles
            Tilesets = WorkingDirectory.LoadFile("Tilesets", "", ".json").JsonToObject <List <TilesetData> >();
            if (Tilesets.Count < 1)
            {
                Close();
                MessageBox.Show("You must have at least 1 tileset!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            cmbTileSets.Items.AddRange(Tilesets.ConvertAll(a => a.Name).ToArray());
            cmbTileSets.SelectedIndex = 0;
            SetTileSet(Tilesets[0]);
            // Load palettes
            CachedSpritePalettes   = Palette.GetLevelSpritePalettes(WorkingDirectory);
            nudLevelNumber.Maximum = CachedSpritePalettes.Count - 1;
            // End load files
            // Generate UI
            UpdatePreview();
            Tiles = new MapTile[Size.X, Size.Y];
            int i;

            for (i = 0; i < Tiles.GetLength(0); i++)
            {
                for (int j = 0; j < Tiles.GetLength(1); j++)
                {
                    Tiles[i, j]     = new MapTile();
                    Tiles[i, j].Pos = new Point(i, j);
                }
            }
            Renderers = new PictureBox[Size.X, Size.Y];
            for (i = 0; i < Size.X; i++)
            {
                for (int j = 0; j < Size.Y; j++)
                {
                    PictureBox pictureBox = new PictureBox();
                    pictureBox.Width      = 16;
                    pictureBox.Height     = 16;
                    pictureBox.Left       = 16 * i;
                    pictureBox.Top        = 16 * j;
                    pictureBox.MouseMove += TileMouseMove;
                    pictureBox.MouseDown += TileMouseMove;
                    pictureBox.Capture    = false;
                    //pictureBox.BackgroundImageLayout = ImageLayout.Stretch; // Why was this even here?
                    pnlRenderer.Controls.Add(pictureBox);
                    Renderers[i, j] = pictureBox;
                }
            }
            Render();
            cmbAIType.SelectedIndex   = 0;
            cmbUnitTeam.SelectedIndex = 0;
            // Set dirty
            rdbDefeatBoss.CheckedChanged += DirtyFunc;
            rdbEscape.CheckedChanged     += DirtyFunc;
            rdbRout.CheckedChanged       += DirtyFunc;
            rdbSurvive.CheckedChanged    += DirtyFunc;
            txtLevelName.TextChanged     += DirtyFunc;
            nudLevelNumber.ValueChanged  += DirtyFunc;
            // Init stuff
            melMapEvents.Init(this, () => new MapEventData(), () => new UserControls.MapEventPanel(), (a) => a.Init(this, DataDirectory), false);
            this.ApplyPreferences();
            // Fix zoom mode - I don't know why it has so many bugs
            for (i = 0; i < Size.X; i++)
            {
                for (int j = 0; j < Size.Y; j++)
                {
                    Renderers[i, j].Height = Renderers[i, j].Width;
                    Renderers[i, j].Top    = Renderers[i, j].Height * j;
                }
            }
            pnlRenderer.Height = Renderers[0, 0].Height * Size.Y;
            picPreview.Top     = -1;
            picPreview.Height  = picPreview.Width;
            SetTileSet(Tilesets[0]);
        }