private void buttonImport_Click( object sender, EventArgs e )
        {
            OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
            dialog.Filter = "Picross Puzzle (*.picross)|*.picross|Any File|*.*";
            DialogResult result = dialog.ShowDialog();
            if ( result == DialogResult.OK ) {
                var infile = System.IO.File.ReadAllBytes( dialog.FileName );

                if ( IsSelectedPuzzleOriginalPuzzle ) {
                    var puzzle = new OriginalPuzzle( infile, 0x0 );
                    puzzle.Type = 0x03;
                    Save.OriginalPuzzles[comboBoxPuzzleSlot.SelectedIndex - 100] = puzzle;
                    comboBoxPuzzleSlot.Items[comboBoxPuzzleSlot.SelectedIndex] = puzzle;
                    PopulateGuiWithPuzzle( puzzle );
                } else {
                    var puzzle = new ClassicPuzzle( infile, 0x0 );
                    puzzle.Type = 0x02;
                    Save.ClassicPuzzles[comboBoxPuzzleSlot.SelectedIndex] = puzzle;
                    comboBoxPuzzleSlot.Items[comboBoxPuzzleSlot.SelectedIndex] = puzzle;
                    PopulateGuiWithPuzzle( puzzle );
                }

                WriteGuiPuzzleDataToSave( sender, e );
            }
        }
示例#2
0
        void PopulateGuiWithPuzzle(ClassicPuzzle puzzle)
        {
            PuzzleLoaded = false;

            try {
                comboBoxPuzzleDimensions.SelectedIndex = (puzzle.Width / 5) - 1;                   // there's only five valid dimensions, this should always get the right one
            } catch (ArgumentOutOfRangeException) {
                comboBoxPuzzleDimensions.SelectedIndex = 0;
            }

            checkBoxFreeMode.Checked = puzzle.Mode == 0x02;
            checkBoxCleared.Checked  = (puzzle.Unknown2 & 0x01) == 0x00;
            textBoxCleartime.Text    = puzzle.ClearTime.ToString();
            textBoxName.Text         = puzzle.PuzzleName.Trim('\0');
            textBoxPack.Text         = puzzle.PackName.Trim('\0');

            try {
                comboBoxPackLetter.SelectedIndex = puzzle.PackLetter;
            } catch (ArgumentOutOfRangeException) {
                comboBoxPackLetter.SelectedIndex = 0;
            }
            try {
                comboBoxPackNumber.SelectedIndex = puzzle.PackNumber;
            } catch (ArgumentOutOfRangeException) {
                comboBoxPackNumber.SelectedIndex = 0;
            }

            PuzzleLoaded = true;
        }
示例#3
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();

            dialog.Filter = "Picross Puzzle (*.picross)|*.picross|Any File|*.*";
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                var infile = System.IO.File.ReadAllBytes(dialog.FileName);

                if (IsSelectedPuzzleOriginalPuzzle)
                {
                    var puzzle = new OriginalPuzzle(infile, 0x0);
                    puzzle.Type = 0x03;
                    Save.OriginalPuzzles[comboBoxPuzzleSlot.SelectedIndex - 100] = puzzle;
                    comboBoxPuzzleSlot.Items[comboBoxPuzzleSlot.SelectedIndex]   = puzzle;
                    PopulateGuiWithPuzzle(puzzle);
                }
                else
                {
                    var puzzle = new ClassicPuzzle(infile, 0x0);
                    puzzle.Type = 0x02;
                    Save.ClassicPuzzles[comboBoxPuzzleSlot.SelectedIndex]      = puzzle;
                    comboBoxPuzzleSlot.Items[comboBoxPuzzleSlot.SelectedIndex] = puzzle;
                    PopulateGuiWithPuzzle(puzzle);
                }

                WriteGuiPuzzleDataToSave(sender, e);
            }
        }
        void PopulateGuiWithPuzzle( ClassicPuzzle puzzle )
        {
            PuzzleLoaded = false;

            try {
                comboBoxPuzzleDimensions.SelectedIndex = ( puzzle.Width / 5 ) - 1; // there's only five valid dimensions, this should always get the right one
            } catch ( ArgumentOutOfRangeException ) {
                comboBoxPuzzleDimensions.SelectedIndex = 0;
            }

            checkBoxFreeMode.Checked = puzzle.Mode == 0x02;
            checkBoxCleared.Checked = ( puzzle.Unknown2 & 0x01 ) == 0x00;
            textBoxCleartime.Text = puzzle.ClearTime.ToString();
            textBoxName.Text = puzzle.PuzzleName.Trim( '\0' );
            textBoxPack.Text = puzzle.PackName.Trim( '\0' );

            try {
                comboBoxPackLetter.SelectedIndex = puzzle.PackLetter;
            } catch ( ArgumentOutOfRangeException ) {
                comboBoxPackLetter.SelectedIndex = 0;
            }
            try {
                comboBoxPackNumber.SelectedIndex = puzzle.PackNumber;
            } catch ( ArgumentOutOfRangeException ) {
                comboBoxPackNumber.SelectedIndex = 0;
            }

            PuzzleLoaded = true;
        }
