1.0.11
+ Windows now have a default icon ~ Changed CVector.Set(params float[]) to CVector.SetRaw(params float[]) ~ I hope, the text rendering is now fixed. ~ Mouse2D.InWorld(Camera) now uses Camera.CalculatedWorldScale.
This commit is contained in:
parent
a921eb827e
commit
51f8dfd522
14 changed files with 78 additions and 24 deletions
|
|
@ -84,7 +84,7 @@ namespace SM.Base.Animation
|
|||
|
||||
private void SetTarget(Vector4 vec)
|
||||
{
|
||||
TargetVector.Set(vec.X, vec.Y, vec.Z, vec.W);
|
||||
TargetVector.SetRaw(vec.X, vec.Y, vec.Z, vec.W);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,5 +27,8 @@ namespace SM.Base.Drawing.Text
|
|||
|
||||
|
||||
public Matrix3 TextureMatrix;
|
||||
|
||||
public Vector2 Offset;
|
||||
public Vector2 Scale;
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ namespace SM.Base.Drawing.Text
|
|||
_fontFace.LoadChar(c, LoadFlags.Render, LoadTarget.Normal);
|
||||
|
||||
pos.Add(c, new []{(float)_fontFace.Glyph.Bitmap.Width, Width});
|
||||
Width += (int)_fontFace.Glyph.Advance.X + 5;
|
||||
Width += (int)_fontFace.Glyph.Advance.X + 2;
|
||||
Height = Math.Max(_fontFace.Glyph.Bitmap.Rows, Height);
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ namespace SM.Base.Drawing.Text
|
|||
|
||||
float bBoxHeight = (Math.Abs(_fontFace.BBox.Bottom) + _fontFace.BBox.Top);
|
||||
float bBoxTopScale = _fontFace.BBox.Top / bBoxHeight;
|
||||
float baseline = Height * bBoxTopScale;
|
||||
float baseline = Height * bBoxTopScale + 1;
|
||||
|
||||
Map = new Bitmap(Width, Height);
|
||||
using (Graphics g = Graphics.FromImage(Map))
|
||||
|
|
@ -72,6 +72,8 @@ namespace SM.Base.Drawing.Text
|
|||
|
||||
g.DrawImageUnscaled(_fontFace.Glyph.Bitmap.ToGdipBitmap(Color.White), (int)keyvalue.Value[1], y);
|
||||
|
||||
Vector2 offset = new Vector2(keyvalue.Value[1] / Width, 0);
|
||||
Vector2 scale = new Vector2(keyvalue.Value[0] / Width, 1);
|
||||
Positions.Add(keyvalue.Key, new CharParameter()
|
||||
{
|
||||
Advance = (int)_fontFace.Glyph.LinearHorizontalAdvance,
|
||||
|
|
@ -79,8 +81,11 @@ namespace SM.Base.Drawing.Text
|
|||
|
||||
Width = keyvalue.Value[0],
|
||||
|
||||
TextureMatrix = TextureTransformation.CalculateMatrix(new Vector2(keyvalue.Value[1] / Width, 0),
|
||||
new Vector2(keyvalue.Value[0] / Width, 1), 0),
|
||||
TextureMatrix = TextureTransformation.CalculateMatrix(offset,
|
||||
scale, 0),
|
||||
|
||||
Offset = offset,
|
||||
Scale = scale
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ namespace SM.Base.Drawing.Text
|
|||
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
var _last = new CharParameter();
|
||||
for (var i = 0; i < _text.Length; i++)
|
||||
{
|
||||
|
||||
|
|
@ -144,18 +143,16 @@ namespace SM.Base.Drawing.Text
|
|||
}
|
||||
|
||||
var matrix = Matrix4.CreateScale(parameter.Width, Font.Height, 1) *
|
||||
Matrix4.CreateTranslation(x, -y, 0);
|
||||
Matrix4.CreateTranslation(x + parameter.Width / 2, -y, 0);
|
||||
_instances[i] = new Instance
|
||||
{
|
||||
ModelMatrix = matrix,
|
||||
TextureMatrix = parameter.TextureMatrix
|
||||
};
|
||||
|
||||
x += Math.Max(parameter.Advance, 6);
|
||||
_last = parameter;
|
||||
Width = Math.Max(Width, x);
|
||||
x += parameter.Advance;
|
||||
}
|
||||
|
||||
Width = Math.Max(Width, x);
|
||||
Height = y + Font.Height;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,9 @@
|
|||
<EmbeddedResource Include="Shaders\Extensions\fragment\textureGamma.glsl" />
|
||||
<EmbeddedResource Include="Shaders\Extensions\fragment\noise.glsl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Window\winIcon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Set(params float[] parameters)
|
||||
public override void SetRaw(params float[] parameters)
|
||||
{
|
||||
X = parameters[0];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,9 +87,9 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Set(params float[] parameters)
|
||||
public override void SetRaw(params float[] parameters)
|
||||
{
|
||||
base.Set(parameters);
|
||||
base.SetRaw(parameters);
|
||||
Y = parameters[1];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Set(params float[] parameters)
|
||||
public override void SetRaw(params float[] parameters)
|
||||
{
|
||||
base.Set(parameters);
|
||||
base.SetRaw(parameters);
|
||||
Z = parameters[2];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ namespace SM.Base.Types
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Set(params float[] parameters)
|
||||
public override void SetRaw(params float[] parameters)
|
||||
{
|
||||
base.Set(parameters);
|
||||
base.SetRaw(parameters);
|
||||
W = parameters[3];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace SM.Base.Types
|
|||
/// Sets the values of the vector, by providing the values over an array.
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
public abstract void Set(params float[] parameters);
|
||||
public abstract void SetRaw(params float[] parameters);
|
||||
|
||||
/// <summary>
|
||||
/// This triggers the <see cref="Changed"/> event.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
|
@ -138,9 +139,15 @@ namespace SM.Base.Window
|
|||
Loading = false;
|
||||
Loaded?.Invoke(this);
|
||||
AppliedSetup?.Loaded(this);
|
||||
OnLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnLoaded()
|
||||
{
|
||||
Icon ??= new Icon(AssemblyUtility.GetAssemblyStream("SM.Base.Window.winIcon.ico"));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
|
|
|
|||
BIN
SMCode/SM.Base/Window/winIcon.ico
Normal file
BIN
SMCode/SM.Base/Window/winIcon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
|
|
@ -28,7 +28,7 @@ namespace SM2D.Controls
|
|||
/// </summary>
|
||||
public static Vector2 InWorld(Camera cam)
|
||||
{
|
||||
return InWorld(cam.WorldScale) + cam.Position;
|
||||
return InWorld(cam.CalculatedWorldScale) + cam.Position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue