-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from ojh050118/sprite-text
Code cleanup
- Loading branch information
Showing
30 changed files
with
391 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#nullable disable | ||
|
||
using System; | ||
using osu.Framework.Graphics; | ||
|
||
namespace Circle.Game.Beatmaps | ||
{ | ||
public class DummyBeatmap : Beatmap | ||
{ | ||
public DummyBeatmap() | ||
{ | ||
AngleData = Array.Empty<float>(); | ||
Settings = new Settings | ||
{ | ||
Artist = "please load a beatmap!", | ||
Song = "no beatmaps available!", | ||
SongFileName = string.Empty, | ||
Author = string.Empty, | ||
SeparateCountdownTime = false, | ||
PreviewSongStart = 0, | ||
PreviewSongDuration = 0, | ||
BeatmapDesc = string.Empty, | ||
Difficulty = 0, | ||
Bpm = 0, | ||
Volume = 0, | ||
Offset = 0, | ||
VidOffset = 0, | ||
Pitch = 0, | ||
CountdownTicks = 0, | ||
BgImage = string.Empty, | ||
BgVideo = string.Empty, | ||
RelativeTo = Relativity.Player, | ||
Position = Array.Empty<float>(), | ||
Rotation = 0, | ||
Zoom = 0, | ||
PlanetEasing = Easing.None | ||
}; | ||
Actions = Array.Empty<Actions>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#nullable disable | ||
|
||
namespace Circle.Game.Beatmaps | ||
{ | ||
public class DummyBeatmapInfo : BeatmapInfo | ||
{ | ||
public DummyBeatmapInfo() | ||
: base(new DummyBeatmap(), null) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#nullable disable | ||
|
||
using osu.Framework.Graphics.Sprites; | ||
|
||
namespace Circle.Game.Graphics | ||
{ | ||
public class CircleFont | ||
{ | ||
public const float DEFAULT_FONT_SIZE = 24; | ||
|
||
public static FontUsage Default => GetFont(); | ||
|
||
public static FontUsage GetFont(Typeface typeface = Typeface.OpenSans, float size = DEFAULT_FONT_SIZE, FontWeight weight = FontWeight.Medium, bool italics = false, bool fixedWidth = false) | ||
{ | ||
string familyString = GetFamilyString(typeface); | ||
return new FontUsage(familyString, size, GetWeightString(familyString, weight), getItalics(italics), fixedWidth); | ||
} | ||
|
||
private static bool getItalics(in bool italicsRequested) | ||
{ | ||
return false; | ||
} | ||
|
||
public static string GetFamilyString(Typeface typeface) | ||
{ | ||
switch (typeface) | ||
{ | ||
case Typeface.OpenSans: | ||
return @"OpenSans"; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static string GetWeightString(string family, FontWeight weight) | ||
{ | ||
return weight.ToString(); | ||
} | ||
} | ||
|
||
public static class TetrisFontExtensions | ||
{ | ||
public static FontUsage With(this FontUsage usage, Typeface? typeface = null, float? size = null, FontWeight? weight = null, bool? italics = null, bool? fixedWidth = null) | ||
{ | ||
string familyString = typeface != null ? CircleFont.GetFamilyString(typeface.Value) : usage.Family; | ||
string weightString = weight != null ? CircleFont.GetWeightString(familyString, weight.Value) : usage.Weight; | ||
|
||
return usage.With(familyString, size, weightString, italics, fixedWidth); | ||
} | ||
} | ||
|
||
public enum Typeface | ||
{ | ||
OpenSans | ||
} | ||
|
||
public enum FontWeight | ||
{ | ||
Light = 300, | ||
Regular = 400, | ||
Medium = 500, | ||
SemiBold = 600, | ||
Bold = 700, | ||
Black = 900 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#nullable disable | ||
|
||
using osu.Framework.Graphics.Sprites; | ||
|
||
namespace Circle.Game.Graphics.Sprites | ||
{ | ||
public partial class CircleSpriteText : SpriteText | ||
{ | ||
public CircleSpriteText() | ||
{ | ||
Shadow = true; | ||
Font = CircleFont.Default; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#nullable disable | ||
|
||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Colour; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Framework.Localisation; | ||
using osuTK; | ||
|
||
namespace Circle.Game.Graphics.Sprites | ||
{ | ||
public partial class GlowingSpriteText : Container, IHasText | ||
{ | ||
private readonly CircleSpriteText spriteText, blurredText; | ||
private readonly BufferedContainer blurContainer; | ||
|
||
public LocalisableString Text | ||
{ | ||
get => spriteText.Text; | ||
set => blurredText.Text = spriteText.Text = value; | ||
} | ||
|
||
public FontUsage Font | ||
{ | ||
get => spriteText.Font; | ||
set => blurredText.Font = spriteText.Font = value; | ||
} | ||
|
||
public Vector2 TextSize | ||
{ | ||
get => spriteText.Size; | ||
set => blurredText.Size = spriteText.Size = value; | ||
} | ||
|
||
public ColourInfo TextColour | ||
{ | ||
get => spriteText.Colour; | ||
set => spriteText.Colour = value; | ||
} | ||
|
||
public ColourInfo GlowColour | ||
{ | ||
get => blurredText.Colour; | ||
set => blurredText.Colour = value; | ||
} | ||
|
||
public Vector2 Spacing | ||
{ | ||
get => spriteText.Spacing; | ||
set => spriteText.Spacing = blurredText.Spacing = value; | ||
} | ||
|
||
public bool UseFullGlyphHeight | ||
{ | ||
get => spriteText.UseFullGlyphHeight; | ||
set => spriteText.UseFullGlyphHeight = blurredText.UseFullGlyphHeight = value; | ||
} | ||
|
||
public Bindable<string> Current | ||
{ | ||
get => spriteText.Current; | ||
set => spriteText.Current = value; | ||
} | ||
|
||
public float BlurSigma | ||
{ | ||
get => blurContainer.BlurSigma.X; | ||
set => blurContainer.BlurSigma = new Vector2(value); | ||
} | ||
|
||
public BlendingParameters GlowBlending | ||
{ | ||
get => blurContainer.Blending; | ||
set => blurContainer.Blending = value; | ||
} | ||
|
||
public GlowingSpriteText() | ||
{ | ||
AutoSizeAxes = Axes.Both; | ||
|
||
Children = new Drawable[] | ||
{ | ||
blurContainer = new BufferedContainer(cachedFrameBuffer: true) | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
BlurSigma = new Vector2(7), | ||
RedrawOnScale = false, | ||
RelativeSizeAxes = Axes.Both, | ||
Blending = BlendingParameters.Inherit, | ||
Size = new Vector2(3f), | ||
Children = new[] | ||
{ | ||
blurredText = new CircleSpriteText | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
Font = CircleFont.Default | ||
}, | ||
}, | ||
}, | ||
spriteText = new CircleSpriteText | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
Font = CircleFont.Default | ||
}, | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.