Esempio n. 1
0
 public void InitScreens(FNTRenderer fl, FNTRenderer fh)
 {
     bl = new Briefing(false, descentGame, fl, FindFile);
     bh = new Briefing(true, descentGame, fh, FindFile);
     bl.BriefingEnded += OnBriefingEnded;
     bh.BriefingEnded += OnBriefingEnded;
 }
Esempio n. 2
0
 public Briefing(bool highRes, int descentGame, FNTRenderer font, FindFile findFile)
 {
     this.findFile    = findFile;
     this.descentGame = descentGame;
     this.highRes     = highRes;
     backgroundName   = null;
     backgroundCache  = null;
     fullText         = text = null;
     if (highRes)
     {
         screen = new Bitmap(640, 480, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
     }
     else
     {
         screen = new Bitmap(320, 200, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
     }
     flipped       = new Bitmap(screen);
     graphics      = Graphics.FromImage(screen);
     flipper       = Graphics.FromImage(flipped);
     frame         = new Rectangle(new Point(0, 0), screen.Size);
     briefingColor = 0;
     this.font     = font;
     playing       = false;
     screens       = new List <BriefingScreen>();
     screens.AddRange(GetBriefingScreens(descentGame, highRes));
     charDelay = descentGame == 2 ? 20 : 28;
 }
Esempio n. 3
0
        private void bannerSaveFileDialog_FileOk(object sender, CancelEventArgs e)
        {
            byte[] fntData = findFile(fontTextBox.Text);
            if (fntData == null)
            {
                MessageBox.Show(this, "Cannot find the given font", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string text = textTextBox.Text;

            LibDescent.Data.Font font  = MainForm.LoadFont(new MemoryStream(fntData));
            FNTRenderer          frend = new FNTRenderer(font);
            Bitmap result;

            if (testing)
            {
                int cw = Math.Max(8, font.GetCharWidth('\0')) * 2;
                result = new Bitmap(cw * 16, (font.Height + 3) * 16);
                Graphics gdi = Graphics.FromImage(result);
                int      x = 0, lx, ly, lw;
                Pen      pen = new Pen(Color.Red);
                for (int c = 0; c < 256; ++c)
                {
                    lx = (c % 16) * cw;
                    ly = (font.Height + 3) * (c / 16);
                    x  = lx;
                    frend.Reset();
                    frend.DrawCharacterRaw(result, (char)c, Color.Green, ref x, ly);

                    x   = lx;
                    ly += font.Height;
                    lw  = font.GetCharWidth((char)c);
                    gdi.DrawLine(pen, lx, ly, lx + lw, ly);
                }
            }
            else
            {
                result = new Bitmap(font.MeasureWidth(text), font.Height);
                int x = 0;
                foreach (char c in text)
                {
                    frend.DrawCharacterRaw(result, c, Color.Green, ref x, 0);
                }
            }
            result.Save(bannerSaveFileDialog.FileName);
        }
Esempio n. 4
0
        private void LoadBaseHog(string filename)
        {
            editor.SetDescentGame(0);
            betterEditor?.SetDescentGame(0);

            baseHogLabel.Text = "No Descent HOG file specified";
            baseHog           = null;
            try
            {
                baseHog = new HOGFile(baseHogFile = filename);
            }
            catch (ArgumentException aex)
            {
                MessageBox.Show(this, aex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            baseHogLabel.Text = "No Descent HOG file specified";
            if (!baseHog.ContainsFile("descent.txb") || !baseHog.ContainsFile("end01.pcx"))
            {
                MessageBox.Show(this, "This is not a valid registered Descent 1 or Descent 2 main HOG", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                baseHog = null;
                return;
            }

            if (baseHog.ContainsFile("neptun01.pcx"))
            {
                descentGame       = 1;
                baseHogLabel.Text = "Main HOG: Descent 1";
            }
            else if (baseHog.ContainsFile("d2levf-s.rl2"))
            {
                descentGame       = 2;
                baseHogLabel.Text = "Main HOG: Descent 2";
            }
            else
            {
                MessageBox.Show(this, "This is not a valid registered Descent 1 or Descent 2 main HOG", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                baseHog = null;
                return;
            }

            byte[] font3_1 = baseHog.GetLumpData("FONT3-1.FNT");
            if (font3_1 == null)
            {
                MessageBox.Show(this, "FONT3-1.FNT not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                baseHog = null;
                return;
            }

            FNTRenderer gamefontL, gamefontH = null;

            gamefontL = new FNTRenderer(LoadFont(new MemoryStream(font3_1)));

            if (descentGame == 1)
            {
                gamefontH = new FNTRendererUpScale(gamefontL.font);
            }
            else if (descentGame == 2)
            {
                font3_1 = baseHog.GetLumpData("FONT3-1H.FNT");
                if (font3_1 == null)
                {
                    MessageBox.Show(this, "FONT3-1H.FNT not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    baseHog = null;
                    return;
                }
                gamefontH = new FNTRenderer(LoadFont(new MemoryStream(font3_1)));
            }

            InitScreens(gamefontL, gamefontH);
            lowres.Refresh();
            highres.Refresh();
            editor.SetDescentGame(descentGame);
            betterEditor?.SetDescentGame(descentGame);
            Properties.Settings.Default.baseHogPath = filename;
            Properties.Settings.Default.Save();
        }