mirror of
https://github.com/ppy/osu.git
synced 2024-11-08 10:47:24 +08:00
Merge branch 'master' into samah-ios
This commit is contained in:
commit
56196e17dd
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="RulesetTests (catch)" type="DotNetProject" factoryName=".NET Project">
|
<configuration default="false" name="RulesetTests (catch)" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Catch.Tests.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Catch.Tests.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Catch.Tests" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="RulesetTests (mania)" type="DotNetProject" factoryName=".NET Project">
|
<configuration default="false" name="RulesetTests (mania)" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Mania.Tests.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Mania.Tests.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Mania.Tests" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="RulesetTests (osu!)" type="DotNetProject" factoryName=".NET Project">
|
<configuration default="false" name="RulesetTests (osu!)" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Osu.Tests.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Osu.Tests.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Osu.Tests" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="RulesetTests (taiko)" type="DotNetProject" factoryName=".NET Project">
|
<configuration default="false" name="RulesetTests (taiko)" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Taiko.Tests.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Taiko.Tests.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Rulesets.Taiko.Tests" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="VisualTests" type="DotNetProject" factoryName=".NET Project">
|
<configuration default="false" name="VisualTests" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Tests/bin/Debug/netcoreapp2.1/osu.Game.Tests.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Game.Tests/bin/Debug/netcoreapp2.2/osu.Game.Tests.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Tests" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Game.Tests" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="osu!" type="DotNetProject" factoryName=".NET Project">
|
<configuration default="false" name="osu!" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp2.1/osu!.dll" />
|
<option name="EXE_PATH" value="$PROJECT_DIR$/osu.Desktop/bin/Debug/netcoreapp2.2/osu!.dll" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/osu.Desktop" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
<option name="USE_MONO" value="0" />
|
<option name="USE_MONO" value="0" />
|
||||||
|
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||||
<option name="PROJECT_PATH" value="$PROJECT_DIR$/osu.Desktop/osu.Desktop.csproj" />
|
<option name="PROJECT_PATH" value="$PROJECT_DIR$/osu.Desktop/osu.Desktop.csproj" />
|
||||||
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v2.1" />
|
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v2.2" />
|
||||||
<method />
|
<method v="2">
|
||||||
|
<option name="Build" enabled="true" />
|
||||||
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
16
.vscode/launch.json
vendored
16
.vscode/launch.json
vendored
@ -7,13 +7,13 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.1/osu.Game.Tests.dll"
|
"${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.2/osu.Game.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build tests (Debug)",
|
"preLaunchTask": "Build tests (Debug)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.1:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
@ -24,13 +24,13 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp2.1/osu.Game.Tests.dll"
|
"${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp2.2/osu.Game.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build tests (Release)",
|
"preLaunchTask": "Build tests (Release)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp2.1:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
@ -41,13 +41,13 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.1/osu!.dll"
|
"${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.2/osu!.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build osu! (Debug)",
|
"preLaunchTask": "Build osu! (Debug)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.1:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
@ -58,13 +58,13 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.1/osu!.dll"
|
"${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.2/osu!.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build osu! (Release)",
|
"preLaunchTask": "Build osu! (Release)",
|
||||||
"linux": {
|
"linux": {
|
||||||
"env": {
|
"env": {
|
||||||
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.1:${env:LD_LIBRARY_PATH}"
|
"LD_LIBRARY_PATH": "${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.2:${env:LD_LIBRARY_PATH}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
|
6
.vscode/tasks.json
vendored
6
.vscode/tasks.json
vendored
@ -11,7 +11,6 @@
|
|||||||
"build",
|
"build",
|
||||||
"--no-restore",
|
"--no-restore",
|
||||||
"osu.Desktop",
|
"osu.Desktop",
|
||||||
"/p:TargetFramework=netcoreapp2.1",
|
|
||||||
"/p:GenerateFullPaths=true",
|
"/p:GenerateFullPaths=true",
|
||||||
"/m",
|
"/m",
|
||||||
"/verbosity:m"
|
"/verbosity:m"
|
||||||
@ -27,7 +26,6 @@
|
|||||||
"build",
|
"build",
|
||||||
"--no-restore",
|
"--no-restore",
|
||||||
"osu.Desktop",
|
"osu.Desktop",
|
||||||
"/p:TargetFramework=netcoreapp2.1",
|
|
||||||
"/p:Configuration=Release",
|
"/p:Configuration=Release",
|
||||||
"/p:GenerateFullPaths=true",
|
"/p:GenerateFullPaths=true",
|
||||||
"/m",
|
"/m",
|
||||||
@ -44,7 +42,6 @@
|
|||||||
"build",
|
"build",
|
||||||
"--no-restore",
|
"--no-restore",
|
||||||
"osu.Game.Tests",
|
"osu.Game.Tests",
|
||||||
"/p:TargetFramework=netcoreapp2.1",
|
|
||||||
"/p:GenerateFullPaths=true",
|
"/p:GenerateFullPaths=true",
|
||||||
"/m",
|
"/m",
|
||||||
"/verbosity:m"
|
"/verbosity:m"
|
||||||
@ -60,7 +57,6 @@
|
|||||||
"build",
|
"build",
|
||||||
"--no-restore",
|
"--no-restore",
|
||||||
"osu.Game.Tests",
|
"osu.Game.Tests",
|
||||||
"/p:TargetFramework=netcoreapp2.1",
|
|
||||||
"/p:Configuration=Release",
|
"/p:Configuration=Release",
|
||||||
"/p:GenerateFullPaths=true",
|
"/p:GenerateFullPaths=true",
|
||||||
"/m",
|
"/m",
|
||||||
@ -70,7 +66,7 @@
|
|||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Restore (netcoreapp2.1)",
|
"label": "Restore (netcoreapp2.2)",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "dotnet",
|
"command": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
|
@ -10,7 +10,7 @@ We are accepting bug reports (please report with as much detail as possible). Fe
|
|||||||
|
|
||||||
# Requirements
|
# Requirements
|
||||||
|
|
||||||
- A desktop platform with the [.NET Core SDK 2.1](https://www.microsoft.com/net/learn/get-started) or higher installed.
|
- A desktop platform with the [.NET Core SDK 2.2](https://www.microsoft.com/net/learn/get-started) or higher installed.
|
||||||
- When working with the codebase, we recommend using an IDE with intellisense and syntax highlighting, such as [Visual Studio Community Edition](https://www.visualstudio.com/) (Windows), [Visual Studio Code](https://code.visualstudio.com/) (with the C# plugin installed) or [Jetbrains Rider](https://www.jetbrains.com/rider/) (commercial).
|
- When working with the codebase, we recommend using an IDE with intellisense and syntax highlighting, such as [Visual Studio Community Edition](https://www.visualstudio.com/) (Windows), [Visual Studio Code](https://code.visualstudio.com/) (with the C# plugin installed) or [Jetbrains Rider](https://www.jetbrains.com/rider/) (commercial).
|
||||||
|
|
||||||
# Building and running
|
# Building and running
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Import Project="..\osu.Game.props" />
|
<Import Project="..\osu.Game.props" />
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Catch.Tests.dll"
|
"${workspaceRoot}/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Catch.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Debug)",
|
"preLaunchTask": "Build (Debug)",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Release/netcoreapp2.1/osu.Game.Rulesets.Catch.Tests.dll"
|
"${workspaceRoot}/bin/Release/netcoreapp2.2/osu.Game.Rulesets.Catch.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Release)",
|
"preLaunchTask": "Build (Release)",
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="Project References">
|
<ItemGroup Label="Project References">
|
||||||
<ProjectReference Include="..\osu.Game.Rulesets.Catch\osu.Game.Rulesets.Catch.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Catch\osu.Game.Rulesets.Catch.csproj" />
|
||||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Catch.Judgements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override float HealthIncreaseFor(HitResult result)
|
protected override double HealthIncreaseFor(HitResult result)
|
||||||
{
|
{
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Catch.Judgements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override float HealthIncreaseFor(HitResult result)
|
protected override double HealthIncreaseFor(HitResult result)
|
||||||
{
|
{
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
|
@ -22,29 +22,17 @@ namespace osu.Game.Rulesets.Catch.Judgements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
protected override double HealthIncreaseFor(HitResult result)
|
||||||
/// Retrieves the numeric health increase of a <see cref="HitResult"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="result">The <see cref="HitResult"/> to find the numeric health increase for.</param>
|
|
||||||
/// <returns>The numeric health increase of <paramref name="result"/>.</returns>
|
|
||||||
protected virtual float HealthIncreaseFor(HitResult result)
|
|
||||||
{
|
{
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
case HitResult.Perfect:
|
case HitResult.Perfect:
|
||||||
return 10.2f;
|
return 10.2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieves the numeric health increase of a <see cref="JudgementResult"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="result">The <see cref="JudgementResult"/> to find the numeric health increase for.</param>
|
|
||||||
/// <returns>The numeric health increase of <paramref name="result"/>.</returns>
|
|
||||||
public float HealthIncreaseFor(JudgementResult result) => HealthIncreaseFor(result.Type);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether fruit on the platter should explode or drop.
|
/// Whether fruit on the platter should explode or drop.
|
||||||
/// Note that this is only checked if the owning object is also <see cref="IHasComboInformation.LastInCombo" />
|
/// Note that this is only checked if the owning object is also <see cref="IHasComboInformation.LastInCombo" />
|
||||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Catch.Judgements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override float HealthIncreaseFor(HitResult result)
|
protected override double HealthIncreaseFor(HitResult result)
|
||||||
{
|
{
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Judgements;
|
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -40,8 +39,7 @@ namespace osu.Game.Rulesets.Catch.Scoring
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.Judgement is CatchJudgement catchJudgement)
|
Health.Value += Math.Max(result.Judgement.HealthIncreaseFor(result) - hpDrainRate, 0) * harshness;
|
||||||
Health.Value += Math.Max(catchJudgement.HealthIncreaseFor(result) - hpDrainRate, 0) * harshness;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Mania.Tests.dll"
|
"${workspaceRoot}/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Mania.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Debug)",
|
"preLaunchTask": "Build (Debug)",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Release/netcoreapp2.1/osu.Game.Rulesets.Mania.Tests.dll"
|
"${workspaceRoot}/bin/Release/netcoreapp2.2/osu.Game.Rulesets.Mania.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Release)",
|
"preLaunchTask": "Build (Release)",
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="Project References">
|
<ItemGroup Label="Project References">
|
||||||
<ProjectReference Include="..\osu.Game.Rulesets.Mania\osu.Game.Rulesets.Mania.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Mania\osu.Game.Rulesets.Mania.csproj" />
|
||||||
|
@ -20,11 +20,10 @@ namespace osu.Game.Rulesets.Mania.Objects
|
|||||||
{ HitResult.Miss, (376, 346, 316) },
|
{ HitResult.Miss, (376, 346, 316) },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public override bool IsHitResultAllowed(HitResult result) => true;
|
||||||
|
|
||||||
public override void SetDifficulty(double difficulty)
|
public override void SetDifficulty(double difficulty)
|
||||||
{
|
{
|
||||||
AllowsPerfect = true;
|
|
||||||
AllowsOk = true;
|
|
||||||
|
|
||||||
Perfect = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Perfect]);
|
Perfect = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Perfect]);
|
||||||
Great = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Great]);
|
Great = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Great]);
|
||||||
Good = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Good]);
|
Good = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Good]);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Osu.Tests.dll"
|
"${workspaceRoot}/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Osu.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Debug)",
|
"preLaunchTask": "Build (Debug)",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Release/netcoreapp2.1/osu.Game.Rulesets.Osu.Tests.dll"
|
"${workspaceRoot}/bin/Release/netcoreapp2.2/osu.Game.Rulesets.Osu.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Release)",
|
"preLaunchTask": "Build (Release)",
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="Project References">
|
<ItemGroup Label="Project References">
|
||||||
<ProjectReference Include="..\osu.Game.Rulesets.Osu\osu.Game.Rulesets.Osu.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Osu\osu.Game.Rulesets.Osu.csproj" />
|
||||||
|
194
osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs
Normal file
194
osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Mods
|
||||||
|
{
|
||||||
|
public class OsuModBlinds : Mod, IApplicableToRulesetContainer<OsuHitObject>, IApplicableToScoreProcessor
|
||||||
|
{
|
||||||
|
public override string Name => "Blinds";
|
||||||
|
public override string Description => "Play with blinds on your screen.";
|
||||||
|
public override string Acronym => "BL";
|
||||||
|
|
||||||
|
public override FontAwesome Icon => FontAwesome.fa_adjust;
|
||||||
|
public override ModType Type => ModType.DifficultyIncrease;
|
||||||
|
|
||||||
|
public override bool Ranked => false;
|
||||||
|
|
||||||
|
public override double ScoreMultiplier => 1.12;
|
||||||
|
private DrawableOsuBlinds blinds;
|
||||||
|
|
||||||
|
public void ApplyToRulesetContainer(RulesetContainer<OsuHitObject> rulesetContainer)
|
||||||
|
{
|
||||||
|
rulesetContainer.Overlays.Add(blinds = new DrawableOsuBlinds(rulesetContainer.Playfield.HitObjectContainer, rulesetContainer.Beatmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
||||||
|
{
|
||||||
|
scoreProcessor.Health.ValueChanged += val => { blinds.AnimateClosedness((float)val); };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Element for the Blinds mod drawing 2 black boxes covering the whole screen which resize inside a restricted area with some leniency.
|
||||||
|
/// </summary>
|
||||||
|
public class DrawableOsuBlinds : Container
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Black background boxes behind blind panel textures.
|
||||||
|
/// </summary>
|
||||||
|
private Box blackBoxLeft, blackBoxRight;
|
||||||
|
|
||||||
|
private Drawable panelLeft, panelRight, bgPanelLeft, bgPanelRight;
|
||||||
|
|
||||||
|
private readonly Beatmap<OsuHitObject> beatmap;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Value between 0 and 1 setting a maximum "closedness" for the blinds.
|
||||||
|
/// Useful for animating how far the blinds can be opened while keeping them at the original position if they are wider open than this.
|
||||||
|
/// </summary>
|
||||||
|
private const float target_clamp = 1;
|
||||||
|
|
||||||
|
private readonly float targetBreakMultiplier = 0;
|
||||||
|
private readonly float easing = 1;
|
||||||
|
|
||||||
|
private readonly CompositeDrawable restrictTo;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>
|
||||||
|
/// Percentage of playfield to extend blinds over. Basically moves the origin points where the blinds start.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// -1 would mean the blinds always cover the whole screen no matter health.
|
||||||
|
/// 0 would mean the blinds will only ever be on the edge of the playfield on 0% health.
|
||||||
|
/// 1 would mean the blinds are fully outside the playfield on 50% health.
|
||||||
|
/// Infinity would mean the blinds are always outside the playfield except on 100% health.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
private const float leniency = 0.1f;
|
||||||
|
|
||||||
|
public DrawableOsuBlinds(CompositeDrawable restrictTo, Beatmap<OsuHitObject> beatmap)
|
||||||
|
{
|
||||||
|
this.restrictTo = restrictTo;
|
||||||
|
this.beatmap = beatmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
blackBoxLeft = new Box
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopLeft,
|
||||||
|
Origin = Anchor.TopLeft,
|
||||||
|
Colour = Color4.Black,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
|
blackBoxRight = new Box
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
Colour = Color4.Black,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
|
bgPanelLeft = new ModBlindsPanel
|
||||||
|
{
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
Colour = Color4.Gray,
|
||||||
|
},
|
||||||
|
panelLeft = new ModBlindsPanel { Origin = Anchor.TopRight, },
|
||||||
|
bgPanelRight = new ModBlindsPanel { Colour = Color4.Gray },
|
||||||
|
panelRight = new ModBlindsPanel()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private float calculateGap(float value) => MathHelper.Clamp(value, 0, target_clamp) * targetBreakMultiplier;
|
||||||
|
|
||||||
|
// lagrange polinominal for (0,0) (0.6,0.4) (1,1) should make a good curve
|
||||||
|
private static float applyAdjustmentCurve(float value) => 0.6f * value * value + 0.4f * value;
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
float start = Parent.ToLocalSpace(restrictTo.ScreenSpaceDrawQuad.TopLeft).X;
|
||||||
|
float end = Parent.ToLocalSpace(restrictTo.ScreenSpaceDrawQuad.TopRight).X;
|
||||||
|
|
||||||
|
float rawWidth = end - start;
|
||||||
|
|
||||||
|
start -= rawWidth * leniency * 0.5f;
|
||||||
|
end += rawWidth * leniency * 0.5f;
|
||||||
|
|
||||||
|
float width = (end - start) * 0.5f * applyAdjustmentCurve(calculateGap(easing));
|
||||||
|
|
||||||
|
// different values in case the playfield ever moves from center to somewhere else.
|
||||||
|
blackBoxLeft.Width = start + width;
|
||||||
|
blackBoxRight.Width = DrawWidth - end + width;
|
||||||
|
|
||||||
|
panelLeft.X = start + width;
|
||||||
|
panelRight.X = end - width;
|
||||||
|
bgPanelLeft.X = start;
|
||||||
|
bgPanelRight.X = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
const float break_open_early = 500;
|
||||||
|
const float break_close_late = 250;
|
||||||
|
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
var firstObj = beatmap.HitObjects[0];
|
||||||
|
var startDelay = firstObj.StartTime - firstObj.TimePreempt;
|
||||||
|
|
||||||
|
using (BeginAbsoluteSequence(startDelay + break_close_late, true))
|
||||||
|
leaveBreak();
|
||||||
|
|
||||||
|
foreach (var breakInfo in beatmap.Breaks)
|
||||||
|
{
|
||||||
|
if (breakInfo.HasEffect)
|
||||||
|
{
|
||||||
|
using (BeginAbsoluteSequence(breakInfo.StartTime - break_open_early, true))
|
||||||
|
{
|
||||||
|
enterBreak();
|
||||||
|
using (BeginDelayedSequence(breakInfo.Duration + break_open_early + break_close_late, true))
|
||||||
|
leaveBreak();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enterBreak() => this.TransformTo(nameof(targetBreakMultiplier), 0f, 1000, Easing.OutSine);
|
||||||
|
|
||||||
|
private void leaveBreak() => this.TransformTo(nameof(targetBreakMultiplier), 1f, 2500, Easing.OutBounce);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 0 is open, 1 is closed.
|
||||||
|
/// </summary>
|
||||||
|
public void AnimateClosedness(float value) => this.TransformTo(nameof(easing), value, 200, Easing.OutQuint);
|
||||||
|
|
||||||
|
public class ModBlindsPanel : Sprite
|
||||||
|
{
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(TextureStore textures)
|
||||||
|
{
|
||||||
|
Texture = textures.Get("Play/osu/blinds-panel");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,9 +26,6 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
if (slider == null)
|
if (slider == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
slider.HeadCircle.Position = new Vector2(slider.HeadCircle.Position.X, OsuPlayfield.BASE_SIZE.Y - slider.HeadCircle.Position.Y);
|
|
||||||
slider.TailCircle.Position = new Vector2(slider.TailCircle.Position.X, OsuPlayfield.BASE_SIZE.Y - slider.TailCircle.Position.Y);
|
|
||||||
|
|
||||||
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||||
slider.NestedHitObjects.OfType<RepeatPoint>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
slider.NestedHitObjects.OfType<RepeatPoint>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
new MultiMod(new OsuModSuddenDeath(), new OsuModPerfect()),
|
new MultiMod(new OsuModSuddenDeath(), new OsuModPerfect()),
|
||||||
new MultiMod(new OsuModDoubleTime(), new OsuModNightcore()),
|
new MultiMod(new OsuModDoubleTime(), new OsuModNightcore()),
|
||||||
new OsuModHidden(),
|
new OsuModHidden(),
|
||||||
new OsuModFlashlight(),
|
new MultiMod(new OsuModFlashlight(), new OsuModBlinds()),
|
||||||
};
|
};
|
||||||
case ModType.Conversion:
|
case ModType.Conversion:
|
||||||
return new Mod[]
|
return new Mod[]
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Taiko.Tests.dll"
|
"${workspaceRoot}/bin/Debug/netcoreapp2.2/osu.Game.Rulesets.Taiko.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Debug)",
|
"preLaunchTask": "Build (Debug)",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "dotnet",
|
"program": "dotnet",
|
||||||
"args": [
|
"args": [
|
||||||
"${workspaceRoot}/bin/Release/netcoreapp2.1/osu.Game.Rulesets.Taiko.Tests.dll"
|
"${workspaceRoot}/bin/Release/netcoreapp2.2/osu.Game.Rulesets.Taiko.Tests.dll"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"preLaunchTask": "Build (Release)",
|
"preLaunchTask": "Build (Release)",
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="Project References">
|
<ItemGroup Label="Project References">
|
||||||
<ProjectReference Include="..\osu.Game.Rulesets.Taiko\osu.Game.Rulesets.Taiko.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Taiko\osu.Game.Rulesets.Taiko.csproj" />
|
||||||
|
24
osu.Game.Rulesets.Taiko/Judgements/TaikoDrumRollJudgement.cs
Normal file
24
osu.Game.Rulesets.Taiko/Judgements/TaikoDrumRollJudgement.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Judgements
|
||||||
|
{
|
||||||
|
public class TaikoDrumRollJudgement : TaikoJudgement
|
||||||
|
{
|
||||||
|
public override bool AffectsCombo => false;
|
||||||
|
|
||||||
|
protected override double HealthIncreaseFor(HitResult result)
|
||||||
|
{
|
||||||
|
// Drum rolls can be ignored with no health penalty
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case HitResult.Miss:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return base.HealthIncreaseFor(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,10 +13,21 @@ namespace osu.Game.Rulesets.Taiko.Judgements
|
|||||||
{
|
{
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
case HitResult.Great:
|
case HitResult.Great:
|
||||||
return 200;
|
return 200;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override double HealthIncreaseFor(HitResult result)
|
||||||
|
{
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case HitResult.Great:
|
||||||
|
return 0.15;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using osu.Game.Rulesets.Scoring;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Judgements
|
|
||||||
{
|
|
||||||
public class TaikoIntermediateSwellJudgement : TaikoJudgement
|
|
||||||
{
|
|
||||||
public override HitResult MaxResult => HitResult.Great;
|
|
||||||
|
|
||||||
public override bool AffectsCombo => false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Computes the numeric result value for the combo portion of the score.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="result">The result to compute the value for.</param>
|
|
||||||
/// <returns>The numeric result value.</returns>
|
|
||||||
protected override int NumericResultFor(HitResult result) => 0;
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,21 +10,31 @@ namespace osu.Game.Rulesets.Taiko.Judgements
|
|||||||
{
|
{
|
||||||
public override HitResult MaxResult => HitResult.Great;
|
public override HitResult MaxResult => HitResult.Great;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Computes the numeric result value for the combo portion of the score.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="result">The result to compute the value for.</param>
|
|
||||||
/// <returns>The numeric result value.</returns>
|
|
||||||
protected override int NumericResultFor(HitResult result)
|
protected override int NumericResultFor(HitResult result)
|
||||||
{
|
{
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
case HitResult.Good:
|
case HitResult.Good:
|
||||||
return 100;
|
return 100;
|
||||||
case HitResult.Great:
|
case HitResult.Great:
|
||||||
return 300;
|
return 300;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override double HealthIncreaseFor(HitResult result)
|
||||||
|
{
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case HitResult.Miss:
|
||||||
|
return -1.0;
|
||||||
|
case HitResult.Good:
|
||||||
|
return 1.1;
|
||||||
|
case HitResult.Great:
|
||||||
|
return 3.0;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
// 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.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Judgements
|
namespace osu.Game.Rulesets.Taiko.Judgements
|
||||||
{
|
{
|
||||||
public class TaikoStrongJudgement : TaikoJudgement
|
public class TaikoStrongJudgement : TaikoJudgement
|
||||||
{
|
{
|
||||||
|
// MainObject already changes the HP
|
||||||
|
protected override double HealthIncreaseFor(HitResult result) => 0;
|
||||||
|
|
||||||
public override bool AffectsCombo => false;
|
public override bool AffectsCombo => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
osu.Game.Rulesets.Taiko/Judgements/TaikoSwellJudgement.cs
Normal file
23
osu.Game.Rulesets.Taiko/Judgements/TaikoSwellJudgement.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Judgements
|
||||||
|
{
|
||||||
|
public class TaikoSwellJudgement : TaikoJudgement
|
||||||
|
{
|
||||||
|
public override bool AffectsCombo => false;
|
||||||
|
|
||||||
|
protected override double HealthIncreaseFor(HitResult result)
|
||||||
|
{
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case HitResult.Miss:
|
||||||
|
return -0.65;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Judgements
|
||||||
|
{
|
||||||
|
public class TaikoSwellTickJudgement : TaikoJudgement
|
||||||
|
{
|
||||||
|
public override bool AffectsCombo => false;
|
||||||
|
|
||||||
|
protected override int NumericResultFor(HitResult result) => 0;
|
||||||
|
|
||||||
|
protected override double HealthIncreaseFor(HitResult result) => 0;
|
||||||
|
}
|
||||||
|
}
|
@ -173,13 +173,13 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
|
|
||||||
if (!userTriggered)
|
if (!userTriggered)
|
||||||
{
|
{
|
||||||
if (timeOffset > second_hit_window)
|
if (timeOffset - MainObject.Result.TimeOffset > second_hit_window)
|
||||||
ApplyResult(r => r.Type = HitResult.Miss);
|
ApplyResult(r => r.Type = HitResult.Miss);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.Abs(MainObject.Result.TimeOffset - timeOffset) < second_hit_window)
|
if (Math.Abs(timeOffset - MainObject.Result.TimeOffset) <= second_hit_window)
|
||||||
ApplyResult(r => r.Type = HitResult.Great);
|
ApplyResult(r => r.Type = MainObject.Result.Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnPressed(TaikoAction action)
|
public override bool OnPressed(TaikoAction action)
|
||||||
|
@ -6,11 +6,11 @@ using osu.Game.Rulesets.Scoring;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||||
{
|
{
|
||||||
public class DrawableSwellTick : DrawableTaikoHitObject
|
public class DrawableSwellTick : DrawableTaikoHitObject<SwellTick>
|
||||||
{
|
{
|
||||||
public override bool DisplayResult => false;
|
public override bool DisplayResult => false;
|
||||||
|
|
||||||
public DrawableSwellTick(TaikoHitObject hitObject)
|
public DrawableSwellTick(SwellTick hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ using osu.Game.Rulesets.Objects.Types;
|
|||||||
using System;
|
using System;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Taiko.Judgements;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects
|
namespace osu.Game.Rulesets.Taiko.Objects
|
||||||
{
|
{
|
||||||
@ -81,5 +83,7 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Judgement CreateJudgement() => new TaikoDrumRollJudgement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Taiko.Judgements;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects
|
namespace osu.Game.Rulesets.Taiko.Objects
|
||||||
{
|
{
|
||||||
@ -26,5 +28,7 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
for (int i = 0; i < RequiredHits; i++)
|
for (int i = 0; i < RequiredHits; i++)
|
||||||
AddNested(new SwellTick());
|
AddNested(new SwellTick());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Judgement CreateJudgement() => new TaikoSwellJudgement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
// 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.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Taiko.Judgements;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects
|
namespace osu.Game.Rulesets.Taiko.Objects
|
||||||
{
|
{
|
||||||
public class SwellTick : TaikoHitObject
|
public class SwellTick : TaikoHitObject
|
||||||
{
|
{
|
||||||
|
public override Judgement CreateJudgement() => new TaikoSwellTickJudgement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,26 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
{
|
{
|
||||||
{ HitResult.Great, (100, 70, 40) },
|
{ HitResult.Great, (100, 70, 40) },
|
||||||
{ HitResult.Good, (240, 160, 100) },
|
{ HitResult.Good, (240, 160, 100) },
|
||||||
{ HitResult.Meh, (270, 190, 140) },
|
{ HitResult.Miss, (270, 190, 140) },
|
||||||
{ HitResult.Miss, (400, 400, 400) },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public override bool IsHitResultAllowed(HitResult result)
|
||||||
|
{
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case HitResult.Great:
|
||||||
|
case HitResult.Good:
|
||||||
|
case HitResult.Miss:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void SetDifficulty(double difficulty)
|
public override void SetDifficulty(double difficulty)
|
||||||
{
|
{
|
||||||
Great = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Great]);
|
Great = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Great]);
|
||||||
Good = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Good]);
|
Good = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Good]);
|
||||||
Meh = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Meh]);
|
|
||||||
Miss = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Miss]);
|
Miss = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Miss]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.Taiko.Judgements;
|
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
@ -13,51 +12,24 @@ namespace osu.Game.Rulesets.Taiko.Scoring
|
|||||||
internal class TaikoScoreProcessor : ScoreProcessor<TaikoHitObject>
|
internal class TaikoScoreProcessor : ScoreProcessor<TaikoHitObject>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The HP awarded by a <see cref="HitResult.Great"/> hit.
|
/// A value used for calculating <see cref="hpMultiplier"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const double hp_hit_great = 0.03;
|
private const double object_count_factor = 3;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The HP awarded for a <see cref="HitResult.Good"/> hit.
|
|
||||||
/// </summary>
|
|
||||||
private const double hp_hit_good = 0.011;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The minimum HP deducted for a <see cref="HitResult.Miss"/>.
|
|
||||||
/// This occurs when HP Drain = 0.
|
|
||||||
/// </summary>
|
|
||||||
private const double hp_miss_min = -0.0018;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The median HP deducted for a <see cref="HitResult.Miss"/>.
|
|
||||||
/// This occurs when HP Drain = 5.
|
|
||||||
/// </summary>
|
|
||||||
private const double hp_miss_mid = -0.0075;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The maximum HP deducted for a <see cref="HitResult.Miss"/>.
|
|
||||||
/// This occurs when HP Drain = 10.
|
|
||||||
/// </summary>
|
|
||||||
private const double hp_miss_max = -0.12;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The HP awarded for a <see cref="DrumRollTick"/> hit.
|
|
||||||
/// <para>
|
|
||||||
/// <see cref="DrumRollTick"/> hits award less HP as they're more spammable, although in hindsight
|
|
||||||
/// this probably awards too little HP and is kept at this value for now for compatibility.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
private const double hp_hit_tick = 0.00000003;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Taiko fails at the end of the map if the player has not half-filled their HP bar.
|
/// Taiko fails at the end of the map if the player has not half-filled their HP bar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override bool DefaultFailCondition => JudgedHits == MaxHits && Health.Value <= 0.5;
|
protected override bool DefaultFailCondition => JudgedHits == MaxHits && Health.Value <= 0.5;
|
||||||
|
|
||||||
private double hpIncreaseTick;
|
/// <summary>
|
||||||
private double hpIncreaseGreat;
|
/// HP multiplier for a successful <see cref="HitResult"/>.
|
||||||
private double hpIncreaseGood;
|
/// </summary>
|
||||||
private double hpIncreaseMiss;
|
private double hpMultiplier;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// HP multiplier for a <see cref="HitResult.Miss"/>.
|
||||||
|
/// </summary>
|
||||||
|
private double hpMissMultiplier;
|
||||||
|
|
||||||
public TaikoScoreProcessor(RulesetContainer<TaikoHitObject> rulesetContainer)
|
public TaikoScoreProcessor(RulesetContainer<TaikoHitObject> rulesetContainer)
|
||||||
: base(rulesetContainer)
|
: base(rulesetContainer)
|
||||||
@ -68,38 +40,23 @@ namespace osu.Game.Rulesets.Taiko.Scoring
|
|||||||
{
|
{
|
||||||
base.ApplyBeatmap(beatmap);
|
base.ApplyBeatmap(beatmap);
|
||||||
|
|
||||||
double hpMultiplierNormal = 1 / (hp_hit_great * beatmap.HitObjects.FindAll(o => o is Hit).Count * BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.5, 0.75, 0.98));
|
hpMultiplier = 1 / (object_count_factor * beatmap.HitObjects.FindAll(o => o is Hit).Count * BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.5, 0.75, 0.98));
|
||||||
|
|
||||||
hpIncreaseTick = hp_hit_tick;
|
hpMissMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.0018, 0.0075, 0.0120);
|
||||||
hpIncreaseGreat = hpMultiplierNormal * hp_hit_great;
|
|
||||||
hpIncreaseGood = hpMultiplierNormal * hp_hit_good;
|
|
||||||
hpIncreaseMiss = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, hp_miss_min, hp_miss_mid, hp_miss_max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ApplyResult(JudgementResult result)
|
protected override void ApplyResult(JudgementResult result)
|
||||||
{
|
{
|
||||||
base.ApplyResult(result);
|
base.ApplyResult(result);
|
||||||
|
|
||||||
bool isTick = result.Judgement is TaikoDrumRollTickJudgement;
|
double hpIncrease = result.Judgement.HealthIncreaseFor(result);
|
||||||
|
|
||||||
// Apply HP changes
|
if (result.Type == HitResult.Miss)
|
||||||
switch (result.Type)
|
hpIncrease *= hpMissMultiplier;
|
||||||
{
|
else
|
||||||
case HitResult.Miss:
|
hpIncrease *= hpMultiplier;
|
||||||
// Missing ticks shouldn't drop HP
|
|
||||||
if (!isTick)
|
Health.Value += hpIncrease;
|
||||||
Health.Value += hpIncreaseMiss;
|
|
||||||
break;
|
|
||||||
case HitResult.Good:
|
|
||||||
Health.Value += hpIncreaseGood;
|
|
||||||
break;
|
|
||||||
case HitResult.Great:
|
|
||||||
if (isTick)
|
|
||||||
Health.Value += hpIncreaseTick;
|
|
||||||
else
|
|
||||||
Health.Value += hpIncreaseGreat;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Reset(bool storeResults)
|
protected override void Reset(bool storeResults)
|
||||||
|
143
osu.Game.Tests/Visual/TestCasePollingComponent.cs
Normal file
143
osu.Game.Tests/Visual/TestCasePollingComponent.cs
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Logging;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Online;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
public class TestCasePollingComponent : OsuTestCase
|
||||||
|
{
|
||||||
|
private Container pollBox;
|
||||||
|
private TestPoller poller;
|
||||||
|
|
||||||
|
private const float safety_adjust = 1f;
|
||||||
|
private int count;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
pollBox = new Container
|
||||||
|
{
|
||||||
|
Alpha = 0,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Scale = new Vector2(0.4f),
|
||||||
|
Colour = Color4.LimeGreen,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Text = "Poll!",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestInstantPolling()
|
||||||
|
{
|
||||||
|
createPoller(true);
|
||||||
|
|
||||||
|
AddStep("set poll interval to 1", () => poller.TimeBetweenPolls = TimePerAction * safety_adjust);
|
||||||
|
checkCount(1);
|
||||||
|
checkCount(2);
|
||||||
|
checkCount(3);
|
||||||
|
|
||||||
|
AddStep("set poll interval to 5", () => poller.TimeBetweenPolls = TimePerAction * safety_adjust * 5);
|
||||||
|
checkCount(4);
|
||||||
|
checkCount(4);
|
||||||
|
checkCount(4);
|
||||||
|
|
||||||
|
skip();
|
||||||
|
|
||||||
|
checkCount(5);
|
||||||
|
checkCount(5);
|
||||||
|
|
||||||
|
AddStep("set poll interval to 1", () => poller.TimeBetweenPolls = TimePerAction * safety_adjust);
|
||||||
|
checkCount(6);
|
||||||
|
checkCount(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Ignore("i have no idea how to fix the timing of this one")]
|
||||||
|
public void TestSlowPolling()
|
||||||
|
{
|
||||||
|
createPoller(false);
|
||||||
|
|
||||||
|
AddStep("set poll interval to 1", () => poller.TimeBetweenPolls = TimePerAction * safety_adjust * 5);
|
||||||
|
checkCount(0);
|
||||||
|
skip();
|
||||||
|
checkCount(0);
|
||||||
|
skip();
|
||||||
|
skip();
|
||||||
|
checkCount(0);
|
||||||
|
skip();
|
||||||
|
skip();
|
||||||
|
checkCount(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void skip() => AddStep("skip", () =>
|
||||||
|
{
|
||||||
|
// could be 4 or 5 at this point due to timing discrepancies (safety_adjust @ 0.2 * 5 ~= 1)
|
||||||
|
// easiest to just ignore the value at this point and move on.
|
||||||
|
});
|
||||||
|
|
||||||
|
private void checkCount(int checkValue)
|
||||||
|
{
|
||||||
|
Logger.Log($"value is {count}");
|
||||||
|
AddAssert($"count is {checkValue}", () => count == checkValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createPoller(bool instant) => AddStep("create poller", () =>
|
||||||
|
{
|
||||||
|
poller?.Expire();
|
||||||
|
|
||||||
|
Add(poller = instant ? new TestPoller() : new TestSlowPoller());
|
||||||
|
poller.OnPoll += () =>
|
||||||
|
{
|
||||||
|
pollBox.FadeOutFromOne(500);
|
||||||
|
count++;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
protected override double TimePerAction => 500;
|
||||||
|
|
||||||
|
public class TestPoller : PollingComponent
|
||||||
|
{
|
||||||
|
public event Action OnPoll;
|
||||||
|
|
||||||
|
protected override Task Poll()
|
||||||
|
{
|
||||||
|
Schedule(() => OnPoll?.Invoke());
|
||||||
|
return base.Poll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestSlowPoller : TestPoller
|
||||||
|
{
|
||||||
|
protected override Task Poll() => Task.Delay((int)(TimeBetweenPolls / 2f / Clock.Rate)).ContinueWith(_ => base.Poll());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
102
osu.Game.Tests/Visual/TestCaseStandAloneChatDisplay.cs
Normal file
102
osu.Game.Tests/Visual/TestCaseStandAloneChatDisplay.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Online.Chat;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
public class TestCaseStandAloneChatDisplay : OsuTestCase
|
||||||
|
{
|
||||||
|
private readonly Channel testChannel = new Channel();
|
||||||
|
|
||||||
|
private readonly User admin = new User
|
||||||
|
{
|
||||||
|
Username = "HappyStick",
|
||||||
|
Id = 2,
|
||||||
|
Colour = "f2ca34"
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly User redUser = new User
|
||||||
|
{
|
||||||
|
Username = "BanchoBot",
|
||||||
|
Id = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly User blueUser = new User
|
||||||
|
{
|
||||||
|
Username = "Zallius",
|
||||||
|
Id = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private ChannelManager channelManager = new ChannelManager();
|
||||||
|
|
||||||
|
private readonly StandAloneChatDisplay chatDisplay;
|
||||||
|
private readonly StandAloneChatDisplay chatDisplay2;
|
||||||
|
|
||||||
|
public TestCaseStandAloneChatDisplay()
|
||||||
|
{
|
||||||
|
Add(channelManager);
|
||||||
|
|
||||||
|
Add(chatDisplay = new StandAloneChatDisplay
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Margin = new MarginPadding(20),
|
||||||
|
Size = new Vector2(400, 80)
|
||||||
|
});
|
||||||
|
|
||||||
|
Add(chatDisplay2 = new StandAloneChatDisplay(true)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Margin = new MarginPadding(20),
|
||||||
|
Size = new Vector2(400, 150)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
channelManager.CurrentChannel.Value = testChannel;
|
||||||
|
|
||||||
|
chatDisplay.Channel.Value = testChannel;
|
||||||
|
chatDisplay2.Channel.Value = testChannel;
|
||||||
|
|
||||||
|
AddStep("message from admin", () => testChannel.AddLocalEcho(new LocalEchoMessage
|
||||||
|
{
|
||||||
|
Sender = admin,
|
||||||
|
Content = "I am a wang!"
|
||||||
|
}));
|
||||||
|
|
||||||
|
AddStep("message from team red", () => testChannel.AddLocalEcho(new LocalEchoMessage
|
||||||
|
{
|
||||||
|
Sender = redUser,
|
||||||
|
Content = "I am team red."
|
||||||
|
}));
|
||||||
|
|
||||||
|
AddStep("message from team red", () => testChannel.AddLocalEcho(new LocalEchoMessage
|
||||||
|
{
|
||||||
|
Sender = redUser,
|
||||||
|
Content = "I plan to win!"
|
||||||
|
}));
|
||||||
|
|
||||||
|
AddStep("message from team blue", () => testChannel.AddLocalEcho(new LocalEchoMessage
|
||||||
|
{
|
||||||
|
Sender = blueUser,
|
||||||
|
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
|
||||||
|
}));
|
||||||
|
|
||||||
|
AddStep("message from admin", () => testChannel.AddLocalEcho(new LocalEchoMessage
|
||||||
|
{
|
||||||
|
Sender = admin,
|
||||||
|
Content = "Okay okay, calm down guys. Let's do this!"
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Project">
|
<PropertyGroup Label="Project">
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="Project References">
|
<ItemGroup Label="Project References">
|
||||||
<ProjectReference Include="..\osu.Game.Rulesets.Osu\osu.Game.Rulesets.Osu.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Osu\osu.Game.Rulesets.Osu.csproj" />
|
||||||
|
@ -149,8 +149,10 @@ namespace osu.Game.Database
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
notification.Text = $"Importing ({++current} of {paths.Length})\n{Path.GetFileName(path)}";
|
notification.Text = $"Importing ({++current} of {paths.Length})\n{Path.GetFileName(path)}";
|
||||||
|
|
||||||
|
TModel import;
|
||||||
using (ArchiveReader reader = getReaderFrom(path))
|
using (ArchiveReader reader = getReaderFrom(path))
|
||||||
imported.Add(Import(reader));
|
imported.Add(import = Import(reader));
|
||||||
|
|
||||||
notification.Progress = (float)current / paths.Length;
|
notification.Progress = (float)current / paths.Length;
|
||||||
|
|
||||||
@ -160,7 +162,7 @@ namespace osu.Game.Database
|
|||||||
// TODO: Add a check to prevent files from storage to be deleted.
|
// TODO: Add a check to prevent files from storage to be deleted.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (File.Exists(path))
|
if (import != null && File.Exists(path))
|
||||||
File.Delete(path);
|
File.Delete(path);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -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 System;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -99,7 +100,20 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bindable<bool> Current { get; } = new Bindable<bool>();
|
private readonly Bindable<bool> current = new Bindable<bool>();
|
||||||
|
|
||||||
|
public Bindable<bool> Current
|
||||||
|
{
|
||||||
|
get => current;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
|
||||||
|
current.UnbindBindings();
|
||||||
|
current.BindTo(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Color4 accentColour;
|
private Color4 accentColour;
|
||||||
public Color4 AccentColour
|
public Color4 AccentColour
|
||||||
|
@ -102,7 +102,7 @@ namespace osu.Game.Online.API
|
|||||||
if (queue.Count == 0)
|
if (queue.Count == 0)
|
||||||
{
|
{
|
||||||
log.Add(@"Queueing a ping request");
|
log.Add(@"Queueing a ping request");
|
||||||
Queue(new ListChannelsRequest { Timeout = 5000 });
|
Queue(new GetUserRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -173,7 +173,6 @@ namespace osu.Game.Online.API
|
|||||||
req = queue.Dequeue();
|
req = queue.Dequeue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle failures better
|
|
||||||
handleRequest(req);
|
handleRequest(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,64 +190,30 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle a single API request.
|
/// Handle a single API request.
|
||||||
|
/// Ensures all exceptions are caught and dealt with correctly.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="req">The request.</param>
|
/// <param name="req">The request.</param>
|
||||||
/// <returns>true if we should remove this request from the queue.</returns>
|
/// <returns>true if the request succeeded.</returns>
|
||||||
private bool handleRequest(APIRequest req)
|
private bool handleRequest(APIRequest req)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logger.Log($@"Performing request {req}", LoggingTarget.Network);
|
|
||||||
req.Perform(this);
|
req.Perform(this);
|
||||||
|
|
||||||
//we could still be in initialisation, at which point we don't want to say we're Online yet.
|
//we could still be in initialisation, at which point we don't want to say we're Online yet.
|
||||||
if (IsLoggedIn)
|
if (IsLoggedIn) State = APIState.Online;
|
||||||
State = APIState.Online;
|
|
||||||
|
|
||||||
failureCount = 0;
|
failureCount = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (WebException we)
|
catch (WebException we)
|
||||||
{
|
{
|
||||||
HttpStatusCode statusCode = (we.Response as HttpWebResponse)?.StatusCode
|
handleWebException(we);
|
||||||
?? (we.Status == WebExceptionStatus.UnknownError ? HttpStatusCode.NotAcceptable : HttpStatusCode.RequestTimeout);
|
return false;
|
||||||
|
|
||||||
// special cases for un-typed but useful message responses.
|
|
||||||
switch (we.Message)
|
|
||||||
{
|
|
||||||
case "Unauthorized":
|
|
||||||
statusCode = HttpStatusCode.Unauthorized;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (statusCode)
|
|
||||||
{
|
|
||||||
case HttpStatusCode.Unauthorized:
|
|
||||||
Logout(false);
|
|
||||||
return true;
|
|
||||||
case HttpStatusCode.RequestTimeout:
|
|
||||||
failureCount++;
|
|
||||||
log.Add($@"API failure count is now {failureCount}");
|
|
||||||
|
|
||||||
if (failureCount < 3)
|
|
||||||
//we might try again at an api level.
|
|
||||||
return false;
|
|
||||||
|
|
||||||
State = APIState.Failing;
|
|
||||||
flushQueue();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Fail(we);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (e is TimeoutException)
|
return false;
|
||||||
log.Add(@"API level timeout exception was hit");
|
|
||||||
|
|
||||||
req.Fail(e);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,6 +241,45 @@ namespace osu.Game.Online.API
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool handleWebException(WebException we)
|
||||||
|
{
|
||||||
|
HttpStatusCode statusCode = (we.Response as HttpWebResponse)?.StatusCode
|
||||||
|
?? (we.Status == WebExceptionStatus.UnknownError ? HttpStatusCode.NotAcceptable : HttpStatusCode.RequestTimeout);
|
||||||
|
|
||||||
|
// special cases for un-typed but useful message responses.
|
||||||
|
switch (we.Message)
|
||||||
|
{
|
||||||
|
case "Unauthorized":
|
||||||
|
case "Forbidden":
|
||||||
|
statusCode = HttpStatusCode.Unauthorized;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (statusCode)
|
||||||
|
{
|
||||||
|
case HttpStatusCode.Unauthorized:
|
||||||
|
Logout(false);
|
||||||
|
return true;
|
||||||
|
case HttpStatusCode.RequestTimeout:
|
||||||
|
failureCount++;
|
||||||
|
log.Add($@"API failure count is now {failureCount}");
|
||||||
|
|
||||||
|
if (failureCount < 3)
|
||||||
|
//we might try again at an api level.
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (State == APIState.Online)
|
||||||
|
{
|
||||||
|
State = APIState.Failing;
|
||||||
|
flushQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsLoggedIn => LocalUser.Value.Id > 1;
|
public bool IsLoggedIn => LocalUser.Value.Id > 1;
|
||||||
|
|
||||||
public void Queue(APIRequest request)
|
public void Queue(APIRequest request)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.IO.Network;
|
using osu.Framework.IO.Network;
|
||||||
|
using osu.Framework.Logging;
|
||||||
|
|
||||||
namespace osu.Game.Online.API
|
namespace osu.Game.Online.API
|
||||||
{
|
{
|
||||||
@ -35,23 +36,12 @@ namespace osu.Game.Online.API
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class APIRequest
|
public abstract class APIRequest
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The maximum amount of time before this request will fail.
|
|
||||||
/// </summary>
|
|
||||||
public int Timeout = WebRequest.DEFAULT_TIMEOUT;
|
|
||||||
|
|
||||||
protected virtual string Target => string.Empty;
|
protected virtual string Target => string.Empty;
|
||||||
|
|
||||||
protected virtual WebRequest CreateWebRequest() => new WebRequest(Uri);
|
protected virtual WebRequest CreateWebRequest() => new WebRequest(Uri);
|
||||||
|
|
||||||
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
|
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
|
||||||
|
|
||||||
private double remainingTime => Math.Max(0, Timeout - (DateTimeOffset.UtcNow - (startTime ?? DateTimeOffset.MinValue)).TotalMilliseconds);
|
|
||||||
|
|
||||||
public bool ExceededTimeout => remainingTime == 0;
|
|
||||||
|
|
||||||
private DateTimeOffset? startTime;
|
|
||||||
|
|
||||||
protected APIAccess API;
|
protected APIAccess API;
|
||||||
protected WebRequest WebRequest;
|
protected WebRequest WebRequest;
|
||||||
|
|
||||||
@ -75,27 +65,24 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
API = api;
|
API = api;
|
||||||
|
|
||||||
if (checkAndProcessFailure())
|
if (checkAndScheduleFailure())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (startTime == null)
|
|
||||||
startTime = DateTimeOffset.UtcNow;
|
|
||||||
|
|
||||||
if (remainingTime <= 0)
|
|
||||||
throw new TimeoutException(@"API request timeout hit");
|
|
||||||
|
|
||||||
WebRequest = CreateWebRequest();
|
WebRequest = CreateWebRequest();
|
||||||
WebRequest.Failed += Fail;
|
WebRequest.Failed += Fail;
|
||||||
WebRequest.AllowRetryOnTimeout = false;
|
WebRequest.AllowRetryOnTimeout = false;
|
||||||
WebRequest.AddHeader("Authorization", $"Bearer {api.AccessToken}");
|
WebRequest.AddHeader("Authorization", $"Bearer {api.AccessToken}");
|
||||||
|
|
||||||
if (checkAndProcessFailure())
|
if (checkAndScheduleFailure())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!WebRequest.Aborted) //could have been aborted by a Cancel() call
|
if (!WebRequest.Aborted) //could have been aborted by a Cancel() call
|
||||||
|
{
|
||||||
|
Logger.Log($@"Performing request {this}", LoggingTarget.Network);
|
||||||
WebRequest.Perform();
|
WebRequest.Perform();
|
||||||
|
}
|
||||||
|
|
||||||
if (checkAndProcessFailure())
|
if (checkAndScheduleFailure())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
api.Schedule(delegate { Success?.Invoke(); });
|
api.Schedule(delegate { Success?.Invoke(); });
|
||||||
@ -105,19 +92,21 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public void Fail(Exception e)
|
public void Fail(Exception e)
|
||||||
{
|
{
|
||||||
cancelled = true;
|
if (cancelled) return;
|
||||||
|
|
||||||
|
cancelled = true;
|
||||||
WebRequest?.Abort();
|
WebRequest?.Abort();
|
||||||
|
|
||||||
|
Logger.Log($@"Failing request {this} ({e})", LoggingTarget.Network);
|
||||||
pendingFailure = () => Failure?.Invoke(e);
|
pendingFailure = () => Failure?.Invoke(e);
|
||||||
checkAndProcessFailure();
|
checkAndScheduleFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checked for cancellation or error. Also queues up the Failed event if we can.
|
/// Checked for cancellation or error. Also queues up the Failed event if we can.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Whether we are in a failed or cancelled state.</returns>
|
/// <returns>Whether we are in a failed or cancelled state.</returns>
|
||||||
private bool checkAndProcessFailure()
|
private bool checkAndScheduleFailure()
|
||||||
{
|
{
|
||||||
if (API == null || pendingFailure == null) return cancelled;
|
if (API == null || pendingFailure == null) return cancelled;
|
||||||
|
|
||||||
|
@ -4,11 +4,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Threading;
|
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -18,7 +17,7 @@ namespace osu.Game.Online.Chat
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Manages everything channel related
|
/// Manages everything channel related
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ChannelManager : Component, IOnlineComponent
|
public class ChannelManager : PollingComponent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The channels the player joins on startup
|
/// The channels the player joins on startup
|
||||||
@ -49,11 +48,14 @@ namespace osu.Game.Online.Chat
|
|||||||
public IBindableCollection<Channel> AvailableChannels => availableChannels;
|
public IBindableCollection<Channel> AvailableChannels => availableChannels;
|
||||||
|
|
||||||
private IAPIProvider api;
|
private IAPIProvider api;
|
||||||
private ScheduledDelegate fetchMessagesScheduleder;
|
|
||||||
|
public readonly BindableBool HighPollRate = new BindableBool();
|
||||||
|
|
||||||
public ChannelManager()
|
public ChannelManager()
|
||||||
{
|
{
|
||||||
CurrentChannel.ValueChanged += currentChannelChanged;
|
CurrentChannel.ValueChanged += currentChannelChanged;
|
||||||
|
|
||||||
|
HighPollRate.BindValueChanged(high => TimeBetweenPolls = high ? 1000 : 6000, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -94,12 +96,14 @@ namespace osu.Game.Online.Chat
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text">The message text that is going to be posted</param>
|
/// <param name="text">The message text that is going to be posted</param>
|
||||||
/// <param name="isAction">Is true if the message is an action, e.g.: user is currently eating </param>
|
/// <param name="isAction">Is true if the message is an action, e.g.: user is currently eating </param>
|
||||||
public void PostMessage(string text, bool isAction = false)
|
/// <param name="target">An optional target channel. If null, <see cref="CurrentChannel"/> will be used.</param>
|
||||||
|
public void PostMessage(string text, bool isAction = false, Channel target = null)
|
||||||
{
|
{
|
||||||
if (CurrentChannel.Value == null)
|
if (target == null)
|
||||||
return;
|
target = CurrentChannel.Value;
|
||||||
|
|
||||||
var currentChannel = CurrentChannel.Value;
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
void dequeueAndRun()
|
void dequeueAndRun()
|
||||||
{
|
{
|
||||||
@ -111,7 +115,7 @@ namespace osu.Game.Online.Chat
|
|||||||
{
|
{
|
||||||
if (!api.IsLoggedIn)
|
if (!api.IsLoggedIn)
|
||||||
{
|
{
|
||||||
currentChannel.AddNewMessages(new ErrorMessage("Please sign in to participate in chat!"));
|
target.AddNewMessages(new ErrorMessage("Please sign in to participate in chat!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,29 +123,29 @@ namespace osu.Game.Online.Chat
|
|||||||
{
|
{
|
||||||
Sender = api.LocalUser.Value,
|
Sender = api.LocalUser.Value,
|
||||||
Timestamp = DateTimeOffset.Now,
|
Timestamp = DateTimeOffset.Now,
|
||||||
ChannelId = CurrentChannel.Value.Id,
|
ChannelId = target.Id,
|
||||||
IsAction = isAction,
|
IsAction = isAction,
|
||||||
Content = text
|
Content = text
|
||||||
};
|
};
|
||||||
|
|
||||||
currentChannel.AddLocalEcho(message);
|
target.AddLocalEcho(message);
|
||||||
|
|
||||||
// if this is a PM and the first message, we need to do a special request to create the PM channel
|
// if this is a PM and the first message, we need to do a special request to create the PM channel
|
||||||
if (currentChannel.Type == ChannelType.PM && !currentChannel.Joined)
|
if (target.Type == ChannelType.PM && !target.Joined)
|
||||||
{
|
{
|
||||||
var createNewPrivateMessageRequest = new CreateNewPrivateMessageRequest(currentChannel.Users.First(), message);
|
var createNewPrivateMessageRequest = new CreateNewPrivateMessageRequest(target.Users.First(), message);
|
||||||
|
|
||||||
createNewPrivateMessageRequest.Success += createRes =>
|
createNewPrivateMessageRequest.Success += createRes =>
|
||||||
{
|
{
|
||||||
currentChannel.Id = createRes.ChannelID;
|
target.Id = createRes.ChannelID;
|
||||||
currentChannel.ReplaceMessage(message, createRes.Message);
|
target.ReplaceMessage(message, createRes.Message);
|
||||||
dequeueAndRun();
|
dequeueAndRun();
|
||||||
};
|
};
|
||||||
|
|
||||||
createNewPrivateMessageRequest.Failure += exception =>
|
createNewPrivateMessageRequest.Failure += exception =>
|
||||||
{
|
{
|
||||||
Logger.Error(exception, "Posting message failed.");
|
Logger.Error(exception, "Posting message failed.");
|
||||||
currentChannel.ReplaceMessage(message, null);
|
target.ReplaceMessage(message, null);
|
||||||
dequeueAndRun();
|
dequeueAndRun();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,14 +157,14 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
req.Success += m =>
|
req.Success += m =>
|
||||||
{
|
{
|
||||||
currentChannel.ReplaceMessage(message, m);
|
target.ReplaceMessage(message, m);
|
||||||
dequeueAndRun();
|
dequeueAndRun();
|
||||||
};
|
};
|
||||||
|
|
||||||
req.Failure += exception =>
|
req.Failure += exception =>
|
||||||
{
|
{
|
||||||
Logger.Error(exception, "Posting message failed.");
|
Logger.Error(exception, "Posting message failed.");
|
||||||
currentChannel.ReplaceMessage(message, null);
|
target.ReplaceMessage(message, null);
|
||||||
dequeueAndRun();
|
dequeueAndRun();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -176,9 +180,13 @@ namespace osu.Game.Online.Chat
|
|||||||
/// Posts a command locally. Commands like /help will result in a help message written in the current channel.
|
/// Posts a command locally. Commands like /help will result in a help message written in the current channel.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text">the text containing the command identifier and command parameters.</param>
|
/// <param name="text">the text containing the command identifier and command parameters.</param>
|
||||||
public void PostCommand(string text)
|
/// <param name="target">An optional target channel. If null, <see cref="CurrentChannel"/> will be used.</param>
|
||||||
|
public void PostCommand(string text, Channel target = null)
|
||||||
{
|
{
|
||||||
if (CurrentChannel.Value == null)
|
if (target == null)
|
||||||
|
target = CurrentChannel.Value;
|
||||||
|
|
||||||
|
if (target == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var parameters = text.Split(new[] { ' ' }, 2);
|
var parameters = text.Split(new[] { ' ' }, 2);
|
||||||
@ -190,7 +198,7 @@ namespace osu.Game.Online.Chat
|
|||||||
case "me":
|
case "me":
|
||||||
if (string.IsNullOrWhiteSpace(content))
|
if (string.IsNullOrWhiteSpace(content))
|
||||||
{
|
{
|
||||||
CurrentChannel.Value.AddNewMessages(new ErrorMessage("Usage: /me [action]"));
|
target.AddNewMessages(new ErrorMessage("Usage: /me [action]"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,11 +206,11 @@ namespace osu.Game.Online.Chat
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "help":
|
case "help":
|
||||||
CurrentChannel.Value.AddNewMessages(new InfoMessage("Supported commands: /help, /me [action]"));
|
target.AddNewMessages(new InfoMessage("Supported commands: /help, /me [action]"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
CurrentChannel.Value.AddNewMessages(new ErrorMessage($@"""/{command}"" is not supported! For a list of supported commands see /help"));
|
target.AddNewMessages(new ErrorMessage($@"""/{command}"" is not supported! For a list of supported commands see /help"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,73 +368,60 @@ namespace osu.Game.Online.Chat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void APIStateChanged(APIAccess api, APIState state)
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case APIState.Online:
|
|
||||||
fetchUpdates();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fetchMessagesScheduleder?.Cancel();
|
|
||||||
fetchMessagesScheduleder = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private long lastMessageId;
|
private long lastMessageId;
|
||||||
private const int update_poll_interval = 1000;
|
|
||||||
|
|
||||||
private bool channelsInitialised;
|
private bool channelsInitialised;
|
||||||
|
|
||||||
private void fetchUpdates()
|
protected override Task Poll()
|
||||||
{
|
{
|
||||||
fetchMessagesScheduleder?.Cancel();
|
if (!api.IsLoggedIn)
|
||||||
fetchMessagesScheduleder = Scheduler.AddDelayed(() =>
|
return base.Poll();
|
||||||
|
|
||||||
|
var fetchReq = new GetUpdatesRequest(lastMessageId);
|
||||||
|
|
||||||
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
|
fetchReq.Success += updates =>
|
||||||
{
|
{
|
||||||
var fetchReq = new GetUpdatesRequest(lastMessageId);
|
if (updates?.Presence != null)
|
||||||
|
|
||||||
fetchReq.Success += updates =>
|
|
||||||
{
|
{
|
||||||
if (updates?.Presence != null)
|
foreach (var channel in updates.Presence)
|
||||||
{
|
{
|
||||||
foreach (var channel in updates.Presence)
|
// we received this from the server so should mark the channel already joined.
|
||||||
{
|
JoinChannel(channel, true);
|
||||||
// we received this from the server so should mark the channel already joined.
|
|
||||||
JoinChannel(channel, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//todo: handle left channels
|
|
||||||
|
|
||||||
handleChannelMessages(updates.Messages);
|
|
||||||
|
|
||||||
foreach (var group in updates.Messages.GroupBy(m => m.ChannelId))
|
|
||||||
JoinedChannels.FirstOrDefault(c => c.Id == group.Key)?.AddNewMessages(group.ToArray());
|
|
||||||
|
|
||||||
lastMessageId = updates.Messages.LastOrDefault()?.Id ?? lastMessageId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!channelsInitialised)
|
//todo: handle left channels
|
||||||
{
|
|
||||||
channelsInitialised = true;
|
|
||||||
// we want this to run after the first presence so we can see if the user is in any channels already.
|
|
||||||
initializeChannels();
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchUpdates();
|
handleChannelMessages(updates.Messages);
|
||||||
};
|
|
||||||
|
|
||||||
fetchReq.Failure += delegate { fetchUpdates(); };
|
foreach (var group in updates.Messages.GroupBy(m => m.ChannelId))
|
||||||
|
JoinedChannels.FirstOrDefault(c => c.Id == group.Key)?.AddNewMessages(group.ToArray());
|
||||||
|
|
||||||
api.Queue(fetchReq);
|
lastMessageId = updates.Messages.LastOrDefault()?.Id ?? lastMessageId;
|
||||||
}, update_poll_interval);
|
}
|
||||||
|
|
||||||
|
if (!channelsInitialised)
|
||||||
|
{
|
||||||
|
channelsInitialised = true;
|
||||||
|
// we want this to run after the first presence so we can see if the user is in any channels already.
|
||||||
|
initializeChannels();
|
||||||
|
}
|
||||||
|
|
||||||
|
tcs.SetResult(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchReq.Failure += _ => tcs.SetResult(false);
|
||||||
|
|
||||||
|
api.Queue(fetchReq);
|
||||||
|
|
||||||
|
return tcs.Task;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IAPIProvider api)
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
api.Register(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
229
osu.Game/Online/Chat/StandAloneChatDisplay.cs
Normal file
229
osu.Game/Online/Chat/StandAloneChatDisplay.cs
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Chat
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Display a chat channel in an insolated region.
|
||||||
|
/// </summary>
|
||||||
|
public class StandAloneChatDisplay : CompositeDrawable
|
||||||
|
{
|
||||||
|
public readonly Bindable<Channel> Channel = new Bindable<Channel>();
|
||||||
|
|
||||||
|
private readonly FillFlowContainer messagesFlow;
|
||||||
|
|
||||||
|
private Channel lastChannel;
|
||||||
|
|
||||||
|
private readonly FocusedTextBox textbox;
|
||||||
|
|
||||||
|
protected ChannelManager ChannelManager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Construct a new instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="postingTextbox">Whether a textbox for posting new messages should be displayed.</param>
|
||||||
|
public StandAloneChatDisplay(bool postingTextbox = false)
|
||||||
|
{
|
||||||
|
CornerRadius = 10;
|
||||||
|
Masking = true;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.Black,
|
||||||
|
Alpha = 0.8f,
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
messagesFlow = new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
LayoutEasing = Easing.Out,
|
||||||
|
LayoutDuration = 500,
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Direction = FillDirection.Vertical
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const float textbox_height = 30;
|
||||||
|
|
||||||
|
if (postingTextbox)
|
||||||
|
{
|
||||||
|
messagesFlow.Y -= textbox_height;
|
||||||
|
AddInternal(textbox = new FocusedTextBox
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = textbox_height,
|
||||||
|
PlaceholderText = "type your message",
|
||||||
|
OnCommit = postMessage,
|
||||||
|
ReleaseFocusOnCommit = false,
|
||||||
|
HoldFocus = true,
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Channel.BindValueChanged(channelChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(ChannelManager manager)
|
||||||
|
{
|
||||||
|
if (ChannelManager == null)
|
||||||
|
ChannelManager = manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void postMessage(TextBox sender, bool newtext)
|
||||||
|
{
|
||||||
|
var text = textbox.Text.Trim();
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (text[0] == '/')
|
||||||
|
ChannelManager?.PostCommand(text.Substring(1), Channel);
|
||||||
|
else
|
||||||
|
ChannelManager?.PostMessage(text, target: Channel);
|
||||||
|
|
||||||
|
textbox.Text = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Contract()
|
||||||
|
{
|
||||||
|
this.FadeIn(300);
|
||||||
|
this.MoveToY(0, 500, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Expand()
|
||||||
|
{
|
||||||
|
this.FadeOut(200);
|
||||||
|
this.MoveToY(100, 500, Easing.In);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual Drawable CreateMessage(Message message)
|
||||||
|
{
|
||||||
|
return new StandAloneMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void channelChanged(Channel channel)
|
||||||
|
{
|
||||||
|
if (lastChannel != null)
|
||||||
|
lastChannel.NewMessagesArrived -= newMessages;
|
||||||
|
|
||||||
|
lastChannel = channel;
|
||||||
|
messagesFlow.Clear();
|
||||||
|
|
||||||
|
if (channel == null) return;
|
||||||
|
|
||||||
|
channel.NewMessagesArrived += newMessages;
|
||||||
|
|
||||||
|
newMessages(channel.Messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void newMessages(IEnumerable<Message> messages)
|
||||||
|
{
|
||||||
|
var excessChildren = messagesFlow.Children.Count - 10;
|
||||||
|
if (excessChildren > 0)
|
||||||
|
foreach (var c in messagesFlow.Children.Take(excessChildren))
|
||||||
|
c.Expire();
|
||||||
|
|
||||||
|
foreach (var message in messages)
|
||||||
|
{
|
||||||
|
var formatted = MessageFormatter.FormatMessage(message);
|
||||||
|
var drawable = CreateMessage(formatted);
|
||||||
|
drawable.Y = messagesFlow.Height;
|
||||||
|
messagesFlow.Add(drawable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class StandAloneMessage : CompositeDrawable
|
||||||
|
{
|
||||||
|
protected readonly Message Message;
|
||||||
|
protected OsuSpriteText SenderText;
|
||||||
|
protected Circle ColourBox;
|
||||||
|
|
||||||
|
public StandAloneMessage(Message message)
|
||||||
|
{
|
||||||
|
Message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding(3);
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Width = 0.2f,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
SenderText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = @"Exo2.0-Bold",
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
Text = Message.Sender.ToString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Size = new Vector2(8, OsuSpriteText.FONT_SIZE),
|
||||||
|
Margin = new MarginPadding { Horizontal = 3 },
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
ColourBox = new Circle
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new OsuTextFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Width = 0.5f,
|
||||||
|
Text = Message.DisplayContent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Message.Sender.Colour))
|
||||||
|
SenderText.Colour = ColourBox.Colour = OsuColour.FromHex(Message.Sender.Colour);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
118
osu.Game/Online/PollingComponent.cs
Normal file
118
osu.Game/Online/PollingComponent.cs
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Threading;
|
||||||
|
|
||||||
|
namespace osu.Game.Online
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A component which requires a constant polling process.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class PollingComponent : Component
|
||||||
|
{
|
||||||
|
private double? lastTimePolled;
|
||||||
|
|
||||||
|
private ScheduledDelegate scheduledPoll;
|
||||||
|
|
||||||
|
private bool pollingActive;
|
||||||
|
|
||||||
|
private double timeBetweenPolls;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time in milliseconds to wait between polls.
|
||||||
|
/// Setting to zero stops all polling.
|
||||||
|
/// </summary>
|
||||||
|
public double TimeBetweenPolls
|
||||||
|
{
|
||||||
|
get => timeBetweenPolls;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
timeBetweenPolls = value;
|
||||||
|
scheduledPoll?.Cancel();
|
||||||
|
pollIfNecessary();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timeBetweenPolls">The initial time in milliseconds to wait between polls. Setting to zero stops al polling.</param>
|
||||||
|
protected PollingComponent(double timeBetweenPolls = 0)
|
||||||
|
{
|
||||||
|
TimeBetweenPolls = timeBetweenPolls;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
pollIfNecessary();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool pollIfNecessary()
|
||||||
|
{
|
||||||
|
// we must be loaded so we have access to clock.
|
||||||
|
if (!IsLoaded) return false;
|
||||||
|
|
||||||
|
// there's already a poll process running.
|
||||||
|
if (pollingActive) return false;
|
||||||
|
|
||||||
|
// don't try polling if the time between polls hasn't been set.
|
||||||
|
if (timeBetweenPolls == 0) return false;
|
||||||
|
|
||||||
|
if (!lastTimePolled.HasValue)
|
||||||
|
{
|
||||||
|
doPoll();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Time.Current - lastTimePolled.Value > timeBetweenPolls)
|
||||||
|
{
|
||||||
|
doPoll();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not ennough time has passed since the last poll. we do want to schedule a poll to happen, though.
|
||||||
|
scheduleNextPoll();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doPoll()
|
||||||
|
{
|
||||||
|
scheduledPoll = null;
|
||||||
|
pollingActive = true;
|
||||||
|
Poll().ContinueWith(_ => pollComplete());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Perform the polling in this method. Call <see cref="pollComplete"/> when done.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual Task Poll()
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call when a poll operation has completed.
|
||||||
|
/// </summary>
|
||||||
|
private void pollComplete()
|
||||||
|
{
|
||||||
|
lastTimePolled = Time.Current;
|
||||||
|
pollingActive = false;
|
||||||
|
|
||||||
|
if (scheduledPoll == null)
|
||||||
|
scheduleNextPoll();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scheduleNextPoll()
|
||||||
|
{
|
||||||
|
scheduledPoll?.Cancel();
|
||||||
|
|
||||||
|
double lastPollDuration = lastTimePolled.HasValue ? Time.Current - lastTimePolled.Value : 0;
|
||||||
|
|
||||||
|
scheduledPoll = Scheduler.AddDelayed(doPoll, Math.Max(0, timeBetweenPolls - lastPollDuration));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -418,6 +418,8 @@ namespace osu.Game
|
|||||||
dependencies.Cache(notifications);
|
dependencies.Cache(notifications);
|
||||||
dependencies.Cache(dialogOverlay);
|
dependencies.Cache(dialogOverlay);
|
||||||
|
|
||||||
|
chatOverlay.StateChanged += state => channelManager.HighPollRate.Value = state == Visibility.Visible;
|
||||||
|
|
||||||
Add(externalLinkOpener = new ExternalLinkOpener());
|
Add(externalLinkOpener = new ExternalLinkOpener());
|
||||||
|
|
||||||
var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications };
|
var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications };
|
||||||
|
@ -9,7 +9,6 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
|
||||||
@ -20,7 +19,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
private const float height = 50;
|
private const float height = 50;
|
||||||
|
|
||||||
private readonly UpdateableAvatar avatar;
|
private readonly UpdateableAvatar avatar;
|
||||||
private readonly ClickableArea clickableArea;
|
|
||||||
private readonly FillFlowContainer fields;
|
private readonly FillFlowContainer fields;
|
||||||
|
|
||||||
private BeatmapSetInfo beatmapSet;
|
private BeatmapSetInfo beatmapSet;
|
||||||
@ -73,7 +71,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
clickableArea = new ClickableArea
|
new Container
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
CornerRadius = 3,
|
CornerRadius = 3,
|
||||||
@ -100,14 +98,8 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
private void load()
|
||||||
private void load(UserProfileOverlay profile)
|
|
||||||
{
|
{
|
||||||
clickableArea.Action = () =>
|
|
||||||
{
|
|
||||||
if (avatar.User != null) profile?.ShowUser(avatar.User);
|
|
||||||
};
|
|
||||||
|
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ using osu.Game.Graphics.Containers;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Chat.Selection
|
namespace osu.Game.Overlays.Chat.Selection
|
||||||
{
|
{
|
||||||
public class ChannelSelectionOverlay : OsuFocusedOverlayContainer
|
public class ChannelSelectionOverlay : WaveOverlayContainer
|
||||||
{
|
{
|
||||||
public static readonly float WIDTH_PADDING = 170;
|
public static readonly float WIDTH_PADDING = 170;
|
||||||
|
|
||||||
@ -39,6 +39,11 @@ namespace osu.Game.Overlays.Chat.Selection
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
Waves.FirstWaveColour = OsuColour.FromHex("353535");
|
||||||
|
Waves.SecondWaveColour = OsuColour.FromHex("434343");
|
||||||
|
Waves.ThirdWaveColour = OsuColour.FromHex("515151");
|
||||||
|
Waves.FourthWaveColour = OsuColour.FromHex("595959");
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Container
|
new Container
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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 System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -19,6 +20,7 @@ using osu.Game.Online.Chat;
|
|||||||
using osu.Game.Overlays.Chat;
|
using osu.Game.Overlays.Chat;
|
||||||
using osu.Game.Overlays.Chat.Selection;
|
using osu.Game.Overlays.Chat.Selection;
|
||||||
using osu.Game.Overlays.Chat.Tabs;
|
using osu.Game.Overlays.Chat.Tabs;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -222,7 +224,7 @@ namespace osu.Game.Overlays
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentChannelContainer.Clear(false);
|
currentChannelContainer.Clear(false);
|
||||||
Scheduler.Add(() => currentChannelContainer.Add(loaded));
|
currentChannelContainer.Add(loaded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,6 +264,39 @@ namespace osu.Game.Overlays
|
|||||||
return base.OnDragEnd(e);
|
return base.OnDragEnd(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void selectTab(int index)
|
||||||
|
{
|
||||||
|
var channel = channelTabControl.Items.Skip(index).FirstOrDefault();
|
||||||
|
if (channel != null && channel.Name != "+")
|
||||||
|
channelTabControl.Current.Value = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
|
{
|
||||||
|
if (e.AltPressed)
|
||||||
|
{
|
||||||
|
switch (e.Key)
|
||||||
|
{
|
||||||
|
case Key.Number1:
|
||||||
|
case Key.Number2:
|
||||||
|
case Key.Number3:
|
||||||
|
case Key.Number4:
|
||||||
|
case Key.Number5:
|
||||||
|
case Key.Number6:
|
||||||
|
case Key.Number7:
|
||||||
|
case Key.Number8:
|
||||||
|
case Key.Number9:
|
||||||
|
selectTab((int)e.Key - (int)Key.Number1);
|
||||||
|
return true;
|
||||||
|
case Key.Number0:
|
||||||
|
selectTab(9);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnKeyDown(e);
|
||||||
|
}
|
||||||
|
|
||||||
public override bool AcceptsFocus => true;
|
public override bool AcceptsFocus => true;
|
||||||
|
|
||||||
protected override void OnFocus(FocusEvent e)
|
protected override void OnFocus(FocusEvent e)
|
||||||
|
@ -82,6 +82,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
CornerRadius = 5,
|
CornerRadius = 5,
|
||||||
|
OpenOnClick = { Value = false },
|
||||||
EdgeEffect = new EdgeEffectParameters
|
EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Type = EdgeEffectType.Shadow,
|
Type = EdgeEffectType.Shadow,
|
||||||
@ -114,7 +115,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
Y = -48,
|
Y = -48,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
usernameText = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = user.Username,
|
Text = user.Username,
|
||||||
Font = @"Exo2.0-RegularItalic",
|
Font = @"Exo2.0-RegularItalic",
|
||||||
@ -316,6 +317,8 @@ namespace osu.Game.Overlays.Profile
|
|||||||
levelBadge.Texture = textures.Get(@"Profile/levelbadge");
|
levelBadge.Texture = textures.Get(@"Profile/levelbadge");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly OsuSpriteText usernameText;
|
||||||
|
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
public User User
|
public User User
|
||||||
@ -343,6 +346,8 @@ namespace osu.Game.Overlays.Profile
|
|||||||
if (user.IsSupporter)
|
if (user.IsSupporter)
|
||||||
SupporterTag.Show();
|
SupporterTag.Show();
|
||||||
|
|
||||||
|
usernameText.Text = user.Username;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(user.Colour))
|
if (!string.IsNullOrEmpty(user.Colour))
|
||||||
{
|
{
|
||||||
colourBar.Colour = OsuColour.FromHex(user.Colour);
|
colourBar.Colour = OsuColour.FromHex(user.Colour);
|
||||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
|
|
||||||
public override FontAwesome Icon => FontAwesome.fa_paint_brush;
|
public override FontAwesome Icon => FontAwesome.fa_paint_brush;
|
||||||
|
|
||||||
private readonly Bindable<SkinInfo> dropdownBindable = new Bindable<SkinInfo>();
|
private readonly Bindable<SkinInfo> dropdownBindable = new Bindable<SkinInfo> { Default = SkinInfo.Default };
|
||||||
private readonly Bindable<int> configBindable = new Bindable<int>();
|
private readonly Bindable<int> configBindable = new Bindable<int>();
|
||||||
|
|
||||||
private SkinManager skins;
|
private SkinManager skins;
|
||||||
|
@ -31,6 +31,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
CornerRadius = 4,
|
CornerRadius = 4,
|
||||||
|
OpenOnClick = { Value = false },
|
||||||
EdgeEffect = new EdgeEffectParameters
|
EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Type = EdgeEffectType.Shadow,
|
Type = EdgeEffectType.Shadow,
|
||||||
|
@ -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 System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -18,7 +19,20 @@ namespace osu.Game.Overlays.Volume
|
|||||||
{
|
{
|
||||||
public class MuteButton : Container, IHasCurrentValue<bool>
|
public class MuteButton : Container, IHasCurrentValue<bool>
|
||||||
{
|
{
|
||||||
public Bindable<bool> Current { get; } = new Bindable<bool>();
|
private readonly Bindable<bool> current = new Bindable<bool>();
|
||||||
|
|
||||||
|
public Bindable<bool> Current
|
||||||
|
{
|
||||||
|
get => current;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
|
||||||
|
current.UnbindBindings();
|
||||||
|
current.BindTo(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Color4 hoveredColour, unhoveredColour;
|
private Color4 hoveredColour, unhoveredColour;
|
||||||
private const float width = 100;
|
private const float width = 100;
|
||||||
|
@ -44,5 +44,19 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
/// <param name="result">The <see cref="JudgementResult"/> to find the numeric score representation for.</param>
|
/// <param name="result">The <see cref="JudgementResult"/> to find the numeric score representation for.</param>
|
||||||
/// <returns>The numeric score representation of <paramref name="result"/>.</returns>
|
/// <returns>The numeric score representation of <paramref name="result"/>.</returns>
|
||||||
public int NumericResultFor(JudgementResult result) => NumericResultFor(result.Type);
|
public int NumericResultFor(JudgementResult result) => NumericResultFor(result.Type);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the numeric health increase of a <see cref="HitResult"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="result">The <see cref="HitResult"/> to find the numeric health increase for.</param>
|
||||||
|
/// <returns>The numeric health increase of <paramref name="result"/>.</returns>
|
||||||
|
protected virtual double HealthIncreaseFor(HitResult result) => 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the numeric health increase of a <see cref="JudgementResult"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="result">The <see cref="JudgementResult"/> to find the numeric health increase for.</param>
|
||||||
|
/// <returns>The numeric health increase of <paramref name="result"/>.</returns>
|
||||||
|
public double HealthIncreaseFor(JudgementResult result) => HealthIncreaseFor(result.Type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hit window for a <see cref="HitResult.Perfect"/> result.
|
/// Hit window for a <see cref="HitResult.Perfect"/> result.
|
||||||
/// The user can only achieve receive this result if <see cref="AllowsPerfect"/> is true.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Perfect { get; protected set; }
|
public double Perfect { get; protected set; }
|
||||||
|
|
||||||
@ -38,7 +37,6 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hit window for an <see cref="HitResult.Ok"/> result.
|
/// Hit window for an <see cref="HitResult.Ok"/> result.
|
||||||
/// The user can only achieve this result if <see cref="AllowsOk"/> is true.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Ok { get; protected set; }
|
public double Ok { get; protected set; }
|
||||||
|
|
||||||
@ -53,14 +51,36 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
public double Miss { get; protected set; }
|
public double Miss { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether it's possible to achieve a <see cref="HitResult.Perfect"/> result.
|
/// Retrieves the <see cref="HitResult"/> with the largest hit window that produces a successful hit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllowsPerfect;
|
/// <returns>The lowest allowed successful <see cref="HitResult"/>.</returns>
|
||||||
|
protected HitResult LowestSuccessfulHitResult()
|
||||||
|
{
|
||||||
|
for (var result = HitResult.Meh; result <= HitResult.Perfect; ++result)
|
||||||
|
{
|
||||||
|
if (IsHitResultAllowed(result))
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HitResult.None;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether it's possible to achieve a <see cref="HitResult.Ok"/> result.
|
/// Check whether it is possible to achieve the provided <see cref="HitResult"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllowsOk;
|
/// <param name="result">The result type to check.</param>
|
||||||
|
/// <returns>Whether the <see cref="HitResult"/> can be achieved.</returns>
|
||||||
|
public virtual bool IsHitResultAllowed(HitResult result)
|
||||||
|
{
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case HitResult.Perfect:
|
||||||
|
case HitResult.Ok:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets hit windows with values that correspond to a difficulty parameter.
|
/// Sets hit windows with values that correspond to a difficulty parameter.
|
||||||
@ -85,18 +105,11 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
{
|
{
|
||||||
timeOffset = Math.Abs(timeOffset);
|
timeOffset = Math.Abs(timeOffset);
|
||||||
|
|
||||||
if (AllowsPerfect && timeOffset <= HalfWindowFor(HitResult.Perfect))
|
for (var result = HitResult.Perfect; result >= HitResult.Miss; --result)
|
||||||
return HitResult.Perfect;
|
{
|
||||||
if (timeOffset <= HalfWindowFor(HitResult.Great))
|
if (IsHitResultAllowed(result) && timeOffset <= HalfWindowFor(result))
|
||||||
return HitResult.Great;
|
return result;
|
||||||
if (timeOffset <= HalfWindowFor(HitResult.Good))
|
}
|
||||||
return HitResult.Good;
|
|
||||||
if (AllowsOk && timeOffset <= HalfWindowFor(HitResult.Ok))
|
|
||||||
return HitResult.Ok;
|
|
||||||
if (timeOffset <= HalfWindowFor(HitResult.Meh))
|
|
||||||
return HitResult.Meh;
|
|
||||||
if (timeOffset <= HalfWindowFor(HitResult.Miss))
|
|
||||||
return HitResult.Miss;
|
|
||||||
|
|
||||||
return HitResult.None;
|
return HitResult.None;
|
||||||
}
|
}
|
||||||
@ -130,10 +143,10 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Given a time offset, whether the <see cref="HitObject"/> can ever be hit in the future with a non-<see cref="HitResult.Miss"/> result.
|
/// Given a time offset, whether the <see cref="HitObject"/> can ever be hit in the future with a non-<see cref="HitResult.Miss"/> result.
|
||||||
/// This happens if <paramref name="timeOffset"/> is less than what is required for a <see cref="Meh"/> result.
|
/// This happens if <paramref name="timeOffset"/> is less than what is required for a <see cref="SuccessfulHitWindow"/> result.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="timeOffset">The time offset.</param>
|
/// <param name="timeOffset">The time offset.</param>
|
||||||
/// <returns>Whether the <see cref="HitObject"/> can be hit at any point in the future from this time offset.</returns>
|
/// <returns>Whether the <see cref="HitObject"/> can be hit at any point in the future from this time offset.</returns>
|
||||||
public bool CanBeHit(double timeOffset) => timeOffset <= HalfWindowFor(HitResult.Meh);
|
public bool CanBeHit(double timeOffset) => timeOffset <= HalfWindowFor(LowestSuccessfulHitResult());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Playfield Playfield => playfield.Value;
|
public Playfield Playfield => playfield.Value;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Place to put drawables above hit objects but below UI.
|
||||||
|
/// </summary>
|
||||||
|
public Container Overlays { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The cursor provided by this <see cref="RulesetContainer"/>. May be null if no cursor is provided.
|
/// The cursor provided by this <see cref="RulesetContainer"/>. May be null if no cursor is provided.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -215,7 +220,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
private Container content;
|
private Container content;
|
||||||
private IEnumerable<Mod> mods;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to assume the beatmap passed into this <see cref="RulesetContainer{TObject}"/> is for the current ruleset.
|
/// Whether to assume the beatmap passed into this <see cref="RulesetContainer{TObject}"/> is for the current ruleset.
|
||||||
@ -245,17 +249,24 @@ namespace osu.Game.Rulesets.UI
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
KeyBindingInputManager.Add(content = new Container
|
KeyBindingInputManager.Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
content = new Container
|
||||||
});
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
AddInternal(KeyBindingInputManager);
|
},
|
||||||
KeyBindingInputManager.Add(Playfield);
|
Playfield
|
||||||
|
};
|
||||||
|
|
||||||
if (Cursor != null)
|
if (Cursor != null)
|
||||||
KeyBindingInputManager.Add(Cursor);
|
KeyBindingInputManager.Add(Cursor);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
KeyBindingInputManager,
|
||||||
|
Overlays = new Container { RelativeSizeAxes = Axes.Both }
|
||||||
|
};
|
||||||
|
|
||||||
// Apply mods
|
// Apply mods
|
||||||
applyRulesetMods(Mods, config);
|
applyRulesetMods(Mods, config);
|
||||||
|
|
||||||
@ -330,7 +341,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
Playfield.Add(drawableObject);
|
Playfield.Add(drawableObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a DrawableHitObject from a HitObject.
|
/// Creates a DrawableHitObject from a HitObject.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// 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 System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -11,7 +13,6 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD
|
namespace osu.Game.Screens.Play.HUD
|
||||||
@ -20,9 +21,20 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
private const int fade_duration = 1000;
|
private const int fade_duration = 1000;
|
||||||
|
|
||||||
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>();
|
private readonly Bindable<IEnumerable<Mod>> current = new Bindable<IEnumerable<Mod>>();
|
||||||
|
|
||||||
public Bindable<IEnumerable<Mod>> Current => mods;
|
public Bindable<IEnumerable<Mod>> Current
|
||||||
|
{
|
||||||
|
get => current;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
|
||||||
|
current.UnbindBindings();
|
||||||
|
current.BindTo(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private readonly FillFlowContainer<ModIcon> iconsContainer;
|
private readonly FillFlowContainer<ModIcon> iconsContainer;
|
||||||
private readonly OsuSpriteText unrankedText;
|
private readonly OsuSpriteText unrankedText;
|
||||||
@ -50,7 +62,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mods.ValueChanged += mods =>
|
Current.ValueChanged += mods =>
|
||||||
{
|
{
|
||||||
iconsContainer.Clear();
|
iconsContainer.Clear();
|
||||||
foreach (Mod mod in mods)
|
foreach (Mod mod in mods)
|
||||||
@ -66,7 +78,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
mods.UnbindAll();
|
Current.UnbindAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -77,7 +89,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
private void appearTransform()
|
private void appearTransform()
|
||||||
{
|
{
|
||||||
if (mods.Value.Any(m => !m.Ranked))
|
if (Current.Value.Any(m => !m.Ranked))
|
||||||
unrankedText.FadeInFromZero(fade_duration, Easing.OutQuint);
|
unrankedText.FadeInFromZero(fade_duration, Easing.OutQuint);
|
||||||
else
|
else
|
||||||
unrankedText.Hide();
|
unrankedText.Hide();
|
||||||
|
@ -170,7 +170,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
Retries = RestartCount,
|
Retries = RestartCount,
|
||||||
OnRetry = Restart,
|
OnRetry = Restart,
|
||||||
OnQuit = Exit,
|
OnQuit = performUserRequestedExit,
|
||||||
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
|
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
@ -211,7 +211,7 @@ namespace osu.Game.Screens.Play
|
|||||||
failOverlay = new FailOverlay
|
failOverlay = new FailOverlay
|
||||||
{
|
{
|
||||||
OnRetry = Restart,
|
OnRetry = Restart,
|
||||||
OnQuit = Exit,
|
OnQuit = performUserRequestedExit,
|
||||||
},
|
},
|
||||||
new HotkeyRetryOverlay
|
new HotkeyRetryOverlay
|
||||||
{
|
{
|
||||||
@ -225,7 +225,7 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
hudOverlay.HoldToQuit.Action = Exit;
|
hudOverlay.HoldToQuit.Action = performUserRequestedExit;
|
||||||
hudOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded);
|
hudOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded);
|
||||||
|
|
||||||
RulesetContainer.IsPaused.BindTo(pauseContainer.IsPaused);
|
RulesetContainer.IsPaused.BindTo(pauseContainer.IsPaused);
|
||||||
@ -250,8 +250,16 @@ namespace osu.Game.Screens.Play
|
|||||||
mod.ApplyToClock(sourceClock);
|
mod.ApplyToClock(sourceClock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void performUserRequestedExit()
|
||||||
|
{
|
||||||
|
if (!IsCurrentScreen) return;
|
||||||
|
Exit();
|
||||||
|
}
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
|
if (!IsCurrentScreen) return;
|
||||||
|
|
||||||
sampleRestart?.Play();
|
sampleRestart?.Play();
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
RestartRequested?.Invoke();
|
RestartRequested?.Invoke();
|
||||||
|
@ -1,111 +1,28 @@
|
|||||||
// 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 System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osuTK.Input;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Audio.Sample;
|
|
||||||
using osu.Framework.Configuration;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Overlays;
|
|
||||||
using osu.Game.Overlays.Mods;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Ranking;
|
using osuTK.Input;
|
||||||
using osu.Game.Skinning;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
{
|
{
|
||||||
public class PlaySongSelect : SongSelect
|
public class PlaySongSelect : SongSelect
|
||||||
{
|
{
|
||||||
private OsuScreen player;
|
|
||||||
private readonly ModSelectOverlay modSelect;
|
|
||||||
protected readonly BeatmapDetailArea BeatmapDetails;
|
|
||||||
private bool removeAutoModOnResume;
|
private bool removeAutoModOnResume;
|
||||||
|
private OsuScreen player;
|
||||||
|
|
||||||
public PlaySongSelect()
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
FooterPanels.Add(modSelect = new ModSelectOverlay
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
});
|
|
||||||
|
|
||||||
LeftContent.Add(BeatmapDetails = new BeatmapDetailArea
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Padding = new MarginPadding { Top = 10, Right = 5 },
|
|
||||||
});
|
|
||||||
|
|
||||||
BeatmapDetails.Leaderboard.ScoreSelected += s => Push(new Results(s));
|
|
||||||
}
|
|
||||||
|
|
||||||
private SampleChannel sampleConfirm;
|
|
||||||
|
|
||||||
[Cached]
|
|
||||||
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
|
||||||
private readonly Bindable<IEnumerable<Mod>> selectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
|
||||||
private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, SkinManager skins, DialogOverlay dialogOverlay, Bindable<IEnumerable<Mod>> selectedMods)
|
|
||||||
{
|
|
||||||
if (selectedMods != null) this.selectedMods.BindTo(selectedMods);
|
|
||||||
|
|
||||||
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
|
|
||||||
|
|
||||||
Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue);
|
|
||||||
|
|
||||||
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1);
|
|
||||||
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2);
|
|
||||||
BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.fa_pencil, colours.Yellow, () =>
|
BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.fa_pencil, colours.Yellow, () =>
|
||||||
{
|
{
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
Edit();
|
Edit();
|
||||||
}, Key.Number3);
|
}, Key.Number3);
|
||||||
|
|
||||||
if (dialogOverlay != null)
|
|
||||||
{
|
|
||||||
Schedule(() =>
|
|
||||||
{
|
|
||||||
// if we have no beatmaps but osu-stable is found, let's prompt the user to import.
|
|
||||||
if (!beatmaps.GetAllUsableBeatmapSets().Any() && beatmaps.StableInstallationAvailable)
|
|
||||||
dialogOverlay.Push(new ImportFromStablePopup(() =>
|
|
||||||
{
|
|
||||||
beatmaps.ImportFromStableAsync();
|
|
||||||
skins.ImportFromStableAsync();
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void ExitFromBack()
|
|
||||||
{
|
|
||||||
if (modSelect.State == Visibility.Visible)
|
|
||||||
{
|
|
||||||
modSelect.Hide();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
base.ExitFromBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateBeatmap(WorkingBeatmap beatmap)
|
|
||||||
{
|
|
||||||
beatmap.Mods.BindTo(selectedMods);
|
|
||||||
|
|
||||||
base.UpdateBeatmap(beatmap);
|
|
||||||
|
|
||||||
BeatmapDetails.Beatmap = beatmap;
|
|
||||||
|
|
||||||
if (beatmap.Track != null)
|
|
||||||
beatmap.Track.Looping = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnResuming(Screen last)
|
protected override void OnResuming(Screen last)
|
||||||
@ -115,38 +32,13 @@ namespace osu.Game.Screens.Select
|
|||||||
if (removeAutoModOnResume)
|
if (removeAutoModOnResume)
|
||||||
{
|
{
|
||||||
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
|
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
|
||||||
modSelect.DeselectTypes(new[] { autoType }, true);
|
ModSelect.DeselectTypes(new[] { autoType }, true);
|
||||||
removeAutoModOnResume = false;
|
removeAutoModOnResume = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeatmapDetails.Leaderboard.RefreshScores();
|
|
||||||
|
|
||||||
Beatmap.Value.Track.Looping = true;
|
|
||||||
|
|
||||||
base.OnResuming(last);
|
base.OnResuming(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSuspending(Screen next)
|
|
||||||
{
|
|
||||||
modSelect.Hide();
|
|
||||||
|
|
||||||
base.OnSuspending(next);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnExiting(Screen next)
|
|
||||||
{
|
|
||||||
if (base.OnExiting(next))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (Beatmap.Value.Track != null)
|
|
||||||
Beatmap.Value.Track.Looping = false;
|
|
||||||
|
|
||||||
selectedMods.UnbindAll();
|
|
||||||
Beatmap.Value.Mods.Value = new Mod[] { };
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnStart()
|
protected override bool OnStart()
|
||||||
{
|
{
|
||||||
if (player != null) return false;
|
if (player != null) return false;
|
||||||
@ -157,10 +49,10 @@ namespace osu.Game.Screens.Select
|
|||||||
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
|
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
|
||||||
var autoType = auto.GetType();
|
var autoType = auto.GetType();
|
||||||
|
|
||||||
var mods = selectedMods.Value;
|
var mods = SelectedMods.Value;
|
||||||
if (mods.All(m => m.GetType() != autoType))
|
if (mods.All(m => m.GetType() != autoType))
|
||||||
{
|
{
|
||||||
selectedMods.Value = mods.Append(auto);
|
SelectedMods.Value = mods.Append(auto);
|
||||||
removeAutoModOnResume = true;
|
removeAutoModOnResume = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,7 +60,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Beatmap.Value.Track.Looping = false;
|
Beatmap.Value.Track.Looping = false;
|
||||||
Beatmap.Disabled = true;
|
Beatmap.Disabled = true;
|
||||||
|
|
||||||
sampleConfirm?.Play();
|
SampleConfirm?.Play();
|
||||||
|
|
||||||
LoadComponentAsync(player = new PlayerLoader(new Player()), l =>
|
LoadComponentAsync(player = new PlayerLoader(new Player()), l =>
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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 System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -21,12 +22,15 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Mods;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens.Backgrounds;
|
using osu.Game.Screens.Backgrounds;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Screens.Select.Options;
|
using osu.Game.Screens.Select.Options;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
{
|
{
|
||||||
@ -60,29 +64,24 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
|
||||||
|
|
||||||
protected Container LeftContent;
|
|
||||||
|
|
||||||
protected readonly BeatmapCarousel Carousel;
|
protected readonly BeatmapCarousel Carousel;
|
||||||
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
||||||
private DialogOverlay dialogOverlay;
|
private DialogOverlay dialogOverlay;
|
||||||
private BeatmapManager beatmaps;
|
private BeatmapManager beatmaps;
|
||||||
|
|
||||||
|
protected readonly ModSelectOverlay ModSelect;
|
||||||
|
|
||||||
|
protected SampleChannel SampleConfirm;
|
||||||
private SampleChannel sampleChangeDifficulty;
|
private SampleChannel sampleChangeDifficulty;
|
||||||
private SampleChannel sampleChangeBeatmap;
|
private SampleChannel sampleChangeBeatmap;
|
||||||
|
|
||||||
|
protected readonly BeatmapDetailArea BeatmapDetails;
|
||||||
|
|
||||||
protected new readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
protected new readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
[Cached]
|
||||||
|
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
|
||||||
{
|
|
||||||
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
dependencies.CacheAs(this);
|
|
||||||
dependencies.CacheAs(Ruleset);
|
|
||||||
dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SongSelect()
|
protected SongSelect()
|
||||||
{
|
{
|
||||||
@ -105,7 +104,7 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
LeftContent = new Container
|
new Container
|
||||||
{
|
{
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
@ -117,6 +116,11 @@ namespace osu.Game.Screens.Select
|
|||||||
Top = wedged_container_size.Y + left_area_padding,
|
Top = wedged_container_size.Y + left_area_padding,
|
||||||
Left = left_area_padding,
|
Left = left_area_padding,
|
||||||
Right = left_area_padding * 2,
|
Right = left_area_padding * 2,
|
||||||
|
},
|
||||||
|
Child = BeatmapDetails = new BeatmapDetailArea
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding { Top = 10, Right = 5 },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
@ -194,21 +198,36 @@ namespace osu.Game.Screens.Select
|
|||||||
OnBack = ExitFromBack,
|
OnBack = ExitFromBack,
|
||||||
});
|
});
|
||||||
|
|
||||||
FooterPanels.Add(BeatmapOptions = new BeatmapOptionsOverlay());
|
FooterPanels.AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
BeatmapOptions = new BeatmapOptionsOverlay(),
|
||||||
|
ModSelect = new ModSelectOverlay
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BeatmapDetails.Leaderboard.ScoreSelected += s => Push(new Results(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void ExitFromBack() => Exit();
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours)
|
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, Bindable<IEnumerable<Mod>> selectedMods)
|
||||||
{
|
{
|
||||||
|
if (selectedMods != null)
|
||||||
|
SelectedMods.BindTo(selectedMods);
|
||||||
|
|
||||||
if (Footer != null)
|
if (Footer != null)
|
||||||
{
|
{
|
||||||
|
Footer.AddButton(@"mods", colours.Yellow, ModSelect, Key.F1);
|
||||||
Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2);
|
Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2);
|
||||||
Footer.AddButton(@"options", colours.Blue, BeatmapOptions, Key.F3);
|
Footer.AddButton(@"options", colours.Blue, BeatmapOptions, Key.F3);
|
||||||
|
|
||||||
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.fa_trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
|
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.fa_trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
|
||||||
|
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1);
|
||||||
|
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.beatmaps == null)
|
if (this.beatmaps == null)
|
||||||
@ -223,8 +242,46 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
|
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
|
||||||
sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand");
|
sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand");
|
||||||
|
SampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
|
||||||
|
|
||||||
Carousel.LoadBeatmapSetsFromManager(this.beatmaps);
|
Carousel.LoadBeatmapSetsFromManager(this.beatmaps);
|
||||||
|
|
||||||
|
if (dialogOverlay != null)
|
||||||
|
{
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
// if we have no beatmaps but osu-stable is found, let's prompt the user to import.
|
||||||
|
if (!beatmaps.GetAllUsableBeatmapSets().Any() && beatmaps.StableInstallationAvailable)
|
||||||
|
dialogOverlay.Push(new ImportFromStablePopup(() =>
|
||||||
|
{
|
||||||
|
beatmaps.ImportFromStableAsync();
|
||||||
|
skins.ImportFromStableAsync();
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DependencyContainer dependencies;
|
||||||
|
|
||||||
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
dependencies.CacheAs(this);
|
||||||
|
dependencies.CacheAs(Ruleset);
|
||||||
|
dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
|
||||||
|
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void ExitFromBack()
|
||||||
|
{
|
||||||
|
if (ModSelect.State == Visibility.Visible)
|
||||||
|
{
|
||||||
|
ModSelect.Hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Edit(BeatmapInfo beatmap = null)
|
public void Edit(BeatmapInfo beatmap = null)
|
||||||
@ -421,6 +478,10 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
protected override void OnResuming(Screen last)
|
protected override void OnResuming(Screen last)
|
||||||
{
|
{
|
||||||
|
BeatmapDetails.Leaderboard.RefreshScores();
|
||||||
|
|
||||||
|
Beatmap.Value.Track.Looping = true;
|
||||||
|
|
||||||
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
|
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
|
||||||
{
|
{
|
||||||
UpdateBeatmap(Beatmap.Value);
|
UpdateBeatmap(Beatmap.Value);
|
||||||
@ -438,6 +499,8 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
protected override void OnSuspending(Screen next)
|
protected override void OnSuspending(Screen next)
|
||||||
{
|
{
|
||||||
|
ModSelect.Hide();
|
||||||
|
|
||||||
Content.ScaleTo(1.1f, 250, Easing.InSine);
|
Content.ScaleTo(1.1f, 250, Easing.InSine);
|
||||||
|
|
||||||
Content.FadeOut(250);
|
Content.FadeOut(250);
|
||||||
@ -448,6 +511,12 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
protected override bool OnExiting(Screen next)
|
protected override bool OnExiting(Screen next)
|
||||||
{
|
{
|
||||||
|
if (ModSelect.State == Visibility.Visible)
|
||||||
|
{
|
||||||
|
ModSelect.Hide();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
FinaliseSelection(performStartAction: false);
|
FinaliseSelection(performStartAction: false);
|
||||||
|
|
||||||
beatmapInfoWedge.State = Visibility.Hidden;
|
beatmapInfoWedge.State = Visibility.Hidden;
|
||||||
@ -456,6 +525,12 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
FilterControl.Deactivate();
|
FilterControl.Deactivate();
|
||||||
|
|
||||||
|
if (Beatmap.Value.Track != null)
|
||||||
|
Beatmap.Value.Track.Looping = false;
|
||||||
|
|
||||||
|
SelectedMods.UnbindAll();
|
||||||
|
Beatmap.Value.Mods.Value = new Mod[] { };
|
||||||
|
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,6 +556,8 @@ namespace osu.Game.Screens.Select
|
|||||||
/// <param name="beatmap">The working beatmap.</param>
|
/// <param name="beatmap">The working beatmap.</param>
|
||||||
protected virtual void UpdateBeatmap(WorkingBeatmap beatmap)
|
protected virtual void UpdateBeatmap(WorkingBeatmap beatmap)
|
||||||
{
|
{
|
||||||
|
beatmap.Mods.BindTo(SelectedMods);
|
||||||
|
|
||||||
Logger.Log($"working beatmap updated to {beatmap}");
|
Logger.Log($"working beatmap updated to {beatmap}");
|
||||||
|
|
||||||
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
|
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
|
||||||
@ -491,6 +568,11 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
|
|
||||||
beatmapInfoWedge.Beatmap = beatmap;
|
beatmapInfoWedge.Beatmap = beatmap;
|
||||||
|
|
||||||
|
BeatmapDetails.Beatmap = beatmap;
|
||||||
|
|
||||||
|
if (beatmap.Track != null)
|
||||||
|
beatmap.Track.Looping = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensurePlayingSelected(bool preview = false)
|
private void ensurePlayingSelected(bool preview = false)
|
||||||
|
@ -16,8 +16,8 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
public event Action SourceChanged;
|
public event Action SourceChanged;
|
||||||
|
|
||||||
private Bindable<bool> beatmapSkins = new Bindable<bool>();
|
private readonly Bindable<bool> beatmapSkins = new Bindable<bool>();
|
||||||
private Bindable<bool> beatmapHitsounds = new Bindable<bool>();
|
private readonly Bindable<bool> beatmapHitsounds = new Bindable<bool>();
|
||||||
|
|
||||||
public Drawable GetDrawableComponent(string componentName)
|
public Drawable GetDrawableComponent(string componentName)
|
||||||
{
|
{
|
||||||
@ -84,11 +84,8 @@ namespace osu.Game.Skinning
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
beatmapSkins = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
|
config.BindWith(OsuSetting.BeatmapSkins, beatmapSkins);
|
||||||
beatmapSkins.BindValueChanged(_ => onSourceChanged());
|
config.BindWith(OsuSetting.BeatmapHitsounds, beatmapHitsounds);
|
||||||
|
|
||||||
beatmapHitsounds = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
|
|
||||||
beatmapHitsounds.BindValueChanged(_ => onSourceChanged(), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -97,6 +94,9 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
if (fallbackSource != null)
|
if (fallbackSource != null)
|
||||||
fallbackSource.SourceChanged += onSourceChanged;
|
fallbackSource.SourceChanged += onSourceChanged;
|
||||||
|
|
||||||
|
beatmapSkins.BindValueChanged(_ => onSourceChanged());
|
||||||
|
beatmapHitsounds.BindValueChanged(_ => onSourceChanged(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -3,17 +3,29 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
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.Cursor;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
|
||||||
namespace osu.Game.Users
|
namespace osu.Game.Users
|
||||||
{
|
{
|
||||||
public class Avatar : Container
|
public class Avatar : Container
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to open the user's profile when clicked.
|
||||||
|
/// </summary>
|
||||||
|
public readonly BindableBool OpenOnClick = new BindableBool(true);
|
||||||
|
|
||||||
private readonly User user;
|
private readonly User user;
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private OsuGame game { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An avatar for specified user.
|
/// An avatar for specified user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -33,14 +45,43 @@ namespace osu.Game.Users
|
|||||||
if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
|
if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
|
||||||
if (texture == null) texture = textures.Get(@"Online/avatar-guest");
|
if (texture == null) texture = textures.Get(@"Online/avatar-guest");
|
||||||
|
|
||||||
Add(new Sprite
|
ClickableArea clickableArea;
|
||||||
|
Add(clickableArea = new ClickableArea
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Texture = texture,
|
Child = new Sprite
|
||||||
FillMode = FillMode.Fit,
|
{
|
||||||
Anchor = Anchor.Centre,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Origin = Anchor.Centre
|
Texture = texture,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
|
},
|
||||||
|
Action = openProfile
|
||||||
});
|
});
|
||||||
|
|
||||||
|
clickableArea.Enabled.BindTo(OpenOnClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openProfile()
|
||||||
|
{
|
||||||
|
if (!OpenOnClick)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (user != null)
|
||||||
|
game?.ShowUser(user.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ClickableArea : OsuClickableContainer, IHasTooltip
|
||||||
|
{
|
||||||
|
public string TooltipText => Enabled.Value ? @"View Profile" : null;
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
if (!Enabled)
|
||||||
|
return false;
|
||||||
|
return base.OnClick(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
@ -35,6 +36,11 @@ namespace osu.Game.Users
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to open the user's profile when clicked.
|
||||||
|
/// </summary>
|
||||||
|
public readonly BindableBool OpenOnClick = new BindableBool(true);
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -45,15 +51,18 @@ namespace osu.Game.Users
|
|||||||
{
|
{
|
||||||
displayedAvatar?.FadeOut(300);
|
displayedAvatar?.FadeOut(300);
|
||||||
displayedAvatar?.Expire();
|
displayedAvatar?.Expire();
|
||||||
|
|
||||||
if (user != null || ShowGuestOnNull)
|
if (user != null || ShowGuestOnNull)
|
||||||
{
|
{
|
||||||
Add(displayedAvatar = new DelayedLoadWrapper(
|
var avatar = new Avatar(user)
|
||||||
new Avatar(user)
|
{
|
||||||
{
|
RelativeSizeAxes = Axes.Both,
|
||||||
RelativeSizeAxes = Axes.Both,
|
OnLoadComplete = d => d.FadeInFromZero(300, Easing.OutQuint),
|
||||||
OnLoadComplete = d => d.FadeInFromZero(300, Easing.OutQuint),
|
};
|
||||||
})
|
|
||||||
);
|
avatar.OpenOnClick.BindTo(OpenOnClick);
|
||||||
|
|
||||||
|
Add(displayedAvatar = new DelayedLoadWrapper(avatar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,7 @@ namespace osu.Game.Users
|
|||||||
User = user,
|
User = user,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
CornerRadius = 5,
|
CornerRadius = 5,
|
||||||
|
OpenOnClick = { Value = false },
|
||||||
EdgeEffect = new EdgeEffectParameters
|
EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Type = EdgeEffectType.Shadow,
|
Type = EdgeEffectType.Shadow,
|
||||||
|
Loading…
Reference in New Issue
Block a user