mirror of https://github.com/ppy/osu
Taking screenshot support initial commit
This commit is contained in:
parent
a9327eac8f
commit
e6c22e2287
|
@ -82,6 +82,8 @@ protected override void InitialiseDefaults()
|
||||||
Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer);
|
Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer);
|
||||||
|
|
||||||
Set(OsuSetting.Version, string.Empty);
|
Set(OsuSetting.Version, string.Empty);
|
||||||
|
|
||||||
|
Set(OsuSetting.ScreenshotFormat, ScreenshotFormat.Png);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsuConfigManager(Storage storage) : base(storage)
|
public OsuConfigManager(Storage storage) : base(storage)
|
||||||
|
@ -125,6 +127,7 @@ public enum OsuSetting
|
||||||
Version,
|
Version,
|
||||||
ShowConvertedBeatmaps,
|
ShowConvertedBeatmaps,
|
||||||
SpeedChangeVisualisation,
|
SpeedChangeVisualisation,
|
||||||
Skin
|
Skin,
|
||||||
|
ScreenshotFormat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ public GlobalActionContainer(OsuGameBase game)
|
||||||
{
|
{
|
||||||
new KeyBinding(InputKey.F8, GlobalAction.ToggleChat),
|
new KeyBinding(InputKey.F8, GlobalAction.ToggleChat),
|
||||||
new KeyBinding(InputKey.F9, GlobalAction.ToggleSocial),
|
new KeyBinding(InputKey.F9, GlobalAction.ToggleSocial),
|
||||||
|
new KeyBinding(InputKey.F12,GlobalAction.TakeScreenshot),
|
||||||
|
|
||||||
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),
|
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),
|
||||||
new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
|
new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
|
||||||
new KeyBinding(new[] { InputKey.Control, InputKey.O }, GlobalAction.ToggleSettings),
|
new KeyBinding(new[] { InputKey.Control, InputKey.O }, GlobalAction.ToggleSettings),
|
||||||
|
@ -66,6 +68,8 @@ public enum GlobalAction
|
||||||
DecreaseVolume,
|
DecreaseVolume,
|
||||||
[Description("Toggle mute")]
|
[Description("Toggle mute")]
|
||||||
ToggleMute,
|
ToggleMute,
|
||||||
|
[Description("Take screenshot")]
|
||||||
|
TakeScreenshot,
|
||||||
|
|
||||||
// In-Game Keybindings
|
// In-Game Keybindings
|
||||||
[Description("Skip Cutscene")]
|
[Description("Skip Cutscene")]
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
@ -83,6 +85,8 @@ private Intro intro
|
||||||
|
|
||||||
private Bindable<int> configSkin;
|
private Bindable<int> configSkin;
|
||||||
|
|
||||||
|
private Bindable<ScreenshotFormat> screenshotFormat;
|
||||||
|
|
||||||
private readonly string[] args;
|
private readonly string[] args;
|
||||||
|
|
||||||
private SettingsOverlay settings;
|
private SettingsOverlay settings;
|
||||||
|
@ -134,6 +138,8 @@ private void load(FrameworkConfigManager frameworkConfig)
|
||||||
// bind config int to database SkinInfo
|
// bind config int to database SkinInfo
|
||||||
configSkin = LocalConfig.GetBindable<int>(OsuSetting.Skin);
|
configSkin = LocalConfig.GetBindable<int>(OsuSetting.Skin);
|
||||||
|
|
||||||
|
screenshotFormat = LocalConfig.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat);
|
||||||
|
|
||||||
SkinManager.CurrentSkinInfo.ValueChanged += s => configSkin.Value = s.ID;
|
SkinManager.CurrentSkinInfo.ValueChanged += s => configSkin.Value = s.ID;
|
||||||
configSkin.ValueChanged += id => SkinManager.CurrentSkinInfo.Value = SkinManager.Query(s => s.ID == id) ?? SkinInfo.Default;
|
configSkin.ValueChanged += id => SkinManager.CurrentSkinInfo.Value = SkinManager.Query(s => s.ID == id) ?? SkinInfo.Default;
|
||||||
configSkin.TriggerChange();
|
configSkin.TriggerChange();
|
||||||
|
@ -432,11 +438,47 @@ public bool OnPressed(GlobalAction action)
|
||||||
case GlobalAction.ToggleDirect:
|
case GlobalAction.ToggleDirect:
|
||||||
direct.ToggleVisibility();
|
direct.ToggleVisibility();
|
||||||
return true;
|
return true;
|
||||||
|
case GlobalAction.TakeScreenshot:
|
||||||
|
if (Window.ScreenshotTakenAction == null)
|
||||||
|
Window.ScreenshotTakenAction = (screenshotBitmap) =>
|
||||||
|
{
|
||||||
|
var fileName = getScreenshotFileName(screenshotFormat);
|
||||||
|
|
||||||
|
switch (screenshotFormat.Value)
|
||||||
|
{
|
||||||
|
case ScreenshotFormat.Bmp:
|
||||||
|
screenshotBitmap.Save(fileName, ImageFormat.Bmp);
|
||||||
|
break;
|
||||||
|
case ScreenshotFormat.Png:
|
||||||
|
screenshotBitmap.Save(fileName, ImageFormat.Png);
|
||||||
|
break;
|
||||||
|
case ScreenshotFormat.Jpg:
|
||||||
|
screenshotBitmap.Save(fileName, ImageFormat.Jpeg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(screenshotFormat));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
RequestScreenshot();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string getScreenshotFileName(ScreenshotFormat screenshotFormat)
|
||||||
|
{
|
||||||
|
// TODO Change screenshots location
|
||||||
|
var baseDirectory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
|
||||||
|
var screenshotsDirectory = baseDirectory.CreateSubdirectory("Screenshots");
|
||||||
|
|
||||||
|
var screenshotExtension = screenshotFormat.ToString().ToLower();
|
||||||
|
var screenshots = screenshotsDirectory.GetFiles($"*.{screenshotExtension}");
|
||||||
|
|
||||||
|
return Path.Combine(screenshotsDirectory.FullName, $"screenshot{screenshots.Length + 1}.{screenshotExtension}");
|
||||||
|
}
|
||||||
|
|
||||||
private readonly BindableDouble inactiveVolumeAdjust = new BindableDouble();
|
private readonly BindableDouble inactiveVolumeAdjust = new BindableDouble();
|
||||||
|
|
||||||
protected override void OnDeactivated()
|
protected override void OnDeactivated()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||||
|
@ -12,7 +13,7 @@ public class DetailSettings : SettingsSubsection
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
Children = new[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
|
@ -24,6 +25,11 @@ private void load(OsuConfigManager config)
|
||||||
LabelText = "Rotate cursor when dragging",
|
LabelText = "Rotate cursor when dragging",
|
||||||
Bindable = config.GetBindable<bool>(OsuSetting.CursorRotation)
|
Bindable = config.GetBindable<bool>(OsuSetting.CursorRotation)
|
||||||
},
|
},
|
||||||
|
new SettingsEnumDropdown<ScreenshotFormat>()
|
||||||
|
{
|
||||||
|
LabelText = "Screenshot format",
|
||||||
|
Bindable = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,6 +187,7 @@
|
||||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>$(SolutionDir)\packages\System.Diagnostics.DiagnosticSource.4.4.1\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
<HintPath>$(SolutionDir)\packages\System.Diagnostics.DiagnosticSource.4.4.1\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Interactive.Async, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
|
<Reference Include="System.Interactive.Async, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
|
||||||
<HintPath>$(SolutionDir)\packages\System.Interactive.Async.3.1.1\lib\net46\System.Interactive.Async.dll</HintPath>
|
<HintPath>$(SolutionDir)\packages\System.Interactive.Async.3.1.1\lib\net46\System.Interactive.Async.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
Loading…
Reference in New Issue