mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge branch 'master' into playlist-unicode
This commit is contained in:
@ -0,0 +1,82 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Markdig;
|
||||
using Markdig.Extensions.AutoIdentifiers;
|
||||
using Markdig.Extensions.Tables;
|
||||
using Markdig.Extensions.Yaml;
|
||||
using Markdig.Syntax;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownContainer : MarkdownContainer
|
||||
{
|
||||
public OsuMarkdownContainer()
|
||||
{
|
||||
LineSpacing = 21;
|
||||
}
|
||||
|
||||
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)
|
||||
{
|
||||
switch (markdownObject)
|
||||
{
|
||||
case YamlFrontMatterBlock _:
|
||||
// Don't parse YAML Frontmatter
|
||||
break;
|
||||
|
||||
case ListItemBlock listItemBlock:
|
||||
var isOrdered = ((ListBlock)listItemBlock.Parent).IsOrdered;
|
||||
var childContainer = CreateListItem(listItemBlock, level, isOrdered);
|
||||
container.Add(childContainer);
|
||||
foreach (var single in listItemBlock)
|
||||
base.AddMarkdownComponent(single, childContainer.Content, level);
|
||||
break;
|
||||
|
||||
default:
|
||||
base.AddMarkdownComponent(markdownObject, container, level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override SpriteText CreateSpriteText() => new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 14),
|
||||
};
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow() => new OsuMarkdownTextFlowContainer();
|
||||
|
||||
protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock) => new OsuMarkdownHeading(headingBlock);
|
||||
|
||||
protected override MarkdownFencedCodeBlock CreateFencedCodeBlock(FencedCodeBlock fencedCodeBlock) => new OsuMarkdownFencedCodeBlock(fencedCodeBlock);
|
||||
|
||||
protected override MarkdownSeparator CreateSeparator(ThematicBreakBlock thematicBlock) => new OsuMarkdownSeparator();
|
||||
|
||||
protected override MarkdownQuoteBlock CreateQuoteBlock(QuoteBlock quoteBlock) => new OsuMarkdownQuoteBlock(quoteBlock);
|
||||
|
||||
protected override MarkdownTable CreateTable(Table table) => new OsuMarkdownTable(table);
|
||||
|
||||
protected override MarkdownList CreateList(ListBlock listBlock) => new MarkdownList
|
||||
{
|
||||
Padding = new MarginPadding(0)
|
||||
};
|
||||
|
||||
protected virtual OsuMarkdownListItem CreateListItem(ListItemBlock listItemBlock, int level, bool isOrdered)
|
||||
{
|
||||
if (isOrdered)
|
||||
return new OsuMarkdownOrderedListItem(listItemBlock.Order);
|
||||
|
||||
return new OsuMarkdownUnorderedListItem(level);
|
||||
}
|
||||
|
||||
protected override MarkdownPipeline CreateBuilder()
|
||||
=> new MarkdownPipelineBuilder().UseAutoIdentifiers(AutoIdentifierOptions.GitHub)
|
||||
.UseEmojiAndSmiley()
|
||||
.UseYamlFrontMatter()
|
||||
.UseAdvancedExtensions().Build();
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Markdig.Syntax;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownFencedCodeBlock : MarkdownFencedCodeBlock
|
||||
{
|
||||
// TODO : change to monospace font for this component
|
||||
public OsuMarkdownFencedCodeBlock(FencedCodeBlock fencedCodeBlock)
|
||||
: base(fencedCodeBlock)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() => new CodeBlockBackground();
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow() => new CodeBlockTextFlowContainer();
|
||||
|
||||
private class CodeBlockBackground : Box
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Colour = colourProvider.Background6;
|
||||
}
|
||||
}
|
||||
|
||||
private class CodeBlockTextFlowContainer : OsuMarkdownTextFlowContainer
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
Colour = colourProvider.Light1;
|
||||
Margin = new MarginPadding(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
osu.Game/Graphics/Containers/Markdown/OsuMarkdownHeading.cs
Normal file
75
osu.Game/Graphics/Containers/Markdown/OsuMarkdownHeading.cs
Normal file
@ -0,0 +1,75 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Markdig.Syntax;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownHeading : MarkdownHeading
|
||||
{
|
||||
private readonly int level;
|
||||
|
||||
public OsuMarkdownHeading(HeadingBlock headingBlock)
|
||||
: base(headingBlock)
|
||||
{
|
||||
level = headingBlock.Level;
|
||||
}
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow() => new HeadingTextFlowContainer
|
||||
{
|
||||
Weight = GetFontWeightByLevel(level),
|
||||
};
|
||||
|
||||
protected override float GetFontSizeByLevel(int level)
|
||||
{
|
||||
// Reference for this font size
|
||||
// https://github.com/ppy/osu-web/blob/376cac43a051b9c85ce95e2c446099be187b3e45/resources/assets/less/bem/osu-md.less#L9
|
||||
// https://github.com/ppy/osu-web/blob/376cac43a051b9c85ce95e2c446099be187b3e45/resources/assets/less/variables.less#L161
|
||||
const float base_font_size = 14;
|
||||
|
||||
switch (level)
|
||||
{
|
||||
case 1:
|
||||
return 30 / base_font_size;
|
||||
|
||||
case 2:
|
||||
return 26 / base_font_size;
|
||||
|
||||
case 3:
|
||||
return 20 / base_font_size;
|
||||
|
||||
case 4:
|
||||
return 18 / base_font_size;
|
||||
|
||||
case 5:
|
||||
return 16 / base_font_size;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual FontWeight GetFontWeightByLevel(int level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
return FontWeight.SemiBold;
|
||||
|
||||
default:
|
||||
return FontWeight.Bold;
|
||||
}
|
||||
}
|
||||
|
||||
private class HeadingTextFlowContainer : OsuMarkdownTextFlowContainer
|
||||
{
|
||||
public FontWeight Weight { get; set; }
|
||||
|
||||
protected override SpriteText CreateSpriteText() => base.CreateSpriteText().With(t => t.Font = t.Font.With(weight: Weight));
|
||||
}
|
||||
}
|
||||
}
|
48
osu.Game/Graphics/Containers/Markdown/OsuMarkdownLinkText.cs
Normal file
48
osu.Game/Graphics/Containers/Markdown/OsuMarkdownLinkText.cs
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Markdig.Syntax.Inlines;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownLinkText : MarkdownLinkText
|
||||
{
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
|
||||
private SpriteText spriteText;
|
||||
|
||||
public OsuMarkdownLinkText(string text, LinkInline linkInline)
|
||||
: base(text, linkInline)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
spriteText.Colour = colourProvider.Light2;
|
||||
}
|
||||
|
||||
public override SpriteText CreateSpriteText()
|
||||
{
|
||||
return spriteText = base.CreateSpriteText();
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
spriteText.Colour = colourProvider.Light1;
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
spriteText.Colour = colourProvider.Light2;
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
}
|
||||
}
|
44
osu.Game/Graphics/Containers/Markdown/OsuMarkdownListItem.cs
Normal file
44
osu.Game/Graphics/Containers/Markdown/OsuMarkdownListItem.cs
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public abstract class OsuMarkdownListItem : CompositeDrawable
|
||||
{
|
||||
[Resolved]
|
||||
private IMarkdownTextComponent parentTextComponent { get; set; }
|
||||
|
||||
public FillFlowContainer Content { get; private set; }
|
||||
|
||||
protected OsuMarkdownListItem()
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
CreateMarker(),
|
||||
Content = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(10, 10),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual SpriteText CreateMarker() => parentTextComponent.CreateSpriteText();
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownOrderedListItem : OsuMarkdownListItem
|
||||
{
|
||||
private const float left_padding = 30;
|
||||
|
||||
private readonly int order;
|
||||
|
||||
public OsuMarkdownOrderedListItem(int order)
|
||||
{
|
||||
this.order = order;
|
||||
Padding = new MarginPadding { Left = left_padding };
|
||||
}
|
||||
|
||||
protected override SpriteText CreateMarker() => base.CreateMarker().With(t =>
|
||||
{
|
||||
t.X = -left_padding;
|
||||
t.Text = $"{order}.";
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Markdig.Syntax;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownQuoteBlock : MarkdownQuoteBlock
|
||||
{
|
||||
public OsuMarkdownQuoteBlock(QuoteBlock quoteBlock)
|
||||
: base(quoteBlock)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() => new QuoteBackground();
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow()
|
||||
{
|
||||
return base.CreateTextFlow().With(f => f.Margin = new MarginPadding
|
||||
{
|
||||
Vertical = 10,
|
||||
Horizontal = 20,
|
||||
});
|
||||
}
|
||||
|
||||
private class QuoteBackground : Box
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft;
|
||||
Origin = Anchor.CentreLeft;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Width = 2;
|
||||
Colour = colourProvider.Content2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownSeparator : MarkdownSeparator
|
||||
{
|
||||
protected override Drawable CreateSeparator() => new Separator();
|
||||
|
||||
private class Separator : Box
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 1;
|
||||
Colour = colourProvider.Background3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
osu.Game/Graphics/Containers/Markdown/OsuMarkdownTable.cs
Normal file
18
osu.Game/Graphics/Containers/Markdown/OsuMarkdownTable.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Markdig.Extensions.Tables;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownTable : MarkdownTable
|
||||
{
|
||||
public OsuMarkdownTable(Table table)
|
||||
: base(table)
|
||||
{
|
||||
}
|
||||
|
||||
protected override MarkdownTableCell CreateTableCell(TableCell cell, TableColumnDefinition definition, bool isHeading) => new OsuMarkdownTableCell(cell, definition, isHeading);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Markdig.Extensions.Tables;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownTableCell : MarkdownTableCell
|
||||
{
|
||||
private readonly bool isHeading;
|
||||
|
||||
public OsuMarkdownTableCell(TableCell cell, TableColumnDefinition definition, bool isHeading)
|
||||
: base(cell, definition)
|
||||
{
|
||||
this.isHeading = isHeading;
|
||||
Masking = false;
|
||||
BorderThickness = 0;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddInternal(CreateBorder(isHeading));
|
||||
}
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow() => new TableCellTextFlowContainer
|
||||
{
|
||||
Weight = isHeading ? FontWeight.Bold : FontWeight.Regular,
|
||||
Padding = new MarginPadding(10),
|
||||
};
|
||||
|
||||
protected virtual Box CreateBorder(bool isHeading)
|
||||
{
|
||||
if (isHeading)
|
||||
return new TableHeadBorder();
|
||||
|
||||
return new TableBodyBorder();
|
||||
}
|
||||
|
||||
private class TableHeadBorder : Box
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
Colour = colourProvider.Background3;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 2;
|
||||
Anchor = Anchor.BottomLeft;
|
||||
Origin = Anchor.BottomLeft;
|
||||
}
|
||||
}
|
||||
|
||||
private class TableBodyBorder : Box
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
Colour = colourProvider.Background4;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private class TableCellTextFlowContainer : OsuMarkdownTextFlowContainer
|
||||
{
|
||||
public FontWeight Weight { get; set; }
|
||||
|
||||
protected override SpriteText CreateSpriteText() => base.CreateSpriteText().With(t => t.Font = t.Font.With(weight: Weight));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Markdig.Syntax.Inlines;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownTextFlowContainer : MarkdownTextFlowContainer
|
||||
{
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
|
||||
protected override void AddLinkText(string text, LinkInline linkInline)
|
||||
=> AddDrawable(new OsuMarkdownLinkText(text, linkInline));
|
||||
|
||||
// TODO : Add background (colour B6) and change font to monospace
|
||||
protected override void AddCodeInLine(CodeInline codeInline)
|
||||
=> AddText(codeInline.Content, t => { t.Colour = colourProvider.Light1; });
|
||||
|
||||
protected override SpriteText CreateEmphasisedSpriteText(bool bold, bool italic)
|
||||
=> CreateSpriteText().With(t => t.Font = t.Font.With(weight: bold ? FontWeight.Bold : FontWeight.Regular, italics: italic));
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownUnorderedListItem : OsuMarkdownListItem
|
||||
{
|
||||
private const float left_padding = 20;
|
||||
|
||||
private readonly int level;
|
||||
|
||||
public OsuMarkdownUnorderedListItem(int level)
|
||||
{
|
||||
this.level = level;
|
||||
|
||||
Padding = new MarginPadding { Left = left_padding };
|
||||
}
|
||||
|
||||
protected override SpriteText CreateMarker() => base.CreateMarker().With(t =>
|
||||
{
|
||||
t.Text = GetTextMarker(level);
|
||||
t.Font = t.Font.With(size: t.Font.Size / 2);
|
||||
t.Origin = Anchor.Centre;
|
||||
t.X = -left_padding / 2;
|
||||
t.Y = t.Font.Size;
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Get text marker based on <paramref name="level"/>
|
||||
/// </summary>
|
||||
/// <param name="level">The markdown level of current list item.</param>
|
||||
/// <returns>The marker string of this list item</returns>
|
||||
protected virtual string GetTextMarker(int level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case 1:
|
||||
return "●";
|
||||
|
||||
case 2:
|
||||
return "○";
|
||||
|
||||
default:
|
||||
return "■";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ namespace osu.Game.Graphics.Containers
|
||||
protected override bool BlockNonPositionalInput => true;
|
||||
|
||||
/// <summary>
|
||||
/// Temporary to allow for overlays in the main screen content to not dim theirselves.
|
||||
/// Temporary to allow for overlays in the main screen content to not dim themselves.
|
||||
/// Should be eventually replaced by dimming which is aware of the target dim container (traverse parent for certain interface type?).
|
||||
/// </summary>
|
||||
protected virtual bool DimMainContent => true;
|
||||
|
@ -36,6 +36,24 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
private BackgroundScreenStack backgroundStack;
|
||||
|
||||
private bool allowScaling = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether user scaling preferences should be applied. Enabled by default.
|
||||
/// </summary>
|
||||
public bool AllowScaling
|
||||
{
|
||||
get => allowScaling;
|
||||
set
|
||||
{
|
||||
if (value == allowScaling)
|
||||
return;
|
||||
|
||||
allowScaling = value;
|
||||
if (IsLoaded) updateSize();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new instance.
|
||||
/// </summary>
|
||||
@ -139,7 +157,7 @@ namespace osu.Game.Graphics.Containers
|
||||
backgroundStack?.FadeOut(fade_time);
|
||||
}
|
||||
|
||||
bool scaling = targetMode == null || scalingMode.Value == targetMode;
|
||||
bool scaling = AllowScaling && (targetMode == null || scalingMode.Value == targetMode);
|
||||
|
||||
var targetSize = scaling ? new Vector2(sizeX.Value, sizeY.Value) : Vector2.One;
|
||||
var targetPosition = scaling ? new Vector2(posX.Value, posY.Value) * (Vector2.One - targetSize) : Vector2.Zero;
|
||||
|
Reference in New Issue
Block a user