mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
VolumeControl: add controls for Effects and Music
This commit is contained in:
@ -1,19 +1,18 @@
|
|||||||
using System;
|
using osu.Framework.Configuration;
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework.Configuration;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Drawables;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Graphics.Transformations;
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game
|
namespace osu.Game
|
||||||
{
|
{
|
||||||
internal class VolumeControl : Container
|
internal class VolumeControl : Container
|
||||||
{
|
{
|
||||||
private Box meterFill;
|
private FlowContainer volumeMetersContainer;
|
||||||
private Container meterContainer;
|
private VolumeMeter VolumeMeterGlobal;
|
||||||
|
private VolumeMeter VolumeMeterSample;
|
||||||
|
private VolumeMeter VolumeMeterTrack;
|
||||||
|
|
||||||
public BindableDouble VolumeGlobal { get; set; }
|
public BindableDouble VolumeGlobal { get; set; }
|
||||||
public BindableDouble VolumeSample { get; set; }
|
public BindableDouble VolumeSample { get; set; }
|
||||||
@ -29,41 +28,17 @@ namespace osu.Game
|
|||||||
base.Load();
|
base.Load();
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
meterContainer = new Container {
|
volumeMetersContainer = new FlowContainer() {
|
||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.BottomRight,
|
||||||
Origin = Anchor.BottomRight,
|
Origin = Anchor.BottomRight,
|
||||||
Position = new Vector2(10, 10),
|
Position = new Vector2(10, 30),
|
||||||
Size = new Vector2(40, 180),
|
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
|
Padding = new Vector2(15,0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
VolumeMeterGlobal = new VolumeMeter("Master"),
|
||||||
{
|
VolumeMeterSample= new VolumeMeter("Effects"),
|
||||||
Colour = Color4.Black,
|
VolumeMeterTrack= new VolumeMeter("Music")
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Size = new Vector2(0.5f, 0.9f),
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
Colour = Color4.DarkGray,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
meterFill = new Box
|
|
||||||
{
|
|
||||||
Colour = Color4.White,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Anchor = Anchor.BottomCentre
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -75,7 +50,19 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
appear();
|
appear();
|
||||||
|
|
||||||
VolumeGlobal.Value -= 0.05f;
|
if (VolumeMeterSample.Contains(state.Mouse.Position))
|
||||||
|
{
|
||||||
|
VolumeSample.Value -= 0.05f;
|
||||||
|
}
|
||||||
|
else if (VolumeMeterTrack.Contains(state.Mouse.Position))
|
||||||
|
{
|
||||||
|
VolumeTrack.Value -= 0.05f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VolumeGlobal.Value -= 0.05f;
|
||||||
|
}
|
||||||
|
|
||||||
updateFill();
|
updateFill();
|
||||||
|
|
||||||
return base.OnWheelDown(state);
|
return base.OnWheelDown(state);
|
||||||
@ -85,7 +72,19 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
appear();
|
appear();
|
||||||
|
|
||||||
VolumeGlobal.Value += 0.05f;
|
if (VolumeMeterSample.Contains(state.Mouse.Position))
|
||||||
|
{
|
||||||
|
VolumeSample.Value += 0.05f;
|
||||||
|
}
|
||||||
|
else if (VolumeMeterTrack.Contains(state.Mouse.Position))
|
||||||
|
{
|
||||||
|
VolumeTrack.Value += 0.05f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VolumeGlobal.Value += 0.05f;
|
||||||
|
}
|
||||||
|
|
||||||
updateFill();
|
updateFill();
|
||||||
|
|
||||||
return base.OnWheelUp(state);
|
return base.OnWheelUp(state);
|
||||||
@ -93,15 +92,17 @@ namespace osu.Game
|
|||||||
|
|
||||||
private void updateFill()
|
private void updateFill()
|
||||||
{
|
{
|
||||||
meterFill.ScaleTo(new Vector2(1, (float)VolumeGlobal.Value), 300, EasingTypes.OutQuint);
|
VolumeMeterGlobal.MeterFill.ScaleTo(new Vector2(1, (float)VolumeGlobal.Value), 300, EasingTypes.OutQuint);
|
||||||
|
VolumeMeterSample.MeterFill.ScaleTo(new Vector2(1, (float)VolumeSample.Value), 300, EasingTypes.OutQuint);
|
||||||
|
VolumeMeterTrack.MeterFill.ScaleTo(new Vector2(1, (float)VolumeTrack.Value), 300, EasingTypes.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appear()
|
private void appear()
|
||||||
{
|
{
|
||||||
meterContainer.ClearTransformations();
|
volumeMetersContainer.ClearTransformations();
|
||||||
meterContainer.FadeIn(100);
|
volumeMetersContainer.FadeIn(100);
|
||||||
meterContainer.Delay(1000);
|
volumeMetersContainer.Delay(1000);
|
||||||
meterContainer.FadeOut(100);
|
volumeMetersContainer.FadeOut(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
49
osu.Game/VolumeMeter.cs
Normal file
49
osu.Game/VolumeMeter.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Drawables;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game
|
||||||
|
{
|
||||||
|
internal class VolumeMeter : Container
|
||||||
|
{
|
||||||
|
public Box MeterFill { get; set; }
|
||||||
|
public VolumeMeter(string meterName)
|
||||||
|
{
|
||||||
|
Size = new Vector2(40, 180);
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.Black,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Size = new Vector2(0.5f, 0.9f),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.DarkGray,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
MeterFill = new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.White,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Anchor = Anchor.BottomCentre
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new SpriteText {Text = meterName, Anchor = Anchor.BottomCentre,Origin = Anchor.BottomCentre,Position = new Vector2(0,-20)}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -133,6 +133,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Users\User.cs" />
|
<Compile Include="Users\User.cs" />
|
||||||
<Compile Include="VolumeControl.cs" />
|
<Compile Include="VolumeControl.cs" />
|
||||||
|
<Compile Include="VolumeMeter.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||||
|
Reference in New Issue
Block a user