mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:17:26 +08:00
Merge branch 'master' of github.com:ppy/osu into better-visibility
This commit is contained in:
commit
6d59429c29
55
osu.Desktop/OsuGameDesktop.cs
Normal file
55
osu.Desktop/OsuGameDesktop.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using osu.Game;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Desktop.Platform;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Desktop
|
||||
{
|
||||
class OsuGameDesktop : OsuGame
|
||||
{
|
||||
public OsuGameDesktop(string[] args = null)
|
||||
: base(args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void SetHost(BasicGameHost host)
|
||||
{
|
||||
base.SetHost(host);
|
||||
var desktopWindow = host.Window as DesktopGameWindow;
|
||||
if (desktopWindow != null)
|
||||
{
|
||||
desktopWindow.DragEnter += dragEnter;
|
||||
desktopWindow.DragDrop += dragDrop;
|
||||
}
|
||||
}
|
||||
|
||||
private void dragDrop(DragEventArgs e)
|
||||
{
|
||||
// this method will only be executed if e.Effect in dragEnter gets set to something other that None.
|
||||
var dropData = e.Data.GetData(DataFormats.FileDrop) as object[];
|
||||
var filePaths = dropData.Select(f => f.ToString()).ToArray();
|
||||
ImportBeatmaps(filePaths);
|
||||
}
|
||||
|
||||
private void dragEnter(DragEventArgs e)
|
||||
{
|
||||
// dragDrop will only be executed if e.Effect gets set to something other that None in this method.
|
||||
bool isFile = e.Data.GetDataPresent(DataFormats.FileDrop);
|
||||
if (isFile)
|
||||
{
|
||||
var paths = (e.Data.GetData(DataFormats.FileDrop) as object[]).Select(f => f.ToString()).ToArray();
|
||||
if (paths.Any(p => !p.EndsWith(".osz")))
|
||||
e.Effect = DragDropEffects.None;
|
||||
else
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -51,7 +51,7 @@ namespace osu.Desktop
|
||||
Ruleset.Register(new ManiaRuleset());
|
||||
Ruleset.Register(new CatchRuleset());
|
||||
|
||||
BaseGame osu = new OsuGame(args);
|
||||
BaseGame osu = new OsuGameDesktop(args);
|
||||
host.Add(osu);
|
||||
host.Run();
|
||||
}
|
||||
|
@ -81,7 +81,9 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\osu.licenseheader">
|
||||
@ -152,6 +154,7 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="OsuGameDesktop.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Beatmaps\IO\LegacyFilesystemReader.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -22,6 +22,7 @@ using osu.Game.Overlays.Toolbar;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using OpenTK;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
@ -63,13 +64,18 @@ namespace osu.Game
|
||||
}
|
||||
|
||||
if (args?.Length > 0)
|
||||
Schedule(delegate { Dependencies.Get<BeatmapDatabase>().Import(args); });
|
||||
ImportBeatmaps(args);
|
||||
|
||||
Dependencies.Cache(this);
|
||||
|
||||
PlayMode = LocalConfig.GetBindable<PlayMode>(OsuConfig.PlayMode);
|
||||
}
|
||||
|
||||
public void ImportBeatmaps(params string[] paths)
|
||||
{
|
||||
Schedule(delegate { Dependencies.Get<BeatmapDatabase>().Import(paths); });
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
@ -205,10 +205,9 @@ namespace osu.Game.Overlays.Pause
|
||||
},
|
||||
new Triangles
|
||||
{
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
TriangleScale = 4,
|
||||
Alpha = 0.05f,
|
||||
ColourDark = OsuColour.Gray(0.88f),
|
||||
Shear = new Vector2(-0.2f, 0)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user