示例#5
0
        private List <ClassicPuzzle> LoadPuzzles(uint mappingTableOffset, uint puzzleOffset, uint puzzleSize, bool puzzlesContainPictures)
        {
            HashSet <uint>       mappedPuzzles = new HashSet <uint>();
            List <ClassicPuzzle> puzzleList    = new List <ClassicPuzzle>();

            // read all existing puzzles in ingame order
            for (uint i = 0; i < 100; ++i)
            {
                uint index = File[mappingTableOffset + i];
                if (index > 0x63)
                {
                    continue;
                }

                ClassicPuzzle puzzle;
                if (puzzlesContainPictures)
                {
                    puzzle = new OriginalPuzzle(File, puzzleOffset + index * puzzleSize);
                }
                else
                {
                    puzzle = new ClassicPuzzle(File, puzzleOffset + index * puzzleSize);
                }
                puzzleList.Add(puzzle);
                mappedPuzzles.Add(index);
            }

            // find deleted puzzles, add those too
            for (uint i = 0; i < 100; ++i)
            {
                if (!mappedPuzzles.Contains(i))
                {
                    ClassicPuzzle puzzle;
                    if (puzzlesContainPictures)
                    {
                        puzzle = new OriginalPuzzle(File, puzzleOffset + i * puzzleSize);
                    }
                    else
                    {
                        puzzle = new ClassicPuzzle(File, puzzleOffset + i * puzzleSize);
                    }
                    puzzle.Deleted = true;
                    puzzleList.Add(puzzle);
                }
            }

            // and fill the rest with garbage if needed
            while (puzzleList.Count < 100)
            {
                if (puzzlesContainPictures)
                {
                    puzzleList.Add(new OriginalPuzzle());
                }
                else
                {
                    puzzleList.Add(new ClassicPuzzle());
                }
            }

            // and cut off if somehow more than 100 were added
            if (puzzleList.Count > 100)
            {
                puzzleList.RemoveRange(100, puzzleList.Count - 100);
            }

            for (int i = 0; i < puzzleList.Count; ++i)
            {
                puzzleList[i].IndexForGui = i + 1;
            }

            return(puzzleList);
        }
示例#6
0
        private List<ClassicPuzzle> LoadPuzzles( uint mappingTableOffset, uint puzzleOffset, uint puzzleSize, bool puzzlesContainPictures )
        {
            HashSet<uint> mappedPuzzles = new HashSet<uint>();
            List<ClassicPuzzle> puzzleList = new List<ClassicPuzzle>();

            // read all existing puzzles in ingame order
            for ( uint i = 0; i < 100; ++i ) {
                uint index = File[mappingTableOffset + i];
                if ( index > 0x63 ) {
                    continue;
                }

                ClassicPuzzle puzzle;
                if ( puzzlesContainPictures ) {
                    puzzle = new OriginalPuzzle( File, puzzleOffset + index * puzzleSize );
                } else {
                    puzzle = new ClassicPuzzle( File, puzzleOffset + index * puzzleSize );
                }
                puzzleList.Add( puzzle );
                mappedPuzzles.Add( index );
            }

            // find deleted puzzles, add those too
            for ( uint i = 0; i < 100; ++i ) {
                if ( !mappedPuzzles.Contains( i ) ) {
                    ClassicPuzzle puzzle;
                    if ( puzzlesContainPictures ) {
                        puzzle = new OriginalPuzzle( File, puzzleOffset + i * puzzleSize );
                    } else {
                        puzzle = new ClassicPuzzle( File, puzzleOffset + i * puzzleSize );
                    }
                    puzzle.Deleted = true;
                    puzzleList.Add( puzzle );
                }
            }

            // and fill the rest with garbage if needed
            while ( puzzleList.Count < 100 ) {
                if ( puzzlesContainPictures ) {
                    puzzleList.Add( new OriginalPuzzle() );
                } else {
                    puzzleList.Add( new ClassicPuzzle() );
                }
            }

            // and cut off if somehow more than 100 were added
            if ( puzzleList.Count > 100 ) {
                puzzleList.RemoveRange( 100, puzzleList.Count - 100 );
            }

            for ( int i = 0; i < puzzleList.Count; ++i ) {
                puzzleList[i].IndexForGui = i + 1;
            }

            return puzzleList;
        }