コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            String fontFile = System.IO.Path.GetTempFileName();

            NFTR.Write(font, fontFile);
            pluginHost.ChangeFile(font.id, fontFile);
        }
コード例 #2
0
        private void btnInversePalette_Click(object sender, EventArgs e)
        {
            inversePalette = !inversePalette;
            this.palette   = NFTR.CalculatePalette(this.font.plgc.depth, inversePalette);

            // Update
            picFont.Image = NFTR.Get_Chars(font, MAX_WIDTH, palette, ZOOM);
            txtBox_TextChanged(txtBox, null);
        }
コード例 #3
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            CharControl charControl = (CharControl)panelCharEdit.Controls[0];

            font.hdwc.info[comboChar.SelectedIndex]  = charControl.TileInfo;
            font.plgc.tiles[comboChar.SelectedIndex] = charControl.Tiles;
            picFont.Image = NFTR.Get_Chars(font, MAX_WIDTH, palette, ZOOM);
            txtBox_TextChanged(txtBox, null);
        }
コード例 #4
0
        private void btnToImage_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog o = new SaveFileDialog())
            {
                o.Filter = "Portable Network Graphic (*.png)|*.png";

                if (o.ShowDialog() == DialogResult.OK)
                {
                    NFTR.ToImage(this.font, palette).Save(o.FileName);
                }
            }
        }
コード例 #5
0
        private void btnExportInfo_Click(object sender, EventArgs e)
        {
            SaveFileDialog o = new SaveFileDialog();

            o.DefaultExt = ".xml";
            if (o.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            NFTR.ExportInfo(o.FileName, charTile, font);
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: calvarado194/layton-rando
        public System.Windows.Forms.Control Show_Info(sFile file)
        {
            System.IO.BinaryReader br = new System.IO.BinaryReader(System.IO.File.OpenRead(file.path));
            string ext = new String(br.ReadChars(4));

            br.Close();

            if (ext == "NFTR" || ext == "RTFN")
            {
                return(new FontControl(pluginHost, NFTR.Read(file, pluginHost.Get_Language())));
            }

            return(new System.Windows.Forms.Control());
        }
コード例 #7
0
        private void btnFromImage_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog o = new OpenFileDialog())
            {
                o.Filter = "Portable Network Graphic (*.png)|*.png";

                if (o.ShowDialog() == DialogResult.OK)
                {
                    NFTR.FromImage((Bitmap)Image.FromFile(o.FileName), this.font, this.palette);
                }
            }

            // Update
            picFont.Image = NFTR.Get_Chars(font, MAX_WIDTH, palette, ZOOM);
            txtBox_TextChanged(txtBox, null);
        }
コード例 #8
0
        public void Draw_Char()
        {
            Bitmap image = NFTR.Get_Char(tiles, depth, width, height, rotateMode, palette, 10);
            // Draw the grid
            Graphics graphic = Graphics.FromImage(image);

            for (int h = 0; h < height * 10; h += 10)
            {
                graphic.DrawLine(Pens.Red, 0, h, width * 10, h);
            }
            for (int w = 0; w < width * 10; w += 10)
            {
                graphic.DrawLine(Pens.Red, w, 0, w, height * 10);
            }

            picFont.Image = image;
        }
コード例 #9
0
        private void btnRemoveChar_Click(object sender, EventArgs e)
        {
            int index = comboChar.SelectedIndex;

            font.hdwc.last_code--;
            font.hdwc.info.RemoveAt(index);

            List <byte[]> tiles = new List <byte[]>();

            tiles.AddRange(font.plgc.tiles);
            tiles.RemoveAt(index);
            font.plgc.tiles = tiles.ToArray();

            picFont.Image = NFTR.Get_Chars(font, MAX_WIDTH, palette, ZOOM);
            comboChar.Items.RemoveAt(index);
            comboChar.SelectedIndex = index - 1;
        }
