예제 #1
0
        private void SkillsForm_Load(object sender, EventArgs e)
        {
            Settings.Default.VerifySetoaLocation();

            using (var archive = DataArchive.Open(Settings.Default.SetoaLocation))
                using (var g = Graphics.FromImage(_skillTilesImage))
                {
                    var epf = new EPFFile(archive.GetEntry(_fileName));
                    var pal = new Palette(archive.GetEntry("gui06.pal"));

                    for (int col = 0; col < columns; ++col)
                    {
                        for (int row = 0; row < rows; ++row)
                        {
                            int frameIndex = columns * row + col;
                            if (frameIndex < epf.Frames.Count)
                            {
                                var frame      = epf.Frames[frameIndex];
                                var frameImage = frame.Render(pal);
                                g.DrawImage(frameImage, col * tileWidth + frame.Left, row * tileHeight + frame.Top);
                            }
                        }
                    }
                }
        }
예제 #2
0
        private void UpdateEffectImage()
        {
            animationTimer.Stop();
            Settings.Default.VerifyRohLocation();
            animationTimer.Start();

            using (var archive = DataArchive.Open(Settings.Default.RohLocation))
            {
                if (_selectedFileName.EndsWith(".epf", StringComparison.CurrentCultureIgnoreCase))
                {
                    var epf = new EPFFile(archive.GetEntry(_selectedFileName));

                    if (_animationFrame >= epf.Frames.Count)
                    {
                        _animationFrame = 0;
                    }

                    var frame = epf.Frames[_animationFrame];

                    int paletteNumber = _paletteTable.GetPaletteNumber(_selectedFileNumber);

                    bool useBlending = false;

                    if (paletteNumber >= 1000)
                    {
                        paletteNumber -= 1000;
                        useBlending    = true;
                    }

                    var palette = new Palette(archive.GetEntry($"eff{paletteNumber:d3}.pal"));

                    _effectImage = new Bitmap(epf.Width, epf.Height);

                    using (var g = Graphics.FromImage(_effectImage))
                    {
                        if (useBlending)
                        {
                            // temporary solution
                            g.Clear(Color.Black);
                        }
                        g.DrawImage(frame.Render(palette), frame.Left, frame.Top);
                    }
                }
                else
                {
                    var efa = new EFAFile(archive.GetEntry(_selectedFileName));

                    if (_animationFrame >= efa.Frames.Count)
                    {
                        _animationFrame = 0;
                    }

                    var frame = efa.Frames[_animationFrame];

                    _effectImage = frame.Render();
                }
            }

            effectPanel.Refresh();
        }
