Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added MonoGame.Framework.arm64.dll
Binary file not shown.
Binary file added MonoGame.Framework.x64.dll
Binary file not shown.
9 changes: 4 additions & 5 deletions Wobble.Tests/Wobble.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.Extensions" Version="4.3.0" />
Expand All @@ -23,10 +24,8 @@
<None Update="Content\exo2-regular_0.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Reference Include="MonoGame.Framework">
<HintPath>..\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Include="MonoGame.Framework">
<HintPath>..\MonoGame.Framework.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
30 changes: 11 additions & 19 deletions Wobble.Tests/WobbleTestsGame.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Wobble.Graphics;
using Wobble.Graphics.BitmapFonts;
using Wobble.Graphics.Sprites;
using Wobble.Graphics.Sprites.Text;
using Wobble.Graphics.UI.Debugging;
Expand All @@ -24,7 +22,7 @@ public class WobbleTestsGame : WobbleGame

private FpsCounter FpsCounter { get; set; }

private SpriteText WaylandState { get; set; }
private SpriteTextPlus WaylandState { get; set; }

public WobbleTestsGame() : base(true)
{
Expand Down Expand Up @@ -72,36 +70,30 @@ protected override void LoadContent()

Resources.AddStore(new DllResourceStore("Wobble.Tests.Resources.dll"));

if (!BitmapFontFactory.CustomFonts.ContainsKey("exo2-bold"))
BitmapFontFactory.AddFont("exo2-bold", GameBase.Game.Resources.Get("Wobble.Tests.Resources/Fonts/exo2-bold.ttf"));

if (!BitmapFontFactory.CustomFonts.ContainsKey("exo2-regular"))
BitmapFontFactory.AddFont("exo2-regular", GameBase.Game.Resources.Get("Wobble.Tests.Resources/Fonts/exo2-regular.ttf"));

if (!BitmapFontFactory.CustomFonts.ContainsKey("exo2-semibold"))
BitmapFontFactory.AddFont("exo2-semibold", GameBase.Game.Resources.Get("Wobble.Tests.Resources/Fonts/exo2-semibold.ttf"));

if (!BitmapFontFactory.CustomFonts.ContainsKey("exo2-medium"))
BitmapFontFactory.AddFont("exo2-medium", GameBase.Game.Resources.Get("Wobble.Tests.Resources/Fonts/exo2-medium.ttf"));
var fonts = new List<string> { "exo2-bold", "exo2-regular", "exo2-semibold", "exo2-medium" };
foreach (var fontName in fonts)
{
FontManager.CacheWobbleFont(fontName, new WobbleFontStore(20, GameBase.Game.Resources.Get($"Wobble.Tests.Resources/Fonts/{fontName}.ttf")));
}

var font = new WobbleFontStore(20, GameBase.Game.Resources.Get("Wobble.Tests.Resources/Fonts/exo2-semibold.ttf"), new Dictionary<string, byte[]>()
var japaneseFont = new WobbleFontStore(20, GameBase.Game.Resources.Get("Wobble.Tests.Resources/Fonts/exo2-semibold.ttf"), new Dictionary<string, byte[]>()
{
{"Emoji", GameBase.Game.Resources.Get("Wobble.Tests.Resources/Fonts/symbola-emoji.ttf")},
{"Japanese", GameBase.Game.Resources.Get("Wobble.Tests.Resources/Fonts/droid-sans-japanese.ttf")}
});

FontManager.CacheWobbleFont("exo2-semibold", font);
FontManager.CacheWobbleFont("exo2-semibold-japanese", japaneseFont);

IsReadyToUpdate = true;

FpsCounter = new FpsCounter(FontManager.LoadBitmapFont("Content/gotham"), 18)
FpsCounter = new FpsCounter(FontManager.GetWobbleFont("exo2-semibold"), 18)
{
Parent = GlobalUserInterface,
Alignment = Alignment.BotRight,
Size = new ScalableVector2(70, 30),
};

WaylandState = new SpriteText("exo2-semibold", $"Wayland: {WaylandVsync}", 18)
WaylandState = new SpriteTextPlus(FontManager.GetWobbleFont("exo2-semibold"), $"Wayland: {WaylandVsync}", 18)
{
Parent = GlobalUserInterface,
Alignment = Alignment.BotRight,
Expand Down Expand Up @@ -137,7 +129,7 @@ protected override void Update(GameTime gameTime)
if (KeyboardManager.IsUniqueKeyPress(Keys.W) && OperatingSystem.IsLinux())
{
WaylandVsync = !WaylandVsync;
WaylandState.ScheduleUpdate(() => WaylandState.Text = $"Wayland: {WaylandVsync}");
WaylandState.Text = $"Wayland: {WaylandVsync}";
}
}

Expand Down
5 changes: 4 additions & 1 deletion Wobble/Graphics/Sprites/Text/SpriteTextPlusLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ public SpriteTextPlusLine(WobbleFontStore font, string text, float size = 0)
private static float GetScale()
{
var scale = WindowManager.ScreenScale.X;
Debug.Assert(scale > 0, "You're setting up text too early (WindowManager.ScreenScale.X is 0).");

// Some stuff (namely DrawableLog and the FPS counter) wants to draw text before anything is initialized.
if (scale == 0)
scale = 1;

if (GameBase.Game.Graphics.PreferredBackBufferWidth < 1600)
return scale * 2;
Expand Down
20 changes: 9 additions & 11 deletions Wobble/Graphics/UI/Debugging/FpsCounter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended.BitmapFonts;
using Wobble.Graphics.BitmapFonts;
using Wobble.Graphics.Sprites;
using Wobble.Graphics.Sprites.Text;
using Wobble.Managers;

namespace Wobble.Graphics.UI.Debugging
{
Expand All @@ -20,9 +20,9 @@ public class FpsCounter : Container
private int FrameCounter { get; set; }

/// <summary>
/// The SpriteText that displays the FPS value.
/// The SpriteTextPlus that displays the FPS value.
/// </summary>
public SpriteTextBitmap TextFps { get; }
public SpriteTextPlus TextFps { get; }

/// <summary>
/// The current update rate.
Expand All @@ -35,9 +35,9 @@ public class FpsCounter : Container
private int UpdateCounter { get; set; }

/// <summary>
/// The SpriteText that displays the UPS value.
/// The SpriteTextPlus that displays the UPS value.
/// </summary>
public SpriteTextBitmap TextUps { get; }
public SpriteTextPlus TextUps { get; }

/// <summary>
/// The amount of time elapsed so we can begin counting each second.
Expand All @@ -48,20 +48,18 @@ public class FpsCounter : Container
/// <summary>
/// Ctor
/// </summary>
public FpsCounter(BitmapFont font, int size)
public FpsCounter(WobbleFontStore font, int size)
{
TextFps = new SpriteTextBitmap(font, "0 FPS", false)
TextFps = new SpriteTextPlus(font, "0 FPS", size)
{
Parent = this,
Alignment = Alignment.TopRight,
FontSize = size
};

TextUps = new SpriteTextBitmap(font, "0 UPS", false)
TextUps = new SpriteTextPlus(font, "0 UPS", size)
{
Parent = this,
Alignment = Alignment.TopRight,
FontSize = size,
Y = TextFps.Size.Y.Value
};
}
Expand Down
15 changes: 8 additions & 7 deletions Wobble/Wobble.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFramework>net6.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>7.1</LangVersion>
<RuntimeIdentifiers>osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
Expand All @@ -17,8 +18,7 @@
<PackageReference Include="MonoGame.Extended" Version="3.8.0" />
<PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="3.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="System.Drawing.Common" Version="4.5.0" />
<PackageReference Include="System.Drawing.Common" Version="5.0.3" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
Expand All @@ -37,13 +37,14 @@
<None Update="libSDL2-2.0.0.dylib">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="libgdiplus.dylib">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="x64/*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Reference Include="MonoGame.Framework">
<HintPath>..\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Include="MonoGame.Framework">
<HintPath>..\MonoGame.Framework.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
Binary file added Wobble/libgdiplus.dylib
Binary file not shown.
Binary file modified Wobble/libopenal.1.dylib
Binary file not shown.