コード例 #10
0
        private void btnPalette_Click(object sender, EventArgs e)
        {
            if (pluginHost.Get_Palette().Loaded)
            {
                palette = pluginHost.Get_Palette().Palette[0];
            }

            int depth = Convert.ToByte(new String('1', font.plgc.depth), 2);

            Color[] palette2 = new System.Drawing.Color[depth + 1];
            Array.Copy(palette, 0, palette2, 0, palette2.Length);
            palette2 = palette2.Reverse().ToArray();
            palette  = palette2;

            picFont.Image = NFTR.Get_Chars(font, MAX_WIDTH, palette);
            txtBox_TextChanged(txtBox, null);
        }
コード例 #11
0
        private void btnAddChar_Click(object sender, EventArgs e)
        {
            font.hdwc.last_code++;
            sNFTR.HDWC.Info newInfo = new sNFTR.HDWC.Info();
            newInfo.pixel_start  = 0;
            newInfo.pixel_width  = 9;
            newInfo.pixel_length = 9;
            font.hdwc.info.Add(newInfo);

            List <byte[]> tiles = new List <byte[]>();

            tiles.AddRange(font.plgc.tiles);
            Byte[] newChar = new byte[8 * font.plgc.tile_length];
            tiles.Add(newChar);
            font.plgc.tiles = tiles.ToArray();

            picFont.Image = NFTR.Get_Chars(font, MAX_WIDTH, palette, ZOOM);
            comboChar.Items.Add("Char" + comboChar.Items.Count.ToString());
            comboChar.SelectedIndex = comboChar.Items.Count - 1;
        }
コード例 #12
0
ファイル: FontControl.cs プロジェクト: chyyran/tinke
        public FontControl(IPluginHost pluginHost, sNFTR font)
        {
            InitializeComponent();

            this.pluginHost = pluginHost;
            this.font       = font;
            ReadLanguage();
            this.palette = NFTR.CalculatePalette(font.plgc.depth, inversePalette);
            for (int i = 0; i < font.plgc.tiles.Length; i++)
            {
                comboChar.Items.Add("Char " + i.ToString());
            }

            picFont.Image = NFTR.Get_Chars(font, MAX_WIDTH, palette, ZOOM);

            Fill_CharTile();

            comboChar.SelectedIndex     = 0;
            comboEncoding.SelectedIndex = font.fnif.encoding;
        }
コード例 #13
0
        private void txtBox_TextChanged(object sender, EventArgs e)
        {
            Bitmap   image   = new Bitmap(picText.Width, picText.Height);
            Graphics graphic = Graphics.FromImage(image);

            graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            int width  = 0;
            int height = 0;

            for (int i = 0; i < txtBox.Text.Length; i++)
            {
                if (txtBox.Text[i] == '\n')
                {
                    width   = 0;
                    height += font.plgc.tile_height;
                    continue;
                }

                byte[] codes = new byte[1];
                if (comboEncoding.SelectedIndex == 2)
                {
                    codes = Encoding.GetEncoding("shift_jis").GetBytes(new char[] { txtBox.Text[i] }).Reverse().ToArray();
                }
                else if (comboEncoding.SelectedIndex == 1)
                {
                    codes = Encoding.GetEncoding("utf-16").GetBytes(new char[] { txtBox.Text[i] });
                }
                else if (comboEncoding.SelectedIndex == 0)
                {
                    codes = Encoding.UTF8.GetBytes(new char[] { txtBox.Text[i] });
                }
                else if (comboEncoding.SelectedIndex == 3)
                {
                    codes = Encoding.GetEncoding(1252).GetBytes(new char[] { txtBox.Text[i] });
                }

                int charCode = (codes.Length == 2 ? BitConverter.ToUInt16(codes, 0) : codes[0]);

                int tileCode;
                if (!charTile.TryGetValue(charCode, out tileCode))
                {
                    width += font.plgc.tile_width;
                    continue;
                }

                width += font.hdwc.info[tileCode].pixel_start;
                Bitmap charImage = NFTR.Get_Char(font, tileCode, palette);
                charImage.MakeTransparent(this.palette[0]);
                graphic.DrawImageUnscaled(charImage, width, height);
                width += font.hdwc.info[tileCode].pixel_length - font.hdwc.info[tileCode].pixel_start;

                if (width + font.plgc.tile_width > image.Width)
                {
                    width   = 0;
                    height += font.plgc.tile_height;
                }
            }

            picText.Image = image;
        }