예제 #3
0
        private void PlaySoundAsync(object parameter)
        {
            string fileName = (string)parameter;

            using (var archive = DataArchive.Open(Settings.Default.LegendLocation))
                using (var stream = archive.GetEntry(fileName).Open())
                {
                    stream.Position = 0;
                    using (var reader = new Mp3FileReader(stream))
                        using (var conversionStream = WaveFormatConversionStream.CreatePcmStream(reader))
                            using (var provider = new BlockAlignReductionStream(conversionStream))
                                using (var waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
                                {
                                    waveOut.Init(provider);
                                    waveOut.Play();

                                    while (waveOut.PlaybackState == PlaybackState.Playing)
                                    {
                                        Thread.Sleep(100);
                                    }
                                }
                }

            TogglePlayButtonEnabled(true);
        }
예제 #4
0
        private void UpdateMonsterTileImage()
        {
            Settings.Default.VerifyHadesLocation();

            using (var archive = DataArchive.Open(Settings.Default.HadesLocation))
            {
                var mpf = new MPFFile(archive.GetEntry(_selectedFileName));
                var pal = new Palette(archive.GetEntry($"mns{mpf.PaletteNumber:d3}.pal"));

                int frontStopFrameIndex;

                int stopFrameCount = Math.Max(mpf.StopFrameCount, mpf.StopMotionFrameCount);

                if (mpf.WalkFrameIndex == 0 && mpf.WalkFrameCount > stopFrameCount)
                {
                    frontStopFrameIndex = mpf.WalkFrameCount;
                }
                else
                {
                    frontStopFrameIndex = stopFrameCount;
                }

                if (frontStopFrameIndex >= mpf.Frames.Count)
                {
                    frontStopFrameIndex = 0;
                }

                if (_animationFrame >= mpf.StopFrameCount || (frontStopFrameIndex + _animationFrame) >= mpf.Frames.Count)
                {
                    _animationFrame = 0;
                }

                var frame = mpf.Frames[frontStopFrameIndex + _animationFrame];

                _monsterTileImage = new Bitmap(mpf.Width, mpf.Height);

                using (var g = Graphics.FromImage(_monsterTileImage))
                {
                    g.DrawImage(frame.Render(pal), frame.Left, frame.Top);
                }
            }

            monsterTilePanel.Refresh();
        }
예제 #5
0
        private void MonstersForm_Load(object sender, EventArgs e)
        {
            Settings.Default.VerifyHadesLocation();

            using (var archive = DataArchive.Open(Settings.Default.HadesLocation))
            {
                var entries = from entry in archive.Entries
                              where EntryIsMonster(entry)
                              orderby int.Parse(entry.EntryName.Substring(3, 3))
                              select entry.EntryName;

                monsterFilesListBox.Items.AddRange(entries.ToArray());
            }

            if (monsterFilesListBox.Items.Count > 0)
            {
                monsterFilesListBox.SelectedIndex = 0;
            }
        }
예제 #6
0
        private void EffectsForm_Load(object sender, EventArgs e)
        {
            Settings.Default.VerifyRohLocation();

            using (var archive = DataArchive.Open(Settings.Default.RohLocation))
            {
                var entries = from entry in archive.Entries
                              where EntryIsEffect(entry)
                              orderby int.Parse(entry.EntryName.Substring(4, 3))
                              select entry.EntryName;

                effectFilesListBox.Items.AddRange(entries.ToArray());
                _paletteTable.AddTable(archive.GetEntry("effpal.tbl"));
            }

            if (effectFilesListBox.Items.Count > 0)
            {
                effectFilesListBox.SelectedIndex = 0;
            }
        }
예제 #7
0
        private void SoundsForm_Load(object sender, EventArgs e)
        {
            Settings.Default.VerifyLegendLocation();

            using (var archive = DataArchive.Open(Settings.Default.LegendLocation))
            {
                int soundNumber;
                var entries = from entry in archive.Entries
                              let name                     = Path.GetFileNameWithoutExtension(entry.EntryName)
                                                   let ext = Path.GetExtension(entry.EntryName)
                                                             where ext.Equals(".mp3", StringComparison.CurrentCultureIgnoreCase) && int.TryParse(name, out soundNumber)
                                                             orderby int.Parse(name)
                                                             select entry.EntryName;

                soundFilesListBox.Items.AddRange(entries.ToArray());
            }

            if (soundFilesListBox.Items.Count > 0)
            {
                soundFilesListBox.SelectedIndex = 0;
            }
        }
예제 #8
0
        private void UpdateItemTilesImage()
        {
            Settings.Default.VerifyLegendLocation();

            using (var archive = DataArchive.Open(Settings.Default.LegendLocation))
                using (var g = Graphics.FromImage(_itemTilesImage))
                {
                    g.Clear(itemTilesPanel.BackColor);

                    var epf = new EPFFile(archive.GetEntry(_selectedFileName));

                    for (int col = 0; col < columns; ++col)
                    {
                        for (int row = 0; row < rows; ++row)
                        {
                            int frameIndex = columns * row + col;

                            if (frameIndex < epf.Frames.Count)
                            {
                                var frame = epf.Frames[frameIndex];

                                int tileNumber    = (_selectedFileNumber - 1) * 266 + frameIndex + 1;
                                int paletteNumber = _paletteTable.GetPaletteNumber(tileNumber);

                                var palette = new Palette(archive.GetEntry($"item{paletteNumber:d3}.pal"));

                                var frameImage = frame.Render(palette);

                                g.DrawImage(frameImage, col * tileWidth + frame.Left, row * tileHeight + frame.Top);
                            }
                        }
                    }
                }

            itemTilesPanel.Refresh();
        }
예제 #9
0
        private void UpdateMotionTilesImage()
        {
            string archiveFileName, idleFileName, motionFileName;

            if (genderListBox.SelectedIndex == 0)
            {
                animationTimer.Stop();
                Settings.Default.VerifyKhanmadLocation();
                animationTimer.Start();
                archiveFileName = Settings.Default.KhanmadLocation;

                idleFileName = "mb00101.epf";

                if (_selectedMotion.Number == 1)
                {
                    motionFileName = "mb00102.epf";
                }
                else if (_selectedMotion.Number == 6)
                {
                    motionFileName = "mb00103.epf";
                }
                else
                {
                    motionFileName = $"mb001{(char)('a' + _selectedMotion.FileNumber)}.epf";
                }
            }
            else
            {
                animationTimer.Stop();
                Settings.Default.VerifyKhanwadLocation();
                animationTimer.Start();
                archiveFileName = Settings.Default.KhanwadLocation;

                idleFileName = "wb00101.epf";

                if (_selectedMotion.Number == 1)
                {
                    motionFileName = "wb00102.epf";
                }
                else if (_selectedMotion.Number == 6)
                {
                    motionFileName = "wb00103.epf";
                }
                else
                {
                    motionFileName = $"wb001{(char)('a' + _selectedMotion.FileNumber)}.epf";
                }
            }

            animationTimer.Stop();
            Settings.Default.VerifyKhanpalLocation();
            animationTimer.Start();

            using (var epfArchive = DataArchive.Open(archiveFileName))
                using (var palArchive = DataArchive.Open(Settings.Default.KhanpalLocation))
                {
                    var idleEpf   = new EPFFile(epfArchive.GetEntry(idleFileName));
                    var motionEpf = new EPFFile(epfArchive.GetEntry(motionFileName));
                    var pal       = new Palette(palArchive.GetEntry("palb000.pal"));

                    EPFFrame frame;

                    if (_animationFrame >= _selectedMotion.FrameCount)
                    {
                        _animationFrame = -1;
                    }

                    if (_animationFrame == -1)
                    {
                        frame = idleEpf.Frames[5];
                    }
                    else
                    {
                        frame = motionEpf.Frames[_selectedMotion.StartIndex + _selectedMotion.FrameCount + _animationFrame];
                    }

                    using (var g = Graphics.FromImage(_motionTilesImage))
                    {
                        g.Clear(motionTilesPanel.BackColor);
                        g.DrawImage(frame.Render(pal), frame.Left, frame.Top);
                    }
                }

            motionTilesPanel.Refresh();
        }