mirror of
https://github.com/ppy/osu.git
synced 2025-01-16 03:03:01 +08:00
Merge branch 'master' into spectator-driven-leaderboard
This commit is contained in:
commit
fa524d64f8
@ -1,18 +1,26 @@
|
||||
// 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 System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Content.PM;
|
||||
using Android.Net;
|
||||
using Android.OS;
|
||||
using Android.Provider;
|
||||
using Android.Views;
|
||||
using osu.Framework.Android;
|
||||
|
||||
namespace osu.Android
|
||||
{
|
||||
[Activity(Theme = "@android:style/Theme.NoTitleBar", MainLauncher = true, ScreenOrientation = ScreenOrientation.FullUser, SupportsPictureInPicture = false, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, HardwareAccelerated = false)]
|
||||
[IntentFilter(new[] { Intent.ActionDefault, Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataPathPatterns = new[] { ".*\\.osz", ".*\\.osk" }, DataMimeType = "application/*")]
|
||||
public class OsuGameActivity : AndroidGameActivity
|
||||
{
|
||||
protected override Framework.Game CreateGame() => new OsuGameAndroid(this);
|
||||
private OsuGameAndroid game;
|
||||
|
||||
protected override Framework.Game CreateGame() => game = new OsuGameAndroid(this);
|
||||
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
{
|
||||
@ -23,8 +31,58 @@ namespace osu.Android
|
||||
|
||||
base.OnCreate(savedInstanceState);
|
||||
|
||||
// OnNewIntent() only fires for an activity if it's *re-launched* while it's on top of the activity stack.
|
||||
// on first launch we still have to fire manually.
|
||||
// reference: https://developer.android.com/reference/android/app/Activity#onNewIntent(android.content.Intent)
|
||||
handleIntent(Intent);
|
||||
|
||||
Window.AddFlags(WindowManagerFlags.Fullscreen);
|
||||
Window.AddFlags(WindowManagerFlags.KeepScreenOn);
|
||||
}
|
||||
|
||||
protected override void OnNewIntent(Intent intent) => handleIntent(intent);
|
||||
|
||||
private void handleIntent(Intent intent)
|
||||
{
|
||||
switch (intent.Action)
|
||||
{
|
||||
case Intent.ActionDefault:
|
||||
if (intent.Scheme == ContentResolver.SchemeContent)
|
||||
handleImportFromUri(intent.Data);
|
||||
break;
|
||||
|
||||
case Intent.ActionSend:
|
||||
{
|
||||
var content = intent.ClipData?.GetItemAt(0);
|
||||
if (content != null)
|
||||
handleImportFromUri(content.Uri);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleImportFromUri(Uri uri) => Task.Factory.StartNew(async () =>
|
||||
{
|
||||
// there are more performant overloads of this method, but this one is the most backwards-compatible
|
||||
// (dates back to API 1).
|
||||
var cursor = ContentResolver?.Query(uri, null, null, null, null);
|
||||
|
||||
if (cursor == null)
|
||||
return;
|
||||
|
||||
cursor.MoveToFirst();
|
||||
|
||||
var filenameColumn = cursor.GetColumnIndex(OpenableColumns.DisplayName);
|
||||
string filename = cursor.GetString(filenameColumn);
|
||||
|
||||
// SharpCompress requires archive streams to be seekable, which the stream opened by
|
||||
// OpenInputStream() seems to not necessarily be.
|
||||
// copy to an arbitrary-access memory stream to be able to proceed with the import.
|
||||
var copy = new MemoryStream();
|
||||
using (var stream = ContentResolver.OpenInputStream(uri))
|
||||
await stream.CopyToAsync(copy);
|
||||
|
||||
await game.Import(copy, filename);
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
|
||||
double multiplier = 1.12; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things
|
||||
|
||||
if (mods.Any(m => m is OsuModNoFail))
|
||||
multiplier *= 0.90;
|
||||
multiplier *= Math.Max(0.90, 1.0 - 0.02 * countMiss);
|
||||
|
||||
if (mods.Any(m => m is OsuModSpunOut))
|
||||
multiplier *= 1.0 - Math.Pow((double)Attributes.SpinnerCount / totalHits, 0.85);
|
||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
/// Signal that the host of the room has changed.
|
||||
/// </summary>
|
||||
/// <param name="userId">The user ID of the new host.</param>
|
||||
Task HostChanged(long userId);
|
||||
Task HostChanged(int userId);
|
||||
|
||||
/// <summary>
|
||||
/// Signals that the settings for this room have changed.
|
||||
@ -45,7 +45,7 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
/// </summary>
|
||||
/// <param name="userId">The ID of the user performing a state change.</param>
|
||||
/// <param name="state">The new state of the user.</param>
|
||||
Task UserStateChanged(long userId, MultiplayerUserState state);
|
||||
Task UserStateChanged(int userId, MultiplayerUserState state);
|
||||
|
||||
/// <summary>
|
||||
/// Signals that a match is to be started. This will *only* be sent to clients which are to begin loading at this point.
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
/// <param name="userId">The new user which is to become host.</param>
|
||||
/// <exception cref="NotHostException">A user other than the current host is attempting to transfer host.</exception>
|
||||
/// <exception cref="NotJoinedRoomException">If the user is not in a room.</exception>
|
||||
Task TransferHost(long userId);
|
||||
Task TransferHost(int userId);
|
||||
|
||||
/// <summary>
|
||||
/// As the host, update the settings of the currently joined room.
|
||||
|
@ -18,13 +18,20 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
|
||||
public int RulesetID { get; set; }
|
||||
|
||||
public string BeatmapChecksum { get; set; } = string.Empty;
|
||||
|
||||
public string Name { get; set; } = "Unnamed room";
|
||||
|
||||
[NotNull]
|
||||
public IEnumerable<APIMod> Mods { get; set; } = Enumerable.Empty<APIMod>();
|
||||
|
||||
public bool Equals(MultiplayerRoomSettings other) => BeatmapID == other.BeatmapID && Mods.SequenceEqual(other.Mods) && RulesetID == other.RulesetID && Name.Equals(other.Name, StringComparison.Ordinal);
|
||||
public bool Equals(MultiplayerRoomSettings other)
|
||||
=> BeatmapID == other.BeatmapID
|
||||
&& BeatmapChecksum == other.BeatmapChecksum
|
||||
&& Mods.SequenceEqual(other.Mods)
|
||||
&& RulesetID == other.RulesetID
|
||||
&& Name.Equals(other.Name, StringComparison.Ordinal);
|
||||
|
||||
public override string ToString() => $"Name:{Name} Beatmap:{BeatmapID} Mods:{string.Join(',', Mods)} Ruleset:{RulesetID}";
|
||||
public override string ToString() => $"Name:{Name} Beatmap:{BeatmapID} ({BeatmapChecksum}) Mods:{string.Join(',', Mods)} Ruleset:{RulesetID}";
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ using osu.Game.Updater;
|
||||
using osu.Game.Utils;
|
||||
using LogLevel = osu.Framework.Logging.LogLevel;
|
||||
using osu.Game.Users;
|
||||
using System.IO;
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
@ -426,6 +427,16 @@ namespace osu.Game
|
||||
}, validScreens: new[] { typeof(PlaySongSelect) });
|
||||
}
|
||||
|
||||
public override Task Import(Stream stream, string filename)
|
||||
{
|
||||
// encapsulate task as we don't want to begin the import process until in a ready state.
|
||||
var importTask = new Task(async () => await base.Import(stream, filename));
|
||||
|
||||
waitForReady(() => this, _ => importTask.Start());
|
||||
|
||||
return importTask;
|
||||
}
|
||||
|
||||
protected virtual Loader CreateLoader() => new Loader();
|
||||
|
||||
protected virtual UpdateManager CreateUpdateManager() => new UpdateManager();
|
||||
|
@ -395,7 +395,7 @@ namespace osu.Game
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Import(Stream stream, string filename)
|
||||
public virtual async Task Import(Stream stream, string filename)
|
||||
{
|
||||
var extension = Path.GetExtension(filename)?.ToLowerInvariant();
|
||||
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
@ -21,7 +22,6 @@ using osu.Game.Graphics.Containers;
|
||||
using osu.Game.IO.Archives;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
@ -157,6 +157,7 @@ namespace osu.Game.Screens.Play
|
||||
PrepareReplay();
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
private Score recordingScore;
|
||||
|
||||
/// <summary>
|
||||
@ -164,7 +165,7 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
protected virtual void PrepareReplay()
|
||||
{
|
||||
DrawableRuleset.SetRecordTarget(recordingScore = new Score { Replay = new Replay() });
|
||||
DrawableRuleset.SetRecordTarget(recordingScore = new Score());
|
||||
|
||||
ScoreProcessor.NewJudgement += result => ScoreProcessor.PopulateScore(recordingScore.ScoreInfo);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Skinning
|
||||
break;
|
||||
|
||||
case "HitPosition":
|
||||
currentConfig.HitPosition = (480 - float.Parse(pair.Value, CultureInfo.InvariantCulture)) * LegacyManiaSkinConfiguration.POSITION_SCALE_FACTOR;
|
||||
currentConfig.HitPosition = (480 - Math.Clamp(float.Parse(pair.Value, CultureInfo.InvariantCulture), 240, 480)) * LegacyManiaSkinConfiguration.POSITION_SCALE_FACTOR;
|
||||
break;
|
||||
|
||||
case "LightPosition":
|
||||
|
Loading…
Reference in New Issue
Block a user