Merge branch 'glfonts', remote branches 'alzeih/master' and 'pchote/master'
This commit is contained in:
@@ -25,7 +25,6 @@ namespace OpenRa.FileFormats.Graphics
|
||||
IVertexBuffer<Vertex> CreateVertexBuffer( int length );
|
||||
IIndexBuffer CreateIndexBuffer( int length );
|
||||
ITexture CreateTexture( Bitmap bitmap );
|
||||
IFont CreateFont( string filename );
|
||||
IShader CreateShader( Stream stream );
|
||||
|
||||
Size WindowSize { get; }
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace OpenRa
|
||||
buttons.Clear();
|
||||
|
||||
renderer.Device.DisableScissor();
|
||||
renderer.RegularFont.DrawText("RenderFrame {0} ({2:F1} ms)\nTick {1} ({3:F1} ms)\n".F(
|
||||
renderer.RegularFont.DrawText( rgbaRenderer, "RenderFrame {0} ({2:F1} ms)\nTick {1} ({3:F1} ms)\n".F(
|
||||
Game.RenderFrame,
|
||||
Game.orderManager.FrameNumber,
|
||||
PerfHistory.items["render"].LastValue,
|
||||
@@ -326,7 +326,7 @@ namespace OpenRa
|
||||
if (map == currentMap)
|
||||
DrawDialogBackground(itemRect, "panel");
|
||||
|
||||
renderer.RegularFont.DrawText(map.Map.Title, new int2(r.Left + 60, y), Color.White);
|
||||
renderer.RegularFont.DrawText(rgbaRenderer, map.Map.Title, new int2(r.Left + 60, y), Color.White);
|
||||
var closureMap = map;
|
||||
AddButton(itemRect, _ => { currentMap = closureMap; mapPreviewDirty = true; });
|
||||
}
|
||||
@@ -444,11 +444,11 @@ namespace OpenRa
|
||||
}
|
||||
|
||||
var f = renderer.BoldFont;
|
||||
f.DrawText("Name", new int2(r.Left + 40, r.Top + 50), Color.White);
|
||||
f.DrawText("Color", new int2(r.Left + 140, r.Top + 50), Color.White);
|
||||
f.DrawText("Faction", new int2(r.Left + 220, r.Top + 50), Color.White);
|
||||
f.DrawText("Status", new int2(r.Left + 290, r.Top + 50), Color.White);
|
||||
f.DrawText("Spawn", new int2(r.Left + 390, r.Top + 50), Color.White);
|
||||
f.DrawText(rgbaRenderer, "Name", new int2(r.Left + 40, r.Top + 50), Color.White);
|
||||
f.DrawText(rgbaRenderer, "Color", new int2(r.Left + 140, r.Top + 50), Color.White);
|
||||
f.DrawText(rgbaRenderer, "Faction", new int2(r.Left + 220, r.Top + 50), Color.White);
|
||||
f.DrawText(rgbaRenderer, "Status", new int2(r.Left + 290, r.Top + 50), Color.White);
|
||||
f.DrawText(rgbaRenderer, "Spawn", new int2(r.Left + 390, r.Top + 50), Color.White);
|
||||
|
||||
var y = r.Top + 80;
|
||||
foreach (var client in Game.LobbyInfo.Clients)
|
||||
@@ -481,17 +481,19 @@ namespace OpenRa
|
||||
shpRenderer.Flush();
|
||||
|
||||
f = renderer.RegularFont;
|
||||
f.DrawText(client.Name, new int2(r.Left + 40, y), Color.White);
|
||||
f.DrawText(rgbaRenderer, client.Name, new int2(r.Left + 40, y), Color.White);
|
||||
lineRenderer.FillRect(RectangleF.FromLTRB(paletteRect.Left + Game.viewport.Location.X + 5,
|
||||
paletteRect.Top + Game.viewport.Location.Y + 5,
|
||||
paletteRect.Right + Game.viewport.Location.X - 5,
|
||||
paletteRect.Bottom+Game.viewport.Location.Y - 5),
|
||||
Player.PlayerColors[client.PaletteIndex].c);
|
||||
lineRenderer.Flush();
|
||||
f.DrawText(client.Country, new int2(r.Left + 220, y), Color.White);
|
||||
f.DrawText(client.State.ToString(), new int2(r.Left + 290, y), Color.White);
|
||||
f.DrawText((client.SpawnPoint == 0)? "-" : client.SpawnPoint.ToString(), new int2(r.Left + 410, y), Color.White);
|
||||
f.DrawText(rgbaRenderer, client.Country, new int2(r.Left + 220, y), Color.White);
|
||||
f.DrawText(rgbaRenderer, client.State.ToString(), new int2(r.Left + 290, y), Color.White);
|
||||
f.DrawText(rgbaRenderer, (client.SpawnPoint == 0) ? "-" : client.SpawnPoint.ToString(), new int2(r.Left + 410, y), Color.White);
|
||||
y += 30;
|
||||
|
||||
rgbaRenderer.Flush();
|
||||
}
|
||||
|
||||
var typingBox = new Rectangle(r.Left + 20, r.Bottom - 47, r.Width - 40, 27);
|
||||
@@ -740,7 +742,7 @@ namespace OpenRa
|
||||
shpRenderer.DrawSprite(optionsButton.Image, optionsDrawPos, "chrome");
|
||||
shpRenderer.Flush();
|
||||
|
||||
renderer.RegularFont.DrawText("Options", new int2((int)(optionsButton.Image.size.X - renderer.RegularFont.Measure("Options").X) / 2, -2), Color.White);
|
||||
renderer.RegularFont.DrawText(rgbaRenderer, "Options", new int2((int)(optionsButton.Image.size.X - renderer.RegularFont.Measure("Options").X) / 2, -2), Color.White);
|
||||
}
|
||||
|
||||
void DrawOptionsMenu()
|
||||
@@ -803,6 +805,8 @@ namespace OpenRa
|
||||
if (Game.chat.isChatting)
|
||||
RenderChatLine(Tuple.New(Color.White, "Chat:", Game.chat.typing),
|
||||
new int2(typingArea.X + 10, typingArea.Y + 6));
|
||||
|
||||
rgbaRenderer.Flush();
|
||||
renderer.Device.DisableScissor();
|
||||
|
||||
renderer.Device.EnableScissor(chatLogArea.Left, chatLogArea.Top, chatLogArea.Width, chatLogArea.Height);
|
||||
@@ -811,14 +815,16 @@ namespace OpenRa
|
||||
chatpos.Y -= 20;
|
||||
RenderChatLine(line, chatpos);
|
||||
}
|
||||
|
||||
rgbaRenderer.Flush();
|
||||
renderer.Device.DisableScissor();
|
||||
}
|
||||
|
||||
void RenderChatLine(Tuple<Color, string, string> line, int2 p)
|
||||
{
|
||||
var size = renderer.RegularFont.Measure(line.b);
|
||||
renderer.RegularFont.DrawText(line.b, p, line.a);
|
||||
renderer.RegularFont.DrawText(line.c, p + new int2(size.X + 10, 0), Color.White);
|
||||
renderer.RegularFont.DrawText(rgbaRenderer, line.b, p, line.a);
|
||||
renderer.RegularFont.DrawText(rgbaRenderer, line.c, p + new int2(size.X + 10, 0), Color.White);
|
||||
}
|
||||
|
||||
void TickPaletteAnimation()
|
||||
@@ -1064,12 +1070,12 @@ namespace OpenRa
|
||||
|
||||
void DrawRightAligned(string text, int2 pos, Color c)
|
||||
{
|
||||
renderer.BoldFont.DrawText(text, pos - new int2(renderer.BoldFont.Measure(text).X, 0), c);
|
||||
renderer.BoldFont.DrawText(rgbaRenderer, text, pos - new int2(renderer.BoldFont.Measure(text).X, 0), c);
|
||||
}
|
||||
|
||||
void DrawCentered(string text, int2 pos, Color c)
|
||||
{
|
||||
renderer.BoldFont.DrawText(text, pos - new int2(renderer.BoldFont.Measure(text).X / 2, 0), c);
|
||||
renderer.BoldFont.DrawText(rgbaRenderer, text, pos - new int2(renderer.BoldFont.Measure(text).X / 2, 0), c);
|
||||
}
|
||||
|
||||
void DrawProductionTooltip(World world, string unit, int2 pos)
|
||||
@@ -1077,12 +1083,12 @@ namespace OpenRa
|
||||
var tooltipSprite = ChromeProvider.GetImage(renderer, chromeCollection, "tooltip-bg");
|
||||
var p = pos.ToFloat2() - new float2(tooltipSprite.size.X, 0);
|
||||
rgbaRenderer.DrawSprite(tooltipSprite, p, "chrome");
|
||||
rgbaRenderer.Flush();
|
||||
|
||||
|
||||
var info = Rules.Info[unit];
|
||||
var buildable = info.Traits.Get<BuildableInfo>();
|
||||
|
||||
renderer.BoldFont.DrawText(buildable.Description, p.ToInt2() + new int2(5, 5), Color.White);
|
||||
renderer.BoldFont.DrawText(rgbaRenderer, buildable.Description, p.ToInt2() + new int2(5, 5), Color.White);
|
||||
|
||||
DrawRightAligned( "${0}".F(buildable.Cost), pos + new int2(-5,5),
|
||||
world.LocalPlayer.Cash + world.LocalPlayer.Ore >= buildable.Cost ? Color.White : Color.Red);
|
||||
@@ -1100,15 +1106,17 @@ namespace OpenRa
|
||||
{
|
||||
var prereqs = buildable.Prerequisites
|
||||
.Select( a => Description( a ) );
|
||||
renderer.RegularFont.DrawText("Requires {0}".F( string.Join( ", ", prereqs.ToArray() ) ), p.ToInt2(),
|
||||
renderer.RegularFont.DrawText(rgbaRenderer, "Requires {0}".F(string.Join(", ", prereqs.ToArray())), p.ToInt2(),
|
||||
Color.White);
|
||||
}
|
||||
|
||||
if (buildable.LongDesc != null)
|
||||
{
|
||||
p += new int2(0, 15);
|
||||
renderer.RegularFont.DrawText(buildable.LongDesc.Replace( "\\n", "\n" ), p.ToInt2(), Color.White);
|
||||
renderer.RegularFont.DrawText(rgbaRenderer, buildable.LongDesc.Replace( "\\n", "\n" ), p.ToInt2(), Color.White);
|
||||
}
|
||||
|
||||
rgbaRenderer.Flush();
|
||||
}
|
||||
|
||||
static string Description( string a )
|
||||
@@ -1201,7 +1209,7 @@ namespace OpenRa
|
||||
|
||||
pos += new int2(5, 5);
|
||||
|
||||
renderer.BoldFont.DrawText(sp.Info.Description, pos, Color.White);
|
||||
renderer.BoldFont.DrawText(rgbaRenderer, sp.Info.Description, pos, Color.White);
|
||||
|
||||
var timer = "Charge Time: {0}".F(FormatTime(sp.RemainingTime));
|
||||
DrawRightAligned(timer, pos + new int2((int)tooltipSprite.size.X - 10, 0), Color.White);
|
||||
@@ -1209,8 +1217,10 @@ namespace OpenRa
|
||||
if (sp.Info.LongDesc != null)
|
||||
{
|
||||
pos += new int2(0, 25);
|
||||
renderer.RegularFont.DrawText(sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
|
||||
renderer.RegularFont.DrawText(rgbaRenderer, sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
|
||||
}
|
||||
|
||||
rgbaRenderer.Flush();
|
||||
}
|
||||
|
||||
public void SetCurrentTab(string produces)
|
||||
|
||||
@@ -34,12 +34,12 @@ namespace OpenRa.Graphics
|
||||
try
|
||||
{
|
||||
var shp = new Dune2ShpReader(FileSystem.OpenWithExts(filename, exts));
|
||||
return shp.Select(a => SheetBuilder.Add(a.Image, a.Size)).ToArray();
|
||||
return shp.Select(a => SheetBuilder.SharedInstance.Add(a.Image, a.Size)).ToArray();
|
||||
}
|
||||
catch (IndexOutOfRangeException) // This will occur when loading a custom (RA-format) .shp
|
||||
{
|
||||
var shp = new ShpReader(FileSystem.OpenWithExts(filename, exts));
|
||||
return shp.Select(a => SheetBuilder.Add(a.Image, shp.Size)).ToArray();
|
||||
return shp.Select(a => SheetBuilder.SharedInstance.Add(a.Image, shp.Size)).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenRa.Graphics
|
||||
|
||||
public ITexture PaletteTexture;
|
||||
|
||||
public readonly IFont RegularFont, BoldFont;
|
||||
public readonly SpriteFont RegularFont, BoldFont;
|
||||
|
||||
public Size Resolution { get { return device.WindowSize; } }
|
||||
|
||||
@@ -56,8 +56,11 @@ namespace OpenRa.Graphics
|
||||
RgbaSpriteShader = device.CreateShader(FileSystem.Open("shaders/chrome-rgba.fx"));
|
||||
WorldSpriteShader = device.CreateShader(FileSystem.Open("shaders/chrome-shp.fx"));
|
||||
|
||||
RegularFont = device.CreateFont( "FreeSans.ttf" );
|
||||
BoldFont = device.CreateFont( "FreeSansBold.ttf" );
|
||||
// RegularFont = device.CreateFont( "FreeSans.ttf" );
|
||||
// BoldFont = device.CreateFont( "FreeSansBold.ttf" );
|
||||
|
||||
RegularFont = new SpriteFont(this, "FreeSans.ttf", 14);
|
||||
BoldFont = new SpriteFont(this, "FreeSansBold.ttf", 14);
|
||||
}
|
||||
|
||||
IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, bool windowed, bool vsync )
|
||||
|
||||
@@ -22,24 +22,31 @@ using System.Drawing;
|
||||
|
||||
namespace OpenRa.Graphics
|
||||
{
|
||||
static class SheetBuilder
|
||||
class SheetBuilder
|
||||
{
|
||||
public static SheetBuilder SharedInstance;
|
||||
public static void Initialize(Renderer r)
|
||||
{
|
||||
SharedInstance = new SheetBuilder(r, TextureChannel.Red);
|
||||
}
|
||||
|
||||
public SheetBuilder(Renderer r, TextureChannel ch)
|
||||
{
|
||||
renderer = r;
|
||||
current = null;
|
||||
rowHeight = 0;
|
||||
channel = null;
|
||||
initialChannel = ch;
|
||||
}
|
||||
|
||||
public static Sprite Add(byte[] src, Size size)
|
||||
public Sprite Add(byte[] src, Size size)
|
||||
{
|
||||
Sprite rect = AddImage(size);
|
||||
Sprite rect = Allocate(size);
|
||||
Util.FastCopyIntoChannel(rect, src);
|
||||
return rect;
|
||||
}
|
||||
|
||||
public static Sprite Add(Size size, byte paletteIndex)
|
||||
public Sprite Add(Size size, byte paletteIndex)
|
||||
{
|
||||
byte[] data = new byte[size.Width * size.Height];
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
@@ -48,18 +55,19 @@ namespace OpenRa.Graphics
|
||||
return Add(data, size);
|
||||
}
|
||||
|
||||
static Sheet NewSheet() { return new Sheet( renderer, new Size( Renderer.SheetSize, Renderer.SheetSize ) ); }
|
||||
Sheet NewSheet() { return new Sheet( renderer, new Size( Renderer.SheetSize, Renderer.SheetSize ) ); }
|
||||
|
||||
static Renderer renderer;
|
||||
static Sheet current = null;
|
||||
static int rowHeight = 0;
|
||||
static Point p;
|
||||
static TextureChannel? channel = null;
|
||||
Renderer renderer;
|
||||
Sheet current = null;
|
||||
int rowHeight = 0;
|
||||
Point p;
|
||||
TextureChannel? channel = null;
|
||||
TextureChannel initialChannel;
|
||||
|
||||
static TextureChannel? NextChannel(TextureChannel? t)
|
||||
TextureChannel? NextChannel(TextureChannel? t)
|
||||
{
|
||||
if (t == null)
|
||||
return TextureChannel.Red;
|
||||
return initialChannel;
|
||||
|
||||
switch (t.Value)
|
||||
{
|
||||
@@ -72,7 +80,7 @@ namespace OpenRa.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
static Sprite AddImage(Size imageSize)
|
||||
public Sprite Allocate(Size imageSize)
|
||||
{
|
||||
if (current == null)
|
||||
{
|
||||
|
||||
116
OpenRa.Game/Graphics/SpriteFont.cs
Normal file
116
OpenRa.Game/Graphics/SpriteFont.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRa.FileFormats;
|
||||
using Tao.FreeType;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenRa.Graphics
|
||||
{
|
||||
class SpriteFont
|
||||
{
|
||||
int size;
|
||||
public SpriteFont(Renderer r, string name, int size)
|
||||
{
|
||||
this.size = size;
|
||||
|
||||
if (0 != FT.FT_New_Face(library, name, 0, out face))
|
||||
throw new InvalidOperationException("FT_New_Face failed");
|
||||
|
||||
FT.FT_Set_Pixel_Sizes(face, 0, (uint)size);
|
||||
glyphs = new Cache<char, GlyphInfo>(CreateGlyph);
|
||||
|
||||
// setup a 1-channel SheetBuilder for our private use
|
||||
if (builder == null) builder = new SheetBuilder(r, TextureChannel.Alpha);
|
||||
|
||||
// precache glyphs for U+0020 - U+007f
|
||||
for (var n = (char)0x20; n < (char)0x7f; n++)
|
||||
if (glyphs[n] == null)
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public void DrawText(SpriteRenderer r, string text, float2 location, Color c)
|
||||
{
|
||||
location.Y += size; // baseline vs top
|
||||
|
||||
var p = location;
|
||||
foreach (var s in text)
|
||||
{
|
||||
if (s == '\n')
|
||||
{
|
||||
location.Y += size;
|
||||
p = location;
|
||||
continue;
|
||||
}
|
||||
|
||||
var g = glyphs[s];
|
||||
r.DrawSprite(g.Sprite,
|
||||
new float2(
|
||||
(int)Math.Round(p.X + g.Offset.X, 0),
|
||||
p.Y + g.Offset.Y),
|
||||
"chrome");
|
||||
p.X += g.Advance;
|
||||
}
|
||||
|
||||
r.Flush();
|
||||
}
|
||||
|
||||
public int2 Measure(string text)
|
||||
{
|
||||
return new int2((int)text.Split( '\n' ).Max( s => s.Sum(a => glyphs[a].Advance)), size);
|
||||
}
|
||||
|
||||
Cache<char, GlyphInfo> glyphs;
|
||||
IntPtr face;
|
||||
|
||||
GlyphInfo CreateGlyph(char c)
|
||||
{
|
||||
var index = FT.FT_Get_Char_Index(face, (uint)c);
|
||||
FT.FT_Load_Glyph(face, index, FT.FT_LOAD_RENDER);
|
||||
|
||||
var _face = (FT_FaceRec)Marshal.PtrToStructure(face, typeof(FT_FaceRec));
|
||||
var _glyph = (FT_GlyphSlotRec)Marshal.PtrToStructure(_face.glyph, typeof(FT_GlyphSlotRec));
|
||||
|
||||
var s = builder.Allocate(new Size(_glyph.metrics.width >> 6, _glyph.metrics.height >> 6));
|
||||
|
||||
var g = new GlyphInfo
|
||||
{
|
||||
Sprite = s,
|
||||
Advance = _glyph.metrics.horiAdvance / 64f,
|
||||
Offset = { X = _glyph.bitmap_left, Y = -_glyph.bitmap_top }
|
||||
};
|
||||
|
||||
unsafe
|
||||
{
|
||||
var p = (byte*)_glyph.bitmap.buffer;
|
||||
|
||||
for (var j = 0; j < s.size.Y; j++)
|
||||
{
|
||||
for (var i = 0; i < s.size.X; i++)
|
||||
if (p[i] != 0)
|
||||
s.sheet.Bitmap.SetPixel(i + s.bounds.Left, j + s.bounds.Top,
|
||||
Color.FromArgb(p[i], 0xff, 0xff, 0xff));
|
||||
|
||||
p += _glyph.bitmap.pitch;
|
||||
}
|
||||
}
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
static SpriteFont()
|
||||
{
|
||||
FT.FT_Init_FreeType(out library);
|
||||
}
|
||||
|
||||
static IntPtr library;
|
||||
static SheetBuilder builder;
|
||||
}
|
||||
|
||||
class GlyphInfo
|
||||
{
|
||||
public float Advance;
|
||||
public int2 Offset;
|
||||
public Sprite Sprite;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace OpenRa.Graphics
|
||||
static Sprite[] LoadSprites(string filename)
|
||||
{
|
||||
var shp = new ShpReader(FileSystem.OpenWithExts(filename, exts));
|
||||
return shp.Select(a => SheetBuilder.Add(a.Image, shp.Size)).ToArray();
|
||||
return shp.Select(a => SheetBuilder.SharedInstance.Add(a.Image, shp.Size)).ToArray();
|
||||
}
|
||||
|
||||
public static Sprite[] LoadAllSprites(string filename) { return sprites[filename]; }
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenRa.Graphics
|
||||
Size tileSize = new Size( Game.CellSize, Game.CellSize );
|
||||
|
||||
var tileMapping = new Cache<TileReference, Sprite>(
|
||||
x => SheetBuilder.Add(world.TileSet.GetBytes(x), tileSize));
|
||||
x => SheetBuilder.SharedInstance.Add(world.TileSet.GetBytes(x), tileSize));
|
||||
|
||||
Vertex[] vertices = new Vertex[4 * map.Height * map.Width];
|
||||
ushort[] indices = new ushort[6 * map.Height * map.Width];
|
||||
|
||||
@@ -65,11 +65,8 @@
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Tao.FreeType, Version=2.3.5.0, Culture=neutral, PublicKeyToken=e499629dc69cd531, processorArchitecture=MSIL" />
|
||||
<Reference Include="Tao.OpenAl, Version=1.1.0.1, Culture=neutral, PublicKeyToken=a7579dda88828311, processorArchitecture=MSIL" />
|
||||
<Reference Include="ISE.FreeType, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1b34ab585684d5ea">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\thirdparty\ISE.FreeType.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Chat.cs" />
|
||||
@@ -93,6 +90,7 @@
|
||||
<Compile Include="Graphics\ChromeProvider.cs" />
|
||||
<Compile Include="Graphics\MappedImage.cs" />
|
||||
<Compile Include="Graphics\Minimap.cs" />
|
||||
<Compile Include="Graphics\SpriteFont.cs" />
|
||||
<Compile Include="Network\Connection.cs" />
|
||||
<Compile Include="Orders\PowerDownOrderGenerator.cs" />
|
||||
<Compile Include="Effects\Missile.cs" />
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace OpenRa.Traits
|
||||
{
|
||||
cachedTheater = world.Map.Theater;
|
||||
sprites = new Cache<TileReference, Sprite>(
|
||||
x => SheetBuilder.Add(world.TileSet.GetBytes(x),
|
||||
x => SheetBuilder.SharedInstance.Add(world.TileSet.GetBytes(x),
|
||||
new Size(Game.CellSize, Game.CellSize)));
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenRa
|
||||
for (int j = 0; j < Game.CellSize; j++)
|
||||
data[i * Game.CellSize + j] = ((i + j) % 4 < 2) ? (byte)0 : paletteIndex;
|
||||
|
||||
return SheetBuilder.Add( data, new Size(Game.CellSize,Game.CellSize) );
|
||||
return SheetBuilder.SharedInstance.Add(data, new Size(Game.CellSize, Game.CellSize));
|
||||
}
|
||||
|
||||
public void Draw( World world )
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Copyright & License Information
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
@@ -28,7 +28,6 @@ using Tao.Cg;
|
||||
using Tao.OpenGl;
|
||||
using OpenRa.FileFormats.Graphics;
|
||||
using Tao.Sdl;
|
||||
using ISE;
|
||||
|
||||
[assembly: Renderer( typeof( OpenRa.GlRenderer.GraphicsDevice ))]
|
||||
|
||||
@@ -60,9 +59,12 @@ namespace OpenRa.GlRenderer
|
||||
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_BLUE_SIZE, 8);
|
||||
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_ALPHA_SIZE, 8);
|
||||
|
||||
Environment.SetEnvironmentVariable("SDL_VIDEO_WINDOW_POS", "0,0");
|
||||
|
||||
surf = Sdl.SDL_SetVideoMode(width, height, 0, Sdl.SDL_NOFRAME | Sdl.SDL_OPENGL | (windowed ? 0 : Sdl.SDL_FULLSCREEN));
|
||||
// Breaks os x usability
|
||||
//Environment.SetEnvironmentVariable("SDL_VIDEO_WINDOW_POS", "0,0");
|
||||
//surf = Sdl.SDL_SetVideoMode(width, height, 0, Sdl.SDL_NOFRAME | Sdl.SDL_OPENGL | (windowed ? 0 : Sdl.SDL_FULLSCREEN));
|
||||
surf = Sdl.SDL_SetVideoMode(width, height, 0, Sdl.SDL_OPENGL | (windowed ? 0 : Sdl.SDL_FULLSCREEN));
|
||||
|
||||
Sdl.SDL_WM_SetCaption("OpenRA", "OpenRA");
|
||||
Sdl.SDL_ShowCursor(0);
|
||||
Sdl.SDL_EnableUNICODE( 1 );
|
||||
@@ -265,11 +267,6 @@ namespace OpenRa.GlRenderer
|
||||
return new Shader( this, stream );
|
||||
}
|
||||
|
||||
public IFont CreateFont( string filename )
|
||||
{
|
||||
return new Font( this, filename );
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -453,63 +450,4 @@ namespace OpenRa.GlRenderer
|
||||
bitmap.UnlockBits(bits);
|
||||
}
|
||||
}
|
||||
|
||||
class Font : IFont
|
||||
{
|
||||
const int RenderedFontSize = 48;
|
||||
const float emHeight = 14f; /* px */
|
||||
|
||||
GraphicsDevice dev;
|
||||
FTFontGL font;
|
||||
|
||||
public Font( GraphicsDevice dev, string filename )
|
||||
{
|
||||
this.dev = dev;
|
||||
int Errors;
|
||||
font = new FTFontGL(filename, out Errors);
|
||||
|
||||
if (Errors > 0)
|
||||
throw new InvalidOperationException("Error(s) loading font");
|
||||
|
||||
font.ftRenderToTexture(RenderedFontSize, 192);
|
||||
font.FT_ALIGN = FTFontAlign.FT_ALIGN_LEFT;
|
||||
}
|
||||
|
||||
public void DrawText( string text, int2 pos, Color c )
|
||||
{
|
||||
pos.Y += (int)(emHeight);
|
||||
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW);
|
||||
Gl.glPushMatrix();
|
||||
Gl.glLoadIdentity();
|
||||
|
||||
Gl.glMatrixMode(Gl.GL_PROJECTION);
|
||||
Gl.glPushMatrix();
|
||||
Gl.glLoadIdentity();
|
||||
|
||||
Gl.glOrtho(0, dev.WindowSize.Width, 0, dev.WindowSize.Height, 0, 1);
|
||||
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW);
|
||||
Gl.glTranslatef(pos.X, dev.WindowSize.Height - pos.Y, 0);
|
||||
Gl.glScalef(emHeight / RenderedFontSize, emHeight / RenderedFontSize, 1);
|
||||
|
||||
font.ftBeginFont(false);
|
||||
Gl.glColor4f(c.R / 255f, c.G / 255f, c.B / 255f, c.A / 255f);
|
||||
font.ftWrite(text);
|
||||
font.ftEndFont();
|
||||
|
||||
Gl.glMatrixMode(Gl.GL_PROJECTION);
|
||||
Gl.glPopMatrix();
|
||||
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW);
|
||||
Gl.glPopMatrix();
|
||||
|
||||
GraphicsDevice.CheckGlError();
|
||||
}
|
||||
|
||||
public int2 Measure( string text )
|
||||
{
|
||||
return new int2((int)(font.ftExtent(ref text) / 3), (int)emHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,22 +31,12 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ISE.FreeType, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1b34ab585684d5ea, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\thirdparty\ISE.FreeType.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Tao.Cg, Version=2.0.0.0, Culture=neutral, PublicKeyToken=52fa5aba625fe731, processorArchitecture=MSIL">
|
||||
@@ -55,9 +45,6 @@
|
||||
<Reference Include="Tao.OpenGl, Version=2.1.0.12, Culture=neutral, PublicKeyToken=1ca010269a4501ef, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Tao.Platform.Windows, Version=1.0.0.5, Culture=neutral, PublicKeyToken=701104b2da67a104, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Tao.Sdl, Version=1.2.13.0, Culture=neutral, PublicKeyToken=9c7a200e36c0094e, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
BIN
packaging/osx/dmgsource/.background/bg.png
Normal file
BIN
packaging/osx/dmgsource/.background/bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
BIN
packaging/osx/osx-dmgbg.xcf
Normal file
BIN
packaging/osx/osx-dmgbg.xcf
Normal file
Binary file not shown.
42
packaging/osx/package_dmg.sh
Executable file
42
packaging/osx/package_dmg.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
source=./packaging/osx/dmgsource/
|
||||
title=OpenRA
|
||||
size=70m
|
||||
dmgName=OpenRA.dmg
|
||||
|
||||
mv openra_server ${source}
|
||||
mv OpenRA.app ${source}
|
||||
|
||||
hdiutil create -srcfolder "${source}" -volname "${title}" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${size} temp.dmg
|
||||
sleep 2
|
||||
device=$(hdiutil attach -readwrite -noverify -noautoopen "temp.dmg" | egrep '^/dev/' | sed 1q | awk '{print $1}')
|
||||
echo '
|
||||
tell application "Finder"
|
||||
tell disk "'${title}'"
|
||||
open
|
||||
set current view of container window to icon view
|
||||
set toolbar visible of container window to false
|
||||
set statusbar visible of container window to false
|
||||
set the bounds of container window to {400, 100, 885, 430}
|
||||
set theViewOptions to the icon view options of container window
|
||||
set arrangement of theViewOptions to not arranged
|
||||
set icon size of theViewOptions to 72
|
||||
set background picture of theViewOptions to file ".background:bg.png"
|
||||
make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
|
||||
set position of item "OpenRA.app" of container window to {100, 90}
|
||||
set position of item "openra_server" of container window to {100, 210}
|
||||
set position of item "Applications" of container window to {375, 150}
|
||||
close
|
||||
open
|
||||
update without registering applications
|
||||
delay 5
|
||||
end tell
|
||||
end tell
|
||||
' | osascript
|
||||
sleep 5
|
||||
chmod -Rf go-w /Volumes/"${title}"
|
||||
sync
|
||||
hdiutil detach ${device}
|
||||
hdiutil convert "./temp.dmg" -format UDZO -imagekey zlib-level=9 -o "${dmgName}"
|
||||
rm -f ./temp.dmg
|
||||
rm -rf ${source}OpenRA.app
|
||||
rm -f ${source}openra_server
|
||||
BIN
thirdparty/ISE.FreeType.dll
vendored
BIN
thirdparty/ISE.FreeType.dll
vendored
Binary file not shown.
7
thirdparty/ISE.FreeType.dll.config
vendored
7
thirdparty/ISE.FreeType.dll.config
vendored
@@ -1,7 +0,0 @@
|
||||
<configuration>
|
||||
<dllmap dll="freetype6.dll">
|
||||
<dllentry os="linux" dll="libfreetype.so.6" />
|
||||
<dllentry os="windows" dll="freetype6.dll" />
|
||||
<dllentry os="osx" dll="/usr/X11/lib/libfreetype.6.dylib" />
|
||||
</dllmap>
|
||||
</configuration>
|
||||
BIN
thirdparty/Tao.Externals.dll
vendored
BIN
thirdparty/Tao.Externals.dll
vendored
Binary file not shown.
12
thirdparty/Tao.Externals.dll.config
vendored
12
thirdparty/Tao.Externals.dll.config
vendored
@@ -1,12 +0,0 @@
|
||||
<configuration>
|
||||
<dllmap dll="freetype6.dll">
|
||||
<dllentry os="linux" dll="libfreetype.so.6" />
|
||||
<dllentry os="windows" dll="freetype6.dll" />
|
||||
<dllentry os="osx" dll="/usr/X11/lib/libfreetype.6.dylib" />
|
||||
</dllmap>
|
||||
</configuration>
|
||||
<dllmap dll="OpenAL32.dll">
|
||||
<dllentry os="linux" dll="libopenal.so.1" />
|
||||
<dllentry os="windows" dll="OpenAL32.dll" />
|
||||
<dllentry os="osx" dll="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
</dllmap>
|
||||
Reference in New Issue
Block a user