cleanup some BizwareGL files - spaces to tabs, remove used code, cleanup
This commit is contained in:
parent
cab5df6c87
commit
f873e7f9c3
|
@ -235,6 +235,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Coroutine/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cpus/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=curr/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cyotek/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=databus/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Datacorder/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Datarows/@EntryIndexedValue">True</s:Boolean>
|
||||
|
@ -305,6 +306,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=jumplist/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Justifier/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=keepalives/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kernings/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=KEYMENU/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kopi/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Letterboxing/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
|
@ -1,126 +1,20 @@
|
|||
//public domain assumed from cyotek.com
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
// public domain assumed from cyotek.com
|
||||
namespace Cyotek.Drawing.BitmapFont
|
||||
{
|
||||
public class BitmapFont : IEnumerable<Character>
|
||||
{
|
||||
#region Public Member Declarations
|
||||
|
||||
public const int NoMaxWidth = -1;
|
||||
|
||||
#endregion Public Member Declarations
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public BitmapFont()
|
||||
{ }
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public IEnumerator<Character> GetEnumerator()
|
||||
{
|
||||
foreach (KeyValuePair<char, Character> pair in this.Characters)
|
||||
foreach (KeyValuePair<char, Character> pair in Characters)
|
||||
{
|
||||
yield return pair.Value;
|
||||
}
|
||||
|
||||
public int GetKerning(char previous, char current)
|
||||
{
|
||||
Kerning key;
|
||||
int result;
|
||||
|
||||
key = new Kerning(previous, current, 0);
|
||||
if (!this.Kernings.TryGetValue(key, out result))
|
||||
result = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Size MeasureFont(string text)
|
||||
{
|
||||
return this.MeasureFont(text, BitmapFont.NoMaxWidth);
|
||||
}
|
||||
|
||||
public Size MeasureFont(string text, double maxWidth)
|
||||
{
|
||||
char previousCharacter;
|
||||
string normalizedText;
|
||||
int currentLineWidth;
|
||||
int currentLineHeight;
|
||||
int blockWidth;
|
||||
int blockHeight;
|
||||
List<int> lineHeights;
|
||||
|
||||
previousCharacter = ' ';
|
||||
normalizedText = this.NormalizeLineBreaks(text);
|
||||
currentLineWidth = 0;
|
||||
currentLineHeight = this.LineHeight;
|
||||
blockWidth = 0;
|
||||
blockHeight = 0;
|
||||
lineHeights = new List<int>();
|
||||
|
||||
foreach (char character in normalizedText)
|
||||
{
|
||||
switch (character)
|
||||
{
|
||||
case '\n':
|
||||
lineHeights.Add(currentLineHeight);
|
||||
blockWidth = Math.Max(blockWidth, currentLineWidth);
|
||||
currentLineWidth = 0;
|
||||
currentLineHeight = this.LineHeight;
|
||||
break;
|
||||
default:
|
||||
Character data;
|
||||
int width;
|
||||
|
||||
data = this[character];
|
||||
width = data.XAdvance + this.GetKerning(previousCharacter, character);
|
||||
|
||||
if (maxWidth != BitmapFont.NoMaxWidth && currentLineWidth + width >= maxWidth)
|
||||
{
|
||||
lineHeights.Add(currentLineHeight);
|
||||
blockWidth = Math.Max(blockWidth, currentLineWidth);
|
||||
currentLineWidth = 0;
|
||||
currentLineHeight = this.LineHeight;
|
||||
}
|
||||
|
||||
currentLineWidth += width;
|
||||
currentLineHeight = Math.Max(currentLineHeight, data.Bounds.Height + data.Offset.Y);
|
||||
previousCharacter = character;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// finish off the current line if required
|
||||
if (currentLineHeight != 0)
|
||||
lineHeights.Add(currentLineHeight);
|
||||
|
||||
// reduce any lines other than the last back to the base
|
||||
for (int i = 0; i < lineHeights.Count - 1; i++)
|
||||
lineHeights[i] = this.LineHeight;
|
||||
|
||||
// calculate the final block height
|
||||
foreach (int lineHeight in lineHeights)
|
||||
blockHeight += lineHeight;
|
||||
|
||||
return new Size(Math.Max(currentLineWidth, blockWidth), blockHeight);
|
||||
}
|
||||
|
||||
public string NormalizeLineBreaks(string s)
|
||||
{
|
||||
return s.Replace("\r\n", "\n").Replace("\r", "\n");
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public int AlphaChannel { get; set; }
|
||||
|
||||
public int BaseHeight { get; set; }
|
||||
|
@ -165,19 +59,13 @@ namespace Cyotek.Drawing.BitmapFont
|
|||
|
||||
public Size TextureSize { get; set; }
|
||||
|
||||
public Character this[char character] => this.Characters[character];
|
||||
public Character this[char character] => Characters[character];
|
||||
|
||||
public bool Unicode { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.GetEnumerator();
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
//public domain assumed from cyotek.com
|
||||
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
// public domain assumed from cyotek.com
|
||||
namespace Cyotek.Drawing.BitmapFont
|
||||
{
|
||||
// Parsing class for bitmap fonts generated by AngelCode BMFont
|
||||
|
@ -15,183 +14,22 @@ namespace Cyotek.Drawing.BitmapFont
|
|||
{
|
||||
#region Public Class Methods
|
||||
|
||||
///// <summary>
|
||||
///// Loads a bitmap font from a file, attempting to auto detect the file type
|
||||
///// </summary>
|
||||
///// <param name="fileName">Name of the file to load.</param>
|
||||
///// <returns></returns>
|
||||
//public static BitmapFont LoadFontFromFile(string fileName)
|
||||
//{
|
||||
// BitmapFont result;
|
||||
|
||||
// if (string.IsNullOrEmpty(fileName))
|
||||
// throw new ArgumentNullException("fileName", "File name not specified");
|
||||
// else if (!File.Exists(fileName))
|
||||
// throw new FileNotFoundException(string.Format("Cannot find file '{0}'", fileName), fileName);
|
||||
|
||||
// using (FileStream file = File.OpenRead(fileName))
|
||||
// {
|
||||
// using (TextReader reader = new StreamReader(file))
|
||||
// {
|
||||
// string line;
|
||||
|
||||
// line = reader.ReadLine();
|
||||
|
||||
// if (line.StartsWith("info "))
|
||||
// result = BitmapFontLoader.LoadFontFromTextFile(fileName);
|
||||
// else if (line.StartsWith("<?xml"))
|
||||
// result = BitmapFontLoader.LoadFontFromXmlFile(fileName);
|
||||
// else
|
||||
// throw new InvalidDataException("Unknown file format.");
|
||||
// }
|
||||
// }
|
||||
|
||||
// return result;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a bitmap font from a text file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">Name of the file to load.</param>
|
||||
public static BitmapFont LoadFontFromTextFile(string fileName)
|
||||
{
|
||||
BitmapFont font;
|
||||
IDictionary<int, Page> pageData;
|
||||
IDictionary<Kerning, int> kerningDictionary;
|
||||
IDictionary<char, Character> charDictionary;
|
||||
string resourcePath;
|
||||
string[] lines;
|
||||
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
throw new ArgumentNullException(nameof(fileName), "File name not specified");
|
||||
else if (!File.Exists(fileName))
|
||||
throw new FileNotFoundException(string.Format("Cannot find file '{0}'", fileName), fileName);
|
||||
|
||||
pageData = new SortedDictionary<int, Page>();
|
||||
kerningDictionary = new Dictionary<Kerning, int>();
|
||||
charDictionary = new Dictionary<char, Character>();
|
||||
font = new BitmapFont();
|
||||
|
||||
resourcePath = Path.GetDirectoryName(fileName);
|
||||
lines = File.ReadAllLines(fileName);
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string[] parts;
|
||||
|
||||
parts = BitmapFontLoader.Split(line, ' ');
|
||||
|
||||
if (parts.Length != 0)
|
||||
{
|
||||
switch (parts[0])
|
||||
{
|
||||
case "info":
|
||||
font.FamilyName = BitmapFontLoader.GetNamedString(parts, "face");
|
||||
font.FontSize = BitmapFontLoader.GetNamedInt(parts, "size");
|
||||
font.Bold = BitmapFontLoader.GetNamedBool(parts, "bold");
|
||||
font.Italic = BitmapFontLoader.GetNamedBool(parts, "italic");
|
||||
font.Charset = BitmapFontLoader.GetNamedString(parts, "charset");
|
||||
font.Unicode = BitmapFontLoader.GetNamedBool(parts, "unicode");
|
||||
font.StretchedHeight = BitmapFontLoader.GetNamedInt(parts, "stretchH");
|
||||
font.Smoothed = BitmapFontLoader.GetNamedBool(parts, "smooth");
|
||||
font.SuperSampling = BitmapFontLoader.GetNamedInt(parts, "aa");
|
||||
font.Padding = BitmapFontLoader.ParsePadding(BitmapFontLoader.GetNamedString(parts, "padding"));
|
||||
font.Spacing = BitmapFontLoader.ParsePoint(BitmapFontLoader.GetNamedString(parts, "spacing"));
|
||||
font.OutlineSize = BitmapFontLoader.GetNamedInt(parts, "outline");
|
||||
break;
|
||||
case "common":
|
||||
font.LineHeight = BitmapFontLoader.GetNamedInt(parts, "lineHeight");
|
||||
font.BaseHeight = BitmapFontLoader.GetNamedInt(parts, "base");
|
||||
font.TextureSize = new Size
|
||||
(
|
||||
BitmapFontLoader.GetNamedInt(parts, "scaleW"),
|
||||
BitmapFontLoader.GetNamedInt(parts, "scaleH")
|
||||
);
|
||||
font.Packed = BitmapFontLoader.GetNamedBool(parts, "packed");
|
||||
font.AlphaChannel = BitmapFontLoader.GetNamedInt(parts, "alphaChnl");
|
||||
font.RedChannel = BitmapFontLoader.GetNamedInt(parts, "redChnl");
|
||||
font.GreenChannel = BitmapFontLoader.GetNamedInt(parts, "greenChnl");
|
||||
font.BlueChannel = BitmapFontLoader.GetNamedInt(parts, "blueChnl");
|
||||
break;
|
||||
case "page":
|
||||
int id;
|
||||
string name;
|
||||
string textureId;
|
||||
|
||||
id = BitmapFontLoader.GetNamedInt(parts, "id");
|
||||
name = BitmapFontLoader.GetNamedString(parts, "file");
|
||||
textureId = Path.GetFileNameWithoutExtension(name);
|
||||
|
||||
pageData.Add(id, new Page(id, Path.Combine(resourcePath, name)));
|
||||
break;
|
||||
case "char":
|
||||
Character charData;
|
||||
|
||||
charData = new Character
|
||||
{
|
||||
Char = (char)BitmapFontLoader.GetNamedInt(parts, "id"),
|
||||
Bounds = new Rectangle
|
||||
(
|
||||
BitmapFontLoader.GetNamedInt(parts, "x"),
|
||||
BitmapFontLoader.GetNamedInt(parts, "y"),
|
||||
BitmapFontLoader.GetNamedInt(parts, "width"),
|
||||
BitmapFontLoader.GetNamedInt(parts, "height")
|
||||
),
|
||||
Offset = new Point
|
||||
(
|
||||
BitmapFontLoader.GetNamedInt(parts, "xoffset"),
|
||||
BitmapFontLoader.GetNamedInt(parts, "yoffset")
|
||||
),
|
||||
XAdvance = BitmapFontLoader.GetNamedInt(parts, "xadvance"),
|
||||
TexturePage = BitmapFontLoader.GetNamedInt(parts, "page"),
|
||||
Channel = BitmapFontLoader.GetNamedInt(parts, "chnl")
|
||||
};
|
||||
charDictionary.Add(charData.Char, charData);
|
||||
break;
|
||||
case "kerning":
|
||||
Kerning key;
|
||||
|
||||
key = new Kerning((char)BitmapFontLoader.GetNamedInt(parts, "first"), (char)BitmapFontLoader.GetNamedInt(parts, "second"), GetNamedInt(parts, "amount"));
|
||||
|
||||
if (!kerningDictionary.ContainsKey(key))
|
||||
kerningDictionary.Add(key, key.Amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
font.Pages = BitmapFontLoader.ToArray(pageData.Values);
|
||||
font.Characters = charDictionary;
|
||||
font.Kernings = kerningDictionary;
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a bitmap font from an XML file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">Name of the file to load.</param>
|
||||
public static BitmapFont LoadFontFromXmlFile(Stream stream)
|
||||
{
|
||||
XmlDocument document;
|
||||
BitmapFont font;
|
||||
IDictionary<int, Page> pageData;
|
||||
IDictionary<Kerning, int> kerningDictionary;
|
||||
IDictionary<char, Character> charDictionary;
|
||||
XmlNode root;
|
||||
XmlNode properties;
|
||||
|
||||
document = new XmlDocument();
|
||||
pageData = new SortedDictionary<int, Page>();
|
||||
kerningDictionary = new Dictionary<Kerning, int>();
|
||||
charDictionary = new Dictionary<char, Character>();
|
||||
font = new BitmapFont();
|
||||
var document = new XmlDocument();
|
||||
IDictionary<int, Page> pageData = new SortedDictionary<int, Page>();
|
||||
IDictionary<Kerning, int> kerningDictionary = new Dictionary<Kerning, int>();
|
||||
IDictionary<char, Character> charDictionary = new Dictionary<char, Character>();
|
||||
var font = new BitmapFont();
|
||||
|
||||
document.Load(stream);
|
||||
root = document.DocumentElement;
|
||||
XmlNode root = document.DocumentElement;
|
||||
|
||||
// load the basic attributes
|
||||
properties = root.SelectSingleNode("info");
|
||||
var properties = root.SelectSingleNode("info");
|
||||
font.FamilyName = properties.Attributes["face"].Value;
|
||||
font.FontSize = Convert.ToInt32(properties.Attributes["size"].Value);
|
||||
font.Bold = Convert.ToInt32(properties.Attributes["bold"].Value) != 0;
|
||||
|
@ -201,8 +39,8 @@ namespace Cyotek.Drawing.BitmapFont
|
|||
font.Charset = properties.Attributes["charset"].Value;
|
||||
font.Smoothed = Convert.ToInt32(properties.Attributes["smooth"].Value) != 0;
|
||||
font.SuperSampling = Convert.ToInt32(properties.Attributes["aa"].Value);
|
||||
font.Padding = BitmapFontLoader.ParsePadding(properties.Attributes["padding"].Value);
|
||||
font.Spacing = BitmapFontLoader.ParsePoint(properties.Attributes["spacing"].Value);
|
||||
font.Padding = ParsePadding(properties.Attributes["padding"].Value);
|
||||
font.Spacing = ParsePoint(properties.Attributes["spacing"].Value);
|
||||
font.OutlineSize = Convert.ToInt32(properties.Attributes["outline"].Value);
|
||||
|
||||
// common attributes
|
||||
|
@ -223,53 +61,55 @@ namespace Cyotek.Drawing.BitmapFont
|
|||
// load texture information
|
||||
foreach (XmlNode node in root.SelectNodes("pages/page"))
|
||||
{
|
||||
Page page;
|
||||
|
||||
page = new Page();
|
||||
page.Id = Convert.ToInt32(node.Attributes["id"].Value);
|
||||
page.FileName = node.Attributes["file"].Value;
|
||||
var page = new Page
|
||||
{
|
||||
Id = Convert.ToInt32(node.Attributes["id"].Value),
|
||||
FileName = node.Attributes["file"].Value
|
||||
};
|
||||
|
||||
pageData.Add(page.Id, page);
|
||||
}
|
||||
font.Pages = BitmapFontLoader.ToArray(pageData.Values);
|
||||
font.Pages = ToArray(pageData.Values);
|
||||
|
||||
// load character information
|
||||
foreach (XmlNode node in root.SelectNodes("chars/char"))
|
||||
{
|
||||
Character character;
|
||||
|
||||
character = new Character();
|
||||
character.Char = (char)Convert.ToInt32(node.Attributes["id"].Value);
|
||||
character.Bounds = new Rectangle
|
||||
var character = new Character
|
||||
{
|
||||
Char = (char) Convert.ToInt32(node.Attributes["id"].Value),
|
||||
Bounds = new Rectangle
|
||||
(
|
||||
Convert.ToInt32(node.Attributes["x"].Value),
|
||||
Convert.ToInt32(node.Attributes["y"].Value),
|
||||
Convert.ToInt32(node.Attributes["width"].Value),
|
||||
Convert.ToInt32(node.Attributes["height"].Value)
|
||||
);
|
||||
character.Offset = new Point
|
||||
),
|
||||
Offset = new Point
|
||||
(
|
||||
Convert.ToInt32(node.Attributes["xoffset"].Value),
|
||||
Convert.ToInt32(node.Attributes["yoffset"].Value)
|
||||
);
|
||||
character.XAdvance = Convert.ToInt32(node.Attributes["xadvance"].Value);
|
||||
character.TexturePage = Convert.ToInt32(node.Attributes["page"].Value);
|
||||
character.Channel = Convert.ToInt32(node.Attributes["chnl"].Value);
|
||||
),
|
||||
XAdvance = Convert.ToInt32(node.Attributes["xadvance"].Value),
|
||||
TexturePage = Convert.ToInt32(node.Attributes["page"].Value),
|
||||
Channel = Convert.ToInt32(node.Attributes["chnl"].Value)
|
||||
};
|
||||
|
||||
charDictionary.Add(character.Char, character);
|
||||
}
|
||||
|
||||
font.Characters = charDictionary;
|
||||
|
||||
// loading kerning information
|
||||
foreach (XmlNode node in root.SelectNodes("kernings/kerning"))
|
||||
{
|
||||
Kerning key;
|
||||
|
||||
key = new Kerning((char)Convert.ToInt32(node.Attributes["first"].Value), (char)Convert.ToInt32(node.Attributes["second"].Value), Convert.ToInt32(node.Attributes["amount"].Value));
|
||||
var key = new Kerning((char)Convert.ToInt32(node.Attributes["first"].Value), (char)Convert.ToInt32(node.Attributes["second"].Value), Convert.ToInt32(node.Attributes["amount"].Value));
|
||||
|
||||
if (!kerningDictionary.ContainsKey(key))
|
||||
{
|
||||
kerningDictionary.Add(key, key.Amount);
|
||||
}
|
||||
}
|
||||
|
||||
font.Kernings = kerningDictionary;
|
||||
|
||||
return font;
|
||||
|
@ -279,76 +119,15 @@ namespace Cyotek.Drawing.BitmapFont
|
|||
|
||||
#region Private Class Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns a boolean from an array of name/value pairs.
|
||||
/// </summary>
|
||||
/// <param name="parts">The array of parts.</param>
|
||||
/// <param name="name">The name of the value to return.</param>
|
||||
private static bool GetNamedBool(string[] parts, string name)
|
||||
{
|
||||
return BitmapFontLoader.GetNamedInt(parts, name) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an integer from an array of name/value pairs.
|
||||
/// </summary>
|
||||
/// <param name="parts">The array of parts.</param>
|
||||
/// <param name="name">The name of the value to return.</param>
|
||||
private static int GetNamedInt(string[] parts, string name)
|
||||
{
|
||||
return Convert.ToInt32(BitmapFontLoader.GetNamedString(parts, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string from an array of name/value pairs.
|
||||
/// </summary>
|
||||
/// <param name="parts">The array of parts.</param>
|
||||
/// <param name="name">The name of the value to return.</param>
|
||||
private static string GetNamedString(string[] parts, string name)
|
||||
{
|
||||
string result;
|
||||
|
||||
result = "";
|
||||
name = name.ToLowerInvariant();
|
||||
|
||||
foreach (string part in parts)
|
||||
{
|
||||
int nameEndIndex;
|
||||
|
||||
nameEndIndex = part.IndexOf("=");
|
||||
if (nameEndIndex != -1)
|
||||
{
|
||||
string namePart;
|
||||
string valuePart;
|
||||
|
||||
namePart = part.Substring(0, nameEndIndex).ToLowerInvariant();
|
||||
valuePart = part.Substring(nameEndIndex + 1);
|
||||
|
||||
if (namePart == name)
|
||||
{
|
||||
if (valuePart.StartsWith("\"") && valuePart.EndsWith("\""))
|
||||
valuePart = valuePart.Substring(1, valuePart.Length - 2);
|
||||
|
||||
result = valuePart;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Padding object from a string representation
|
||||
/// </summary>
|
||||
/// <param name="s">The string.</param>
|
||||
private static Padding ParsePadding(string s)
|
||||
{
|
||||
string[] parts;
|
||||
var parts = s.Split(',');
|
||||
|
||||
parts = s.Split(',');
|
||||
|
||||
return new Padding()
|
||||
return new Padding
|
||||
{
|
||||
Left = Convert.ToInt32(parts[3].Trim()),
|
||||
Top = Convert.ToInt32(parts[0].Trim()),
|
||||
|
@ -363,68 +142,15 @@ namespace Cyotek.Drawing.BitmapFont
|
|||
/// <param name="s">The string.</param>
|
||||
private static Point ParsePoint(string s)
|
||||
{
|
||||
string[] parts;
|
||||
var parts = s.Split(',');
|
||||
|
||||
parts = s.Split(',');
|
||||
|
||||
return new Point()
|
||||
return new Point
|
||||
{
|
||||
X = Convert.ToInt32(parts[0].Trim()),
|
||||
Y = Convert.ToInt32(parts[1].Trim())
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Splits the specified string using a given delimiter, ignoring any instances of the delimiter as part of a quoted string.
|
||||
/// </summary>
|
||||
/// <param name="s">The string to split.</param>
|
||||
/// <param name="delimiter">The delimiter.</param>
|
||||
private static string[] Split(string s, char delimiter)
|
||||
{
|
||||
string[] results;
|
||||
|
||||
if (s.Contains("\""))
|
||||
{
|
||||
List<string> parts;
|
||||
int partStart;
|
||||
|
||||
partStart = -1;
|
||||
parts = new List<string>();
|
||||
|
||||
do
|
||||
{
|
||||
int partEnd;
|
||||
int quoteStart;
|
||||
int quoteEnd;
|
||||
bool hasQuotes;
|
||||
|
||||
quoteStart = s.IndexOf("\"", partStart + 1);
|
||||
quoteEnd = s.IndexOf("\"", quoteStart + 1);
|
||||
partEnd = s.IndexOf(delimiter, partStart + 1);
|
||||
|
||||
if (partEnd == -1)
|
||||
partEnd = s.Length;
|
||||
|
||||
hasQuotes = quoteStart != -1 && partEnd > quoteStart && partEnd < quoteEnd;
|
||||
if (hasQuotes)
|
||||
partEnd = s.IndexOf(delimiter, quoteEnd + 1);
|
||||
|
||||
parts.Add(s.Substring(partStart + 1, partEnd - partStart - 1));
|
||||
|
||||
if (hasQuotes)
|
||||
partStart = partEnd - 1;
|
||||
|
||||
partStart = s.IndexOf(delimiter, partStart + 1);
|
||||
} while (partStart != -1);
|
||||
|
||||
results = parts.ToArray();
|
||||
}
|
||||
else
|
||||
results = s.Split(new char[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the given collection into an array
|
||||
/// </summary>
|
||||
|
@ -432,11 +158,8 @@ namespace Cyotek.Drawing.BitmapFont
|
|||
/// <param name="values">The values.</param>
|
||||
private static T[] ToArray<T>(ICollection<T> values)
|
||||
{
|
||||
T[] result;
|
||||
|
||||
// avoid a forced .NET 3 dependency just for one call to Linq
|
||||
|
||||
result = new T[values.Count];
|
||||
var result = new T[values.Count];
|
||||
values.CopyTo(result, 0);
|
||||
|
||||
return result;
|
||||
|
|
|
@ -30,6 +30,4 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
/// </summary>
|
||||
void End();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -23,8 +23,11 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
return;
|
||||
|
||||
UniformsDictionary = new SpecialWorkingDictionary(this);
|
||||
foreach(var ui in uniforms)
|
||||
foreach (var ui in uniforms)
|
||||
{
|
||||
UniformsDictionary[ui.Name] = new PipelineUniform(this);
|
||||
}
|
||||
|
||||
foreach (var ui in uniforms)
|
||||
{
|
||||
UniformsDictionary[ui.Name].AddUniformInfo(ui);
|
||||
|
@ -47,11 +50,9 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
{
|
||||
get
|
||||
{
|
||||
PipelineUniform temp;
|
||||
if (!TryGetValue(key, out temp))
|
||||
if (!TryGetValue(key, out var temp))
|
||||
{
|
||||
var ui = new UniformInfo();
|
||||
ui.Opaque = null;
|
||||
var ui = new UniformInfo {Opaque = null};
|
||||
temp = this[key] = new PipelineUniform(null);
|
||||
}
|
||||
|
||||
|
@ -65,12 +66,11 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
readonly SpecialWorkingDictionary UniformsDictionary;
|
||||
IDictionary<string, PipelineUniform> Uniforms => UniformsDictionary;
|
||||
|
||||
public IEnumerable<PipelineUniform> GetUniforms() { return Uniforms.Values; }
|
||||
public IEnumerable<PipelineUniform> GetUniforms() => Uniforms.Values;
|
||||
|
||||
public PipelineUniform TryGetUniform(string name)
|
||||
{
|
||||
PipelineUniform ret = null;
|
||||
Uniforms.TryGetValue(name,out ret);
|
||||
Uniforms.TryGetValue(name, out var ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
Owner = owner;
|
||||
FontInfo = Cyotek.Drawing.BitmapFont.BitmapFontLoader.LoadFontFromXmlFile(xml);
|
||||
|
||||
//load textures
|
||||
// load textures
|
||||
for(int i=0;i<FontInfo.Pages.Length;i++)
|
||||
{
|
||||
TexturePages.Add(owner.LoadTexture(textures[i]));
|
||||
|
@ -121,8 +121,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
|
||||
public IGL Owner { get; }
|
||||
|
||||
readonly Cyotek.Drawing.BitmapFont.BitmapFont FontInfo;
|
||||
List<Texture2d> TexturePages = new List<Texture2d>();
|
||||
|
||||
private readonly Cyotek.Drawing.BitmapFont.BitmapFont FontInfo;
|
||||
private List<Texture2d> TexturePages = new List<Texture2d>();
|
||||
}
|
||||
}
|
|
@ -21,8 +21,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
public object Item;
|
||||
}
|
||||
|
||||
|
||||
class TryFitParam
|
||||
private class TryFitParam
|
||||
{
|
||||
public TryFitParam(int _w, int _h) { this.w = _w; this.h = _h; }
|
||||
public readonly int w;
|
||||
|
@ -49,19 +48,19 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
/// </summary>
|
||||
public static PackedAtlasResults PackAtlas(IEnumerable<RectItem> items)
|
||||
{
|
||||
PackedAtlasResults ret = new PackedAtlasResults();
|
||||
var ret = new PackedAtlasResults();
|
||||
ret.Atlases.Add(new PackedAtlasResults.SingleAtlas());
|
||||
|
||||
//initially, we'll try all the items; none remain
|
||||
List<RectItem> currentItems = new List<RectItem>(items);
|
||||
List<RectItem> remainItems = new List<RectItem>();
|
||||
// initially, we'll try all the items; none remain
|
||||
var currentItems = new List<RectItem>(items);
|
||||
var remainItems = new List<RectItem>();
|
||||
|
||||
RETRY:
|
||||
|
||||
//this is where the texture size range is determined.
|
||||
//we run this every time we make an atlas, in case we want to variably control the maximum texture output size.
|
||||
//ALSO - we accumulate data in there, so we need to refresh it each time. ... lame.
|
||||
List<TryFitParam> todoSizes = new List<TryFitParam>();
|
||||
// this is where the texture size range is determined.
|
||||
// we run this every time we make an atlas, in case we want to variably control the maximum texture output size.
|
||||
// ALSO - we accumulate data in there, so we need to refresh it each time. ... lame.
|
||||
var todoSizes = new List<TryFitParam>();
|
||||
for (int i = 3; i <= MaxSizeBits; i++)
|
||||
{
|
||||
for (int j = 3; j <= MaxSizeBits; j++)
|
||||
|
@ -164,9 +163,9 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
return ret;
|
||||
}
|
||||
|
||||
//original file: RectangleBinPack.cpp
|
||||
//author: Jukka Jylänki
|
||||
class RectangleBinPack
|
||||
// original file: RectangleBinPack.cpp
|
||||
// author: Jukka Jylänki
|
||||
private class RectangleBinPack
|
||||
{
|
||||
/** A node of a binary tree. Each node represents a rectangular area of the texture
|
||||
we surface. Internal nodes store rectangles of used data, whereas leaf nodes track
|
||||
|
@ -315,8 +314,5 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue