mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 12:25:04 +08:00
add the ability to set the size of the Tournament Client to an arbitrary value instead of a fixed 1080p option
This commit is contained in:
parent
95a30226ea
commit
554be1c422
@ -25,7 +25,7 @@ namespace osu.Game.Tournament.Screens
|
|||||||
private FillFlowContainer fillFlow;
|
private FillFlowContainer fillFlow;
|
||||||
|
|
||||||
private LoginOverlay loginOverlay;
|
private LoginOverlay loginOverlay;
|
||||||
private ActionableInfo resolution;
|
private ActionableInfoWithNumberBox resolution;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private MatchIPCInfo ipc { get; set; }
|
private MatchIPCInfo ipc { get; set; }
|
||||||
@ -108,18 +108,22 @@ namespace osu.Game.Tournament.Screens
|
|||||||
Items = rulesets.AvailableRulesets,
|
Items = rulesets.AvailableRulesets,
|
||||||
Current = LadderInfo.Ruleset,
|
Current = LadderInfo.Ruleset,
|
||||||
},
|
},
|
||||||
resolution = new ActionableInfo
|
resolution = new ActionableInfoWithNumberBox
|
||||||
{
|
{
|
||||||
Label = "Stream area resolution",
|
Label = "Stream area resolution",
|
||||||
ButtonText = "Set to 1080p",
|
ButtonText = "Set size",
|
||||||
Action = () =>
|
Action = i =>
|
||||||
{
|
{
|
||||||
windowSize.Value = new Size((int)(1920 / TournamentSceneManager.STREAM_AREA_WIDTH * TournamentSceneManager.REQUIRED_WIDTH), 1080);
|
i = Math.Clamp(i, 480, 2160);
|
||||||
|
windowSize.Value = new Size((int)(i * aspect_ratio / TournamentSceneManager.STREAM_AREA_WIDTH * TournamentSceneManager.REQUIRED_WIDTH), i);
|
||||||
|
resolution.NumberValue = i;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const float aspect_ratio = 16f / 9f;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -149,7 +153,7 @@ namespace osu.Game.Tournament.Screens
|
|||||||
|
|
||||||
private class ActionableInfo : LabelledDrawable<Drawable>
|
private class ActionableInfo : LabelledDrawable<Drawable>
|
||||||
{
|
{
|
||||||
private OsuButton button;
|
protected OsuButton Button;
|
||||||
|
|
||||||
public ActionableInfo()
|
public ActionableInfo()
|
||||||
: base(true)
|
: base(true)
|
||||||
@ -158,22 +162,22 @@ namespace osu.Game.Tournament.Screens
|
|||||||
|
|
||||||
public string ButtonText
|
public string ButtonText
|
||||||
{
|
{
|
||||||
set => button.Text = value;
|
set => Button.Text = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Value
|
public string Value
|
||||||
{
|
{
|
||||||
set => valueText.Text = value;
|
set => ValueText.Text = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Failing
|
public bool Failing
|
||||||
{
|
{
|
||||||
set => valueText.Colour = value ? Color4.Red : Color4.White;
|
set => ValueText.Colour = value ? Color4.Red : Color4.White;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Action;
|
public Action Action;
|
||||||
|
|
||||||
private TournamentSpriteText valueText;
|
protected TournamentSpriteText ValueText;
|
||||||
|
|
||||||
protected override Drawable CreateComponent() => new Container
|
protected override Drawable CreateComponent() => new Container
|
||||||
{
|
{
|
||||||
@ -181,12 +185,12 @@ namespace osu.Game.Tournament.Screens
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
valueText = new TournamentSpriteText
|
ValueText = new TournamentSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
},
|
},
|
||||||
button = new TriangleButton
|
Button = new TriangleButton
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
@ -196,5 +200,56 @@ namespace osu.Game.Tournament.Screens
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ActionableInfoWithNumberBox : ActionableInfo
|
||||||
|
{
|
||||||
|
public new Action<int> Action;
|
||||||
|
|
||||||
|
private OsuNumberBox numberBox;
|
||||||
|
|
||||||
|
public int NumberValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int.TryParse(numberBox.Text, out var val);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
set => numberBox.Text = value.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Drawable CreateComponent() => new Container
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
ValueText = new TournamentSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
},
|
||||||
|
numberBox = new OsuNumberBox
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Width = 100,
|
||||||
|
Margin = new MarginPadding
|
||||||
|
{
|
||||||
|
Right = 110
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Button = new TriangleButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Size = new Vector2(100, 30),
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
if (numberBox.Text.Length > 0) Action?.Invoke(NumberValue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user