Renderer:
+ Font.BaselineAdjust Utils: + GameControllerState.AnyInteractions
This commit is contained in:
parent
89de4258e1
commit
dffa581596
18 changed files with 70 additions and 40 deletions
|
|
@ -11,9 +11,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM2D", "src\renderer\SM2D\S
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_TEST", "tests\SM_TEST\SM_TEST.csproj", "{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Utils", "src\optionals\SM.Utils\SM.Utils.csproj", "{079BAB31-3DC4-40DA-90C7-EFAA8517C647}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMRenderer.Utils", "src\optionals\SM.Utils\SMRenderer.Utils.csproj", "{079BAB31-3DC4-40DA-90C7-EFAA8517C647}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Intergrations", "src\optionals\SM.Intergrations\SM.Intergrations.csproj", "{4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMRenderer.Intergrations", "src\optionals\SM.Intergrations\SMRenderer.Intergrations.csproj", "{4CB351F4-B3F2-4F77-ACC2-02F21DBF5EC2}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Renderer", "Renderer", "{62ED6240-4DEC-4535-95EB-AE3D90A3FDF5}"
|
||||
EndProject
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using SharpDX.XInput;
|
||||
|
||||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public struct GameController
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
using OpenTK;
|
||||
using SharpDX.XInput;
|
||||
|
||||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public struct GameControllerState
|
||||
{
|
||||
|
|
@ -12,7 +12,7 @@ namespace SM.Optionals.Controls
|
|||
public GameControllerStateButtons Buttons;
|
||||
|
||||
public bool FromConnected { get; }
|
||||
|
||||
public bool AnyInteraction => Buttons.AnyInteraction || DPad.AnyInteraction || Triggers.AnyInteraction || Thumbs.AnyInteraction;
|
||||
internal GameControllerState(bool empty)
|
||||
{
|
||||
FromConnected = false;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using SharpDX.XInput;
|
||||
|
||||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public struct GameControllerStateButtons
|
||||
{
|
||||
|
|
@ -19,8 +19,13 @@ namespace SM.Optionals.Controls
|
|||
public bool LeftThumb;
|
||||
public bool RightThumb;
|
||||
|
||||
public bool Start;
|
||||
public bool Back;
|
||||
|
||||
public bool this[GamepadButtonFlags flags] => _buttonFlags.HasFlag(flags);
|
||||
|
||||
public bool AnyInteraction { get; }
|
||||
|
||||
internal GameControllerStateButtons(GamepadButtonFlags flags)
|
||||
{
|
||||
_buttonFlags = flags;
|
||||
|
|
@ -35,6 +40,11 @@ namespace SM.Optionals.Controls
|
|||
|
||||
LeftThumb = flags.HasFlag(GamepadButtonFlags.LeftThumb);
|
||||
RightThumb = flags.HasFlag(GamepadButtonFlags.RightThumb);
|
||||
|
||||
Start = flags.HasFlag(GamepadButtonFlags.Start);
|
||||
Back = flags.HasFlag(GamepadButtonFlags.Back);
|
||||
|
||||
AnyInteraction = (int) flags >= 16;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using SharpDX.XInput;
|
||||
|
||||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public struct GameControllerStateDPad
|
||||
{
|
||||
|
|
@ -11,12 +11,16 @@ namespace SM.Optionals.Controls
|
|||
public bool Left;
|
||||
public bool Right;
|
||||
|
||||
public bool AnyInteraction { get; }
|
||||
|
||||
internal GameControllerStateDPad(GamepadButtonFlags flags)
|
||||
{
|
||||
Up = flags.HasFlag(GamepadButtonFlags.DPadUp);
|
||||
Down = flags.HasFlag(GamepadButtonFlags.DPadDown);
|
||||
Left = flags.HasFlag(GamepadButtonFlags.DPadLeft);
|
||||
Right = flags.HasFlag(GamepadButtonFlags.DPadRight);
|
||||
|
||||
AnyInteraction = (int)flags > 0 && (int) flags < 16;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using OpenTK;
|
||||
|
||||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public struct GameControllerStateThumbs
|
||||
{
|
||||
|
|
@ -13,6 +13,8 @@ namespace SM.Optionals.Controls
|
|||
public bool PressedLeft;
|
||||
public bool PressedRight;
|
||||
|
||||
public bool AnyInteraction => Left != Vector2.Zero || Right != Vector2.Zero || PressedLeft || PressedRight;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Left: ({Left.X}; {Left.Y}){(PressedLeft ? " Pressed" : "")}; Right: ({Right.X}; {Right.Y}){(PressedRight ? " Pressed" : "")}";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public struct GameControllerStateTriggers
|
||||
{
|
||||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
public float Left;
|
||||
public float Right;
|
||||
|
||||
public bool AnyInteraction => Left != 0f || Right != 0f;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Left: {Left}; Right: {Right}";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public class GameKeybind
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using OpenTK.Input;
|
||||
|
||||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public enum GameKeybindActorType
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using OpenTK.Input;
|
||||
|
||||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public struct GameKeybindContext
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public class GameKeybindHost
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SM.Optionals.Controls
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public class GameKeybindList : List<KeyValuePair<string, GameKeybind>>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,9 +39,16 @@ namespace SM.Base.Drawing
|
|||
/// <summary>
|
||||
/// Returns the current model matrix.
|
||||
/// </summary>
|
||||
/// <param name="force">If set to true, it will always (re-)calculate the model matrix.</param>
|
||||
/// <returns></returns>
|
||||
public Matrix4 GetMatrix()
|
||||
public Matrix4 GetMatrix(bool force = false)
|
||||
{
|
||||
if (force)
|
||||
{
|
||||
_lastFrame = SMRenderer.CurrentFrame;
|
||||
return _modelMatrix = RequestMatrix();
|
||||
}
|
||||
|
||||
if (Ignore) return Matrix4.Identity;
|
||||
|
||||
if (_lastFrame != SMRenderer.CurrentFrame)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@ namespace SM.Base.Drawing.Text
|
|||
/// </summary>
|
||||
public float FontSize { get; set; } = 12;
|
||||
|
||||
/// <summary>
|
||||
/// Allows to adjust the baseline to fix clipping issues.
|
||||
/// <para>Due to some issues with the calculations, this is a temporary fix.</para>
|
||||
/// </summary>
|
||||
public float BaselineAdjust { get; set; } = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// The character positions.
|
||||
/// </summary>
|
||||
|
|
@ -64,6 +70,8 @@ namespace SM.Base.Drawing.Text
|
|||
public void RegenerateTexture()
|
||||
{
|
||||
Width = Height = 0;
|
||||
|
||||
//Height = Math.Abs(_fontFace.BBox.Bottom) + _fontFace.BBox.Top;
|
||||
Positions = new Dictionary<char, CharParameter>();
|
||||
|
||||
_fontFace.SetCharSize(0, FontSize, 0, 96);
|
||||
|
|
@ -83,7 +91,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 + 1;
|
||||
float baseline = (Height * bBoxTopScale) + BaselineAdjust;
|
||||
|
||||
Map = new Bitmap(Width, Height);
|
||||
using (Graphics g = Graphics.FromImage(Map))
|
||||
|
|
@ -95,8 +103,7 @@ namespace SM.Base.Drawing.Text
|
|||
{
|
||||
_fontFace.LoadChar(keyvalue.Key, LoadFlags.Render, LoadTarget.Normal);
|
||||
|
||||
int y = ((int)baseline - (int)_fontFace.Glyph.Metrics.HorizontalBearingY);
|
||||
|
||||
int y = ((int)baseline - (int) _fontFace.Glyph.Metrics.HorizontalBearingY);
|
||||
g.DrawImageUnscaled(_fontFace.Glyph.Bitmap.ToGdipBitmap(Color.White), (int)keyvalue.Value[1], y);
|
||||
|
||||
Vector2 offset = new Vector2(keyvalue.Value[1] / Width, 0);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ using SM.Base.Drawing;
|
|||
using SM.Base.Time;
|
||||
using SM.Base.Window;
|
||||
using SM.Intergrations.ShaderTool;
|
||||
using SM.Utils.Controls;
|
||||
using SM2D;
|
||||
using SM2D.Controls;
|
||||
using SM2D.Drawing;
|
||||
|
|
@ -37,9 +38,13 @@ namespace SM_TEST
|
|||
public static STPProject portal;
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Font font = new Font(@"C:\Windows\Fonts\Arial.ttf")
|
||||
Font font = new Font(@".\GapSansBold.ttf")
|
||||
{
|
||||
FontSize = 30,
|
||||
FontSize = 51,
|
||||
CharSet = new char[]
|
||||
{
|
||||
'I', 'A','M','T','W','O'
|
||||
}
|
||||
};
|
||||
font.RegenerateTexture();
|
||||
|
||||
|
|
@ -58,18 +63,10 @@ namespace SM_TEST
|
|||
{
|
||||
|
||||
};
|
||||
DrawObject2D obj = new DrawObject2D()
|
||||
{
|
||||
Material = new STMaterial(portal.DrawNodes.First(a => a.Variables.ContainsKey("_MATColor")))
|
||||
{
|
||||
ShaderArguments = {
|
||||
{ "RingLoc", .33f },
|
||||
|
||||
}
|
||||
},
|
||||
Mesh = Polygon.GenerateCircle()
|
||||
};
|
||||
obj.Transform.Size.Set(200);
|
||||
|
||||
DrawText obj = new DrawText(font, "I AM\n\tTWO")
|
||||
{};
|
||||
|
||||
scene.Objects.Add(obj);
|
||||
|
||||
window.UpdateFrame += WindowOnUpdateFrame;
|
||||
|
|
@ -86,12 +83,8 @@ namespace SM_TEST
|
|||
|
||||
private static void WindowOnUpdateFrame(object sender, FrameEventArgs e)
|
||||
{
|
||||
/*
|
||||
if (Mouse.LeftClick)
|
||||
particles.Trigger();
|
||||
if (Mouse.RightClick)
|
||||
particles.ContinuousInterval = .05f;*/
|
||||
|
||||
bool interactions = new GameController(0).GetState().AnyInteraction;
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -73,9 +73,13 @@
|
|||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\optionals\SM.Intergrations\SM.Intergrations.csproj">
|
||||
<ProjectReference Include="..\..\src\optionals\SM.Intergrations\SMRenderer.Intergrations.csproj">
|
||||
<Project>{4cb351f4-b3f2-4f77-acc2-02f21dbf5ec2}</Project>
|
||||
<Name>SM.Intergrations</Name>
|
||||
<Name>SMRenderer.Intergrations</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\optionals\SM.Utils\SMRenderer.Utils.csproj">
|
||||
<Project>{079BAB31-3DC4-40DA-90C7-EFAA8517C647}</Project>
|
||||
<Name>SMRenderer.Utils</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\renderer\SM.Base\SM.Base.csproj">
|
||||
<Project>{8e733844-4204-43e7-b3dc-3913cddabb0d}</Project>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue