diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia/Font/Bitmap/BitmapFontEditor.glade b/Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia/Font/Bitmap/BitmapFontEditor.glade new file mode 100644 index 00000000..428f9bb7 --- /dev/null +++ b/Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia/Font/Bitmap/BitmapFontEditor.glade @@ -0,0 +1,379 @@ + + + + + + False + + + True + False + 16 + 16 + 16 + 16 + vertical + + + + True + False + 8 + 8 + + + True + False + Name + 0 + + + 0 + 0 + + + + + True + True + True + FROGGREN + + + 1 + 0 + 2 + + + + + True + False + Title + 0 + + + 0 + 1 + + + + + True + True + True + Frogger Green Font + + + 1 + 1 + 2 + + + + + True + False + Size + 0 + + + 0 + 2 + 2 + + + + + True + False + Width + + + 1 + 3 + + + + + True + False + Height + + + 2 + 3 + + + + + True + True + + + 1 + 2 + + + + + True + True + + + 2 + 2 + + + + + False + True + 0 + + + + + True + False + 16 + vertical + + + True + True + enter some text... + + + True + True + 0 + + + + + MBS.Framework.UserInterface.CustomControl + 96 + True + False + + + False + True + 1 + + + + + False + True + 1 + + + + + True + True + + + True + False + vertical + + + True + True + in + + + True + True + + + + + + + + True + True + 0 + + + + + + + True + False + Images + + + False + + + + + True + False + True + True + vertical + + + True + False + + + True + False + Add + Add + True + gtk-add + + + False + True + + + + + True + False + Edit + Edit + True + gtk-edit + + + False + True + + + + + True + False + Remove + Remove + True + gtk-remove + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Move Up + Move Up + True + gtk-go-up + + + False + True + + + + + True + False + Move Down + Move Down + True + gtk-go-down + + + False + True + + + + + False + True + 0 + + + + + True + True + in + + + True + True + 6 + lmIcons + + + + 0 + + + + + + 0 + + + + + + + True + True + 1 + + + + + 1 + + + + + True + False + Glyphs + + + 1 + False + + + + + True + True + 2 + + + + + + + + + + + + + + diff --git a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj index a3084ff4..7c916147 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj +++ b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj @@ -389,6 +389,7 @@ + diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Font/Bitmap/BitmapFontEditor.cs b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Font/Bitmap/BitmapFontEditor.cs new file mode 100644 index 00000000..c0a6539f --- /dev/null +++ b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Font/Bitmap/BitmapFontEditor.cs @@ -0,0 +1,149 @@ +// +// BitmapFontEditor.cs +// +// Author: +// beckermj <> +// +// Copyright (c) 2023 ${CopyrightHolder} +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using MBS.Framework.UserInterface; +using MBS.Framework.UserInterface.Controls; +using MBS.Framework.UserInterface.Controls.ListView; +using UniversalEditor.ObjectModels.Multimedia.Font.Bitmap; +using UniversalEditor.ObjectModels.Multimedia.Picture; +using UniversalEditor.UserInterface; + +namespace UniversalEditor.Plugins.Multimedia.UserInterface.Editors.Multimedia.Font.Bitmap +{ + [ContainerLayout("~/Editors/Multimedia/Font/Bitmap/BitmapFontEditor.glade")] + public class BitmapFontEditor : Editor + { + private ListViewControl lv; + private TextBox txtTitle; + private NumericTextBox txtWidth; + private NumericTextBox txtHeight; + private CustomControl canvas; + private TextBox txtRenderTest; + + private static EditorReference _er = null; + public override EditorReference MakeReference() + { + if (_er == null) + { + _er = base.MakeReference(); + _er.SupportedObjectModels.Add(typeof(BitmapFontObjectModel)); + } + return _er; + } + + protected override void OnObjectModelChanged(EventArgs e) + { + if (IsCreated) + { + lv.Model.Rows.Clear(); + + base.OnObjectModelChanged(e); + + BitmapFontObjectModel font = (ObjectModel as BitmapFontObjectModel); + //txtName.Text = font.Name; + txtTitle.Text = font.Title; + txtWidth.Value = font.Size.Width; + txtHeight.Value = font.Size.Height; + + foreach (BitmapFontPixmap pixmap in font.Pixmaps) + { + foreach (BitmapFontGlyph glyph in pixmap.Glyphs) + { + MBS.Framework.UserInterface.Drawing.Image image = null; + if (glyph.Picture != null) + { + image = glyph.Picture.ToImage(); + } + else if (pixmap.Picture != null) + { + if (!((int)pixmap.Picture.Width == (int)font.Size.Width && (int)pixmap.Picture.Height == (int)font.Size.Height)) + { + // pixmap size does not equal font size - pixmap contains multiple glyphs + PictureObjectModel pic = new PictureObjectModel((int)font.Size.Width, (int)font.Size.Height); + pixmap.Picture.CopyTo(pic, glyph.X, glyph.Y, font.Size.Width, font.Size.Height); + + image = pic.ToImage(); + } + else + { + // pixmap size equal to font size - pixmap is one per glyph + image = pixmap.Picture.ToImage(); + } + } + + if (image != null) + { + _glyphs[glyph.Character] = image; + } + + TreeModelRow row = new TreeModelRow(new TreeModelRowColumn[] + { + new TreeModelRowColumn(lv.Model.Columns[0], glyph.Character.ToString()), + new TreeModelRowColumn(lv.Model.Columns[1], image) + }); + lv.Model.Rows.Add(row); + } + } + } + } + protected override void OnCreated(EventArgs e) + { + base.OnCreated(e); + + OnObjectModelChanged(e); + } + + [EventHandler(nameof(txtRenderTest), nameof(TextBox.Changed))] + private void txtRenderTest_Changed(object sender, EventArgs e) + { + canvas.Refresh(); + } + + private System.Collections.Generic.Dictionary _glyphs = new System.Collections.Generic.Dictionary(); + + [EventHandler(nameof(canvas), nameof(Paint))] + private void canvas_Paint(object sender, PaintEventArgs e) + { + e.Graphics.Clear(MBS.Framework.Drawing.Colors.Black); + + int x = 16, y = 16; + for (int i = 0; i < txtRenderTest.Text.Length; i++) + { + BitmapFontObjectModel font = (ObjectModel as BitmapFontObjectModel); + if (_glyphs.ContainsKey(txtRenderTest.Text[i])) + { + MBS.Framework.UserInterface.Drawing.Image image = _glyphs[txtRenderTest.Text[i]]; + e.Graphics.DrawImage(image, x, y); + } + x += (int)font.Size.Width; + } + } + + public override void UpdateSelections() + { + } + + protected override Selection CreateSelectionInternal(object content) + { + return null; + } + } +} diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface.csproj b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface.csproj index 5945205f..550360bf 100644 --- a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface.csproj +++ b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface.csproj @@ -63,6 +63,7 @@ + @@ -90,6 +91,8 @@ + + diff --git a/Plugins/UniversalEditor.Plugins.Multimedia/Associations/Picture/PCX.uexml b/Plugins/UniversalEditor.Plugins.Multimedia/Associations/Picture/PCX.uexml index 4f2dc2df..20491832 100644 --- a/Plugins/UniversalEditor.Plugins.Multimedia/Associations/Picture/PCX.uexml +++ b/Plugins/UniversalEditor.Plugins.Multimedia/Associations/Picture/PCX.uexml @@ -3,9 +3,10 @@ - + *.pcx + *.PCX diff --git a/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Font/Bitmap/BitmapFontGlyph.cs b/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Font/Bitmap/BitmapFontGlyph.cs new file mode 100644 index 00000000..d5897898 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Font/Bitmap/BitmapFontGlyph.cs @@ -0,0 +1,41 @@ +// +// BitmapFontGlyph.cs +// +// Author: +// beckermj <> +// +// Copyright (c) 2023 ${CopyrightHolder} +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using UniversalEditor.ObjectModels.Multimedia.Picture; + +namespace UniversalEditor.ObjectModels.Multimedia.Font.Bitmap +{ + public class BitmapFontGlyph + { + public class BitmapFontGlyphCollection + : System.Collections.ObjectModel.Collection + { + + } + + public char Character { get; set; } + + public double X { get; set; } + public double Y { get; set; } + public BitmapFontPixmap Pixmap { get; set; } = null; + public PictureObjectModel Picture { get; set; } + } +} diff --git a/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Font/Bitmap/BitmapFontObjectModel.cs b/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Font/Bitmap/BitmapFontObjectModel.cs new file mode 100644 index 00000000..f3eb60f7 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Font/Bitmap/BitmapFontObjectModel.cs @@ -0,0 +1,55 @@ +// +// BitmapFontObjectModel.cs +// +// Author: +// beckermj <> +// +// Copyright (c) 2023 ${CopyrightHolder} +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using MBS.Framework.Drawing; + +namespace UniversalEditor.ObjectModels.Multimedia.Font.Bitmap +{ + public class BitmapFontObjectModel : ObjectModel + { + public string Title { get; set; } = null; + public Dimension2D Size { get; set; } + public BitmapFontPixmap.BitmapFontPixmapCollection Pixmaps { get; } = new BitmapFontPixmap.BitmapFontPixmapCollection(); + + public override void Clear() + { + throw new NotImplementedException(); + } + + public override void CopyTo(ObjectModel where) + { + throw new NotImplementedException(); + } + + public BitmapFontGlyph FindGlyph(char c) + { + foreach (BitmapFontPixmap pixmap in Pixmaps) + { + foreach (BitmapFontGlyph glyph in pixmap.Glyphs) + { + if (glyph.Character == c) + return glyph; + } + } + return null; + } + } +} diff --git a/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Font/Bitmap/BitmapFontPixmap.cs b/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Font/Bitmap/BitmapFontPixmap.cs new file mode 100644 index 00000000..b944a25c --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Font/Bitmap/BitmapFontPixmap.cs @@ -0,0 +1,38 @@ +// +// BitmapFontPixmap.cs +// +// Author: +// beckermj <> +// +// Copyright (c) 2023 ${CopyrightHolder} +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using UniversalEditor.ObjectModels.Multimedia.Picture; + +namespace UniversalEditor.ObjectModels.Multimedia.Font.Bitmap +{ + public class BitmapFontPixmap + { + public class BitmapFontPixmapCollection + : System.Collections.ObjectModel.Collection + { + + } + + public string RelativePath { get; set; } + public PictureObjectModel Picture { get; set; } = null; + public BitmapFontGlyph.BitmapFontGlyphCollection Glyphs { get; } = new BitmapFontGlyph.BitmapFontGlyphCollection(); + } +} diff --git a/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Picture/PictureObjectModel.cs b/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Picture/PictureObjectModel.cs index 9b1ce22c..766dc004 100644 --- a/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Picture/PictureObjectModel.cs +++ b/Plugins/UniversalEditor.Plugins.Multimedia/ObjectModels/Multimedia/Picture/PictureObjectModel.cs @@ -74,6 +74,32 @@ namespace UniversalEditor.ObjectModels.Multimedia.Picture return colorMap; } + public void CopyTo(PictureObjectModel pic, double x, double y, double width, double height) + { + if (pic.Width < width || pic.Height < height) + { + throw new InvalidOperationException(); + } + + double ix = x, iy = y; + for (double xx = 0; xx < width; xx++) + { + for (double yy = 0; yy < height; yy++) + { + Console.WriteLine("src: ({0}, {1}) dst: ({2}, {3})", x, y, xx, yy); + pic.SetPixel(this.GetPixel((int)x, (int)y), (int)xx, (int)yy); + y++; + } + x++; + y = iy; + + if (x == Width) + { + x = 0; + } + } + } + public void SetPixel(Color color) { if (lastAddedLocation.X >= mvarWidth && lastAddedLocation.Y >= mvarHeight) @@ -95,6 +121,7 @@ namespace UniversalEditor.ObjectModels.Multimedia.Picture { if (x >= mvarWidth || y >= mvarHeight) { + Console.Error.WriteLine("ue: picture: out of image space @({0}, {1}) ({2}x{3})", x, y, Width, Height); throw new InvalidOperationException("Out of image space. Try resizing the image"); } @@ -146,10 +173,10 @@ namespace UniversalEditor.ObjectModels.Multimedia.Picture } public PictureObjectModel(int width, int height) { - InitializeBitmapData(); - mvarWidth = width; mvarHeight = height; + + InitializeBitmapData(); } private static void InitializeBitmapData(ref Color[][] array, int width, int height) diff --git a/Plugins/UniversalEditor.Plugins.Multimedia/UniversalEditor.Plugins.Multimedia.csproj b/Plugins/UniversalEditor.Plugins.Multimedia/UniversalEditor.Plugins.Multimedia.csproj index 2cc50d00..74f59dbf 100644 --- a/Plugins/UniversalEditor.Plugins.Multimedia/UniversalEditor.Plugins.Multimedia.csproj +++ b/Plugins/UniversalEditor.Plugins.Multimedia/UniversalEditor.Plugins.Multimedia.csproj @@ -387,6 +387,9 @@ + + + @@ -457,6 +460,8 @@ + + diff --git a/Plugins/UniversalEditor.Plugins.Webfoot/Associations/DAT.uexml b/Plugins/UniversalEditor.Plugins.Webfoot/Associations/DAT.uexml index 7e564f46..6cbd59f0 100644 --- a/Plugins/UniversalEditor.Plugins.Webfoot/Associations/DAT.uexml +++ b/Plugins/UniversalEditor.Plugins.Webfoot/Associations/DAT.uexml @@ -3,7 +3,7 @@ - + *.dat diff --git a/Plugins/UniversalEditor.Plugins.Webfoot/Associations/FNT.uexml b/Plugins/UniversalEditor.Plugins.Webfoot/Associations/FNT.uexml new file mode 100644 index 00000000..5b81b5f7 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Webfoot/Associations/FNT.uexml @@ -0,0 +1,23 @@ + + + + + + + + *.fnt + + + [Font Properties] + + + + + + + + + + + + diff --git a/Plugins/UniversalEditor.Plugins.Webfoot/DataFormats/FileSystem/Webfoot/DATDataFormat.cs b/Plugins/UniversalEditor.Plugins.Webfoot/DataFormats/FileSystem/Webfoot/DATDataFormat.cs index 1a60594c..6fe9289f 100644 --- a/Plugins/UniversalEditor.Plugins.Webfoot/DataFormats/FileSystem/Webfoot/DATDataFormat.cs +++ b/Plugins/UniversalEditor.Plugins.Webfoot/DataFormats/FileSystem/Webfoot/DATDataFormat.cs @@ -37,9 +37,9 @@ namespace UniversalEditor.Plugins.Webfoot.DataFormats.FileSystem.Webfoot { if (_dfr == null) { - _dfr = base.MakeReferenceInternal(); + _dfr = new DataFormatReference(GetType()); _dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.All); - _dfr.ExportOptions.SettingsGroups[0].Settings.Add(new RangeSetting("Key", "Encryption _key", 0xAA, 0x00, 0xFF)); + _dfr.ExportOptions.SettingsGroups[0].Settings.Add(new RangeSetting("Key", "Encryption _key", 0xAA, 0x00, 0xFF)); } return _dfr; } diff --git a/Plugins/UniversalEditor.Plugins.Webfoot/DataFormats/Font/Bitmap/FNTDataFormat.cs b/Plugins/UniversalEditor.Plugins.Webfoot/DataFormats/Font/Bitmap/FNTDataFormat.cs new file mode 100644 index 00000000..b888c8ef --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Webfoot/DataFormats/Font/Bitmap/FNTDataFormat.cs @@ -0,0 +1,202 @@ +// +// FNTDataFormat.cs +// +// Author: +// beckermj <> +// +// Copyright (c) 2023 ${CopyrightHolder} +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using System.Collections.Generic; +using UniversalEditor.Accessors; +using UniversalEditor.DataFormats.Multimedia.Picture.ZSoft; +using UniversalEditor.DataFormats.PropertyList; +using UniversalEditor.ObjectModels.Multimedia.Font.Bitmap; +using UniversalEditor.ObjectModels.Multimedia.Picture; +using UniversalEditor.ObjectModels.PropertyList; + +namespace UniversalEditor.Plugins.Webfoot.DataFormats.Font.Bitmap +{ + public class FNTDataFormat : WindowsConfigurationDataFormat + { + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = new DataFormatReference(GetType()); + _dfr.Capabilities.Add(typeof(BitmapFontObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } + + public FNTDataFormat() + { + PropertyValuePrefix = String.Empty; + PropertyValueSuffix = String.Empty; + } + + protected override void BeforeLoadInternal(Stack objectModels) + { + base.BeforeLoadInternal(objectModels); + objectModels.Push(new PropertyListObjectModel()); + } + protected override void AfterLoadInternal(Stack objectModels) + { + base.AfterLoadInternal(objectModels); + + string basePath = null; + if (Accessor is FileAccessor) + { + basePath = System.IO.Path.GetDirectoryName(((FileAccessor)Accessor).FileName); + } + + PropertyListObjectModel plom = objectModels.Pop() as PropertyListObjectModel; + BitmapFontObjectModel font = objectModels.Pop() as BitmapFontObjectModel; + + Group grpFontProperties = plom.Items["Font Properties"] as Group; + if (grpFontProperties != null) + { + font.Title = (grpFontProperties.Items["Name"] as Property).Value?.ToString(); + + double width = + Double.Parse((grpFontProperties.Items["Width"] as Property).Value?.ToString()), + height = + Double.Parse((grpFontProperties.Items["Height"] as Property).Value?.ToString()); + + font.Size = new MBS.Framework.Drawing.Dimension2D(width, height); + + int filesCount = Int32.Parse((grpFontProperties.Items["NbFiles"] as Property).Value?.ToString()); + string paletteFileName = (grpFontProperties.Items["Palette"] as Property).Value?.ToString(); + + for (int i = 0; i < filesCount; i++) + { + BitmapFontPixmap pixmap = new BitmapFontPixmap(); + + Group grpFile = plom.Items[String.Format("File{0}", (i + 1).ToString().PadLeft(3, '0'))] as Group; + if (grpFile != null) + { + string fileName = (grpFile.Items["Name"] as Property).Value?.ToString(); + pixmap.RelativePath = fileName; + + if (basePath != null) + { + string fullyQualifiedFileName = System.IO.Path.Combine(basePath, fileName); + if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) + { + // try and fix Win32 assumptions on Linux + if (!System.IO.File.Exists(fullyQualifiedFileName)) + { + fileName = fileName.ToUpper(); + fullyQualifiedFileName = System.IO.Path.Combine(basePath, fileName); + } + if (!System.IO.File.Exists(fullyQualifiedFileName)) + { + fileName = fileName.Replace("\\", "/"); + fullyQualifiedFileName = System.IO.Path.Combine(basePath, fileName); + } + } + + if (System.IO.File.Exists(fullyQualifiedFileName)) + { + PictureObjectModel pic = new PictureObjectModel(); + FileAccessor fa = new FileAccessor(fullyQualifiedFileName); + Association[] assocs = Association.FromCriteria(new AssociationCriteria() { Accessor = fa, ObjectModel = pic.MakeReference(), FileName = fa.FileName }); + + Document.Load(pic, new PCXDataFormat(), fa); + pixmap.Picture = pic; + } + } + + int type = Int32.Parse((grpFile.Items["Type"] as Property).Value?.ToString()); + + int nbLines = Int32.Parse((grpFile.Items["NbLines"] as Property).Value?.ToString()); + + for (int j = 0; j < nbLines; j++) + { + string lineXXX = (grpFile.Items[String.Format("Line{0}", (j + 1).ToString().PadLeft(3, '0'))] as Property).Value?.ToString(); + for (int k = 0; k < lineXXX.Length; k++) + { + BitmapFontGlyph glyph = new BitmapFontGlyph(); + glyph.X = k * font.Size.Width; + glyph.Y = j * font.Size.Height; + glyph.Pixmap = pixmap; + glyph.Character = lineXXX[k]; + pixmap.Glyphs.Add(glyph); + } + } + font.Pixmaps.Add(pixmap); + } + } + } + } + + protected override void BeforeSaveInternal(Stack objectModels) + { + base.BeforeSaveInternal(objectModels); + + BitmapFontObjectModel font = objectModels.Pop() as BitmapFontObjectModel; + PropertyListObjectModel plom = new PropertyListObjectModel(); + + Group grpFontProperties = new Group("Font Properties"); + grpFontProperties.Items.AddProperty("Name", font.Title); + grpFontProperties.Items.AddProperty("Width", font.Size.Width); + grpFontProperties.Items.AddProperty("Height", font.Size.Height); + grpFontProperties.Items.AddProperty("NbFiles", font.Pixmaps.Count); + grpFontProperties.Items.AddProperty("Palette", font.Pixmaps[0].RelativePath); + plom.Items.Add(grpFontProperties); + + Group grpCharacterProperties = new Group("Character Properties"); + grpCharacterProperties.Items.AddProperty("MapSrc", "abcdefghijklmnopqrstuvwxyz\u0083\u0084\u0085\u0086\u00a0\u0082\u0088\u0089\u008a\u008b\u008c\u008d¡\u0093\u0094\u0095¢\u0081\u0096\u0097£\u0098\u0087¤\u008e\u008f\u0080\u0090¥\u0099¨­"); + grpCharacterProperties.Items.AddProperty("MapDst", "ABCDEFGHIJKLMNOPQRSTUVWXYZaaaaaeeeeiiiioooouuuuycnAACENO?!"); + plom.Items.Add(grpCharacterProperties); + + for (int i = 0; i < font.Pixmaps.Count; i++) + { + BitmapFontPixmap pixmap = font.Pixmaps[i]; + Group grpFile = new Group(String.Format("File{0}", (i + 1).ToString().PadLeft(3, '0'))); + grpFile.Items.AddProperty("Name", font.Pixmaps[i].RelativePath); + grpFile.Items.AddProperty("Type", 1); + + if (font.Pixmaps[i].Picture == null) + { + } + + double picwidth = font.Pixmaps[i].Picture.Size.Width; + int nbLines = (int)Math.Round((font.Pixmaps[i].Glyphs.Count * font.Size.Width) / picwidth); + grpFile.Items.AddProperty("NbLines", font.Pixmaps[i].Glyphs.Count); + + double x = 0; + int k = 0; + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + for (int j = 0; j < font.Pixmaps[i].Glyphs.Count; j++) + { + sb.Append(font.Pixmaps[i].Glyphs[j].Character); + x += font.Size.Width; + if (x >= picwidth) + { + grpFile.Items.AddProperty(String.Format("Line{0}", (k + 1).ToString().PadLeft(3, '0')), sb.ToString()); + x = 0; + sb.Clear(); + k++; + } + } + plom.Items.Add(grpFile); + } + + objectModels.Push(plom); + } + } +} diff --git a/Plugins/UniversalEditor.Plugins.Webfoot/UniversalEditor.Plugins.Webfoot.csproj b/Plugins/UniversalEditor.Plugins.Webfoot/UniversalEditor.Plugins.Webfoot.csproj index 1899f724..ac5ff897 100644 --- a/Plugins/UniversalEditor.Plugins.Webfoot/UniversalEditor.Plugins.Webfoot.csproj +++ b/Plugins/UniversalEditor.Plugins.Webfoot/UniversalEditor.Plugins.Webfoot.csproj @@ -33,12 +33,15 @@ + + + @@ -57,9 +60,18 @@ {00266B21-35C9-4A7F-A6BA-D54D7FDCC25C} MBS.Framework + + {BE4D0BA3-0888-42A5-9C09-FC308A4509D2} + UniversalEditor.Plugins.Multimedia + + + {3F664673-7E22-4486-9AD0-FC81861D0B78} + UniversalEditor.Compression + +